commit bash-20110401 snapshot

This commit is contained in:
Chet Ramey
2011-12-29 13:06:12 -05:00
parent c1854f2dd6
commit af32e54dd7
19 changed files with 1838 additions and 1271 deletions
+35
View File
@@ -11384,3 +11384,38 @@ lib/readline/signals.c
- _rl_signal_handler: call rl_resize_terminal if sig == SIGWINCH.
Should fix hang when sending multiple repeated SIGWINCH reported by
Henning Bekel <h.bekel@googlemail.com>
3/29
----
lib/sh/snprintf.c
- include math.h for any defines for isinf/isnan
- use code from gnulib documentation to implement isinf/isnan if they
are not defined
configure.in
- don't check for isinf or isnan; c99 says they're macros anyway
config.h.in
- remove defines for ISINF_IN_LIBC and ISNAN_IN_LIBC, no longer used
by snprintf.c
4/2
---
braces.c
- brace_gobbler: fix to understand double-quoted command subtitution,
since the shell understands unquoted comsubs. Fixes bug reported
by Michael Whitten <mfwitten@gmail.com>
lib/readline/display.c
- include <pc.h> on MDOS
- get and set screen size using DJGPP-specific calls on MSDOS
- move cursor up clear screen using DJGPP-specific calls
- don't call tputs on DJGPP; there is no good terminfo support
lib/readline/terminal.c
- include <pc.h> on MDOS
- get and set screen size using DJGPP-specific calls on MSDOS
- use DJGPP-specific initialization on MSDOS, zeroing all the
_rl_term_* variables
- don't call tputs on DJGPP; there is no good terminfo support
DJGPP support from Eli Zaretskii <eliz@gnu.org>
+35 -1
View File
@@ -11382,5 +11382,39 @@ lib/readline/signals.c
- rl_sigwinch_handler: don't immediately call rl_resize_terminal; just
leave _rl_caught_signal set for RL_CHECK_SIGNALS to handle
- _rl_signal_handler: call rl_resize_terminal if sig == SIGWINCH.
Should fix hang when sending multiple repeat SIGWINCH reported by
Should fix hang when sending multiple repeated SIGWINCH reported by
Henning Bekel <h.bekel@googlemail.com>
3/29
----
lib/sh/snprintf.c
- include math.h for any defines for isinf/isnan
- use code from gnulib documentation to implement isinf/isnan if they
are not defined
configure.in
- don't check for isinf or isnan; c99 says they're macros anyway
config.h.in
- remove defines for ISINF_IN_LIBC and ISNAN_IN_LIBC, no longer used
by snprintf.c
4/2
---
braces.c
- brace_gobbler: fix to understand double-quoted command subtitution,
since the shell understands unquoted comsubs. Fixes bug reported
by Michael Whitten <mfwitten@gmail.com>
lib/readline/display.c
- include <pc.h> on MDOS
- get and set screen size using DJGPP-specific calls on MSDOS
- move cursor up clear screen using DJGPP-specific calls
- don't call tputs on DJGPP; there is no good terminfo support
lib/readline/terminal.c
- get and set screen size using DJGPP-specific calls on MSDOS
- use DJGPP-specific initialization on MSDOS, zeroing all the
_rl_term_* variables
- don't call tputs on DJGPP; there is no good terminfo support
DJGPP support from Eli Zaretskii <eliz@gnu.org>
+1
View File
@@ -895,6 +895,7 @@ tests/heredoc.tests f
tests/heredoc.right f
tests/heredoc1.sub f
tests/heredoc2.sub f
tests/heredoc3.sub f
tests/herestr.tests f
tests/herestr.right f
tests/histexp.tests f
+1 -185
View File
@@ -1,5 +1,5 @@
@%:@! /bin/sh
@%:@ From configure.in for Bash 4.2, version 4.037.
@%:@ From configure.in for Bash 4.2, version 4.038.
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.63 for bash 4.2-maint.
@%:@
@@ -12949,190 +12949,6 @@ _ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for isinf" >&5
$as_echo_n "checking for isinf... " >&6; }
if test "${ac_cv_func_isinf+set}" = set; then
$as_echo_n "(cached) " >&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 isinf to an innocuous variant, in case <limits.h> declares isinf.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define isinf innocuous_isinf
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char isinf (); 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 isinf
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char isinf ();
/* 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_isinf || defined __stub___isinf
choke me
#endif
int
main ()
{
return isinf ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_func_isinf=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isinf=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_isinf" >&5
$as_echo "$ac_cv_func_isinf" >&6; }
if test "x$ac_cv_func_isinf" = x""yes; then
cat >>confdefs.h <<\_ACEOF
@%:@define HAVE_ISINF_IN_LIBC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for isnan" >&5
$as_echo_n "checking for isnan... " >&6; }
if test "${ac_cv_func_isnan+set}" = set; then
$as_echo_n "(cached) " >&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 GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
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
#endif
int
main ()
{
return isnan ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_func_isnan=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isnan=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_isnan" >&5
$as_echo "$ac_cv_func_isnan" >&6; }
if test "x$ac_cv_func_isnan" = x""yes; then
cat >>confdefs.h <<\_ACEOF
@%:@define HAVE_ISNAN_IN_LIBC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for mkfifo" >&5
$as_echo_n "checking for mkfifo... " >&6; }
+11 -11
View File
@@ -15,25 +15,25 @@
'configure.in'
],
{
'AM_PROG_F77_C_O' => 1,
'_LT_AC_TAGCONFIG' => 1,
'm4_pattern_forbid' => 1,
'AM_PROG_F77_C_O' => 1,
'AC_INIT' => 1,
'AC_CANONICAL_TARGET' => 1,
'm4_pattern_forbid' => 1,
'_AM_COND_IF' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_CANONICAL_TARGET' => 1,
'AC_SUBST' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_FC_SRCEXT' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_PROG_LIBTOOL' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
'LT_SUPPORTED_TAG' => 1,
'AC_CONFIG_LINKS' => 1,
'm4_sinclude' => 1,
'LT_SUPPORTED_TAG' => 1,
'AM_MAINTAINER_MODE' => 1,
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
'_m4_warn' => 1,
@@ -49,13 +49,13 @@
'AC_CANONICAL_BUILD' => 1,
'AC_FC_FREEFORM' => 1,
'AH_OUTPUT' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AM_PROG_CC_C_O' => 1,
'm4_pattern_allow' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'sinclude' => 1,
'AM_CONDITIONAL' => 1,
'm4_pattern_allow' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'm4_include' => 1,
+824 -828
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -535,6 +535,11 @@ brace_gobbler (text, tlen, indx, satisfy)
{
if (c == quoted)
quoted = 0;
#if defined (SHELL)
/* The shell allows quoted command substitutions */
if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/
goto comsub;
#endif
ADVANCE_CHAR (text, tlen, i);
continue;
}
@@ -550,6 +555,7 @@ brace_gobbler (text, tlen, indx, satisfy)
/* Pass new-style command and process substitutions through unchanged. */
if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */
{
comsub:
si = i + 2;
t = extract_command_subst (text, &si, 0);
i = si;
+696
View File
@@ -0,0 +1,696 @@
/* braces.c -- code for doing word expansion in curly braces. */
/* Copyright (C) 1987-2009 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/>.
*/
/* Stuff in curly braces gets expanded before all other shell expansions. */
#include "config.h"
#if defined (BRACE_EXPANSION)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include "bashansi.h"
#if defined (SHELL)
# include "shell.h"
#endif /* SHELL */
#include "general.h"
#include "shmbutil.h"
#include "chartypes.h"
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
#define BRACE_SEQ_SPECIFIER ".."
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
/* Basic idea:
Segregate the text into 3 sections: preamble (stuff before an open brace),
postamble (stuff after the matching close brace) and amble (stuff after
preamble, and before postamble). Expand amble, and then tack on the
expansions to preamble. Expand postamble, and tack on the expansions to
the result so far.
*/
/* The character which is used to separate arguments. */
static const int brace_arg_separator = ',';
#if defined (__P)
static int brace_gobbler __P((char *, size_t, int *, int));
static char **expand_amble __P((char *, size_t, int));
static char **expand_seqterm __P((char *, size_t));
static char **mkseq __P((intmax_t, intmax_t, int, int, int));
static char **array_concat __P((char **, char **));
#else
static int brace_gobbler ();
static char **expand_amble ();
static char **expand_seqterm ();
static char **mkseq();
static char **array_concat ();
#endif
#if 0
static void
dump_result (a)
char **a;
{
int i;
for (i = 0; a[i]; i++)
printf ("dump_result: a[%d] = -%s-\n", i, a[i]);
}
#endif
/* Return an array of strings; the brace expansion of TEXT. */
char **
brace_expand (text)
char *text;
{
register int start;
size_t tlen;
char *preamble, *postamble, *amble;
size_t alen;
char **tack, **result;
int i, j, c, c1;
DECLARE_MBSTATE;
/* Find the text of the preamble. */
tlen = strlen (text);
i = 0;
#if defined (CSH_BRACE_COMPAT)
c = brace_gobbler (text, tlen, &i, '{'); /* } */
#else
/* Make sure that when we exit this loop, c == 0 or text[i] begins a
valid brace expansion sequence. */
do
{
c = brace_gobbler (text, tlen, &i, '{'); /* } */
c1 = c;
/* Verify that c begins a valid brace expansion word. If it doesn't, we
go on. Loop stops when there are no more open braces in the word. */
if (c)
{
start = j = i + 1; /* { */
c = brace_gobbler (text, tlen, &j, '}');
if (c == 0) /* it's not */
{
i++;
c = c1;
continue;
}
else /* it is */
{
c = c1;
break;
}
}
else
break;
}
while (c);
#endif /* !CSH_BRACE_COMPAT */
preamble = (char *)xmalloc (i + 1);
strncpy (preamble, text, i);
preamble[i] = '\0';
result = (char **)xmalloc (2 * sizeof (char *));
result[0] = preamble;
result[1] = (char *)NULL;
/* Special case. If we never found an exciting character, then
the preamble is all of the text, so just return that. */
if (c != '{')
return (result);
/* Find the amble. This is the stuff inside this set of braces. */
start = ++i;
c = brace_gobbler (text, tlen, &i, '}');
/* What if there isn't a matching close brace? */
if (c == 0)
{
#if defined (NOTDEF)
/* Well, if we found an unquoted BRACE_ARG_SEPARATOR between START
and I, then this should be an error. Otherwise, it isn't. */
j = start;
while (j < i)
{
if (text[j] == '\\')
{
j++;
ADVANCE_CHAR (text, tlen, j);
continue;
}
if (text[j] == brace_arg_separator)
{ /* { */
strvec_dispose (result);
report_error ("no closing `%c' in %s", '}', text);
throw_to_top_level ();
}
ADVANCE_CHAR (text, tlen, j);
}
#endif
free (preamble); /* Same as result[0]; see initialization. */
result[0] = savestring (text);
return (result);
}
#if defined (SHELL)
amble = substring (text, start, i);
alen = i - start;
#else
amble = (char *)xmalloc (1 + (i - start));
strncpy (amble, &text[start], (i - start));
alen = i - start;
amble[alen] = '\0';
#endif
#if defined (SHELL)
INITIALIZE_MBSTATE;
/* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
just return without doing any expansion. */
j = 0;
while (amble[j])
{
if (amble[j] == '\\')
{
j++;
ADVANCE_CHAR (amble, alen, j);
continue;
}
if (amble[j] == brace_arg_separator)
break;
ADVANCE_CHAR (amble, alen, j);
}
if (amble[j] == 0)
{
tack = expand_seqterm (amble, alen);
if (tack)
goto add_tack;
else
{
free (amble);
free (preamble);
result[0] = savestring (text);
return (result);
}
}
#endif /* SHELL */
tack = expand_amble (amble, alen, 0);
add_tack:
result = array_concat (result, tack);
free (amble);
strvec_dispose (tack);
postamble = text + i + 1;
tack = brace_expand (postamble);
result = array_concat (result, tack);
strvec_dispose (tack);
return (result);
}
/* Expand the text found inside of braces. We simply try to split the
text at BRACE_ARG_SEPARATORs into separate strings. We then brace
expand each slot which needs it, until there are no more slots which
need it. */
static char **
expand_amble (text, tlen, flags)
char *text;
size_t tlen;
int flags;
{
char **result, **partial;
char *tem;
int start, i, c;
DECLARE_MBSTATE;
result = (char **)NULL;
start = i = 0;
c = 1;
while (c)
{
c = brace_gobbler (text, tlen, &i, brace_arg_separator);
#if defined (SHELL)
tem = substring (text, start, i);
#else
tem = (char *)xmalloc (1 + (i - start));
strncpy (tem, &text[start], (i - start));
tem[i- start] = '\0';
#endif
partial = brace_expand (tem);
if (!result)
result = partial;
else
{
register int lr, lp, j;
lr = strvec_len (result);
lp = strvec_len (partial);
result = strvec_resize (result, lp + lr + 1);
for (j = 0; j < lp; j++)
result[lr + j] = partial[j];
result[lr + j] = (char *)NULL;
free (partial);
}
free (tem);
ADVANCE_CHAR (text, tlen, i);
start = i;
}
return (result);
}
#define ST_BAD 0
#define ST_INT 1
#define ST_CHAR 2
#define ST_ZINT 3
static char **
mkseq (start, end, incr, type, width)
intmax_t start, end;
int incr, type, width;
{
intmax_t n;
int i;
char **result, *t;
i = abs (end - start) + 1;
result = strvec_create (i + 1);
if (incr == 0)
incr = 1;
if (start > end && incr > 0)
incr = -incr;
else if (start < end && incr < 0)
incr = -incr;
/* Make sure we go through the loop at least once, so {3..3} prints `3' */
i = 0;
n = start;
do
{
#if defined (SHELL)
QUIT; /* XXX - memory leak here */
#endif
if (type == ST_INT)
result[i++] = itos (n);
else if (type == ST_ZINT)
{
int len, arg;
arg = n;
len = asprintf (&t, "%0*d", width, arg);
result[i++] = t;
}
else
{
t = (char *)xmalloc (2);
t[0] = n;
t[1] = '\0';
result[i++] = t;
}
n += incr;
if ((incr < 0 && n < end) || (incr > 0 && n > end))
break;
}
while (1);
result[i] = (char *)0;
return (result);
}
static char **
expand_seqterm (text, tlen)
char *text;
size_t tlen;
{
char *t, *lhs, *rhs;
int i, lhs_t, rhs_t, incr, lhs_l, rhs_l, width;
intmax_t lhs_v, rhs_v;
intmax_t tl, tr;
char **result, *ep, *oep;
t = strstr (text, BRACE_SEQ_SPECIFIER);
if (t == 0)
return ((char **)NULL);
lhs_l = t - text; /* index of start of BRACE_SEQ_SPECIFIER */
lhs = substring (text, 0, lhs_l);
rhs = substring (text, lhs_l + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen);
if (lhs[0] == 0 || rhs[0] == 0)
{
free (lhs);
free (rhs);
return ((char **)NULL);
}
/* Now figure out whether LHS and RHS are integers or letters. Both
sides have to match. */
lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);
/* Decide on rhs and whether or not it looks like the user specified
an increment */
ep = 0;
if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))
{
rhs_t = ST_INT;
tr = strtoimax (rhs, &ep, 10);
if (ep && *ep != 0 && *ep != '.')
rhs_t = ST_BAD; /* invalid */
}
else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.'))
{
rhs_t = ST_CHAR;
ep = rhs + 1;
}
else
{
rhs_t = ST_BAD;
ep = 0;
}
incr = 1;
if (rhs_t != ST_BAD)
{
oep = ep;
if (ep && *ep == '.' && ep[1] == '.' && ep[2])
incr = strtoimax (ep + 2, &ep, 10);
if (*ep != 0)
rhs_t = ST_BAD; /* invalid incr */
tlen -= ep - oep;
}
if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
{
free (lhs);
free (rhs);
return ((char **)NULL);
}
/* OK, we have something. It's either a sequence of integers, ascending
or descending, or a sequence or letters, ditto. Generate the sequence,
put it into a string vector, and return it. */
if (lhs_t == ST_CHAR)
{
lhs_v = (unsigned char)lhs[0];
rhs_v = (unsigned char)rhs[0];
width = 1;
}
else
{
lhs_v = tl; /* integer truncation */
rhs_v = tr;
/* Decide whether or not the terms need zero-padding */
rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1;
width = 0;
if (lhs_l > 1 && lhs[0] == '0')
width = lhs_l, lhs_t = ST_ZINT;
if (lhs_l > 2 && lhs[0] == '-' && lhs[1] == '0')
width = lhs_l, lhs_t = ST_ZINT;
if (rhs_l > 1 && rhs[0] == '0' && width < rhs_l)
width = rhs_l, lhs_t = ST_ZINT;
if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l)
width = rhs_l, lhs_t = ST_ZINT;
if (width < lhs_l && lhs_t == ST_ZINT)
width = lhs_l;
if (width < rhs_l && lhs_t == ST_ZINT)
width = rhs_l;
}
result = mkseq (lhs_v, rhs_v, incr, lhs_t, width);
free (lhs);
free (rhs);
return (result);
}
/* Start at INDEX, and skip characters in TEXT. Set INDEX to the
index of the character matching SATISFY. This understands about
quoting. Return the character that caused us to stop searching;
this is either the same as SATISFY, or 0. */
/* If SATISFY is `}', we are looking for a brace expression, so we
should enforce the rules that govern valid brace expansions:
1) to count as an arg separator, a comma or `..' has to be outside
an inner set of braces.
*/
static int
brace_gobbler (text, tlen, indx, satisfy)
char *text;
size_t tlen;
int *indx;
int satisfy;
{
register int i, c, quoted, level, commas, pass_next;
#if defined (SHELL)
int si;
char *t;
#endif
DECLARE_MBSTATE;
level = quoted = pass_next = 0;
#if defined (CSH_BRACE_COMPAT)
commas = 1;
#else
commas = (satisfy == '}') ? 0 : 1;
#endif
i = *indx;
while (c = text[i])
{
if (pass_next)
{
pass_next = 0;
ADVANCE_CHAR (text, tlen, i);
continue;
}
/* A backslash escapes the next character. This allows backslash to
escape the quote character in a double-quoted string. */
if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
{
pass_next = 1;
i++;
continue;
}
#if defined (SHELL)
/* If compiling for the shell, treat ${...} like \{...} */
if (c == '$' && text[i+1] == '{' && quoted != '\'') /* } */
{
pass_next = 1;
i++;
if (quoted == 0)
level++;
continue;
}
#endif
if (quoted)
{
if (c == quoted)
quoted = 0;
#if defined (SHELL)
if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/
goto comsub;
#endif
ADVANCE_CHAR (text, tlen, i);
continue;
}
if (c == '"' || c == '\'' || c == '`')
{
quoted = c;
i++;
continue;
}
#if defined (SHELL)
/* Pass new-style command and process substitutions through unchanged. */
if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */
{
comsub:
si = i + 2;
t = extract_command_subst (text, &si, 0);
i = si;
free (t);
i++;
continue;
}
#endif
if (c == satisfy && level == 0 && quoted == 0 && commas > 0)
{
/* We ignore an open brace surrounded by whitespace, and also
an open brace followed immediately by a close brace preceded
by whitespace. */
if (c == '{' &&
((!i || brace_whitespace (text[i - 1])) &&
(brace_whitespace (text[i + 1]) || text[i + 1] == '}')))
{
i++;
continue;
}
break;
}
if (c == '{')
level++;
else if (c == '}' && level)
level--;
#if !defined (CSH_BRACE_COMPAT)
else if (satisfy == '}' && c == brace_arg_separator && level == 0)
commas++;
else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) &&
text[i+2] != satisfy && level == 0)
commas++;
#endif
ADVANCE_CHAR (text, tlen, i);
}
*indx = i;
return (c);
}
/* Return a new array of strings which is the result of appending each
string in ARR2 to each string in ARR1. The resultant array is
len (arr1) * len (arr2) long. For convenience, ARR1 (and its contents)
are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2
is returned. */
static char **
array_concat (arr1, arr2)
char **arr1, **arr2;
{
register int i, j, len, len1, len2;
register char **result;
if (arr1 == 0)
return (strvec_copy (arr2));
if (arr2 == 0)
return (strvec_copy (arr1));
len1 = strvec_len (arr1);
len2 = strvec_len (arr2);
result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
len = 0;
for (i = 0; i < len1; i++)
{
int strlen_1 = strlen (arr1[i]);
for (j = 0; j < len2; j++)
{
result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
strcpy (result[len], arr1[i]);
strcpy (result[len] + strlen_1, arr2[j]);
len++;
}
free (arr1[i]);
}
free (arr1);
result[len] = (char *)NULL;
return (result);
}
#if defined (TEST)
#include <stdio.h>
fatal_error (format, arg1, arg2)
char *format, *arg1, *arg2;
{
report_error (format, arg1, arg2);
exit (1);
}
report_error (format, arg1, arg2)
char *format, *arg1, *arg2;
{
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
main ()
{
char example[256];
for (;;)
{
char **result;
int i;
fprintf (stderr, "brace_expand> ");
if ((!fgets (example, 256, stdin)) ||
(strncmp (example, "quit", 4) == 0))
break;
if (strlen (example))
example[strlen (example) - 1] = '\0';
result = brace_expand (example);
for (i = 0; result[i]; i++)
printf ("%s\n", result[i]);
free_array (result);
}
}
/*
* Local variables:
* compile-command: "gcc -g -Bstatic -DTEST -o brace_expand braces.c general.o"
* end:
*/
#endif /* TEST */
#endif /* BRACE_EXPANSION */
-6
View File
@@ -637,12 +637,6 @@
/* Define if you have the isgraph function. */
#undef HAVE_ISGRAPH
/* 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
+1 -185
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 4.2, version 4.037.
# From configure.in for Bash 4.2, version 4.038.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63 for bash 4.2-maint.
#
@@ -12949,190 +12949,6 @@ _ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for isinf" >&5
$as_echo_n "checking for isinf... " >&6; }
if test "${ac_cv_func_isinf+set}" = set; then
$as_echo_n "(cached) " >&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 isinf to an innocuous variant, in case <limits.h> declares isinf.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define isinf innocuous_isinf
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char isinf (); 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 isinf
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char isinf ();
/* 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_isinf || defined __stub___isinf
choke me
#endif
int
main ()
{
return isinf ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_func_isinf=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isinf=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_isinf" >&5
$as_echo "$ac_cv_func_isinf" >&6; }
if test "x$ac_cv_func_isinf" = x""yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ISINF_IN_LIBC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for isnan" >&5
$as_echo_n "checking for isnan... " >&6; }
if test "${ac_cv_func_isnan+set}" = set; then
$as_echo_n "(cached) " >&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 GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
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
#endif
int
main ()
{
return isnan ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then
ac_cv_func_isnan=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_isnan=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_isnan" >&5
$as_echo "$ac_cv_func_isnan" >&6; }
if test "x$ac_cv_func_isnan" = x""yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ISNAN_IN_LIBC 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for mkfifo" >&5
$as_echo_n "checking for mkfifo... " >&6; }
+1 -3
View File
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 4.2, version 4.037])dnl
AC_REVISION([for Bash 4.2, version 4.038])dnl
define(bashvers, 4.2)
define(relstatus, maint)
@@ -713,8 +713,6 @@ AC_TYPE_SIGNAL
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))
+23 -2
View File
@@ -41,6 +41,10 @@
#include <stdio.h>
#ifdef __MSDOS__
# include <pc.h>
#endif
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
@@ -2057,9 +2061,18 @@ _rl_move_vert (to)
}
else
{ /* delta < 0 */
#ifdef __DJGPP__
int row, col;
fflush (rl_outstream);
ScreenGetCursor (&row, &col);
ScreenSetCursor (row + delta, col);
i = -delta;
#else
if (_rl_term_up && *_rl_term_up)
for (i = 0; i < -delta; i++)
tputs (_rl_term_up, 1, _rl_output_character_function);
#endif /* !__DJGPP__ */
}
_rl_last_v_pos = to; /* Now TO is here */
@@ -2342,10 +2355,13 @@ void
_rl_clear_to_eol (count)
int count;
{
#ifndef __MSDOS__
if (_rl_term_clreol)
tputs (_rl_term_clreol, 1, _rl_output_character_function);
else if (count)
space_to_eol (count);
else
#endif
if (count)
space_to_eol (count);
}
/* Clear to the end of the line using spaces. COUNT is the minimum
@@ -2365,10 +2381,15 @@ space_to_eol (count)
void
_rl_clear_screen ()
{
#ifndef __DJGPP__
if (_rl_term_clrpag)
tputs (_rl_term_clrpag, 1, _rl_output_character_function);
else
rl_crlf ();
#else
ScreenClear ();
ScreenSetCursor (0, 0);
#endif /* __DJGPP__ */
}
/* Insert COUNT characters from STRING to the output stream at column COL. */
+28 -4
View File
@@ -176,7 +176,8 @@ int _rl_vis_botlin = 0;
static int last_lmargin;
/* A buffer for `modeline' messages. */
static char msg_buf[128];
static char *msg_buf = 0;
static int msg_bufsiz = 0;
/* Non-zero forces the redisplay even if we thought it was unnecessary. */
static int forced_display;
@@ -2136,6 +2137,9 @@ rl_message (va_alist)
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (HAVE_VSNPRINTF)
int bneed;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
@@ -2144,11 +2148,28 @@ rl_message (va_alist)
format = va_arg (args, char *);
#endif
if (msg_buf == 0)
msg_buf = xmalloc (msg_bufsiz = 128);
#if defined (HAVE_VSNPRINTF)
vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);
bneed = vsnprintf (msg_buf, msg_bufsiz - 1, format, args);
if (bneed >= msg_bufsiz - 1)
{
msg_bufsiz = bneed + 1;
msg_buf = xrealloc (msg_buf, msg_bufsiz);
va_end (args);
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
vsnprintf (msg_buf, msg_bufsiz - 1, format, args);
}
#else
vsprintf (msg_buf, format, args);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */
#endif
va_end (args);
@@ -2173,8 +2194,11 @@ int
rl_message (format, arg1, arg2)
char *format;
{
if (msg_buf == 0)
msg_buf = xmalloc (msg_bufsiz = 128);
sprintf (msg_buf, format, arg1, arg2);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
msg_buf[msg_bufsiz - 1] = '\0'; /* overflow? */
rl_display_prompt = msg_buf;
if (saved_local_prompt == 0)
+41 -4
View File
@@ -55,6 +55,10 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
#ifdef __MSDOS__
# include <pc.h>
#endif
#include "rltty.h"
#include "tcap.h"
@@ -91,8 +95,10 @@ int rl_prefer_env_winsize = 0;
/* */
/* **************************************************************** */
#ifndef __MSDOS__
static char *term_buffer = (char *)NULL;
static char *term_string_buffer = (char *)NULL;
#endif
static int tcap_initialized;
@@ -264,7 +270,10 @@ _rl_get_screen_size (tty, ignore_env)
if (_rl_screenwidth <= 0)
_rl_screenwidth = wc;
#if !defined (__DJGPP__)
#if defined (__DJGPP__)
if (_rl_screenwidth <= 0)
_rl_screenwidth = ScreenCols ();
#else
if (_rl_screenwidth <= 0 && term_string_buffer)
_rl_screenwidth = tgetnum ("co");
#endif
@@ -280,7 +289,10 @@ _rl_get_screen_size (tty, ignore_env)
if (_rl_screenheight <= 0)
_rl_screenheight = wr;
#if !defined (__DJGPP__)
#if defined (__DJGPP__)
if (_rl_screenheight <= 0)
_rl_screenheight = ScreenRows ();
#else
if (_rl_screenheight <= 0 && term_string_buffer)
_rl_screenheight = tgetnum ("li");
#endif
@@ -296,8 +308,7 @@ _rl_get_screen_size (tty, ignore_env)
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
if (ignore_env == 0)
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
@@ -439,6 +450,23 @@ _rl_init_terminal_io (terminal_name)
if (term == 0)
term = "dumb";
#ifdef __MSDOS__
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
_rl_term_cr = "\r";
_rl_term_clreol = _rl_term_clrpag = _rl_term_backspace = (char *)NULL;
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
#endif
_rl_get_screen_size (tty, 0);
#else /* !__MSDOS__ */
/* I've separated this out for later work on not calling tgetent at all
if the calling application has supplied a custom redisplay function,
(and possibly if the application has supplied a custom input function). */
@@ -538,6 +566,7 @@ _rl_init_terminal_io (terminal_name)
term_has_meta = tgetflag ("km") != 0;
if (term_has_meta == 0)
_rl_term_mm = _rl_term_mo = (char *)NULL;
#endif /* !__MSDOS__ */
/* Attempt to find and bind the arrow keys. Do not override already
bound keys in an overzealous attempt, however. */
@@ -635,10 +664,12 @@ _rl_backspace (count)
{
register int i;
#ifndef __MSDOS__
if (_rl_term_backspace)
for (i = 0; i < count; i++)
tputs (_rl_term_backspace, 1, _rl_output_character_function);
else
#endif
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
@@ -670,7 +701,11 @@ rl_ding ()
case VISIBLE_BELL:
if (_rl_visible_bell)
{
#ifdef __DJGPP__
ScreenVisualBell ();
#else
tputs (_rl_visible_bell, 1, _rl_output_character_function);
#endif
break;
}
/* FALLTHROUGH */
@@ -725,6 +760,7 @@ void
_rl_set_cursor (im, force)
int im, force;
{
#ifndef __MSDOS__
if (_rl_term_ve && _rl_term_vs)
{
if (force || im != rl_insert_mode)
@@ -735,4 +771,5 @@ _rl_set_cursor (im, force)
tputs (_rl_term_ve, 1, _rl_output_character_function);
}
}
#endif
}
+1 -3
View File
@@ -296,8 +296,7 @@ _rl_get_screen_size (tty, ignore_env)
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
if (ignore_env == 0)
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
_rl_screenwidth--;
@@ -367,7 +366,6 @@ rl_resize_terminal ()
}
}
struct _tc_string {
const char * const tc_var;
char **tc_value;
+31 -38
View File
@@ -303,11 +303,30 @@ 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));
#if defined (HAVE_LONG_DOUBLE)
# define LONGDOUBLE long double
#else
# define LONGDOUBLE double
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int isnan __P((double));
#ifndef isnan
static inline int isnan_f (float x) { return x != x; }
static inline int isnan_d (double x) { return x != x; }
static inline int isnan_ld (LONGDOUBLE x) { return x != x; }
# define isnan(x) \
(sizeof (x) == sizeof (LONGDOUBLE) ? isnan_ld (x) \
: sizeof (x) == sizeof (double) ? isnan_d (x) \
: isnan_f (x))
#endif
#ifndef isinf
static inline int isinf_f (float x) { return !isnan (x) && isnan (x - x); }
static inline int isinf_d (double x) { return !isnan (x) && isnan (x - x); }
static inline int isinf_ld (LONGDOUBLE x) { return !isnan (x) && isnan (x - x); }
# define isinf(x) \
(sizeof (x) == sizeof (LONGDOUBLE) ? isinf_ld (x) \
: sizeof (x) == sizeof (double) ? isinf_d (x) \
: isinf_f (x))
#endif
#ifdef DRIVER
@@ -431,9 +450,9 @@ static void xfree __P((void *));
if (lv) \
{ \
if (lv->decimal_point && lv->decimal_point[0]) \
(d) = lv->decimal_point[0]; \
(d) = lv->decimal_point[0]; \
if (lv->thousands_sep && lv->thousands_sep[0]) \
(t) = lv->thousands_sep[0]; \
(t) = lv->thousands_sep[0]; \
(g) = lv->grouping ? lv->grouping : ""; \
if (*(g) == '\0' || *(g) == CHAR_MAX || (t) == -1) (g) = 0; \
} \
@@ -698,7 +717,7 @@ number(p, d, base)
{
GETLOCALEDATA(decpoint, thoussep, grouping);
if (grouping && (t = groupnum (tmp)))
tmp = t;
tmp = t;
}
p->width -= strlen(tmp);
@@ -768,7 +787,7 @@ lnumber(p, d, base)
{
GETLOCALEDATA(decpoint, thoussep, grouping);
if (grouping && (t = groupnum (tmp)))
tmp = t;
tmp = t;
}
p->width -= strlen(tmp);
@@ -875,11 +894,11 @@ wstrings(p, tmp)
{
len = wcsrtombs (NULL, &ws, 0, &mbs);
if (len != (size_t)-1)
{
{
memset (&mbs, '\0', sizeof (mbstate_t));
os = (char *)xmalloc (len + 1);
(void)wcsrtombs (os, &ws, len + 1, &mbs);
}
}
}
if (len == (size_t)-1)
{
@@ -919,32 +938,6 @@ wchars (p, wc)
#ifdef FLOATING_POINT
#ifndef HAVE_ISINF_IN_LIBC
/* Half-assed versions, since we don't want to link with libm. */
static int
isinf(d)
double d;
{
#ifdef DBL_MAX
if (d < DBL_MIN)
return -1;
else if (d > DBL_MAX)
return 1;
else
#endif
return 0;
}
#endif
#ifndef HAVE_ISNAN_IN_LIBC
static int
isnan(d)
double d;
{
return 0;
}
#endif
/* Check for [+-]infinity and NaN. If MODE == 1, we check for Infinity, else
(mode == 2) we check for NaN. This does the necessary printing. Returns
1 if Inf or Nan, 0 if not. */
@@ -1002,7 +995,7 @@ floating(p, d)
{
/* smash the trailing zeros unless altform */
for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
tmp2[i] = '\0';
tmp2[i] = '\0';
if (tmp2[0] == '\0')
p->precision = 0;
}
@@ -1163,7 +1156,7 @@ groupnum (s)
else if (*g == CHAR_MAX)
{
do
*--re = *--se;
*--re = *--se;
while (se > s);
break;
}
+27 -1
View File
@@ -59,7 +59,33 @@ qux
bar
qux
abc def geh
./heredoc3.sub: line 6: warning: here-document at line 4 delimited by end-of-file (wanted `EOF')
= here is the text =
./heredoc3.sub: line 12: warning: here-document at line 10 delimited by end-of-file (wanted `EOF')
this paren ) is not a problem
./heredoc3.sub: line 18: warning: here-document at line 16 delimited by end-of-file (wanted `EOF')
these balanced parens ( ) are not a problem
./heredoc3.sub: line 24: warning: here-document at line 22 delimited by end-of-file (wanted `EOF')
quoted balanced parens \( ) are not a problem either
more text in a subshell
some more text in a different subshell
end
hello
hello
ENDEND
end ENDEND
hello
end hello
x star x
end x*x
helloEND
end helloEND
hello
\END
end hello<NL>\END
./heredoc3.sub: line 74: warning: here-document at line 72 delimited by end-of-file (wanted `EOF')
./heredoc3.sub: line 75: syntax error: unexpected end of file
comsub here-string
./heredoc.tests: line 103: warning: here-document at line 101 delimited by end-of-file (wanted `EOF')
./heredoc.tests: line 105: warning: here-document at line 103 delimited by end-of-file (wanted `EOF')
hi
there
+2
View File
@@ -91,6 +91,8 @@ ${THIS_SH} ./heredoc1.sub
# test heredocs in command substitutions
${THIS_SH} ./heredoc2.sub
${THIS_SH} ./heredoc3.sub
echo $(
cat <<< "comsub here-string"
)
+74
View File
@@ -0,0 +1,74 @@
text=$(cat <<EOF
here is the text
EOF)
echo = $text =
unbalanced=$(cat <<EOF
this paren ) is not a problem
EOF)
echo $unbalanced
balanced=$(cat <<EOF
these balanced parens ( ) are not a problem
EOF)
echo $balanced
balanced=$(cat <<EOF
quoted balanced parens \( ) are not a problem either
EOF)
echo $balanced
(cat <<EOF
more text in a subshell
EOF
)
(cat <<EOF; )
some more text in a different subshell
EOF
echo end
# semi-weird examples posted by Wayne Pollack to austin-group mailing list
cat <<-' END'
hello
END
cat <<END
hello
END\
END
END
echo end ENDEND
cat <<' END '
hello
END
echo end hello
cat <<x*x & touch 'x*x'
x star x
x*x
echo end 'x*x'
rm 'x*x'
cat <<END
hello\
END
END
echo end helloEND
cat <<END
hello
\END
END
echo end 'hello<NL>\END'
# this has to be last -- results in a syntax error
# doesn't currently parse because EOF is not on a line by itself -- should it?
(cat <<EOF
still more text in a subshell
EOF)