commit bash-20181123 snapshot

This commit is contained in:
Chet Ramey
2018-12-03 10:29:56 -05:00
parent d61300ec87
commit 0712a90cd8
42 changed files with 3440 additions and 4637 deletions
+10 -1
View File
@@ -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;
+17 -2
View File
@@ -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))
@@ -289,6 +295,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 +306,22 @@ 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 ((r = wcscoll (s1, s2)) != 0)
return r;
return ((int)(c1 - c2)); /* impose total ordering */
#else
return (wcscoll (s1, s2));
#endif
}
static int
collequiv_wc (c, equiv)
wint_t c, equiv;
{
return (c == equiv);
return (rangecmp_wc (c, equiv, 1) == 0);
}
/* Helper function for collating symbol. */