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): migrate to Var_ParsePP in Var_Parse an...



details:   https://anonhg.NetBSD.org/src/rev/a32d9ba28b5a
branches:  trunk
changeset: 938397:a32d9ba28b5a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 07 07:10:56 2020 +0000

description:
make(1): migrate to Var_ParsePP in Var_Parse and Var_Subst

diffstat:

 usr.bin/make/var.c |  31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diffs (99 lines):

diff -r aff51dc546a4 -r a32d9ba28b5a usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Sep 07 07:10:43 2020 +0000
+++ b/usr.bin/make/var.c        Mon Sep 07 07:10:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.489 2020/09/07 07:04:30 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.490 2020/09/07 07:10:56 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.489 2020/09/07 07:04:30 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.490 2020/09/07 07:10:56 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.489 2020/09/07 07:04:30 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.490 2020/09/07 07:10:56 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3429,7 +3429,7 @@
         * Skip to the end character or a colon, whichever comes first.
         */
        depth = 1;
-       for (tstr = str + 2; *tstr != '\0'; tstr++) {
+       for (tstr = str + 2; *tstr != '\0';) {
            /* Track depth so we can spot parse errors. */
            if (*tstr == startc)
                depth++;
@@ -3441,15 +3441,14 @@
                break;
            /* A variable inside a variable, expand. */
            if (*tstr == '$') {
-               int rlen;
                void *freeIt;
-               const char *rval = Var_Parse(tstr, ctxt, eflags, &rlen,
-                                            &freeIt);
+               const char *rval = Var_ParsePP(&tstr, ctxt, eflags, &freeIt);
                Buf_AddStr(&namebuf, rval);
                free(freeIt);
-               tstr += rlen - 1;
-           } else
+           } else {
                Buf_AddByte(&namebuf, *tstr);
+               tstr++;
+           }
        }
        if (*tstr == ':') {
            haveModifier = TRUE;
@@ -3696,9 +3695,9 @@
                continue;
            Buf_AddBytesBetween(&buf, cp, str);
        } else {
-           int length;
+           const char *nested_str = str;
            void *freeIt;
-           const char *val = Var_Parse(str, ctxt, eflags, &length, &freeIt);
+           const char *val = Var_ParsePP(&nested_str, ctxt, eflags, &freeIt);
 
            if (val == var_Error || val == varNoError) {
                /*
@@ -3708,7 +3707,7 @@
                 * the string...
                 */
                if (oldVars) {
-                   str += length;
+                   str = nested_str;
                } else if ((eflags & VARE_UNDEFERR) || val == var_Error) {
                    /*
                     * If variable is undefined, complain and skip the
@@ -3717,18 +3716,18 @@
                     */
                    if (!errorReported) {
                        Parse_Error(PARSE_FATAL, "Undefined variable \"%.*s\"",
-                                   length, str);
+                                   (int)(size_t)(nested_str - str), str);
                    }
-                   str += length;
+                   str = nested_str;
                    errorReported = TRUE;
                } else {
                    Buf_AddByte(&buf, *str);
-                   str += 1;
+                   str++;
                }
            } else {
                size_t val_len;
 
-               str += length;
+               str = nested_str;
 
                val_len = strlen(val);
                Buf_AddBytes(&buf, val, val_len);



Home | Main Index | Thread Index | Old Index