Bash-4.1 distribution source

This commit is contained in:
Chet Ramey 2011-11-21 20:51:19 -05:00
commit 0001803f0b
252 changed files with 51563 additions and 37176 deletions

View file

@ -86,12 +86,12 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
vprint.c itos.c rename.c zread.c zwrite.c shtty.c \
inet_aton.c netconn.c netopen.c strpbrk.c timeval.c makepath.c \
pathcanon.c pathphys.c tmpfile.c stringlist.c stringvec.c spell.c \
shquote.c strtrans.c strindex.c snprintf.c mailstat.c \
shquote.c strtrans.c strcasestr.c snprintf.c mailstat.c \
fmtulong.c fmtullong.c fmtumax.c shmatch.c strnlen.c \
strtoll.c strtoull.c strtoimax.c strtoumax.c memset.c strstr.c \
mktime.c strftime.c xstrchr.c zcatfd.c zmapfd.c winsize.c eaccess.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 fdprintf.c input_avail.c
casemod.c fdprintf.c input_avail.c mbscasecmp.c fnxform.c
# The header files for this library.
HSOURCES =
@ -102,10 +102,10 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
itos.o zread.o zwrite.o shtty.o shmatch.o eaccess.o \
netconn.o netopen.o timeval.o makepath.o pathcanon.o \
pathphys.o tmpfile.o stringlist.o stringvec.o spell.o shquote.o \
strtrans.o strindex.o snprintf.o mailstat.o fmtulong.o \
fmtullong.o fmtumax.o xstrchr.o zcatfd.o zmapfd.o winsize.o wcsdup.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 \
fdprintf.o input_avail.o ${LIBOBJS}
fdprintf.o input_avail.o mbscasecmp.o fnxform.o ${LIBOBJS}
SUPPORT = Makefile
@ -136,6 +136,9 @@ mostlyclean: clean
${BUILD_DIR}/version.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
-( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h )
${BUILD_DIR}/pathnames.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
-( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} pathnames.h )
# rules for losing makes, like SunOS
casemod.o: casemod.c
clktck.o: clktck.c
@ -145,6 +148,7 @@ fdprintf.o: fdprintf.c
fmtullong.o: fmtullong.c
fmtulong.o: fmtulong.c
fmtumax.o: fmtumax.c
fnxform.o: fnxform.c
fpurge.o: fpurge.c
getcwd.o: getcwd.c
getenv.o: getenv.c
@ -153,6 +157,7 @@ input_avail.o: input_avail.c
itos.o: itos.c
mailstat.o: mailstat.c
makepath.o: makepath.c
mbscasecmp.o: mbscasecmp.c
mbscmp.o: mbscmp.c
memset.o: memset.c
mktime.o: mktime.c
@ -170,7 +175,7 @@ spell.o: spell.c
strcasecmp.o: strcasecmp.c
strerror.o: strerror.c
strftime.o: strftime.c
strindex.o: strindex.c
strcasestr.o: strcasestr.c
stringlist.o: stringlist.c
stringvec.o: stringvec.c
strnlen.o: strnlen.c
@ -190,7 +195,7 @@ uconvert.o: uconvert.c
ufuncs.o: ufuncs.c
vprint.o: vprint.c
wcsdup.o: wcsdup.c
xstrchr.o: xstrchr.c
mbschr.o: mbschr.c
zcatfd.o: zcatfd.c
zmapfd.o: zmapfd.c
zgetline.o: zgetline.c
@ -213,6 +218,7 @@ fdprintf.o: ${BUILD_DIR}/config.h
fmtullong.o: ${BUILD_DIR}/config.h
fmtulong.o: ${BUILD_DIR}/config.h
fmtumax.o: ${BUILD_DIR}/config.h
fnxform.o: ${BUILD_DIR}/config.h
fpurge.o: ${BUILD_DIR}/config.h
getcwd.o: ${BUILD_DIR}/config.h
getenv.o: ${BUILD_DIR}/config.h
@ -221,6 +227,7 @@ input_avail.o: ${BUILD_DIR}/config.h
itos.o: ${BUILD_DIR}/config.h
mailstat.o: ${BUILD_DIR}/config.h
makepath.o: ${BUILD_DIR}/config.h
mbscasecmp.o: ${BUILD_DIR}/config.h
mbscmp.o: ${BUILD_DIR}/config.h
memset.o: ${BUILD_DIR}/config.h
mktime.o: ${BUILD_DIR}/config.h
@ -238,7 +245,7 @@ spell.o: ${BUILD_DIR}/config.h
strcasecmp.o: ${BUILD_DIR}/config.h
strerror.o: ${BUILD_DIR}/config.h
strftime.o: ${BUILD_DIR}/config.h
strindex.o: ${BUILD_DIR}/config.h
strcasestr.o: ${BUILD_DIR}/config.h
stringlist.o: ${BUILD_DIR}/config.h
stringvec.o: ${BUILD_DIR}/config.h
strnlen.o: ${BUILD_DIR}/config.h
@ -258,7 +265,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
xstrchr.o: ${BUILD_DIR}/config.h
mbschr.o: ${BUILD_DIR}/config.h
zcatfd.o: ${BUILD_DIR}/config.h
zgetline.o: ${BUILD_DIR}/config.h
zmapfd.o: ${BUILD_DIR}/config.h
@ -393,8 +400,8 @@ strerror.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
strerror.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
strerror.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h ${BUILD_DIR}/version.h
strindex.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h
strindex.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
strcasestr.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h
strcasestr.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
stringlist.o: ${topdir}/bashansi.h
stringlist.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
@ -498,15 +505,19 @@ wcsdup.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
wcsdup.o: ${BASHINCDIR}/stdc.h
wcsdup.o: ${topdir}/xmalloc.h
xstrchr.o: ${topdir}/bashansi.h
xstrchr.o: ${BASHINCDIR}/ansi_stdlib.h
xstrchr.o: ${BASHINCDIR}/shmbutil.h
mbschr.o: ${topdir}/bashansi.h
mbschr.o: ${BASHINCDIR}/ansi_stdlib.h
mbschr.o: ${BASHINCDIR}/shmbutil.h
zgetline.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
zgetline.o: ${BASHINCDIR}/stdc.h
zgetline.o: ${topdir}/xmalloc.h
zgetline.o: ${topdir}/bashtypes.h
mbscasecmp.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
mbscasecmp.o: ${BASHINCDIR}/stdc.h
mbscasecmp.o: ${topdir}/xmalloc.h
mbscmp.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
mbscmp.o: ${BASHINCDIR}/stdc.h
mbscmp.o: ${topdir}/xmalloc.h
@ -522,5 +533,12 @@ fdprintf.o: ${BASHINCDIR}/stdc.h
input_avail.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
input_avail.o: ${BASHINCDIR}/stdc.h
input_avail.o: ${topdir}/xmalloc.h
input_avail.o: ${topdir}/xmalloc.h ${BASHINCDIR}/posixselect.h
mktime.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
mktime.o: ${BASHINCDIR}/stdc.h
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

View file

@ -107,6 +107,7 @@ sh_modcase (string, pat, flags)
wchar_t nwc;
char mb[MB_LEN_MAX+1];
int mlen;
size_t m;
mbstate_t state;
#endif
@ -210,7 +211,11 @@ sh_modcase (string, pat, flags)
#if defined (HANDLE_MULTIBYTE)
else
{
mbrtowc (&wc, string + start, end - start, &state);
m = mbrtowc (&wc, string + start, end - start, &state);
if (MB_INVALIDCH (m))
wc = (wchar_t)string[start];
else if (MB_NULLWCH (m))
wc = L'\0';
switch (nop)
{
default:

View file

@ -31,7 +31,7 @@
#endif
extern int fpurge __P((FILE *stream));
#if HAVE___FPURGE /* glibc >= 2.2, Solaris >= 7 */
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */
# include <stdio_ext.h>
#endif
#include <stdlib.h>
@ -39,13 +39,13 @@ extern int fpurge __P((FILE *stream));
int
fpurge (FILE *fp)
{
#if HAVE___FPURGE /* glibc >= 2.2, Solaris >= 7 */
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */
__fpurge (fp);
/* The __fpurge function does not have a return value. */
return 0;
#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, MacOS X */
#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X */
/* Call the system's fpurge function. */
# undef fpurge
@ -53,7 +53,7 @@ fpurge (FILE *fp)
extern int fpurge (FILE *);
# endif
int result = fpurge (fp);
# if defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
if (result == 0)
/* Correct the invariants that fpurge broke.
<stdio.h> on BSD systems says:
@ -71,7 +71,7 @@ fpurge (FILE *fp)
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
# if defined _IO_ferror_unlocked /* GNU libc, BeOS */
# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_end = fp->_IO_read_ptr;
fp->_IO_write_ptr = fp->_IO_write_base;
/* Avoid memory leak when there is an active ungetc buffer. */
@ -81,28 +81,27 @@ fpurge (FILE *fp)
fp->_IO_save_base = NULL;
}
return 0;
# elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
fp->_p = fp->_bf._base;
fp->_r = 0;
fp->_w = ((fp->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
? fp->_bf._size
: 0);
# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p = fp_->_bf._base;
fp_->_r = 0;
fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
? fp_->_bf._size
: 0);
/* Avoid memory leak when there is an active ungetc buffer. */
# if defined __NetBSD__ || defined __OpenBSD__ /* NetBSD, OpenBSD */
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
# define fp_ub ((struct { struct __sbuf _ub; } *) fp->_ext._base)->_ub
# else /* FreeBSD, MacOS X, Cygwin */
# define fp_ub fp->_ub
# endif
if (fp_ub._base != NULL)
{
if (fp_ub._base != fp->_ubuf)
if (fp_ub._base != fp_->_ubuf)
free (fp_ub._base);
fp_ub._base = NULL;
}
return 0;
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */
# elif defined __EMX__ /* emx+gcc */
fp->_ptr = fp->_buffer;
fp->_rcount = 0;
fp->_wcount = 0;
fp->_ungetc_count = 0;
return 0;
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
fp->_ptr = fp->_base;
if (fp->_ptr != NULL)
fp->_cnt = 0;
@ -115,8 +114,34 @@ fpurge (FILE *fp)
fp->__bufpos = fp->__bufread;
# endif
return 0;
# elif defined __QNX__ /* QNX */
fp->_Rback = fp->_Back + sizeof (fp->_Back);
fp->_Rsave = NULL;
if (fp->_Mode & 0x2000 /* _MWRITE */)
/* fp->_Buf <= fp->_Next <= fp->_Wend */
fp->_Next = fp->_Buf;
else
/* fp->_Buf <= fp->_Next <= fp->_Rend */
fp->_Rend = fp->_Next;
return 0;
# elif defined __MINT__ /* Atari FreeMiNT */
if (fp->__pushed_back)
{
fp->__bufp = fp->__pushback_bufp;
fp->__pushed_back = 0;
}
/* Preserve the current file position. */
if (fp->__target != -1)
fp->__target += fp->__bufp - fp->__buffer;
fp->__bufp = fp->__buffer;
/* Nothing in the buffer, next getc is nontrivial. */
fp->__get_limit = fp->__bufp;
/* Nothing in the buffer, next putc is nontrivial. */
fp->__put_limit = fp->__buffer;
return 0;
# else
#error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
# warning "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
return 0;
# endif
#endif

View file

@ -48,6 +48,12 @@
#include <bashansi.h>
#if defined (BROKEN_DIRENT_D_INO)
# include "command.h"
# include "general.h"
# include "externs.h"
#endif
#include <xmalloc.h>
#if !defined (errno)

View file

@ -39,14 +39,7 @@
#include "bashansi.h"
#if defined (HAVE_SELECT)
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
# include <sys/time.h>
# endif
#endif /* HAVE_SELECT */
#if defined (HAVE_SYS_SELECT_H)
# include <sys/select.h>
#endif
#include "posixselect.h"
#if defined (FIONREAD_IN_SYS_IOCTL)
# include <sys/ioctl.h>

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
/* Compare MBS1 and MBS2. */
int
@ -40,16 +41,25 @@ mbscmp (mbs1, mbs2)
do
{
len1 = mbtowc ((wchar_t *) &c1, mbs1, MB_CUR_MAX);
len2 = mbtowc ((wchar_t *) &c2, mbs2, MB_CUR_MAX);
len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
len2 = mbtowc (&c2, mbs2, MB_CUR_MAX);
if (len1 == 0)
return len2 == 0 ? 0 : -1;
if (len2 == 0)
else if (len2 == 0)
return 1;
if (len1 < 0 || len2 < 0)
/* FIXME: an illegal character appears. What to do? */
return c1 - c2;
else if (len1 > 0 && len2 < 0)
return -1;
else if (len1 < 0 && len2 > 0)
return 1;
else if (len1 < 0 && len2 < 0)
{
len1 = strlen (mbs1);
len2 = strlen (mbs2);
return (len1 == len2 ? memcmp (mbs1, mbs2, len1)
: ((len1 < len2) ? (memcmp (mbs1, mbs2, len1) > 0 ? 1 : -1)
: (memcmp (mbs1, mbs2, len2) >= 0 ? 1 : -1)));
}
mbs1 += len1;
mbs2 += len2;

View file

@ -61,9 +61,13 @@
# include <config.h>
#endif
#if defined(DEBUG)
/* GCC 4.2 on Snow Leopard doesn't like the snprintf prototype */
#if defined(DEBUG) && !defined (MACOSX)
# undef HAVE_SNPRINTF
# undef HAVE_ASPRINTF
# define HAVE_SNPRINTF 0
# define HAVE_ASPRINTF 0
#endif
#if defined(DRIVER) && !defined(HAVE_CONFIG_H)
@ -82,7 +86,7 @@
#define intmax_t long
#endif
#if !defined (HAVE_SNPRINTF) || !defined (HAVE_ASPRINTF)
#if !HAVE_SNPRINTF || !HAVE_ASPRINTF
#include <bashtypes.h>
@ -299,6 +303,13 @@ static void dfallback __P((struct DATA *, const char *, const char *, double));
static char *groupnum __P((char *));
#ifndef HAVE_ISINF_IN_LIBC
static int isinf __P((double));
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int isnan __P((double));
#endif
#ifdef DRIVER
static void memory_error_and_abort ();
static void *xmalloc __P((size_t));
@ -1640,7 +1651,7 @@ dfallback (data, fs, fe, d)
}
#endif /* FLOATING_POINT */
#ifndef HAVE_SNPRINTF
#if !HAVE_SNPRINTF
int
#if defined (__STDC__)
@ -1690,7 +1701,7 @@ snprintf(string, length, format, va_alist)
#endif /* HAVE_SNPRINTF */
#ifndef HAVE_ASPRINTF
#if !HAVE_ASPRINTF
int
#if defined (__STDC__)
@ -1735,9 +1746,9 @@ asprintf(stringp, format, va_alist)
return rval;
}
#endif
#endif /* !HAVE_ASPRINTF */
#endif
#endif /* !HAVE_SNPRINTF || !HAVE_ASPRINTF */
#ifdef DRIVER

View file

@ -1,6 +1,6 @@
/* strtoimax - convert string representation of a number into an intmax_t value. */
/* Copyright 1999-2005 Free Software Foundation, Inc.
/* Copyright 1999-2009 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -28,6 +28,10 @@
# include <inttypes.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif

View file

@ -1,6 +1,6 @@
/* strtoumax - convert string representation of a number into an uintmax_t value. */
/* Copyright 1999-2005 Free Software Foundation, Inc.
/* Copyright 1999-2009 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -17,6 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
/* Written by Paul Eggert. Modified by Chet Ramey for Bash. */
#if HAVE_CONFIG_H
@ -27,6 +28,10 @@
# include <inttypes.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif

View file

@ -92,7 +92,7 @@ uconvert(s, ip, up)
ipart = (ipart * 10) + (*p - '0');
}
if (*p == 0)
if (p == 0 || *p == 0) /* callers ensure p can never be 0; this is to shut up clang */
RETURN(1);
if (*p == DECIMAL)