Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Str_Match: allow [^a-z] to behave as expected.



details:   https://anonhg.NetBSD.org/src/rev/fee7f9ad09ce
branches:  trunk
changeset: 352827:fee7f9ad09ce
user:      sjg <sjg%NetBSD.org@localhost>
date:      Tue Apr 11 17:30:13 2017 +0000

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

diffstat:

 usr.bin/make/str.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (61 lines):

diff -r 72025c31ca47 -r fee7f9ad09ce usr.bin/make/str.c
--- a/usr.bin/make/str.c        Tue Apr 11 17:27:54 2017 +0000
+++ b/usr.bin/make/str.c        Tue Apr 11 17:30:13 2017 +0000
@@ -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 @@
                 * 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 @@
                                }
                                ++pattern;
                        }
+                       if (nomatch)
+                               return 0;
                        while ((*pattern != ']') && (*pattern != 0))
                                ++pattern;
                        goto thisCharOK;



Home | Main Index | Thread Index | Old Index