diff options
author | ache <ache@FreeBSD.org> | 2006-03-27 22:47:12 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2006-03-27 22:47:12 +0000 |
commit | 8aeb9782f4a5d98c23b918bdae2477810088d0d1 (patch) | |
tree | 5e38d670d1899750fd24e8f171fd03d714ab0681 /contrib/libreadline/history.c | |
parent | 17222c720e12474e93a40d68fd9646bad49690a7 (diff) | |
download | FreeBSD-src-8aeb9782f4a5d98c23b918bdae2477810088d0d1.zip FreeBSD-src-8aeb9782f4a5d98c23b918bdae2477810088d0d1.tar.gz |
Virgin import of GNU Readline 5.1
Diffstat (limited to 'contrib/libreadline/history.c')
-rw-r--r-- | contrib/libreadline/history.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/contrib/libreadline/history.c b/contrib/libreadline/history.c index d99b76e..a538f91 100644 --- a/contrib/libreadline/history.c +++ b/contrib/libreadline/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. @@ -204,7 +204,7 @@ 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]; } @@ -340,7 +340,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)); @@ -364,17 +364,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); } |