X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=readline%2Fhistsearch.c;h=1ad55d22d3010d1a74c963addd46d5d9de0b0c78;hb=4aae6e5abddb84e1225cfd696b8fd2c6832f9fb6;hp=7e98e950acb1495c982a6c346931b7b67ab3a9e3;hpb=d60d9f651ab04df95fcd31488fbb46be263382ae;p=deliverable%2Fbinutils-gdb.git diff --git a/readline/histsearch.c b/readline/histsearch.c index 7e98e950ac..1ad55d22d3 100644 --- a/readline/histsearch.c +++ b/readline/histsearch.c @@ -1,24 +1,23 @@ /* histsearch.c -- searching the history list. */ -/* Copyright (C) 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc. - This file contains the GNU History Library (the Library), a set of + This file contains the GNU History Library (History), a set of routines for managing the text of previously typed lines. - The Library is free software; you can redistribute it and/or modify + History is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 1, or (at your option) - any later version. + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - The Library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + History is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 675 Mass Ave, Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU General Public License + along with History. If not, see . +*/ #define READLINE_LIBRARY @@ -32,28 +31,23 @@ #else # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ + #if defined (HAVE_UNISTD_H) # ifdef _MINIX # include # endif # include #endif -#if defined (HAVE_STRING_H) -# include -#else -# include -#endif /* !HAVE_STRING_H */ #include "history.h" #include "histlib.h" -/* Variables imported from other history library files. */ -extern int history_offset; - /* The list of alternate characters that can delimit a history search string. */ char *history_search_delimiter_chars = (char *)NULL; +static int history_search_internal PARAMS((const char *, int, int)); + /* Search the history for STRING, starting at history_offset. If DIRECTION < 0, then the search is through previous entries, else through subsequent. If ANCHORED is non-zero, the string must @@ -66,7 +60,7 @@ char *history_search_delimiter_chars = (char *)NULL; static int history_search_internal (string, direction, anchored) - char *string; + const char *string; int direction, anchored; { register int i, reverse; @@ -82,11 +76,11 @@ history_search_internal (string, direction, anchored) if (string == 0 || *string == '\0') return (-1); - if (!history_length || ((i == history_length) && !reverse)) + if (!history_length || ((i >= history_length) && !reverse)) return (-1); - if (reverse && (i == history_length)) - i--; + if (reverse && (i >= history_length)) + i = history_length - 1; #define NEXT_LINE() do { if (reverse) i--; else i++; } while (0) @@ -162,7 +156,7 @@ history_search_internal (string, direction, anchored) /* Do a non-anchored search for STRING through the history in DIRECTION. */ int history_search (string, direction) - char *string; + const char *string; int direction; { return (history_search_internal (string, direction, NON_ANCHORED_SEARCH)); @@ -171,7 +165,7 @@ history_search (string, direction) /* Do an anchored search for string through the history in DIRECTION. */ int history_search_prefix (string, direction) - char *string; + const char *string; int direction; { return (history_search_internal (string, direction, ANCHORED_SEARCH)); @@ -182,7 +176,7 @@ history_search_prefix (string, direction) which point to begin searching. */ int history_search_pos (string, dir, pos) - char *string; + const char *string; int dir, pos; { int ret, old;