From 4273a431f02dfe0a7c26b3afe6d9579bdb4bc739 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 13 Sep 2020 09:43:01 +0000 Subject: [PATCH] make(1): inline strchr call in IsInclude --- usr.bin/make/parse.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 6d0420e9c132..897216e2b97f 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.297 2020/09/13 09:25:52 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.298 2020/09/13 09:43:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.297 2020/09/13 09:25:52 rillig Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.298 2020/09/13 09:43:01 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.297 2020/09/13 09:25:52 rillig Exp $"); +__RCSID("$NetBSD: parse.c,v 1.298 2020/09/13 09:43:01 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -2422,19 +2422,16 @@ Parse_SetInput(const char *name, int line, int fd, /* Check if the line is an include directive. */ static Boolean -IsInclude(const char *line, Boolean sysv) +IsInclude(const char *dir, Boolean sysv) { - static const char inc[] = "include"; - static const size_t inclen = sizeof(inc) - 1; + if (dir[0] == 's' || dir[0] == '-' || (dir[0] == 'd' && !sysv)) + dir++; - /* 'd' is not valid for sysv */ - int o = strchr(sysv ? "s-" : "ds-", *line) != NULL; - - if (strncmp(line + o, inc, inclen) != 0) + if (strncmp(dir, "include", 7) != 0) return FALSE; /* Space is not mandatory for BSD .include */ - return !sysv || ch_isspace(line[inclen + o]); + return !sysv || ch_isspace(dir[7]); }