Module Name: src
Committed By: rillig
Date: Sun Sep 13 09:43:01 UTC 2020
Modified Files:
src/usr.bin/make: parse.c
Log Message:
make(1): inline strchr call in IsInclude
To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/usr.bin/make/parse.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.297 src/usr.bin/make/parse.c:1.298
--- src/usr.bin/make/parse.c:1.297 Sun Sep 13 09:25:52 2020
+++ src/usr.bin/make/parse.c Sun Sep 13 09:43:01 2020
@@ -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 <sys/cdefs.h>
#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 lin
/* 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]);
}