make: Support for variable expansions in target names
This commit is contained in:
parent
0d60359428
commit
5bed3b58f3
@ -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 \
|
||||
|
1
tests/ctags/make-target-with-parentheses.mak
Normal file
1
tests/ctags/make-target-with-parentheses.mak
Normal file
@ -0,0 +1 @@
|
||||
$(obj)/raid6int1.c: F := 6
|
3
tests/ctags/make-target-with-parentheses.mak.tags
Normal file
3
tests/ctags/make-target-with-parentheses.mak.tags
Normal file
@ -0,0 +1,3 @@
|
||||
# format=tagmanager
|
||||
$(obj)/raid6int1.cÌ16Ö0
|
||||
FÌ65536Ö0
|
@ -1,4 +1,5 @@
|
||||
# format=tagmanager
|
||||
$(obj)/raid6int1.cÌ16Ö0
|
||||
AÌ65536Ö0
|
||||
BÌ65536Ö0
|
||||
CÌ65536Ö0
|
||||
|
Loading…
x
Reference in New Issue
Block a user