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 ExportVarsExpand from Var_Export



details:   https://anonhg.NetBSD.org/src/rev/e4506cf06596
branches:  trunk
changeset: 979071:e4506cf06596
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 12 20:00:51 2020 +0000

description:
make(1): extract ExportVarsExpand from Var_Export

diffstat:

 usr.bin/make/var.c |  21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 55b2294beb30 -r e4506cf06596 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Dec 12 19:39:34 2020 +0000
+++ b/usr.bin/make/var.c        Sat Dec 12 20:00:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.727 2020/12/12 19:39:34 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.728 2020/12/12 20:00:51 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.727 2020/12/12 19:39:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.728 2020/12/12 20:00:51 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -694,6 +694,17 @@
        Words_Free(words);
 }
 
+static void
+ExportVarsExpand(const char *uvarnames, Boolean isExport, VarExportFlags flags)
+{
+       char *xvarnames;
+
+       (void)Var_Subst(uvarnames, VAR_GLOBAL, VARE_WANTRES, &xvarnames);
+       /* TODO: handle errors */
+       ExportVars(xvarnames, isExport, flags);
+       free(xvarnames);
+}
+
 /*
  * This is called when .export is seen or .MAKE.EXPORTED is modified.
  *
@@ -706,7 +717,6 @@
 Var_Export(const char *str, Boolean isExport)
 {
        VarExportFlags flags;
-       char *varnames;
 
        if (isExport && str[0] == '\0') {
                var_exportedVars = VAR_EXPORTED_ALL; /* use with caution! */
@@ -723,10 +733,7 @@
                flags = VAR_EXPORT_PARENT;
        }
 
-       (void)Var_Subst(str, VAR_GLOBAL, VARE_WANTRES, &varnames);
-       /* TODO: handle errors */
-       ExportVars(varnames, isExport, flags);
-       free(varnames);
+       ExportVarsExpand(str, isExport, flags);
 }
 
 



Home | Main Index | Thread Index | Old Index