mirror of
https://github.com/mirror/make.git
synced 2026-08-19 08:23:28 +08:00
[SV 64402] Correct locating "," in ifeq/ifneq conditionals
Ensure that we correctly skip the entirety of a macro or function
reference when searching for the "," separator in an ifeq/ifneq
conditional, including using "$," and also "${foo,bar}". Note that
this change means that parenthesis OTHER than those used for variable
expansion are not considered special, any longer.
* NEWS: Announce the change.
* src/read.c (conditional_line): Skip variable references when looking
for "," and ensure that we match closing parens/braces properly.
* tests/scripts/features/conditionals: Add tests for this behavior.
This commit is contained in:
28
src/read.c
28
src/read.c
@@ -1672,13 +1672,27 @@ conditional_line (char *line, size_t len, const floc *flocp)
|
||||
if (termin == ',')
|
||||
{
|
||||
int count = 0;
|
||||
for (; *line != '\0'; ++line)
|
||||
if (*line == '(')
|
||||
++count;
|
||||
else if (*line == ')')
|
||||
--count;
|
||||
else if (*line == ',' && count <= 0)
|
||||
break;
|
||||
char *delim = xmalloc (strlen (line));
|
||||
while (*line != '\0')
|
||||
{
|
||||
if (*line == '$')
|
||||
{
|
||||
++line;
|
||||
if (*line == '(')
|
||||
delim[count++] = ')';
|
||||
else if (*line == '{')
|
||||
delim[count++] = '}';
|
||||
}
|
||||
else if (count == 0)
|
||||
{
|
||||
if (*line == ',')
|
||||
break;
|
||||
}
|
||||
else if (*line == delim[count-1])
|
||||
--count;
|
||||
++line;
|
||||
}
|
||||
free (delim);
|
||||
}
|
||||
else
|
||||
while (*line != '\0' && *line != termin)
|
||||
|
||||
Reference in New Issue
Block a user