]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20120928 snapshot
authorChet Ramey <chet@caleb.ins.cwru.edu>
Wed, 10 Oct 2012 13:38:49 +0000 (09:38 -0400)
committerChet Ramey <chet@caleb.ins.cwru.edu>
Wed, 10 Oct 2012 13:38:49 +0000 (09:38 -0400)
CWRU/CWRU.chlog
lib/glob/sm_loop.c
lib/readline/doc/rltech.texi

index 7e684716b3bcdae55d197d720124a68b55a496bf..b76f7baeba8442288dce191f6066999a54230718 100644 (file)
@@ -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 <hans1worst@gmail.com>
index ff5adb31ccc2a56478f589efbbce58aaddd7fc0b..f4ca34550684e3aa9d92f4da800e28ff78b18893 100644 (file)
@@ -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;
index 42c8bb95b6c3a53157b0c02ebb82771ca75173b7..f2d2a510f2fec99eb6d364910b8d951d42ca090b 100644 (file)
@@ -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.