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: inline functions that have a single call ...



details:   https://anonhg.NetBSD.org/src/rev/ae5a698b1f63
branches:  trunk
changeset: 359868:ae5a698b1f63
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 29 01:07:31 2022 +0000

description:
make: inline functions that have a single call site

No functional change.

diffstat:

 usr.bin/make/make.h  |   3 +--
 usr.bin/make/parse.c |  24 ++++++------------------
 usr.bin/make/var.c   |  44 ++++++++++++++++++--------------------------
 3 files changed, 25 insertions(+), 46 deletions(-)

diffs (167 lines):

diff -r 23f359f828d5 -r ae5a698b1f63 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Sat Jan 29 00:52:53 2022 +0000
+++ b/usr.bin/make/make.h       Sat Jan 29 01:07:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.291 2022/01/27 06:02:59 sjg Exp $   */
+/*     $NetBSD: make.h,v 1.292 2022/01/29 01:07:31 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -987,7 +987,6 @@
 void Var_Set(GNode *, const char *, const char *);
 void Var_SetExpand(GNode *, const char *, const char *);
 void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags);
-void Var_SetExpandWithFlags(GNode *, const char *, const char *, VarSetFlags);
 void Var_Append(GNode *, const char *, const char *);
 void Var_AppendExpand(GNode *, const char *, const char *);
 bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE;
diff -r 23f359f828d5 -r ae5a698b1f63 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Jan 29 00:52:53 2022 +0000
+++ b/usr.bin/make/parse.c      Sat Jan 29 01:07:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.657 2022/01/27 10:34:55 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.658 2022/01/29 01:07:31 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.657 2022/01/27 10:34:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.658 2022/01/29 01:07:31 rillig Exp $");
 
 /*
  * A file being read.
@@ -188,7 +188,7 @@
 } VarAssign;
 
 static bool Parse_IsVar(const char *, VarAssign *);
-static void Parse_Var_Keep(VarAssign *, GNode *);
+static void Parse_Var(VarAssign *, GNode *);
 
 /*
  * The target to be made if no targets are specified in the command line.
@@ -1282,18 +1282,12 @@
 }
 
 static void
-LinkSourceVar(GNode *pgn, VarAssign *var)
-{
-       Parse_Var_Keep(var, pgn);
-}
-
-static void
 LinkVarToTargets(VarAssign *var)
 {
        GNodeListNode *ln;
 
        for (ln = targets->first; ln != NULL; ln = ln->next)
-               LinkSourceVar(ln->datum, var);
+               Parse_Var(var, ln->datum);
 }
 
 static bool
@@ -1725,7 +1719,7 @@
 
 /* Perform the variable assignment in the given scope. */
 static void
-Parse_Var_Keep(VarAssign *var, GNode *scope)
+Parse_Var(VarAssign *var, GNode *scope)
 {
        FStr avalue;            /* actual value (maybe expanded) */
 
@@ -1736,13 +1730,6 @@
        }
 }
 
-static void
-Parse_Var(VarAssign *var, GNode *scope)
-{
-       Parse_Var_Keep(var, scope);
-       free(var->varname);
-}
-
 
 /*
  * See if the command possibly calls a sub-make by using the variable
@@ -2718,6 +2705,7 @@
        if (finishDependencyGroup)
                FinishDependencyGroup();
        Parse_Var(&var, scope);
+       free(var.varname);
        return true;
 }
 
diff -r 23f359f828d5 -r ae5a698b1f63 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Jan 29 00:52:53 2022 +0000
+++ b/usr.bin/make/var.c        Sat Jan 29 01:07:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.1006 2022/01/27 06:02:59 sjg Exp $   */
+/*     $NetBSD: var.c,v 1.1007 2022/01/29 01:07:31 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1006 2022/01/27 06:02:59 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1007 2022/01/29 01:07:31 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1018,29 +1018,6 @@
                VarFreeShortLived(v);
 }
 
-/* See Var_Set for documentation. */
-void
-Var_SetExpandWithFlags(GNode *scope, const char *name, const char *val,
-                      VarSetFlags flags)
-{
-       const char *unexpanded_name = name;
-       FStr varname = FStr_InitRefer(name);
-
-       assert(val != NULL);
-
-       Var_Expand(&varname, scope, VARE_WANTRES);
-
-       if (varname.str[0] == '\0') {
-               DEBUG2(VAR,
-                   "Var_SetExpand: variable name \"%s\" expands "
-                   "to empty string, with value \"%s\" - ignored\n",
-                   unexpanded_name, val);
-       } else
-               Var_SetWithFlags(scope, varname.str, val, flags);
-
-       FStr_Done(&varname);
-}
-
 void
 Var_Set(GNode *scope, const char *name, const char *val)
 {
@@ -1061,7 +1038,22 @@
 void
 Var_SetExpand(GNode *scope, const char *name, const char *val)
 {
-       Var_SetExpandWithFlags(scope, name, val, VAR_SET_NONE);
+       const char *unexpanded_name = name;
+       FStr varname = FStr_InitRefer(name);
+
+       assert(val != NULL);
+
+       Var_Expand(&varname, scope, VARE_WANTRES);
+
+       if (varname.str[0] == '\0') {
+               DEBUG2(VAR,
+                   "Var_SetExpand: variable name \"%s\" expands "
+                   "to empty string, with value \"%s\" - ignored\n",
+                   unexpanded_name, val);
+       } else
+               Var_SetWithFlags(scope, varname.str, val, VAR_SET_NONE);
+
+       FStr_Done(&varname);
 }
 
 void



Home | Main Index | Thread Index | Old Index