make: Fix handling comments inside rules

A line consisting only of blanks or comments should not end a rule,
even if it doesn't start with a tabulation character.
This commit is contained in:
Colomban Wendling 2015-04-02 20:00:40 +02:00
parent 2d31d8f836
commit a11d67bb0b
4 changed files with 26 additions and 8 deletions

View File

@ -59,12 +59,10 @@ static void skipLine (void)
fileUngetc (c);
}
static int skipToNonWhite (void)
static int skipToNonWhite (int c)
{
int c;
do
while (c != '\n' && isspace (c))
c = nextChar ();
while (c != '\n' && isspace (c));
return c;
}
@ -138,12 +136,12 @@ static void findMakeTags (void)
{
if (in_rule)
{
if (c == '\t')
if (c == '\t' || (c = skipToNonWhite (c)) == '#')
{
skipLine (); /* skip rule */
skipLine (); /* skip rule or comment */
c = nextChar ();
}
else
else if (c != '\n')
in_rule = FALSE;
}
stringListClear (identifiers);
@ -198,7 +196,7 @@ static void findMakeTags (void)
else if (! strcmp (vStringValue (name), "define"))
{
in_define = TRUE;
c = skipToNonWhite ();
c = skipToNonWhite (nextChar ());
vStringClear (name);
/* all remaining characters on the line are the name -- even spaces */
while (c != EOF && c != '\n')

View File

@ -200,6 +200,7 @@ test_sources = \
line_directives.c \
local.c \
macros.c \
make-comment-in-rule.mak \
make-multi-target.mak \
make-target-with-parentheses.mak \
make-variable-on-cmdline.mak \

View File

@ -0,0 +1,17 @@
# all this is one single rule
all:
a=1; echo "$$a"
# foo
b=2; echo "$$b"
# foo
c=3; echo "$$c"
# foo
d=4; echo "$$d"
# foo
e=5; echo "$$e"
f=6; echo "$$f"
# foo
g=7; echo "$$g"

View File

@ -0,0 +1,2 @@
# format=tagmanager
allÌ16Ö0