summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>1998-10-13 20:59:08 +0000
committerPaul Smith <psmith@gnu.org>1998-10-13 20:59:08 +0000
commit394864015453ce78c822e6457df04fe483f4bfb0 (patch)
tree22f24043d01395fa9197c32c7ab5e2ed4c521e4f /read.c
parent2c64fb221a265f9e7fc93374906b1e7540377561 (diff)
downloadgunmake-394864015453ce78c822e6457df04fe483f4bfb0.tar.gz
Ignore non-empty lines which become empty after variable expansion.
Don't choke on invalid pattern rules if we fail during makefile parsing. Don't dump core if a non-empty command becomes empty after expansion.
Diffstat (limited to 'read.c')
-rw-r--r--read.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/read.c b/read.c
index a677399..242f953 100644
--- a/read.c
+++ b/read.c
@@ -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';