* lib/exclude.c (unescape_pattern): Don't worry about unescaped [;
it's not possible here. Handle the case of \ at end of pattern
without dumping core.
(add_exclude): Do not unescape the pattern if FNM_NOESCAPE is used.
2012-04-29 Paul Eggert <eggert@cs.ucla.edu>
+ exclude: handle wildcards with FNM_NOESCAPE and with trailing \
+ * lib/exclude.c (unescape_pattern): Don't worry about unescaped [;
+ it's not possible here. Handle the case of \ at end of pattern
+ without dumping core.
+ (add_exclude): Do not unescape the pattern if FNM_NOESCAPE is used.
+
_Noreturn: future-proof non-GNU and non-MSVC compilers
* build-aux/snippet/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
static void
unescape_pattern (char *str)
{
- int inset = 0;
- char *q = str;
+ char const *q = str;
do
- {
- if (inset)
- {
- if (*q == ']')
- inset = 0;
- }
- else if (*q == '[')
- inset = 1;
- else if (*q == '\\')
- q++;
- }
+ q += *q == '\\' && q[1];
while ((*str++ = *q++));
}
seg = new_exclude_segment (ex, exclude_hash, options);
str = xstrdup (pattern);
- if (options & EXCLUDE_WILDCARDS)
+ if ((options & (EXCLUDE_WILDCARDS | FNM_NOESCAPE)) == EXCLUDE_WILDCARDS)
unescape_pattern (str);
p = hash_insert (seg->v.table, str);
if (p != str)