Module Name:    src
Committed By:   sjg
Date:           Fri Apr 21 22:15:44 UTC 2017

Modified Files:
        src/usr.bin/make: str.c
        src/usr.bin/make/unit-tests: modmatch.exp modmatch.mk

Log Message:
Str_Match: fix closure tests for [^] and add unit-test.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/str.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/modmatch.exp \
    src/usr.bin/make/unit-tests/modmatch.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.37 src/usr.bin/make/str.c:1.38
--- src/usr.bin/make/str.c:1.37	Tue Apr 11 17:30:13 2017
+++ src/usr.bin/make/str.c	Fri Apr 21 22:15:44 2017
@@ -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
 			} 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;
 			}
-			if (nomatch)
+			if (nomatch && (*pattern != ']') && (*pattern != 0))
 				return 0;
 			while ((*pattern != ']') && (*pattern != 0))
 				++pattern;

Index: src/usr.bin/make/unit-tests/modmatch.exp
diff -u src/usr.bin/make/unit-tests/modmatch.exp:1.2 src/usr.bin/make/unit-tests/modmatch.exp:1.3
--- src/usr.bin/make/unit-tests/modmatch.exp:1.2	Thu Apr 13 16:23:39 2017
+++ src/usr.bin/make/unit-tests/modmatch.exp	Fri Apr 21 22:15:44 2017
@@ -16,4 +16,5 @@ LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/
 Mscanner=OK
 Upper=One Two Three Four
 Lower=five six seven
+nose=One Three five
 exit status 0
Index: src/usr.bin/make/unit-tests/modmatch.mk
diff -u src/usr.bin/make/unit-tests/modmatch.mk:1.2 src/usr.bin/make/unit-tests/modmatch.mk:1.3
--- src/usr.bin/make/unit-tests/modmatch.mk:1.2	Thu Apr 13 16:23:39 2017
+++ src/usr.bin/make/unit-tests/modmatch.mk	Fri Apr 21 22:15:44 2017
@@ -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]}

Reply via email to