summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorsjg <sjg@NetBSD.org>2017-04-21 22:15:44 +0000
committersjg <sjg@NetBSD.org>2017-04-21 22:15:44 +0000
commitb49ead78fb3bfc7cdbfa6f26e019b4f3c5372cac (patch)
treed50d4a6ccb231ce7f2ab9b65b684ce9462f5782a /usr.bin/make
parent22009e324b9885f47c4e7d9128f6644c527b24db (diff)
Str_Match: fix closure tests for [^] and add unit-test.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/str.c15
-rw-r--r--usr.bin/make/unit-tests/modmatch.exp1
-rw-r--r--usr.bin/make/unit-tests/modmatch.mk1
3 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
index 4c56e15b78d..b5255bc9c70 100644
--- a/usr.bin/make/str.c
+++ b/usr.bin/make/str.c
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $ */
+/* $NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg 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.37 2017/04/11 17:30:13 sjg Exp $");
+__RCSID("$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -382,8 +382,11 @@ Str_Match(const char *string, const char *pattern)
} else
nomatch = 0;
for (;;) {
- if ((*pattern == ']') || (*pattern == 0))
- return(nomatch);
+ if ((*pattern == ']') || (*pattern == 0)) {
+ if (nomatch)
+ break;
+ return(0);
+ }
if (*pattern == *string)
break;
if (pattern[1] == '-') {
@@ -400,7 +403,7 @@ Str_Match(const char *string, const char *pattern)
}
++pattern;
}
- if (nomatch)
+ if (nomatch && (*pattern != ']') && (*pattern != 0))
return 0;
while ((*pattern != ']') && (*pattern != 0))
++pattern;
diff --git a/usr.bin/make/unit-tests/modmatch.exp b/usr.bin/make/unit-tests/modmatch.exp
index 73dbb6a87b8..a7bf8b748f5 100644
--- a/usr.bin/make/unit-tests/modmatch.exp
+++ b/usr.bin/make/unit-tests/modmatch.exp
@@ -16,4 +16,5 @@ LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
Mscanner=OK
Upper=One Two Three Four
Lower=five six seven
+nose=One Three five
exit status 0
diff --git a/usr.bin/make/unit-tests/modmatch.mk b/usr.bin/make/unit-tests/modmatch.mk
index 2c031388493..45199287acd 100644
--- a/usr.bin/make/unit-tests/modmatch.mk
+++ b/usr.bin/make/unit-tests/modmatch.mk
@@ -31,3 +31,4 @@ LIST= One Two Three Four five six seven
check-cclass:
@echo Upper=${LIST:M[A-Z]*}
@echo Lower=${LIST:M[^A-Z]*}
+ @echo nose=${LIST:M[^s]*[ex]}