Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests make: remove unreachable code for pa...
details: https://anonhg.NetBSD.org/src/rev/2842401818e9
branches: trunk
changeset: 1027629:2842401818e9
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Dec 14 00:02:57 2021 +0000
description:
make: remove unreachable code for parsing the dependency operator
At the point where ParseDependencyOp is called, cp is guaranteed to
point to either ':' or '!'.
No functional change.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
usr.bin/make/parse.c | 46 +++++++----------------------
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/dep-op-missing.exp | 4 ++
usr.bin/make/unit-tests/dep-op-missing.mk | 13 ++++++++
usr.bin/make/unit-tests/dep-wildcards.exp | 1 +
6 files changed, 34 insertions(+), 37 deletions(-)
diffs (150 lines):
diff -r bafb5809d5b0 -r 2842401818e9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Dec 13 23:59:35 2021 +0000
+++ b/distrib/sets/lists/tests/mi Tue Dec 14 00:02:57 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1177 2021/12/13 23:38:54 rillig Exp $
+# $NetBSD: mi,v 1.1178 2021/12/14 00:02:57 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5459,6 +5459,8 @@
./usr/tests/usr.bin/make/unit-tests/dep-exclam.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dep-none.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dep-none.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-op-missing.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-op-missing.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dep-percent.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dep-percent.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dep-var.exp tests-usr.bin-tests compattestfile,atf
diff -r bafb5809d5b0 -r 2842401818e9 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Mon Dec 13 23:59:35 2021 +0000
+++ b/usr.bin/make/parse.c Tue Dec 14 00:02:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.577 2021/12/13 06:11:34 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.578 2021/12/14 00:02:57 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.577 2021/12/13 06:11:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.578 2021/12/14 00:02:57 rillig Exp $");
/* types and constants */
@@ -1265,34 +1265,15 @@
* In a dependency line like 'targets: sources' or 'targets! sources', parse
* the operator ':', '::' or '!' from between the targets and the sources.
*/
-static bool
-ParseDependencyOp(char **pp, const char *lstart, GNodeType *out_op)
+static GNodeType
+ParseDependencyOp(char **pp)
{
- const char *cp = *pp;
-
- if (*cp == '!') {
- *out_op = OP_FORCE;
- (*pp)++;
- return true;
- }
-
- if (*cp == ':') {
- if (cp[1] == ':') {
- *out_op = OP_DOUBLEDEP;
- (*pp) += 2;
- } else {
- *out_op = OP_DEPENDS;
- (*pp)++;
- }
- return true;
- }
-
- {
- const char *msg = lstart[0] == '.'
- ? "Unknown directive" : "Missing dependency operator";
- Parse_Error(PARSE_FATAL, "%s", msg);
- return false;
- }
+ if (**pp == '!')
+ return (*pp)++, OP_FORCE;
+ if ((*pp)[1] == ':')
+ return (*pp) += 2, OP_DOUBLEDEP;
+ else
+ return (*pp)++, OP_DEPENDS;
}
static void
@@ -1708,16 +1689,11 @@
ParseDependencyCheckSpec(specType);
/*
- * Have now parsed all the target names. Must parse the operator next.
- */
- if (!ParseDependencyOp(&cp, lstart, &op))
- goto out;
-
- /*
* Apply the operator to the target. This is how we remember which
* operator a target was defined with. It fails if the operator
* used isn't consistent across all references.
*/
+ op = ParseDependencyOp(&cp);
ApplyDependencyOperator(op);
/*
diff -r bafb5809d5b0 -r 2842401818e9 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Mon Dec 13 23:59:35 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile Tue Dec 14 00:02:57 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.289 2021/12/13 23:38:54 rillig Exp $
+# $NetBSD: Makefile,v 1.290 2021/12/14 00:02:57 rillig Exp $
#
# Unit tests for make(1)
#
@@ -94,6 +94,7 @@
TESTS+= dep-double-colon-indep
TESTS+= dep-exclam
TESTS+= dep-none
+TESTS+= dep-op-missing
TESTS+= dep-percent
TESTS+= dep-var
TESTS+= dep-wildcards
diff -r bafb5809d5b0 -r 2842401818e9 usr.bin/make/unit-tests/dep-op-missing.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-op-missing.exp Tue Dec 14 00:02:57 2021 +0000
@@ -0,0 +1,4 @@
+make: "dep-op-missing.tmp" line 1: Invalid line type
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 0
diff -r bafb5809d5b0 -r 2842401818e9 usr.bin/make/unit-tests/dep-op-missing.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/dep-op-missing.mk Tue Dec 14 00:02:57 2021 +0000
@@ -0,0 +1,13 @@
+# $NetBSD: dep-op-missing.mk,v 1.1 2021/12/14 00:02:57 rillig Exp $
+#
+# Test for a missing dependency operator, in a line with trailing whitespace.
+
+# Before parse.c 1.578 from 2021-12-14, there was some unreachable error
+# handling code in ParseDependencyOp. This test tried to reach it and failed.
+# To reach that point, there would have to be trailing whitespace in the line,
+# but that is removed in an early stage of parsing.
+
+all: .PHONY
+ @printf 'target ' > dep-op-missing.tmp
+ @${MAKE} -r -f dep-op-missing.tmp || exit 0
+ @rm dep-op-missing.tmp
diff -r bafb5809d5b0 -r 2842401818e9 usr.bin/make/unit-tests/dep-wildcards.exp
--- a/usr.bin/make/unit-tests/dep-wildcards.exp Mon Dec 13 23:59:35 2021 +0000
+++ b/usr.bin/make/unit-tests/dep-wildcards.exp Tue Dec 14 00:02:57 2021 +0000
@@ -4,6 +4,7 @@
dep-double-colon.mk
dep-exclam.mk
dep-none.mk
+dep-op-missing.mk
dep-percent.mk
dep-var.mk
dep-wildcards.mk
Home |
Main Index |
Thread Index |
Old Index