mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-24 07:03:45 +00:00
ignore: move star-star matching closer to it use
Instead of threading the state down to the larger loop, let's have the loop where we detect the double star so each of them are easier to read.
This commit is contained in:
parent
1c3018eb12
commit
d45928cc0d
@ -69,8 +69,7 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
|
|||||||
if (recurs-- == 0)
|
if (recurs-- == 0)
|
||||||
return FNM_NORES;
|
return FNM_NORES;
|
||||||
|
|
||||||
for (stringstart = string;;) {
|
for (stringstart = string;;)
|
||||||
bool match_slash = false;
|
|
||||||
switch (c = *pattern++) {
|
switch (c = *pattern++) {
|
||||||
case EOS:
|
case EOS:
|
||||||
if ((flags & FNM_LEADING_DIR) && *string == '/')
|
if ((flags & FNM_LEADING_DIR) && *string == '/')
|
||||||
@ -103,8 +102,15 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
|
|||||||
return (FNM_NOMATCH);
|
return (FNM_NOMATCH);
|
||||||
|
|
||||||
c = *++pattern;
|
c = *++pattern;
|
||||||
flags &= ~FNM_PATHNAME;
|
do {
|
||||||
match_slash = true;
|
int e = p_fnmatchx(pattern, string, recurs_flags, recurs);
|
||||||
|
if (e != FNM_NOMATCH)
|
||||||
|
return e;
|
||||||
|
string = strchr(string, '/');
|
||||||
|
} while (string++);
|
||||||
|
|
||||||
|
/* If we get here, we didn't find a match */
|
||||||
|
return FNM_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*string == '.' && (flags & FNM_PERIOD) &&
|
if (*string == '.' && (flags & FNM_PERIOD) &&
|
||||||
@ -135,17 +141,7 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
|
|||||||
return e;
|
return e;
|
||||||
if (test == '/' && (flags & FNM_PATHNAME))
|
if (test == '/' && (flags & FNM_PATHNAME))
|
||||||
break;
|
break;
|
||||||
|
++string;
|
||||||
/* searching for star-star, so we jump over entire dirs */
|
|
||||||
if (match_slash) {
|
|
||||||
const char *slash;
|
|
||||||
if (!(slash = strchr(string, '/')))
|
|
||||||
break;
|
|
||||||
|
|
||||||
string = slash + 1;
|
|
||||||
} else {
|
|
||||||
++string;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (FNM_NOMATCH);
|
return (FNM_NOMATCH);
|
||||||
case '[':
|
case '[':
|
||||||
@ -187,7 +183,6 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
|
|||||||
++string;
|
++string;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user