Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Use VAR_INTERNAL when calling ApplyModifiers fo...



details:   https://anonhg.NetBSD.org/src/rev/9e9de45eb662
branches:  trunk
changeset: 821276:9e9de45eb662
user:      sjg <sjg%NetBSD.org@localhost>
date:      Tue Jan 31 07:00:59 2017 +0000

description:
Use VAR_INTERNAL when calling ApplyModifiers for VAR_{CMD,GLOBAL} only.

diffstat:

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

diffs (65 lines):

diff -r 25b21c08d824 -r 9e9de45eb662 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Jan 31 06:54:23 2017 +0000
+++ b/usr.bin/make/var.c        Tue Jan 31 07:00:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.210 2017/01/30 02:46:20 sjg Exp $    */
+/*     $NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.210 2017/01/30 02:46:20 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg 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.210 2017/01/30 02:46:20 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3729,6 +3729,7 @@
 Var_Parse(const char *str, GNode *ctxt, int flags,
          int *lengthPtr, void **freePtr)
 {
+    GNode         *mctxt;
     const char    *tstr;       /* Pointer into str */
     Var                   *v;          /* Variable in invocation */
     Boolean        haveModifier;/* TRUE if have modifiers for the variable */
@@ -3746,6 +3747,12 @@
     const char     *extramodifiers; /* extra modifiers to apply first */
     char         name[2];
 
+    /*
+     * We can safely (and only need to?) use VAR_INTERNAL for modifiers
+     * (so correct $_ is found) if ctxt is any of VAR_CMD, VAR_GLOBAL
+     * or VAR_INTERNAL, otherwise leave it alone.
+     */
+    mctxt = (ctxt == VAR_GLOBAL || ctxt == VAR_CMD) ? VAR_INTERNAL : ctxt;
     *freePtr = NULL;
     extramodifiers = NULL;
     dynamic = FALSE;
@@ -3992,7 +3999,7 @@
        extraFree = NULL;
        if (extramodifiers != NULL) {
                nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
-                                     v, ctxt, flags, &used, &extraFree);
+                                     v, mctxt, flags, &used, &extraFree);
        }
 
        if (haveModifier) {
@@ -4000,7 +4007,7 @@
                tstr++;
 
                nstr = ApplyModifiers(nstr, tstr, startc, endc,
-                                     v, ctxt, flags, &used, freePtr);
+                                     v, mctxt, flags, &used, freePtr);
                tstr += used;
                free(extraFree);
        } else {



Home | Main Index | Thread Index | Old Index