diff options
| author | rillig <rillig@NetBSD.org> | 2022-01-15 19:05:23 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2022-01-15 19:05:23 +0000 |
| commit | 74007c04e7e6907fa16fb9da8e2bc231817a5853 (patch) | |
| tree | 7801c53878183cd2cfb8e6cc8483c36abfa66d6a /usr.bin/make | |
| parent | 472663e928b067f52543b8b943468d6a4612a9a1 (diff) | |
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 (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/main.c | 6 | ||||
| -rw-r--r-- | usr.bin/make/meta.c | 18 | ||||
| -rw-r--r-- | usr.bin/make/nonints.h | 4 | ||||
| -rw-r--r-- | usr.bin/make/var.c | 25 |
4 files changed, 15 insertions, 38 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 5e62183c82f..ade0ae6d011 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -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 @@ MainParseArg(char c, const char *argvalue) 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 --git a/usr.bin/make/meta.c b/usr.bin/make/meta.c index ab068ae1723..9582779ae57 100644 --- a/usr.bin/make/meta.c +++ b/usr.bin/make/meta.c @@ -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 @@ meta_oodate(GNode *gn, bool oodate) 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 @@ meta_oodate(GNode *gn, bool oodate) /* 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 @@ meta_oodate(GNode *gn, bool oodate) 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 @@ meta_oodate(GNode *gn, bool oodate) /* 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 --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index 76d14eb6295..51969b01046 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -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 @@ typedef enum VarExportMode { } 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_ExportVars(const char *); 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 --git a/usr.bin/make/var.c b/usr.bin/make/var.c index fb1f9b91353..e87e04cb1cc 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -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 @@ Var_Delete(GNode *scope, const char *varname) } /* - * 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 @@ Global_Set(const char *name, const char *value) } 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); |
