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 <r0maikx02b@gmail.com>
+
+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
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);
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
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)
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. */
/* 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
/* 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)