X-Git-Url: https://git.cworth.org/git?p=tar;a=blobdiff_plain;f=gnu%2Fexclude.c;fp=gnu%2Fexclude.c;h=dfa2aabff8f5bd045eb7976f9149b9961cd498b7;hp=00a053fc70a022ebb5fc4b3ce64be0848085c251;hb=de7372b23c3da92fbfaea2d1ac592f0b2ba87914;hpb=fbbfb9406a82e647ce27b6462b11a802fa48f31a diff --git a/gnu/exclude.c b/gnu/exclude.c index 00a053f..dfa2aab 100644 --- a/gnu/exclude.c +++ b/gnu/exclude.c @@ -136,6 +136,26 @@ fnmatch_pattern_has_wildcards (const char *str, int options) return false; } +static void +unescape_pattern (char *str) +{ + int inset = 0; + char *q = str; + do + { + if (inset) + { + if (*q == ']') + inset = 0; + } + else if (*q == '[') + inset = 1; + else if (*q == '\\') + q++; + } + while ((*str++ = *q++)); +} + /* Return a newly allocated and empty exclude list. */ struct exclude * @@ -344,7 +364,7 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f) { char const *pattern = exclude[i].pattern; int options = exclude[i].options; - if (excluded != exclude_fnmatch (pattern, f, options)) + if (exclude_fnmatch (pattern, f, options)) return !excluded; } return excluded; @@ -482,6 +502,8 @@ add_exclude (struct exclude *ex, char const *pattern, int options) seg = new_exclude_segment (ex, exclude_hash, options); str = xstrdup (pattern); + if (options & EXCLUDE_WILDCARDS) + unescape_pattern (str); p = hash_insert (seg->v.table, str); if (p != str) free (str);