]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix for history-search-backward after previous-history clearing the undo list
authorChet Ramey <chet.ramey@case.edu>
Mon, 4 Apr 2022 13:40:49 +0000 (09:40 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 4 Apr 2022 13:40:49 +0000 (09:40 -0400)
CWRU/CWRU.chlog
aclocal.m4
configure
lib/readline/histlib.h
lib/readline/history.c
lib/readline/misc.c
lib/readline/readline.c
lib/readline/search.c
po/hr.gmo
po/hr.po
tests/RUN-ONE-TEST

index a416b14fd684d4b1a89813934b9d197d7b66eeaf..5372efdc2a0611365fd4e8f56d63a7d8b6963a23 100644 (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>
index 15d914338131add7afc428603b3aaf9fc7de64a1..cc97bd4b8461528958dbd009c7c563aa97945527 100644 (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
 ])
index e9200378abcce2ebafeffe0910c6b1e7075f4961..2cdf0596a6ceb210f2db876a163e63c35b67acbf 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
 
index adaf1e50c1cb12038848166c47c5194eee6b520d..29fc4d2e5781dc24d6885f6317f2604695799002 100644 (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 *);
index a3c26c6e5df6b5ce499f74eb1f0d17fd440ed8cf..2daa362d9541bb6ce5aed973a9b9e57f317aa156 100644 (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.
index 96d37b8d6ac7d812bdcac741cb4ace286d6cc7c2..2a75847d7473117e9e6ca6708107619613c8a56d 100644 (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;
     }
index 719845050967e3f33b64954398b7de37978cde53..8fad893c187b2c652745593c8f96dce3b13eb040 100644 (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)
index 898ffe7bbb70fbcb080172dce9d3ba33d8c1b90e..ce278fd955d0e560d1117ed8a380e143cd3f1cd2 100644 (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
index dbf4f360570666401afa3d94a91c2f0ac2f80ce4..39178a315d2e2e67ba1e9a4eafda8d7122b6ecd3 100644 (file)
Binary files a/po/hr.gmo and b/po/hr.gmo differ
index 6a869e55fbb99f92491ffde16579d18656c33216..6fe53be0e40269ed3125b4985acc5c25658b299f 100644 (file)
--- a/po/hr.po
+++ b/po/hr.po
@@ -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"
index c8bef8dd12533217b1b65fc20d00f3d1cc1b81e7..0b06381072414283266cf5d055a42ac14b9b6da6 100755 (executable)
@@ -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