X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fexclude.c;h=df49714a6be7eb68cdb037aebac61cd451ddf792;hb=1b94e030d122eb05acd5054b711e7bf6d49994e3;hp=d4dcd76bd9f193e1494be31ab73d0ade35b53949;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/lib/exclude.c b/lib/exclude.c index d4dcd76bd..df49714a6 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -1,7 +1,7 @@ /* exclude.c -- exclude file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1992-1994, 1997, 1999-2007, 2009-2011 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -134,6 +134,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 * @@ -342,7 +362,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; @@ -480,6 +500,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);