Module Name: src Committed By: christos Date: Wed May 6 02:30:10 UTC 2020
Modified Files: src/usr.bin/make: str.c src/usr.bin/make/unit-tests: sysv.exp sysv.mk Log Message: Behave like gmake: empty string does not match % pattern To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/str.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/sysv.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/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/str.c diff -u src/usr.bin/make/str.c:1.41 src/usr.bin/make/str.c:1.42 --- src/usr.bin/make/str.c:1.41 Sun May 3 08:10:28 2020 +++ src/usr.bin/make/str.c Tue May 5 22:30:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.41 2020/05/03 12:10:28 rillig Exp $ */ +/* $NetBSD: str.c,v 1.42 2020/05/06 02:30:10 christos Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: str.c,v 1.41 2020/05/03 12:10:28 rillig Exp $"; +static char rcsid[] = "$NetBSD: str.c,v 1.42 2020/05/06 02:30:10 christos Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; #else -__RCSID("$NetBSD: str.c,v 1.41 2020/05/03 12:10:28 rillig Exp $"); +__RCSID("$NetBSD: str.c,v 1.42 2020/05/06 02:30:10 christos Exp $"); #endif #endif /* not lint */ #endif @@ -471,6 +471,10 @@ Str_SYSVMatch(const char *word, const ch if ((m = strchr(p, '%')) != NULL) { *hasPercent = TRUE; + if (*w == '\0') { + /* empty word does not match pattern */ + return NULL; + } /* check that the prefix matches */ for (; p != m && *w && *w == *p; w++, p++) continue; Index: src/usr.bin/make/unit-tests/sysv.exp diff -u src/usr.bin/make/unit-tests/sysv.exp:1.2 src/usr.bin/make/unit-tests/sysv.exp:1.3 --- src/usr.bin/make/unit-tests/sysv.exp:1.2 Sat Apr 25 14:20:57 2020 +++ src/usr.bin/make/unit-tests/sysv.exp Tue May 5 22:30:10 2020 @@ -11,4 +11,5 @@ a%.c asam.c.c asam.c a.c.c + exit status 0 Index: src/usr.bin/make/unit-tests/sysv.mk diff -u src/usr.bin/make/unit-tests/sysv.mk:1.3 src/usr.bin/make/unit-tests/sysv.mk:1.4 --- src/usr.bin/make/unit-tests/sysv.mk:1.3 Sat Apr 25 14:20:57 2020 +++ src/usr.bin/make/unit-tests/sysv.mk Tue May 5 22:30:10 2020 @@ -1,4 +1,4 @@ -# $Id: sysv.mk,v 1.3 2020/04/25 18:20:57 christos Exp $ +# $Id: sysv.mk,v 1.4 2020/05/06 02:30:10 christos Exp $ FOO ?= FOOBAR = ${FOO:=bar} @@ -11,7 +11,7 @@ FUN = ${B}${S}fun SUN = the Sun # we expect nothing when FOO is empty -all: foo fun sam +all: foo fun sam bla foo: @echo FOOBAR = ${FOOBAR} @@ -36,3 +36,8 @@ sam: @echo ${SAM:%=a%.c} @echo ${SAM:%.c=a%.c} @echo ${SAM:sam%=a%.c} + +BLA= + +bla: + @echo $(BLA:%=foo/%x)