bash-5.0-beta release

This commit is contained in:
Chet Ramey
2018-09-17 15:10:56 -04:00
parent 9a51695bed
commit 2f5dfe5a18
144 changed files with 27560 additions and 36005 deletions
+9 -2
View File
@@ -92,7 +92,8 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
mktime.c strftime.c mbschr.c zcatfd.c zmapfd.c winsize.c eaccess.c \
wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \
casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \
utf8.c
# The header files for this library.
HSOURCES =
@@ -107,7 +108,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o \
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o \
wcsnwidth.o ${LIBOBJS}
utf8.o wcsnwidth.o ${LIBOBJS}
SUPPORT = Makefile
@@ -200,6 +201,7 @@ tmpfile.o: tmpfile.c
uconvert.o: uconvert.c
ufuncs.o: ufuncs.c
unicode.o: unicode.c
utf8.o: utf8.c
vprint.o: vprint.c
wcsdup.o: wcsdup.c
wcsnwidth.o: wcsnwidth.c
@@ -277,6 +279,7 @@ tmpfile.o: ${BUILD_DIR}/config.h
uconvert.o: ${BUILD_DIR}/config.h
ufuncs.o: ${BUILD_DIR}/config.h
unicode.o: ${BUILD_DIR}/config.h
utf8.o: ${BUILD_DIR}/config.h
vprint.o: ${BUILD_DIR}/config.h
wcsdup.o: ${BUILD_DIR}/config.h
wcsnwidth.o: ${BUILD_DIR}/config.h
@@ -612,6 +615,10 @@ unicode.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
unicode.o: ${BASHINCDIR}/stdc.h
unicode.o: ${topdir}/xmalloc.h
utf8.o: ${topdir}/bashansi.h
utf8.o: ${BASHINCDIR}/ansi_stdlib.h
utf8.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
winsize.o: ${BASHINCDIR}/stdc.h
winsize.o: ${topdir}/xmalloc.h
winsize.o: ${topdir}/bashtypes.h
+1 -1
View File
@@ -69,7 +69,7 @@ getenv (name)
if (var && exported_p (var))
return (value_cell (var));
}
else
else if (environ)
{
register int i, len;
+1 -7
View File
@@ -32,13 +32,7 @@ extern int locale_utf8locale;
#undef mbschr
static inline char *
utf8_mbschr (s, c)
const char *s;
int c;
{
return strchr (s, c); /* for now */
}
extern char *utf8_mbschr (const char *, int); /* XXX */
/* In some locales, the non-first byte of some multibyte characters have
the same value as some ascii character. Faced with these strings, a
+5 -1
View File
@@ -1,6 +1,6 @@
/* mbscmp - multibyte string comparison. */
/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
/* Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -26,6 +26,10 @@
#include <stddef.h>
#include <string.h>
extern int locale_utf8locale;
extern int utf8_mbscmp (const char *, const char *);
/* Compare MBS1 and MBS2. */
int
mbscmp (mbs1, mbs2)
+3 -124
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2006, 2009, 2010, 2012, 2015 Free Software Foundation, Inc.
/* Copyright (C) 2001, 2006, 2009, 2010, 2012, 2015-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,102 +45,9 @@ const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] =
extern int locale_utf8locale;
/* We can optimize this if we know the locale is UTF-8, but needs to handle
malformed byte sequences. */
static inline size_t
utf8_mbstrlen(s)
const char *s;
{
size_t num = 0;
register unsigned char c;
extern char *utf8_mbsmbchar (const char *);
extern int utf8_mblen (const char *, size_t);
while ((c = *s++))
/* bytes 0xc0 through 0xff are first byte of multi-byte sequence */
if ((c & 0xc0) != 0x80) /* skip continuation bytes */
++num;
return (num);
}
/* Adapted from GNU libutf8 */
static inline int
utf8_mblen (s, n)
const char *s;
int n;
{
unsigned char c;
if (s == 0)
return 0;
else if (n == 0)
return -1;
c = (unsigned char) *s;
if (c < 0x80)
return (c != 0);
else if (c < 0xc0)
goto return_error;
else
{
const char *start = s;
size_t count;
int check_unsafe;
if (c < 0xe0)
{
count = 1;
if (c < 0xc2)
goto return_error;
check_unsafe = 0;
}
else if (c < 0xf0)
{
count = 2;
check_unsafe = (c == 0xe0);
}
#if SIZEOF_WCHAR_T == 4
else if (c < 0xf8)
{
count = 3;
check_unsafe = (c == 0xe0);
}
else if (c < 0xfc)
{
count = 4;
check_unsafe = (c == 0xf8);
}
else if (c < 0xfe)
{
count = 5;
check_unsafe = (c == 0xfc);
}
#endif
else
goto return_error;
if (n <= count)
return -1;
s++;
c = (unsigned char) *s++ ^ 0x80;
if (c >= 0x40)
goto return_error;
if (--count > 0)
{
if (check_unsafe && ((c >> (6 - count)) == 0))
goto return_error;
do
{
c = (unsigned char) *s++ ^ 0x80;
if (c >= 0x40)
goto return_error;
}
while (--count > 0);
}
return s - start;
}
return_error:
errno = EILSEQ;
return -1;
}
/* Count the number of characters in S, counting multi-byte characters as a
single character. */
size_t
@@ -170,18 +77,6 @@ mbstrlen (s)
return nc;
}
static inline char *
utf8_mbsmbchar (str)
const char *str;
{
register char *s;
for (s = (char *)str; *s; s++)
if ((*s & 0xc0) == 0x80)
return s;
return (0);
}
/* Return pointer to first multibyte char in S, or NULL if none. */
/* XXX - if we know that the locale is UTF-8, we can just check whether or
not any byte has the eighth bit turned on */
@@ -219,22 +114,6 @@ mbsmbchar (s)
return 0;
}
static inline int
utf_mbsnlen(src, srclen, maxlen)
const char *src;
size_t srclen;
int maxlen;
{
register int sind, count;
for (sind = count = 0; src[sind] && sind <= maxlen; sind++)
{
if ((src[sind] & 0xc0) != 0x80)
count++;
}
return (count);
}
int
sh_mbsnlen(src, srclen, maxlen)
const char *src;
+2
View File
@@ -142,9 +142,11 @@ extern char *fmtullong __P((unsigned long long int, int, char *, size_t, int));
302 / 1000 is log10 (2) rounded up;
add one for integer division truncation;
add one more for a minus sign if t is signed. */
#ifndef INT_STRLEN_BOUND
#define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
+ 1 + TYPE_SIGNED (t))
#endif
/* conversion flags */
#define PF_ALTFORM 0x00001 /* # */
+147
View File
@@ -0,0 +1,147 @@
/* utf8.c - UTF-8 character handling functions */
/* Copyright (C) 2018 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "bashansi.h"
#include "shmbutil.h"
extern int locale_mb_cur_max;
extern int locale_utf8locale;
#if defined (HANDLE_MULTIBYTE)
char *
utf8_mbschr (s, c)
const char *s;
int c;
{
return strchr (s, c); /* for now */
}
int
utf8_mbscmp (s1, s2)
const char *s1, *s2;
{
/* Use the fact that the UTF-8 encoding preserves lexicographic order. */
return strcmp (s1, s2);
}
char *
utf8_mbsmbchar (str)
const char *str;
{
register char *s;
for (s = (char *)str; *s; s++)
if ((*s & 0xc0) == 0x80)
return s;
return (0);
}
int
utf8_mbsnlen(src, srclen, maxlen)
const char *src;
size_t srclen;
int maxlen;
{
register int sind, count;
for (sind = count = 0; src[sind] && sind <= maxlen; sind++)
{
if ((src[sind] & 0xc0) != 0x80)
count++;
}
return (count);
}
/* Adapted from GNU gnulib */
int
utf8_mblen (s, n)
const char *s;
size_t n;
{
unsigned char c, c1;
if (s == 0)
return (0); /* no shift states */
if (n <= 0)
return (-1);
c = (unsigned char)*s;
if (c < 0x80)
return (c != 0);
if (c >= 0xc2)
{
c1 = (unsigned char)s[1];
if (c < 0xe0)
{
if (n >= 2 && (s[1] ^ 0x80) < 0x40)
return 2;
}
else if (c < 0xf0)
{
if (n >= 3
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || c1 >= 0xa0)
&& (c != 0xed || c1 < 0xa0))
return 3;
}
else if (c < 0xf8)
{
if (n >= 4
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || c1 >= 0x90)
&& (c < 0xf4 || (c == 0xf4 && c1 < 0x90)))
return 4;
}
}
/* invalid or incomplete multibyte character */
return -1;
}
/* We can optimize this if we know the locale is UTF-8, but needs to handle
malformed byte sequences. */
size_t
utf8_mbstrlen(s)
const char *s;
{
size_t clen, nc;
int mb_cur_max;
nc = 0;
mb_cur_max = MB_CUR_MAX;
while (*s && (clen = (size_t)utf8_mblen(s, mb_cur_max)) != 0)
{
if (MB_INVALIDCH(clen))
clen = 1; /* assume single byte */
s += clen;
nc++;
}
return nc;
}
#endif