diff options
author | Paul Smith <psmith@gnu.org> | 2022-11-15 10:50:34 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-11-15 10:50:34 -0500 |
commit | 6c1a6dd77c55e7302ced47cdc293292ae9400d85 (patch) | |
tree | 516a4e0664e2868f8138b96310911e5774a7209d /src/read.c | |
parent | 1b51ba1f5d448281ddeea5a252814bdec56a86fa (diff) | |
download | make-git-6c1a6dd77c55e7302ced47cdc293292ae9400d85.tar.gz |
Add specific hints for errors due to invalid conditionals
* src/read.c (eval): If "missing separator" appears to be due to
missing space after ifeq/ifneq, give a hint about the error.
* tests/scripts/misc/failure: Check for these types of failures.
* tests/scripts/variables/special: Move error checking unrelated
to special variables, to misc/failure.
Diffstat (limited to 'src/read.c')
-rw-r--r-- | src/read.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -1140,20 +1140,29 @@ eval (struct ebuffer *ebuf, int set_default) 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 we're at EOL we didn't find a separator so we don't know what + kind of line this is. */ if (wtype == w_eol) { + /* Ignore an empty line. */ if (*p2 == '\0') continue; - /* There's no need to be ivory-tower about this: check for - one of the most common bugs found in makefiles... */ + /* Check for spaces instead of TAB. */ if (cmd_prefix == '\t' && strneq (line, " ", 8)) O (fatal, fstart, _("missing separator (did you mean TAB instead of 8 spaces?)")); - else - O (fatal, fstart, _("missing separator")); + + /* Check for conditionals without whitespace afterward. + We don't check ifdef/ifndef because there's no real way to miss + whitespace there. */ + p2 = next_token (line); + if (strneq (p2, "if", 2) && + ((strneq (&p2[2], "neq", 3) && !STOP_SET (p2[5], MAP_BLANK)) + || (strneq (&p2[2], "eq", 2) && !STOP_SET (p2[4], MAP_BLANK)))) + O (fatal, fstart, _("missing separator (ifeq/ifneq must be followed by whitespace)")); + + /* No idea... */ + O (fatal, fstart, _("missing separator")); } { |