summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-03-01 07:58:18 +0000
committerharti <harti@FreeBSD.org>2005-03-01 07:58:18 +0000
commit6db6af010a98fbe3e559af60594dbc13c43c2040 (patch)
tree2360793dc15d7c5d2ed97f588ffc5c8254d3d945 /usr.bin/make
parentca5e477ca2bce8c6983ba3d48bdec85ca0c8fd37 (diff)
downloadFreeBSD-src-6db6af010a98fbe3e559af60594dbc13c43c2040.zip
FreeBSD-src-6db6af010a98fbe3e559af60594dbc13c43c2040.tar.gz
Reverse a condition so that the else clause can be changed
to a fallthrough. Patch: 7.82 Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/var.c77
1 files changed, 38 insertions, 39 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index fb7ae0f..c0a5898 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1679,55 +1679,23 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
}
}
+/**
+ * If it's not bounded by braces of some sort, life is much simpler.
+ * We just need to check for the first character and return the value
+ * if it exists.
+ */
static char *
VarParseShort(const char input[], GNode *ctxt, Boolean err, size_t *lengthPtr,
Boolean *freePtr)
{
- /*
- * If it's not bounded by braces of some sort, life is much simpler.
- * We just need to check for the first character and return the value
- * if it exists.
- */
- Var *v; /* Variable in invocation */
char name[2];
+ Var *v;
name[0] = input[1];
name[1] = '\0';
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
- if (v == NULL) {
- if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
- /*
- * If substituting a local variable in a non-local
- * context, assume it's for dynamic source stuff. We
- * have to handle this specially and return the
- * longhand for the variable with the dollar sign
- * escaped so it makes it back to the caller. Only
- * four of the local variables are treated specially
- * as they are the only four that will be set when
- * dynamic sources are expanded.
- */
- /* XXX: It looks like $% and $! are reversed here */
- *freePtr = FALSE;
- *lengthPtr = 2;
- switch (input[1]) {
- case '@':
- return ("$(.TARGET)");
- case '%':
- return ("$(.ARCHIVE)");
- case '*':
- return ("$(.PREFIX)");
- case '!':
- return ("$(.MEMBER)");
- default:
- return (err ? var_Error : varNoError);
- }
- } else {
- *freePtr = FALSE;
- *lengthPtr = 2;
- return (err ? var_Error : varNoError);
- }
- } else {
+ if (v != NULL) {
char *result;
result = VarExpand(v, ctxt, err);
@@ -1740,6 +1708,37 @@ VarParseShort(const char input[], GNode *ctxt, Boolean err, size_t *lengthPtr,
*lengthPtr = 2;
return (result);
}
+
+ /*
+ * If substituting a local variable in a non-local context, assume
+ * it's for dynamic source stuff. We have to handle this specially
+ * and return the longhand for the variable with the dollar sign
+ * escaped so it makes it back to the caller. Only four of the local
+ * variables are treated specially as they are the only four that
+ * will be set when dynamic sources are expanded.
+ */
+ if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) {
+ *freePtr = FALSE;
+ *lengthPtr = 2;
+
+ /* XXX: It looks like $% and $! are reversed here */
+ switch (input[1]) {
+ case '@':
+ return ("$(.TARGET)");
+ case '%':
+ return ("$(.ARCHIVE)");
+ case '*':
+ return ("$(.PREFIX)");
+ case '!':
+ return ("$(.MEMBER)");
+ default:
+ return (err ? var_Error : varNoError);
+ }
+ }
+
+ *freePtr = FALSE;
+ *lengthPtr = 2;
+ return (err ? var_Error : varNoError);
}
/*-
OpenPOWER on IntegriCloud