aboutsummaryrefslogtreecommitdiff
path: root/readline/text.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-07-14 20:29:21 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-07-25 09:53:01 -0400
commit4a11f2065906976675808364ddbd1c0f77eea41f (patch)
tree8b25495190b4d41b1785910c4cc4fd709d0a628a /readline/text.c
parenta496fbc8802f0a5719db6347a43cc869e03d83c9 (diff)
downloadfsf-binutils-gdb-4a11f2065906976675808364ddbd1c0f77eea41f.zip
fsf-binutils-gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.gz
fsf-binutils-gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.bz2
Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the latest version, 7.0 alpha (released July 10 2015). I essentially copied what was done the last time readline was synced, when Jan updated to readline 6.2 in 2011: http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html Procedure: 1. I extracted the readline-7.0-alpha tarball on top of readline/. 2. I deleted all the new files under doc/ that were deliberately omitted before. 3. I regenerated readline/configure and readline/examples/rlfe/configure using autoconf 2.64. No other configure files need regenerating. 4. I updated the function gdb_printable_part in completer.c with a trivial change made to the readline function it is based off of, printable_part in readline/complete.c. There is more work to be done in completer.c to sync it with readline/complete.c, but it is non-trivial and should probably be done separately anyway. Local patches that had to be reapplied: None. readline 7.0 alpha contains all of our local readline patches. New files in readline/: colors.{c,h} examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c parse-colors.{c,h} readline.pc.in configure.ac Deleted files in readline/: configure.in Regressions: After the sync there is one testsuite regression, the test "signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously, the readline 6.2 SIGINT handler would temporarily reinstall the underlying application's SIGINT handler and immediately re-raise SIGINT so that the orginal handler gets invoked. But now (since readline 6.3) its SIGINT handler does not re-raise SIGINT or directly invoke the original handler; it now sets a flag marking that SIGINT was raised, and waits until readline explicitly has control to call the application's SIGINT handler. Anyway, because SIGINT is no longer re-raised from within readline's SIGINT handler, doing "signal SIGINT" with a stopped inferior gdb process will no longer resume and then immediately stop the process (since there is no 2nd SIGINT to immediately catch). Instead, the inferior gdb process will now just print "Quit" and continue to run. So with this commit, this particular test case is adjusted to reflect this change in behavior (we now have to send a 2nd SIGINT manually to stop it). Aside from this one testsuite regression, I personally noticed no regression in user-visible behavior. Though I only tested on x86_64 and on i686 Debian Stretch. Getting this kind of change in at the start of the GDB 7.11 development cycle will allow us to get a lot of passive testing from developers and from bleeding-edge users. readline/ChangeLog.gdb: Import readline 7.0 alpha * configure: Regenerate. * examples/rlfe/configure: Regenerate. gdb/ChangeLog: * completer.c (gdb_printable_part): Sync with readline function it is based off of. gdb/testsuite/ChangeLog: * gdb.gdb/selftest.exp (test_with_self): Update test to now expect the GDB inferior to no longer immediately stop after being resumed with "signal SIGINT".
Diffstat (limited to 'readline/text.c')
-rw-r--r--readline/text.c77
1 files changed, 58 insertions, 19 deletions
diff --git a/readline/text.c b/readline/text.c
index 536e31a..f2bb224 100644
--- a/readline/text.c
+++ b/readline/text.c
@@ -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 */
@@ -240,7 +242,7 @@ rl_replace_line (text, clear_undo)
this is the same as rl_end.
Any command that is called interactively receives two arguments.
- The first is a count: the numeric arg pased to this command.
+ The first is a count: the numeric arg passed to this command.
The second is the key which invoked this command.
*/
@@ -826,7 +828,7 @@ _rl_insert_char (count, c)
pending characters that are bound to rl_insert, and insert
them all. Don't do this if we're current reading input from
a macro. */
- if ((RL_ISSTATE (RL_STATE_MACROINPUT) == 0) && _rl_any_typein ())
+ if ((RL_ISSTATE (RL_STATE_MACROINPUT) == 0) && _rl_pushed_input_available ())
_rl_insert_typein (c);
else
{
@@ -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. */
@@ -906,7 +942,10 @@ _rl_insert_next (count)
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
- return -1;
+ return 1;
+
+ if (RL_ISSTATE (RL_STATE_MACRODEF))
+ _rl_add_macro_char (c);
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
@@ -1063,7 +1102,7 @@ rl_rubout (count, key)
if (!rl_point)
{
rl_ding ();
- return -1;
+ return 1;
}
if (rl_insert_mode == RL_IM_OVERWRITE)
@@ -1086,7 +1125,7 @@ _rl_rubout_char (count, key)
if (rl_point == 0)
{
rl_ding ();
- return -1;
+ return 1;
}
orig_point = rl_point;
@@ -1100,7 +1139,7 @@ _rl_rubout_char (count, key)
c = rl_line_buffer[--rl_point];
rl_delete_text (rl_point, orig_point);
/* The erase-at-end-of-line hack is of questionable merit now. */
- if (rl_point == rl_end && ISPRINT (c) && _rl_last_c_pos)
+ if (rl_point == rl_end && ISPRINT ((unsigned char)c) && _rl_last_c_pos)
{
int l;
l = rl_character_len (c, rl_point);
@@ -1130,7 +1169,7 @@ rl_delete (count, key)
if (rl_point == rl_end)
{
rl_ding ();
- return -1;
+ return 1;
}
if (count > 1 || rl_explicit_arg)
@@ -1300,7 +1339,7 @@ rl_change_case (count, op)
if (op != UpCase && op != DownCase && op != CapCase)
{
rl_ding ();
- return -1;
+ return 1;
}
if (count < 0)
@@ -1334,7 +1373,7 @@ rl_change_case (count, op)
}
else
nop = op;
- if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii (c))
+ if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii ((unsigned char)c))
{
nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c);
rl_line_buffer[start] = nc;
@@ -1400,7 +1439,7 @@ rl_transpose_words (count, key)
{
rl_ding ();
rl_point = orig_point;
- return -1;
+ return 1;
}
/* Get the text of the words. */
@@ -1453,7 +1492,7 @@ rl_transpose_chars (count, key)
if (!rl_point || rl_end < 2)
{
rl_ding ();
- return -1;
+ return 1;
}
rl_begin_undo_group ();
@@ -1516,7 +1555,7 @@ _rl_char_search_internal (count, dir, schar)
#endif
if (dir == 0)
- return -1;
+ return 1;
pos = rl_point;
inc = (dir < 0) ? -1 : 1;
@@ -1525,7 +1564,7 @@ _rl_char_search_internal (count, dir, schar)
if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end))
{
rl_ding ();
- return -1;
+ return 1;
}
#if defined (HANDLE_MULTIBYTE)
@@ -1580,7 +1619,7 @@ _rl_char_search (count, fdir, bdir)
mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
if (mb_len <= 0)
- return -1;
+ return 1;
if (count < 0)
return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
@@ -1599,7 +1638,7 @@ _rl_char_search (count, fdir, bdir)
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
- return -1;
+ return 1;
if (count < 0)
return (_rl_char_search_internal (-count, bdir, c));
@@ -1668,7 +1707,7 @@ _rl_set_mark_at_pos (position)
int position;
{
if (position > rl_end)
- return -1;
+ return 1;
rl_mark = position;
return 0;
@@ -1693,7 +1732,7 @@ rl_exchange_point_and_mark (count, key)
if (rl_mark == -1)
{
rl_ding ();
- return -1;
+ return 1;
}
else
SWAP (rl_point, rl_mark);