commit bash-20060406 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 22:47:02 -05:00
parent 4c4d2fbfda
commit f0130b89d2
21 changed files with 1021 additions and 617 deletions
+52
View File
@@ -13241,3 +13241,55 @@ execute_cmd.c
lib/sh/strtrans.c
- add code to echo -e and echo with xpg_echo enabled to require
a leading 0 to specify octal constants
4/3
---
subst.c
- slight change to wcsdup() replacement: use memcpy instead of wcscpy
parse.y
- before turning on W_COMPASSIGN, make sure the final character in the
token is a `(' (avoids problems with things like a=(4*3)/2)
4/4
---
lib/sh/snprintf.c
- in number() and lnumber(), turn off PF_ZEROPAD if explicit precision
supplied in format
- change number() and lnumber() to correctly implement zero-padding
specified by a non-zero `.precision' part of the format
subst.c
- new flag for extract_delimited_string: EX_COMMAND. For $(...), so
we can do things like skip over delimiters in comments. Added to
appropriate callers
- changes to extract_delimited_string to skip over shell comments when
extracting a command for $(...) (EX_COMMAND is contained in the
flags argument)
4/5
---
subst.c
- first argument to skip_single_quoted is now a const char *
- new function, chk_arithsub, checks for valid arithmetic expressions
by balancing parentheses. Fix based on a patch from Len Lattanzi
4/6
---
{configure,config.h}.in
- add separate test for isnan in libc, instead of piggybacking on
isinf-in-libc test
lib/sh/snprintf.c
- separate the isnan replacement function so it's guarded by its own
HAVE_ISNAN_IN_LIBC define
lib/sh/wcsdup.c
- new file, contains replacement wcsdup library function from subst.c
with change back to using wcscpy
Makefile.in,lib/sh/Makefile.in
- make sure wcsdup.c is compiled and linked in
subst.c
- wcsdup now found in libsh; removed static definition
+1
View File
@@ -422,6 +422,7 @@ lib/sh/times.c f
lib/sh/timeval.c f
lib/sh/tmpfile.c f
lib/sh/vprint.c f
lib/sh/wcsdup.c f
lib/sh/winsize.c f
lib/sh/xstrchr.c f
lib/sh/zcatfd.c f
+1 -1
View File
@@ -201,7 +201,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/memset.c ${SH_LIBSRC}/xstrchr.c \
${SH_LIBSRC}/zcatfd.c ${SH_LIBSRC}/shmatch.c \
${SH_LIBSRC}/strnlen.c ${SH_LIBSRC}/winsize.c \
${SH_LIBSRC}/eaccess.c
${SH_LIBSRC}/eaccess.c ${SH_LIBSRC}/wcsdup.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
+98 -1
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.in for Bash 3.2, version 3.187.
@%:@ From configure.in for Bash 3.2, version 3.188.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.59 for bash 3.2-devel.
@%:@
@@ -11914,6 +11914,103 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for isnan" >&5
echo $ECHO_N "checking for isnan... $ECHO_C" >&6
if test "${ac_cv_func_isnan+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define isnan to an innocuous variant, in case <limits.h> declares isnan.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define isnan innocuous_isnan
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char isnan (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef isnan
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char isnan ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_isnan) || defined (__stub___isnan)
choke me
#else
char (*f) () = isnan;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != isnan;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_isnan=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isnan=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_func_isnan" >&5
echo "${ECHO_T}$ac_cv_func_isnan" >&6
if test $ac_cv_func_isnan = yes; then
cat >>confdefs.h <<\_ACEOF
@%:@define HAVE_ISNAN_IN_LIBC 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for mkfifo" >&5
echo $ECHO_N "checking for mkfifo... $ECHO_C" >&6
+17 -17
View File
@@ -17,19 +17,19 @@
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_STRUCT_TM' => 1,
'AC_HEADER_TIME' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRNLEN' => 1,
@@ -48,17 +48,17 @@
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_PROG_MAKE_SET' => 1,
'sinclude' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_FUNC_FORK' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_YACC' => 1,
'AC_INIT' => 1,
'AC_STRUCT_TIMEZONE' => 1,
@@ -80,33 +80,33 @@
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_HEADER_STAT' => 1,
'AC_PROG_CPP' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_C_INLINE' => 1,
'AC_TYPE_PID_T' => 1,
'AC_PROG_LEX' => 1,
'AC_PROG_CPP' => 1,
'AC_C_CONST' => 1,
'AC_PROG_LEX' => 1,
'AC_TYPE_PID_T' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_MEMCMP' => 1,
'm4_include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
+549 -548
View File
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -1,6 +1,6 @@
/* config.h -- Configuration file for bash. */
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -583,9 +583,12 @@
/* Define if you have the isgraph function. */
#undef HAVE_ISGRAPH
/* Define if you have the isint function in libc */
/* Define if you have the isinf function in libc */
#undef HAVE_ISINF_IN_LIBC
/* Define if you have the isnan function in libc */
#undef HAVE_ISNAN_IN_LIBC
/* Define if you have the isprint function. */
#undef HAVE_ISPRINT
Vendored
+98 -1
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 3.2, version 3.187.
# From configure.in for Bash 3.2, version 3.188.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for bash 3.2-devel.
#
@@ -11914,6 +11914,103 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for isnan" >&5
echo $ECHO_N "checking for isnan... $ECHO_C" >&6
if test "${ac_cv_func_isnan+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define isnan to an innocuous variant, in case <limits.h> declares isnan.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define isnan innocuous_isnan
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char isnan (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef isnan
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char isnan ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_isnan) || defined (__stub___isnan)
choke me
#else
char (*f) () = isnan;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != isnan;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_isnan=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isnan=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_func_isnan" >&5
echo "${ECHO_T}$ac_cv_func_isnan" >&6
if test $ac_cv_func_isnan = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ISNAN_IN_LIBC 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for mkfifo" >&5
echo $ECHO_N "checking for mkfifo... $ECHO_C" >&6
+2 -1
View File
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 3.2, version 3.187])dnl
AC_REVISION([for Bash 3.2, version 3.188])dnl
define(bashvers, 3.2)
define(relstatus, devel)
@@ -688,6 +688,7 @@ dnl checks for certain version-specific system calls and libc functions
AC_CHECK_FUNC(__setostype, AC_DEFINE(HAVE_SETOSTYPE))
AC_CHECK_FUNC(wait3, AC_DEFINE(HAVE_WAIT3))
AC_CHECK_FUNC(isinf, AC_DEFINE(HAVE_ISINF_IN_LIBC))
AC_CHECK_FUNC(isnan, AC_DEFINE(HAVE_ISNAN_IN_LIBC))
dnl checks for missing libc functions
AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
+2 -2
View File
@@ -809,10 +809,10 @@ as for pathname expansion (see
.B Pathname Expansion
below).
The \fIword\fP is expanded using tilde
expansion, parameter and variable expansion, arithmetic substituion,
expansion, parameter and variable expansion, arithmetic substitution,
command substitution, process substitution and quote removal.
Each \fIpattern\fP examined is expanded using tilde
expansion, parameter and variable expansion, arithmetic substituion,
expansion, parameter and variable expansion, arithmetic substitution,
command substitution, and process substitution.
If the shell option
.B nocasematch
+10 -2
View File
@@ -88,7 +88,8 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
shquote.c strtrans.c strindex.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 winsize.c eaccess.c
mktime.c strftime.c xstrchr.c zcatfd.c winsize.c eaccess.c \
wcsdup.c
# The header files for this library.
HSOURCES =
@@ -100,7 +101,8 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.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 winsize.o ${LIBOBJS}
fmtullong.o fmtumax.o xstrchr.o zcatfd.o winsize.o wcsdup.o \
${LIBOBJS}
SUPPORT = Makefile
@@ -177,6 +179,7 @@ times.o: times.c
timeval.o: timeval.c
tmpfile.o: tmpfile.c
vprint.o: vprint.c
wcsdup.o: wcsdup.c
xstrchr.o: xstrchr.c
zcatfd.o: zcatfd.c
zread.o: zread.c
@@ -235,6 +238,7 @@ times.o: ${BUILD_DIR}/config.h
timeval.o: ${BUILD_DIR}/config.h
tmpfile.o: ${BUILD_DIR}/config.h
vprint.o: ${BUILD_DIR}/config.h
wcsdup.o: ${BUILD_DIR}/config.h
xstrchr.o: ${BUILD_DIR}/config.h
zcatfd.o: ${BUILD_DIR}/config.h
zread.o: ${BUILD_DIR}/config.h
@@ -465,6 +469,10 @@ fmtumax.o: ${BASHINCDIR}/stdc.h
fmtumax.o: ${BASHINCDIR}/typemax.h
fmtumax.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
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
+29
View File
@@ -65,6 +65,7 @@
#define HAVE_PRINTF_A_FORMAT
#endif
#define HAVE_ISINF_IN_LIBC
#define HAVE_ISNAN_IN_LIBC
#define PREFER_STDARG
#define HAVE_STRINGIZE
#define HAVE_LIMITS_H
@@ -370,6 +371,12 @@ static void xfree __P((void *));
for (; (p)->width > 0; (p)->width--) \
PUT_CHAR((p)->pad, p)
/* pad with zeros from decimal precision */
#define PAD_ZERO(p) \
if ((p)->precision > 0) \
for (; (p)->precision > 0; (p)->precision--) \
PUT_CHAR('0', p)
/* if width and prec. in the args */
#define STAR_ARGS(p) \
do { \
@@ -651,6 +658,10 @@ number(p, d, base)
long sd;
int flags;
/* An explicit precision turns off the zero-padding flag. */
if ((p->flags & PF_ZEROPAD) && p->precision >= 0 && (p->flags & PF_DOT))
p->flags &= ~PF_ZEROPAD;
sd = d; /* signed for ' ' padding in base 10 */
flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
if (*p->pf == 'X')
@@ -668,6 +679,12 @@ number(p, d, base)
p->width -= strlen(tmp);
PAD_RIGHT(p);
if ((p->flags & PF_DOT) && p->precision > 0)
{
p->precision -= strlen(tmp);
PAD_ZERO(p);
}
switch (base)
{
case 10:
@@ -711,6 +728,10 @@ lnumber(p, d, base)
long long sd;
int flags;
/* An explicit precision turns off the zero-padding flag. */
if ((p->flags & PF_ZEROPAD) && p->precision >= 0 && (p->flags & PF_DOT))
p->flags &= ~PF_ZEROPAD;
sd = d; /* signed for ' ' padding in base 10 */
flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
if (*p->pf == 'X')
@@ -728,6 +749,12 @@ lnumber(p, d, base)
p->width -= strlen(tmp);
PAD_RIGHT(p);
if ((p->flags & PF_DOT) && p->precision > 0)
{
p->precision -= strlen(tmp);
PAD_ZERO(p);
}
switch (base)
{
case 10:
@@ -881,7 +908,9 @@ isinf(d)
#endif
return 0;
}
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int
isnan(d)
double d;
+44
View File
@@ -0,0 +1,44 @@
/* wcsdup.c - wcsdup(3) library function */
/* Copyright (C) 2006 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 2, 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; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
#include <stdc.h>
#include <wchar.h>
#include <bashansi.h>
#include <xmalloc.h>
wchar_t *
wcsdup (ws)
const wchar_t *ws;
{
wchar_t *ret;
size_t len;
len = wcslen (ws);
ret = xmalloc ((len + 1) * sizeof (wchar_t));
if (ret == 0)
return ret;
return (wcscpy (ret, ws));
}
#endif /* !HAVE_WCSDUP && HANDLE_MULTIBYTE */
+5 -3
View File
@@ -2776,7 +2776,9 @@ parse_matched_pair (qc, open, close, lenp, flags)
continue;
}
/* Not exactly right yet */
/* Not exactly right yet, should handle shell metacharacters, too. If
any changes are made to this test, make analogous changes to subst.c:
extract_delimited_string(). */
else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
in_comment = 1;
@@ -3696,8 +3698,8 @@ got_token:
if (dollar_present)
the_word->flags |= W_HASDOLLAR;
if (quoted)
the_word->flags |= W_QUOTED;
if (compound_assignment)
the_word->flags |= W_QUOTED; /*(*/
if (compound_assignment && token[token_index-1] == ')')
the_word->flags |= W_COMPASSIGN;
/* A word is an assignment if it appears at the beginning of a
simple command, or after another assignment word. This is
+91 -37
View File
@@ -4,7 +4,7 @@
/* ``Have a little faith, there's magic in the night. You ain't a
beauty, but, hey, you're alright.'' */
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -82,6 +82,7 @@ extern int errno;
#define EX_NOALLOC 0x01 /* just skip; don't return substring */
#define EX_VARNAME 0x02 /* variable name; for string_extract () */
#define EX_REQMATCH 0x04 /* closing/matching delimiter required */
#define EX_COMMAND 0x08 /* extracting a shell script/command */
/* Flags for the `pflags' argument to param_expand() */
#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */
@@ -147,6 +148,10 @@ extern int wordexp_only;
extern int expanding_redir;
extern int tempenv_assign_error;
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
extern wchar_t *wcsdup __P((const wchar_t *));
#endif
/* Non-zero means to allow unmatched globbed filenames to expand to
a null file. */
int allow_null_glob_expansion;
@@ -216,7 +221,7 @@ static char *string_extract_verbatim __P((char *, size_t, int *, char *));
static char *string_extract __P((char *, int *, char *, int));
static char *string_extract_double_quoted __P((char *, int *, int));
static inline char *string_extract_single_quoted __P((char *, int *));
static inline int skip_single_quoted __P((char *, size_t, int));
static inline int skip_single_quoted __P((const char *, size_t, int));
static int skip_double_quoted __P((char *, size_t, int));
static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int));
static char *extract_dollar_brace_string __P((char *, int *, int, int));
@@ -226,10 +231,7 @@ static char *pos_params __P((char *, int, int, int));
static unsigned char *mb_getcharlens __P((char *, int));
static char *remove_upattern __P((char *, char *, int));
#if defined (HANDLE_MULTIBYTE)
# if !defined (HAVE_WCSDUP)
static wchar_t *wcsdup __P((wchar_t *));
# endif
#if defined (HANDLE_MULTIBYTE)
static wchar_t *remove_wpattern __P((wchar_t *, size_t, wchar_t *, int));
#endif
static char *remove_pattern __P((char *, char *, int));
@@ -261,6 +263,7 @@ static arrayind_t array_length_reference __P((char *));
static int valid_brace_expansion_word __P((char *, int));
static int chk_atstar __P((char *, int, int *, int *));
static int chk_arithsub __P((const char *, int));
static WORD_DESC *parameter_brace_expand_word __P((char *, int, int));
static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int *, int *));
@@ -710,7 +713,7 @@ add_one_character:
si = i + 2;
if (string[i + 1] == LPAREN)
ret = extract_delimited_string (string, &si, "$(", "(", ")", 0); /*)*/
ret = extract_delimited_string (string, &si, "$(", "(", ")", EX_COMMAND); /*)*/
else
ret = extract_dollar_brace_string (string, &si, 1, 0);
@@ -812,7 +815,7 @@ skip_double_quoted (string, slen, sind)
{
si = i + 2;
if (string[i + 1] == LPAREN)
ret = extract_delimited_string (string, &si, "$(", "(", ")", EX_NOALLOC); /* ) */
ret = extract_delimited_string (string, &si, "$(", "(", ")", EX_NOALLOC|EX_COMMAND); /* ) */
else
ret = extract_dollar_brace_string (string, &si, 0, EX_NOALLOC);
@@ -865,7 +868,7 @@ string_extract_single_quoted (string, sindex)
static inline int
skip_single_quoted (string, slen, sind)
char *string;
const char *string;
size_t slen;
int sind;
{
@@ -980,7 +983,7 @@ extract_command_subst (string, sindex)
char *string;
int *sindex;
{
return (extract_delimited_string (string, sindex, "$(", "(", ")", 0)); /*)*/
return (extract_delimited_string (string, sindex, "$(", "(", ")", EX_COMMAND)); /*)*/
}
/* Extract the $[ construct in STRING, and return a new string. (])
@@ -1049,7 +1052,7 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)
int i, c, si;
size_t slen;
char *t, *result;
int pass_character, nesting_level;
int pass_character, nesting_level, in_comment;
int len_closer, len_opener, len_alt_opener;
DECLARE_MBSTATE;
@@ -1058,7 +1061,7 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)
len_alt_opener = STRLEN (alt_opener);
len_closer = STRLEN (closer);
pass_character = 0;
pass_character = in_comment = 0;
nesting_level = 1;
i = *sindex;
@@ -1070,6 +1073,14 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)
if (c == 0)
break;
if (in_comment)
{
if (c == '\n')
in_comment = 0;
ADVANCE_CHAR (string, slen, i);
continue;
}
if (pass_character) /* previous char was backslash */
{
pass_character = 0;
@@ -1077,6 +1088,15 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)
continue;
}
/* Not exactly right yet; should handle shell metacharacters and
multibyte characters, too. */
if ((flags & EX_COMMAND) && c == '#' && (i == 0 || string[i - 1] == '\n' || whitespace (string[i - 1])))
{
in_comment = 1;
ADVANCE_CHAR (string, slen, i);
continue;
}
if (c == CTLESC || c == '\\')
{
pass_character++;
@@ -1235,7 +1255,7 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
if (string[i] == '$' && string[i+1] == LPAREN)
{
si = i + 2;
t = extract_delimited_string (string, &si, "$(", "(", ")", flags|EX_NOALLOC); /*)*/
t = extract_delimited_string (string, &si, "$(", "(", ")", flags|EX_NOALLOC|EX_COMMAND); /*)*/
i = si + 1;
continue;
}
@@ -1498,7 +1518,7 @@ skip_to_delim (string, start, delims)
CQ_RETURN(si);
if (string[i+1] == LPAREN)
temp = extract_delimited_string (string, &si, "$(", "(", ")", EX_NOALLOC); /* ) */
temp = extract_delimited_string (string, &si, "$(", "(", ")", EX_NOALLOC|EX_COMMAND); /* ) */
else
temp = extract_dollar_brace_string (string, &si, 0, EX_NOALLOC);
i = si;
@@ -3317,23 +3337,6 @@ remove_upattern (param, pattern, op)
}
#if defined (HANDLE_MULTIBYTE)
#if !defined (HAVE_WCSDUP)
static wchar_t *
wcsdup (ws)
wchar_t *ws;
{
wchar_t *ret;
size_t len;
len = wcslen (ws);
ret = xmalloc ((len + 1) * sizeof (wchar_t));
if (ret == 0)
return ret;
return (wcscpy (ret, ws));
}
#endif /* !HAVE_WCSDUP */
static wchar_t *
remove_wpattern (wparam, wstrlen, wpattern, op)
wchar_t *wparam;
@@ -5803,6 +5806,57 @@ parameter_brace_patsub (varname, value, patsub, quoted)
return temp;
}
/* Check for unbalanced parens in S, which is the contents of $(( ... )). If
any occur, this must be a nested command substitution, so return 0.
Otherwise, return 1. A valid arithmetic expression must always have a
( before a matching ), so any cases where there are more right parens
means that this must not be an arithmetic expression, though the parser
will not accept it without a balanced total number of parens. */
static int
chk_arithsub (s, len)
const char *s;
int len;
{
int i, count;
DECLARE_MBSTATE;
i = count = 0;
while (i < len)
{
if (s[i] == '(')
count++;
else if (s[i] == ')')
{
count--;
if (count < 0)
return 0;
}
switch (s[i])
{
default:
ADVANCE_CHAR (s, len, i);
break;
case '\\':
i++;
if (s[i])
ADVANCE_CHAR (s, len, i);
break;
case '\'':
i = skip_single_quoted (s, len, ++i);
break;
case '"':
i = skip_double_quoted ((char *)s, len, ++i);
break;
}
}
return (count == 0);
}
/****************************************************************/
/* */
/* Functions to perform parameter expansion on a string */
@@ -6414,7 +6468,6 @@ param_expand (string, sindex, quoted, expanded_something,
quoted_dollar_at_p,
contains_dollar_at);
/* Fix this later when parameter_brace_expand returns a WORD_DESC * */
if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
return (tdesc);
temp = tdesc ? tdesc->word : (char *)0;
@@ -6427,12 +6480,7 @@ param_expand (string, sindex, quoted, expanded_something,
in the string, discard TEMP, and go on. The exception to
this is when we have "${@}" and $1 is '', since $@ needs
special handling. */
/* XXX - fix this once parameter_brace_expand returns a WORD_DESC * */
#if 0
if (temp && QUOTED_NULL (temp))
#else
if (tdesc && tdesc->word && (tdesc->flags & W_HASQUOTEDNULL) && QUOTED_NULL (temp))
#endif
{
if (had_quoted_null_p)
*had_quoted_null_p = 1;
@@ -6472,6 +6520,12 @@ param_expand (string, sindex, quoted, expanded_something,
/* Cut off ending `)' */
temp2[t_index] = '\0';
if (chk_arithsub (temp2, t_index) == 0)
{
free (temp2);
goto comsub;
}
/* Expand variables found inside the expression. */
temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES);
free (temp2);
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+2
View File
@@ -140,6 +140,7 @@ value = new1 new2 new3
8 11
8 11
6
6
nordholz
8
8
@@ -204,3 +205,4 @@ t
[3]=abcde r s t u v
e
9
2
+4
View File
@@ -399,3 +399,7 @@ unset x[2]
x[9]='9'
echo ${x[*]: -1}
TOOLKIT=(1 2 3 4 5 6 7 8 9 10)
ARRAY="1"
echo ${TOOLKIT["$ARRAY"]}
+2
View File
@@ -21,6 +21,8 @@ echo $a $b
let a=(4*3)/2
echo $a
a=(4*3)/2
echo $a
LNAME=nordholz
echo ${LNAME}
Binary file not shown.
+8 -1
View File
@@ -67,7 +67,7 @@ printf -- "--%b--\n" '\t\0101'
printf -- "--%b--\n" '\t\101'
# these should all display `A7'
echo -e "\1017"
echo -e "\01017"
echo -e "\x417"
printf "%b\n" '\01017'
@@ -246,3 +246,10 @@ printf '\x07e\n'
# additional backslash escapes
printf '\"\?\n'
# failures with decimal precisions until after bash-3.1
printf '%0.5d\n' 1
printf '%05d\n' 1
printf '%5d\n' 1
printf '%0d\n' 1