diff options
author | James Youngman <jay@gnu.org> | 2011-05-12 22:14:11 +0100 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2011-05-13 21:06:50 -0600 |
commit | 0bc30ce602212b9005e296602081138448691e79 (patch) | |
tree | 1ad998074b0ba9b74e20c7c7e2f53c3515846c47 /lib/fnmatch_loop.c | |
parent | d65c36a0dad9c79af241ae49c93ff7c7967a1040 (diff) | |
download | gnulib-0bc30ce602212b9005e296602081138448691e79.tar.gz |
fnmatch: sync glibc change fixing Bugzilla bug #12378
* lib/fnmatch_loop.c (FCT): When matching '[' keep track of
beginning and fall back to matching as normal character if the
string ends before the matching ']' is found. This is what POSIX
requires.
Diffstat (limited to 'lib/fnmatch_loop.c')
-rw-r--r-- | lib/fnmatch_loop.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index ed760dd8af..1fb246f0a2 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -200,6 +200,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, case L_('['): { /* Nonzero if the sense of the character class is inverted. */ + CHAR *p_init = p; + CHAR *n_init = n; register bool not; CHAR cold; UCHAR fn; @@ -410,8 +412,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, } #endif else if (c == L_('\0')) - /* [ (unterminated) loses. */ - return FNM_NOMATCH; + { + /* [ unterminated, treat as normal character. */ + p = p_init; + n = n_init; + c = L_('['); + goto normal_match; + } else { bool is_range = false; |