mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-02 09:50:50 +02:00
readline changes to use xfree; bumped version to bash-5.2-beta
This commit is contained in:
@@ -1981,7 +1981,7 @@ compare_match (char *text, const char *match)
|
||||
{
|
||||
temp = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
|
||||
r = strcmp (temp, match);
|
||||
free (temp);
|
||||
xfree (temp);
|
||||
return r;
|
||||
}
|
||||
return (strcmp (text, match));
|
||||
|
||||
@@ -536,7 +536,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
|
||||
*vlp = physchars;
|
||||
|
||||
if (nprompt != pmt)
|
||||
free (nprompt);
|
||||
xfree (nprompt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ read_history_range (const char *filename, int from, int to)
|
||||
|
||||
if (file_size == 0)
|
||||
{
|
||||
free (input);
|
||||
xfree (input);
|
||||
close (file);
|
||||
return 0; /* don't waste time if we don't have to */
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ _hs_history_patsearch (const char *string, int direction, int flags)
|
||||
ret = history_search_internal (pat, direction, flags|PATTERN_SEARCH);
|
||||
|
||||
if (pat != string)
|
||||
free (pat);
|
||||
xfree (pat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -679,7 +679,7 @@ opcode_dispatch:
|
||||
paste = _rl_bracketed_text (&pastelen);
|
||||
if (paste == 0 || *paste == 0)
|
||||
{
|
||||
free (paste);
|
||||
xfree (paste);
|
||||
break;
|
||||
}
|
||||
if (_rl_enable_active_region)
|
||||
@@ -692,7 +692,7 @@ opcode_dispatch:
|
||||
memcpy (cxt->search_string + cxt->search_string_index, paste, pastelen);
|
||||
cxt->search_string_index += pastelen;
|
||||
cxt->search_string[cxt->search_string_index] = '\0';
|
||||
free (paste);
|
||||
xfree (paste);
|
||||
break;
|
||||
|
||||
/* Add character to search string and continue search. */
|
||||
|
||||
@@ -388,23 +388,12 @@ _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 = (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;
|
||||
}
|
||||
|
||||
@@ -492,12 +492,8 @@ 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 defined (HISTORY_SEARCH_SETS_HISTPOS)
|
||||
if (entry && rl_undo_list && _rl_history_search_pos != where_history ())
|
||||
#else
|
||||
if (entry && rl_undo_list)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
temp = savestring (the_line);
|
||||
rl_revert_line (1, 0);
|
||||
entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
|
||||
|
||||
+1
-40
@@ -84,14 +84,12 @@ 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 */
|
||||
@@ -106,7 +104,6 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
rl_free_undo_list ();
|
||||
#endif
|
||||
|
||||
#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
|
||||
@@ -115,7 +112,6 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
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
|
||||
@@ -204,10 +200,6 @@ 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)
|
||||
{
|
||||
@@ -538,20 +530,11 @@ rl_history_search_internal (int count, int dir)
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int ret, oldpos, newcol;
|
||||
UNDO_LIST *origlist;
|
||||
int had_saved_line, origpos;
|
||||
int had_saved_line;
|
||||
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
|
||||
@@ -606,28 +589,6 @@ rl_history_search_internal (int count, int dir)
|
||||
/* Copy the line we found into the current line buffer. */
|
||||
make_history_line_current (temp);
|
||||
|
||||
/* 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. */
|
||||
origlist = rl_undo_list;
|
||||
rl_undo_list = 0; /* XXX - was (UNDO_LIST *)temp->data */
|
||||
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);
|
||||
rl_undo_list = origlist;
|
||||
#endif
|
||||
|
||||
/* decide where to put rl_point -- need to change this for pattern search */
|
||||
if (_rl_history_search_flags & ANCHORED_SEARCH)
|
||||
rl_point = _rl_history_search_len; /* easy case */
|
||||
|
||||
@@ -824,7 +824,7 @@ _rl_reset_region_color (int which, const char *value)
|
||||
|
||||
if (which == 0)
|
||||
{
|
||||
free (_rl_active_region_start_color);
|
||||
xfree (_rl_active_region_start_color);
|
||||
if (value && *value)
|
||||
{
|
||||
_rl_active_region_start_color = (char *)xmalloc (2 * strlen (value) + 1);
|
||||
@@ -836,7 +836,7 @@ _rl_reset_region_color (int which, const char *value)
|
||||
}
|
||||
else
|
||||
{
|
||||
free (_rl_active_region_end_color);
|
||||
xfree (_rl_active_region_end_color);
|
||||
if (value && *value)
|
||||
{
|
||||
_rl_active_region_end_color = (char *)xmalloc (2 * strlen (value) + 1);
|
||||
|
||||
Reference in New Issue
Block a user