Module Name: src
Committed By: rillig
Date: Fri May 13 20:37:01 UTC 2022
Modified Files:
src/usr.bin/make: str.c
Log Message:
make: clean up low-level comments, eliminate common subexpression
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 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.89 src/usr.bin/make/str.c:1.90
--- src/usr.bin/make/str.c:1.89 Thu Mar 3 19:50:01 2022
+++ src/usr.bin/make/str.c Fri May 13 20:37:01 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.89 2022/03/03 19:50:01 rillig Exp $ */
+/* $NetBSD: str.c,v 1.90 2022/05/13 20:37:01 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.89 2022/03/03 19:50:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.90 2022/05/13 20:37:01 rillig Exp $");
static HashTable interned_strings;
@@ -302,34 +302,25 @@ bool
Str_Match(const char *str, const char *pat)
{
for (;;) {
- /*
- * See if we're at the end of both the pattern and the
- * string. If so, we succeeded. If we're at the end of the
- * pattern but not at the end of the string, we failed.
- */
if (*pat == '\0')
return *str == '\0';
- if (*str == '\0' && *pat != '*')
- return false;
- /*
- * A '*' in the pattern matches any substring. We handle this
- * by calling ourselves for each suffix of the string.
- */
+ /* A '*' in the pattern matches any substring. */
if (*pat == '*') {
pat++;
while (*pat == '*')
pat++;
if (*pat == '\0')
return true;
- while (*str != '\0') {
+ for (; *str != '\0'; str++)
if (Str_Match(str, pat))
return true;
- str++;
- }
return false;
}
+ if (*str == '\0')
+ return false;
+
/* A '?' in the pattern matches any single character. */
if (*pat == '?')
goto thisCharOK;