diff options
author | Wayne Davison <wayned@samba.org> | 2003-07-05 18:48:34 +0000 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2003-07-05 18:48:34 +0000 |
commit | 20b2e9cef70ef6ab6e28904a508569a86a5df7d0 (patch) | |
tree | 1645ba5910e2a34b0a447c37141816aac0cd2402 /lib | |
parent | e37d8229f5de9398b6823d0076818bc9409cccf2 (diff) | |
download | android_external_rsync-20b2e9cef70ef6ab6e28904a508569a86a5df7d0.tar.gz android_external_rsync-20b2e9cef70ef6ab6e28904a508569a86a5df7d0.tar.bz2 android_external_rsync-20b2e9cef70ef6ab6e28904a508569a86a5df7d0.zip |
Improved the ABORT logic to allow aborting consecutive "*" wildcards
back to a "**" wildcard. Added optional debug code for recursion stats.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wildmatch.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/wildmatch.c b/lib/wildmatch.c index 99da11eb..1d3f92f4 100644 --- a/lib/wildmatch.c +++ b/lib/wildmatch.c @@ -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; } |