From 253e3c70854a1a46f2cb3463363c3c7f7132abe6 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 10 Oct 2012 09:38:49 -0400 Subject: commit bash-20120928 snapshot --- CWRU/CWRU.chlog | 11 +++++++++++ lib/glob/sm_loop.c | 17 +++++++++++++++-- lib/readline/doc/rltech.texi | 3 ++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 7e684716..b76f7bae 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -3622,3 +3622,14 @@ lib/readline/input.c lib/readline/doc/rltech.texi - rl_input_available_hook: document + + 9/27 + ---- +lib/glob/sm_loop.c: + - GMATCH: after one or more `*', an instance of ?(x) can match zero or + 1 times (unlike ?, which has to match one character). The old code + failed if it didn't match at least once. Fixes `a*?(x)' bug. + - GMATCH: if we hit the end of the search string, but not the end of + the pattern, and the rest of the pattern is something that can + match the NUL at the end of the search string, we should successfully + match. Fixes `a*!(x)' bug reported by diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index ff5adb31..f4ca3455 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -145,8 +145,9 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe); if (EXTMATCH (c, newn, se, p, pe, flags) == 0) return (0); } - /* We didn't match. If we have a `?(...)', that's failure. */ - return FNM_NOMATCH; + /* We didn't match. If we have a `?(...)', we can match 0 + or 1 times. */ + return 0; } #endif else if (c == L('?')) @@ -192,6 +193,18 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe); if (p == pe && (c == L('?') || c == L('*'))) return (0); + /* If we've hit the end of the string and the rest of the pattern + is something that matches the empty string, we can succeed. */ +#if defined (EXTENDED_GLOB) + if (n == se && ((flags & FNM_EXTMATCH) && (c == L('!') || c == L('?')) && *p == L('('))) + { + --p; + if (EXTMATCH (c, n, se, p, pe, flags) == 0) + return (c == L('!') ? FNM_NOMATCH : 0); + return (c == L('!') ? 0 : FNM_NOMATCH); + } +#endif + /* General case, use recursion. */ { U_CHAR c1; diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index 42c8bb95..f2d2a510 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -449,7 +449,8 @@ source. Readline queries for available input when implementing intra-key-sequence timeouts during input and incremental searches. This may use an application-specific timeout before returning a value; -Readline uses the value passed to @code{rl_set_keyboard_input_timeout()}. +Readline uses the value passed to @code{rl_set_keyboard_input_timeout()} +or the value of the user-settable @var{keyseq-timeout} variable. This is designed for use by functions using Readline's callback interface (@pxref{Alternate Interface}), which may not use the traditional @code{read(2)} and file descriptor interface. -- cgit v1.2.1