diff options
author | unknown <df@pippilotta.erinye.com> | 2007-11-19 14:38:08 +0100 |
---|---|---|
committer | unknown <df@pippilotta.erinye.com> | 2007-11-19 14:38:08 +0100 |
commit | 17146fc93d49fc4354f791f9c269fc21d5000eb6 (patch) | |
tree | 6886afa4046d456ba17671394e79a76cec21267a /cmd-line-utils/readline/history.c | |
parent | 7bb73945459e71bdd8fa1297dc3fd313306235cc (diff) | |
download | mariadb-git-17146fc93d49fc4354f791f9c269fc21d5000eb6.tar.gz |
Update readline to version 5.2. This fixes bug#18431.
cmd-line-utils/readline/INSTALL:
update readline to version 5.2
cmd-line-utils/readline/README:
update readline to version 5.2
cmd-line-utils/readline/bind.c:
update readline to version 5.2
cmd-line-utils/readline/callback.c:
update readline to version 5.2
cmd-line-utils/readline/chardefs.h:
update readline to version 5.2
cmd-line-utils/readline/compat.c:
update readline to version 5.2
cmd-line-utils/readline/complete.c:
update readline to version 5.2
cmd-line-utils/readline/configure.in:
update readline to version 5.2
cmd-line-utils/readline/display.c:
update readline to version 5.2
cmd-line-utils/readline/funmap.c:
update readline to version 5.2
cmd-line-utils/readline/histexpand.c:
update readline to version 5.2
cmd-line-utils/readline/histfile.c:
update readline to version 5.2
cmd-line-utils/readline/history.c:
update readline to version 5.2
cmd-line-utils/readline/histsearch.c:
update readline to version 5.2
cmd-line-utils/readline/input.c:
update readline to version 5.2
cmd-line-utils/readline/isearch.c:
update readline to version 5.2
cmd-line-utils/readline/keymaps.c:
update readline to version 5.2
cmd-line-utils/readline/kill.c:
update readline to version 5.2
cmd-line-utils/readline/macro.c:
update readline to version 5.2
cmd-line-utils/readline/mbutil.c:
update readline to version 5.2
cmd-line-utils/readline/misc.c:
update readline to version 5.2
cmd-line-utils/readline/nls.c:
update readline to version 5.2
cmd-line-utils/readline/parens.c:
update readline to version 5.2
cmd-line-utils/readline/readline.c:
update readline to version 5.2
cmd-line-utils/readline/readline.h:
update readline to version 5.2
cmd-line-utils/readline/rlconf.h:
update readline to version 5.2
cmd-line-utils/readline/rldefs.h:
update readline to version 5.2
cmd-line-utils/readline/rlmbutil.h:
update readline to version 5.2
cmd-line-utils/readline/rlprivate.h:
update readline to version 5.2
cmd-line-utils/readline/rltty.c:
update readline to version 5.2
cmd-line-utils/readline/savestring.c:
update readline to version 5.2
cmd-line-utils/readline/search.c:
update readline to version 5.2
cmd-line-utils/readline/shell.c:
update readline to version 5.2
cmd-line-utils/readline/signals.c:
update readline to version 5.2
cmd-line-utils/readline/terminal.c:
update readline to version 5.2
cmd-line-utils/readline/text.c:
update readline to version 5.2
cmd-line-utils/readline/tilde.c:
update readline to version 5.2
cmd-line-utils/readline/tilde.h:
update readline to version 5.2
cmd-line-utils/readline/undo.c:
update readline to version 5.2
cmd-line-utils/readline/util.c:
update readline to version 5.2
cmd-line-utils/readline/vi_keymap.c:
update readline to version 5.2
cmd-line-utils/readline/vi_mode.c:
update readline to version 5.2
cmd-line-utils/readline/xmalloc.c:
update readline to version 5.2
Diffstat (limited to 'cmd-line-utils/readline/history.c')
-rw-r--r-- | cmd-line-utils/readline/history.c | 113 |
1 files changed, 95 insertions, 18 deletions
diff --git a/cmd-line-utils/readline/history.c b/cmd-line-utils/readline/history.c index bb1960d8d99..1ccf4db786c 100644 --- a/cmd-line-utils/readline/history.c +++ b/cmd-line-utils/readline/history.c @@ -1,6 +1,6 @@ /* history.c -- standalone history library */ -/* Copyright (C) 1989-2003 Free Software Foundation, Inc. +/* Copyright (C) 1989-2005 Free Software Foundation, Inc. This file contains the GNU History Library (the Library), a set of routines for managing the text of previously typed lines. @@ -25,7 +25,9 @@ you can call. I think I have done that. */ #define READLINE_LIBRARY -#include "config_readline.h" +#if defined (HAVE_CONFIG_H) +# include <config.h> +#endif #include <stdio.h> @@ -202,11 +204,27 @@ history_get (offset) int local_index; local_index = offset - history_base; - return (local_index >= history_length || local_index < 0 || !the_history) + return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *)NULL : the_history[local_index]; } +HIST_ENTRY * +alloc_history_entry (string, ts) + char *string; + char *ts; +{ + HIST_ENTRY *temp; + + temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); + + temp->line = string ? savestring (string) : string; + temp->data = (char *)NULL; + temp->timestamp = ts; + + return temp; +} + time_t history_get_time (hist) HIST_ENTRY *hist; @@ -288,11 +306,7 @@ add_history (string) } } - temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); - temp->line = savestring (string); - temp->data = (char *)NULL; - - temp->timestamp = hist_inittime (); + temp = alloc_history_entry (string, hist_inittime ()); the_history[history_length] = (HIST_ENTRY *)NULL; the_history[history_length - 1] = temp; @@ -326,6 +340,26 @@ free_history_entry (hist) free (hist); return (x); } + +HIST_ENTRY * +copy_history_entry (hist) + HIST_ENTRY *hist; +{ + HIST_ENTRY *ret; + char *ts; + + if (hist == 0) + return hist; + + ret = alloc_history_entry (hist->line, (char *)NULL); + + ts = hist->timestamp ? savestring (hist->timestamp) : hist->timestamp; + ret->timestamp = ts; + + ret->data = hist->data; + + return ret; +} /* Make the history entry at WHICH have LINE and DATA. This returns the old entry so you can dispose of the data. In the case of an @@ -338,7 +372,7 @@ replace_history_entry (which, line, data) { HIST_ENTRY *temp, *old_value; - if (which >= history_length) + if (which < 0 || which >= history_length) return ((HIST_ENTRY *)NULL); temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); @@ -352,6 +386,51 @@ replace_history_entry (which, line, data) return (old_value); } +/* Replace the DATA in the specified history entries, replacing OLD with + NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace + all of the history entries where entry->data == OLD; WHICH == -2 means + to replace the `newest' history entry where entry->data == OLD; and + WHICH >= 0 means to replace that particular history entry's data, as + long as it matches OLD. */ +void +replace_history_data (which,old, new) + int which; + histdata_t *old, *new; +{ + HIST_ENTRY *entry; + register int i, last; + + if (which < -2 || which >= history_length || history_length == 0 || the_history == 0) + return; + + if (which >= 0) + { + entry = the_history[which]; + if (entry && entry->data == old) + entry->data = new; + return; + } + + last = -1; + for (i = 0; i < history_length; i++) + { + entry = the_history[i]; + if (entry == 0) + continue; + if (entry->data == old) + { + last = i; + if (which == -1) + entry->data = new; + } + } + if (which == -2 && last >= 0) + { + entry = the_history[last]; + entry->data = new; /* XXX - we don't check entry->old */ + } +} + /* Remove history element WHICH from the history. The removed element is returned to you so you can free the line, data, and containing structure. */ @@ -362,17 +441,15 @@ remove_history (which) HIST_ENTRY *return_value; register int i; - if (which >= history_length || !history_length) - return_value = (HIST_ENTRY *)NULL; - else - { - return_value = the_history[which]; + if (which < 0 || which >= history_length || history_length == 0 || the_history == 0) + return ((HIST_ENTRY *)NULL); - for (i = which; i < history_length; i++) - the_history[i] = the_history[i + 1]; + return_value = the_history[which]; - history_length--; - } + for (i = which; i < history_length; i++) + the_history[i] = the_history[i + 1]; + + history_length--; return (return_value); } |