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): extract Var_Undef from ParseDirective



details:   https://anonhg.NetBSD.org/src/rev/e1023bec4b49
branches:  trunk
changeset: 979207:e1023bec4b49
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 20:16:36 2020 +0000

description:
make(1): extract Var_Undef from ParseDirective

diffstat:

 usr.bin/make/nonints.h |   3 ++-
 usr.bin/make/parse.c   |  11 +++--------
 usr.bin/make/var.c     |  18 ++++++++++++++++--
 3 files changed, 21 insertions(+), 11 deletions(-)

diffs (88 lines):

diff -r ce7628c4c635 -r e1023bec4b49 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Dec 19 19:49:01 2020 +0000
+++ b/usr.bin/make/nonints.h    Sat Dec 19 20:16:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.173 2020/12/18 14:36:46 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.174 2020/12/19 20:16:36 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -343,6 +343,7 @@
 } VarExportMode;
 
 void Var_Delete(const char *, GNode *);
+void Var_Undef(char *);
 void Var_Set(const char *, const char *, GNode *);
 void Var_SetWithFlags(const char *, const char *, GNode *, VarSetFlags);
 void Var_Append(const char *, const char *, GNode *);
diff -r ce7628c4c635 -r e1023bec4b49 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Dec 19 19:49:01 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Dec 19 20:16:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.501 2020/12/19 17:54:29 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.502 2020/12/19 20:16:36 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.501 2020/12/19 17:54:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.502 2020/12/19 20:16:36 rillig Exp $");
 
 /* types and constants */
 
@@ -3052,12 +3052,7 @@
        arg = cp;
 
        if (IsDirective(dir, dirlen, "undef")) {
-               for (; !ch_isspace(*cp) && *cp != '\0'; cp++)
-                       continue;
-               *cp = '\0';
-               Var_Delete(arg, VAR_GLOBAL);
-               /* TODO: undefine all variables, not only the first */
-               /* TODO: use Str_Words, like everywhere else */
+               Var_Undef(cp);
                return TRUE;
        } else if (IsDirective(dir, dirlen, "export")) {
                Var_Export(VEM_PARENT, arg);
diff -r ce7628c4c635 -r e1023bec4b49 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Dec 19 19:49:01 2020 +0000
+++ b/usr.bin/make/var.c        Sat Dec 19 20:16:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.734 2020/12/13 21:27:45 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.735 2020/12/19 20:16:36 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.734 2020/12/13 21:27:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.735 2020/12/19 20:16:36 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -519,6 +519,20 @@
        }
 }
 
+void
+Var_Undef(char *arg)
+{
+       char *cp = arg;
+
+       for (; !ch_isspace(*cp) && *cp != '\0'; cp++)
+               continue;
+       *cp = '\0';
+
+       Var_Delete(arg, VAR_GLOBAL);
+       /* TODO: undefine all variables, not only the first */
+       /* TODO: use Str_Words, like everywhere else */
+}
+
 static Boolean
 MayExport(const char *name)
 {



Home | Main Index | Thread Index | Old Index