Module Name: src
Committed By: rillig
Date: Wed Nov 4 02:26:21 UTC 2020
Modified Files:
src/usr.bin/make: var.c
Log Message:
make(1): replace emptyString with allocated empty string
Special-casing this variable only made the code more complicated.
Furthermore, it is not related to error handling in any way and
therefore distracted the reader from this topic.
To generate a diff of this commit:
cvs rdiff -u -r1.652 -r1.653 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/var.c
diff -u src/usr.bin/make/var.c:1.652 src/usr.bin/make/var.c:1.653
--- src/usr.bin/make/var.c:1.652 Mon Nov 2 21:34:40 2020
+++ src/usr.bin/make/var.c Wed Nov 4 02:26:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.652 2020/11/02 21:34:40 rillig Exp $ */
+/* $NetBSD: var.c,v 1.653 2020/11/04 02:26:21 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.652 2020/11/02 21:34:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.653 2020/11/04 02:26:21 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -157,11 +157,6 @@ char var_Error[] = "";
* be deferred until it is defined in an actual target. */
static char varUndefined[] = "";
-/* Special return value for Var_Parse, just to avoid allocating empty strings.
- * In contrast to var_Error and varUndefined, this is not an error marker but
- * just an ordinary successful return value. */
-static char emptyString[] = "";
-
/*
* Traditionally this make consumed $$ during := like any other expansion.
* Other make's do not, and this make follows straight since 2016-01-09.
@@ -2299,7 +2294,7 @@ ApplyModifier_ShellCommand(const char **
if (st->eflags & VARE_WANTRES)
st->newVal = Cmd_Exec(cmd, &errfmt);
else
- st->newVal = emptyString;
+ st->newVal = bmake_strdup("");
free(cmd);
if (errfmt != NULL)
@@ -3014,7 +3009,7 @@ ok:
}
}
free(val);
- st->newVal = emptyString;
+ st->newVal = bmake_strdup("");
return AMR_OK;
}
@@ -3138,7 +3133,7 @@ ApplyModifier_SunShell(const char **pp,
if (errfmt)
Error(errfmt, st->val);
} else
- st->newVal = emptyString;
+ st->newVal = bmake_strdup("");
*pp = p + 2;
return AMR_OK;
} else
@@ -3412,10 +3407,8 @@ ApplyModifiers(
*out_freeIt = NULL;
}
st.val = st.newVal;
- if (st.val != var_Error && st.val != varUndefined &&
- st.val != emptyString) {
+ if (st.val != var_Error && st.val != varUndefined)
*out_freeIt = st.val;
- }
}
if (*p == '\0' && st.endc != '\0') {
Error("Unclosed variable specification (expecting '%c') "