summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-06-11 09:24:07 +0000
committerrillig <rillig@NetBSD.org>2022-06-11 09:24:07 +0000
commitbeaf6ce245284a6cc358dcd73e999f3bfb779ed3 (patch)
treeaf55e02a1b5425776c54a6b0df402d125923429f /usr.bin/make
parentb6f0f59610a644073f6fd7bb6945e1e23b6ceeaa (diff)
make: clean up comments for string splitting and string matching
No binary change.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/str.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
index 079ceba1566..d88f895630e 100644
--- a/usr.bin/make/str.c
+++ b/usr.bin/make/str.c
@@ -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 @@ Substring_Words(const char *str, bool expand)
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 @@ in_range(char e1, char c, char e2)
* 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 @@ Str_Match(const char *str, const char *pat)
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 @@ Str_Match(const char *str, const char *pat)
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] == '-') {