Module Name: src
Committed By: rillig
Date: Sat Oct 31 09:03:36 UTC 2020
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-sysv.mk
Log Message:
make(1): remove redundant code branch in SysVMatch
The general code path of parsing :from=to achieves the same effect.
To generate a diff of this commit:
cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-sysv.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.611 src/usr.bin/make/var.c:1.612
--- src/usr.bin/make/var.c:1.611 Sat Oct 31 08:40:54 2020
+++ src/usr.bin/make/var.c Sat Oct 31 09:03:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $ */
+/* $NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1181,11 +1181,6 @@ SysVMatch(const char *word, const char *
const char *w_tail;
*out_hasPercent = FALSE;
- if (*p == '\0') { /* ${VAR:=suffix} */
- *out_match_len = strlen(w); /* Null pattern is the whole string */
- return w;
- }
-
percent = strchr(p, '%');
if (percent != NULL) { /* ${VAR:...%...=...} */
*out_hasPercent = TRUE;
Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.6 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.6 Sat Oct 31 08:31:37 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk Sat Oct 31 09:03:36 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.6 2020/10/31 08:31:37 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.7 2020/10/31 09:03:36 rillig Exp $
#
# Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
# "from" with "to". It can also use '%' as a wildcard.
@@ -60,6 +60,11 @@ all:
. error
.endif
+# Each word gets the suffix "X" appended.
+.if ${one two:L:=X} != "oneX twoX"
+. error
+.endif
+
# The suffix "o" is replaced with "X".
.if ${one two:L:o=X} != "one twX"
. error