Module Name:    src
Committed By:   sjg
Date:           Tue Apr 11 17:30:13 UTC 2017

Modified Files:
        src/usr.bin/make: str.c

Log Message:
Str_Match: allow [^a-z] to behave as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/str.c

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.36 src/usr.bin/make/str.c:1.37
--- src/usr.bin/make/str.c:1.36	Wed Apr  6 09:57:00 2016
+++ src/usr.bin/make/str.c	Tue Apr 11 17:30:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.36 2016/04/06 09:57:00 gson Exp $	*/
+/*	$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.36 2016/04/06 09:57:00 gson Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 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.36 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $");
 #endif
 #endif				/* not lint */
 #endif
@@ -373,16 +373,23 @@ Str_Match(const char *string, const char
 		 * by a range (two characters separated by "-").
 		 */
 		if (*pattern == '[') {
+			int nomatch;
+
 			++pattern;
+			if (*pattern == '^') {
+				++pattern;
+				nomatch = 1;
+			} else
+				nomatch = 0;
 			for (;;) {
 				if ((*pattern == ']') || (*pattern == 0))
-					return(0);
+					return(nomatch);
 				if (*pattern == *string)
 					break;
 				if (pattern[1] == '-') {
 					c2 = pattern[2];
 					if (c2 == 0)
-						return(0);
+						return(nomatch);
 					if ((*pattern <= *string) &&
 					    (c2 >= *string))
 						break;
@@ -393,6 +400,8 @@ Str_Match(const char *string, const char
 				}
 				++pattern;
 			}
+			if (nomatch)
+				return 0;
 			while ((*pattern != ']') && (*pattern != 0))
 				++pattern;
 			goto thisCharOK;

Reply via email to