Module Name: src Committed By: rillig Date: Sat Jun 11 09:24:07 UTC 2022
Modified Files: src/usr.bin/make: str.c Log Message: make: clean up comments for string splitting and string matching No binary change. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 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.92 src/usr.bin/make/str.c:1.93 --- src/usr.bin/make/str.c:1.92 Sat Jun 11 08:06:32 2022 +++ src/usr.bin/make/str.c Sat Jun 11 09:24:07 2022 @@ -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 ex 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 *p 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 *p 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] == '-') {