mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-09 03:30:48 +02:00
commit bash-20101124 snapshot
This commit is contained in:
+8
-4
@@ -92,7 +92,7 @@ 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
|
||||
strchrnul.c unicode.c wcswidth.c shmbchar.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -106,7 +106,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
|
||||
strtrans.o snprintf.o mailstat.o fmtulong.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 ${LIBOBJS}
|
||||
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o ${LIBOBJS}
|
||||
|
||||
SUPPORT = Makefile
|
||||
|
||||
@@ -169,6 +169,7 @@ pathcanon.o: pathcanon.c
|
||||
pathphys.o: pathphys.c
|
||||
rename.o: rename.c
|
||||
setlinebuf.o: setlinebuf.c
|
||||
shmbchar.o: shmbchar.c
|
||||
shquote.o: shquote.c
|
||||
shtty.o: shtty.c
|
||||
snprintf.o: snprintf.c
|
||||
@@ -240,6 +241,7 @@ pathcanon.o: ${BUILD_DIR}/config.h
|
||||
pathphys.o: ${BUILD_DIR}/config.h
|
||||
rename.o: ${BUILD_DIR}/config.h
|
||||
setlinebuf.o: ${BUILD_DIR}/config.h
|
||||
shmbchare.o: ${BUILD_DIR}/config.h
|
||||
shquote.o: ${BUILD_DIR}/config.h
|
||||
shtty.o: ${BUILD_DIR}/config.h
|
||||
snprintf.o: ${BUILD_DIR}/config.h
|
||||
@@ -513,7 +515,7 @@ wcswidth.o: ${BASHINCDIR}/stdc.h
|
||||
|
||||
mbschr.o: ${topdir}/bashansi.h
|
||||
mbschr.o: ${BASHINCDIR}/ansi_stdlib.h
|
||||
mbschr.o: ${BASHINCDIR}/shmbutil.h
|
||||
mbschr.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
|
||||
|
||||
zgetline.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
zgetline.o: ${BASHINCDIR}/stdc.h
|
||||
@@ -532,7 +534,7 @@ casemod.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
casemod.o: ${BASHINCDIR}/stdc.h
|
||||
casemod.o: ${topdir}/xmalloc.h
|
||||
casemod.o: ${topdir}/bashtypes.h
|
||||
casemod.o: ${BASHINCDIR}/shmbutil.h
|
||||
casemod.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
|
||||
casemod.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
|
||||
|
||||
dprintf.o: ${BASHINCDIR}/stdc.h
|
||||
@@ -548,3 +550,5 @@ fnxform.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
fnxform.o: ${BASHINCDIR}/stdc.h
|
||||
fnxform.o: ${topdir}/bashtypes.h
|
||||
fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
|
||||
|
||||
shmbchar.o: ${BASHINCDIR}/shmbchar.h
|
||||
|
||||
+13
-4
@@ -92,7 +92,7 @@ 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
|
||||
strchrnul.c unicode.c wcswidth.c shmbchar.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -106,7 +106,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
|
||||
strtrans.o snprintf.o mailstat.o fmtulong.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 ${LIBOBJS}
|
||||
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o ${LIBOBJS}
|
||||
|
||||
SUPPORT = Makefile
|
||||
|
||||
@@ -169,6 +169,7 @@ pathcanon.o: pathcanon.c
|
||||
pathphys.o: pathphys.c
|
||||
rename.o: rename.c
|
||||
setlinebuf.o: setlinebuf.c
|
||||
shmbchar.o: shmbchar.c
|
||||
shquote.o: shquote.c
|
||||
shtty.o: shtty.c
|
||||
snprintf.o: snprintf.c
|
||||
@@ -196,6 +197,7 @@ uconvert.o: uconvert.c
|
||||
ufuncs.o: ufuncs.c
|
||||
vprint.o: vprint.c
|
||||
wcsdup.o: wcsdup.c
|
||||
wcswidth.o: wcswidth.c
|
||||
mbschr.o: mbschr.c
|
||||
zcatfd.o: zcatfd.c
|
||||
zmapfd.o: zmapfd.c
|
||||
@@ -239,6 +241,7 @@ pathcanon.o: ${BUILD_DIR}/config.h
|
||||
pathphys.o: ${BUILD_DIR}/config.h
|
||||
rename.o: ${BUILD_DIR}/config.h
|
||||
setlinebuf.o: ${BUILD_DIR}/config.h
|
||||
shmbchare.o: ${BUILD_DIR}/config.h
|
||||
shquote.o: ${BUILD_DIR}/config.h
|
||||
shtty.o: ${BUILD_DIR}/config.h
|
||||
snprintf.o: ${BUILD_DIR}/config.h
|
||||
@@ -266,6 +269,7 @@ uconvert.o: ${BUILD_DIR}/config.h
|
||||
ufuncs.o: ${BUILD_DIR}/config.h
|
||||
vprint.o: ${BUILD_DIR}/config.h
|
||||
wcsdup.o: ${BUILD_DIR}/config.h
|
||||
wcswidth.o: ${BUILD_DIR}/config.h
|
||||
mbschr.o: ${BUILD_DIR}/config.h
|
||||
zcatfd.o: ${BUILD_DIR}/config.h
|
||||
zgetline.o: ${BUILD_DIR}/config.h
|
||||
@@ -506,9 +510,12 @@ wcsdup.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
wcsdup.o: ${BASHINCDIR}/stdc.h
|
||||
wcsdup.o: ${topdir}/xmalloc.h
|
||||
|
||||
wcswidth.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
wcswidth.o: ${BASHINCDIR}/stdc.h
|
||||
|
||||
mbschr.o: ${topdir}/bashansi.h
|
||||
mbschr.o: ${BASHINCDIR}/ansi_stdlib.h
|
||||
mbschr.o: ${BASHINCDIR}/shmbutil.h
|
||||
mbschr.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmchar.h
|
||||
|
||||
zgetline.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
zgetline.o: ${BASHINCDIR}/stdc.h
|
||||
@@ -527,7 +534,7 @@ casemod.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
casemod.o: ${BASHINCDIR}/stdc.h
|
||||
casemod.o: ${topdir}/xmalloc.h
|
||||
casemod.o: ${topdir}/bashtypes.h
|
||||
casemod.o: ${BASHINCDIR}/shmbutil.h
|
||||
casemod.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmchar.h
|
||||
casemod.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
|
||||
|
||||
dprintf.o: ${BASHINCDIR}/stdc.h
|
||||
@@ -543,3 +550,5 @@ fnxform.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
fnxform.o: ${BASHINCDIR}/stdc.h
|
||||
fnxform.o: ${topdir}/bashtypes.h
|
||||
fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
|
||||
|
||||
shmbchar.o: ${BASHINCDIR}/shmbchar.h
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ curencoding ()
|
||||
mod = strchr (dot, '@');
|
||||
if (mod)
|
||||
*mod = '\0';
|
||||
return dot;
|
||||
return ++dot;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/* Copyright (C) 2001, 2006, 2009, 2010 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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <shmbutil.h>
|
||||
#include <shmbchar.h>
|
||||
|
||||
#if IS_BASIC_ASCII
|
||||
|
||||
/* Bit table of characters in the ISO C "basic character set". */
|
||||
const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] =
|
||||
{
|
||||
0x00001a00, /* '\t' '\v' '\f' */
|
||||
0xffffffef, /* ' '...'#' '%'...'?' */
|
||||
0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */
|
||||
0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */
|
||||
/* The remaining bits are 0. */
|
||||
};
|
||||
|
||||
#endif /* IS_BASIC_ASCII */
|
||||
|
||||
size_t
|
||||
mbstrlen (s)
|
||||
const char *s;
|
||||
{
|
||||
size_t clen, nc;
|
||||
mbstate_t mbs = { 0 }, mbsbak = { 0 };
|
||||
int f;
|
||||
|
||||
nc = 0;
|
||||
while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
|
||||
{
|
||||
if (MB_INVALIDCH(clen))
|
||||
{
|
||||
clen = 1; /* assume single byte */
|
||||
mbs = mbsbak;
|
||||
}
|
||||
|
||||
if (f == 0)
|
||||
mbsbak = mbs;
|
||||
|
||||
s += clen;
|
||||
nc++;
|
||||
}
|
||||
return nc;
|
||||
}
|
||||
|
||||
/* Return pointer to first multibyte char in S, or NULL if none. */
|
||||
char *
|
||||
mbsmbchar (s)
|
||||
const char *s;
|
||||
{
|
||||
char *t;
|
||||
size_t clen;
|
||||
mbstate_t mbs = { 0 };
|
||||
|
||||
for (t = (char *)s; *t; t++)
|
||||
{
|
||||
if (is_basic (*t))
|
||||
continue;
|
||||
|
||||
clen = mbrlen (t, MB_CUR_MAX, &mbs);
|
||||
|
||||
if (clen == 0)
|
||||
return 0;
|
||||
if (MB_INVALIDCH(clen))
|
||||
continue;
|
||||
|
||||
if (clen > 1)
|
||||
return t;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/* Copyright (C) 2001, 2006, 2009, 2010 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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <shmbutil.h>
|
||||
#include <shmbchar.h>
|
||||
|
||||
#if IS_BASIC_ASCII
|
||||
|
||||
/* Bit table of characters in the ISO C "basic character set". */
|
||||
const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] =
|
||||
{
|
||||
0x00001a00, /* '\t' '\v' '\f' */
|
||||
0xffffffef, /* ' '...'#' '%'...'?' */
|
||||
0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */
|
||||
0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */
|
||||
/* The remaining bits are 0. */
|
||||
};
|
||||
|
||||
#endif /* IS_BASIC_ASCII */
|
||||
|
||||
size_t
|
||||
mbstrlen (s)
|
||||
const char *s;
|
||||
{
|
||||
size_t clen, nc;
|
||||
mbstate_t mbs = { 0 }, mbsbak = { 0 };
|
||||
|
||||
nc = 0;
|
||||
while (*s && (clen = is_basic (*s) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
|
||||
{
|
||||
if (MB_INVALIDCH(clen))
|
||||
{
|
||||
clen = 1; /* assume single byte */
|
||||
mbs = mbsbak;
|
||||
}
|
||||
|
||||
if (is_basic (*s) == 0)
|
||||
mbsbak = mbs;
|
||||
|
||||
s += clen;
|
||||
nc++;
|
||||
}
|
||||
return nc;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
/* Copyright (C) 2001, 2006, 2009, 2010 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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <shmbutil.h>
|
||||
#include <shmbchar.h>
|
||||
|
||||
#if IS_BASIC_ASCII
|
||||
|
||||
/* Bit table of characters in the ISO C "basic character set". */
|
||||
const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] =
|
||||
{
|
||||
0x00001a00, /* '\t' '\v' '\f' */
|
||||
0xffffffef, /* ' '...'#' '%'...'?' */
|
||||
0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */
|
||||
0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */
|
||||
/* The remaining bits are 0. */
|
||||
};
|
||||
|
||||
#endif /* IS_BASIC_ASCII */
|
||||
|
||||
size_t
|
||||
mbstrlen (s)
|
||||
const char *s;
|
||||
{
|
||||
size_t clen, nc;
|
||||
mbstate_t mbs = { 0 }, mbsbak = { 0 };
|
||||
|
||||
nc = 0;
|
||||
while (*s && (clen = is_basic (*s) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
|
||||
{
|
||||
if (MB_INVALIDCH(clen))
|
||||
{
|
||||
clen = 1; /* assume single byte */
|
||||
mbs = mbsbak;
|
||||
}
|
||||
|
||||
if (is_basic (*s) == 0)
|
||||
mbsbak = mbs;
|
||||
|
||||
s += clen;
|
||||
nc++;
|
||||
}
|
||||
return nc;
|
||||
}
|
||||
|
||||
/* Return pointer to first multibyte char in S, or NULL if none. */
|
||||
char *
|
||||
mbsmbchar (s)
|
||||
const char *s;
|
||||
{
|
||||
char *t;
|
||||
size_t clen;
|
||||
mbstate_t mbs = { 0 };
|
||||
|
||||
for (t = (char *)s; *t; t++)
|
||||
{
|
||||
if (is_basic (*t))
|
||||
continue;
|
||||
|
||||
clen = mbrlen (t, MB_CUR_MAX, &mbs);
|
||||
|
||||
if (clen == 0)
|
||||
return 0;
|
||||
if (MB_INVALIDCH(clen))
|
||||
continue;
|
||||
|
||||
if (clen > 1)
|
||||
return t;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+8
-3
@@ -64,14 +64,19 @@ static iconv_t localconv;
|
||||
static char *
|
||||
stub_charset ()
|
||||
{
|
||||
char *locale, *s;
|
||||
char *locale, *s, *t;
|
||||
|
||||
locale = get_locale_var ("LC_CTYPE");
|
||||
if (locale == 0)
|
||||
if (locale == 0 || *locale == 0)
|
||||
return "ASCII";
|
||||
s = strrchr (locale, '.');
|
||||
if (s)
|
||||
return ++s;
|
||||
{
|
||||
t = strchr (s, '@');
|
||||
if (t)
|
||||
*t = 0;
|
||||
return ++s;
|
||||
}
|
||||
else if (STREQ (locale, "UTF-8"))
|
||||
return "UTF-8";
|
||||
else
|
||||
|
||||
+33
-3
@@ -1,6 +1,6 @@
|
||||
/* unicode.c - functions to convert unicode characters */
|
||||
|
||||
/* Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -56,7 +56,33 @@ extern char *get_locale_var __P((char *));
|
||||
|
||||
static int u32init = 0;
|
||||
static int utf8locale = 0;
|
||||
#if defined (HAVE_ICONV)
|
||||
static iconv_t localconv;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOCALE_CHARSET
|
||||
static char *
|
||||
stub_charset ()
|
||||
{
|
||||
char *locale, *s;
|
||||
|
||||
locale = get_locale_var ("LC_CTYPE");
|
||||
if (locale == 0 || *locale == 0)
|
||||
return "ASCII";
|
||||
s = strrchr (locale, '.');
|
||||
if (s)
|
||||
{
|
||||
t = strchr (s, '@');
|
||||
if (t)
|
||||
*t = 0;
|
||||
return ++s;
|
||||
}
|
||||
else if (STREQ (locale, "UTF-8"))
|
||||
return "UTF-8";
|
||||
else
|
||||
return "ASCII";
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u32toascii ? */
|
||||
int
|
||||
@@ -127,7 +153,7 @@ u32cconv (c, s)
|
||||
const char *charset;
|
||||
char obuf[25], *optr;
|
||||
size_t obytesleft;
|
||||
char *iptr;
|
||||
const char *iptr;
|
||||
size_t sn;
|
||||
#endif
|
||||
|
||||
@@ -154,7 +180,11 @@ u32cconv (c, s)
|
||||
/* this is mostly from coreutils-8.5/lib/unicodeio.c */
|
||||
if (u32init == 0)
|
||||
{
|
||||
# if HAVE_LOCALE_CHARSET
|
||||
charset = locale_charset (); /* XXX - fix later */
|
||||
# else
|
||||
charset = stub_charset ();
|
||||
# endif
|
||||
if (STREQ (charset, "UTF-8"))
|
||||
utf8locale = 1;
|
||||
else
|
||||
@@ -187,7 +217,7 @@ u32cconv (c, s)
|
||||
|
||||
iconv (localconv, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (iconv (localconv, &iptr, &sn, &optr, &obytesleft) == (size_t)-1)
|
||||
if (iconv (localconv, (ICONV_CONST char **)&iptr, &sn, &optr, &obytesleft) == (size_t)-1)
|
||||
return n; /* You get utf-8 if iconv fails */
|
||||
|
||||
*optr = '\0';
|
||||
|
||||
Reference in New Issue
Block a user