Skip to content

Commit

Permalink
dir.c: get rid of the wildcard symbol set in no_wildcard()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Jun 7, 2012
1 parent 35a94d4 commit fcd631e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fcd631e

Please sign in to comment.