mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-24 14:48:16 -04:00
Improved the ABORT logic to allow aborting consecutive "*" wildcards
back to a "**" wildcard. Added optional debug code for recursion stats.
This commit is contained in:
1 parent
e37d8229f5
commit
20b2e9cef7
1 file changed
+20
-6
+20
-6
@@ -16,13 +16,22 @@
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define ABORT -1
|
||||
#define ABORT_ALL -1
|
||||
#define ABORT_TO_STARSTAR -2
|
||||
|
||||
#ifdef WILD_TEST_DEPTH
|
||||
int wildmatch_depth;
|
||||
#endif
|
||||
|
||||
static int domatch(const char *p, const char *text)
|
||||
{
|
||||
int matched, special;
|
||||
char ch, prev;
|
||||
|
||||
#ifdef WILD_TEST_DEPTH
|
||||
wildmatch_depth++;
|
||||
#endif
|
||||
|
||||
for ( ; (ch = *p) != '\0'; text++, p++) {
|
||||
if (*text == '\0' && ch != '*')
|
||||
return FALSE;
|
||||
@@ -54,12 +63,14 @@ static int domatch(const char *p, const char *text)
|
||||
return special? TRUE : strchr(text, '/') == 0;
|
||||
}
|
||||
for ( ; *text; text++) {
|
||||
if ((matched = domatch(p, text)) != FALSE)
|
||||
return matched;
|
||||
if (!special && *text == '/')
|
||||
return FALSE;
|
||||
if ((matched = domatch(p, text)) != FALSE) {
|
||||
if (!special || matched != ABORT_TO_STARSTAR)
|
||||
return matched;
|
||||
}
|
||||
else if (!special && *text == '/')
|
||||
return ABORT_TO_STARSTAR;
|
||||
}
|
||||
return ABORT;
|
||||
return ABORT_ALL;
|
||||
case '[':
|
||||
special = *++p == NEGATE_CLASS ? TRUE : FALSE;
|
||||
if (special) {
|
||||
@@ -97,5 +108,8 @@ static int domatch(const char *p, const char *text)
|
||||
|
||||
int wildmatch(const char *p, const char *text)
|
||||
{
|
||||
#ifdef WILD_TEST_DEPTH
|
||||
wildmatch_depth = 0;
|
||||
#endif
|
||||
return domatch(p, text) == TRUE;
|
||||
}
|
||||
Reference in new issue
Block a user