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));
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
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;
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++);
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. */
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)
{
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;
}
else if (line_index != sline_len)
++line_index;
else
- ding ();
+ rl_ding ();
break;
/* switch directions */
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';
if (failed)
{
/* We cannot find the search string. Ding the bell. */
- ding ();
+ rl_ding ();
i = last_found_line;
continue; /* XXX - was break */
}
free (allocated_line);
free (lines);
+ RL_UNSETSTATE(RL_STATE_ISEARCH);
+
return 0;
}