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(1): remove dead code from GetVarnamesToUne...
details: https://anonhg.NetBSD.org/src/rev/4d715264017b
branches: trunk
changeset: 1017120:4d715264017b
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 13 02:15:49 2020 +0000
description:
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.
diffstat:
usr.bin/make/nonints.h | 4 ++--
usr.bin/make/parse.c | 12 +++++++-----
usr.bin/make/var.c | 32 +++++++++++---------------------
3 files changed, 20 insertions(+), 28 deletions(-)
diffs (126 lines):
diff -r 0b6d64944dcd -r 4d715264017b usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Sun Dec 13 02:09:55 2020 +0000
+++ b/usr.bin/make/nonints.h Sun Dec 13 02:15:49 2020 +0000
@@ -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_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);
diff -r 0b6d64944dcd -r 4d715264017b usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Dec 13 02:09:55 2020 +0000
+++ b/usr.bin/make/parse.c Sun Dec 13 02:15:49 2020 +0000
@@ -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 @@
} 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))
diff -r 0b6d64944dcd -r 4d715264017b usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Dec 13 02:09:55 2020 +0000
+++ b/usr.bin/make/var.c Sun Dec 13 02:15:49 2020 +0000
@@ -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 @@
}
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;
+ } else {
+ what = arg[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);
+ FStr_Assign(&varnames, arg, NULL);
}
if (what != UNEXPORT_NAMED) {
@@ -838,12 +828,12 @@
* 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);
}
Home |
Main Index |
Thread Index |
Old Index