aboutsummaryrefslogtreecommitdiff
path: root/readline/history.c
diff options
context:
space:
mode:
authorElena Zannoni <ezannoni@kwikemart.cygnus.com>2002-12-08 22:31:39 +0000
committerElena Zannoni <ezannoni@kwikemart.cygnus.com>2002-12-08 22:31:39 +0000
commit9255ee3150832d7e235fc0711f0efa70700559e7 (patch)
tree97d578647cc7f257e42ce12fa74e570b783ee0b9 /readline/history.c
parentffbceea9fb49e8dd28c88a4b59cf8616b2dcc210 (diff)
downloadgdb-9255ee3150832d7e235fc0711f0efa70700559e7.zip
gdb-9255ee3150832d7e235fc0711f0efa70700559e7.tar.gz
gdb-9255ee3150832d7e235fc0711f0efa70700559e7.tar.bz2
Import of readline 4.3.
Non-readline modified files: src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog src/gdb/tui/tuiWin.c In readline directory: * compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h, text.c, doc/history.0, doc/history.3, support/wcwidth.c, examples/readlinebuf.h, examples/rlcat.c: New files. * CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README, aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h, complete.c, config.h.in, configure, configure.in, display.c, emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h, history.c, history.h, histsearch.c, input.c, isearch.c, keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c, posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h, rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c, search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h, undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h, doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo, doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3, doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html, shlib/Makefile.in, support/install.sh, support/mkdirs, support/mkdist, support/shlib-install, support/shobj-conf, examples/Inputrc, examples/Makefile.in, examples/fileman.c, examples/histexamp.c, examples/manexamp.c, examples/rl.c, examples/rlfe.c, examples/rltest.c, examples/rlversion.c: Modified files.
Diffstat (limited to 'readline/history.c')
-rw-r--r--readline/history.c51
1 files changed, 22 insertions, 29 deletions
diff --git a/readline/history.c b/readline/history.c
index 400f18b..4242f33 100644
--- a/readline/history.c
+++ b/readline/history.c
@@ -44,12 +44,6 @@
# include <unistd.h>
#endif
-#if defined (HAVE_STRING_H)
-# include <string.h>
-#else
-# include <strings.h>
-#endif /* !HAVE_STRING_H */
-
#include "history.h"
#include "histlib.h"
@@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
history that we save. */
static int history_stifled;
+/* The current number of slots allocated to the input_history. */
+static int history_size;
+
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
entries to remember. */
-int max_input_history;
+int history_max_entries;
+int max_input_history; /* backwards compatibility */
/* The current location of the interactive history pointer. Just makes
life easier for outside callers. */
@@ -82,9 +80,6 @@ int history_offset;
/* The number of strings currently stored in the history list. */
int history_length;
-/* The current number of slots allocated to the input_history. */
-static int history_size;
-
/* The logical `base' of the history array. It defaults to 1. */
int history_base = 1;
@@ -134,9 +129,7 @@ history_total_bytes ()
{
register int i, result;
- result = 0;
-
- for (i = 0; the_history && the_history[i]; i++)
+ for (i = result = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line);
return (result);
@@ -217,16 +210,16 @@ history_get (offset)
is set to NULL. */
void
add_history (string)
- char *string;
+ const char *string;
{
HIST_ENTRY *temp;
- if (history_stifled && (history_length == max_input_history))
+ if (history_stifled && (history_length == history_max_entries))
{
register int i;
/* If the history is stifled, and history_length is zero,
- and it equals max_input_history, we don't save items. */
+ and it equals history_max_entries, we don't save items. */
if (history_length == 0)
return;
@@ -277,15 +270,15 @@ add_history (string)
HIST_ENTRY *
replace_history_entry (which, line, data)
int which;
- char *line;
+ const char *line;
histdata_t data;
{
- HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
- HIST_ENTRY *old_value;
+ HIST_ENTRY *temp, *old_value;
if (which >= history_length)
return ((HIST_ENTRY *)NULL);
+ temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
old_value = the_history[which];
temp->line = savestring (line);
@@ -303,12 +296,12 @@ remove_history (which)
int which;
{
HIST_ENTRY *return_value;
+ register int i;
if (which >= history_length || !history_length)
return_value = (HIST_ENTRY *)NULL;
else
{
- register int i;
return_value = the_history[which];
for (i = which; i < history_length; i++)
@@ -325,13 +318,13 @@ void
stifle_history (max)
int max;
{
+ register int i, j;
+
if (max < 0)
max = 0;
if (history_length > max)
{
- register int i, j;
-
/* This loses because we cannot free the data. */
for (i = 0, j = history_length - max; i < j; i++)
{
@@ -347,22 +340,22 @@ stifle_history (max)
}
history_stifled = 1;
- max_input_history = max;
+ max_input_history = history_max_entries = max;
}
-/* Stop stifling the history. This returns the previous amount the
- history was stifled by. The value is positive if the history was
- stifled, negative if it wasn't. */
+/* Stop stifling the history. This returns the previous maximum
+ number of history entries. The value is positive if the history
+ was stifled, negative if it wasn't. */
int
unstifle_history ()
{
if (history_stifled)
{
history_stifled = 0;
- return (-max_input_history);
+ return (history_max_entries);
}
-
- return (max_input_history);
+ else
+ return (-history_max_entries);
}
int