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

[PATCH 2/4] dir.c: get rid of the wildcard symbol set in no_wildcard()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 7, 2012, 07:53 UTC
Message-ID
<1339055617-23028-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1339055617-23028-1-git-send-email-pclouds@gmail.com>

Elsewhere in this file is_glob_special() is also used to check for wildcards, which is defined in ctype. Make no_wildcard() also use this function (indirectly via simple_length())

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/dir.c b/dir.c
index e756de1..bbf958c 100644
--- a/dir.c
+++ b/dir.c
@@ -288,9 +288,24 @@ int match_pathspec_depth(const struct pathspec *ps,
 	return retval;
 }
 
+/*
+ * Return the length of the "simple" part of a path match limiter.
+ */
+static int simple_length(const char *match)
+{
+	int len = -1;
+
+	for (;;) {
+		unsigned char c = *match++;
+		len++;
+		if (c == '\0' || is_glob_special(c))
+			return len;
+	}
+}
+
 static int no_wildcard(const char *string)
 {
-	return string[strcspn(string, "*?[{\\")] == '\0';
+	return string[simple_length(string)] == '\0';
 }
 
 void add_exclude(const char *string, const char *base,
@@ -997,21 +1012,6 @@ static int cmp_name(const void *p1, const void *p2)
 				  e2->name, e2->len);
 }
 
-/*
- * Return the length of the "simple" part of a path match limiter.
- */
-static int simple_length(const char *match)
-{
-	int len = -1;
-
-	for (;;) {
-		unsigned char c = *match++;
-		len++;
-		if (c == '\0' || is_glob_special(c))
-			return len;
-	}
-}
-
 static struct path_simplify *create_simplify(const char **pathspec)
 {
 	int nr, alloc = 0;
-- 
1.7.11.rc1.185.g281ad67
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 7 in “Unindent excluded_from_list()”
  1. 1/4 Unindent excluded_from_list()Nguyễn Thái Ngọc Duy, Jun 7, 2012
  2. 2/4 dir.c: get rid of the wildcard symbol set in no_wildcard()Nguyễn Thái Ngọc Duy, Jun 7, 2012
  3. 3/4 exclude: do strcmp as much as possible before fnmatchNguyễn Thái Ngọc Duy, Jun 7, 2012
  4. 4/4 exclude: reuse last basename comparisonNguyễn Thái Ngọc Duy, Jun 7, 2012
  5. Junio C HamanoJun 7, 2012
  6. Junio C HamanoJun 7, 2012
  7. Nguyen Thai Ngoc DuyJun 8, 2012

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.