aboutsummaryrefslogtreecommitdiff
path: root/readline/misc.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-10-07 12:52:13 -0600
committerTom Tromey <tom@tromey.com>2019-08-12 10:57:56 -0600
commit775e241e9c5f2b2ff2b59972ab70e5f20763fae6 (patch)
tree597ab643dce69ee6e98e46ecac00ee85f447bb4b /readline/misc.c
parent08132bdd876fa1825810f90ecc25390dd4ded457 (diff)
downloadgdb-775e241e9c5f2b2ff2b59972ab70e5f20763fae6.zip
gdb-775e241e9c5f2b2ff2b59972ab70e5f20763fae6.tar.gz
gdb-775e241e9c5f2b2ff2b59972ab70e5f20763fae6.tar.bz2
Import readline 7.0 (patch 5)
This imports readline 7.0 (up to patch 5) while preserving all gdb-local changes. This was done by checking out the readline git repository, making a branch based on the gdb baseline revision, applying the gdb changes to that branch, and then merging from readline 7. readline/ChangeLog.gdb 2019-08-12 Tom Tromey <tom@tromey.com> * Imported readline 7.0 patch 5.
Diffstat (limited to 'readline/misc.c')
-rw-r--r--readline/misc.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/readline/misc.c b/readline/misc.c
index 9f45773..f7acdee 100644
--- a/readline/misc.c
+++ b/readline/misc.c
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -126,7 +126,7 @@ _rl_arg_dispatch (cxt, c)
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
- if (_rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
+ if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
{
if ((cxt & NUM_SAWDIGITS) == 0)
{
@@ -266,6 +266,8 @@ _rl_arg_callback (cxt)
int c, r;
c = _rl_arg_getchar ();
+ if (c < 0)
+ return (1); /* EOF */
if (_rl_argcxt & NUM_READONE)
{
@@ -459,6 +461,7 @@ _rl_revert_all_lines ()
saved_undo_list = 0;
/* Set up rl_line_buffer and other variables from history entry */
rl_replace_from_history (entry, 0); /* entry->line is now current */
+ entry->data = 0; /* entry->data is now current undo list */
/* Undo all changes to this history entry */
while (rl_undo_list)
rl_do_undo ();
@@ -466,7 +469,6 @@ _rl_revert_all_lines ()
the timestamp. */
FREE (entry->line);
entry->line = savestring (rl_line_buffer);
- entry->data = 0;
}
entry = previous_history ();
}
@@ -483,6 +485,37 @@ _rl_revert_all_lines ()
xfree (lbuf);
}
+/* Free the history list, including private readline data and take care
+ of pointer aliases to history data. Resets rl_undo_list if it points
+ to an UNDO_LIST * saved as some history entry's data member. This
+ should not be called while editing is active. */
+void
+rl_clear_history ()
+{
+ HIST_ENTRY **hlist, *hent;
+ register int i;
+ UNDO_LIST *ul, *saved_undo_list;
+
+ saved_undo_list = rl_undo_list;
+ hlist = history_list (); /* direct pointer, not copy */
+
+ for (i = 0; i < history_length; i++)
+ {
+ hent = hlist[i];
+ if (ul = (UNDO_LIST *)hent->data)
+ {
+ if (ul == saved_undo_list)
+ saved_undo_list = 0;
+ _rl_free_undo_list (ul);
+ hent->data = 0;
+ }
+ _rl_free_history_entry (hent);
+ }
+
+ history_offset = history_length = 0;
+ rl_undo_list = saved_undo_list; /* should be NULL */
+}
+
/* **************************************************************** */
/* */
/* History Commands */
@@ -623,6 +656,10 @@ rl_emacs_editing_mode (count, key)
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
+
+ if (_rl_show_mode_in_prompt)
+ _rl_reset_prompt ();
+
return 0;
}