summaryrefslogtreecommitdiff
path: root/cmd-line-utils/readline/histsearch.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-line-utils/readline/histsearch.c')
-rw-r--r--cmd-line-utils/readline/histsearch.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd-line-utils/readline/histsearch.c b/cmd-line-utils/readline/histsearch.c
index ffc97d720db..1cc5875a4b4 100644
--- a/cmd-line-utils/readline/histsearch.c
+++ b/cmd-line-utils/readline/histsearch.c
@@ -22,7 +22,9 @@
#define READLINE_LIBRARY
-#include "config_readline.h"
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
#include <stdio.h>
#if defined (HAVE_STDLIB_H)
@@ -75,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)