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 possible return values for CondPar...
details: https://anonhg.NetBSD.org/src/rev/c944a783ac87
branches: trunk
changeset: 950185:c944a783ac87
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jan 19 17:57:07 2021 +0000
description:
make(1): fix possible return values for CondParser_Term
The invalid return values didn't do any harm since CondParser_Factor and
CondParser_Expr passed them through, and CondParser_Eval carefully
checks for TOK_TRUE or TOK_FALSE and treats everything else as an error.
No change in observable behavior since there is no debug logging in that
part of the code.
diffstat:
usr.bin/make/cond.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
diffs (53 lines):
diff -r 8263d21af405 -r c944a783ac87 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Tue Jan 19 17:49:13 2021 +0000
+++ b/usr.bin/make/cond.c Tue Jan 19 17:57:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.236 2021/01/19 17:49:13 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 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.236 2021/01/19 17:49:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.237 2021/01/19 17:57:07 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -924,14 +924,10 @@
Token t;
t = CondParser_Token(par, doEval);
+ if (t == TOK_TRUE || t == TOK_FALSE)
+ return t;
- if (t == TOK_EOF) {
- /*
- * If we reached the end of the expression, the expression
- * is malformed...
- */
- t = TOK_ERROR;
- } else if (t == TOK_LPAREN) {
+ if (t == TOK_LPAREN) {
/*
* T -> ( E )
*/
@@ -948,13 +944,10 @@
} else if (t == TOK_FALSE) {
t = TOK_TRUE;
}
- }
+ } else
+ return TOK_ERROR;
- /*
- * FIXME: Can at least return TOK_AND, TOK_OR, TOK_RPAREN, maybe
- * others as well.
- */
- /* TODO: assert(t == TOK_ERROR); */
+ assert(t == TOK_TRUE || t == TOK_FALSE || t == TOK_ERROR);
return t;
}
Home |
Main Index |
Thread Index |
Old Index