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): rename variables cp2 to be more expres...



details:   https://anonhg.NetBSD.org/src/rev/eb443412153c
branches:  trunk
changeset: 1014534:eb443412153c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 25 20:48:23 2020 +0000

description:
make(1): rename variables cp2 to be more expressive

diffstat:

 usr.bin/make/cond.c  |  14 +++++++-------
 usr.bin/make/parse.c |  24 +++++++++++++-----------
 2 files changed, 20 insertions(+), 18 deletions(-)

diffs (100 lines):

diff -r 1116c98f5cc9 -r eb443412153c usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Sep 25 20:11:06 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Sep 25 20:48:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.151 2020/09/25 20:48:23 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.150 2020/09/25 15:54:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.151 2020/09/25 20:48:23 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -245,13 +245,13 @@
             * variable, so we don't need to do it. Nor do we return an error,
             * though perhaps we should...
             */
-           void *freeIt;
+           void *nestedVal_freeIt;
            VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
-           const char *cp2;
-           (void)Var_Parse(&p, VAR_CMD, eflags, &cp2, &freeIt);
+           const char *nestedVal;
+           (void)Var_Parse(&p, VAR_CMD, eflags, &nestedVal, &nestedVal_freeIt);
            /* TODO: handle errors */
-           Buf_AddStr(&argBuf, cp2);
-           free(freeIt);
+           Buf_AddStr(&argBuf, nestedVal);
+           free(nestedVal_freeIt);
            continue;
        }
        if (ch == '(')
diff -r 1116c98f5cc9 -r eb443412153c usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Sep 25 20:11:06 2020 +0000
+++ b/usr.bin/make/parse.c      Fri Sep 25 20:48:23 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.324 2020/09/24 07:11:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $");
 
 /* types and constants */
 
@@ -1923,11 +1923,11 @@
     if (DEBUG(LINT)) {
        if (type != VAR_SUBST && strchr(cp, '$') != NULL) {
            /* sanity check now */
-           char *cp2;
+           char *expandedValue;
 
-           (void)Var_Subst(cp, ctxt, VARE_ASSIGN, &cp2);
+           (void)Var_Subst(cp, ctxt, VARE_ASSIGN, &expandedValue);
            /* TODO: handle errors */
-           free(cp2);
+           free(expandedValue);
        }
     }
 
@@ -2925,21 +2925,23 @@
                 * On the other hand they can be suffix rules (.c.o: ...)
                 * or just dependencies for filenames that start '.'.
                 */
-               for (cp = line + 1; ch_isspace(*cp); cp++) {
+               for (cp = line + 1; ch_isspace(*cp); cp++)
                    continue;
-               }
                if (IsInclude(cp, FALSE)) {
                    ParseDoInclude(cp);
                    continue;
                }
                if (strncmp(cp, "undef", 5) == 0) {
-                   char *cp2;
+                   const char *varname;
                    for (cp += 5; ch_isspace(*cp); cp++)
                        continue;
-                   for (cp2 = cp; !ch_isspace(*cp2) && *cp2 != '\0'; cp2++)
+                   varname = cp;
+                   for (; !ch_isspace(*cp) && *cp != '\0'; cp++)
                        continue;
-                   *cp2 = '\0';
-                   Var_Delete(cp, VAR_GLOBAL);
+                   *cp = '\0';
+                   Var_Delete(varname, VAR_GLOBAL);
+                   /* TODO: undefine all variables, not only the first */
+                   /* TODO: use Str_Words, like everywhere else */
                    continue;
                } else if (strncmp(cp, "export", 6) == 0) {
                    for (cp += 6; ch_isspace(*cp); cp++)



Home | Main Index | Thread Index | Old Index