fix for history-search-backward after previous-history clearing the undo list

This commit is contained in:
Chet Ramey
2022-04-04 09:40:49 -04:00
parent 8f68f9f0ff
commit 505f60f94c
11 changed files with 81 additions and 25 deletions
+14
View File
@@ -3424,3 +3424,17 @@ arrayfunc.c
- array_value_internal: fix typo and set estatep->type to ARRAY_INDEXED for
indexed arrays
3/31
----
lib/readline/{history.c,histlib.h}
- _hs_at_end_of_history: convenience function to tell whether or not the
current history position is at the end of the history list
4/1
---
lib/readline/search.c
- make_history_line_current: don't free rl_undo_list if it is equal to
_rl_saved_line_for_history->data, since we will need to restore it later
if we got it from a history entry. Fixes issue dating back to 7/2021 and
changes to _rl_free_saved_line_for_history, current issue reported by
Andreas Schwab <schwab@linux-m68k.org>
Vendored
+2 -1
View File
@@ -990,7 +990,8 @@ elif test $bash_cv_termcap_lib = libc; then
TERMCAP_LIB=
TERMCAP_DEP=
else
TERMCAP_LIB=-lcurses
# we assume ncurses is installed somewhere the linker can find it
TERMCAP_LIB=-lncurses
TERMCAP_DEP=
fi
])
Vendored
+4 -2
View File
@@ -5960,7 +5960,8 @@ elif test $bash_cv_termcap_lib = libc; then
TERMCAP_LIB=
TERMCAP_DEP=
else
TERMCAP_LIB=-lcurses
# we assume ncurses is installed somewhere the linker can find it
TERMCAP_LIB=-lncurses
TERMCAP_DEP=
fi
@@ -21546,7 +21547,8 @@ elif test $bash_cv_termcap_lib = libc; then
TERMCAP_LIB=
TERMCAP_DEP=
else
TERMCAP_LIB=-lcurses
# we assume ncurses is installed somewhere the linker can find it
TERMCAP_LIB=-lncurses
TERMCAP_DEP=
fi
+2 -1
View File
@@ -1,6 +1,6 @@
/* histlib.h -- internal definitions for the history library. */
/* Copyright (C) 1989-2009,2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2009,2021-2022 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -84,6 +84,7 @@ extern int _hs_history_patsearch (const char *, int, int);
/* history.c */
extern void _hs_replace_history_data (int, histdata_t *, histdata_t *);
extern int _hs_at_end_of_history (void);
/* histfile.c */
extern void _hs_append_history_line (int, const char *);
+7
View File
@@ -165,6 +165,13 @@ history_set_pos (int pos)
history_offset = pos;
return (1);
}
/* Are we currently at the end of the history list? */
int
_hs_at_end_of_history (void)
{
return (the_history == 0 || history_offset == history_length);
}
/* Return the current history array. The caller has to be careful, since this
is the actual array of data, and could be bashed or made corrupt easily.
+7 -1
View File
@@ -388,17 +388,23 @@ _rl_free_saved_history_line (void)
{
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
rl_undo_list = 0;
/* Have to free this separately because _rl_free_history entry can't:
it doesn't know whether or not this has application data. Only the
callers that know this is _rl_saved_line_for_history can know that
it's an undo list. */
#if defined (HISTORY_SEARCH_SETS_HISTPOS)
if (_rl_saved_line_for_history->data)
{
orig = rl_undo_list;
rl_undo_list = _rl_saved_line_for_history->data;
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
rl_free_undo_list ();
rl_undo_list = orig;
}
#else
if (_rl_saved_line_for_history->data)
_rl_free_undo_list ((UNDO_LIST *)_rl_saved_line_for_history->data);
#endif
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
+1 -1
View File
@@ -492,7 +492,7 @@ 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 HISTORY_SEARCH_SETS_HISTPOS
#if defined (HISTORY_SEARCH_SETS_HISTPOS)
if (entry && rl_undo_list && _rl_history_search_pos != where_history ())
#else
if (entry && rl_undo_list)
+33 -8
View File
@@ -84,6 +84,15 @@ static int _rl_nsearch_dispatch (_rl_search_cxt *, int);
static void
make_history_line_current (HIST_ENTRY *entry)
{
#if !defined (HISTORY_SEARCH_SETS_HISTPOS)
UNDO_LIST *xlist;
xlist = _rl_saved_line_for_history ? (UNDO_LIST *)_rl_saved_line_for_history->data : 0;
/* 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_undo_list != xlist)
rl_free_undo_list ();
#endif
/* 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);
@@ -97,7 +106,16 @@ make_history_line_current (HIST_ENTRY *entry)
rl_free_undo_list ();
#endif
/* XXX - free the saved line for history here? */
#if !defined (HISTORY_SEARCH_SETS_HISTPOS)
/* This will need to free the saved undo list associated with the original
(pre-search) line buffer.
XXX - look at _rl_free_saved_history_line and consider calling it if
rl_undo_list != xlist (or calling rl_free_undo list directly on
_rl_saved_line_for_history->data) */
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
#endif
}
/* Search the history list for STRING starting at absolute history position
@@ -186,8 +204,10 @@ noninc_dosearch (char *string, int dir, int flags)
history_set_pos (oldpos);
make_history_line_current (entry);
#if !defined (HISTORY_SEARCH_SETS_HISTPOS)
/* make_history_line_current used to do this. */
_rl_free_saved_history_line ();
#endif
if (_rl_enable_active_region && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end)
{
@@ -517,16 +537,21 @@ static int
rl_history_search_internal (int count, int dir)
{
HIST_ENTRY *temp;
int ret, oldpos, newcol;
UNDO_LIST *origlist;
int ret, oldpos, newcol, had_saved_line, origpos;
int had_saved_line, origpos;
char *t;
#if defined (HISTORY_SEARCH_SETS_HISTPOS)
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. */
rl_undo_list = 0;
#else
rl_maybe_save_line ();
#endif
temp = (HIST_ENTRY *)NULL;
/* Search COUNT times through the history for a line matching
@@ -581,16 +606,16 @@ 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 ();
#if HISTORY_SEARCH_SETS_HISTPOS
/* XXX - can't make this work the way I want it to yet. Too much assumes
that rl_undo_list corresponds to the current history entry's undo list,
especially the stuff in maybe_save_line and especially maybe_replace_line.
Leaving it commented out for now. */
#if defined (HISTORY_SEARCH_SETS_HISTPOS)
/* 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. */
@@ -644,7 +669,7 @@ rl_history_search_reinit (int flags)
strncpy (history_search_string + sind, rl_line_buffer, rl_point);
history_search_string[rl_point + sind] = '\0';
}
_rl_free_saved_history_line ();
_rl_free_saved_history_line (); /* XXX rl_undo_list? */
}
/* Search forward in the history for the string of characters
BIN
View File
Binary file not shown.
+10 -10
View File
@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: bash 5.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-28 12:51-0500\n"
"PO-Revision-Date: 2022-03-24 15:58-0700\n"
"PO-Revision-Date: 2022-03-30 11:48-0700\n"
"Last-Translator: Božidar Putanec <bozidarp@yahoo.com>\n"
"Language-Team: Croatian <lokalizacija@linux.hr>\n"
"Language: hr\n"
@@ -1973,7 +1973,7 @@ msgstr "nije moguće duplicirati imenovanu cijev %s kao deskriptor datoteke %d"
#: subst.c:6213
msgid "command substitution: ignored null byte in input"
msgstr "nevaljana supstitucija: ignorira se prazni (nula) bajt na ulazu"
msgstr "nevaljana supstitucija: zanemaren prazni (nula) bajt u ulazu"
#: subst.c:6353
msgid "cannot make pipe for command substitution"
@@ -2796,10 +2796,10 @@ msgstr ""
"\n"
" Opcije:\n"
" -L slijedi simboličke veze; simboličke veze u DIREKTORIJU razriješi\n"
" nakon obrade zapisa „..“\n"
" nakon obrade instance „..“\n"
" -P rabi fizičku strukturu direktorija umjesto da slijedi simboličke\n"
" veze; simboličke veze u DIREKTORIJU razriješi prije obrade\n"
" zapisa „..“\n"
" instance „..“\n"
" -e ako je dana s opcijom „-P“, i trenutni radni direktorij nije\n"
" moguće uspješno odrediti nakon uspješne promjene direktorija,\n"
" „cd“ završi s kȏdom različitim od 0.\n"
@@ -2948,7 +2948,7 @@ msgstr ""
" -f prikaže samo definirane funkcije (ne prikaže varijable)\n"
" -F prikaže samo imena funkcija bez definicija\n"
" -g stvori globalne varijable samo za upotrebu u funkciji ljuske;\n"
" inače se ignoriraju\n"
" inače su zanemarene\n"
" -I ako stvori lokalnu varijablu, neka naslijedi atribute i vrijednost\n"
" varijable s istim imenom u prethodnom opsegu\n"
" -p prikaže atribute i vrijednost za svako dano IME\n"
@@ -3962,7 +3962,7 @@ msgstr ""
" hashall == -h\n"
" histexpand == -H\n"
" history omogući naredbu „history“\n"
" ignoreeof ignorira Ctrl-D; ne završi (ne iziđe iz) ljusku na EOF\n"
" ignoreeof zanemari Ctrl-D; ne završi (ne iziđe iz) ljusku na EOF\n"
" interactive-comments dopusti komentiranje u interaktivnim naredbama\n"
" keyword == -k\n"
" monitor == -m\n"
@@ -4372,7 +4372,7 @@ msgstr ""
" specificiranih signala (SIGNAL_SPEC). Ako nema ARGUMENTA (i dan je samo\n"
" jedan signal) ili ARGUMENT je „-“, specificirani signal zadobije svoju\n"
" originalnu vrijednost (koju je imao na startu ove ljuske). Ako je ARGUMENT\n"
" prazni string, ljuska i njezini potomci ignoriraju svaki SIGNAL_SPEC.\n"
" prazni string, ljuska i njezini potomci zanemare svaki SIGNAL_SPEC.\n"
"\n"
" Ako je SIGNAL_SPEC 0 ili EXIT, ARGUMENT se izvrši kad zatvorite\n"
" (exit) ljusku. Ako je SIGNAL_SPEC DEBUG, ARGUMENT se izvrši prije\n"
@@ -4741,7 +4741,7 @@ msgstr ""
" korisnikom i CPU vrijeme potrošeno sustavom za izvršavanje naredbi.\n"
"\n"
" Izlazni format se može prilagoditi s varijablom okoline TIMEFORMAT.\n"
" Opcija „-p“ ignorira TIMEFORMAT i ispiše izlaz u prenosivom POSIX\n"
" Opcija „-p“ zanemari TIMEFORMAT i ispiše izlaz u prenosivom POSIX\n"
" formatu.\n"
"\n"
" Završi s izlaznim kȏdom CJEVOVODA."
@@ -5030,7 +5030,7 @@ msgstr ""
" kad argument od „cd“ (direktorij) nije u\n"
" trenutnom radnom direktoriju\n"
" GLOBIGNORE popis uzoraka koji opisuju imena datoteka koje\n"
" se ignoriraju prilikom ekspanzije imena staza\n"
" su zanemarene prilikom ekspanzije imena staza\n"
" HISTFILE ime datoteke koja sadrži povijest vaših naredbi\n"
" HISTFILESIZE maksimalni broj redaka datoteke s povijesti naredba\n"
" HISTIGNORE popis uzoraka koji opisuju naredbe koje ne treba zapisati\n"
@@ -5039,7 +5039,7 @@ msgstr ""
" HOME puni naziv staze do vašega vlastitog direktorija\n"
" HOSTNAME ime računala na kojem se izvršava „bash“\n"
" HOSTTYPE vrsta CPU-a na kojem se izvršava „bash“\n"
" IGNOREEOF broj ignoriranih Ctrl-D (EOF) prije zatvaranja ljuske\n"
" IGNOREEOF broj zanemarenih Ctrl-D (EOF) prije zatvaranja ljuske\n"
" MACHTYPE vrsta računala na kojem se izvršava „bash“\n"
" MAILCHECK kako često (u sekundama) „bash“ gleda ima li nove pošte\n"
" MAILPATH popis datoteka koje „bash“ provjeri za novu poštu\n"
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR