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: remove unnecessary functions for expandin...



details:   https://anonhg.NetBSD.org/src/rev/ef9dd89c8a30
branches:  trunk
changeset: 359658:ef9dd89c8a30
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 15 19:05:23 2022 +0000

description:
make: remove unnecessary functions for expanding variable names

In meta mode, the affected variable patterns do not contain a '$'.

Outside of meta mode, Global_SetExpand was only called a single time, so
inline that call.

No functional change.

diffstat:

 usr.bin/make/main.c    |   6 +++---
 usr.bin/make/meta.c    |  18 +++++++++---------
 usr.bin/make/nonints.h |   4 +---
 usr.bin/make/var.c     |  25 ++-----------------------
 4 files changed, 15 insertions(+), 38 deletions(-)

diffs (166 lines):

diff -r af6e1f7b2161 -r ef9dd89c8a30 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Jan 15 18:45:13 2022 +0000
+++ b/usr.bin/make/main.c       Sat Jan 15 19:05:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.570 2022/01/15 18:34:41 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.571 2022/01/15 19:05:23 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.570 2022/01/15 18:34:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.571 2022/01/15 19:05:23 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -452,7 +452,7 @@
        case 'D':
                if (argvalue[0] == '\0')
                        return false;
-               Global_SetExpand(argvalue, "1");
+               Var_SetExpand(SCOPE_GLOBAL, argvalue, "1");
                Global_Append(MAKEFLAGS, "-D");
                Global_Append(MAKEFLAGS, argvalue);
                break;
diff -r af6e1f7b2161 -r ef9dd89c8a30 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Jan 15 18:45:13 2022 +0000
+++ b/usr.bin/make/meta.c       Sat Jan 15 19:05:23 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.190 2022/01/15 18:34:41 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.191 2022/01/15 19:05:23 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1268,8 +1268,8 @@
 
                        if (lastpid > 0) {
                            /* We need to remember these. */
-                           Global_SetExpand(lcwd_vname, lcwd);
-                           Global_SetExpand(ldir_vname, latestdir);
+                           Global_Set(lcwd_vname, lcwd);
+                           Global_Set(ldir_vname, latestdir);
                        }
                        snprintf(lcwd_vname, sizeof lcwd_vname, LCWD_VNAME_FMT, pid);
                        snprintf(ldir_vname, sizeof ldir_vname, LDIR_VNAME_FMT, pid);
@@ -1302,8 +1302,8 @@
                /* Process according to record type. */
                switch (buf[0]) {
                case 'X':               /* eXit */
-                   Var_DeleteExpand(SCOPE_GLOBAL, lcwd_vname);
-                   Var_DeleteExpand(SCOPE_GLOBAL, ldir_vname);
+                   Var_Delete(SCOPE_GLOBAL, lcwd_vname);
+                   Var_Delete(SCOPE_GLOBAL, ldir_vname);
                    lastpid = 0;        /* no need to save ldir_vname */
                    break;
 
@@ -1315,9 +1315,9 @@
                        child = atoi(p);
                        if (child > 0) {
                            snprintf(cldir, sizeof cldir, LCWD_VNAME_FMT, child);
-                           Global_SetExpand(cldir, lcwd);
+                           Global_Set(cldir, lcwd);
                            snprintf(cldir, sizeof cldir, LDIR_VNAME_FMT, child);
-                           Global_SetExpand(cldir, latestdir);
+                           Global_Set(cldir, latestdir);
 #ifdef DEBUG_META_MODE
                            if (DEBUG(META))
                                debug_printf(
@@ -1333,8 +1333,8 @@
                    /* Update lcwd and latest directory. */
                    strlcpy(latestdir, p, sizeof latestdir);
                    strlcpy(lcwd, p, sizeof lcwd);
-                   Global_SetExpand(lcwd_vname, lcwd);
-                   Global_SetExpand(ldir_vname, lcwd);
+                   Global_Set(lcwd_vname, lcwd);
+                   Global_Set(ldir_vname, lcwd);
 #ifdef DEBUG_META_MODE
                    DEBUG4(META, "%s: %d: cwd=%s ldir=%s\n",
                           fname, lineno, cwd, lcwd);
diff -r af6e1f7b2161 -r ef9dd89c8a30 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Jan 15 18:45:13 2022 +0000
+++ b/usr.bin/make/nonints.h    Sat Jan 15 19:05:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.238 2022/01/15 18:34:41 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.239 2022/01/15 19:05:23 rillig Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -296,7 +296,6 @@
 } VarExportMode;
 
 void Var_Delete(GNode *, const char *);
-void Var_DeleteExpand(GNode *, const char *);
 void Var_Undef(const char *);
 void Var_Set(GNode *, const char *, const char *);
 void Var_SetExpand(GNode *, const char *, const char *);
@@ -319,7 +318,6 @@
 void Var_UnExport(bool, const char *);
 
 void Global_Set(const char *, const char *);
-void Global_SetExpand(const char *, const char *);
 void Global_Append(const char *, const char *);
 void Global_Delete(const char *);
 
diff -r af6e1f7b2161 -r ef9dd89c8a30 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Jan 15 18:45:13 2022 +0000
+++ b/usr.bin/make/var.c        Sat Jan 15 19:05:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.1001 2022/01/15 18:34:41 rillig Exp $        */
+/*     $NetBSD: var.c,v 1.1002 2022/01/15 19:05:23 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -103,7 +103,6 @@
  *     Var_Parse       Parse a variable expression such as ${VAR:Mpattern}.
  *
  *     Var_Delete
- *     Var_DeleteExpand
  *                     Delete a variable.
  *
  *     Var_ReexportVars
@@ -140,7 +139,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1001 2022/01/15 18:34:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1002 2022/01/15 19:05:23 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -522,20 +521,6 @@
 }
 
 /*
- * Remove a variable from a scope, freeing all related memory as well.
- * The variable name is expanded once.
- */
-void
-Var_DeleteExpand(GNode *scope, const char *name)
-{
-       FStr varname = FStr_InitRefer(name);
-
-       Var_Expand(&varname, SCOPE_GLOBAL, VARE_WANTRES);
-       Var_Delete(scope, varname.str);
-       FStr_Done(&varname);
-}
-
-/*
  * Undefine one or more variables from the global scope.
  * The argument is expanded exactly once and then split into words.
  */
@@ -1085,12 +1070,6 @@
 }
 
 void
-Global_SetExpand(const char *name, const char *value)
-{
-       Var_SetExpand(SCOPE_GLOBAL, name, value);
-}
-
-void
 Global_Delete(const char *name)
 {
        Var_Delete(SCOPE_GLOBAL, name);



Home | Main Index | Thread Index | Old Index