Module Name:    src
Committed By:   christos
Date:           Fri Jun 19 14:25:34 UTC 2015

Modified Files:
        src/usr.bin/make: compat.c metachar.h

Log Message:
create needshell so we don't scan the string multiple times.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/metachar.h

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/compat.c
diff -u src/usr.bin/make/compat.c:1.98 src/usr.bin/make/compat.c:1.99
--- src/usr.bin/make/compat.c:1.98	Fri Jun 19 04:03:35 2015
+++ src/usr.bin/make/compat.c	Fri Jun 19 10:25:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $	*/
+/*	$NetBSD: compat.c,v 1.99 2015/06/19 14:25:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.99 2015/06/19 14:25:34 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.98 2015/06/19 08:03:35 mlelstv Exp $");
+__RCSID("$NetBSD: compat.c,v 1.99 2015/06/19 14:25:34 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -280,7 +280,7 @@ CompatRunCommand(void *cmdp, void *gnp)
      * meta characters as documented in make(1).
      */
     
-    useShell = hasmeta(cmd) || strchr(cmd,'=') || strchr(cmd,':');
+    useShell = needshell(cmd);
 #endif
 
     /*

Index: src/usr.bin/make/metachar.h
diff -u src/usr.bin/make/metachar.h:1.1 src/usr.bin/make/metachar.h:1.2
--- src/usr.bin/make/metachar.h:1.1	Wed Jun 17 11:34:55 2015
+++ src/usr.bin/make/metachar.h	Fri Jun 19 10:25:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: metachar.h,v 1.1 2015/06/17 15:34:55 christos Exp $	*/
+/*	$NetBSD: metachar.h,v 1.2 2015/06/19 14:25:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -46,6 +46,15 @@ hasmeta(const char *cmd)
 
 	return *cmd != '\0';
 }
+
+static inline int
+needshell(const char *cmd)
+{
+	while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=')
+		cmd++;
+
+	return *cmd != '\0';
+}
 __END_DECLS
 
 #endif /* _METACHAR_H */

Reply via email to