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 wording of parse error in conditio...



details:   https://anonhg.NetBSD.org/src/rev/a56a6512e436
branches:  trunk
changeset: 976062:a56a6512e436
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 12 10:38:52 2020 +0000

description:
make(1): fix wording of parse error in conditionals

The word "should" is not appropriate for situations that eventually lead
to a parse error.

diffstat:

 usr.bin/make/cond.c                         |  17 +++++++++++------
 usr.bin/make/unit-tests/cond-cmp-string.exp |   2 +-
 usr.bin/make/unit-tests/cond1.exp           |   2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

diffs (100 lines):

diff -r 18febed31693 -r a56a6512e436 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sat Sep 12 10:14:16 2020 +0000
+++ b/usr.bin/make/cond.c       Sat Sep 12 10:38:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.135 2020/09/12 10:38:52 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.135 2020/09/12 10:38:52 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.135 2020/09/12 10:38:52 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -281,6 +281,7 @@
     if (func != NULL && *cp++ != ')') {
        Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
                    func);
+       /* The PARSE_FATAL is done as a follow-up by Cond_EvalExpression. */
        return 0;
     }
 
@@ -550,18 +551,20 @@
 EvalCompareNum(double lhs, const char *op, double rhs)
 {
     if (DEBUG(COND))
-       fprintf(debug_file, "lhs = %f, right = %f, op = %.2s\n", lhs, rhs, op);
+       fprintf(debug_file, "lhs = %f, rhs = %f, op = %.2s\n", lhs, rhs, op);
 
     switch (op[0]) {
     case '!':
        if (op[1] != '=') {
            Parse_Error(PARSE_WARNING, "Unknown operator");
+           /* The PARSE_FATAL is done as a follow-up by Cond_EvalExpression. */
            return TOK_ERROR;
        }
        return lhs != rhs;
     case '=':
        if (op[1] != '=') {
            Parse_Error(PARSE_WARNING, "Unknown operator");
+           /* The PARSE_FATAL is done as a follow-up by Cond_EvalExpression. */
            return TOK_ERROR;
        }
        return lhs == rhs;
@@ -576,9 +579,10 @@
 static Token
 EvalCompareStr(const char *lhs, const char *op, const char *rhs)
 {
-    if ((*op != '!' && *op != '=') || op[1] != '=') {
+    if (!((op[0] == '!' || op[0] == '=') && op[1] == '=')) {
        Parse_Error(PARSE_WARNING,
-                   "String comparison operator should be either == or !=");
+                   "String comparison operator must be either == or !=");
+       /* The PARSE_FATAL is done as a follow-up by Cond_EvalExpression. */
        return TOK_ERROR;
     }
 
@@ -658,6 +662,7 @@
 
     if (par->p[0] == '\0') {
        Parse_Error(PARSE_WARNING, "Missing right-hand-side of operator");
+       /* The PARSE_FATAL is done as a follow-up by Cond_EvalExpression. */
        goto done;
     }
 
diff -r 18febed31693 -r a56a6512e436 usr.bin/make/unit-tests/cond-cmp-string.exp
--- a/usr.bin/make/unit-tests/cond-cmp-string.exp       Sat Sep 12 10:14:16 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-string.exp       Sat Sep 12 10:38:52 2020 +0000
@@ -1,6 +1,6 @@
 make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str)
 make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing")
-make: "cond-cmp-string.mk" line 42: warning: String comparison operator should be either == or !=
+make: "cond-cmp-string.mk" line 42: warning: String comparison operator must be either == or !=
 make: "cond-cmp-string.mk" line 42: Malformed conditional (!("value" = "value"))
 make: "cond-cmp-string.mk" line 49: Malformed conditional (!("value" === "value"))
 make: Fatal errors encountered -- cannot continue
diff -r 18febed31693 -r a56a6512e436 usr.bin/make/unit-tests/cond1.exp
--- a/usr.bin/make/unit-tests/cond1.exp Sat Sep 12 10:14:16 2020 +0000
+++ b/usr.bin/make/unit-tests/cond1.exp Sat Sep 12 10:38:52 2020 +0000
@@ -16,7 +16,7 @@
 4 is not prime
 5 is  prime
 
-make: warning: String comparison operator should be either == or !=
+make: warning: String comparison operator must be either == or !=
 make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
 
 OK



Home | Main Index | Thread Index | Old Index