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): replace emptyString with allocated emp...
details: https://anonhg.NetBSD.org/src/rev/04c4648e4f6c
branches: trunk
changeset: 942019:04c4648e4f6c
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Nov 04 02:26:21 2020 +0000
description:
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.
diffstat:
usr.bin/make/var.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diffs (69 lines):
diff -r e4e2b8e6919f -r 04c4648e4f6c usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Nov 04 01:37:55 2020 +0000
+++ b/usr.bin/make/var.c Wed Nov 04 02:26:21 2020 +0000
@@ -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 @@
* 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 @@
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 @@
}
}
free(val);
- st->newVal = emptyString;
+ st->newVal = bmake_strdup("");
return AMR_OK;
}
@@ -3138,7 +3133,7 @@
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 @@
*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') "
Home |
Main Index |
Thread Index |
Old Index