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 UnexportVars from Var_UnExport



details:   https://anonhg.NetBSD.org/src/rev/661110b9447c
branches:  trunk
changeset: 946716:661110b9447c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 06 17:35:51 2020 +0000

description:
make(1): extract UnexportVars from Var_UnExport

diffstat:

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

diffs (64 lines):

diff -r 1e0cc6fad15d -r 661110b9447c usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Dec 06 17:29:27 2020 +0000
+++ b/usr.bin/make/var.c        Sun Dec 06 17:35:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.715 2020/12/06 17:27:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.716 2020/12/06 17:35:51 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -810,6 +810,22 @@
        }
 }
 
+static void
+UnexportVars(FStr *varnames, UnexportWhat what)
+{
+       size_t i;
+
+       Words words = Str_Words(varnames->str, FALSE);
+       for (i = 0; i < words.len; i++) {
+               const char *varname = words.words[i];
+               UnexportVar(varname, what);
+       }
+       Words_Free(words);
+
+       if (what != UNEXPORT_NAMED)
+               Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
+}
+
 /*
  * This is called when .unexport[-env] is seen.
  *
@@ -822,21 +838,7 @@
        FStr varnames;
 
        GetVarnamesToUnexport(str, &varnames, &what);
-
-       {
-               size_t i;
-
-               Words words = Str_Words(varnames.str, FALSE);
-               for (i = 0; i < words.len; i++) {
-                       const char *varname = words.words[i];
-                       UnexportVar(varname, what);
-               }
-               Words_Free(words);
-
-               if (what != UNEXPORT_NAMED)
-                       Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
-       }
-
+       UnexportVars(&varnames, what);
        FStr_Done(&varnames);
 }
 



Home | Main Index | Thread Index | Old Index