commit bash-20071025 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:14:40 -05:00
parent cc12da027f
commit 97c2aab24b
13 changed files with 188 additions and 37 deletions
+37
View File
@@ -14978,3 +14978,40 @@ expr.c
- in readtok(), don't reset lasttp if we've consumed the whitespace
at the end of the expression string. Fixes error message problem
reported by <anmaster@tele2.se>
11/1
----
builtins/printf.def
- change asciicode() to return intmax_t; add multibyte character
support instead of assuming ASCII (depending on behavior of system
multibyte support functions). Fixes bug reported by Rich
Felker <dalias@aerifal.cx>
11/5
----
execute_cmd.c
- if redirections attached to a compound command fail, make sure to
set last_command_exit_value when returning EXECUTION_FAILURE.
Fixes bug reported separately by Andreas Schwab <schwab@suse.de>
and Paul Eggert <eggert@cs.ucla.edu>
11/9
----
builtins/read.def
- make sure the return value from get_word_from_string is freed if
non-null. Fixes bug reported by Lars Ellenberg
<lars.ellenberg@linbit.com>
11/10
-----
variables.c
- use getpid() as value of seeded_subshell to avoid problems with
random number generator not getting re-seeded correctly when
subshells are created. Fix from Tomas Janousek <tjanouse@redhat.com>
lib/readline/display.c
- in update_line(), when outputting characters at the end of the line,
e.g., when displaying the prompt string, adjust _rl_last_c_pos by
wrap_offset if the text we're drawing begins before the last
invisible character in the line. Similar to fix from 5/24. Fixes
bug reported by Miroslav Lichvar <mlichvar@redhat.com>
+50
View File
@@ -14957,3 +14957,53 @@ builtins/type.def
- change exit status of `type' to not successful if any of the
requested commands are not found. Reported by Stephane Chazleas
<stephane_chazelas@yahoo.fr>
pcomplete.c
- change command_line_to_word_list to use rl_completer_word_break_characters
instead of the shell metacharacters to split words, so programmable
completion does the same thing readline does internally. Reported
by Vasily Tarasov <vtaras@sw.ru>
10/16
-----
bashline.c
- When completing a command name beginnig with a tilde and containing
escaped specical characters, dequote the filename before prefixing
it to the matches, so the escapes are not quoted again. Reported
by neil@s-z.org
10/17
-----
expr.c
- in readtok(), don't reset lasttp if we've consumed the whitespace
at the end of the expression string. Fixes error message problem
reported by <anmaster@tele2.se>
11/1
----
builtins/printf.def
- change asciicode() to return intmax_t; add multibyte character
support instead of assuming ASCII (depending on behavior of system
multibyte support functions). Fixes bug reported by Rich
Felker <dalias@aerifal.cx>
11/9
----
builtins/read.def
- make sure the return value from get_word_from_string is freed if
non-null. Fixes bug reported by Lars Ellenberg
<lars.ellenberg@linbit.com>
11/10
-----
variables.c
- use getpid() as value of seeded_subshell to avoid problems with
random number generator not getting re-seeded correctly when
subshells are created. Fix from Tomas Janousek <tjanouse@redhat.com>
lib/readline/display.c
- in update_line(), when outputting characters at the end of the line,
e.g., when displaying the prompt string, adjust _rl_last_c_pos by
wrap_offset if the text we're drawing begins before the last
invisible character in the line. Similar to fix from 5/24. Fixes
bug reported by Miroslav Lichvar <mlichvar@redhat.com>
+25 -4
View File
@@ -66,6 +66,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "shmbutil.h"
#include "stdc.h"
#include "bashgetopt.h"
#include "common.h"
@@ -190,7 +191,7 @@ typedef double floatmax_t;
#endif
static floatmax_t getfloatmax __P((void));
static int asciicode __P((void));
static intmax_t asciicode __P((void));
static WORD_LIST *garglist;
static int retval;
@@ -1018,12 +1019,32 @@ getfloatmax ()
}
/* NO check is needed for garglist here. */
static int
static intmax_t
asciicode ()
{
register int ch;
register intmax_t ch;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t mblength, slen;
#endif
DECLARE_MBSTATE;
#if defined (HANDLE_MULTIBYTE)
slen = strlen (garglist->word->word+1);
mblength = mbrlen (garglist->word->word+1, slen, NULL);
#if 0
if (mblength > 1)
#else
if (1)
#endif
{
mblength = mbrtowc (&wc, garglist->word->word+1, slen, NULL);
ch = wc; /* XXX */
}
else
#endif
ch = garglist->word->word[1];
ch = garglist->word->word[1];
garglist = garglist->next;
return (ch);
}
+26 -4
View File
@@ -66,6 +66,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "shmbutil.h"
#include "stdc.h"
#include "bashgetopt.h"
#include "common.h"
@@ -148,6 +149,8 @@ extern int errno;
vbsize = 0; \
vbuf = 0; \
} \
else if (vbuf) \
vbuf[0] = 0; \
fflush (stdout); \
if (ferror (stdout)) \
{ \
@@ -188,7 +191,7 @@ typedef double floatmax_t;
#endif
static floatmax_t getfloatmax __P((void));
static int asciicode __P((void));
static intmax_t asciicode __P((void));
static WORD_LIST *garglist;
static int retval;
@@ -1016,12 +1019,31 @@ getfloatmax ()
}
/* NO check is needed for garglist here. */
static int
static intmax_t
asciicode ()
{
register int ch;
register intmax_t ch;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t mblength, slen;
#endif
DECLARE_MBSTATE;
#if defined (HANDLE_MULTIBYTE)
slen = strlen (garglist->word->word+1);
mblength = mbrlen (garglist->word->word+1, slen, NULL);
#if 0
if (mblength > 1)
#else
if (1)
{
mblength = mbrtowc (&wc, garglist->word->word+1, slen, NULL);
ch = wc; /* XXX */
}
else
#endif
ch = garglist->word->word[1];
ch = garglist->word->word[1];
garglist = garglist->next;
return (ch);
}
+5 -2
View File
@@ -137,7 +137,7 @@ read_builtin (list)
intmax_t intval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1, *ps2;
char *e, *t, *t1, *ps2, *tofree;
struct stat tsb;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
@@ -692,12 +692,13 @@ add_char:
#else
/* Check whether or not the number of fields is exactly the same as the
number of variables. */
tofree = NULL;
if (*input_string)
{
t1 = input_string;
t = get_word_from_string (&input_string, ifs_chars, &e);
if (*input_string == 0)
input_string = t;
tofree = input_string = t;
else
input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
}
@@ -712,6 +713,8 @@ add_char:
else
var = bind_read_variable (list->word->word, input_string);
stupidly_hack_special_variables (list->word->word);
FREE (tofree);
if (var)
VUNSETATTR (var, att_invisible);
xfree (orig_input_string);
+4 -3
View File
@@ -137,7 +137,7 @@ read_builtin (list)
intmax_t intval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1, *ps2;
char *e, *t, *t1, *ps2, *tofree;
struct stat tsb;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
@@ -492,7 +492,7 @@ add_char:
input_string[i++] = c;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1)
if (nchars > 0 && MB_CUR_MAX > 1)
{
input_string[i] = '\0'; /* for simplicity and debugging */
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
@@ -695,7 +695,8 @@ add_char:
if (*input_string)
{
t1 = input_string;
t = get_word_from_string (&input_string, ifs_chars, &e);
tofree = NULL;
tofree = t = get_word_from_string (&input_string, ifs_chars, &e);
if (*input_string == 0)
input_string = t;
else
+1 -1
View File
@@ -619,7 +619,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
cleanup_redirects (redirection_undo_list);
redirection_undo_list = (REDIRECT *)NULL;
dispose_exec_redirects ();
return (EXECUTION_FAILURE);
return (last_command_exit_value = EXECUTION_FAILURE);
}
if (redirection_undo_list)
-1
View File
@@ -3309,7 +3309,6 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
array_push (bash_source_a, sfile);
t = itos (executing_line_number ());
array_push (bash_lineno_a, t);
itrace("execute_function: pushed %s to BASH_LINENO", t);
free (t);
#endif
+8 -3
View File
@@ -1618,11 +1618,16 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
else
{
/* We have horizontal scrolling and we are not inserting at
the end. We have invisible characters in this line. This
is a dumb update. */
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp;
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
}
return;
}
/* Copy (new) chars to screen from first diff to last match. */
+16 -4
View File
@@ -938,7 +938,7 @@ rl_redisplay ()
second and subsequent lines start at inv_lbreaks[N], offset by
OFFSET (which has already been calculated above). */
#define WRAP_OFFSET<(line, offset) ((line == 0) \
#define WRAP_OFFSET(line, offset) ((line == 0) \
? (offset ? prompt_invis_chars_first_line : 0) \
: ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
@@ -1102,7 +1102,7 @@ rl_redisplay ()
tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
else
tx = nleft;
if (_rl_last_c_pos > tx)
if (tx >= 0 && _rl_last_c_pos > tx)
{
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_last_c_pos = tx;
@@ -1251,7 +1251,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
int current_line, omax, nmax, inv_botlin;
{
register char *ofd, *ols, *oe, *nfd, *nls, *ne;
int temp, lendiff, wsatend, od, nd, twidth;
int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
int current_invis_chars;
int col_lendiff, col_temp;
#if defined (HANDLE_MULTIBYTE)
@@ -1514,6 +1514,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_last_c_pos = lendiff + modmark;
}
o_cpos = _rl_last_c_pos;
/* When this function returns, _rl_last_c_pos is correct, and an absolute
cursor postion in multibyte mode, but a buffer index when not in a
multibyte locale. */
@@ -1523,7 +1525,9 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* We need to indicate that the cursor position is correct in the presence of
invisible characters in the prompt string. Let's see if setting this when
we make sure we're at the end of the drawn prompt string works. */
if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
(_rl_last_c_pos > 0 || o_cpos > 0) &&
_rl_last_c_pos == prompt_physical_chars)
cpos_adjusted = 1;
#endif
#endif
@@ -1619,6 +1623,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
is a dumb update. */
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += col_temp;
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
}
return;
}
/* Copy (new) chars to screen from first diff to last match. */
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+6 -5
View File
@@ -1186,20 +1186,21 @@ assign_random (self, value, unused)
{
sbrand (strtoul (value, (char **)NULL, 10));
if (subshell_environment)
seeded_subshell = 1;
seeded_subshell = getpid ();
return (self);
}
int
get_random_number ()
{
int rv;
int rv, pid;
/* Reset for command and process substitution. */
if (subshell_environment && seeded_subshell == 0)
pid = getpid ();
if (subshell_environment && seeded_subshell != pid)
{
sbrand (rseed + getpid() + NOW);
seeded_subshell = 1;
sbrand (rseed + pid + NOW);
seeded_subshell = pid;
}
do
+9 -9
View File
@@ -24,13 +24,13 @@
#include "posixstat.h"
#include "posixtime.h"
#if defined (qnx)
# if defined (qnx6)
#if defined (__QNX__)
# if defined (__QNXNTO__)
# include <sys/netmgr.h>
# else
# include <sys/vc.h>
# endif /* !qnx6 */
#endif /* qnx */
# endif /* !__QNXNTO__ */
#endif /* __QNX__ */
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
@@ -391,11 +391,11 @@ initialize_shell_variables (env, privmode)
set_auto_export (temp_var); /* XXX */
#endif
#if defined (qnx)
#if defined (__QNX__)
/* set node id -- don't import it from the environment */
{
char node_name[22];
# if defined (qnx6)
# if defined (__QNXNTO__)
netmgr_ndtostr(ND2S_LOCAL_STR, ND_LOCAL_NODE, node_name, sizeof(node_name));
# else
qnx_nidtostr (getnid (), node_name, sizeof (node_name));
@@ -1861,10 +1861,10 @@ make_variable_value (var, value, flags)
}
rval = evalexp (value, &expok);
if (expok == 0)
{
top_level_cleanup ();
{
top_level_cleanup ();
jump_to_top_level (DISCARD);
}
}
if (flags & ASS_APPEND)
rval += lval;
retval = itos (rval);