make: add shortcut Global_Delete for deleting a global variable

This commit is contained in:
rillig 2021-02-05 04:41:17 +00:00
parent 54ddcb24e6
commit 715bef6038
5 changed files with 26 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.268 2021/02/04 21:33:13 rillig Exp $ */
/* $NetBSD: dir.c,v 1.269 2021/02/05 04:41:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -138,7 +138,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
MAKE_RCSID("$NetBSD: dir.c,v 1.268 2021/02/04 21:33:13 rillig Exp $");
MAKE_RCSID("$NetBSD: dir.c,v 1.269 2021/02/05 04:41:17 rillig Exp $");
/*
* A search path is a list of CachedDir structures. A CachedDir has in it the
@ -549,7 +549,7 @@ Dir_SetPATH(void)
CachedDirListNode *ln;
Boolean seenDotLast = FALSE; /* true if we should search '.' last */
Var_Delete(".PATH", SCOPE_GLOBAL);
Global_Delete(".PATH");
if ((ln = dirSearchPath.dirs.first) != NULL) {
CachedDir *dir = ln->datum;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.530 2021/02/04 21:33:13 rillig Exp $ */
/* $NetBSD: main.c,v 1.531 2021/02/05 04:41:17 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.530 2021/02/04 21:33:13 rillig Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.531 2021/02/05 04:41:17 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@ -2105,7 +2105,7 @@ SetErrorVars(GNode *gn)
* We can print this even if there is no .ERROR target.
*/
Global_Set(".ERROR_TARGET", gn->name);
Var_Delete(".ERROR_CMD", SCOPE_GLOBAL);
Global_Delete(".ERROR_CMD");
for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
const char *cmd = ln->datum;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.200 2021/02/04 21:50:39 rillig Exp $ */
/* $NetBSD: nonints.h,v 1.201 2021/02/05 04:41:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -393,6 +393,7 @@ void Var_UnExport(Boolean, 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 *);
/* util.c */
typedef void (*SignalProc)(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.546 2021/02/04 21:42:46 rillig Exp $ */
/* $NetBSD: parse.c,v 1.547 2021/02/05 04:41:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -109,7 +109,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.546 2021/02/04 21:42:46 rillig Exp $");
MAKE_RCSID("$NetBSD: parse.c,v 1.547 2021/02/05 04:41:17 rillig Exp $");
/* types and constants */
@ -2321,8 +2321,8 @@ ParseSetParseFile(const char *filename)
SetFilenameVars(including,
".INCLUDEDFROMDIR", ".INCLUDEDFROMFILE");
} else {
Var_Delete(".INCLUDEDFROMDIR", SCOPE_GLOBAL);
Var_Delete(".INCLUDEDFROMFILE", SCOPE_GLOBAL);
Global_Delete(".INCLUDEDFROMDIR");
Global_Delete(".INCLUDEDFROMFILE");
}
}
@ -2594,10 +2594,10 @@ ParseEOF(void)
if (includes.len == 0) {
/* We've run out of input */
Var_Delete(".PARSEDIR", SCOPE_GLOBAL);
Var_Delete(".PARSEFILE", SCOPE_GLOBAL);
Var_Delete(".INCLUDEDFROMDIR", SCOPE_GLOBAL);
Var_Delete(".INCLUDEDFROMFILE", SCOPE_GLOBAL);
Global_Delete(".PARSEDIR");
Global_Delete(".PARSEFILE");
Global_Delete(".INCLUDEDFROMDIR");
Global_Delete(".INCLUDEDFROMFILE");
return FALSE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.803 2021/02/04 21:50:39 rillig Exp $ */
/* $NetBSD: var.c,v 1.804 2021/02/05 04:41:17 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.803 2021/02/04 21:50:39 rillig Exp $");
MAKE_RCSID("$NetBSD: var.c,v 1.804 2021/02/05 04:41:17 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@ -564,7 +564,7 @@ Var_Undef(const char *arg)
for (i = 0; i < varnames.len; i++) {
const char *varname = varnames.words[i];
Var_Delete(varname, SCOPE_GLOBAL);
Global_Delete(varname);
}
Words_Free(varnames);
@ -898,7 +898,7 @@ UnexportVars(FStr *varnames, UnexportWhat what)
Words_Free(words);
if (what != UNEXPORT_NAMED)
Var_Delete(MAKE_EXPORTED, SCOPE_GLOBAL);
Global_Delete(MAKE_EXPORTED);
}
/*
@ -1063,6 +1063,12 @@ Global_SetExpand(const char *name, const char *value)
Var_SetExpand(name, value, SCOPE_GLOBAL);
}
void
Global_Delete(const char *name)
{
Var_Delete(name, SCOPE_GLOBAL);
}
/*
* Append the value to the named variable.
*