diff options
| author | christos <christos@NetBSD.org> | 2020-05-06 02:30:10 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2020-05-06 02:30:10 +0000 |
| commit | 9a14dd9bc55901d9366dc37ca4cccfdd2eb9e1fa (patch) | |
| tree | 0e1b432a8d7466cb26c53ed0653fbc5cc46cf4f5 | |
| parent | 3fa68824cd7600a101fc6ee6feda31c020bb23b7 (diff) | |
Behave like gmake: empty string does not match % pattern
| -rw-r--r-- | usr.bin/make/str.c | 10 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/sysv.exp | 1 | ||||
| -rw-r--r-- | usr.bin/make/unit-tests/sysv.mk | 9 |
3 files changed, 15 insertions, 5 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index d6389bdbbe9..d3d7994a086 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -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 char *pattern, size_t *len, 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; diff --git a/usr.bin/make/unit-tests/sysv.exp b/usr.bin/make/unit-tests/sysv.exp index bcf572a265d..610f97c39e8 100644 --- a/usr.bin/make/unit-tests/sysv.exp +++ b/usr.bin/make/unit-tests/sysv.exp @@ -11,4 +11,5 @@ a%.c asam.c.c asam.c a.c.c + exit status 0 diff --git a/usr.bin/make/unit-tests/sysv.mk b/usr.bin/make/unit-tests/sysv.mk index 701580f136c..3a2444b4236 100644 --- a/usr.bin/make/unit-tests/sysv.mk +++ b/usr.bin/make/unit-tests/sysv.mk @@ -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) |
