version 1.736, 2020/12/19 20:47:24 |
version 1.737, 2020/12/19 22:10:17 |
Line 531 Var_Delete(const char *name, GNode *ctxt |
|
Line 531 Var_Delete(const char *name, GNode *ctxt |
|
Var_DeleteVar(name, ctxt); |
Var_DeleteVar(name, ctxt); |
} |
} |
|
|
|
/* |
|
* Undefine a single variable from the global scope. The argument is |
|
* expanded once. |
|
*/ |
void |
void |
Var_Undef(char *arg) |
Var_Undef(char *arg) |
{ |
{ |
|
/* |
|
* The argument must consist of exactly 1 word. Accepting more than |
|
* 1 word would have required to split the argument into several |
|
* words, and such splitting is already done subtly different in many |
|
* other places of make. |
|
* |
|
* Using Str_Words to split the words, followed by Var_Subst to expand |
|
* each variable name once would make it impossible to undefine |
|
* variables whose names contain space characters or unbalanced |
|
* quotes or backslashes in arbitrary positions. |
|
* |
|
* Using Var_Subst on the whole argument and splitting the words |
|
* afterwards using Str_Words would make it impossible to undefine |
|
* variables whose names contain space characters. |
|
*/ |
char *cp = arg; |
char *cp = arg; |
|
|
for (; !ch_isspace(*cp) && *cp != '\0'; cp++) |
for (; !ch_isspace(*cp) && *cp != '\0'; cp++) |
continue; |
continue; |
|
if (cp == arg || *cp != '\0') { |
|
Parse_Error(PARSE_FATAL, |
|
"The .undef directive requires exactly 1 argument"); |
|
} |
*cp = '\0'; |
*cp = '\0'; |
|
|
Var_Delete(arg, VAR_GLOBAL); |
Var_Delete(arg, VAR_GLOBAL); |
/* TODO: undefine all variables, not only the first */ |
|
/* TODO: use Str_Words, like everywhere else */ |
|
} |
} |
|
|
static Boolean |
static Boolean |