Kaydet (Commit) 5bed3b58 authored tarafından Colomban Wendling's avatar Colomban Wendling

make: Support for variable expansions in target names

üst 0d603594
......@@ -70,7 +70,7 @@ static int skipToNonWhite (void)
static boolean isIdentifier (int c)
{
return (boolean)(c != '\0' && (isalnum (c) || strchr (".-_/", c) != NULL));
return (boolean)(c != '\0' && (isalnum (c) || strchr (".-_/$(){}", c) != NULL));
}
static boolean isSpecialTarget (vString *const name)
......@@ -118,14 +118,19 @@ static void newMacroFromDefine (vString *const name)
static void readIdentifier (const int first, vString *const id)
{
int depth = 0;
int c = first;
int c_prev = first;
int c_next = first;
vStringClear (id);
while (isIdentifier (c) || c == ' ')
while (isIdentifier (c) || c == ' ' || (depth > 0 && c != EOF && c != '\n'))
{
c_next = nextChar ();
if (c == ' ') {
if (c == '(' || c == '}')
depth++;
else if (depth > 0 && (c == ')' || c == '}'))
depth--;
if (depth < 1 && c == ' ') {
/* add the space character only if the previous and
* next character are valid identifiers */
if (isIdentifier (c_prev) && isIdentifier (c_next))
......@@ -141,28 +146,6 @@ static void readIdentifier (const int first, vString *const id)
vStringTerminate (id);
}
static void skipToMatch (const char *const pair)
{
const int begin = pair [0], end = pair [1];
const unsigned long inputLineNumber = getInputLineNumber ();
int matchLevel = 1;
int c = '\0';
while (matchLevel > 0)
{
c = nextChar ();
if (c == begin)
++matchLevel;
else if (c == end)
--matchLevel;
else if (c == '\n' || c == EOF)
break;
}
if (c == EOF)
verbose ("%s: failed to find match for '%c' at line %lu\n",
getInputFileName (), begin, inputLineNumber);
}
static void findMakeTags (void)
{
vString *name = vStringNew ();
......@@ -195,10 +178,6 @@ static void findMakeTags (void)
continue;
else if (c == '#')
skipLine ();
else if (c == '(')
skipToMatch ("()");
else if (c == '{')
skipToMatch ("{}");
else if (c == ':')
{
variable_possible = TRUE;
......
......@@ -200,6 +200,7 @@ test_sources = \
line_directives.c \
local.c \
macros.c \
make-target-with-parentheses.mak \
make-variable-on-cmdline.mak \
masm.asm \
matlab_backtracking.m \
......
# format=tagmanager
$(obj)/raid6int1.cÌ16Ö0
FÌ65536Ö0
# format=tagmanager
$(obj)/raid6int1.c160
A655360
B655360
C655360
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment