Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): start nesting level in ApplyModifier_M...



details:   https://anonhg.NetBSD.org/src/rev/dbad276652e2
branches:  trunk
changeset: 936691:dbad276652e2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 01 19:19:05 2020 +0000

description:
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.

diffstat:

 usr.bin/make/var.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 7e1815799530 -r dbad276652e2 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Aug 01 18:59:16 2020 +0000
+++ b/usr.bin/make/var.c        Sat Aug 01 19:19:05 2020 +0000
@@ -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 @@
      * 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 @@
            ++nest;
        if (*p == ')' || *p == '}') {
            --nest;
-           if (nest == 0)
+           if (nest < 0)
                break;
        }
     }



Home | Main Index | Thread Index | Old Index