summaryrefslogtreecommitdiff
path: root/isearch.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-23 19:00:13 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-23 19:00:13 -0500
commitf8d82ba21c017f4d23a0ee77ecb13d8d3ff1aab7 (patch)
treeacf568c234913c50f2cc159bdf4973e6f697a879 /isearch.c
parent2916980bde9ae4d8b8e9d60062660bdca947f56e (diff)
downloadreadline-f8d82ba21c017f4d23a0ee77ecb13d8d3ff1aab7.tar.gz
Readline-4.2 import
Diffstat (limited to 'isearch.c')
-rw-r--r--isearch.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/isearch.c b/isearch.c
index 952c10d..f8d7695 100644
--- a/isearch.c
+++ b/isearch.c
@@ -55,7 +55,7 @@
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
/* Variables imported from other files in the readline library. */
-extern HIST_ENTRY *saved_line_for_history;
+extern HIST_ENTRY *_rl_saved_line_for_history;
/* Forward declarations */
static int rl_search_history __P((int, int));
@@ -64,6 +64,8 @@ static int rl_search_history __P((int, int));
identical lines many times in a row. */
static char *prev_line_found;
+static unsigned char *default_isearch_terminators = "\033\012";
+
/* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
@@ -176,6 +178,7 @@ rl_search_history (direction, invoking_key)
been set, we use that value, otherwise we use ESC and C-J. */
unsigned char *isearch_terminators;
+ RL_SETSTATE(RL_STATE_ISEARCH);
orig_point = rl_point;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
@@ -183,10 +186,10 @@ rl_search_history (direction, invoking_key)
allocated_line = (char *)NULL;
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
- : (unsigned char *)"\033\012";
+ : default_isearch_terminators;
/* Create an arrary of pointers to the lines that we want to search. */
- maybe_replace_line ();
+ rl_maybe_replace_line ();
i = 0;
if (hlist)
for (i = 0; hlist[i]; i++);
@@ -197,8 +200,8 @@ rl_search_history (direction, invoking_key)
for (i = 0; i < hlen; i++)
lines[i] = hlist[i]->line;
- if (saved_line_for_history)
- lines[i] = saved_line_for_history->line;
+ if (_rl_saved_line_for_history)
+ lines[i] = _rl_saved_line_for_history->line;
else
{
/* Keep track of this so we can free it. */
@@ -232,10 +235,12 @@ rl_search_history (direction, invoking_key)
found = failed = 0;
for (;;)
{
- Function *f = (Function *)NULL;
+ rl_command_func_t *f = (rl_command_func_t *)NULL;
/* Read a key and decide how to proceed. */
+ RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
+ RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC)
{
@@ -273,6 +278,8 @@ rl_search_history (direction, invoking_key)
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
{
+ /* This sets rl_pending_input to c; it will be picked up the next
+ time rl_read_key is called. */
rl_execute_next (c);
break;
}
@@ -287,7 +294,7 @@ rl_search_history (direction, invoking_key)
else if (line_index != sline_len)
++line_index;
else
- ding ();
+ rl_ding ();
break;
/* switch directions */
@@ -305,13 +312,14 @@ rl_search_history (direction, invoking_key)
if (allocated_line)
free (allocated_line);
free (lines);
+ RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
#if 0
/* delete character from search string. */
case -3:
if (search_string_index == 0)
- ding ();
+ rl_ding ();
else
{
search_string[--search_string_index] = '\0';
@@ -384,7 +392,7 @@ rl_search_history (direction, invoking_key)
if (failed)
{
/* We cannot find the search string. Ding the bell. */
- ding ();
+ rl_ding ();
i = last_found_line;
continue; /* XXX - was break */
}
@@ -438,5 +446,7 @@ rl_search_history (direction, invoking_key)
free (allocated_line);
free (lines);
+ RL_UNSETSTATE(RL_STATE_ISEARCH);
+
return 0;
}