Module Name:    src
Committed By:   rillig
Date:           Sat Aug  1 19:19:06 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): start nesting level in ApplyModifier_Match at 0

There is no need to start at 1, and starting at 0 generates smaller code
on x86_64.  Reordering the --nest and the following break would increase
the code size though, for unknown reasons.


To generate a diff of this commit:
cvs rdiff -u -r1.386 -r1.387 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.386 src/usr.bin/make/var.c:1.387
--- src/usr.bin/make/var.c:1.386	Sat Aug  1 18:36:49 2020
+++ src/usr.bin/make/var.c	Sat Aug  1 19:19:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.386 2020/08/01 18:36:49 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.387 2020/08/01 19:19:05 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2273,9 +2273,9 @@ ApplyModifier_Match(const char *mod, App
      * original brace level.
      * XXX This will likely not work right if $() and ${} are intermixed.
      */
-    int nest = 1;
+    int nest = 0;
     const char *p;
-    for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 1); p++) {
+    for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) {
 	if (*p == '\\' &&
 	    (p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) {
 	    if (!needSubst)
@@ -2289,7 +2289,7 @@ ApplyModifier_Match(const char *mod, App
 	    ++nest;
 	if (*p == ')' || *p == '}') {
 	    --nest;
-	    if (nest == 0)
+	    if (nest < 0)
 		break;
 	}
     }

Reply via email to