mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-09 05:00:49 +02:00
efficiency change to command hashing; fix pointer aliasing problem with readline history-search-backward
This commit is contained in:
+9
-1
@@ -50,6 +50,7 @@
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "histlib.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
@@ -381,6 +382,8 @@ rl_maybe_save_line (void)
|
||||
int
|
||||
_rl_free_saved_history_line (void)
|
||||
{
|
||||
UNDO_LIST *orig;
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
|
||||
@@ -390,7 +393,12 @@ _rl_free_saved_history_line (void)
|
||||
callers that know this is _rl_saved_line_for_history can know that
|
||||
it's an undo list. */
|
||||
if (_rl_saved_line_for_history->data)
|
||||
_rl_free_undo_list ((UNDO_LIST *)_rl_saved_line_for_history->data);
|
||||
{
|
||||
orig = rl_undo_list;
|
||||
rl_undo_list = _rl_saved_line_for_history->data;
|
||||
rl_free_undo_list ();
|
||||
rl_undo_list = orig;
|
||||
}
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,11 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
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 ();
|
||||
|
||||
/* 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);
|
||||
@@ -100,11 +105,6 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
current editing buffer. */
|
||||
rl_free_undo_list ();
|
||||
#endif
|
||||
|
||||
/* 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 ();
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
|
||||
Reference in New Issue
Block a user