Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): fix error message for .info/.warning/....



details:   https://anonhg.NetBSD.org/src/rev/7ee4dc9f6507
branches:  trunk
changeset: 979220:7ee4dc9f6507
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 22:33:11 2020 +0000

description:
make(1): fix error message for .info/.warning/.error without argument

Previously, the error message was "Unknown directive", which was
obviously wrong.  The new error message is "Missing argument".

diffstat:

 usr.bin/make/parse.c                          |  28 ++++++++++++++------------
 usr.bin/make/unit-tests/directive-if.exp      |   4 +-
 usr.bin/make/unit-tests/directive-if.mk       |   6 ++--
 usr.bin/make/unit-tests/directive-info.exp    |  24 +++++++++++-----------
 usr.bin/make/unit-tests/directive-info.mk     |   8 +++++-
 usr.bin/make/unit-tests/directive-warning.exp |  16 +++++++-------
 usr.bin/make/unit-tests/directive-warning.mk  |   8 +++++-
 usr.bin/make/unit-tests/varmod.exp            |   2 +-
 usr.bin/make/unit-tests/varmod.mk             |   4 +-
 9 files changed, 55 insertions(+), 45 deletions(-)

diffs (234 lines):

diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Dec 19 22:33:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.502 2020/12/19 20:16:36 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.503 2020/12/19 22:33:11 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.502 2020/12/19 20:16:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.503 2020/12/19 22:33:11 rillig Exp $");
 
 /* types and constants */
 
@@ -723,13 +723,16 @@
 
 /* Parse and handle a .info, .warning or .error directive.
  * For an .error directive, immediately exit. */
-static Boolean
-ParseMessage(ParseErrorLevel level, const char *umsg)
+static void
+ParseMessage(ParseErrorLevel level, const char *levelName, const char *umsg)
 {
        char *xmsg;
 
-       if (umsg[0] == '\0')
-               return FALSE;   /* missing argument */
+       if (umsg[0] == '\0') {
+               Parse_Error(PARSE_FATAL, "Missing argument for \".%s\"",
+                   levelName);
+               return;
+       }
 
        (void)Var_Subst(umsg, VAR_CMDLINE, VARE_WANTRES, &xmsg);
        /* TODO: handle errors */
@@ -741,7 +744,6 @@
                PrintOnError(NULL, NULL);
                exit(1);
        }
-       return TRUE;
 }
 
 /* Add the child to the parent's children.
@@ -3070,14 +3072,14 @@
                Var_UnExport(TRUE, arg);
                return TRUE;
        } else if (IsDirective(dir, dirlen, "info")) {
-               if (ParseMessage(PARSE_INFO, arg))
-                       return TRUE;
+               ParseMessage(PARSE_INFO, "info", arg);
+               return TRUE;
        } else if (IsDirective(dir, dirlen, "warning")) {
-               if (ParseMessage(PARSE_WARNING, arg))
-                       return TRUE;
+               ParseMessage(PARSE_WARNING, "warning", arg);
+               return TRUE;
        } else if (IsDirective(dir, dirlen, "error")) {
-               if (ParseMessage(PARSE_FATAL, arg))
-                       return TRUE;
+               ParseMessage(PARSE_FATAL, "error", arg);
+               return TRUE;
        }
        return FALSE;
 }
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-if.exp
--- a/usr.bin/make/unit-tests/directive-if.exp  Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-if.exp  Sat Dec 19 22:33:11 2020 +0000
@@ -1,9 +1,9 @@
 make: "directive-if.mk" line 13: 0 evaluates to false.
 make: "directive-if.mk" line 17: 1 evaluates to true.
 make: "directive-if.mk" line 40: Unknown directive "ifx"
-make: "directive-if.mk" line 41: Unknown directive "error"
+make: "directive-if.mk" line 41: This is not conditional.
 make: "directive-if.mk" line 42: if-less else
-make: "directive-if.mk" line 43: Unknown directive "error"
+make: "directive-if.mk" line 43: This is not conditional.
 make: "directive-if.mk" line 44: if-less endif
 make: "directive-if.mk" line 47: Malformed conditional ()
 make: "directive-if.mk" line 57: Quotes in plain words are probably a mistake.
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-if.mk
--- a/usr.bin/make/unit-tests/directive-if.mk   Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-if.mk   Sat Dec 19 22:33:11 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-if.mk,v 1.8 2020/12/14 21:02:25 rillig Exp $
+# $NetBSD: directive-if.mk,v 1.9 2020/12/19 22:33:11 rillig Exp $
 #
 # Tests for the .if directive.
 #
@@ -38,9 +38,9 @@
 # are interpreted as ordinary directives, producing the error messages
 # "if-less else" and "if-less endif".
 .ifx 123
-.  error
+.info This is not conditional.
 .else
-.  error
+.info This is not conditional.
 .endif
 
 # Missing condition.
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-info.exp
--- a/usr.bin/make/unit-tests/directive-info.exp        Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.exp        Sat Dec 19 22:33:11 2020 +0000
@@ -1,15 +1,15 @@
-make: "directive-info.mk" line 7: begin .info tests
-make: "directive-info.mk" line 8: Unknown directive "inf"
-make: "directive-info.mk" line 9: Unknown directive "info"
-make: "directive-info.mk" line 10: message
-make: "directive-info.mk" line 11: indented message
-make: "directive-info.mk" line 12: Unknown directive "information"
-make: "directive-info.mk" line 13: Unknown directive "information"
-make: "directive-info.mk" line 18: Unknown directive "info"
-make: "directive-info.mk" line 19: Unknown directive "info"
-make: "directive-info.mk" line 22: Unknown directive "info-message"
-make: "directive-info.mk" line 23: no-target: no-source
-make: "directive-info.mk" line 32: expect line 30 for multi-line message
+make: "directive-info.mk" line 11: begin .info tests
+make: "directive-info.mk" line 12: Unknown directive "inf"
+make: "directive-info.mk" line 13: Missing argument for ".info"
+make: "directive-info.mk" line 14: message
+make: "directive-info.mk" line 15: indented message
+make: "directive-info.mk" line 16: Unknown directive "information"
+make: "directive-info.mk" line 17: Unknown directive "information"
+make: "directive-info.mk" line 22: Missing argument for ".info"
+make: "directive-info.mk" line 23: Missing argument for ".info"
+make: "directive-info.mk" line 26: Unknown directive "info-message"
+make: "directive-info.mk" line 27: no-target: no-source
+make: "directive-info.mk" line 36: expect line 30 for multi-line message
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-info.mk
--- a/usr.bin/make/unit-tests/directive-info.mk Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.mk Sat Dec 19 22:33:11 2020 +0000
@@ -1,12 +1,16 @@
-# $NetBSD: directive-info.mk,v 1.7 2020/12/19 12:40:00 rillig Exp $
+# $NetBSD: directive-info.mk,v 1.8 2020/12/19 22:33:11 rillig Exp $
 #
 # Tests for the .info directive.
+#
+# Until parse.c 1.502 from 2020-12-19, a missing argument to the directive
+# produced the wrong error message "Unknown directive".  Since parse.c 1.503
+# from 2020-12-19, the correct "Missing argument" is produced.
 
 # TODO: Implementation
 
 .info begin .info tests
 .inf                           # misspelled
-.info                          # oops: message should be "missing parameter"
+.info                          # "Missing argument"
 .info message
 .info          indented message
 .information
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-warning.exp
--- a/usr.bin/make/unit-tests/directive-warning.exp     Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-warning.exp     Sat Dec 19 22:33:11 2020 +0000
@@ -1,11 +1,11 @@
-make: "directive-warning.mk" line 7: Unknown directive "warn"
-make: "directive-warning.mk" line 8: Unknown directive "warn"
-make: "directive-warning.mk" line 9: Unknown directive "warnin"
-make: "directive-warning.mk" line 10: Unknown directive "warnin"
-make: "directive-warning.mk" line 11: Unknown directive "warning"
-make: "directive-warning.mk" line 12: warning: message
-make: "directive-warning.mk" line 13: Unknown directive "warnings"
-make: "directive-warning.mk" line 14: Unknown directive "warnings"
+make: "directive-warning.mk" line 11: Unknown directive "warn"
+make: "directive-warning.mk" line 12: Unknown directive "warn"
+make: "directive-warning.mk" line 13: Unknown directive "warnin"
+make: "directive-warning.mk" line 14: Unknown directive "warnin"
+make: "directive-warning.mk" line 15: Missing argument for ".warning"
+make: "directive-warning.mk" line 16: warning: message
+make: "directive-warning.mk" line 17: Unknown directive "warnings"
+make: "directive-warning.mk" line 18: Unknown directive "warnings"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/directive-warning.mk
--- a/usr.bin/make/unit-tests/directive-warning.mk      Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-warning.mk      Sat Dec 19 22:33:11 2020 +0000
@@ -1,6 +1,10 @@
-# $NetBSD: directive-warning.mk,v 1.5 2020/12/13 01:10:22 rillig Exp $
+# $NetBSD: directive-warning.mk,v 1.6 2020/12/19 22:33:11 rillig Exp $
 #
 # Tests for the .warning directive.
+#
+# Until parse.c 1.502 from 2020-12-19, a missing argument to the directive
+# produced the wrong error message "Unknown directive".  Since parse.c 1.503
+# from 2020-12-19, the correct "Missing argument" is produced.
 
 # TODO: Implementation
 
@@ -8,7 +12,7 @@
 .warn message                  # misspelled
 .warnin                                # misspelled
 .warnin        message                 # misspelled
-.warning                       # oops: should be "missing argument"
+.warning                       # "Missing argument"
 .warning message               # ok
 .warnings                      # misspelled
 .warnings messages             # Accepted before 2020-12-13 01:07:54.
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/varmod.exp
--- a/usr.bin/make/unit-tests/varmod.exp        Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod.exp        Sat Dec 19 22:33:11 2020 +0000
@@ -2,7 +2,7 @@
 make: "varmod.mk" line 42: Invalid variable name ':', at "$:L} != """
 make: "varmod.mk" line 47: Dollar followed by nothing
 make: "varmod.mk" line 56: Missing delimiter ':' after modifier "P"
-make: "varmod.mk" line 57: Unknown directive "error"
+make: "varmod.mk" line 57: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r a5ce3d78a814 -r 7ee4dc9f6507 usr.bin/make/unit-tests/varmod.mk
--- a/usr.bin/make/unit-tests/varmod.mk Sat Dec 19 22:11:57 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod.mk Sat Dec 19 22:33:11 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod.mk,v 1.4 2020/11/02 17:30:22 rillig Exp $
+# $NetBSD: varmod.mk,v 1.5 2020/12/19 22:33:11 rillig Exp $
 #
 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
 
@@ -51,7 +51,7 @@
 # The variable modifier :P does not fall back to the SysV modifier.
 # Therefore the modifier :P=RE generates a parse error.
 # XXX: The .error should not be reached since the variable expression is
-# malformed.
+# malformed, and this error should be propagated up to Cond_EvalLine.
 VAR=   STOP
 .if ${VAR:P=RE} != "STORE"
 .  error



Home | Main Index | Thread Index | Old Index