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): add error handling for edge case in ma...
details: https://anonhg.NetBSD.org/src/rev/94a2cfbb47aa
branches: trunk
changeset: 1018046:94a2cfbb47aa
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jan 19 18:13:37 2021 +0000
description:
make(1): add error handling for edge case in malformed conditions
diffstat:
usr.bin/make/cond.c | 10 ++++++----
usr.bin/make/unit-tests/cond-op.exp | 4 ++--
usr.bin/make/unit-tests/cond-op.mk | 10 +++++-----
3 files changed, 13 insertions(+), 11 deletions(-)
diffs (82 lines):
diff -r e5e3b9eaa90b -r 94a2cfbb47aa usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Tue Jan 19 18:09:12 2021 +0000
+++ b/usr.bin/make/cond.c Tue Jan 19 18:13:37 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 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.237 2021/01/19 17:57:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.238 2021/01/19 18:13:37 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -980,7 +980,8 @@
if (l == TOK_TRUE) {
l = CondParser_Factor(par, doEval);
} else {
- (void)CondParser_Factor(par, FALSE);
+ if (CondParser_Factor(par, FALSE) == TOK_ERROR)
+ return TOK_ERROR;
}
} else {
/*
@@ -1023,7 +1024,8 @@
if (l == TOK_FALSE) {
l = CondParser_Expr(par, doEval);
} else {
- (void)CondParser_Expr(par, FALSE);
+ if (CondParser_Expr(par, FALSE) == TOK_ERROR)
+ return TOK_ERROR;
}
} else {
/*
diff -r e5e3b9eaa90b -r 94a2cfbb47aa usr.bin/make/unit-tests/cond-op.exp
--- a/usr.bin/make/unit-tests/cond-op.exp Tue Jan 19 18:09:12 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op.exp Tue Jan 19 18:13:37 2021 +0000
@@ -12,8 +12,8 @@
make: "cond-op.mk" line 93: 1 1 0 => 0 1 1
make: "cond-op.mk" line 93: 1 1 1 => 1 1 1
make: "cond-op.mk" line 104: Malformed conditional (1 &&)
-make: "cond-op.mk" line 115: Missing argument for ".error"
-make: "cond-op.mk" line 121: Missing argument for ".error"
+make: "cond-op.mk" line 112: Malformed conditional (0 &&)
+make: "cond-op.mk" line 120: Malformed conditional (1 ||)
make: "cond-op.mk" line 129: Malformed conditional (0 ||)
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
diff -r e5e3b9eaa90b -r 94a2cfbb47aa usr.bin/make/unit-tests/cond-op.mk
--- a/usr.bin/make/unit-tests/cond-op.mk Tue Jan 19 18:09:12 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-op.mk Tue Jan 19 18:13:37 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.11 2021/01/19 18:09:12 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.12 2021/01/19 18:13:37 rillig Exp $
#
# Tests for operators like &&, ||, ! in .if conditions.
#
@@ -107,16 +107,16 @@
. error
.endif
-# FIXME: Don't accept this condition as syntactically valid.
-# FIXME: CondParser_Factor, (void).
+# This obviously malformed condition was not detected as such before cond.c
+# 1.238 from 2021-01-19.
.if 0 &&
. error
.else
. error
.endif
-# FIXME: Don't accept this condition as syntactically valid.
-# FIXME: CondParser_Expr, (void).
+# This obviously malformed condition was not detected as such before cond.c
+# 1.238 from 2021-01-19.
.if 1 ||
. error
.else
Home |
Main Index |
Thread Index |
Old Index