Thu Jul 28 00:46:27 2011 UTC ()
term -> terminal


(christos)
diff -r1.24 -r1.25 src/lib/libedit/search.c

cvs diff -r1.24 -r1.25 src/lib/libedit/search.c (expand / switch to unified diff)

--- src/lib/libedit/search.c 2010/04/15 00:57:33 1.24
+++ src/lib/libedit/search.c 2011/07/28 00:46:26 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: search.c,v 1.24 2010/04/15 00:57:33 christos Exp $ */ 1/* $NetBSD: search.c,v 1.25 2011/07/28 00:46:26 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Christos Zoulas of Cornell University. 8 * Christos Zoulas of Cornell University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include "config.h" 35#include "config.h"
36#if !defined(lint) && !defined(SCCSID) 36#if !defined(lint) && !defined(SCCSID)
37#if 0 37#if 0
38static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: search.c,v 1.24 2010/04/15 00:57:33 christos Exp $"); 40__RCSID("$NetBSD: search.c,v 1.25 2011/07/28 00:46:26 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * search.c: History and character search functions 45 * search.c: History and character search functions
46 */ 46 */
47#include <stdlib.h> 47#include <stdlib.h>
48#if defined(REGEX) 48#if defined(REGEX)
49#include <regex.h> 49#include <regex.h>
50#elif defined(REGEXP) 50#elif defined(REGEXP)
51#include <regexp.h> 51#include <regexp.h>
52#endif 52#endif
53#include "el.h" 53#include "el.h"
@@ -244,89 +244,89 @@ ce_inc_search(EditLine *el, int dir) @@ -244,89 +244,89 @@ ce_inc_search(EditLine *el, int dir)
244 cp < &el->el_search.patbuf[el->el_search.patlen]; 244 cp < &el->el_search.patbuf[el->el_search.patlen];
245 *el->el_line.lastchar++ = *cp++) 245 *el->el_line.lastchar++ = *cp++)
246 continue; 246 continue;
247 *el->el_line.lastchar = '\0'; 247 *el->el_line.lastchar = '\0';
248 re_refresh(el); 248 re_refresh(el);
249 249
250 if (FUN(el,getc)(el, &ch) != 1) 250 if (FUN(el,getc)(el, &ch) != 1)
251 return (ed_end_of_file(el, 0)); 251 return (ed_end_of_file(el, 0));
252 252
253 switch (el->el_map.current[(unsigned char) ch]) { 253 switch (el->el_map.current[(unsigned char) ch]) {
254 case ED_INSERT: 254 case ED_INSERT:
255 case ED_DIGIT: 255 case ED_DIGIT:
256 if (el->el_search.patlen >= EL_BUFSIZ - LEN) 256 if (el->el_search.patlen >= EL_BUFSIZ - LEN)
257 term_beep(el); 257 terminal_beep(el);
258 else { 258 else {
259 el->el_search.patbuf[el->el_search.patlen++] = 259 el->el_search.patbuf[el->el_search.patlen++] =
260 ch; 260 ch;
261 *el->el_line.lastchar++ = ch; 261 *el->el_line.lastchar++ = ch;
262 *el->el_line.lastchar = '\0'; 262 *el->el_line.lastchar = '\0';
263 re_refresh(el); 263 re_refresh(el);
264 } 264 }
265 break; 265 break;
266 266
267 case EM_INC_SEARCH_NEXT: 267 case EM_INC_SEARCH_NEXT:
268 newdir = ED_SEARCH_NEXT_HISTORY; 268 newdir = ED_SEARCH_NEXT_HISTORY;
269 redo++; 269 redo++;
270 break; 270 break;
271 271
272 case EM_INC_SEARCH_PREV: 272 case EM_INC_SEARCH_PREV:
273 newdir = ED_SEARCH_PREV_HISTORY; 273 newdir = ED_SEARCH_PREV_HISTORY;
274 redo++; 274 redo++;
275 break; 275 break;
276 276
277 case EM_DELETE_PREV_CHAR: 277 case EM_DELETE_PREV_CHAR:
278 case ED_DELETE_PREV_CHAR: 278 case ED_DELETE_PREV_CHAR:
279 if (el->el_search.patlen > LEN) 279 if (el->el_search.patlen > LEN)
280 done++; 280 done++;
281 else 281 else
282 term_beep(el); 282 terminal_beep(el);
283 break; 283 break;
284 284
285 default: 285 default:
286 switch (ch) { 286 switch (ch) {
287 case 0007: /* ^G: Abort */ 287 case 0007: /* ^G: Abort */
288 ret = CC_ERROR; 288 ret = CC_ERROR;
289 done++; 289 done++;
290 break; 290 break;
291 291
292 case 0027: /* ^W: Append word */ 292 case 0027: /* ^W: Append word */
293 /* No can do if globbing characters in pattern */ 293 /* No can do if globbing characters in pattern */
294 for (cp = &el->el_search.patbuf[LEN];; cp++) 294 for (cp = &el->el_search.patbuf[LEN];; cp++)
295 if (cp >= &el->el_search.patbuf[ 295 if (cp >= &el->el_search.patbuf[
296 el->el_search.patlen]) { 296 el->el_search.patlen]) {
297 el->el_line.cursor += 297 el->el_line.cursor +=
298 el->el_search.patlen - LEN - 1; 298 el->el_search.patlen - LEN - 1;
299 cp = c__next_word(el->el_line.cursor, 299 cp = c__next_word(el->el_line.cursor,
300 el->el_line.lastchar, 1, 300 el->el_line.lastchar, 1,
301 ce__isword); 301 ce__isword);
302 while (el->el_line.cursor < cp && 302 while (el->el_line.cursor < cp &&
303 *el->el_line.cursor != '\n') { 303 *el->el_line.cursor != '\n') {
304 if (el->el_search.patlen >= 304 if (el->el_search.patlen >=
305 EL_BUFSIZ - LEN) { 305 EL_BUFSIZ - LEN) {
306 term_beep(el); 306 terminal_beep(el);
307 break; 307 break;
308 } 308 }
309 el->el_search.patbuf[el->el_search.patlen++] = 309 el->el_search.patbuf[el->el_search.patlen++] =
310 *el->el_line.cursor; 310 *el->el_line.cursor;
311 *el->el_line.lastchar++ = 311 *el->el_line.lastchar++ =
312 *el->el_line.cursor++; 312 *el->el_line.cursor++;
313 } 313 }
314 el->el_line.cursor = ocursor; 314 el->el_line.cursor = ocursor;
315 *el->el_line.lastchar = '\0'; 315 *el->el_line.lastchar = '\0';
316 re_refresh(el); 316 re_refresh(el);
317 break; 317 break;
318 } else if (isglob(*cp)) { 318 } else if (isglob(*cp)) {
319 term_beep(el); 319 terminal_beep(el);
320 break; 320 break;
321 } 321 }
322 break; 322 break;
323 323
324 default: /* Terminate and execute cmd */ 324 default: /* Terminate and execute cmd */
325 endcmd[0] = ch; 325 endcmd[0] = ch;
326 FUN(el,push)(el, endcmd); 326 FUN(el,push)(el, endcmd);
327 /* FALLTHROUGH */ 327 /* FALLTHROUGH */
328 328
329 case 0033: /* ESC: Terminate */ 329 case 0033: /* ESC: Terminate */
330 ret = CC_REFRESH; 330 ret = CC_REFRESH;
331 done++; 331 done++;
332 break; 332 break;
@@ -391,27 +391,27 @@ ce_inc_search(EditLine *el, int dir) @@ -391,27 +391,27 @@ ce_inc_search(EditLine *el, int dir)
391 if (ret != CC_ERROR) { 391 if (ret != CC_ERROR) {
392 el->el_line.cursor = newdir == 392 el->el_line.cursor = newdir ==
393 ED_SEARCH_PREV_HISTORY ? 393 ED_SEARCH_PREV_HISTORY ?
394 el->el_line.lastchar : 394 el->el_line.lastchar :
395 el->el_line.buffer; 395 el->el_line.buffer;
396 (void) ce_search_line(el, 396 (void) ce_search_line(el,
397 newdir); 397 newdir);
398 } 398 }
399 } 399 }
400 el->el_search.patlen -= LEN; 400 el->el_search.patlen -= LEN;
401 el->el_search.patbuf[el->el_search.patlen] = 401 el->el_search.patbuf[el->el_search.patlen] =
402 '\0'; 402 '\0';
403 if (ret == CC_ERROR) { 403 if (ret == CC_ERROR) {
404 term_beep(el); 404 terminal_beep(el);
405 if (el->el_history.eventno != 405 if (el->el_history.eventno !=
406 ohisteventno) { 406 ohisteventno) {
407 el->el_history.eventno = 407 el->el_history.eventno =
408 ohisteventno; 408 ohisteventno;
409 if (hist_get(el) == CC_ERROR) 409 if (hist_get(el) == CC_ERROR)
410 return (CC_ERROR); 410 return (CC_ERROR);
411 } 411 }
412 el->el_line.cursor = ocursor; 412 el->el_line.cursor = ocursor;
413 pchar = '?'; 413 pchar = '?';
414 } else { 414 } else {
415 pchar = ':'; 415 pchar = ':';
416 } 416 }
417 } 417 }