Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: clean up comments for string splitting an...



details:   https://anonhg.NetBSD.org/src/rev/f3d12287acaa
branches:  trunk
changeset: 366726:f3d12287acaa
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 11 09:24:07 2022 +0000

description:
make: clean up comments for string splitting and string matching

No binary change.

diffstat:

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

diffs (67 lines):

diff -r dd065bfc1b43 -r f3d12287acaa usr.bin/make/str.c
--- a/usr.bin/make/str.c        Sat Jun 11 09:15:49 2022 +0000
+++ b/usr.bin/make/str.c        Sat Jun 11 09:24:07 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: str.c,v 1.92 2022/06/11 08:06:32 rillig Exp $  */
+/*     $NetBSD: str.c,v 1.93 2022/06/11 09:24:07 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*     "@(#)str.c      5.8 (Berkeley) 6/1/90"  */
-MAKE_RCSID("$NetBSD: str.c,v 1.92 2022/06/11 08:06:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.93 2022/06/11 09:24:07 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -219,7 +219,7 @@
                                if (word_start == NULL)
                                        word_start = word_end;
                                *word_end++ = '\\';
-                               /* catch '\' at end of line */
+                               /* catch lonely '\' at end of string */
                                if (str_p[1] == '\0')
                                        continue;
                                ch = *++str_p;
@@ -317,6 +317,8 @@
  * The following special characters are known *?\[] (as in fnmatch(3)).
  *
  * XXX: this function does not detect or report malformed patterns.
+ *
+ * See varmod-match.mk for examples and edge cases.
  */
 bool
 Str_Match(const char *str, const char *pat)
@@ -340,13 +342,7 @@
                if (*pat == '?')        /* match any single character */
                        continue;
 
-               /*
-                * A '[' in the pattern matches a character from a list.
-                * The '[' is followed by the list of acceptable characters,
-                * or by ranges (two characters separated by '-'). In these
-                * character lists, the backslash is an ordinary character.
-                */
-               if (*pat == '[') {
+               if (*pat == '[') {      /* match a character from a list */
                        bool neg = pat[1] == '^';
                        pat += neg ? 2 : 1;
 
@@ -356,15 +352,6 @@
                                                break;
                                        return false;
                                }
-                               /*
-                                * XXX: This naive comparison makes the
-                                * control flow of the pattern parser
-                                * dependent on the actual value of the
-                                * string.  This is unpredictable.  It may be
-                                * though that the code only looks wrong but
-                                * actually all code paths result in the same
-                                * behavior.  This needs further tests.
-                                */
                                if (*pat == *str)
                                        break;
                                if (pat[1] == '-') {



Home | Main Index | Thread Index | Old Index