diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 36e5bd1d..1b1d006a 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -3364,3 +3364,25 @@ bashline.c string does *not* exist as a filename before removing those characters from the set that must be backslash-quoted. See change from 1/1/2022 + + 3/18 + ---- +lib/readline/search.c + - make_history_line_current: don't free rl_undo_list or + _rl_saved_line_for_history; don't unconditionally save the history + line. This reverts some of the changes to support setting the + history position in history-search-backward + - rl_history_search_internal: only free the saved history line if we + were the ones who created it + + 3/21 + ---- +lib/readline/nls.c + - xmalloc.h: include for systems without setlocale(), so xfree has a + prototype. Report and fix from AndrĂ¡s Kucsma + +lib/readline/search.c + - _rl_history_search_internal: use previous-history/next-history to + move to the found history line instead of directly calling + history_set_pos. This makes the behavior more similar to incremental + search diff --git a/lib/readline/nls.c b/lib/readline/nls.c index fd093b6c..8447c10f 100644 --- a/lib/readline/nls.c +++ b/lib/readline/nls.c @@ -1,6 +1,6 @@ /* nls.c -- skeletal internationalization code. */ -/* Copyright (C) 1996-2021 Free Software Foundation, Inc. +/* Copyright (C) 1996-2022 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. @@ -53,6 +53,7 @@ #include "readline.h" #include "rlshell.h" #include "rlprivate.h" +#include "xmalloc.h" static int utf8locale (char *); diff --git a/lib/readline/readline.c b/lib/readline/readline.c index 888612c6..f1140614 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -489,7 +489,11 @@ readline_internal_teardown (int eof) /* We don't want to do this if we executed functions that call history_set_pos to set the history offset to the line containing the non-incremental search string. */ +#if 1 /* XXX */ + if (entry && rl_undo_list) +#else if (entry && rl_undo_list && _rl_history_search_pos != where_history ()) +#endif { temp = savestring (the_line); rl_revert_line (1, 0); diff --git a/lib/readline/search.c b/lib/readline/search.c index 22451663..22a044fe 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -84,17 +84,6 @@ static int _rl_nsearch_dispatch (_rl_search_cxt *, int); static void make_history_line_current (HIST_ENTRY *entry) { - /* At this point, rl_undo_list points to a private search string list. */ - if (rl_undo_list && rl_undo_list != (UNDO_LIST *)entry->data) - rl_free_undo_list (); - - /* This will need to free the saved undo list associated with the original - (pre-search) line buffer. */ - if (_rl_saved_line_for_history) - _rl_free_saved_history_line (); - - rl_maybe_save_line (); - /* Now we create a new undo list with a single insert for this text. WE DON'T CHANGE THE ORIGINAL HISTORY ENTRY UNDO LIST */ _rl_replace_text (entry->line, 0, rl_end); @@ -107,6 +96,8 @@ make_history_line_current (HIST_ENTRY *entry) current editing buffer. */ rl_free_undo_list (); #endif + + /* XXX - free the saved line for history here? */ } /* Search the history list for STRING starting at absolute history position @@ -195,6 +186,7 @@ noninc_dosearch (char *string, int dir, int flags) history_set_pos (oldpos); make_history_line_current (entry); + /* make_history_line_current used to do this. */ _rl_free_saved_history_line (); if (_rl_enable_active_region && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end) @@ -525,9 +517,11 @@ static int rl_history_search_internal (int count, int dir) { HIST_ENTRY *temp; - int ret, oldpos, newcol; + int ret, oldpos, newcol, had_saved_line, origpos; char *t; + origpos = where_history (); + had_saved_line = _rl_saved_line_for_history != 0; rl_maybe_save_line (); /* This will either be restored from the saved line or set from the found history line. */ @@ -563,6 +557,7 @@ rl_history_search_internal (int count, int dir) /* If we didn't find anything at all, return. */ if (temp == 0) { + /* XXX - check had_saved_line here? */ rl_maybe_unsave_line (); rl_ding (); /* If you don't want the saved history line (last match) to show up @@ -585,11 +580,17 @@ rl_history_search_internal (int count, int dir) /* Copy the line we found into the current line buffer. */ make_history_line_current (temp); + /* Free the saved history line corresponding to the search string */ + if (had_saved_line == 0) + _rl_free_saved_history_line (); + /* Make sure we set the current history position to the last line found so we can do things like operate-and-get-next from here. This is similar to how incremental search behaves. */ - rl_maybe_replace_line (); - history_set_pos (_rl_history_search_pos); /* XXX */ + if (_rl_history_search_pos < origpos) + rl_get_previous_history (origpos - _rl_history_search_pos, 0); + else + rl_get_next_history (_rl_history_search_pos - origpos, 0); /* decide where to put rl_point -- need to change this for pattern search */ if (_rl_history_search_flags & ANCHORED_SEARCH)