diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-07-14 20:29:21 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-07-25 09:53:01 -0400 |
commit | 4a11f2065906976675808364ddbd1c0f77eea41f (patch) | |
tree | 8b25495190b4d41b1785910c4cc4fd709d0a628a /readline/search.c | |
parent | a496fbc8802f0a5719db6347a43cc869e03d83c9 (diff) | |
download | gdb-4a11f2065906976675808364ddbd1c0f77eea41f.zip gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.gz 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/search.c')
-rw-r--r-- | readline/search.c | 98 |
1 files changed, 79 insertions, 19 deletions
diff --git a/readline/search.c b/readline/search.c index bf525e6..c9bc6b1 100644 --- a/readline/search.c +++ b/readline/search.c @@ -1,6 +1,6 @@ /* search.c - code for non-incremental searching in emacs and vi modes. */ -/* Copyright (C) 1992-2009 Free Software Foundation, Inc. +/* Copyright (C) 1992-2013 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -43,6 +43,7 @@ #include "readline.h" #include "history.h" +#include "histlib.h" #include "rlprivate.h" #include "xmalloc.h" @@ -66,6 +67,8 @@ static char *prev_line_found = (char *) NULL; static int rl_history_search_len; static int rl_history_search_pos; +static int rl_history_search_flags; + static char *history_search_string; static int history_string_size; @@ -74,10 +77,9 @@ static int noninc_search_from_pos PARAMS((char *, int, int)); static int noninc_dosearch PARAMS((char *, int)); static int noninc_search PARAMS((int, int)); static int rl_history_search_internal PARAMS((int, int)); -static void rl_history_search_reinit PARAMS((void)); +static void rl_history_search_reinit PARAMS((int)); static _rl_search_cxt *_rl_nsearch_init PARAMS((int, int)); -static int _rl_nsearch_cleanup PARAMS((_rl_search_cxt *, int)); static void _rl_nsearch_abort PARAMS((_rl_search_cxt *)); static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int)); @@ -169,7 +171,8 @@ noninc_dosearch (string, dir) oldpos = where_history (); history_set_pos (noninc_history_pos); - entry = current_history (); + entry = current_history (); /* will never be NULL after successful search */ + #if defined (VI_MODE) if (rl_editing_mode != vi_mode) #endif @@ -220,7 +223,7 @@ _rl_nsearch_init (dir, pchar) return cxt; } -static int +int _rl_nsearch_cleanup (cxt, r) _rl_search_cxt *cxt; int r; @@ -407,7 +410,7 @@ rl_noninc_forward_search_again (count, key) if (!noninc_search_string) { rl_ding (); - return (-1); + return (1); } r = noninc_dosearch (noninc_search_string, 1); return (r != 1); @@ -424,7 +427,7 @@ rl_noninc_reverse_search_again (count, key) if (!noninc_search_string) { rl_ding (); - return (-1); + return (1); } r = noninc_dosearch (noninc_search_string, -1); return (r != 1); @@ -453,15 +456,19 @@ rl_history_search_internal (count, dir) { HIST_ENTRY *temp; int ret, oldpos; + char *t; rl_maybe_save_line (); temp = (HIST_ENTRY *)NULL; - /* Search COUNT times through the history for a line whose prefix - matches history_search_string. When this loop finishes, TEMP, - if non-null, is the history line to copy into the line buffer. */ + /* Search COUNT times through the history for a line matching + history_search_string. If history_search_string[0] == '^', the + line must match from the start; otherwise any substring can match. + When this loop finishes, TEMP, if non-null, is the history line to + copy into the line buffer. */ while (count) { + RL_CHECK_SIGNALS (); ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir); if (ret == -1) break; @@ -470,7 +477,7 @@ rl_history_search_internal (count, dir) rl_history_search_pos = ret; oldpos = where_history (); history_set_pos (rl_history_search_pos); - temp = current_history (); + temp = current_history (); /* will never be NULL after successful search */ history_set_pos (oldpos); /* Don't find multiple instances of the same line. */ @@ -505,35 +512,49 @@ rl_history_search_internal (count, dir) /* Copy the line we found into the current line buffer. */ make_history_line_current (temp); - rl_point = rl_history_search_len; + if (rl_history_search_flags & ANCHORED_SEARCH) + rl_point = rl_history_search_len; /* easy case */ + else + { + t = strstr (rl_line_buffer, history_search_string); + rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end; + } rl_mark = rl_end; return 0; } static void -rl_history_search_reinit () +rl_history_search_reinit (flags) + int flags; { + int sind; + rl_history_search_pos = where_history (); rl_history_search_len = rl_point; + rl_history_search_flags = flags; + prev_line_found = (char *)NULL; if (rl_point) { + /* Allocate enough space for anchored and non-anchored searches */ if (rl_history_search_len >= history_string_size - 2) { history_string_size = rl_history_search_len + 2; history_search_string = (char *)xrealloc (history_search_string, history_string_size); } - history_search_string[0] = '^'; - strncpy (history_search_string + 1, rl_line_buffer, rl_point); - history_search_string[rl_point + 1] = '\0'; + sind = 0; + if (flags & ANCHORED_SEARCH) + history_search_string[sind++] = '^'; + strncpy (history_search_string + sind, rl_line_buffer, rl_point); + history_search_string[rl_point + sind] = '\0'; } _rl_free_saved_history_line (); } /* Search forward in the history for the string of characters from the start of the line to rl_point. This is a non-incremental - search. */ + search. The search is anchored to the beginning of the history line. */ int rl_history_search_forward (count, ignore) int count, ignore; @@ -543,7 +564,7 @@ rl_history_search_forward (count, ignore) if (rl_last_func != rl_history_search_forward && rl_last_func != rl_history_search_backward) - rl_history_search_reinit (); + rl_history_search_reinit (ANCHORED_SEARCH); if (rl_history_search_len == 0) return (rl_get_next_history (count, ignore)); @@ -562,7 +583,46 @@ rl_history_search_backward (count, ignore) if (rl_last_func != rl_history_search_forward && rl_last_func != rl_history_search_backward) - rl_history_search_reinit (); + rl_history_search_reinit (ANCHORED_SEARCH); + + if (rl_history_search_len == 0) + return (rl_get_previous_history (count, ignore)); + return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1)); +} + +/* Search forward in the history for the string of characters + from the start of the line to rl_point. This is a non-incremental + search. The search succeeds if the search string is present anywhere + in the history line. */ +int +rl_history_substr_search_forward (count, ignore) + int count, ignore; +{ + if (count == 0) + return (0); + + if (rl_last_func != rl_history_substr_search_forward && + rl_last_func != rl_history_substr_search_backward) + rl_history_search_reinit (NON_ANCHORED_SEARCH); + + if (rl_history_search_len == 0) + return (rl_get_next_history (count, ignore)); + return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1)); +} + +/* Search backward through the history for the string of characters + from the start of the line to rl_point. This is a non-incremental + search. */ +int +rl_history_substr_search_backward (count, ignore) + int count, ignore; +{ + if (count == 0) + return (0); + + if (rl_last_func != rl_history_substr_search_forward && + rl_last_func != rl_history_substr_search_backward) + rl_history_search_reinit (NON_ANCHORED_SEARCH); if (rl_history_search_len == 0) return (rl_get_previous_history (count, ignore)); |