diff options
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -718,8 +718,7 @@ read_makefile (filename, flags) because there was no preceding target, and the line might have been usable as a variable definition. But now it is definitely lossage. */ - fatal (&fileinfo, - "commands commence before first target"); + fatal(&fileinfo, "commands commence before first target"); } else { @@ -767,12 +766,10 @@ read_makefile (filename, flags) { case w_eol: if (cmdleft != 0) - fatal (&fileinfo, - "missing rule before commands"); - else - /* This line contained a variable reference that - expanded to nothing but whitespace. */ - continue; + fatal(&fileinfo, "missing rule before commands"); + /* This line contained something but turned out to be nothing + but whitespace (a comment?). */ + continue; case w_colon: case w_dcolon: @@ -835,11 +832,7 @@ read_makefile (filename, flags) wtype = get_next_mword(lb_next, NULL, &lb_next, &len); if (wtype == w_eol) - /* There's no need to be ivory-tower about this: check for - one of the most common bugs found in makefiles... */ - fatal (&fileinfo, "missing separator%s", - strncmp(lb.buffer, " ", 8) ? "" - : " (did you mean TAB instead of 8 spaces?)"); + break; p2 += strlen(p2); *(p2++) = ' '; @@ -851,6 +844,20 @@ read_makefile (filename, flags) p2 = next_token (variable_buffer); + /* If the word we're looking at is EOL, see if there's _anything_ + on the line. If not, a variable expanded to nothing, so ignore + it. If so, we can't parse this line so punt. */ + if (wtype == w_eol) + { + if (*p2 != '\0') + /* There's no need to be ivory-tower about this: check for + one of the most common bugs found in makefiles... */ + fatal (&fileinfo, "missing separator%s", + strncmp(lb.buffer, " ", 8) ? "" + : " (did you mean TAB instead of 8 spaces?)"); + continue; + } + /* Make the colon the end-of-string so we know where to stop looking for targets. */ *colonp = '\0'; |