X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=readline%2Fhistsearch.c;h=1cc5875a4b41f6b65821e77a01affe2abd23398f;hb=174660cedf9568db1381a8e8840a6709fcaa96f6;hp=8d153b63edd53ac237db0edb52f9f7e2b48bbc69;hpb=1b17e766659d93d1e7bd6633bf78132e1abb3568;p=deliverable%2Fbinutils-gdb.git diff --git a/readline/histsearch.c b/readline/histsearch.c index 8d153b63ed..1cc5875a4b 100644 --- a/readline/histsearch.c +++ b/readline/histsearch.c @@ -32,17 +32,13 @@ #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" @@ -51,6 +47,8 @@ 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 @@ -63,7 +61,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; @@ -79,11 +77,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) @@ -159,7 +157,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)); @@ -168,7 +166,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)); @@ -179,7 +177,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;