diff options
author | Chet Ramey <chet.ramey@case.edu> | 2018-12-20 11:41:58 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2018-12-20 11:41:58 -0500 |
commit | f250956cb2a8dca13fc0242affc225f9d6983604 (patch) | |
tree | 2df8e15963af786dc8efed1c91c4d823a3bf05bb /lib | |
parent | 2ae59c1134a75d5778997b7202b15b0586283042 (diff) | |
download | bash-5.0-testing.tar.gz |
bash-5.0-rc1 releasebash-5.0-rc1bash-5.0-testing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/glob/sm_loop.c | 11 | ||||
-rw-r--r-- | lib/glob/smatch.c | 70 | ||||
-rw-r--r-- | lib/readline/doc/rltech.texi | 17 | ||||
-rw-r--r-- | lib/readline/doc/version.texi | 6 | ||||
-rw-r--r-- | lib/sh/strcasecmp.c | 2 |
5 files changed, 93 insertions, 13 deletions
diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index 2de5acd3..cc14fb16 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -384,7 +384,7 @@ BRACKMATCH (p, test, flags) { register CHAR cstart, cend, c; register int not; /* Nonzero if the sense of the character class is inverted. */ - int brcnt, brchr, forcecoll; + int brcnt, brchr, forcecoll, isrange; INT pc; CHAR *savep; U_CHAR orig_test; @@ -519,6 +519,7 @@ BRACKMATCH (p, test, flags) } cstart = cend = FOLD (cstart); + isrange = 0; /* POSIX.2 2.8.3.1.2 says: `An expression containing a `[' that is not preceded by a backslash and is not part of a bracket @@ -573,10 +574,18 @@ BRACKMATCH (p, test, flags) c = FOLD (c); continue; } + isrange = 1; } +#if 0 /* TAG: bash-5.1 */ + if (isrange == 0 && test == cstart) + goto matched; + if (isrange && RANGECMP (test, cstart, forcecoll) >= 0 && RANGECMP (test, cend, forcecoll) <= 0) + goto matched; +#else if (RANGECMP (test, cstart, forcecoll) >= 0 && RANGECMP (test, cend, forcecoll) <= 0) goto matched; +#endif if (c == L(']')) break; diff --git a/lib/glob/smatch.c b/lib/glob/smatch.c index 025fe4fc..64fdbbb7 100644 --- a/lib/glob/smatch.c +++ b/lib/glob/smatch.c @@ -30,6 +30,12 @@ #include "shmbutil.h" #include "xmalloc.h" +#include <errno.h> + +#if !defined (errno) +extern int errno; +#endif + /* First, compile `sm_loop.c' for single-byte characters. */ #define CHAR unsigned char #define U_CHAR unsigned char @@ -82,7 +88,7 @@ rangecmp (c1, c2, forcecoll) if ((ret = strcoll (s1, s2)) != 0) return ret; - return (c1 - c2); + return (c1 - c2); /* impose total ordering */ } #else /* !HAVE_STRCOLL */ # define rangecmp(c1, c2, f) ((int)(c1) - (int)(c2)) @@ -282,6 +288,41 @@ is_cclass (c, name) extern char *mbsmbchar __P((const char *)); +#if FNMATCH_EQUIV_FALLBACK +/* We don't include <fnmatch.h> in order to avoid namespace collisions; the + internal strmatch still uses the FNM_ constants. */ +extern int fnmatch (const char *, const char *, int); + +/* Construct a string w1 = "c1" and a pattern w2 = "[[=c2=]]" and pass them + to fnmatch to see if wide characters c1 and c2 collate as members of the + same equivalence class. We can't really do this portably any other way */ +static int +_fnmatch_fallback_wc (c1, c2) + wchar_t c1, c2; /* string char, patchar */ +{ + char w1[MB_LEN_MAX+1]; /* string */ + char w2[MB_LEN_MAX+8]; /* constructed pattern */ + int l1, l2; + + l1 = wctomb (w1, c1); + if (l1 == -1) + return (2); + w1[l1] = '\0'; + + /* reconstruct the pattern */ + w2[0] = w2[1] = '['; + w2[2] = '='; + l2 = wctomb (w2+3, c2); + if (l2 == -1) + return (2); + w2[l2+3] = '='; + w2[l2+4] = w2[l2+5] = ']'; + w2[l2+6] = '\0'; + + return (fnmatch ((const char *)w2, (const char *)w1, 0)); +} +#endif + static int rangecmp_wc (c1, c2, forcecoll) wint_t c1, c2; @@ -289,6 +330,7 @@ rangecmp_wc (c1, c2, forcecoll) { static wchar_t s1[2] = { L' ', L'\0' }; static wchar_t s2[2] = { L' ', L'\0' }; + int r, oerrno; if (c1 == c2) return 0; @@ -299,14 +341,38 @@ rangecmp_wc (c1, c2, forcecoll) s1[0] = c1; s2[0] = c2; +#if 0 /* TAG:bash-5.1 */ + /* We impose a total ordering here by returning c1-c2 if wcscoll returns 0, + as we do above in the single-byte case. If we do this, we can no longer + use this code in collequiv_wc */ + if ((r = wcscoll (s1, s2)) != 0) + return r; + return ((int)(c1 - c2)); /* impose total ordering */ +#else return (wcscoll (s1, s2)); +#endif } +/* Returns non-zero on success */ static int collequiv_wc (c, equiv) wint_t c, equiv; { - return (c == equiv); + wchar_t s, p; + + if (rangecmp_wc (c, equiv, 1) == 0) + return 1; +#if FNMATCH_EQUIV_FALLBACK +/* We check explicitly for success (fnmatch returns 0) to avoid problems if + our local definition of FNM_NOMATCH (strmatch.h) doesn't match the + system's (fnmatch.h). We don't care about error return values here. */ + + s = c; + p = equiv; + return (_fnmatch_fallback_wc (s, p) == 0); +#else + return 0; +#endif } /* Helper function for collating symbol. */ diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index 3624ea3e..28a02d99 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -720,19 +720,22 @@ Return the name matching @var{keymap}. @var{name} is one which would be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). @end deftypefun -@deftypefun void rl_set_keymap (const char *name, Keymap keymap) +@deftypefun int rl_set_keymap_name (const char *name, Keymap keymap) Set the name of @var{keymap}. This name will then be "registered" and available for use in a @code{set keymap} inputrc directive @pxref{Readline Init File}). -The @var{name} may not be one of Readline's builtin names; +The @var{name} may not be one of Readline's builtin keymap names; you may not add a different name for one of Readline's builtin keymaps. -Readline will make a copy of @var{name}. You may replace the name associated with a given keymap by calling this -function two or more times with the same @var{keymap} argument. -You can associate a registered name with a new keymap by calling this -function two or more times with the same @var{name} argument. +function more than once with the same @var{keymap} argument. +You may associate a registered @var{name} with a new keymap by calling this +function more than once with the same @var{name} argument. There is no way to remove a named keymap once the name has been registered. +Readline will make a copy of @var{name}. +The return value is greater than zero unless @var{name} is one of +Readline's builtin keymap names or @var{keymap} is one of Readline's +builtin keymaps. @end deftypefun @node Binding Keys @@ -2143,6 +2146,8 @@ character (@samp{\0}) prevents anything being appended automatically. This can be changed in application-specific completion functions to provide the ``most sensible word separator character'' according to an application-specific command line syntax specification. +It is set to the default before any application-specific completion function +is called, and may only be changed within such a function. @end deftypevar @deftypevar int rl_completion_suppress_append diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 7e08db61..576c35c8 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -4,7 +4,7 @@ Copyright (C) 1988-2018 Free Software Foundation, Inc. @set EDITION 8.0 @set VERSION 8.0 -@set UPDATED 18 September 2018 -@set UPDATED-MONTH September 2018 +@set UPDATED 30 November 2018 +@set UPDATED-MONTH November 2018 -@set LASTCHANGE Tue Sep 18 13:08:12 EDT 2018 +@set LASTCHANGE Fri Nov 30 22:50:53 EST 2018 diff --git a/lib/sh/strcasecmp.c b/lib/sh/strcasecmp.c index 5542f715..70d0551a 100644 --- a/lib/sh/strcasecmp.c +++ b/lib/sh/strcasecmp.c @@ -32,7 +32,7 @@ int strncasecmp (string1, string2, count) const char *string1; const char *string2; - int count; + size_t count; { register const char *s1; register const char *s2; |