commit bash-20150521 snapshot

This commit is contained in:
Chet Ramey
2015-06-05 11:49:44 -04:00
parent 74b8cbb413
commit 3bf257a5d9
24 changed files with 261 additions and 81 deletions
+2 -1
View File
@@ -284,7 +284,8 @@ _rl_callback_data_alloc (count)
return arg;
}
void _rl_callback_data_dispose (arg)
void
_rl_callback_data_dispose (arg)
_rl_callback_generic_arg *arg;
{
xfree (arg);
+16 -15
View File
@@ -586,6 +586,7 @@ rl_redisplay ()
int wc_width;
mbstate_t ps;
int _rl_wrapped_multicolumn = 0;
int mb_cur_max = MB_CUR_MAX;
#endif
if (_rl_echoing_p == 0)
@@ -764,7 +765,7 @@ rl_redisplay ()
prompts that exceed two physical lines?
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
{
n0 = num;
temp = local_prompt_len;
@@ -802,7 +803,7 @@ rl_redisplay ()
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
lpos -= _rl_col_width (local_prompt, n0, num, 1);
else
#endif
@@ -819,7 +820,7 @@ rl_redisplay ()
lb_linenum = 0;
#if defined (HANDLE_MULTIBYTE)
in = 0;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
memset (&ps, 0, sizeof (mbstate_t));
/* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
@@ -835,7 +836,7 @@ rl_redisplay ()
c = (unsigned char)rl_line_buffer[in];
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
if (MB_INVALIDCH (wc_bytes))
{
@@ -944,7 +945,7 @@ rl_redisplay ()
else
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
register int i;
@@ -980,7 +981,7 @@ rl_redisplay ()
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
in += wc_bytes;
/* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
@@ -1028,7 +1029,7 @@ rl_redisplay ()
not the first. */
if (out >= _rl_screenchars)
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
else
out = _rl_screenchars - 1;
@@ -1076,10 +1077,10 @@ rl_redisplay ()
time update_line is called, then we can assume in our
calculations that o_cpos does not need to be adjusted by
wrap_offset. */
if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
if (linenum == 0 && (mb_cur_max > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
(mb_cur_max > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
@@ -1096,7 +1097,7 @@ rl_redisplay ()
(wrap_offset > visible_wrap_offset) &&
(_rl_last_c_pos < visible_first_line_len))
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
nleft = _rl_screenwidth - _rl_last_c_pos;
else
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
@@ -1148,7 +1149,7 @@ rl_redisplay ()
the physical cursor position on the screen stays the same,
but the buffer position needs to be adjusted to account
for invisible characters. */
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
if ((mb_cur_max == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
@@ -1175,7 +1176,7 @@ rl_redisplay ()
_rl_output_some_chars ("*", 1);
_rl_output_some_chars (local_prompt, nleft);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
else
_rl_last_c_pos = nleft + modmark;
@@ -1199,7 +1200,7 @@ rl_redisplay ()
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
{
/* TX == new physical cursor position in multibyte locale. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
else
tx = nleft;
@@ -1214,7 +1215,7 @@ rl_redisplay ()
_rl_last_c_pos as an absolute cursor position, but moving to a
point specified by a buffer position (NLEFT) that doesn't take
invisible characters into account. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
else if (nleft != _rl_last_c_pos)
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
@@ -1295,7 +1296,7 @@ rl_redisplay ()
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
displaying_prompt_first_line && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
+7 -12
View File
@@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Mon Apr 6 14:13:28 EDT 2015
.\" Last Change: Sun May 24 18:01:17 EDT 2015
.\"
.TH HISTORY 3 "2014 April 6" "GNU History 6.3"
.TH HISTORY 3 "2015 May 24" "GNU History 6.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -441,16 +441,11 @@ return a pointer to that entry. If there is no previous entry, return
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
If the current history offset is not already at the end of the history
list, move the current history offset forward to the next history entry.
If the incremented history offset refers to a valid history entry, return
a pointer to that entry.
If there is no next entry, as when the history offset before being
incremented refers to the last valid entry in the history list, return
a \fBNULL\fP pointer.
If this function returns \fBNULL\fP, the current history offset when the
function returns (possibly incremented as described above)
is at the end of the history list.
If the current history offset refers to a valid history entry,
increment the current history offset.
If the possibly-incremented history offset refers to a valid history
entry, return a pointer to that entry;
otherwise, return a \fBNULL\fP pointer.
.SS Searching the History List
+5 -10
View File
@@ -270,16 +270,11 @@ a @code{NULL} pointer.
@end deftypefun
@deftypefun {HIST_ENTRY *} next_history (void)
If the current history offset is not already at the end of the history
list, move the current history offset forward to the next history entry.
If the incremented history offset refers to a valid history entry, return
a pointer to that entry.
If there is no next entry, as when the history offset before being
incremented refers to the last valid entry in the history list, return
a @code{NULL} pointer.
If this function returns @code{NULL}, the current history offset when the
function returns (possibly incremented as described above)
is at the end of the history list.
If the current history offset refers to a valid history entry,
increment the current history offset.
If the possibly-incremented history offset refers to a valid history
entry, return a pointer to that entry;
otherwise, return a @code{BNULL} pointer.
@end deftypefun
@node Searching the History List
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2015 Free Software Foundation, Inc.
@set EDITION 6.4
@set VERSION 6.4
@set UPDATED 6 April 2015
@set UPDATED-MONTH April 2015
@set UPDATED 24 May 2015
@set UPDATED-MONTH May 2015
@set LASTCHANGE Mon Apr 6 14:13:14 EDT 2015
@set LASTCHANGE Sun May 24 18:01:45 EDT 2015
-4
View File
@@ -514,10 +514,6 @@ rl_getc (stream)
FD_ZERO (&readfds);
FD_SET (fileno (stream), &readfds);
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
# if 0
if (result < 0 && errno == EINTR)
goto handle_error;
# endif
#endif
if (result >= 0)
result = read (fileno (stream), &c, sizeof (unsigned char));
+36 -2
View File
@@ -123,13 +123,47 @@ extern int _rl_walphabetic PARAMS((wchar_t));
#define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2)
#define MB_NULLWCH(x) ((x) == 0)
/* Try and shortcut the printable ascii characters to cut down the number of
calls to a libc wcwidth() */
static inline int
_rl_wcwidth (wc)
wchar_t wc;
{
switch (wc)
{
case ' ': case '!': case '"': case '#': case '%':
case '&': case '\'': case '(': case ')': case '*':
case '+': case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>':
case '?':
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
case 'K': case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X': case 'Y':
case 'Z':
case '[': case '\\': case ']': case '^': case '_':
case 'a': case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i': case 'j':
case 'k': case 'l': case 'm': case 'n': case 'o':
case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z': case '{': case '|': case '}': case '~':
return 1;
default:
return wcwidth (wc);
}
}
/* Unicode combining characters range from U+0300 to U+036F */
#define UNICODE_COMBINING_CHAR(x) ((x) >= 768 && (x) <= 879)
#if defined (WCWIDTH_BROKEN)
# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : wcwidth(wc))
# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : _rl_wcwidth(wc))
#else
# define WCWIDTH(wc) wcwidth(wc)
# define WCWIDTH(wc) _rl_wcwidth(wc)
#endif
#if defined (WCWIDTH_BROKEN)
+3
View File
@@ -545,6 +545,9 @@ extern int _rl_screenchars;
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
/* text.c */
extern int _rl_optimize_typeahead;
/* undo.c */
extern int _rl_doing_an_undo;
extern int _rl_undo_group_level;
+38 -2
View File
@@ -71,6 +71,8 @@ static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
rl_insert_text. Text blocks larger than this are divided. */
#define TEXT_COUNT_MAX 1024
int _rl_optimize_typeahead = 1; /* rl_insert tries to read typeahead */
/* **************************************************************** */
/* */
/* Insert and Delete */
@@ -890,8 +892,42 @@ int
rl_insert (count, c)
int count, c;
{
return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c)
: _rl_overwrite_char (count, c));
int r, n, x;
r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (count, c) : _rl_overwrite_char (count, c);
/* XXX -- attempt to batch-insert pending input that maps to self-insert */
x = 0;
n = (unsigned short)-2;
while (_rl_optimize_typeahead &&
(RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued (0) &&
(n = rl_read_key ()) > 0 &&
_rl_keymap[(unsigned char)n].type == ISFUNC &&
_rl_keymap[(unsigned char)n].function == rl_insert)
{
r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (1, n) : _rl_overwrite_char (1, n);
/* _rl_insert_char keeps its own set of pending characters to compose a
complete multibyte character, and only returns 1 if it sees a character
that's part of a multibyte character but too short to complete one. We
can try to read another character in the hopes that we will get the
next one or just punt. Right now we try to read another character.
We don't want to call rl_insert_next if _rl_insert_char has already
stored the character in the pending_bytes array because that will
result in doubled input. */
n = (unsigned short)-2;
x++; /* count of bytes of typeahead read, currently unused */
if (r == 1) /* read partial multibyte character */
continue;
if (rl_done || r != 0)
break;
}
if (n != (unsigned short)-2) /* -2 = sentinel value for having inserted N */
r = rl_execute_next (n);
return r;
}
/* Insert the next typed character verbatim. */
+3 -2
View File
@@ -112,7 +112,7 @@ sh_modcase (string, pat, flags)
#if defined (HANDLE_MULTIBYTE)
wchar_t nwc;
char mb[MB_LEN_MAX+1];
int mlen;
int mlen, mb_cur_max;
size_t m;
mbstate_t state;
#endif
@@ -130,6 +130,7 @@ sh_modcase (string, pat, flags)
start = 0;
end = strlen (string);
mb_cur_max = MB_CUR_MAX;
ret = (char *)xmalloc (2*end + 1);
retind = 0;
@@ -209,7 +210,7 @@ sh_modcase (string, pat, flags)
/* 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)
if (mb_cur_max == 1)
{
singlebyte:
switch (nop)
+4 -3
View File
@@ -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;
+4 -3
View File
@@ -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;
+6 -3
View File
@@ -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;
+4 -2
View File
@@ -233,7 +233,7 @@ sh_backslash_quote (string, table, flags)
char *table;
int flags;
{
int c;
int c, mb_cur_max;
size_t slen;
char *result, *r, *s, *backslash_table, *send;
DECLARE_MBSTATE;
@@ -243,6 +243,8 @@ sh_backslash_quote (string, table, flags)
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 defined (HANDLE_MULTIBYTE)
@@ -253,7 +255,7 @@ sh_backslash_quote (string, table, flags)
*r++ = c;
continue;
}
if (MB_CUR_MAX > 1 && is_basic (c) == 0)
if (mb_cur_max > 1 && is_basic (c) == 0)
{
COPY_CHAR_P (r, s, send);
s--; /* compensate for auto-increment in loop above */