Module Name: src
Committed By: rillig
Date: Sun Dec 13 02:15:49 UTC 2020
Modified Files:
src/usr.bin/make: nonints.h parse.c var.c
Log Message:
make(1): remove dead code from GetVarnamesToUnexport
Now that the parsing of the directives is unified and strict, there is
no need anymore for the dispatched functions to check for unknown
directives. These functions don't even get the information to decide
that since this decision is already done.
To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.478 -r1.479 src/usr.bin/make/parse.c
cvs rdiff -u -r1.731 -r1.732 src/usr.bin/make/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.169 src/usr.bin/make/nonints.h:1.170
--- src/usr.bin/make/nonints.h:1.169 Sun Dec 13 01:41:12 2020
+++ src/usr.bin/make/nonints.h Sun Dec 13 02:15:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.169 2020/12/13 01:41:12 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.170 2020/12/13 02:15:49 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -335,7 +335,7 @@ void Var_Dump(GNode *);
void Var_ReexportVars(void);
void Var_Export(VarExportMode, const char *);
void Var_ExportVars(const char *);
-void Var_UnExport(const char *);
+void Var_UnExport(Boolean, const char *);
/* util.c */
typedef void (*SignalProc)(int);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.478 src/usr.bin/make/parse.c:1.479
--- src/usr.bin/make/parse.c:1.478 Sun Dec 13 02:01:43 2020
+++ src/usr.bin/make/parse.c Sun Dec 13 02:15:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.479 2020/12/13 02:15:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.479 2020/12/13 02:15:49 rillig Exp $");
/* types and constants */
@@ -2998,9 +2998,11 @@ ParseDirective(char *line)
} else if (IsDirective(dir, dirlen, "export-literal")) {
Var_Export(VEM_LITERAL, arg);
return TRUE;
- } else if (IsDirective(dir, dirlen, "unexport") ||
- IsDirective(dir, dirlen, "unexport-env")) {
- Var_UnExport(dir);
+ } else if (IsDirective(dir, dirlen, "unexport")) {
+ Var_UnExport(FALSE, arg);
+ return TRUE;
+ } else if (IsDirective(dir, dirlen, "unexport-env")) {
+ Var_UnExport(TRUE, arg);
return TRUE;
} else if (IsDirective(dir, dirlen, "info")) {
if (ParseMessage(PARSE_INFO, arg))
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.731 src/usr.bin/make/var.c:1.732
--- src/usr.bin/make/var.c:1.731 Sun Dec 13 01:41:12 2020
+++ src/usr.bin/make/var.c Sun Dec 13 02:15:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.731 2020/12/13 01:41:12 rillig Exp $ */
+/* $NetBSD: var.c,v 1.732 2020/12/13 02:15:49 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.731 2020/12/13 01:41:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.732 2020/12/13 02:15:49 rillig Exp $");
/* A string that may need to be freed after use. */
typedef struct FStr {
@@ -740,34 +740,24 @@ ClearEnv(void)
}
static void
-GetVarnamesToUnexport(const char *directive,
+GetVarnamesToUnexport(Boolean isEnv, const char *arg,
FStr *out_varnames, UnexportWhat *out_what)
{
UnexportWhat what;
FStr varnames = FSTR_INIT;
- const char *p = directive;
- p += strlen("unexport");
- if (strncmp(p, "-env", 4) == 0) {
- if (ch_isspace(p[4])) {
+ if (isEnv) {
+ if (arg[0] != '\0') {
Parse_Error(PARSE_FATAL,
"The directive .unexport-env does not take "
"arguments");
- } else if (p[4] != '\0') {
- Parse_Error(PARSE_FATAL,
- "Unknown directive \"%s\"", directive);
}
what = UNEXPORT_ENV;
- } else if (*p == '\0' || ch_isspace(*p)) {
- cpp_skip_whitespace(&p);
- what = p[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
- if (what == UNEXPORT_NAMED)
- FStr_Assign(&varnames, p, NULL);
} else {
- Parse_Error(PARSE_FATAL, "Unknown directive \"%s\"", directive);
- what = UNEXPORT_NAMED;
- FStr_Assign(&varnames, "", NULL);
+ what = arg[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
+ if (what == UNEXPORT_NAMED)
+ FStr_Assign(&varnames, arg, NULL);
}
if (what != UNEXPORT_NAMED) {
@@ -838,12 +828,12 @@ UnexportVars(FStr *varnames, UnexportWha
* str must have the form "unexport[-env] varname...".
*/
void
-Var_UnExport(const char *str)
+Var_UnExport(Boolean isEnv, const char *arg)
{
UnexportWhat what;
FStr varnames;
- GetVarnamesToUnexport(str, &varnames, &what);
+ GetVarnamesToUnexport(isEnv, arg, &varnames, &what);
UnexportVars(&varnames, what);
FStr_Done(&varnames);
}