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): demonstrate wrong return value in Cond...
details: https://anonhg.NetBSD.org/src/rev/500339fdb250
branches: trunk
changeset: 958784:500339fdb250
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jan 19 17:49:13 2021 +0000
description:
make(1): demonstrate wrong return value in CondParser_Term
diffstat:
usr.bin/make/cond.c | 10 ++++++++--
usr.bin/make/unit-tests/cond-op-not.exp | 5 ++++-
usr.bin/make/unit-tests/cond-op-not.mk | 9 ++++++++-
usr.bin/make/unit-tests/cond-op-parentheses.exp | 6 +++++-
usr.bin/make/unit-tests/cond-op-parentheses.mk | 19 ++++++++++++++++++-
5 files changed, 43 insertions(+), 6 deletions(-)
diffs (108 lines):
diff -r 4d98b5d16985 -r 500339fdb250 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Tue Jan 19 14:39:20 2021 +0000
+++ b/usr.bin/make/cond.c Tue Jan 19 17:49:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.235 2021/01/10 21:20:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -949,6 +949,12 @@
t = TOK_TRUE;
}
}
+
+ /*
+ * FIXME: Can at least return TOK_AND, TOK_OR, TOK_RPAREN, maybe
+ * others as well.
+ */
+ /* TODO: assert(t == TOK_ERROR); */
return t;
}
diff -r 4d98b5d16985 -r 500339fdb250 usr.bin/make/unit-tests/cond-op-not.exp
--- a/usr.bin/make/unit-tests/cond-op-not.exp Tue Jan 19 14:39:20 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op-not.exp Tue Jan 19 17:49:13 2021 +0000
@@ -3,4 +3,7 @@
make: "cond-op-not.mk" line 41: Not 0 evaluates to true.
make: "cond-op-not.mk" line 49: Not 1 evaluates to false.
make: "cond-op-not.mk" line 55: Not word evaluates to false.
-exit status 0
+make: "cond-op-not.mk" line 59: Malformed conditional (!)
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 4d98b5d16985 -r 500339fdb250 usr.bin/make/unit-tests/cond-op-not.mk
--- a/usr.bin/make/unit-tests/cond-op-not.mk Tue Jan 19 14:39:20 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op-not.mk Tue Jan 19 17:49:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-not.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op-not.mk,v 1.7 2021/01/19 17:49:13 rillig Exp $
#
# Tests for the ! operator in .if conditions, which negates its argument.
@@ -55,5 +55,12 @@
. info Not word evaluates to false.
.endif
+# A single exclamation mark is a parse error.
+.if !
+. error
+.else
+. error
+.endif
+
all:
@:;
diff -r 4d98b5d16985 -r 500339fdb250 usr.bin/make/unit-tests/cond-op-parentheses.exp
--- a/usr.bin/make/unit-tests/cond-op-parentheses.exp Tue Jan 19 14:39:20 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op-parentheses.exp Tue Jan 19 17:49:13 2021 +0000
@@ -1,2 +1,6 @@
make: "cond-op-parentheses.mk" line 13: Parentheses can be nested at least to depth 112.
-exit status 0
+make: "cond-op-parentheses.mk" line 19: Malformed conditional (()
+make: "cond-op-parentheses.mk" line 29: Malformed conditional ())
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 4d98b5d16985 -r 500339fdb250 usr.bin/make/unit-tests/cond-op-parentheses.mk
--- a/usr.bin/make/unit-tests/cond-op-parentheses.mk Tue Jan 19 14:39:20 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op-parentheses.mk Tue Jan 19 17:49:13 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-parentheses.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $
+# $NetBSD: cond-op-parentheses.mk,v 1.4 2021/01/19 17:49:13 rillig Exp $
#
# Tests for parentheses in .if conditions.
@@ -15,5 +15,22 @@
. error
.endif
+# An unbalanced opening parenthesis is a parse error.
+.if (
+. error
+.else
+. error
+.endif
+
+# An unbalanced closing parenthesis is a parse error.
+#
+# As of 2021-01-19, CondParser_Term returned TOK_RPAREN even though this
+# function promised to only ever return TOK_TRUE, TOK_FALSE or TOK_ERROR.
+.if )
+. error
+.else
+. error
+.endif
+
all:
@:;
Home |
Main Index |
Thread Index |
Old Index