git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/5] wildmatch: more cleanups after killing uchar

From
Masahiro Yamada <masahiroy@kernel.org>
Date
Feb 10, 2023, 07:59 UTC
Message-ID
<20230210075939.44949-6-masahiroy@kernel.org>
In-Reply-To
<20230210075939.44949-1-masahiroy@kernel.org>

Remove the local function dowild(), which is now equivalent to wildmatch().

Remove the local variable, slash.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
 wildmatch.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/wildmatch.c b/wildmatch.c
index 7dffd783cb..24577e9b8e 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -17,7 +17,7 @@
 				    && strncmp(class, litmatch, len) == 0)
 
 /* Match pattern "p" against "text" */
-static int dowild(const char *p, const char *text, unsigned int flags)
+int wildmatch(const char *p, const char *text, unsigned int flags)
 {
 	char p_ch;
 	const char *pattern = p;
@@ -66,7 +66,7 @@ static int dowild(const char *p, const char *text, unsigned int flags)
 					 * both foo/bar and foo/a/bar.
 					 */
 					if (p[0] == '/' &&
-					    dowild(p + 1, text, flags) == WM_MATCH)
+					    wildmatch(p + 1, text, flags) == WM_MATCH)
 						return WM_MATCH;
 					match_slash = 1;
 				} else /* WM_PATHNAME is set */
@@ -88,10 +88,9 @@ static int dowild(const char *p, const char *text, unsigned int flags)
 				 * with WM_PATHNAME matches the next
 				 * directory
 				 */
-				const char *slash = strchr(text, '/');
-				if (!slash)
+				text = strchr(text, '/');
+				if (!text)
 					return WM_NOMATCH;
-				text = slash;
 				/* the slash is consumed by the top-level for loop */
 				break;
 			}
@@ -121,7 +120,7 @@ static int dowild(const char *p, const char *text, unsigned int flags)
 					if (t_ch != p_ch)
 						return WM_NOMATCH;
 				}
-				if ((matched = dowild(p, text, flags)) != WM_NOMATCH) {
+				if ((matched = wildmatch(p, text, flags)) != WM_NOMATCH) {
 					if (!match_slash || matched != WM_ABORT_TO_STARSTAR)
 						return matched;
 				} else if (!match_slash && t_ch == '/')
@@ -231,9 +230,3 @@ static int dowild(const char *p, const char *text, unsigned int flags)
 
 	return *text ? WM_NOMATCH : WM_MATCH;
 }
-
-/* Match the "pattern" against the "text" string. */
-int wildmatch(const char *pattern, const char *text, unsigned int flags)
-{
-	return dowild(pattern, text, flags);
-}
-- 
2.34.1
Previous: Masahiro YamadaNext: Masahiro Yamada
Message 15 of 17 in “Clean up wildmatch.c”
  1. 0/5 Clean up wildmatch.cMasahiro Yamada, Feb 10, 2023
  2. 1/5 git-compat-util: add isblank() and isgraph()Masahiro Yamada, Feb 10, 2023
  3. Ævar Arnfjörð BjarmasonFeb 10, 2023
  4. Masahiro YamadaFeb 10, 2023
  5. Junio C HamanoFeb 10, 2023
  6. Masahiro YamadaFeb 10, 2023
  7. René ScharfeFeb 10, 2023
  8. Masahiro YamadaFeb 11, 2023
  9. René ScharfeFeb 11, 2023
  10. René ScharfeFeb 11, 2023
  11. 2/5 wildmatch: remove IS*() macrosMasahiro Yamada, Feb 10, 2023
  12. 3/5 wildmatch: remove NEGATE_CLASS and NEGATE_CLASS2 macrosMasahiro Yamada, Feb 10, 2023
  13. Ævar Arnfjörð BjarmasonFeb 10, 2023
  14. Masahiro YamadaFeb 10, 2023
  15. 5/5 wildmatch: more cleanups after killing ucharMasahiro Yamada, Feb 10, 2023
  16. 4/5 wildmatch: use char instead of ucharMasahiro Yamada, Feb 10, 2023
  17. Ævar Arnfjörð BjarmasonFeb 10, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.