Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Add Boolean wantit to Var_Parse and Var_Subst



details:   https://anonhg.NetBSD.org/src/rev/24b629db89bd
branches:  trunk
changeset: 340930:24b629db89bd
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sun Oct 11 04:51:24 2015 +0000

description:
Add Boolean wantit to Var_Parse and Var_Subst

wantit will be FALSE when we are just consuming to discard
in which case we skip "expensive" things like Cmd_Exec.

Reviewed by: christos

diffstat:

 usr.bin/make/arch.c                 |   14 +-
 usr.bin/make/compat.c               |    8 +-
 usr.bin/make/cond.c                 |   12 +-
 usr.bin/make/for.c                  |    8 +-
 usr.bin/make/job.c                  |   13 +-
 usr.bin/make/main.c                 |   32 ++++---
 usr.bin/make/make.c                 |    8 +-
 usr.bin/make/meta.c                 |   19 ++-
 usr.bin/make/nonints.h              |    6 +-
 usr.bin/make/parse.c                |   22 ++--
 usr.bin/make/suff.c                 |   10 +-
 usr.bin/make/unit-tests/varmisc.exp |   12 ++
 usr.bin/make/unit-tests/varmisc.mk  |   34 +++++++-
 usr.bin/make/var.c                  |  154 +++++++++++++++++++++--------------
 14 files changed, 215 insertions(+), 137 deletions(-)

diffs (truncated from 1138 to 300 lines):

diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/arch.c       Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $  */
+/*     $NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -261,7 +261,7 @@
            void        *freeIt;
            char        *result;
 
-           result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
+           result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt);
            if (freeIt)
                free(freeIt);
            if (result == var_Error) {
@@ -276,7 +276,7 @@
 
     *cp++ = '\0';
     if (subLibName) {
-       libName = Var_Subst(NULL, libName, ctxt, TRUE);
+       libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE);
     }
 
 
@@ -302,7 +302,7 @@
                void    *freeIt;
                char    *result;
 
-               result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
+               result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt);
                if (freeIt)
                    free(freeIt);
                if (result == var_Error) {
@@ -355,7 +355,7 @@
            char    *oldMemName = memName;
            size_t   sz;
 
-           memName = Var_Subst(NULL, memName, ctxt, TRUE);
+           memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE);
 
            /*
             * Now form an archive spec and recurse to deal with nested
diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/compat.c     Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.100 2015/06/19 14:32:04 christos Exp $    */
+/*     $NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg 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.100 2015/06/19 14:32:04 christos Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg 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.100 2015/06/19 14:32:04 christos Exp $");
+__RCSID("$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -210,7 +210,7 @@
     doIt = FALSE;
     
     cmdNode = Lst_Member(gn->commands, cmd);
-    cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
+    cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE);
 
     /*
      * brk_string will return an argv with a NULL in av[0], thus causing
diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/cond.c       Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $    */
+/*     $NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $");
+__RCSID("$NetBSD: cond.c,v 1.69 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -289,7 +289,7 @@
            int         len;
            void        *freeIt;
 
-           cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt);
+           cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, &len, &freeIt);
            Buf_AddBytes(&buf, strlen(cp2), cp2);
            if (freeIt)
                free(freeIt);
@@ -571,7 +571,7 @@
        case '$':
            /* if we are in quotes, then an undefined variable is ok */
            str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval),
-                           &len, freeIt);
+                           TRUE, &len, freeIt);
            if (str == var_Error) {
                if (*freeIt) {
                    free(*freeIt);
@@ -823,7 +823,7 @@
     /* We do all the work here and return the result as the length */
     *argPtr = NULL;
 
-    val = Var_Parse(cp - 1, VAR_CMD, FALSE, &length, &freeIt);
+    val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, &length, &freeIt);
     /*
      * Advance *linePtr to beyond the closing ). Note that
      * we subtract one because 'length' is calculated from 'cp - 1'.
diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/for.c
--- a/usr.bin/make/for.c        Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/for.c        Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $     */
+/*     $NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $     */
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)for.c      8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $");
+__RCSID("$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -216,7 +216,7 @@
      * We can't do the escapes here - because we don't know whether
      * we are substuting into ${...} or $(...).
      */
-    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
+    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE, TRUE);
 
     /*
      * Split into words allowing for quoted strings.
diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/job.c        Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $  */
+/*     $NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.180 2015/04/16 13:31:03 joerg Exp $");
+__RCSID("$NetBSD: job.c,v 1.181 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -702,7 +702,7 @@
 
     numCommands += 1;
 
-    cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
+    cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE, TRUE);
 
     cmdTemplate = "%s\n";
 
@@ -890,7 +890,7 @@
 static int
 JobSaveCommand(void *cmd, void *gn)
 {
-    cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE);
+    cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE, TRUE);
     (void)Lst_AtEnd(postCommands->commands, cmd);
     return(0);
 }
@@ -2178,7 +2178,8 @@
        Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0);
     }
 
-    targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0);
+    targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
+                          VAR_GLOBAL, FALSE, TRUE);
 }
 
 /*-
diff -r aaf13137b709 -r 24b629db89bd usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Oct 11 01:01:45 2015 +0000
+++ b/usr.bin/make/main.c       Sun Oct 11 04:51:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.233 2015/09/10 17:15:11 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.233 2015/09/10 17:15:11 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.233 2015/09/10 17:15:11 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.234 2015/10/11 04:51:24 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -692,7 +692,7 @@
        /* expand variable substitutions */
        if (strchr(path, '$') != 0) {
                snprintf(buf, MAXPATHLEN, "%s", path);
-               path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0);
+               path = p = Var_Subst(NULL, buf, VAR_GLOBAL, FALSE, TRUE);
        }
 
        if (path[0] != '/') {
@@ -775,7 +775,8 @@
     char *mp = NULL;
 
     if (!mode)
-       mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0);
+       mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}",
+                             VAR_GLOBAL, FALSE, TRUE);
 
     if (mode && *mode) {
        if (strstr(mode, "compat")) {
@@ -1217,7 +1218,7 @@
                            (char *)Lst_Datum(ln));
        } else {
            p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}",
-               VAR_CMD, 0);
+               VAR_CMD, FALSE, TRUE);
            if (p1) {
                (void)str2Lst_Append(makefiles, p1, NULL);
                (void)Lst_Find(makefiles, NULL, ReadMakefile);
@@ -1228,7 +1229,7 @@
        /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
        if (!noBuiltins || !printVars) {
            makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}",
-               VAR_CMD, 0);
+               VAR_CMD, FALSE, TRUE);



Home | Main Index | Thread Index | Old Index