Bash-4.4 distribution sources and documentation
This commit is contained in:
parent
30a978b7d8
commit
a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
|
|
@ -26,7 +26,7 @@ PACKAGE_STRING = @PACKAGE_STRING@
|
|||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
VPATH = @srcdir@
|
||||
topdir = @top_srcdir@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
|
|
@ -160,6 +160,7 @@ itos.o: itos.c
|
|||
mailstat.o: mailstat.c
|
||||
makepath.o: makepath.c
|
||||
mbscasecmp.o: mbscasecmp.c
|
||||
mbschr.o: mbschr.c
|
||||
mbscmp.o: mbscmp.c
|
||||
memset.o: memset.c
|
||||
mktime.o: mktime.c
|
||||
|
|
@ -170,12 +171,14 @@ pathcanon.o: pathcanon.c
|
|||
pathphys.o: pathphys.c
|
||||
rename.o: rename.c
|
||||
setlinebuf.o: setlinebuf.c
|
||||
shmatch.o: shmatch.c
|
||||
shmbchar.o: shmbchar.c
|
||||
shquote.o: shquote.c
|
||||
shtty.o: shtty.c
|
||||
snprintf.o: snprintf.c
|
||||
spell.o: spell.c
|
||||
strcasecmp.o: strcasecmp.c
|
||||
strchrnul.o: strchrnul.c
|
||||
strerror.o: strerror.c
|
||||
strftime.o: strftime.c
|
||||
strcasestr.o: strcasestr.c
|
||||
|
|
@ -196,11 +199,12 @@ timeval.o: timeval.c
|
|||
tmpfile.o: tmpfile.c
|
||||
uconvert.o: uconvert.c
|
||||
ufuncs.o: ufuncs.c
|
||||
unicode.o: unicode.c
|
||||
vprint.o: vprint.c
|
||||
wcsdup.o: wcsdup.c
|
||||
wcsnwidth.o: wcsnwidth.c
|
||||
wcswidth.o: wcswidth.c
|
||||
mbschr.o: mbschr.c
|
||||
winsize.o: winsize.c
|
||||
zcatfd.o: zcatfd.c
|
||||
zmapfd.o: zmapfd.c
|
||||
zgetline.o: zgetline.c
|
||||
|
|
@ -233,6 +237,7 @@ itos.o: ${BUILD_DIR}/config.h
|
|||
mailstat.o: ${BUILD_DIR}/config.h
|
||||
makepath.o: ${BUILD_DIR}/config.h
|
||||
mbscasecmp.o: ${BUILD_DIR}/config.h
|
||||
mbschr.o: ${BUILD_DIR}/config.h
|
||||
mbscmp.o: ${BUILD_DIR}/config.h
|
||||
memset.o: ${BUILD_DIR}/config.h
|
||||
mktime.o: ${BUILD_DIR}/config.h
|
||||
|
|
@ -243,12 +248,14 @@ 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
|
||||
shmatch.o: ${BUILD_DIR}/config.h
|
||||
shmbchar.o: ${BUILD_DIR}/config.h
|
||||
shquote.o: ${BUILD_DIR}/config.h
|
||||
shtty.o: ${BUILD_DIR}/config.h
|
||||
snprintf.o: ${BUILD_DIR}/config.h
|
||||
spell.o: ${BUILD_DIR}/config.h
|
||||
strcasecmp.o: ${BUILD_DIR}/config.h
|
||||
strchrnul.o: ${BUILD_DIR}/config.h
|
||||
strerror.o: ${BUILD_DIR}/config.h
|
||||
strftime.o: ${BUILD_DIR}/config.h
|
||||
strcasestr.o: ${BUILD_DIR}/config.h
|
||||
|
|
@ -269,11 +276,12 @@ timeval.o: ${BUILD_DIR}/config.h
|
|||
tmpfile.o: ${BUILD_DIR}/config.h
|
||||
uconvert.o: ${BUILD_DIR}/config.h
|
||||
ufuncs.o: ${BUILD_DIR}/config.h
|
||||
unicode.o: ${BUILD_DIR}/config.h
|
||||
vprint.o: ${BUILD_DIR}/config.h
|
||||
wcsdup.o: ${BUILD_DIR}/config.h
|
||||
wcsnwidth.o: ${BUILD_DIR}/config.h
|
||||
wcswidth.o: ${BUILD_DIR}/config.h
|
||||
mbschr.o: ${BUILD_DIR}/config.h
|
||||
winsize.o: ${BUILD_DIR}/config.h
|
||||
zcatfd.o: ${BUILD_DIR}/config.h
|
||||
zgetline.o: ${BUILD_DIR}/config.h
|
||||
zmapfd.o: ${BUILD_DIR}/config.h
|
||||
|
|
@ -389,14 +397,26 @@ eaccess.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
|||
eaccess.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
#eaccess.o: ${BUILD_DIR}/version.h
|
||||
|
||||
shmatch.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h
|
||||
shmatch.o: ${BASHINCDIR}/ansi_stdlib.h ${topdir}/xmalloc.h
|
||||
shmatch.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
|
||||
shmatch.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
|
||||
shmatch.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h ${topdir}/conftypes.h
|
||||
shmatch.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
|
||||
shmatch.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
|
||||
shmatch.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
||||
shmatch.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
|
||||
shquote.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h
|
||||
shquote.o: ${BASHINCDIR}/ansi_stdlib.h ${topdir}/xmalloc.h
|
||||
shquote.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
|
||||
|
||||
shtty.o: ${BASHINCDIR}/shtty.h
|
||||
shtty.o: ${BASHINCDIR}/stdc.h
|
||||
|
||||
snprintf.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h ${topdir}/xmalloc.h
|
||||
snprintf.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
|
||||
snprintf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
|
||||
snprintf.o: ${BASHINCDIR}/typemax.h
|
||||
|
||||
spell.o: ${topdir}/bashtypes.h
|
||||
|
|
@ -475,6 +495,7 @@ strtrans.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
|
|||
strtrans.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
|
||||
strtrans.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
||||
strtrans.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
strtrans.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
|
||||
#strtrans.o: ${BUILD_DIR}/version.h
|
||||
|
||||
times.o: ${BASHINCDIR}/systimes.h
|
||||
|
|
@ -483,10 +504,26 @@ times.o: ${BASHINCDIR}/posixtime.h
|
|||
timeval.o: ${BASHINCDIR}/posixtime.h
|
||||
|
||||
tmpfile.o: ${topdir}/bashtypes.h
|
||||
tmpfile.o: ${BASHINCDIR}/chartypes.h
|
||||
tmpfile.o: ${BASHINCDIR}/posixstat.h
|
||||
tmpfile.o: ${BASHINCDIR}/filecntl.h
|
||||
tmpfile.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
|
||||
tmpfile.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
|
||||
tmpfile.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h ${topdir}/conftypes.h
|
||||
tmpfile.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
|
||||
tmpfile.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
|
||||
tmpfile.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
||||
tmpfile.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
|
||||
uconvert.o: ${topdir}/bashtypes.h
|
||||
uconvert.o: ${BASHINCDIR}/chartypes.h
|
||||
uconvert.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
|
||||
uconvert.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
|
||||
uconvert.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h ${topdir}/conftypes.h
|
||||
uconvert.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
|
||||
uconvert.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
|
||||
uconvert.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
||||
uconvert.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
|
||||
ufuncs.o: ${topdir}/bashtypes.h
|
||||
|
||||
|
|
@ -569,3 +606,18 @@ fnxform.o: ${topdir}/bashtypes.h
|
|||
fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
|
||||
|
||||
shmbchar.o: ${BASHINCDIR}/shmbchar.h
|
||||
shmbchar.o: ${BASHINCDIR}/shmbutil.h
|
||||
|
||||
unicode.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
unicode.o: ${BASHINCDIR}/stdc.h
|
||||
unicode.o: ${topdir}/xmalloc.h
|
||||
|
||||
winsize.o: ${BASHINCDIR}/stdc.h
|
||||
winsize.o: ${topdir}/xmalloc.h
|
||||
winsize.o: ${topdir}/bashtypes.h
|
||||
|
||||
zmapfd.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
zmapfd.o: ${BASHINCDIR}/stdc.h
|
||||
zmapfd.o: ${topdir}/command.h
|
||||
zmapfd.o: ${topdir}/general.h
|
||||
zmapfd.o: ${topdir}/bashtypes.h ${BASHINCDIR}/chartypes.h ${topdir}/xmalloc.h
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* casemod.c -- functions to change case of strings */
|
||||
|
||||
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008,2009,2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
#if !defined (HANDLE_MULTIBYTE)
|
||||
# define cval(s, i) ((s)[(i)])
|
||||
# define iswalnum(c) (isalnum(c))
|
||||
# define TOGGLE(x) (ISUPPER (x) ? tolower (x) : (TOUPPER (x)))
|
||||
# define TOGGLE(x) (ISUPPER (x) ? tolower ((unsigned char)x) : (TOUPPER (x)))
|
||||
#else
|
||||
# define TOGGLE(x) (iswupper (x) ? towlower (x) : (_to_wupper(x)))
|
||||
#endif
|
||||
|
|
@ -105,10 +105,11 @@ sh_modcase (string, pat, flags)
|
|||
char *pat;
|
||||
int flags;
|
||||
{
|
||||
int start, next, end;
|
||||
int start, next, end, retind;
|
||||
int inword, c, nc, nop, match, usewords;
|
||||
char *ret, *s;
|
||||
wchar_t wc;
|
||||
int mb_cur_max;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t nwc;
|
||||
char mb[MB_LEN_MAX+1];
|
||||
|
|
@ -130,9 +131,10 @@ sh_modcase (string, pat, flags)
|
|||
|
||||
start = 0;
|
||||
end = strlen (string);
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
|
||||
ret = (char *)xmalloc (end + 1);
|
||||
strcpy (ret, string);
|
||||
ret = (char *)xmalloc (2*end + 1);
|
||||
retind = 0;
|
||||
|
||||
/* See if we are supposed to split on alphanumerics and operate on each word */
|
||||
usewords = (flags & CASE_USEWORDS);
|
||||
|
|
@ -141,26 +143,23 @@ sh_modcase (string, pat, flags)
|
|||
inword = 0;
|
||||
while (start < end)
|
||||
{
|
||||
wc = cval (ret, start);
|
||||
wc = cval ((char *)string, start);
|
||||
|
||||
if (iswalnum (wc) == 0)
|
||||
{
|
||||
inword = 0;
|
||||
#if 0
|
||||
ADVANCE_CHAR (ret, end, start);
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
inword = 0;
|
||||
|
||||
if (pat)
|
||||
{
|
||||
next = start;
|
||||
ADVANCE_CHAR (ret, end, next);
|
||||
s = substring (ret, start, next);
|
||||
ADVANCE_CHAR (string, end, next);
|
||||
s = substring ((char *)string, start, next);
|
||||
match = strmatch (pat, s, FNM_EXTMATCH) != FNM_NOMATCH;
|
||||
free (s);
|
||||
if (match == 0)
|
||||
{
|
||||
/* copy unmatched portion */
|
||||
memcpy (ret + retind, string + start, next - start);
|
||||
retind += next - start;
|
||||
start = next;
|
||||
inword = 1;
|
||||
continue;
|
||||
|
|
@ -210,27 +209,27 @@ sh_modcase (string, pat, flags)
|
|||
else
|
||||
nop = flags;
|
||||
|
||||
/* Need to check UCHAR_MAX since wc may have already been converted to a
|
||||
wide character by cval() */
|
||||
if (MB_CUR_MAX == 1 || (wc <= UCHAR_MAX && is_basic ((int)wc)))
|
||||
/* Can't short-circuit, some locales have multibyte upper and lower
|
||||
case equivalents of single-byte ascii characters (e.g., Turkish) */
|
||||
if (mb_cur_max == 1)
|
||||
{
|
||||
singlebyte:
|
||||
switch (nop)
|
||||
{
|
||||
default:
|
||||
case CASE_NOOP: nc = wc; break;
|
||||
case CASE_UPPER: nc = TOUPPER (wc); break;
|
||||
case CASE_LOWER: nc = TOLOWER (wc); break;
|
||||
case CASE_TOGGLEALL:
|
||||
case CASE_TOGGLE: nc = TOGGLE (wc); break;
|
||||
}
|
||||
ret[start] = nc;
|
||||
{
|
||||
default:
|
||||
case CASE_NOOP: nc = wc; break;
|
||||
case CASE_UPPER: nc = TOUPPER (wc); break;
|
||||
case CASE_LOWER: nc = TOLOWER (wc); break;
|
||||
case CASE_TOGGLEALL:
|
||||
case CASE_TOGGLE: nc = TOGGLE (wc); break;
|
||||
}
|
||||
ret[retind++] = nc;
|
||||
}
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
else
|
||||
{
|
||||
m = mbrtowc (&wc, string + start, end - start, &state);
|
||||
if (MB_INVALIDCH (m))
|
||||
if (MB_INVALIDCH (m) || m == 1)
|
||||
{
|
||||
wc = (unsigned char)string[start];
|
||||
goto singlebyte;
|
||||
|
|
@ -238,28 +237,34 @@ singlebyte:
|
|||
else if (MB_NULLWCH (m))
|
||||
wc = L'\0';
|
||||
switch (nop)
|
||||
{
|
||||
default:
|
||||
case CASE_NOOP: nwc = wc; break;
|
||||
case CASE_UPPER: nwc = _to_wupper (wc); break;
|
||||
case CASE_LOWER: nwc = _to_wlower (wc); break;
|
||||
case CASE_TOGGLEALL:
|
||||
case CASE_TOGGLE: nwc = TOGGLE (wc); break;
|
||||
}
|
||||
if (nwc != wc) /* just skip unchanged characters */
|
||||
{
|
||||
default:
|
||||
case CASE_NOOP: nwc = wc; break;
|
||||
case CASE_UPPER: nwc = _to_wupper (wc); break;
|
||||
case CASE_LOWER: nwc = _to_wlower (wc); break;
|
||||
case CASE_TOGGLEALL:
|
||||
case CASE_TOGGLE: nwc = TOGGLE (wc); break;
|
||||
}
|
||||
|
||||
/* We don't have to convert `wide' characters that are in the
|
||||
unsigned char range back to single-byte `multibyte' characters. */
|
||||
if ((int)nwc <= UCHAR_MAX && is_basic ((int)nwc))
|
||||
ret[retind++] = nwc;
|
||||
else
|
||||
{
|
||||
mlen = wcrtomb (mb, nwc, &state);
|
||||
if (mlen > 0)
|
||||
mb[mlen] = '\0';
|
||||
/* Assume the same width */
|
||||
strncpy (ret + start, mb, mlen);
|
||||
/* Don't assume the same width */
|
||||
strncpy (ret + retind, mb, mlen);
|
||||
retind += mlen;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This assumes that the upper and lower case versions are the same width. */
|
||||
ADVANCE_CHAR (ret, end, start);
|
||||
ADVANCE_CHAR (string, end, start);
|
||||
}
|
||||
|
||||
ret[retind] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ extern int errno;
|
|||
#endif /* R_OK */
|
||||
|
||||
static int path_is_devfd __P((const char *));
|
||||
static int sh_stataccess __P((char *, int));
|
||||
static int sh_stataccess __P((const char *, int));
|
||||
#if HAVE_DECL_SETREGID
|
||||
static int sh_euidaccess __P((char *, int));
|
||||
static int sh_euidaccess __P((const char *, int));
|
||||
#endif
|
||||
|
||||
static int
|
||||
|
|
@ -135,7 +135,7 @@ sh_stat (path, finfo)
|
|||
executable. This version uses stat(2). */
|
||||
static int
|
||||
sh_stataccess (path, mode)
|
||||
char *path;
|
||||
const char *path;
|
||||
int mode;
|
||||
{
|
||||
struct stat st;
|
||||
|
|
@ -172,7 +172,7 @@ sh_stataccess (path, mode)
|
|||
the effective and real uid and gid as appropriate. */
|
||||
static int
|
||||
sh_euidaccess (path, mode)
|
||||
char *path;
|
||||
const char *path;
|
||||
int mode;
|
||||
{
|
||||
int r, e;
|
||||
|
|
@ -197,7 +197,7 @@ sh_euidaccess (path, mode)
|
|||
|
||||
int
|
||||
sh_eaccess (path, mode)
|
||||
char *path;
|
||||
const char *path;
|
||||
int mode;
|
||||
{
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* mbscasecmp - case-insensitive multibyte string comparison. */
|
||||
|
||||
/* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -35,17 +35,18 @@ mbscasecmp (mbs1, mbs2)
|
|||
const char *mbs1;
|
||||
const char *mbs2;
|
||||
{
|
||||
int len1, len2;
|
||||
int len1, len2, mb_cur_max;
|
||||
wchar_t c1, c2, l1, l2;
|
||||
|
||||
len1 = len2 = 0;
|
||||
/* Reset multibyte characters to their initial state. */
|
||||
(void) mblen ((char *) NULL, 0);
|
||||
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
do
|
||||
{
|
||||
len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
|
||||
len2 = mbtowc (&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;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* mbscmp - multibyte string comparison. */
|
||||
|
||||
/* Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -32,17 +32,18 @@ mbscmp (mbs1, mbs2)
|
|||
const char *mbs1;
|
||||
const char *mbs2;
|
||||
{
|
||||
int len1, len2;
|
||||
int len1, len2, mb_cur_max;
|
||||
wchar_t c1, c2;
|
||||
|
||||
len1 = len2 = 0;
|
||||
/* Reset multibyte characters to their initial state. */
|
||||
(void) mblen ((char *) NULL, 0);
|
||||
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
do
|
||||
{
|
||||
len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
|
||||
len2 = mbtowc (&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;
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@
|
|||
|
||||
#include "bashansi.h"
|
||||
|
||||
#if DEBUG
|
||||
#if DEBUG_MKTIME
|
||||
#include <stdio.h>
|
||||
/* Make it work even if the system's libc has its own mktime routine. */
|
||||
#define mktime my_mktime
|
||||
#endif /* DEBUG */
|
||||
#endif /* DEBUG_MKTIME */
|
||||
|
||||
#ifndef __P
|
||||
#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
|
||||
|
|
@ -75,12 +75,27 @@
|
|||
#define INT_MAX (~0 - INT_MIN)
|
||||
#endif
|
||||
|
||||
/* True if the arithmetic type T is signed. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
|
||||
/* The maximum and minimum values for the integer type T. These
|
||||
macros have undefined behavior if T is signed and has padding bits.
|
||||
If this is a problem for you, please let us know how to fix it for
|
||||
your host. */
|
||||
#define TYPE_MINIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) 0 \
|
||||
: ~ TYPE_MAXIMUM (t)))
|
||||
#define TYPE_MAXIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) -1 \
|
||||
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
|
||||
|
||||
#ifndef TIME_T_MIN
|
||||
#define TIME_T_MIN (0 < (time_t) -1 ? (time_t) 0 \
|
||||
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
|
||||
# define TIME_T_MIN TYPE_MINIMUM (time_t)
|
||||
#endif
|
||||
#ifndef TIME_T_MAX
|
||||
#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
|
||||
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
|
||||
#endif
|
||||
|
||||
#define TM_YEAR_BASE 1900
|
||||
|
|
@ -303,7 +318,7 @@ __mktime_internal (tp, convert, offset)
|
|||
weak_alias (mktime, timelocal)
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
#if DEBUG_MKTIME
|
||||
|
||||
static int
|
||||
not_equal_tm (a, b)
|
||||
|
|
@ -414,7 +429,7 @@ main (argc, argv)
|
|||
return status;
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
#endif /* DEBUG_MKTIME */
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ int
|
|||
isnetconn (fd)
|
||||
int fd;
|
||||
{
|
||||
#if defined (HAVE_GETPEERNAME) && !defined (SVR4_2) && !defined (__BEOS__)
|
||||
#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && !defined (SVR4_2) && !defined (__BEOS__)
|
||||
int rv;
|
||||
socklen_t l;
|
||||
struct sockaddr sa;
|
||||
|
|
@ -52,7 +52,7 @@ isnetconn (fd)
|
|||
l = sizeof(sa);
|
||||
rv = getpeername(fd, &sa, &l);
|
||||
/* Posix.2 says getpeername can return these errors. */
|
||||
return ((rv < 0 && (errno == ENOTSOCK || errno == ENOTCONN || errno == EINVAL)) ? 0 : 1);
|
||||
return ((rv < 0 && (errno == ENOTSOCK || errno == ENOTCONN || errno == EINVAL || errno == EBADF)) ? 0 : 1);
|
||||
#else /* !HAVE_GETPEERNAME || SVR4_2 || __BEOS__ */
|
||||
# if defined (SVR4) || defined (SVR4_2)
|
||||
/* Sockets on SVR4 and SVR4.2 are character special (streams) devices. */
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* chet@ins.CWRU.Edu
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -304,6 +304,7 @@ netopen (path)
|
|||
if (t == 0)
|
||||
{
|
||||
internal_error (_("%s: bad network path specification"), path);
|
||||
free (np);
|
||||
return -1;
|
||||
}
|
||||
*t++ = '\0';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* shmatch.c -- shell interface to posix regular expression matching.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -79,7 +79,8 @@ sh_regmatch (string, pattern, flags)
|
|||
matches = NULL;
|
||||
#endif
|
||||
|
||||
if (regexec (®ex, string, regex.re_nsub + 1, matches, 0))
|
||||
/* man regexec: NULL PMATCH ignored if NMATCH == 0 */
|
||||
if (regexec (®ex, string, matches ? regex.re_nsub + 1 : 0, matches, 0))
|
||||
result = EXECUTION_FAILURE;
|
||||
else
|
||||
result = EXECUTION_SUCCESS; /* match */
|
||||
|
|
@ -91,11 +92,11 @@ sh_regmatch (string, pattern, flags)
|
|||
/* Store the parenthesized subexpressions in the array BASH_REMATCH.
|
||||
Element 0 is the portion that matched the entire regexp. Element 1
|
||||
is the part that matched the first subexpression, and so on. */
|
||||
unbind_variable ("BASH_REMATCH");
|
||||
unbind_variable_noref ("BASH_REMATCH");
|
||||
rematch = make_new_array_variable ("BASH_REMATCH");
|
||||
amatch = array_cell (rematch);
|
||||
|
||||
if ((flags & SHMAT_SUBEXP) && result == EXECUTION_SUCCESS && subexp_str)
|
||||
if (matches && (flags & SHMAT_SUBEXP) && result == EXECUTION_SUCCESS && subexp_str)
|
||||
{
|
||||
for (subexp_ind = 0; subexp_ind <= regex.re_nsub; subexp_ind++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2001, 2006, 2009, 2010, 2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001, 2006, 2009, 2010, 2012, 2015 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
|
||||
|
|
@ -43,10 +43,11 @@ mbstrlen (s)
|
|||
{
|
||||
size_t clen, nc;
|
||||
mbstate_t mbs = { 0 }, mbsbak = { 0 };
|
||||
int f;
|
||||
int f, mb_cur_max;
|
||||
|
||||
nc = 0;
|
||||
while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, mb_cur_max, &mbs)) != 0)
|
||||
{
|
||||
if (MB_INVALIDCH(clen))
|
||||
{
|
||||
|
|
@ -71,13 +72,15 @@ mbsmbchar (s)
|
|||
char *t;
|
||||
size_t clen;
|
||||
mbstate_t mbs = { 0 };
|
||||
int mb_cur_max;
|
||||
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
for (t = (char *)s; *t; t++)
|
||||
{
|
||||
if (is_basic (*t))
|
||||
continue;
|
||||
|
||||
clen = mbrlen (t, MB_CUR_MAX, &mbs);
|
||||
clen = mbrlen (t, mb_cur_max, &mbs);
|
||||
|
||||
if (clen == 0)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* shquote - functions to quote and dequote strings */
|
||||
|
||||
/* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -28,10 +28,17 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdc.h>
|
||||
|
||||
#include "syntax.h"
|
||||
#include <xmalloc.h>
|
||||
|
||||
#include "shmbchar.h"
|
||||
#include "shmbutil.h"
|
||||
|
||||
extern char *ansic_quote __P((char *, int, int *));
|
||||
extern int ansic_shouldquote __P((const char *));
|
||||
|
||||
/* Default set of characters that should be backslash-quoted in strings */
|
||||
static const char bstab[256] =
|
||||
{
|
||||
|
|
@ -141,8 +148,11 @@ sh_double_quote (string)
|
|||
/* Backslash-newline disappears within double quotes, so don't add one. */
|
||||
if ((sh_syntaxtab[c] & CBSDQUOTE) && c != '\n')
|
||||
*r++ = '\\';
|
||||
#if 0
|
||||
/* Assume that the string will not be further expanded. */
|
||||
else if (c == CTLESC || c == CTLNUL)
|
||||
*r++ = CTLESC; /* could be '\\'? */
|
||||
#endif
|
||||
|
||||
*r++ = c;
|
||||
}
|
||||
|
|
@ -226,15 +236,36 @@ sh_backslash_quote (string, table, flags)
|
|||
char *table;
|
||||
int flags;
|
||||
{
|
||||
int c;
|
||||
char *result, *r, *s, *backslash_table;
|
||||
int c, mb_cur_max;
|
||||
size_t slen;
|
||||
char *result, *r, *s, *backslash_table, *send;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
result = (char *)xmalloc (2 * strlen (string) + 1);
|
||||
slen = strlen (string);
|
||||
send = string + slen;
|
||||
result = (char *)xmalloc (2 * slen + 1);
|
||||
|
||||
backslash_table = table ? table : (char *)bstab;
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
|
||||
for (r = result, s = string; s && (c = *s); s++)
|
||||
{
|
||||
if (backslash_table[c] == 1)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* XXX - isascii, even if is_basic(c) == 0 - works in most cases. */
|
||||
if (c >= 0 && c <= 127 && backslash_table[(unsigned char)c] == 1)
|
||||
{
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
continue;
|
||||
}
|
||||
if (mb_cur_max > 1 && is_basic (c) == 0)
|
||||
{
|
||||
COPY_CHAR_P (r, s, send);
|
||||
s--; /* compensate for auto-increment in loop above */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (backslash_table[(unsigned char)c] == 1)
|
||||
*r++ = '\\';
|
||||
else if (c == '#' && s == string) /* comment char */
|
||||
*r++ = '\\';
|
||||
|
|
@ -277,11 +308,36 @@ sh_backslash_quote_for_double_quotes (string)
|
|||
}
|
||||
#endif /* PROMPT_STRING_DECODE */
|
||||
|
||||
char *
|
||||
sh_quote_reusable (s, flags)
|
||||
char *s;
|
||||
int flags;
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (s == 0)
|
||||
return s;
|
||||
else if (*s == 0)
|
||||
{
|
||||
ret = (char *)xmalloc (3);
|
||||
ret[0] = ret[1] = '\'';
|
||||
ret[2] = '\0';
|
||||
}
|
||||
else if (ansic_shouldquote (s))
|
||||
ret = ansic_quote (s, 0, (int *)0);
|
||||
else if (flags)
|
||||
ret = sh_backslash_quote (s, 0, 1);
|
||||
else
|
||||
ret = sh_single_quote (s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
sh_contains_shell_metas (string)
|
||||
char *string;
|
||||
const char *string;
|
||||
{
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
for (s = string; s && *s; s++)
|
||||
{
|
||||
|
|
@ -314,9 +370,9 @@ sh_contains_shell_metas (string)
|
|||
|
||||
int
|
||||
sh_contains_quotes (string)
|
||||
char *string;
|
||||
const char *string;
|
||||
{
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
for (s = string; s && *s; s++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* strtrans.c - Translate and untranslate strings with ANSI-C escape sequences. */
|
||||
|
||||
/* Copyright (C) 2000-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -60,7 +60,10 @@ ansicstr (string, len, flags, sawc, rlen)
|
|||
return ((char *)NULL);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
ret = (char *)xmalloc (4*len + 1);
|
||||
temp = 4*len + 1;
|
||||
if (temp < 12)
|
||||
temp = 12; /* ensure enough for eventual u32cesc */
|
||||
ret = (char *)xmalloc (temp);
|
||||
#else
|
||||
ret = (char *)xmalloc (2*len + 1); /* 2*len for possible CTLESC */
|
||||
#endif
|
||||
|
|
@ -309,8 +312,9 @@ ansic_wshouldquote (string)
|
|||
|
||||
slen = mbstowcs (wcstr, string, 0);
|
||||
|
||||
if (slen == -1)
|
||||
slen = 0;
|
||||
if (slen == (size_t)-1)
|
||||
return 1;
|
||||
|
||||
wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (slen + 1));
|
||||
mbstowcs (wcstr, string, slen + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* tmpfile.c - functions to create and safely open temp files for the shell.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -47,6 +47,11 @@ extern int errno;
|
|||
#define DEFAULT_TMPDIR "." /* bogus default, should be changed */
|
||||
#define DEFAULT_NAMEROOT "shtmp"
|
||||
|
||||
/* Use ANSI-C rand() interface if random(3) is not available */
|
||||
#if !HAVE_RANDOM
|
||||
#define random() rand()
|
||||
#endif
|
||||
|
||||
extern pid_t dollar_dollar_pid;
|
||||
|
||||
static char *get_sys_tmpdir __P((void));
|
||||
|
|
@ -109,6 +114,23 @@ get_tmpdir (flags)
|
|||
return tdir;
|
||||
}
|
||||
|
||||
static void
|
||||
sh_seedrand ()
|
||||
{
|
||||
#if HAVE_RANDOM
|
||||
int d;
|
||||
static int seeded = 0;
|
||||
if (seeded == 0)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (uintptr_t)&d);
|
||||
seeded = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
sh_mktmpname (nameroot, flags)
|
||||
char *nameroot;
|
||||
|
|
@ -117,6 +139,7 @@ sh_mktmpname (nameroot, flags)
|
|||
char *filename, *tdir, *lroot;
|
||||
struct stat sb;
|
||||
int r, tdlen;
|
||||
static int seeded = 0;
|
||||
|
||||
filename = (char *)xmalloc (PATH_MAX + 1);
|
||||
tdir = get_tmpdir (flags);
|
||||
|
|
@ -132,6 +155,7 @@ sh_mktmpname (nameroot, flags)
|
|||
filename = NULL;
|
||||
}
|
||||
#else /* !USE_MKTEMP */
|
||||
sh_seedrand ();
|
||||
while (1)
|
||||
{
|
||||
filenum = (filenum << 1) ^
|
||||
|
|
@ -162,7 +186,7 @@ sh_mktmpfd (nameroot, flags, namep)
|
|||
{
|
||||
char *filename, *tdir, *lroot;
|
||||
int fd, tdlen;
|
||||
|
||||
|
||||
filename = (char *)xmalloc (PATH_MAX + 1);
|
||||
tdir = get_tmpdir (flags);
|
||||
tdlen = strlen (tdir);
|
||||
|
|
@ -181,6 +205,7 @@ sh_mktmpfd (nameroot, flags, namep)
|
|||
*namep = filename;
|
||||
return fd;
|
||||
#else /* !USE_MKSTEMP */
|
||||
sh_seedrand ();
|
||||
do
|
||||
{
|
||||
filenum = (filenum << 1) ^
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
# include "posixselect.h"
|
||||
#endif
|
||||
|
||||
/* A version of `alarm' using setitimer if it's available. */
|
||||
|
||||
#if defined (HAVE_SETITIMER)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* unicode.c - functions to convert unicode characters */
|
||||
|
||||
/* Copyright (C) 2010-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ u32toutf16 (c, s)
|
|||
}
|
||||
|
||||
/* convert a single unicode-32 character into a multibyte string and put the
|
||||
result in S, which must be large enough (at least MB_LEN_MAX bytes) */
|
||||
result in S, which must be large enough (at least max(10,MB_LEN_MAX) bytes) */
|
||||
int
|
||||
u32cconv (c, s)
|
||||
unsigned long c;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* winsize.c - handle window size changes and information. */
|
||||
|
||||
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -32,9 +32,11 @@
|
|||
|
||||
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
|
||||
|
||||
#if 0
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
|
||||
#endif
|
||||
|
||||
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# include <termios.h>
|
||||
|
|
|
|||
|
|
@ -48,9 +48,12 @@ typedef ssize_t creadfunc_t __P((int, char *));
|
|||
/* Derived from GNU libc's getline.
|
||||
The behavior is almost the same as getline. See man getline.
|
||||
The differences are
|
||||
(1) using file descriptor instead of FILE *,
|
||||
(2) the order of arguments; the file descriptor comes the first, and
|
||||
(3) the addition of third argument, UNBUFFERED_READ; this argument
|
||||
(1) using file descriptor instead of FILE *;
|
||||
(2) the order of arguments: the file descriptor comes first;
|
||||
(3) the addition of a fourth argument, DELIM; sets the delimiter to
|
||||
be something other than newline if desired. If setting DELIM,
|
||||
the next argument should be 1; and
|
||||
(4) the addition of a fifth argument, UNBUFFERED_READ; this argument
|
||||
controls whether get_line uses buffering or not to get a byte data
|
||||
from FD. get_line uses zreadc if UNBUFFERED_READ is zero; and
|
||||
uses zread if UNBUFFERED_READ is non-zero.
|
||||
|
|
@ -58,10 +61,11 @@ typedef ssize_t creadfunc_t __P((int, char *));
|
|||
Returns number of bytes read or -1 on error. */
|
||||
|
||||
ssize_t
|
||||
zgetline (fd, lineptr, n, unbuffered_read)
|
||||
zgetline (fd, lineptr, n, delim, unbuffered_read)
|
||||
int fd;
|
||||
char **lineptr;
|
||||
size_t *n;
|
||||
int delim;
|
||||
int unbuffered_read;
|
||||
{
|
||||
int nr, retval;
|
||||
|
|
@ -110,7 +114,7 @@ zgetline (fd, lineptr, n, unbuffered_read)
|
|||
line[nr] = c;
|
||||
nr++;
|
||||
|
||||
if (c == '\n')
|
||||
if (c == delim)
|
||||
{
|
||||
line[nr] = '\0';
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue