OpenCoverage

isearch.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/isearch.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* isearch.c - incremental searching */-
2-
3/* **************************************************************** */-
4/* */-
5/* I-Search and Searching */-
6/* */-
7/* **************************************************************** */-
8-
9/* Copyright (C) 1987-2017 Free Software Foundation, Inc.-
10-
11 This file is part of the GNU Readline Library (Readline), a library-
12 for reading lines of text with interactive input and history editing. -
13-
14 Readline is free software: you can redistribute it and/or modify-
15 it under the terms of the GNU General Public License as published by-
16 the Free Software Foundation, either version 3 of the License, or-
17 (at your option) any later version.-
18-
19 Readline is distributed in the hope that it will be useful,-
20 but WITHOUT ANY WARRANTY; without even the implied warranty of-
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
22 GNU General Public License for more details.-
23-
24 You should have received a copy of the GNU General Public License-
25 along with Readline. If not, see <http://www.gnu.org/licenses/>.-
26*/-
27-
28#define READLINE_LIBRARY-
29-
30#if defined (HAVE_CONFIG_H)-
31# include <config.h>-
32#endif-
33-
34#include <sys/types.h>-
35-
36#include <stdio.h>-
37-
38#if defined (HAVE_UNISTD_H)-
39# include <unistd.h>-
40#endif-
41-
42#if defined (HAVE_STDLIB_H)-
43# include <stdlib.h>-
44#else-
45# include "ansi_stdlib.h"-
46#endif-
47-
48#include "rldefs.h"-
49#include "rlmbutil.h"-
50-
51#include "readline.h"-
52#include "history.h"-
53-
54#include "rlprivate.h"-
55#include "xmalloc.h"-
56-
57/* Variables exported to other files in the readline library. */-
58char *_rl_isearch_terminators = (char *)NULL;-
59-
60_rl_search_cxt *_rl_iscxt = 0;-
61-
62/* Variables imported from other files in the readline library. */-
63extern HIST_ENTRY *_rl_saved_line_for_history;-
64-
65static int rl_search_history PARAMS((int, int));-
66-
67static _rl_search_cxt *_rl_isearch_init PARAMS((int));-
68static void _rl_isearch_fini PARAMS((_rl_search_cxt *));-
69-
70/* Last line found by the current incremental search, so we don't `find'-
71 identical lines many times in a row. Now part of isearch context. */-
72/* static char *prev_line_found; */-
73-
74/* Last search string and its length. */-
75static char *last_isearch_string;-
76static int last_isearch_string_len;-
77-
78static char * const default_isearch_terminators = "\033\012";-
79-
80_rl_search_cxt *-
81_rl_scxt_alloc (int type, int flags)-
82{-
83 _rl_search_cxt *cxt;-
84-
85 cxt = (_rl_search_cxt *)xmalloc (sizeof (_rl_search_cxt));-
86-
87 cxt->type = type;-
88 cxt->sflags = flags;-
89-
90 cxt->search_string = 0;-
91 cxt->search_string_size = cxt->search_string_index = 0;-
92-
93 cxt->lines = 0;-
94 cxt->allocated_line = 0;-
95 cxt->hlen = cxt->hindex = 0;-
96-
97 cxt->save_point = rl_point;-
98 cxt->save_mark = rl_mark;-
99 cxt->save_line = where_history ();-
100 cxt->last_found_line = cxt->save_line;-
101 cxt->prev_line_found = 0;-
102-
103 cxt->save_undo_list = 0;-
104-
105 cxt->keymap = _rl_keymap;-
106 cxt->okeymap = _rl_keymap;-
107-
108 cxt->history_pos = 0;-
109 cxt->direction = 0;-
110-
111 cxt->prevc = cxt->lastc = 0;-
112-
113 cxt->sline = 0;-
114 cxt->sline_len = cxt->sline_index = 0;-
115-
116 cxt->search_terminators = 0;-
117-
118 return cxt;
never executed: return cxt;
0
119}-
120-
121void-
122_rl_scxt_dispose (_rl_search_cxt *cxt, int flags)-
123{-
124 FREE (cxt->search_string);
never executed: free (cxt->search_string);
cxt->search_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
125 FREE (cxt->allocated_line);
never executed: free (cxt->allocated_line);
cxt->allocated_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 FREE (cxt->lines);
never executed: free (cxt->lines);
cxt->linesDescription
TRUEnever evaluated
FALSEnever evaluated
0
127-
128 xfree (cxt);-
129}
never executed: end of block
0
130-
131/* Search backwards through the history looking for a string which is typed-
132 interactively. Start with the current line. */-
133int-
134rl_reverse_search_history (int sign, int key)-
135{-
136 return (rl_search_history (-sign, key));
never executed: return (rl_search_history (-sign, key));
0
137}-
138-
139/* Search forwards through the history looking for a string which is typed-
140 interactively. Start with the current line. */-
141int-
142rl_forward_search_history (int sign, int key)-
143{-
144 return (rl_search_history (sign, key));
never executed: return (rl_search_history (sign, key));
0
145}-
146-
147/* Display the current state of the search in the echo-area.-
148 SEARCH_STRING contains the string that is being searched for,-
149 DIRECTION is zero for forward, or non-zero for reverse,-
150 WHERE is the history list number of the current line. If it is-
151 -1, then this line is the starting one. */-
152static void-
153rl_display_search (char *search_string, int flags, int where)-
154{-
155 char *message;-
156 int msglen, searchlen;-
157-
158 searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
search_stringDescription
TRUEnever evaluated
FALSEnever evaluated
*search_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
159-
160 message = (char *)xmalloc (searchlen + 64);-
161 msglen = 0;-
162-
163#if defined (NOTDEF)-
164 if (where != -1)-
165 {-
166 sprintf (message, "[%d]", where + history_base);-
167 msglen = strlen (message);-
168 }-
169#endif /* NOTDEF */-
170-
171 message[msglen++] = '(';-
172-
173 if (flags & SF_FAILED)
flags & 0x04Description
TRUEnever evaluated
FALSEnever evaluated
0
174 {-
175 strcpy (message + msglen, "failed ");-
176 msglen += 7;-
177 }
never executed: end of block
0
178-
179 if (flags & SF_REVERSE)
flags & 0x01Description
TRUEnever evaluated
FALSEnever evaluated
0
180 {-
181 strcpy (message + msglen, "reverse-");-
182 msglen += 8;-
183 }
never executed: end of block
0
184-
185 strcpy (message + msglen, "i-search)`");-
186 msglen += 10;-
187-
188 if (search_string)
search_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
189 {-
190 strcpy (message + msglen, search_string);-
191 msglen += searchlen;-
192 }
never executed: end of block
0
193-
194 strcpy (message + msglen, "': ");-
195-
196 rl_message ("%s", message);-
197 xfree (message);-
198 (*rl_redisplay_function) ();-
199}
never executed: end of block
0
200-
201static _rl_search_cxt *-
202_rl_isearch_init (int direction)-
203{-
204 _rl_search_cxt *cxt;-
205 register int i;-
206 HIST_ENTRY **hlist;-
207-
208 cxt = _rl_scxt_alloc (RL_SEARCH_ISEARCH, 0);-
209 if (direction < 0)
direction < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
210 cxt->sflags |= SF_REVERSE;
never executed: cxt->sflags |= 0x01;
0
211-
212 cxt->search_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
_rl_isearch_terminatorsDescription
TRUEnever evaluated
FALSEnever evaluated
0
213 : default_isearch_terminators;-
214-
215 /* Create an array of pointers to the lines that we want to search. */-
216 hlist = history_list ();-
217 rl_maybe_replace_line ();-
218 i = 0;-
219 if (hlist)
hlistDescription
TRUEnever evaluated
FALSEnever evaluated
0
220 for (i = 0; hlist[i]; i++);
never executed: ;
hlist[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
221-
222 /* Allocate space for this many lines, +1 for the current input line,-
223 and remember those lines. */-
224 cxt->lines = (char **)xmalloc ((1 + (cxt->hlen = i)) * sizeof (char *));-
225 for (i = 0; i < cxt->hlen; i++)
i < cxt->hlenDescription
TRUEnever evaluated
FALSEnever evaluated
0
226 cxt->lines[i] = hlist[i]->line;
never executed: cxt->lines[i] = hlist[i]->line;
0
227-
228 if (_rl_saved_line_for_history)
_rl_saved_line_for_historyDescription
TRUEnever evaluated
FALSEnever evaluated
0
229 cxt->lines[i] = _rl_saved_line_for_history->line;
never executed: cxt->lines[i] = _rl_saved_line_for_history->line;
0
230 else-
231 {-
232 /* Keep track of this so we can free it. */-
233 cxt->allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));-
234 strcpy (cxt->allocated_line, &rl_line_buffer[0]);-
235 cxt->lines[i] = cxt->allocated_line;-
236 }
never executed: end of block
0
237-
238 cxt->hlen++;-
239-
240 /* The line where we start the search. */-
241 cxt->history_pos = cxt->save_line;-
242-
243 rl_save_prompt ();-
244-
245 /* Initialize search parameters. */-
246 cxt->search_string = (char *)xmalloc (cxt->search_string_size = 128);-
247 cxt->search_string[cxt->search_string_index = 0] = '\0';-
248-
249 /* Normalize DIRECTION into 1 or -1. */-
250 cxt->direction = (direction >= 0) ? 1 : -1;
(direction >= 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
251-
252 cxt->sline = rl_line_buffer;-
253 cxt->sline_len = strlen (cxt->sline);-
254 cxt->sline_index = rl_point;-
255-
256 _rl_iscxt = cxt; /* save globally */-
257-
258 return cxt;
never executed: return cxt;
0
259}-
260-
261static void-
262_rl_isearch_fini (_rl_search_cxt *cxt)-
263{-
264 /* First put back the original state. */-
265 rl_replace_line (cxt->lines[cxt->save_line], 0);-
266-
267 rl_restore_prompt ();-
268-
269 /* Save the search string for possible later use. */-
270 FREE (last_isearch_string);
never executed: free (last_isearch_string);
last_isearch_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
271 last_isearch_string = cxt->search_string;-
272 last_isearch_string_len = cxt->search_string_index;-
273 cxt->search_string = 0;-
274-
275 if (cxt->last_found_line < cxt->save_line)
cxt->last_foun...cxt->save_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
276 rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
never executed: rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
0
277 else-
278 rl_get_next_history (cxt->last_found_line - cxt->save_line, 0);
never executed: rl_get_next_history (cxt->last_found_line - cxt->save_line, 0);
0
279-
280 /* If the string was not found, put point at the end of the last matching-
281 line. If last_found_line == orig_line, we didn't find any matching-
282 history lines at all, so put point back in its original position. */-
283 if (cxt->sline_index < 0)
cxt->sline_index < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
284 {-
285 if (cxt->last_found_line == cxt->save_line)
cxt->last_foun...cxt->save_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
286 cxt->sline_index = cxt->save_point;
never executed: cxt->sline_index = cxt->save_point;
0
287 else-
288 cxt->sline_index = strlen (rl_line_buffer);
never executed: cxt->sline_index = strlen (rl_line_buffer);
0
289 rl_mark = cxt->save_mark;-
290 }
never executed: end of block
0
291-
292 rl_point = cxt->sline_index;-
293 /* Don't worry about where to put the mark here; rl_get_previous_history-
294 and rl_get_next_history take care of it. */-
295 _rl_fix_point (0);-
296-
297 rl_clear_message ();-
298}
never executed: end of block
0
299-
300int-
301_rl_search_getchar (_rl_search_cxt *cxt)-
302{-
303 int c;-
304-
305 /* Read a key and decide how to proceed. */-
306 RL_SETSTATE(RL_STATE_MOREINPUT);-
307 c = cxt->lastc = rl_read_key ();-
308 RL_UNSETSTATE(RL_STATE_MOREINPUT);-
309-
310#if defined (HANDLE_MULTIBYTE)-
311 /* This ends up with C (and LASTC) being set to the last byte of the-
312 multibyte character. In most cases c == lastc == mb[0] */-
313 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
314 c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
never executed: c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, 16 );
0
315#endif-
316-
317 RL_CHECK_SIGNALS ();
never executed: _rl_signal_handler (_rl_caught_signal);
_rl_caught_signalDescription
TRUEnever evaluated
FALSEnever evaluated
0
318 return c;
never executed: return c;
0
319}-
320-
321#define ENDSRCH_CHAR(c) \-
322 ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))-
323-
324/* Process just-read character C according to isearch context CXT. Return-
325 -1 if the caller should just free the context and return, 0 if we should-
326 break out of the loop, and 1 if we should continue to read characters. */-
327int-
328_rl_isearch_dispatch (_rl_search_cxt *cxt, int c)-
329{-
330 int n, wstart, wlen, limit, cval;-
331 rl_command_func_t *f;-
332-
333 f = (rl_command_func_t *)NULL;-
334-
335 if (c < 0)
c < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
336 {-
337 cxt->sflags |= SF_FAILED;-
338 cxt->history_pos = cxt->last_found_line;-
339 return -1;
never executed: return -1;
0
340 }-
341-
342 /* If we are moving into a new keymap, modify cxt->keymap and go on.-
343 This can be a problem if c == ESC and we want to terminate the-
344 incremental search, so we check */-
345 if (c >= 0 && cxt->keymap[c].type == ISKMAP && strchr (cxt->search_terminators, cxt->lastc) == 0)
c >= 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->keymap[c].type == 1Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...lastc ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( cxt->lastc )Description
TRUEnever evaluated
FALSEnever evaluated
!__builtin_con..._terminators )Description
TRUEnever evaluated
FALSEnever evaluated
( cxt->lastc ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
346 {-
347 /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued-
348 takes microseconds, so multiply by 1000. If we don't get any-
349 additional input and this keymap shadows another function, process-
350 that key as if it was all we read. */-
351 if (_rl_keyseq_timeout > 0 &&
_rl_keyseq_timeout > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
352 RL_ISSTATE (RL_STATE_CALLBACK) == 0 &&
(rl_readline_s...0080000)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
353 RL_ISSTATE (RL_STATE_INPUTPENDING) == 0 &&
(rl_readline_s...0020000)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
354 _rl_pushed_input_available () == 0 &&
_rl_pushed_inp...ilable () == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
355 ((Keymap)(cxt->keymap[c].function))[ANYOTHERKEY].function &&
((Keymap)(cxt-...7 -1].functionDescription
TRUEnever evaluated
FALSEnever evaluated
0
356 _rl_input_queued (_rl_keyseq_timeout*1000) == 0)
_rl_input_queu...out*1000) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
357 goto add_character;
never executed: goto add_character;
0
358-
359 cxt->okeymap = cxt->keymap;-
360 cxt->keymap = FUNCTION_TO_KEYMAP (cxt->keymap, c);-
361 cxt->sflags |= SF_CHGKMAP;-
362 /* XXX - we should probably save this sequence, so we can do-
363 something useful if this doesn't end up mapping to a command we-
364 interpret here. Right now we just save the most recent character-
365 that caused the index into a new keymap. */-
366 cxt->prevc = c;-
367#if defined (HANDLE_MULTIBYTE)-
368 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
369 {-
370 if (cxt->mb[1] == 0)
cxt->mb[1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
371 {-
372 cxt->pmb[0] = c; /* XXX should be == cxt->mb[0] */-
373 cxt->pmb[1] = '\0';-
374 }
never executed: end of block
0
375 else-
376 memcpy (cxt->pmb, cxt->mb, sizeof (cxt->pmb));
never executed: memcpy (cxt->pmb, cxt->mb, sizeof (cxt->pmb));
0
377 }-
378#endif-
379 return 1;
never executed: return 1;
0
380 }-
381-
382add_character:
code before this statement never executed: add_character:
0
383-
384 /* Translate the keys we do something with to opcodes. */-
385 if (c >= 0 && cxt->keymap[c].type == ISFUNC)
c >= 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->keymap[c].type == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
386 {-
387 f = cxt->keymap[c].function;-
388-
389 if (f == rl_reverse_search_history)
f == rl_reverse_search_historyDescription
TRUEnever evaluated
FALSEnever evaluated
0
390 cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
never executed: cxt->lastc = (cxt->sflags & 0x01) ? -1 : -2;
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
391 else if (f == rl_forward_search_history)
f == rl_forward_search_historyDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1;
never executed: cxt->lastc = (cxt->sflags & 0x01) ? -2 : -1;
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
393 else if (f == rl_rubout)
f == rl_ruboutDescription
TRUEnever evaluated
FALSEnever evaluated
0
394 cxt->lastc = -3;
never executed: cxt->lastc = -3;
0
395 else if (c == CTRL ('G') || f == rl_abort)
c == (('G') & 0x1f)Description
TRUEnever evaluated
FALSEnever evaluated
f == rl_abortDescription
TRUEnever evaluated
FALSEnever evaluated
0
396 cxt->lastc = -4;
never executed: cxt->lastc = -4;
0
397 else if (c == CTRL ('W') || f == rl_unix_word_rubout) /* XXX */
c == (('W') & 0x1f)Description
TRUEnever evaluated
FALSEnever evaluated
f == rl_unix_word_ruboutDescription
TRUEnever evaluated
FALSEnever evaluated
0
398 cxt->lastc = -5;
never executed: cxt->lastc = -5;
0
399 else if (c == CTRL ('Y') || f == rl_yank) /* XXX */
c == (('Y') & 0x1f)Description
TRUEnever evaluated
FALSEnever evaluated
f == rl_yankDescription
TRUEnever evaluated
FALSEnever evaluated
0
400 cxt->lastc = -6;
never executed: cxt->lastc = -6;
0
401 }
never executed: end of block
0
402-
403 /* If we changed the keymap earlier while translating a key sequence into-
404 a command, restore it now that we've succeeded. */-
405 if (cxt->sflags & SF_CHGKMAP)
cxt->sflags & 0x08Description
TRUEnever evaluated
FALSEnever evaluated
0
406 {-
407 cxt->keymap = cxt->okeymap;-
408 cxt->sflags &= ~SF_CHGKMAP;-
409 /* If we indexed into a new keymap, but didn't map to a command that-
410 affects the search (lastc > 0), and the character that mapped to a-
411 new keymap would have ended the search (ENDSRCH_CHAR(cxt->prevc)),-
412 handle that now as if the previous char would have ended the search-
413 and we would have read the current character. */-
414 /* XXX - should we check cxt->mb? */-
415 if (cxt->lastc > 0 && ENDSRCH_CHAR (cxt->prevc))
cxt->lastc > 0Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->prevc) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((cxt->prevc) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->prevc) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(cxt->prevc) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->prevc) == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
((cxt->prevc) ...('G') & 0x1f))Description
TRUEnever evaluated
FALSEnever evaluated
0
416 {-
417 rl_stuff_char (cxt->lastc);-
418 rl_execute_next (cxt->prevc);-
419 /* XXX - do we insert everything in cxt->pmb? */-
420 return (0);
never executed: return (0);
0
421 }-
422 /* Otherwise, if the current character is mapped to self-insert or-
423 nothing (i.e., not an editing command), and the previous character-
424 was a keymap index, then we need to insert both the previous-
425 character and the current character into the search string. */-
426 else if (cxt->lastc > 0 && cxt->prevc > 0 &&
cxt->lastc > 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->prevc > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
427 cxt->keymap[cxt->prevc].type == ISKMAP &&
cxt->keymap[cx...evc].type == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
428 (f == 0 || f == rl_insert))
f == 0Description
TRUEnever evaluated
FALSEnever evaluated
f == rl_insertDescription
TRUEnever evaluated
FALSEnever evaluated
0
429 {-
430 /* Make lastc be the next character read */-
431 /* XXX - do we insert everything in cxt->mb? */-
432 rl_execute_next (cxt->lastc);-
433 /* Dispatch on the previous character (insert into search string) */-
434 cxt->lastc = cxt->prevc;-
435#if defined (HANDLE_MULTIBYTE)-
436 /* Have to overwrite cxt->mb here because dispatch uses it below */-
437 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
438 { -
439 if (cxt->pmb[1] == 0)
cxt->pmb[1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
440 {-
441 cxt->mb[0] = cxt->lastc; /* == cxt->prevc */-
442 cxt->mb[1] = '\0';-
443 }
never executed: end of block
0
444 else-
445 memcpy (cxt->mb, cxt->pmb, sizeof (cxt->mb));
never executed: memcpy (cxt->mb, cxt->pmb, sizeof (cxt->mb));
0
446 }-
447#endif-
448 cxt->prevc = 0; -
449 }
never executed: end of block
0
450 else if (cxt->lastc > 0 && cxt->prevc > 0 && f && f != rl_insert)
cxt->lastc > 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->prevc > 0Description
TRUEnever evaluated
FALSEnever evaluated
fDescription
TRUEnever evaluated
FALSEnever evaluated
f != rl_insertDescription
TRUEnever evaluated
FALSEnever evaluated
0
451 {-
452 rl_stuff_char (cxt->lastc);-
453 rl_execute_next (cxt->prevc);-
454 /* XXX - do we insert everything in cxt->pmb? */-
455 return (0);
never executed: return (0);
0
456 }-
457 }
never executed: end of block
0
458-
459 /* The characters in isearch_terminators (set from the user-settable-
460 variable isearch-terminators) are used to terminate the search but-
461 not subsequently execute the character as a command. The default-
462 value is "\033\012" (ESC and C-J). */-
463 if (cxt->lastc > 0 && strchr (cxt->search_terminators, cxt->lastc))
cxt->lastc > 0Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...cxt->lastc )))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( cxt->lastc )Description
TRUEnever evaluated
FALSEnever evaluated
!__builtin_con..._terminators )Description
TRUEnever evaluated
FALSEnever evaluated
( cxt->lastc ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
464 {-
465 /* ESC still terminates the search, but if there is pending-
466 input or if input arrives within 0.1 seconds (on systems-
467 with select(2)) it is used as a prefix character-
468 with rl_execute_next. WATCH OUT FOR THIS! This is intended-
469 to allow the arrow keys to be used like ^F and ^B are used-
470 to terminate the search and execute the movement command.-
471 XXX - since _rl_input_available depends on the application--
472 settable keyboard timeout value, this could alternatively-
473 use _rl_input_queued(100000) */-
474 if (cxt->lastc == ESC && (_rl_pushed_input_available () || _rl_input_available ()))
cxt->lastc == (('[') & 0x1f)Description
TRUEnever evaluated
FALSEnever evaluated
_rl_pushed_input_available ()Description
TRUEnever evaluated
FALSEnever evaluated
_rl_input_available ()Description
TRUEnever evaluated
FALSEnever evaluated
0
475 rl_execute_next (ESC);
never executed: rl_execute_next ((('[') & 0x1f));
0
476 return (0);
never executed: return (0);
0
477 }-
478-
479#if defined (HANDLE_MULTIBYTE)-
480 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
481 {-
482 if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
cxt->lastc >= 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->mb[0]Description
TRUEnever evaluated
FALSEnever evaluated
cxt->mb[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((cxt->lastc) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
((cxt->lastc) ...('G') & 0x1f))Description
TRUEnever evaluated
FALSEnever evaluated
0
483 {-
484 /* This sets rl_pending_input to LASTC; it will be picked up the next-
485 time rl_read_key is called. */-
486 rl_execute_next (cxt->lastc);-
487 return (0);
never executed: return (0);
0
488 }-
489 }
never executed: end of block
0
490 else-
491#endif-
492 if (cxt->lastc >= 0 && ENDSRCH_CHAR (cxt->lastc))
cxt->lastc >= 0Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) < 0x020Description
TRUEnever evaluated
FALSEnever evaluated
(((cxt->lastc) & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) > 0x07fDescription
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) <= 255Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->lastc) == 0x7fDescription
TRUEnever evaluated
FALSEnever evaluated
((cxt->lastc) ...('G') & 0x1f))Description
TRUEnever evaluated
FALSEnever evaluated
0
493 {-
494 /* This sets rl_pending_input to LASTC; it will be picked up the next-
495 time rl_read_key is called. */-
496 rl_execute_next (cxt->lastc);-
497 return (0);
never executed: return (0);
0
498 }-
499-
500 /* Now dispatch on the character. `Opcodes' affect the search string or-
501 state. Other characters are added to the string. */-
502 switch (cxt->lastc)-
503 {-
504 /* search again */-
505 case -1:
never executed: case -1:
0
506 if (cxt->search_string_index == 0)
cxt->search_string_index == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
507 {-
508 if (last_isearch_string)
last_isearch_stringDescription
TRUEnever evaluated
FALSEnever evaluated
0
509 {-
510 cxt->search_string_size = 64 + last_isearch_string_len;-
511 cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);-
512 strcpy (cxt->search_string, last_isearch_string);-
513 cxt->search_string_index = last_isearch_string_len;-
514 rl_display_search (cxt->search_string, cxt->sflags, -1);-
515 break;
never executed: break;
0
516 }-
517 return (1);
never executed: return (1);
0
518 }-
519 else if ((cxt->sflags & SF_REVERSE) && cxt->sline_index >= 0)
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
cxt->sline_index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
520 cxt->sline_index--;
never executed: cxt->sline_index--;
0
521 else if (cxt->sline_index != cxt->sline_len)
cxt->sline_ind...cxt->sline_lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
522 cxt->sline_index++;
never executed: cxt->sline_index++;
0
523 else-
524 rl_ding ();
never executed: rl_ding ();
0
525 break;
never executed: break;
0
526-
527 /* switch directions */-
528 case -2:
never executed: case -2:
0
529 cxt->direction = -cxt->direction;-
530 if (cxt->direction < 0)
cxt->direction < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
531 cxt->sflags |= SF_REVERSE;
never executed: cxt->sflags |= 0x01;
0
532 else-
533 cxt->sflags &= ~SF_REVERSE;
never executed: cxt->sflags &= ~0x01;
0
534 break;
never executed: break;
0
535-
536 /* delete character from search string. */-
537 case -3: /* C-H, DEL */
never executed: case -3:
0
538 /* This is tricky. To do this right, we need to keep a-
539 stack of search positions for the current search, with-
540 sentinels marking the beginning and end. But this will-
541 do until we have a real isearch-undo. */-
542 if (cxt->search_string_index == 0)
cxt->search_string_index == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
543 rl_ding ();
never executed: rl_ding ();
0
544 else if (MB_CUR_MAX == 1 || rl_byte_oriented)
(__ctype_get_m...r_max ()) == 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_orientedDescription
TRUEnever evaluated
FALSEnever evaluated
0
545 cxt->search_string[--cxt->search_string_index] = '\0';
never executed: cxt->search_string[--cxt->search_string_index] = '\0';
0
546 else-
547 {-
548 wstart = _rl_find_prev_mbchar (cxt->search_string, cxt->search_string_index, MB_FIND_NONZERO);-
549 if (wstart >= 0)
wstart >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
550 cxt->search_string[cxt->search_string_index = wstart] = '\0';
never executed: cxt->search_string[cxt->search_string_index = wstart] = '\0';
0
551 else-
552 cxt->search_string[cxt->search_string_index = 0] = '\0';
never executed: cxt->search_string[cxt->search_string_index = 0] = '\0';
0
553 }-
554-
555 if (cxt->search_string_index == 0)
cxt->search_string_index == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
556 rl_ding ();
never executed: rl_ding ();
0
557-
558 break;
never executed: break;
0
559-
560 case -4: /* C-G, abort */
never executed: case -4:
0
561 rl_replace_line (cxt->lines[cxt->save_line], 0);-
562 rl_point = cxt->save_point;-
563 rl_mark = cxt->save_mark;-
564 rl_restore_prompt();-
565 rl_clear_message ();-
566-
567 return -1;
never executed: return -1;
0
568-
569 case -5: /* C-W */
never executed: case -5:
0
570 /* skip over portion of line we already matched and yank word */-
571 wstart = rl_point + cxt->search_string_index;-
572 if (wstart >= rl_end)
wstart >= rl_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
573 {-
574 rl_ding ();-
575 break;
never executed: break;
0
576 }-
577-
578 /* if not in a word, move to one. */-
579 cval = _rl_char_value (rl_line_buffer, wstart);-
580 if (_rl_walphabetic (cval) == 0)
_rl_walphabetic (cval) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
581 {-
582 rl_ding ();-
583 break;
never executed: break;
0
584 }-
585 n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
586 while (n < rl_end)
n < rl_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
587 {-
588 cval = _rl_char_value (rl_line_buffer, n);-
589 if (_rl_walphabetic (cval) == 0)
_rl_walphabetic (cval) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
590 break;
never executed: break;
0
591 n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
592 }
never executed: end of block
0
593 wlen = n - wstart + 1;-
594 if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
cxt->search_st...ch_string_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 {-
596 cxt->search_string_size += wlen + 1;-
597 cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);-
598 }
never executed: end of block
0
599 for (; wstart < n; wstart++)
wstart < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
600 cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart];
never executed: cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart];
0
601 cxt->search_string[cxt->search_string_index] = '\0';-
602 break;
never executed: break;
0
603-
604 case -6: /* C-Y */
never executed: case -6:
0
605 /* skip over portion of line we already matched and yank rest */-
606 wstart = rl_point + cxt->search_string_index;-
607 if (wstart >= rl_end)
wstart >= rl_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
608 {-
609 rl_ding ();-
610 break;
never executed: break;
0
611 }-
612 n = rl_end - wstart + 1;-
613 if (cxt->search_string_index + n + 1 >= cxt->search_string_size)
cxt->search_st...ch_string_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
614 {-
615 cxt->search_string_size += n + 1;-
616 cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);-
617 }
never executed: end of block
0
618 for (n = wstart; n < rl_end; n++)
n < rl_endDescription
TRUEnever evaluated
FALSEnever evaluated
0
619 cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n];
never executed: cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n];
0
620 cxt->search_string[cxt->search_string_index] = '\0';-
621 break;
never executed: break;
0
622-
623 /* Add character to search string and continue search. */-
624 default:
never executed: default:
0
625 if (cxt->search_string_index + 2 >= cxt->search_string_size)
cxt->search_st...ch_string_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
626 {-
627 cxt->search_string_size += 128;-
628 cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);-
629 }
never executed: end of block
0
630#if defined (HANDLE_MULTIBYTE)-
631 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEnever evaluated
rl_byte_oriented == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
632 {-
633 int j, l;-
634-
635 if (cxt->mb[0] == 0 || cxt->mb[1] == 0)
cxt->mb[0] == 0Description
TRUEnever evaluated
FALSEnever evaluated
cxt->mb[1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
636 cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
never executed: cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
0
637 else-
638 for (j = 0, l = RL_STRLEN (cxt->mb); j < l; )
j < lDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
never executed: cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
0
640 }
never executed: end of block
0
641 else-
642#endif-
643 cxt->search_string[cxt->search_string_index++] = cxt->lastc; /* XXX - was c instead of lastc */
never executed: cxt->search_string[cxt->search_string_index++] = cxt->lastc;
0
644 cxt->search_string[cxt->search_string_index] = '\0';-
645 break;
never executed: break;
0
646 }-
647-
648 for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )-
649 {-
650 if (cxt->search_string_index == 0)
cxt->search_string_index == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
651 {-
652 cxt->sflags |= SF_FAILED;-
653 break;
never executed: break;
0
654 }-
655-
656 limit = cxt->sline_len - cxt->search_string_index + 1;-
657-
658 /* Search the current line. */-
659 while ((cxt->sflags & SF_REVERSE) ? (cxt->sline_index >= 0) : (cxt->sline_index < limit))
(cxt->sflags &...index < limit)Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
660 {-
661 if (STREQN (cxt->search_string, cxt->sline + cxt->sline_index, cxt->search_string_index))
never executed: __result = (((const unsigned char *) (const char *) ( (cxt->search_string) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( (cxt->sline + cxt->sline_index) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(((cxt->search...ex) ))) == 0))Description
TRUEnever evaluated
FALSEnever evaluated
((cxt->search_...g_index) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
((cxt->search_...ine_index)[0])Description
TRUEnever evaluated
FALSEnever evaluated
( (__extension...dex) ))) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...tring_index) )Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...arch_string) )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( (cxt-...ring_index) ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...sline_index) )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( (cxt-...ring_index) ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
662 {-
663 cxt->sflags |= SF_FOUND;-
664 break;
never executed: break;
0
665 }-
666 else-
667 cxt->sline_index += cxt->direction;
never executed: cxt->sline_index += cxt->direction;
0
668-
669 if (cxt->sline_index < 0)
cxt->sline_index < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
670 {-
671 cxt->sline_index = 0;-
672 break;
never executed: break;
0
673 }-
674 }
never executed: end of block
0
675 if (cxt->sflags & SF_FOUND)
cxt->sflags & 0x02Description
TRUEnever evaluated
FALSEnever evaluated
0
676 break;
never executed: break;
0
677-
678 /* Move to the next line, but skip new copies of the line-
679 we just found and lines shorter than the string we're-
680 searching for. */-
681 do-
682 {-
683 /* Move to the next line. */-
684 cxt->history_pos += cxt->direction;-
685-
686 /* At limit for direction? */-
687 if ((cxt->sflags & SF_REVERSE) ? (cxt->history_pos < 0) : (cxt->history_pos == cxt->hlen))
(cxt->sflags &... == cxt->hlen)Description
TRUEnever evaluated
FALSEnever evaluated
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
688 {-
689 cxt->sflags |= SF_FAILED;-
690 break;
never executed: break;
0
691 }-
692-
693 /* We will need these later. */-
694 cxt->sline = cxt->lines[cxt->history_pos];-
695 cxt->sline_len = strlen (cxt->sline);-
696 }
never executed: end of block
0
697 while ((cxt->prev_line_found && STREQ (cxt->prev_line_found, cxt->lines[cxt->history_pos])) ||
never executed: __result = (((const unsigned char *) (const char *) ( (cxt->prev_line_found) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( (cxt->lines[cxt->history_pos]) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
cxt->prev_line_foundDescription
TRUEnever evaluated
FALSEnever evaluated
((cxt->prev_li...tory_pos])[0])Description
TRUEnever evaluated
FALSEnever evaluated
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
698 (cxt->search_string_index > cxt->sline_len));
(cxt->search_s...xt->sline_len)Description
TRUEnever evaluated
FALSEnever evaluated
0
699-
700 if (cxt->sflags & SF_FAILED)
cxt->sflags & 0x04Description
TRUEnever evaluated
FALSEnever evaluated
0
701 {-
702 /* XXX - reset sline_index if < 0 */-
703 if (cxt->sline_index < 0)
cxt->sline_index < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
704 cxt->sline_index = 0;
never executed: cxt->sline_index = 0;
0
705 break;
never executed: break;
0
706 }-
707-
708 /* Now set up the line for searching... */-
709 cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
(cxt->sflags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
710 }
never executed: end of block
0
711-
712 if (cxt->sflags & SF_FAILED)
cxt->sflags & 0x04Description
TRUEnever evaluated
FALSEnever evaluated
0
713 {-
714 /* We cannot find the search string. Ding the bell. */-
715 rl_ding ();-
716 cxt->history_pos = cxt->last_found_line;-
717 rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);-
718 return 1;
never executed: return 1;
0
719 }-
720-
721 /* We have found the search string. Just display it. But don't-
722 actually move there in the history list until the user accepts-
723 the location. */-
724 if (cxt->sflags & SF_FOUND)
cxt->sflags & 0x02Description
TRUEnever evaluated
FALSEnever evaluated
0
725 {-
726 cxt->prev_line_found = cxt->lines[cxt->history_pos];-
727 rl_replace_line (cxt->lines[cxt->history_pos], 0);-
728 rl_point = cxt->sline_index;-
729 cxt->last_found_line = cxt->history_pos;-
730 rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);-
731 }
never executed: end of block
0
732-
733 return 1;
never executed: return 1;
0
734}-
735-
736int-
737_rl_isearch_cleanup (_rl_search_cxt *cxt, int r)-
738{-
739 if (r >= 0)
r >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
740 _rl_isearch_fini (cxt);
never executed: _rl_isearch_fini (cxt);
0
741 _rl_scxt_dispose (cxt, 0);-
742 _rl_iscxt = 0;-
743-
744 RL_UNSETSTATE(RL_STATE_ISEARCH);-
745-
746 return (r != 0);
never executed: return (r != 0);
0
747}-
748-
749/* Search through the history looking for an interactively typed string.-
750 This is analogous to i-search. We start the search in the current line.-
751 DIRECTION is which direction to search; >= 0 means forward, < 0 means-
752 backwards. */-
753static int-
754rl_search_history (int direction, int invoking_key)-
755{-
756 _rl_search_cxt *cxt; /* local for now, but saved globally */-
757 int c, r;-
758-
759 RL_SETSTATE(RL_STATE_ISEARCH);-
760 cxt = _rl_isearch_init (direction);-
761-
762 rl_display_search (cxt->search_string, cxt->sflags, -1);-
763-
764 /* If we are using the callback interface, all we do is set up here and-
765 return. The key is that we leave RL_STATE_ISEARCH set. */-
766 if (RL_ISSTATE (RL_STATE_CALLBACK))
(rl_readline_s...& (0x0080000))Description
TRUEnever evaluated
FALSEnever evaluated
0
767 return (0);
never executed: return (0);
0
768-
769 r = -1;-
770 for (;;)-
771 {-
772 c = _rl_search_getchar (cxt);-
773 /* We might want to handle EOF here (c == 0) */-
774 r = _rl_isearch_dispatch (cxt, cxt->lastc);-
775 if (r <= 0)
r <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
776 break;
never executed: break;
0
777 }
never executed: end of block
0
778-
779 /* The searching is over. The user may have found the string that she-
780 was looking for, or else she may have exited a failing search. If-
781 LINE_INDEX is -1, then that shows that the string searched for was-
782 not found. We use this to determine where to place rl_point. */-
783 return (_rl_isearch_cleanup (cxt, r));
never executed: return (_rl_isearch_cleanup (cxt, r));
0
784}-
785-
786#if defined (READLINE_CALLBACKS)-
787/* Called from the callback functions when we are ready to read a key. The-
788 callback functions know to call this because RL_ISSTATE(RL_STATE_ISEARCH).-
789 If _rl_isearch_dispatch finishes searching, this function is responsible-
790 for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */-
791int-
792_rl_isearch_callback (_rl_search_cxt *cxt)-
793{-
794 int c, r;-
795-
796 c = _rl_search_getchar (cxt);-
797 /* We might want to handle EOF here */-
798 r = _rl_isearch_dispatch (cxt, cxt->lastc);-
799-
800 return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
never executed: return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
0
801}-
802#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2