Skip to content

Commit fcd631e

Browse files
pcloudsgitster
authored andcommitted
dir.c: get rid of the wildcard symbol set in no_wildcard()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35a94d4 commit fcd631e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

dir.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,24 @@ int match_pathspec_depth(const struct pathspec *ps,
288288
return retval;
289289
}
290290

291+
/*
292+
* Return the length of the "simple" part of a path match limiter.
293+
*/
294+
static int simple_length(const char *match)
295+
{
296+
int len = -1;
297+
298+
for (;;) {
299+
unsigned char c = *match++;
300+
len++;
301+
if (c == '\0' || is_glob_special(c))
302+
return len;
303+
}
304+
}
305+
291306
static int no_wildcard(const char *string)
292307
{
293-
return string[strcspn(string, "*?[{\\")] == '\0';
308+
return string[simple_length(string)] == '\0';
294309
}
295310

296311
void add_exclude(const char *string, const char *base,
@@ -997,21 +1012,6 @@ static int cmp_name(const void *p1, const void *p2)
9971012
e2->name, e2->len);
9981013
}
9991014

1000-
/*
1001-
* Return the length of the "simple" part of a path match limiter.
1002-
*/
1003-
static int simple_length(const char *match)
1004-
{
1005-
int len = -1;
1006-
1007-
for (;;) {
1008-
unsigned char c = *match++;
1009-
len++;
1010-
if (c == '\0' || is_glob_special(c))
1011-
return len;
1012-
}
1013-
}
1014-
10151015
static struct path_simplify *create_simplify(const char **pathspec)
10161016
{
10171017
int nr, alloc = 0;

0 commit comments

Comments
 (0)