Wed Feb 17 19:47:49 2016 UTC ()
whitespace and header sorting changes (Ingo Schwarze). No functional changes.


(christos)
diff -r1.53 -r1.54 src/lib/libedit/Makefile
diff -r1.53 -r1.54 src/lib/libedit/vi.c
diff -r1.46 -r1.47 src/lib/libedit/chared.c
diff -r1.18 -r1.19 src/lib/libedit/chartype.c
diff -r1.20 -r1.21 src/lib/libedit/chartype.h
diff -r1.37 -r1.38 src/lib/libedit/common.c
diff -r1.81 -r1.82 src/lib/libedit/el.c
diff -r1.81 -r1.82 src/lib/libedit/read.c
diff -r1.32 -r1.33 src/lib/libedit/el.h
diff -r1.39 -r1.40 src/lib/libedit/filecomplete.c
diff -r1.17 -r1.18 src/lib/libedit/hist.h
diff -r1.54 -r1.55 src/lib/libedit/histedit.h
diff -r1.51 -r1.52 src/lib/libedit/history.c
diff -r1.12 -r1.13 src/lib/libedit/keymacro.c
diff -r1.12 -r1.13 src/lib/libedit/prompt.h
diff -r1.23 -r1.24 src/lib/libedit/makelist
diff -r1.23 -r1.24 src/lib/libedit/tokenizer.c
diff -r1.42 -r1.43 src/lib/libedit/map.c
diff -r1.34 -r1.35 src/lib/libedit/parse.c
diff -r1.7 -r1.8 src/lib/libedit/read.h
diff -r1.124 -r1.125 src/lib/libedit/readline.c
diff -r1.43 -r1.44 src/lib/libedit/refresh.c
diff -r1.22 -r1.23 src/lib/libedit/sys.h
diff -r1.21 -r1.22 src/lib/libedit/terminal.c
diff -r1.56 -r1.57 src/lib/libedit/tty.c
diff -r1.6 -r1.7 src/lib/libedit/TEST/tc1.c
diff -r1.7 -r1.8 src/lib/libedit/TEST/wtc1.c
diff -r1.7 -r1.8 src/lib/libedit/readline/Makefile
diff -r1.38 -r1.39 src/lib/libedit/readline/readline.h

cvs diff -r1.53 -r1.54 src/lib/libedit/Makefile (expand / switch to unified diff)

--- src/lib/libedit/Makefile 2015/01/29 20:30:02 1.53
+++ src/lib/libedit/Makefile 2016/02/17 19:47:49 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.53 2015/01/29 20:30:02 joerg Exp $ 1# $NetBSD: Makefile,v 1.54 2016/02/17 19:47:49 christos Exp $
2# @(#)Makefile 8.1 (Berkeley) 6/4/93 2# @(#)Makefile 8.1 (Berkeley) 6/4/93
3 3
4USE_SHLIBDIR= yes 4USE_SHLIBDIR= yes
5 5
6WIDECHAR ?= yes 6WIDECHAR ?= yes
7WARNS?= 5 7WARNS?= 5
8LIB= edit 8LIB= edit
9 9
10LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo 10LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo
11 11
12.include "bsd.own.mk" 12.include "bsd.own.mk"
13 13
14COPTS+= -Wunused-parameter 14COPTS+= -Wunused-parameter
@@ -42,32 +42,32 @@ SRCS += tokenizern.c historyn.c @@ -42,32 +42,32 @@ SRCS += tokenizern.c historyn.c
42CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c 42CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
43CPPFLAGS+=-DWIDECHAR 43CPPFLAGS+=-DWIDECHAR
44.endif 44.endif
45 45
46LIBEDITDIR?=${.CURDIR} 46LIBEDITDIR?=${.CURDIR}
47 47
48INCS= histedit.h 48INCS= histedit.h
49INCSDIR=/usr/include 49INCSDIR=/usr/include
50 50
51CLEANFILES+=editline.c 51CLEANFILES+=editline.c
52CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp 52CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp
53CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1 53CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1
54CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c 54CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
55CPPFLAGS+=-I. -I${LIBEDITDIR}  55CPPFLAGS+=-I. -I${LIBEDITDIR}
56CPPFLAGS+=-I. -I${.CURDIR} 56CPPFLAGS+=-I. -I${.CURDIR}
57CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH 57CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
58CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT 58CPPFLAGS+=#-DDEBUG_PASTE -DDEBUG_EDIT
59 59
60AHDR=vi.h emacs.h common.h  60AHDR=vi.h emacs.h common.h
61ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c 61ASRC=${LIBEDITDIR}/vi.c ${LIBEDITDIR}/emacs.c ${LIBEDITDIR}/common.c
62 62
63DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c 63DPSRCS+= ${AHDR} fcns.h help.h fcns.c help.c
64CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c 64CLEANFILES+= ${AHDR} fcns.h help.h fcns.c help.c
65 65
66SUBDIR= readline 66SUBDIR= readline
67 67
68vi.h: vi.c makelist Makefile 68vi.h: vi.c makelist Makefile
69 ${_MKTARGET_CREATE} 69 ${_MKTARGET_CREATE}
70 ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \ 70 ${HOST_SH} ${LIBEDITDIR}/makelist -h ${LIBEDITDIR}/vi.c \
71 > ${.TARGET}.tmp && \ 71 > ${.TARGET}.tmp && \
72 mv ${.TARGET}.tmp ${.TARGET} 72 mv ${.TARGET}.tmp ${.TARGET}
73 73
@@ -110,26 +110,26 @@ editline.c: ${OSRCS} makelist Makefile @@ -110,26 +110,26 @@ editline.c: ${OSRCS} makelist Makefile
110 110
111tokenizern.c: makelist Makefile 111tokenizern.c: makelist Makefile
112 ${_MKTARGET_CREATE} 112 ${_MKTARGET_CREATE}
113 ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \ 113 ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.TARGET}.tmp && \
114 mv ${.TARGET}.tmp ${.TARGET} 114 mv ${.TARGET}.tmp ${.TARGET}
115 115
116historyn.c: makelist Makefile 116historyn.c: makelist Makefile
117 ${_MKTARGET_CREATE} 117 ${_MKTARGET_CREATE}
118 ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \ 118 ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \
119 mv ${.TARGET}.tmp ${.TARGET} 119 mv ${.TARGET}.tmp ${.TARGET}
120 120
121tc1.o: ${LIBEDITDIR}/TEST/tc1.c 121tc1.o: ${LIBEDITDIR}/TEST/tc1.c
122 122
123tc1: libedit.a tc1.o  123tc1: libedit.a tc1.o
124 ${_MKTARGET_LINK} 124 ${_MKTARGET_LINK}
125 ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib 125 ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} libedit.a ${LDADD} -ltermlib
126 126
127.include <bsd.lib.mk> 127.include <bsd.lib.mk>
128.include <bsd.subdir.mk> 128.include <bsd.subdir.mk>
129 129
130# XXX 130# XXX
131.if defined(HAVE_GCC) 131.if defined(HAVE_GCC)
132COPTS.editline.c+= -Wno-cast-qual 132COPTS.editline.c+= -Wno-cast-qual
133COPTS.tokenizer.c+= -Wno-cast-qual 133COPTS.tokenizer.c+= -Wno-cast-qual
134COPTS.tokenizern.c+= -Wno-cast-qual 134COPTS.tokenizern.c+= -Wno-cast-qual
135.endif 135.endif

cvs diff -r1.53 -r1.54 src/lib/libedit/vi.c (expand / switch to unified diff)

--- src/lib/libedit/vi.c 2016/02/16 22:53:14 1.53
+++ src/lib/libedit/vi.c 2016/02/17 19:47:49 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vi.c,v 1.53 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 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[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: vi.c,v 1.53 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: vi.c,v 1.54 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * vi.c: Vi mode commands. 45 * vi.c: Vi mode commands.
46 */ 46 */
47#include <sys/wait.h> 47#include <sys/wait.h>
48#include <ctype.h> 48#include <ctype.h>
49#include <limits.h> 49#include <limits.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <string.h> 51#include <string.h>
52#include <unistd.h> 52#include <unistd.h>
53 53
@@ -575,27 +575,27 @@ vi_zero(EditLine *el, wint_t c) @@ -575,27 +575,27 @@ vi_zero(EditLine *el, wint_t c)
575 if (el->el_state.doingarg) 575 if (el->el_state.doingarg)
576 return ed_argument_digit(el, c); 576 return ed_argument_digit(el, c);
577 577
578 el->el_line.cursor = el->el_line.buffer; 578 el->el_line.cursor = el->el_line.buffer;
579 if (el->el_chared.c_vcmd.action != NOP) { 579 if (el->el_chared.c_vcmd.action != NOP) {
580 cv_delfini(el); 580 cv_delfini(el);
581 return CC_REFRESH; 581 return CC_REFRESH;
582 } 582 }
583 return CC_CURSOR; 583 return CC_CURSOR;
584} 584}
585 585
586 586
587/* vi_delete_prev_char(): 587/* vi_delete_prev_char():
588 * Vi move to previous character (backspace) 588 * Vi move to previous character (backspace)
589 * [^H] in insert mode only 589 * [^H] in insert mode only
590 */ 590 */
591protected el_action_t 591protected el_action_t
592/*ARGSUSED*/ 592/*ARGSUSED*/
593vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__))) 593vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
594{ 594{
595 595
596 if (el->el_line.cursor <= el->el_line.buffer) 596 if (el->el_line.cursor <= el->el_line.buffer)
597 return CC_ERROR; 597 return CC_ERROR;
598 598
599 c_delbefore1(el); 599 c_delbefore1(el);
600 el->el_line.cursor--; 600 el->el_line.cursor--;
601 return CC_REFRESH; 601 return CC_REFRESH;
@@ -967,27 +967,27 @@ vi_to_history_line(EditLine *el, wint_t  @@ -967,27 +967,27 @@ vi_to_history_line(EditLine *el, wint_t
967 /* Lack of a 'count' means oldest, not 1 */ 967 /* Lack of a 'count' means oldest, not 1 */
968 if (!el->el_state.doingarg) { 968 if (!el->el_state.doingarg) {
969 el->el_history.eventno = 0x7fffffff; 969 el->el_history.eventno = 0x7fffffff;
970 hist_get(el); 970 hist_get(el);
971 } else { 971 } else {
972 /* This is brain dead, all the rest of this code counts 972 /* This is brain dead, all the rest of this code counts
973 * upwards going into the past. Here we need count in the 973 * upwards going into the past. Here we need count in the
974 * other direction (to match the output of fc -l). 974 * other direction (to match the output of fc -l).
975 * I could change the world, but this seems to suffice. 975 * I could change the world, but this seems to suffice.
976 */ 976 */
977 el->el_history.eventno = 1; 977 el->el_history.eventno = 1;
978 if (hist_get(el) == CC_ERROR) 978 if (hist_get(el) == CC_ERROR)
979 return CC_ERROR; 979 return CC_ERROR;
980 el->el_history.eventno = 1 + el->el_history.ev.num  980 el->el_history.eventno = 1 + el->el_history.ev.num
981 - el->el_state.argument; 981 - el->el_state.argument;
982 if (el->el_history.eventno < 0) { 982 if (el->el_history.eventno < 0) {
983 el->el_history.eventno = sv_event_no; 983 el->el_history.eventno = sv_event_no;
984 return CC_ERROR; 984 return CC_ERROR;
985 } 985 }
986 } 986 }
987 rval = hist_get(el); 987 rval = hist_get(el);
988 if (rval == CC_ERROR) 988 if (rval == CC_ERROR)
989 el->el_history.eventno = sv_event_no; 989 el->el_history.eventno = sv_event_no;
990 return rval; 990 return rval;
991} 991}
992 992
993/* vi_histedit(): 993/* vi_histedit():

cvs diff -r1.46 -r1.47 src/lib/libedit/chared.c (expand / switch to unified diff)

--- src/lib/libedit/chared.c 2016/02/16 22:53:14 1.46
+++ src/lib/libedit/chared.c 2016/02/17 19:47:49 1.47
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: chared.c,v 1.46 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: chared.c,v 1.47 2016/02/17 19:47:49 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[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: chared.c,v 1.46 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: chared.c,v 1.47 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * chared.c: Character editor utilities 45 * chared.c: Character editor utilities
46 */ 46 */
47#include <ctype.h> 47#include <ctype.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <string.h> 49#include <string.h>
50 50
51#include "el.h" 51#include "el.h"
52#include "common.h" 52#include "common.h"
53 53
@@ -516,27 +516,27 @@ ch_enlargebufs(EditLine *el, size_t addl @@ -516,27 +516,27 @@ ch_enlargebufs(EditLine *el, size_t addl
516 while(newsz - sz < addlen) 516 while(newsz - sz < addlen)
517 newsz *= 2; 517 newsz *= 2;
518 } 518 }
519 519
520 /* 520 /*
521 * Reallocate line buffer. 521 * Reallocate line buffer.
522 */ 522 */
523 newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer)); 523 newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer));
524 if (!newbuffer) 524 if (!newbuffer)
525 return 0; 525 return 0;
526 526
527 /* zero the newly added memory, leave old data in */ 527 /* zero the newly added memory, leave old data in */
528 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); 528 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
529  529
530 oldbuf = el->el_line.buffer; 530 oldbuf = el->el_line.buffer;
531 531
532 el->el_line.buffer = newbuffer; 532 el->el_line.buffer = newbuffer;
533 el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf); 533 el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
534 el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf); 534 el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
535 /* don't set new size until all buffers are enlarged */ 535 /* don't set new size until all buffers are enlarged */
536 el->el_line.limit = &newbuffer[sz - EL_LEAVE]; 536 el->el_line.limit = &newbuffer[sz - EL_LEAVE];
537 537
538 /* 538 /*
539 * Reallocate kill buffer. 539 * Reallocate kill buffer.
540 */ 540 */
541 newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * 541 newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz *
542 sizeof(*newbuffer)); 542 sizeof(*newbuffer));
@@ -565,27 +565,27 @@ ch_enlargebufs(EditLine *el, size_t addl @@ -565,27 +565,27 @@ ch_enlargebufs(EditLine *el, size_t addl
565 /* zero the newly added memory, leave old data in */ 565 /* zero the newly added memory, leave old data in */
566 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer)); 566 (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
567 el->el_chared.c_undo.buf = newbuffer; 567 el->el_chared.c_undo.buf = newbuffer;
568 568
569 newbuffer = el_realloc(el->el_chared.c_redo.buf, 569 newbuffer = el_realloc(el->el_chared.c_redo.buf,
570 newsz * sizeof(*newbuffer)); 570 newsz * sizeof(*newbuffer));
571 if (!newbuffer) 571 if (!newbuffer)
572 return 0; 572 return 0;
573 el->el_chared.c_redo.pos = newbuffer + 573 el->el_chared.c_redo.pos = newbuffer +
574 (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf); 574 (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
575 el->el_chared.c_redo.lim = newbuffer + 575 el->el_chared.c_redo.lim = newbuffer +
576 (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); 576 (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
577 el->el_chared.c_redo.buf = newbuffer; 577 el->el_chared.c_redo.buf = newbuffer;
578  578
579 if (!hist_enlargebuf(el, sz, newsz)) 579 if (!hist_enlargebuf(el, sz, newsz))
580 return 0; 580 return 0;
581 581
582 /* Safe to set enlarged buffer size */ 582 /* Safe to set enlarged buffer size */
583 el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; 583 el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
584 if (el->el_chared.c_resizefun) 584 if (el->el_chared.c_resizefun)
585 (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg); 585 (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg);
586 return 1; 586 return 1;
587} 587}
588 588
589/* ch_end(): 589/* ch_end():
590 * Free the data structures used by the editor 590 * Free the data structures used by the editor
591 */ 591 */

cvs diff -r1.18 -r1.19 src/lib/libedit/chartype.c (expand / switch to unified diff)

--- src/lib/libedit/chartype.c 2016/02/16 22:53:14 1.18
+++ src/lib/libedit/chartype.c 2016/02/17 19:47:49 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: chartype.c,v 1.18 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE. 33 * POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36/* 36/*
37 * chartype.c: character classification and meta information 37 * chartype.c: character classification and meta information
38 */ 38 */
39#include "config.h" 39#include "config.h"
40#if !defined(lint) && !defined(SCCSID) 40#if !defined(lint) && !defined(SCCSID)
41__RCSID("$NetBSD: chartype.c,v 1.18 2016/02/16 22:53:14 christos Exp $"); 41__RCSID("$NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $");
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44#include <ctype.h> 44#include <ctype.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <string.h> 46#include <string.h>
47 47
48#include "el.h" 48#include "el.h"
49 49
50#define CT_BUFSIZ ((size_t)1024) 50#define CT_BUFSIZ ((size_t)1024)
51 51
52#ifdef WIDECHAR 52#ifdef WIDECHAR
53protected int 53protected int
54ct_conv_cbuff_resize(ct_buffer_t *conv, size_t csize) 54ct_conv_cbuff_resize(ct_buffer_t *conv, size_t csize)
@@ -66,27 +66,27 @@ ct_conv_cbuff_resize(ct_buffer_t *conv,  @@ -66,27 +66,27 @@ ct_conv_cbuff_resize(ct_buffer_t *conv,
66 el_free(conv->cbuff); 66 el_free(conv->cbuff);
67 conv->cbuff = NULL; 67 conv->cbuff = NULL;
68 return -1; 68 return -1;
69 } 69 }
70 conv->cbuff = p; 70 conv->cbuff = p;
71 return 0; 71 return 0;
72} 72}
73 73
74protected int 74protected int
75ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize) 75ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
76{ 76{
77 void *p; 77 void *p;
78 78
79 if (wsize <= conv->wsize)  79 if (wsize <= conv->wsize)
80 return 0; 80 return 0;
81 81
82 conv->wsize = wsize; 82 conv->wsize = wsize;
83 83
84 p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff)); 84 p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
85 if (p == NULL) { 85 if (p == NULL) {
86 conv->wsize = 0; 86 conv->wsize = 0;
87 el_free(conv->wbuff); 87 el_free(conv->wbuff);
88 conv->wbuff = NULL; 88 conv->wbuff = NULL;
89 return -1; 89 return -1;
90 } 90 }
91 conv->wbuff = p; 91 conv->wbuff = p;
92 return 0; 92 return 0;

cvs diff -r1.20 -r1.21 src/lib/libedit/chartype.h (expand / switch to unified diff)

--- src/lib/libedit/chartype.h 2016/02/14 17:06:24 1.20
+++ src/lib/libedit/chartype.h 2016/02/17 19:47:49 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: chartype.h,v 1.20 2016/02/14 17:06:24 christos Exp $ */ 1/* $NetBSD: chartype.h,v 1.21 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -62,27 +62,27 @@ @@ -62,27 +62,27 @@
62 62
63#define ct_mbrtowc mbrtowc 63#define ct_mbrtowc mbrtowc
64#define ct_wctob wctob 64#define ct_wctob wctob
65#define ct_wctomb wctomb 65#define ct_wctomb wctomb
66#define ct_wctomb_reset wctomb(0,0) 66#define ct_wctomb_reset wctomb(0,0)
67#define ct_wcstombs wcstombs 67#define ct_wcstombs wcstombs
68#define ct_mbstowcs mbstowcs 68#define ct_mbstowcs mbstowcs
69 69
70#define Char wchar_t 70#define Char wchar_t
71#define FUN(prefix,rest) prefix ## _w ## rest 71#define FUN(prefix,rest) prefix ## _w ## rest
72#define FUNW(type) type ## _w 72#define FUNW(type) type ## _w
73#define TYPE(type) type ## W 73#define TYPE(type) type ## W
74#define FSTR "%ls" 74#define FSTR "%ls"
75#define STR(x) L ## x 75#define STR(x) L ## x
76#define UC(c) c 76#define UC(c) c
77#define Isalpha(x) iswalpha(x) 77#define Isalpha(x) iswalpha(x)
78#define Isalnum(x) iswalnum(x) 78#define Isalnum(x) iswalnum(x)
79#define Isgraph(x) iswgraph(x) 79#define Isgraph(x) iswgraph(x)
80#define Isspace(x) iswspace(x) 80#define Isspace(x) iswspace(x)
81#define Isdigit(x) iswdigit(x) 81#define Isdigit(x) iswdigit(x)
82#define Iscntrl(x) iswcntrl(x) 82#define Iscntrl(x) iswcntrl(x)
83#define Isprint(x) iswprint(x) 83#define Isprint(x) iswprint(x)
84 84
85#define Isupper(x) iswupper(x) 85#define Isupper(x) iswupper(x)
86#define Islower(x) iswlower(x) 86#define Islower(x) iswlower(x)
87#define Toupper(x) towupper(x) 87#define Toupper(x) towupper(x)
88#define Tolower(x) towlower(x) 88#define Tolower(x) towlower(x)
@@ -103,39 +103,39 @@ @@ -103,39 +103,39 @@
103#define Strcspn(s,r) wcscspn(s,r) 103#define Strcspn(s,r) wcscspn(s,r)
104 104
105#define Strtol(p,e,b) wcstol(p,e,b) 105#define Strtol(p,e,b) wcstol(p,e,b)
106 106
107static inline int 107static inline int
108Width(wchar_t c) 108Width(wchar_t c)
109{ 109{
110 int w = wcwidth(c); 110 int w = wcwidth(c);
111 return w < 0 ? 0 : w; 111 return w < 0 ? 0 : w;
112} 112}
113 113
114#else /* NARROW */ 114#else /* NARROW */
115 115
116size_t ct_mbrtowc(char *, const char *, size_t, void *); 116size_t ct_mbrtowc(char *, const char *, size_t, void *);
117#define ct_wctob(w) ((int)(w)) 117#define ct_wctob(w) ((int)(w))
118#define ct_wctomb error 118#define ct_wctomb error
119#define ct_wctomb_reset  119#define ct_wctomb_reset
120#define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a)) 120#define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a))
121#define ct_mbstowcs(a, b, c) (strncpy(a, b, c), strlen(a)) 121#define ct_mbstowcs(a, b, c) (strncpy(a, b, c), strlen(a))
122 122
123#define Char char 123#define Char char
124#define FUN(prefix,rest) prefix ## _ ## rest 124#define FUN(prefix,rest) prefix ## _ ## rest
125#define FUNW(type) type 125#define FUNW(type) type
126#define TYPE(type) type 126#define TYPE(type) type
127#define FSTR "%s" 127#define FSTR "%s"
128#define STR(x) x 128#define STR(x) x
129#define UC(c) (unsigned char)(c) 129#define UC(c) (unsigned char)(c)
130 130
131#define Isalpha(x) isalpha((unsigned char)x) 131#define Isalpha(x) isalpha((unsigned char)x)
132#define Isalnum(x) isalnum((unsigned char)x) 132#define Isalnum(x) isalnum((unsigned char)x)
133#define Isgraph(x) isgraph((unsigned char)x) 133#define Isgraph(x) isgraph((unsigned char)x)
134#define Isspace(x) isspace((unsigned char)x) 134#define Isspace(x) isspace((unsigned char)x)
135#define Isdigit(x) isdigit((unsigned char)x) 135#define Isdigit(x) isdigit((unsigned char)x)
136#define Iscntrl(x) iscntrl((unsigned char)x) 136#define Iscntrl(x) iscntrl((unsigned char)x)
137#define Isprint(x) isprint((unsigned char)x) 137#define Isprint(x) isprint((unsigned char)x)
138 138
139#define Isupper(x) isupper((unsigned char)x) 139#define Isupper(x) isupper((unsigned char)x)
140#define Islower(x) islower((unsigned char)x) 140#define Islower(x) islower((unsigned char)x)
141#define Toupper(x) toupper((unsigned char)x) 141#define Toupper(x) toupper((unsigned char)x)
@@ -204,27 +204,27 @@ protected size_t ct_enc_width(Char); @@ -204,27 +204,27 @@ protected size_t ct_enc_width(Char);
204#define ct_free_argv(s) 204#define ct_free_argv(s)
205#endif 205#endif
206 206
207#ifndef NARROWCHAR 207#ifndef NARROWCHAR
208/* Encode a characted into the destination buffer, provided there is sufficent 208/* Encode a characted into the destination buffer, provided there is sufficent
209 * buffer space available. Returns the number of bytes used up (zero if the 209 * buffer space available. Returns the number of bytes used up (zero if the
210 * character cannot be encoded, -1 if there was not enough space available). */ 210 * character cannot be encoded, -1 if there was not enough space available). */
211 211
212/* The maximum buffer size to hold the most unwieldly visual representation, 212/* The maximum buffer size to hold the most unwieldly visual representation,
213 * in this case \U+nnnnn. */ 213 * in this case \U+nnnnn. */
214#define VISUAL_WIDTH_MAX ((size_t)8) 214#define VISUAL_WIDTH_MAX ((size_t)8)
215 215
216/* The terminal is thought of in terms of X columns by Y lines. In the cases 216/* The terminal is thought of in terms of X columns by Y lines. In the cases
217 * where a wide character takes up more than one column, the adjacent  217 * where a wide character takes up more than one column, the adjacent
218 * occupied column entries will contain this faux character. */ 218 * occupied column entries will contain this faux character. */
219#define MB_FILL_CHAR ((Char)-1) 219#define MB_FILL_CHAR ((Char)-1)
220 220
221/* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn 221/* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn
222 * style visual expansions. */ 222 * style visual expansions. */
223protected int ct_visual_width(Char); 223protected int ct_visual_width(Char);
224 224
225/* Turn the given character into the appropriate visual format, matching 225/* Turn the given character into the appropriate visual format, matching
226 * the width given by ct_visual_width(). Returns the number of characters used 226 * the width given by ct_visual_width(). Returns the number of characters used
227 * up, or -1 if insufficient space. Buffer length is in count of Char's. */ 227 * up, or -1 if insufficient space. Buffer length is in count of Char's. */
228protected ssize_t ct_visual_char(Char *, size_t, Char); 228protected ssize_t ct_visual_char(Char *, size_t, Char);
229 229
230/* Convert the given string into visual format, using the ct_visual_char() 230/* Convert the given string into visual format, using the ct_visual_char()

cvs diff -r1.37 -r1.38 src/lib/libedit/common.c (expand / switch to unified diff)

--- src/lib/libedit/common.c 2016/02/16 22:53:14 1.37
+++ src/lib/libedit/common.c 2016/02/17 19:47:49 1.38
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: common.c,v 1.37 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: common.c,v 1.38 2016/02/17 19:47:49 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[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: common.c,v 1.37 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: common.c,v 1.38 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * common.c: Common Editor functions 45 * common.c: Common Editor functions
46 */ 46 */
47#include <ctype.h> 47#include <ctype.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "el.h" 50#include "el.h"
51#include "common.h" 51#include "common.h"
52#include "parse.h" 52#include "parse.h"
53#include "vi.h" 53#include "vi.h"
@@ -443,111 +443,111 @@ ed_unassigned(EditLine *el __attribute__ @@ -443,111 +443,111 @@ ed_unassigned(EditLine *el __attribute__
443} 443}
444 444
445 445
446/** 446/**
447 ** TTY key handling. 447 ** TTY key handling.
448 **/ 448 **/
449 449
450/* ed_tty_sigint(): 450/* ed_tty_sigint():
451 * Tty interrupt character 451 * Tty interrupt character
452 * [^C] 452 * [^C]
453 */ 453 */
454protected el_action_t 454protected el_action_t
455/*ARGSUSED*/ 455/*ARGSUSED*/
456ed_tty_sigint(EditLine *el __attribute__((__unused__)),  456ed_tty_sigint(EditLine *el __attribute__((__unused__)),
457 wint_t c __attribute__((__unused__))) 457 wint_t c __attribute__((__unused__)))
458{ 458{
459 459
460 return CC_NORM; 460 return CC_NORM;
461} 461}
462 462
463 463
464/* ed_tty_dsusp(): 464/* ed_tty_dsusp():
465 * Tty delayed suspend character 465 * Tty delayed suspend character
466 * [^Y] 466 * [^Y]
467 */ 467 */
468protected el_action_t 468protected el_action_t
469/*ARGSUSED*/ 469/*ARGSUSED*/
470ed_tty_dsusp(EditLine *el __attribute__((__unused__)),  470ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
471 wint_t c __attribute__((__unused__))) 471 wint_t c __attribute__((__unused__)))
472{ 472{
473 473
474 return CC_NORM; 474 return CC_NORM;
475} 475}
476 476
477 477
478/* ed_tty_flush_output(): 478/* ed_tty_flush_output():
479 * Tty flush output characters 479 * Tty flush output characters
480 * [^O] 480 * [^O]
481 */ 481 */
482protected el_action_t 482protected el_action_t
483/*ARGSUSED*/ 483/*ARGSUSED*/
484ed_tty_flush_output(EditLine *el __attribute__((__unused__)),  484ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
485 wint_t c __attribute__((__unused__))) 485 wint_t c __attribute__((__unused__)))
486{ 486{
487 487
488 return CC_NORM; 488 return CC_NORM;
489} 489}
490 490
491 491
492/* ed_tty_sigquit(): 492/* ed_tty_sigquit():
493 * Tty quit character 493 * Tty quit character
494 * [^\] 494 * [^\]
495 */ 495 */
496protected el_action_t 496protected el_action_t
497/*ARGSUSED*/ 497/*ARGSUSED*/
498ed_tty_sigquit(EditLine *el __attribute__((__unused__)),  498ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
499 wint_t c __attribute__((__unused__))) 499 wint_t c __attribute__((__unused__)))
500{ 500{
501 501
502 return CC_NORM; 502 return CC_NORM;
503} 503}
504 504
505 505
506/* ed_tty_sigtstp(): 506/* ed_tty_sigtstp():
507 * Tty suspend character 507 * Tty suspend character
508 * [^Z] 508 * [^Z]
509 */ 509 */
510protected el_action_t 510protected el_action_t
511/*ARGSUSED*/ 511/*ARGSUSED*/
512ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),  512ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
513 wint_t c __attribute__((__unused__))) 513 wint_t c __attribute__((__unused__)))
514{ 514{
515 515
516 return CC_NORM; 516 return CC_NORM;
517} 517}
518 518
519 519
520/* ed_tty_stop_output(): 520/* ed_tty_stop_output():
521 * Tty disallow output characters 521 * Tty disallow output characters
522 * [^S] 522 * [^S]
523 */ 523 */
524protected el_action_t 524protected el_action_t
525/*ARGSUSED*/ 525/*ARGSUSED*/
526ed_tty_stop_output(EditLine *el __attribute__((__unused__)),  526ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
527 wint_t c __attribute__((__unused__))) 527 wint_t c __attribute__((__unused__)))
528{ 528{
529 529
530 return CC_NORM; 530 return CC_NORM;
531} 531}
532 532
533 533
534/* ed_tty_start_output(): 534/* ed_tty_start_output():
535 * Tty allow output characters 535 * Tty allow output characters
536 * [^Q] 536 * [^Q]
537 */ 537 */
538protected el_action_t 538protected el_action_t
539/*ARGSUSED*/ 539/*ARGSUSED*/
540ed_tty_start_output(EditLine *el __attribute__((__unused__)),  540ed_tty_start_output(EditLine *el __attribute__((__unused__)),
541 wint_t c __attribute__((__unused__))) 541 wint_t c __attribute__((__unused__)))
542{ 542{
543 543
544 return CC_NORM; 544 return CC_NORM;
545} 545}
546 546
547 547
548/* ed_newline(): 548/* ed_newline():
549 * Execute command 549 * Execute command
550 * [^J] 550 * [^J]
551 */ 551 */
552protected el_action_t 552protected el_action_t
553/*ARGSUSED*/ 553/*ARGSUSED*/
@@ -592,27 +592,27 @@ ed_clear_screen(EditLine *el, wint_t c _ @@ -592,27 +592,27 @@ ed_clear_screen(EditLine *el, wint_t c _
592 592
593 terminal_clear_screen(el); /* clear the whole real screen */ 593 terminal_clear_screen(el); /* clear the whole real screen */
594 re_clear_display(el); /* reset everything */ 594 re_clear_display(el); /* reset everything */
595 return CC_REFRESH; 595 return CC_REFRESH;
596} 596}
597 597
598 598
599/* ed_redisplay(): 599/* ed_redisplay():
600 * Redisplay everything 600 * Redisplay everything
601 * ^R 601 * ^R
602 */ 602 */
603protected el_action_t 603protected el_action_t
604/*ARGSUSED*/ 604/*ARGSUSED*/
605ed_redisplay(EditLine *el __attribute__((__unused__)),  605ed_redisplay(EditLine *el __attribute__((__unused__)),
606 wint_t c __attribute__((__unused__))) 606 wint_t c __attribute__((__unused__)))
607{ 607{
608 608
609 return CC_REDISPLAY; 609 return CC_REDISPLAY;
610} 610}
611 611
612 612
613/* ed_start_over(): 613/* ed_start_over():
614 * Erase current line and start from scratch 614 * Erase current line and start from scratch
615 * [^G] 615 * [^G]
616 */ 616 */
617protected el_action_t 617protected el_action_t
618/*ARGSUSED*/ 618/*ARGSUSED*/
@@ -620,27 +620,27 @@ ed_start_over(EditLine *el, wint_t c __a @@ -620,27 +620,27 @@ ed_start_over(EditLine *el, wint_t c __a
620{ 620{
621 621
622 ch_reset(el, 0); 622 ch_reset(el, 0);
623 return CC_REFRESH; 623 return CC_REFRESH;
624} 624}
625 625
626 626
627/* ed_sequence_lead_in(): 627/* ed_sequence_lead_in():
628 * First character in a bound sequence 628 * First character in a bound sequence
629 * Placeholder for external keys 629 * Placeholder for external keys
630 */ 630 */
631protected el_action_t 631protected el_action_t
632/*ARGSUSED*/ 632/*ARGSUSED*/
633ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),  633ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
634 wint_t c __attribute__((__unused__))) 634 wint_t c __attribute__((__unused__)))
635{ 635{
636 636
637 return CC_NORM; 637 return CC_NORM;
638} 638}
639 639
640 640
641/* ed_prev_history(): 641/* ed_prev_history():
642 * Move to the previous history line 642 * Move to the previous history line
643 * [^P] [k] 643 * [^P] [k]
644 */ 644 */
645protected el_action_t 645protected el_action_t
646/*ARGSUSED*/ 646/*ARGSUSED*/
@@ -654,27 +654,26 @@ ed_prev_history(EditLine *el, wint_t c _ @@ -654,27 +654,26 @@ ed_prev_history(EditLine *el, wint_t c _
654 654
655 if (el->el_history.eventno == 0) { /* save the current buffer 655 if (el->el_history.eventno == 0) { /* save the current buffer
656 * away */ 656 * away */
657 (void) Strncpy(el->el_history.buf, el->el_line.buffer, 657 (void) Strncpy(el->el_history.buf, el->el_line.buffer,
658 EL_BUFSIZ); 658 EL_BUFSIZ);
659 el->el_history.last = el->el_history.buf + 659 el->el_history.last = el->el_history.buf +
660 (el->el_line.lastchar - el->el_line.buffer); 660 (el->el_line.lastchar - el->el_line.buffer);
661 } 661 }
662 el->el_history.eventno += el->el_state.argument; 662 el->el_history.eventno += el->el_state.argument;
663 663
664 if (hist_get(el) == CC_ERROR) { 664 if (hist_get(el) == CC_ERROR) {
665 if (el->el_map.type == MAP_VI) { 665 if (el->el_map.type == MAP_VI) {
666 el->el_history.eventno = sv_event; 666 el->el_history.eventno = sv_event;
667  
668 } 667 }
669 beep = 1; 668 beep = 1;
670 /* el->el_history.eventno was fixed by first call */ 669 /* el->el_history.eventno was fixed by first call */
671 (void) hist_get(el); 670 (void) hist_get(el);
672 } 671 }
673 if (beep) 672 if (beep)
674 return CC_REFRESH_BEEP; 673 return CC_REFRESH_BEEP;
675 return CC_REFRESH; 674 return CC_REFRESH;
676} 675}
677 676
678 677
679/* ed_next_history(): 678/* ed_next_history():
680 * Move to the next history line 679 * Move to the next history line

cvs diff -r1.81 -r1.82 src/lib/libedit/el.c (expand / switch to unified diff)

--- src/lib/libedit/el.c 2016/02/16 19:08:41 1.81
+++ src/lib/libedit/el.c 2016/02/17 19:47:49 1.82
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: el.c,v 1.81 2016/02/16 19:08:41 christos Exp $ */ 1/* $NetBSD: el.c,v 1.82 2016/02/17 19:47:49 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,39 +27,39 @@ @@ -27,39 +27,39 @@
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[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; 38static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
39#else 39#else
40__RCSID("$NetBSD: el.c,v 1.81 2016/02/16 19:08:41 christos Exp $"); 40__RCSID("$NetBSD: el.c,v 1.82 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * el.c: EditLine interface functions 45 * el.c: EditLine interface functions
46 */ 46 */
47#include <sys/types.h> 47#include <sys/types.h>
48#include <sys/param.h> 48#include <sys/param.h>
49#include <string.h> 
50#include <stdlib.h> 
51#include <stdarg.h> 
52#include <ctype.h> 49#include <ctype.h>
 50#include <stdarg.h>
 51#include <stdlib.h>
 52#include <string.h>
53#ifdef WIDECHAR 53#ifdef WIDECHAR
54#include <locale.h> 54#include <locale.h>
55#include <langinfo.h> 55#include <langinfo.h>
56#endif 56#endif
57 57
58#include "el.h" 58#include "el.h"
59#include "parse.h" 59#include "parse.h"
60 60
61/* el_init(): 61/* el_init():
62 * Initialize editline and set default parameters. 62 * Initialize editline and set default parameters.
63 */ 63 */
64public EditLine * 64public EditLine *
65el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr) 65el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
@@ -427,27 +427,27 @@ FUN(el,get)(EditLine *el, int op, ...) @@ -427,27 +427,27 @@ FUN(el,get)(EditLine *el, int op, ...)
427 break; 427 break;
428 428
429 case EL_TERMINAL: 429 case EL_TERMINAL:
430 terminal_get(el, va_arg(ap, const char **)); 430 terminal_get(el, va_arg(ap, const char **));
431 rv = 0; 431 rv = 0;
432 break; 432 break;
433 433
434 case EL_GETTC: 434 case EL_GETTC:
435 { 435 {
436 static char name[] = "gettc"; 436 static char name[] = "gettc";
437 char *argv[20]; 437 char *argv[20];
438 int i; 438 int i;
439 439
440 for (i = 1; i < (int)__arraycount(argv); i++) 440 for (i = 1; i < (int)__arraycount(argv); i++)
441 if ((argv[i] = va_arg(ap, char *)) == NULL) 441 if ((argv[i] = va_arg(ap, char *)) == NULL)
442 break; 442 break;
443 443
444 argv[0] = name; 444 argv[0] = name;
445 rv = terminal_gettc(el, i, argv); 445 rv = terminal_gettc(el, i, argv);
446 break; 446 break;
447 } 447 }
448 448
449 case EL_GETCFN: 449 case EL_GETCFN:
450 *va_arg(ap, el_rfunc_t *) = el_read_getfn(el); 450 *va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
451 rv = 0; 451 rv = 0;
452 break; 452 break;
453 453

cvs diff -r1.81 -r1.82 src/lib/libedit/read.c (expand / switch to unified diff)

--- src/lib/libedit/read.c 2016/02/16 22:53:14 1.81
+++ src/lib/libedit/read.c 2016/02/17 19:47:49 1.82
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: read.c,v 1.81 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: read.c,v 1.82 2016/02/17 19:47:49 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,41 +27,41 @@ @@ -27,41 +27,41 @@
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[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: read.c,v 1.81 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: read.c,v 1.82 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * read.c: Clean this junk up! This is horrible code. 45 * read.c: Clean this junk up! This is horrible code.
46 * Terminal read functions 46 * Terminal read functions
47 */ 47 */
48#include <ctype.h> 48#include <ctype.h>
49#include <errno.h> 49#include <errno.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <unistd.h> 51#include <limits.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <string.h> 53#include <string.h>
54#include <limits.h> 54#include <unistd.h>
55 55
56#include "el.h" 56#include "el.h"
57 57
58#define OKCMD -1 /* must be -1! */ 58#define OKCMD -1 /* must be -1! */
59 59
60private int read__fixio(int, int); 60private int read__fixio(int, int);
61private int read_preread(EditLine *); 61private int read_preread(EditLine *);
62private int read_char(EditLine *, Char *); 62private int read_char(EditLine *, Char *);
63private int read_getcmd(EditLine *, el_action_t *, Char *); 63private int read_getcmd(EditLine *, el_action_t *, Char *);
64private void read_pop(c_macro_t *); 64private void read_pop(c_macro_t *);
65 65
66/* read_init(): 66/* read_init():
67 * Initialize the read stuff 67 * Initialize the read stuff

cvs diff -r1.32 -r1.33 src/lib/libedit/el.h (expand / switch to unified diff)

--- src/lib/libedit/el.h 2016/02/16 22:53:14 1.32
+++ src/lib/libedit/el.h 2016/02/17 19:47:49 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: el.h,v 1.32 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: el.h,v 1.33 2016/02/17 19:47:49 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.
@@ -57,42 +57,42 @@ @@ -57,42 +57,42 @@
57#define UNBUFFERED 0x08 57#define UNBUFFERED 0x08
58#define CHARSET_IS_UTF8 0x10 58#define CHARSET_IS_UTF8 0x10
59#define NARROW_HISTORY 0x40 59#define NARROW_HISTORY 0x40
60#define NARROW_READ 0x80 60#define NARROW_READ 0x80
61 61
62typedef unsigned char el_action_t; /* Index to command array */ 62typedef unsigned char el_action_t; /* Index to command array */
63 63
64typedef struct coord_t { /* Position on the screen */ 64typedef struct coord_t { /* Position on the screen */
65 int h; 65 int h;
66 int v; 66 int v;
67} coord_t; 67} coord_t;
68 68
69typedef struct el_line_t { 69typedef struct el_line_t {
70 Char *buffer; /* Input line */ 70 Char *buffer; /* Input line */
71 Char *cursor; /* Cursor position */ 71 Char *cursor; /* Cursor position */
72 Char *lastchar; /* Last character */ 72 Char *lastchar; /* Last character */
73 const Char *limit; /* Max position */ 73 const Char *limit; /* Max position */
74} el_line_t; 74} el_line_t;
75 75
76/* 76/*
77 * Editor state 77 * Editor state
78 */ 78 */
79typedef struct el_state_t { 79typedef struct el_state_t {
80 int inputmode; /* What mode are we in? */ 80 int inputmode; /* What mode are we in? */
81 int doingarg; /* Are we getting an argument? */ 81 int doingarg; /* Are we getting an argument? */
82 int argument; /* Numeric argument */ 82 int argument; /* Numeric argument */
83 int metanext; /* Is the next char a meta char */ 83 int metanext; /* Is the next char a meta char */
84 el_action_t lastcmd; /* Previous command */ 84 el_action_t lastcmd; /* Previous command */
85 el_action_t thiscmd; /* this command */ 85 el_action_t thiscmd; /* this command */
86 Char thisch; /* char that generated it */ 86 Char thisch; /* char that generated it */
87} el_state_t; 87} el_state_t;
88 88
89/* 89/*
90 * Until we come up with something better... 90 * Until we come up with something better...
91 */ 91 */
92#define el_malloc(a) malloc(a) 92#define el_malloc(a) malloc(a)
93#define el_realloc(a,b) realloc(a, b) 93#define el_realloc(a,b) realloc(a, b)
94#define el_free(a) free(a) 94#define el_free(a) free(a)
95 95
96#include "tty.h" 96#include "tty.h"
97#include "prompt.h" 97#include "prompt.h"
98#include "keymacro.h" 98#include "keymacro.h"

cvs diff -r1.39 -r1.40 src/lib/libedit/filecomplete.c (expand / switch to unified diff)

--- src/lib/libedit/filecomplete.c 2016/02/16 22:53:14 1.39
+++ src/lib/libedit/filecomplete.c 2016/02/17 19:47:49 1.40
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: filecomplete.c,v 1.39 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
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.
@@ -21,40 +21,40 @@ @@ -21,40 +21,40 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "config.h" 32#include "config.h"
33#if !defined(lint) && !defined(SCCSID) 33#if !defined(lint) && !defined(SCCSID)
34__RCSID("$NetBSD: filecomplete.c,v 1.39 2016/02/16 22:53:14 christos Exp $"); 34__RCSID("$NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $");
35#endif /* not lint && not SCCSID */ 35#endif /* not lint && not SCCSID */
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/stat.h> 38#include <sys/stat.h>
39#include <stdio.h> 
40#include <dirent.h> 39#include <dirent.h>
41#include <string.h> 40#include <errno.h>
 41#include <fcntl.h>
 42#include <limits.h>
42#include <pwd.h> 43#include <pwd.h>
 44#include <stdio.h>
43#include <stdlib.h> 45#include <stdlib.h>
 46#include <string.h>
44#include <unistd.h> 47#include <unistd.h>
45#include <limits.h> 
46#include <errno.h> 
47#include <fcntl.h> 
48 48
49#include "el.h" 49#include "el.h"
50#include "filecomplete.h" 50#include "filecomplete.h"
51 51
52static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', 52static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@',
53 '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0' }; 53 '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0' };
54 54
55 55
56/********************************/ 56/********************************/
57/* completion functions */ 57/* completion functions */
58 58
59/* 59/*
60 * does tilde expansion of strings of type ``~user/foo'' 60 * does tilde expansion of strings of type ``~user/foo''
@@ -83,29 +83,29 @@ fn_tilde_expand(const char *txt) @@ -83,29 +83,29 @@ fn_tilde_expand(const char *txt)
83 if (temp == NULL) 83 if (temp == NULL)
84 return NULL; 84 return NULL;
85 } else { 85 } else {
86 /* text until string after slash */ 86 /* text until string after slash */
87 len = (size_t)(temp - txt + 1); 87 len = (size_t)(temp - txt + 1);
88 temp = el_malloc(len * sizeof(*temp)); 88 temp = el_malloc(len * sizeof(*temp));
89 if (temp == NULL) 89 if (temp == NULL)
90 return NULL; 90 return NULL;
91 (void)strncpy(temp, txt + 1, len - 2); 91 (void)strncpy(temp, txt + 1, len - 2);
92 temp[len - 2] = '\0'; 92 temp[len - 2] = '\0';
93 } 93 }
94 if (temp[0] == 0) { 94 if (temp[0] == 0) {
95#ifdef HAVE_GETPW_R_POSIX 95#ifdef HAVE_GETPW_R_POSIX
96 if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), 96 if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
97 &pass) != 0) 97 &pass) != 0)
98 pass = NULL; 98 pass = NULL;
99#elif HAVE_GETPW_R_DRAFT 99#elif HAVE_GETPW_R_DRAFT
100 pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf)); 100 pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf));
101#else 101#else
102 pass = getpwuid(getuid()); 102 pass = getpwuid(getuid());
103#endif 103#endif
104 } else { 104 } else {
105#ifdef HAVE_GETPW_R_POSIX 105#ifdef HAVE_GETPW_R_POSIX
106 if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) 106 if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0)
107 pass = NULL; 107 pass = NULL;
108#elif HAVE_GETPW_R_DRAFT 108#elif HAVE_GETPW_R_DRAFT
109 pass = getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf)); 109 pass = getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf));
110#else 110#else
111 pass = getpwnam(temp); 111 pass = getpwnam(temp);
@@ -451,27 +451,27 @@ fn_complete(EditLine *el, @@ -451,27 +451,27 @@ fn_complete(EditLine *el,
451 /* or (*attempted_completion_function)() */ 451 /* or (*attempted_completion_function)() */
452 if (point != 0) 452 if (point != 0)
453 *point = (int)(li->cursor - li->buffer); 453 *point = (int)(li->cursor - li->buffer);
454 if (end != NULL) 454 if (end != NULL)
455 *end = (int)(li->lastchar - li->buffer); 455 *end = (int)(li->lastchar - li->buffer);
456 456
457 if (attempted_completion_function) { 457 if (attempted_completion_function) {
458 int cur_off = (int)(li->cursor - li->buffer); 458 int cur_off = (int)(li->cursor - li->buffer);
459 matches = (*attempted_completion_function)( 459 matches = (*attempted_completion_function)(
460 ct_encode_string(temp, &el->el_scratch), 460 ct_encode_string(temp, &el->el_scratch),
461 cur_off - (int)len, cur_off); 461 cur_off - (int)len, cur_off);
462 } else 462 } else
463 matches = 0; 463 matches = 0;
464 if (!attempted_completion_function ||  464 if (!attempted_completion_function ||
465 (over != NULL && !*over && !matches)) 465 (over != NULL && !*over && !matches))
466 matches = completion_matches( 466 matches = completion_matches(
467 ct_encode_string(temp, &el->el_scratch), complet_func); 467 ct_encode_string(temp, &el->el_scratch), complet_func);
468 468
469 if (over != NULL) 469 if (over != NULL)
470 *over = 0; 470 *over = 0;
471 471
472 if (matches) { 472 if (matches) {
473 int i; 473 int i;
474 size_t matches_num, maxlen, match_len, match_display=1; 474 size_t matches_num, maxlen, match_len, match_display=1;
475 475
476 retval = CC_REFRESH; 476 retval = CC_REFRESH;
477 /* 477 /*
@@ -501,27 +501,27 @@ fn_complete(EditLine *el, @@ -501,27 +501,27 @@ fn_complete(EditLine *el,
501 display_matches: 501 display_matches:
502 /* 502 /*
503 * More than one match and requested to list possible 503 * More than one match and requested to list possible
504 * matches. 504 * matches.
505 */ 505 */
506 506
507 for(i = 1, maxlen = 0; matches[i]; i++) { 507 for(i = 1, maxlen = 0; matches[i]; i++) {
508 match_len = strlen(matches[i]); 508 match_len = strlen(matches[i]);
509 if (match_len > maxlen) 509 if (match_len > maxlen)
510 maxlen = match_len; 510 maxlen = match_len;
511 } 511 }
512 /* matches[1] through matches[i-1] are available */ 512 /* matches[1] through matches[i-1] are available */
513 matches_num = (size_t)(i - 1); 513 matches_num = (size_t)(i - 1);
514  514
515 /* newline to get on next line from command line */ 515 /* newline to get on next line from command line */
516 (void)fprintf(el->el_outfile, "\n"); 516 (void)fprintf(el->el_outfile, "\n");
517 517
518 /* 518 /*
519 * If there are too many items, ask user for display 519 * If there are too many items, ask user for display
520 * confirmation. 520 * confirmation.
521 */ 521 */
522 if (matches_num > query_items) { 522 if (matches_num > query_items) {
523 (void)fprintf(el->el_outfile, 523 (void)fprintf(el->el_outfile,
524 "Display all %zu possibilities? (y or n) ", 524 "Display all %zu possibilities? (y or n) ",
525 matches_num); 525 matches_num);
526 (void)fflush(el->el_outfile); 526 (void)fflush(el->el_outfile);
527 if (getc(stdin) != 'y') 527 if (getc(stdin) != 'y')

cvs diff -r1.17 -r1.18 src/lib/libedit/hist.h (expand / switch to unified diff)

--- src/lib/libedit/hist.h 2016/02/16 15:53:48 1.17
+++ src/lib/libedit/hist.h 2016/02/17 19:47:49 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: hist.h,v 1.17 2016/02/16 15:53:48 christos Exp $ */ 1/* $NetBSD: hist.h,v 1.18 2016/02/17 19:47:49 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.
@@ -70,17 +70,17 @@ typedef struct el_history_t { @@ -70,17 +70,17 @@ typedef struct el_history_t {
70#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL) 70#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)
71#define HIST_SET(el, num) HIST_FUN(el, H_SET, num) 71#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)
72#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname) 72#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
73#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname) 73#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
74#define HIST_SAVE_FP(el, fp) HIST_FUN(el, H_SAVE_FP fp) 74#define HIST_SAVE_FP(el, fp) HIST_FUN(el, H_SAVE_FP fp)
75 75
76protected int hist_init(EditLine *); 76protected int hist_init(EditLine *);
77protected void hist_end(EditLine *); 77protected void hist_end(EditLine *);
78protected el_action_t hist_get(EditLine *); 78protected el_action_t hist_get(EditLine *);
79protected int hist_set(EditLine *, hist_fun_t, void *); 79protected int hist_set(EditLine *, hist_fun_t, void *);
80protected int hist_command(EditLine *, int, const Char **); 80protected int hist_command(EditLine *, int, const Char **);
81protected int hist_enlargebuf(EditLine *, size_t, size_t); 81protected int hist_enlargebuf(EditLine *, size_t, size_t);
82#ifdef WIDECHAR 82#ifdef WIDECHAR
83protected wchar_t *hist_convert(EditLine *, int, void *); 83protected wchar_t *hist_convert(EditLine *, int, void *);
84#endif 84#endif
85 85
86#endif /* _h_el_hist */ 86#endif /* _h_el_hist */

cvs diff -r1.54 -r1.55 src/lib/libedit/histedit.h (expand / switch to unified diff)

--- src/lib/libedit/histedit.h 2016/02/16 19:29:51 1.54
+++ src/lib/libedit/histedit.h 2016/02/17 19:47:49 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: histedit.h,v 1.54 2016/02/16 19:29:51 christos Exp $ */ 1/* $NetBSD: histedit.h,v 1.55 2016/02/17 19:47:49 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.
@@ -118,40 +118,40 @@ unsigned char _el_fn_complete(EditLine * @@ -118,40 +118,40 @@ unsigned char _el_fn_complete(EditLine *
118 * el_set/el_get parameters 118 * el_set/el_get parameters
119 * 119 *
120 * When using el_wset/el_wget (as opposed to el_set/el_get): 120 * When using el_wset/el_wget (as opposed to el_set/el_get):
121 * Char is wchar_t, otherwise it is char. 121 * Char is wchar_t, otherwise it is char.
122 * prompt_func is el_wpfunc_t, otherwise it is el_pfunc_t . 122 * prompt_func is el_wpfunc_t, otherwise it is el_pfunc_t .
123 123
124 * Prompt function prototypes are: 124 * Prompt function prototypes are:
125 * typedef char *(*el_pfunct_t) (EditLine *); 125 * typedef char *(*el_pfunct_t) (EditLine *);
126 * typedef wchar_t *(*el_wpfunct_t) (EditLine *); 126 * typedef wchar_t *(*el_wpfunct_t) (EditLine *);
127 * 127 *
128 * For operations that support set or set/get, the argument types listed are for 128 * For operations that support set or set/get, the argument types listed are for
129 * the "set" operation. For "get", each listed type must be a pointer. 129 * the "set" operation. For "get", each listed type must be a pointer.
130 * E.g. EL_EDITMODE takes an int when set, but an int* when get. 130 * E.g. EL_EDITMODE takes an int when set, but an int* when get.
131 *  131 *
132 * Operations that only support "get" have the correct argument types listed. 132 * Operations that only support "get" have the correct argument types listed.
133 */ 133 */
134#define EL_PROMPT 0 /* , prompt_func); set/get */ 134#define EL_PROMPT 0 /* , prompt_func); set/get */
135#define EL_TERMINAL 1 /* , const char *); set/get */ 135#define EL_TERMINAL 1 /* , const char *); set/get */
136#define EL_EDITOR 2 /* , const Char *); set/get */ 136#define EL_EDITOR 2 /* , const Char *); set/get */
137#define EL_SIGNAL 3 /* , int); set/get */ 137#define EL_SIGNAL 3 /* , int); set/get */
138#define EL_BIND 4 /* , const Char *, ..., NULL); set */ 138#define EL_BIND 4 /* , const Char *, ..., NULL); set */
139#define EL_TELLTC 5 /* , const Char *, ..., NULL); set */ 139#define EL_TELLTC 5 /* , const Char *, ..., NULL); set */
140#define EL_SETTC 6 /* , const Char *, ..., NULL); set */ 140#define EL_SETTC 6 /* , const Char *, ..., NULL); set */
141#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */ 141#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */
142#define EL_SETTY 8 /* , const Char *, ..., NULL); set */ 142#define EL_SETTY 8 /* , const Char *, ..., NULL); set */
143#define EL_ADDFN 9 /* , const Char *, const Char, set */ 143#define EL_ADDFN 9 /* , const Char *, const Char, set */
144 /* el_func_t); */ 144 /* el_func_t); */
145#define EL_HIST 10 /* , hist_fun_t, const void *); set */ 145#define EL_HIST 10 /* , hist_fun_t, const void *); set */
146#define EL_EDITMODE 11 /* , int); set/get */ 146#define EL_EDITMODE 11 /* , int); set/get */
147#define EL_RPROMPT 12 /* , prompt_func); set/get */ 147#define EL_RPROMPT 12 /* , prompt_func); set/get */
148#define EL_GETCFN 13 /* , el_rfunc_t); set/get */ 148#define EL_GETCFN 13 /* , el_rfunc_t); set/get */
149#define EL_CLIENTDATA 14 /* , void *); set/get */ 149#define EL_CLIENTDATA 14 /* , void *); set/get */
150#define EL_UNBUFFERED 15 /* , int); set/get */ 150#define EL_UNBUFFERED 15 /* , int); set/get */
151#define EL_PREP_TERM 16 /* , int); set */ 151#define EL_PREP_TERM 16 /* , int); set */
152#define EL_GETTC 17 /* , const Char *, ..., NULL); get */ 152#define EL_GETTC 17 /* , const Char *, ..., NULL); get */
153#define EL_GETFP 18 /* , int, FILE **); get */ 153#define EL_GETFP 18 /* , int, FILE **); get */
154#define EL_SETFP 19 /* , int, FILE *); set */ 154#define EL_SETFP 19 /* , int, FILE *); set */
155#define EL_REFRESH 20 /* , void); set */ 155#define EL_REFRESH 20 /* , void); set */
156#define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */ 156#define EL_PROMPT_ESC 21 /* , prompt_func, Char); set/get */
157#define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */ 157#define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */

cvs diff -r1.51 -r1.52 src/lib/libedit/history.c (expand / switch to unified diff)

--- src/lib/libedit/history.c 2016/02/15 21:35:52 1.51
+++ src/lib/libedit/history.c 2016/02/17 19:47:49 1.52
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: history.c,v 1.51 2016/02/15 21:35:52 christos Exp $ */ 1/* $NetBSD: history.c,v 1.52 2016/02/17 19:47:49 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,38 +27,38 @@ @@ -27,38 +27,38 @@
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[] = "@(#)history.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: history.c,v 1.51 2016/02/15 21:35:52 christos Exp $"); 40__RCSID("$NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * hist.c: TYPE(History) access functions 45 * hist.c: TYPE(History) access functions
46 */ 46 */
47#include <string.h> 47#include <sys/stat.h>
48#include <stdlib.h> 
49#include <stdarg.h> 48#include <stdarg.h>
 49#include <stdlib.h>
 50#include <string.h>
50#include <vis.h> 51#include <vis.h>
51#include <sys/stat.h> 
52 52
53static const char hist_cookie[] = "_HiStOrY_V2_\n"; 53static const char hist_cookie[] = "_HiStOrY_V2_\n";
54 54
55#include "histedit.h" 55#include "histedit.h"
56#include "chartype.h" 56#include "chartype.h"
57 57
58typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *); 58typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *);
59typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *); 59typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
60typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *); 60typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *);
61typedef int (*history_sfun_t)(void *, TYPE(HistEvent) *, const int); 61typedef int (*history_sfun_t)(void *, TYPE(HistEvent) *, const int);
62 62
63struct TYPE(history) { 63struct TYPE(history) {
64 void *h_ref; /* Argument for history fcns */ 64 void *h_ref; /* Argument for history fcns */
@@ -427,27 +427,27 @@ history_def_del(void *p, TYPE(HistEvent) @@ -427,27 +427,27 @@ history_def_del(void *p, TYPE(HistEvent)
427 return -1; 427 return -1;
428 ev->str = Strdup(h->cursor->ev.str); 428 ev->str = Strdup(h->cursor->ev.str);
429 ev->num = h->cursor->ev.num; 429 ev->num = h->cursor->ev.num;
430 history_def_delete(h, ev, h->cursor); 430 history_def_delete(h, ev, h->cursor);
431 return 0; 431 return 0;
432} 432}
433 433
434 434
435/* history_def_delete(): 435/* history_def_delete():
436 * Delete element hp of the h list 436 * Delete element hp of the h list
437 */ 437 */
438/* ARGSUSED */ 438/* ARGSUSED */
439private void 439private void
440history_def_delete(history_t *h,  440history_def_delete(history_t *h,
441 TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp) 441 TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp)
442{ 442{
443 HistEventPrivate *evp = (void *)&hp->ev; 443 HistEventPrivate *evp = (void *)&hp->ev;
444 if (hp == &h->list) 444 if (hp == &h->list)
445 abort(); 445 abort();
446 if (h->cursor == hp) { 446 if (h->cursor == hp) {
447 h->cursor = hp->prev; 447 h->cursor = hp->prev;
448 if (h->cursor == &h->list) 448 if (h->cursor == &h->list)
449 h->cursor = hp->next; 449 h->cursor = hp->next;
450 } 450 }
451 hp->prev->next = hp->next; 451 hp->prev->next = hp->next;
452 hp->next->prev = hp->prev; 452 hp->next->prev = hp->prev;
453 h_free(evp->str); 453 h_free(evp->str);

cvs diff -r1.12 -r1.13 src/lib/libedit/keymacro.c (expand / switch to unified diff)

--- src/lib/libedit/keymacro.c 2016/02/16 15:53:48 1.12
+++ src/lib/libedit/keymacro.c 2016/02/17 19:47:49 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: keymacro.c,v 1.12 2016/02/16 15:53:48 christos Exp $ */ 1/* $NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 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,66 +27,66 @@ @@ -27,66 +27,66 @@
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[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: keymacro.c,v 1.12 2016/02/16 15:53:48 christos Exp $"); 40__RCSID("$NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * keymacro.c: This module contains the procedures for maintaining 45 * keymacro.c: This module contains the procedures for maintaining
46 * the extended-key map. 46 * the extended-key map.
47 * 47 *
48 * An extended-key (key) is a sequence of keystrokes introduced 48 * An extended-key (key) is a sequence of keystrokes introduced
49 * with a sequence introducer and consisting of an arbitrary 49 * with a sequence introducer and consisting of an arbitrary
50 * number of characters. This module maintains a map (the 50 * number of characters. This module maintains a map (the
51 * el->el_keymacro.map) 51 * el->el_keymacro.map)
52 * to convert these extended-key sequences into input strs 52 * to convert these extended-key sequences into input strs
53 * (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE). 53 * (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
54 * 54 *
55 * Warning: 55 * Warning:
56 * If key is a substr of some other keys, then the longer 56 * If key is a substr of some other keys, then the longer
57 * keys are lost!! That is, if the keys "abcd" and "abcef" 57 * keys are lost!! That is, if the keys "abcd" and "abcef"
58 * are in el->el_keymacro.map, adding the key "abc" will cause 58 * are in el->el_keymacro.map, adding the key "abc" will cause
59 * the first two definitions to be lost. 59 * the first two definitions to be lost.
60 * 60 *
61 * Restrictions: 61 * Restrictions:
62 * ------------- 62 * -------------
63 * 1) It is not possible to have one key that is a 63 * 1) It is not possible to have one key that is a
64 * substr of another. 64 * substr of another.
65 */ 65 */
66#include <string.h> 
67#include <stdlib.h> 66#include <stdlib.h>
 67#include <string.h>
68 68
69#include "el.h" 69#include "el.h"
70 70
71/* 71/*
72 * The Nodes of the el->el_keymacro.map. The el->el_keymacro.map is a 72 * The Nodes of the el->el_keymacro.map. The el->el_keymacro.map is a
73 * linked list of these node elements 73 * linked list of these node elements
74 */ 74 */
75struct keymacro_node_t { 75struct keymacro_node_t {
76 Char ch; /* single character of key */ 76 Char ch; /* single character of key */
77 int type; /* node type */ 77 int type; /* node type */
78 keymacro_value_t val; /* command code or pointer to str, */ 78 keymacro_value_t val; /* command code or pointer to str, */
79 /* if this is a leaf */ 79 /* if this is a leaf */
80 struct keymacro_node_t *next; /* ptr to next char of this key */ 80 struct keymacro_node_t *next; /* ptr to next char of this key */
81 struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/ 81 struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/
82}; 82};
83 83
84private int node_trav(EditLine *, keymacro_node_t *, Char *, 84private int node_trav(EditLine *, keymacro_node_t *, Char *,
85 keymacro_value_t *); 85 keymacro_value_t *);
86private int node__try(EditLine *, keymacro_node_t *, const Char *, 86private int node__try(EditLine *, keymacro_node_t *, const Char *,
87 keymacro_value_t *, int); 87 keymacro_value_t *, int);
88private keymacro_node_t *node__get(wint_t); 88private keymacro_node_t *node__get(wint_t);
89private void node__free(keymacro_node_t *); 89private void node__free(keymacro_node_t *);
90private void node__put(EditLine *, keymacro_node_t *); 90private void node__put(EditLine *, keymacro_node_t *);
91private int node__delete(EditLine *, keymacro_node_t **, 91private int node__delete(EditLine *, keymacro_node_t **,
92 const Char *); 92 const Char *);
@@ -265,27 +265,27 @@ keymacro_print(EditLine *el, const Char  @@ -265,27 +265,27 @@ keymacro_print(EditLine *el, const Char
265 return; 265 return;
266 266
267 el->el_keymacro.buf[0] = '"'; 267 el->el_keymacro.buf[0] = '"';
268 if (node_lookup(el, key, el->el_keymacro.map, (size_t)1) <= -1) 268 if (node_lookup(el, key, el->el_keymacro.map, (size_t)1) <= -1)
269 /* key is not bound */ 269 /* key is not bound */
270 (void) fprintf(el->el_errfile, "Unbound extended key \"" FSTR 270 (void) fprintf(el->el_errfile, "Unbound extended key \"" FSTR
271 "\"\n", key); 271 "\"\n", key);
272 return; 272 return;
273} 273}
274 274
275 275
276/* node_trav(): 276/* node_trav():
277 * recursively traverses node in tree until match or mismatch is 277 * recursively traverses node in tree until match or mismatch is
278 * found. May read in more characters. 278 * found. May read in more characters.
279 */ 279 */
280private int 280private int
281node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) 281node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
282{ 282{
283 283
284 if (ptr->ch == *ch) { 284 if (ptr->ch == *ch) {
285 /* match found */ 285 /* match found */
286 if (ptr->next) { 286 if (ptr->next) {
287 /* key not complete so get next char */ 287 /* key not complete so get next char */
288 if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */ 288 if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */
289 val->cmd = ED_END_OF_FILE; 289 val->cmd = ED_END_OF_FILE;
290 return XK_CMD; 290 return XK_CMD;
291 /* PWP: Pretend we just read an end-of-file */ 291 /* PWP: Pretend we just read an end-of-file */
@@ -302,27 +302,27 @@ node_trav(EditLine *el, keymacro_node_t  @@ -302,27 +302,27 @@ node_trav(EditLine *el, keymacro_node_t
302 if (ptr->sibling) { 302 if (ptr->sibling) {
303 /* try next sibling */ 303 /* try next sibling */
304 return node_trav(el, ptr->sibling, ch, val); 304 return node_trav(el, ptr->sibling, ch, val);
305 } else { 305 } else {
306 /* no next sibling -- mismatch */ 306 /* no next sibling -- mismatch */
307 val->str = NULL; 307 val->str = NULL;
308 return XK_STR; 308 return XK_STR;
309 } 309 }
310 } 310 }
311} 311}
312 312
313 313
314/* node__try(): 314/* node__try():
315 * Find a node that matches *str or allocate a new one 315 * Find a node that matches *str or allocate a new one
316 */ 316 */
317private int 317private int
318node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, 318node__try(EditLine *el, keymacro_node_t *ptr, const Char *str,
319 keymacro_value_t *val, int ntype) 319 keymacro_value_t *val, int ntype)
320{ 320{
321 321
322 if (ptr->ch != *str) { 322 if (ptr->ch != *str) {
323 keymacro_node_t *xm; 323 keymacro_node_t *xm;
324 324
325 for (xm = ptr; xm->sibling != NULL; xm = xm->sibling) 325 for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
326 if (xm->sibling->ch == *str) 326 if (xm->sibling->ch == *str)
327 break; 327 break;
328 if (xm->sibling == NULL) 328 if (xm->sibling == NULL)
@@ -584,27 +584,27 @@ node_enum(EditLine *el, keymacro_node_t  @@ -584,27 +584,27 @@ node_enum(EditLine *el, keymacro_node_t
584 */ 584 */
585protected void 585protected void
586keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) 586keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
587{ 587{
588 el_bindings_t *fp; 588 el_bindings_t *fp;
589 char unparsbuf[EL_BUFSIZ]; 589 char unparsbuf[EL_BUFSIZ];
590 static const char fmt[] = "%-15s-> %s\n"; 590 static const char fmt[] = "%-15s-> %s\n";
591 591
592 if (val != NULL) 592 if (val != NULL)
593 switch (ntype) { 593 switch (ntype) {
594 case XK_STR: 594 case XK_STR:
595 case XK_EXE: 595 case XK_EXE:
596 (void) keymacro__decode_str(val->str, unparsbuf, 596 (void) keymacro__decode_str(val->str, unparsbuf,
597 sizeof(unparsbuf),  597 sizeof(unparsbuf),
598 ntype == XK_STR ? "\"\"" : "[]"); 598 ntype == XK_STR ? "\"\"" : "[]");
599 (void) fprintf(el->el_outfile, fmt, 599 (void) fprintf(el->el_outfile, fmt,
600 ct_encode_string(key, &el->el_scratch), unparsbuf); 600 ct_encode_string(key, &el->el_scratch), unparsbuf);
601 break; 601 break;
602 case XK_CMD: 602 case XK_CMD:
603 for (fp = el->el_map.help; fp->name; fp++) 603 for (fp = el->el_map.help; fp->name; fp++)
604 if (val->cmd == fp->func) { 604 if (val->cmd == fp->func) {
605 ct_wcstombs(unparsbuf, fp->name, sizeof(unparsbuf)); 605 ct_wcstombs(unparsbuf, fp->name, sizeof(unparsbuf));
606 unparsbuf[sizeof(unparsbuf) -1] = '\0'; 606 unparsbuf[sizeof(unparsbuf) -1] = '\0';
607 (void) fprintf(el->el_outfile, fmt, 607 (void) fprintf(el->el_outfile, fmt,
608 ct_encode_string(key, &el->el_scratch), unparsbuf); 608 ct_encode_string(key, &el->el_scratch), unparsbuf);
609 break; 609 break;
610 } 610 }

cvs diff -r1.12 -r1.13 src/lib/libedit/prompt.h (expand / switch to unified diff)

--- src/lib/libedit/prompt.h 2016/02/16 15:53:48 1.12
+++ src/lib/libedit/prompt.h 2016/02/17 19:47:49 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: prompt.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */ 1/* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 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.
@@ -36,23 +36,23 @@ @@ -36,23 +36,23 @@
36 36
37/* 37/*
38 * el.prompt.h: Prompt printing stuff 38 * el.prompt.h: Prompt printing stuff
39 */ 39 */
40#ifndef _h_el_prompt 40#ifndef _h_el_prompt
41#define _h_el_prompt 41#define _h_el_prompt
42 42
43typedef Char *(*el_pfunc_t)(EditLine *); 43typedef Char *(*el_pfunc_t)(EditLine *);
44 44
45typedef struct el_prompt_t { 45typedef struct el_prompt_t {
46 el_pfunc_t p_func; /* Function to return the prompt */ 46 el_pfunc_t p_func; /* Function to return the prompt */
47 coord_t p_pos; /* position in the line after prompt */ 47 coord_t p_pos; /* position in the line after prompt */
48 Char p_ignore; /* character to start/end literal */ 48 Char p_ignore; /* character to start/end literal */
49 int p_wide;  49 int p_wide;
50} el_prompt_t; 50} el_prompt_t;
51 51
52protected void prompt_print(EditLine *, int); 52protected void prompt_print(EditLine *, int);
53protected int prompt_set(EditLine *, el_pfunc_t, Char, int, int); 53protected int prompt_set(EditLine *, el_pfunc_t, Char, int, int);
54protected int prompt_get(EditLine *, el_pfunc_t *, Char *, int); 54protected int prompt_get(EditLine *, el_pfunc_t *, Char *, int);
55protected int prompt_init(EditLine *); 55protected int prompt_init(EditLine *);
56protected void prompt_end(EditLine *); 56protected void prompt_end(EditLine *);
57 57
58#endif /* _h_el_prompt */ 58#endif /* _h_el_prompt */

cvs diff -r1.23 -r1.24 src/lib/libedit/makelist (expand / switch to unified diff)

--- src/lib/libedit/makelist 2016/02/16 19:08:41 1.23
+++ src/lib/libedit/makelist 2016/02/17 19:47:49 1.24
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#!/bin/sh - 1#!/bin/sh -
2# $NetBSD: makelist,v 1.23 2016/02/16 19:08:41 christos Exp $ 2# $NetBSD: makelist,v 1.24 2016/02/17 19:47:49 christos Exp $
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.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
@@ -51,27 +51,27 @@ FILES="$@" @@ -51,27 +51,27 @@ FILES="$@"
51 51
52case $FLAG in 52case $FLAG in
53 53
54# generate foo.h file from foo.c 54# generate foo.h file from foo.c
55# 55#
56-n) 56-n)
57 cat << _EOF 57 cat << _EOF
58#include "config.h" 58#include "config.h"
59#undef WIDECHAR 59#undef WIDECHAR
60#define NARROWCHAR 60#define NARROWCHAR
61#include "${FILES}" 61#include "${FILES}"
62_EOF 62_EOF
63 ;; 63 ;;
64  64
65-h) 65-h)
66 set - `echo $FILES | sed -e 's/\\./_/g'` 66 set - `echo $FILES | sed -e 's/\\./_/g'`
67 hdr="_h_`basename $1`" 67 hdr="_h_`basename $1`"
68 cat $FILES | $AWK ' 68 cat $FILES | $AWK '
69 BEGIN { 69 BEGIN {
70 printf("/* Automatically generated file, do not edit */\n"); 70 printf("/* Automatically generated file, do not edit */\n");
71 printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'"); 71 printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'");
72 } 72 }
73 /\(\):/ { 73 /\(\):/ {
74 pr = substr($2, 1, 2); 74 pr = substr($2, 1, 2);
75 if (pr == "vi" || pr == "em" || pr == "ed") { 75 if (pr == "vi" || pr == "em" || pr == "ed") {
76 name = substr($2, 1, length($2) - 3); 76 name = substr($2, 1, length($2) - 3);
77# 77#

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

--- src/lib/libedit/tokenizer.c 2016/02/15 15:37:20 1.23
+++ src/lib/libedit/tokenizer.c 2016/02/17 19:47:49 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tokenizer.c,v 1.23 2016/02/15 15:37:20 christos Exp $ */ 1/* $NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 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,36 +27,37 @@ @@ -27,36 +27,37 @@
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[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: tokenizer.c,v 1.23 2016/02/15 15:37:20 christos Exp $"); 40__RCSID("$NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* We build this file twice, once as NARROW, once as WIDE. */ 44/* We build this file twice, once as NARROW, once as WIDE. */
45/* 45/*
46 * tokenize.c: Bourne shell like tokenizer 46 * tokenize.c: Bourne shell like tokenizer
47 */ 47 */
48#include <string.h> 
49#include <stdlib.h> 48#include <stdlib.h>
 49#include <string.h>
 50
50#include "histedit.h" 51#include "histedit.h"
51#include "chartype.h" 52#include "chartype.h"
52 53
53typedef enum { 54typedef enum {
54 Q_none, Q_single, Q_double, Q_one, Q_doubleone 55 Q_none, Q_single, Q_double, Q_one, Q_doubleone
55} quote_t; 56} quote_t;
56 57
57#define TOK_KEEP 1 58#define TOK_KEEP 1
58#define TOK_EAT 2 59#define TOK_EAT 2
59 60
60#define WINCR 20 61#define WINCR 20
61#define AINCR 10 62#define AINCR 10
62 63

cvs diff -r1.42 -r1.43 src/lib/libedit/map.c (expand / switch to unified diff)

--- src/lib/libedit/map.c 2016/02/16 22:53:14 1.42
+++ src/lib/libedit/map.c 2016/02/17 19:47:49 1.43
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: map.c,v 1.42 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: map.c,v 1.43 2016/02/17 19:47:49 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[] = "@(#)map.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: map.c,v 1.42 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * map.c: Editor function definitions 45 * map.c: Editor function definitions
46 */ 46 */
47#include <ctype.h> 47#include <ctype.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <string.h> 49#include <string.h>
50 50
51#include "el.h" 51#include "el.h"
52#include "help.h" 52#include "help.h"
53#include "parse.h" 53#include "parse.h"
@@ -1149,63 +1149,63 @@ map_print_key(EditLine *el, el_action_t  @@ -1149,63 +1149,63 @@ map_print_key(EditLine *el, el_action_t
1149private void 1149private void
1150map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last) 1150map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
1151{ 1151{
1152 el_bindings_t *bp, *ep; 1152 el_bindings_t *bp, *ep;
1153 Char firstbuf[2], lastbuf[2]; 1153 Char firstbuf[2], lastbuf[2];
1154 char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; 1154 char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
1155 1155
1156 firstbuf[0] = (Char)first; 1156 firstbuf[0] = (Char)first;
1157 firstbuf[1] = 0; 1157 firstbuf[1] = 0;
1158 lastbuf[0] = (Char)last; 1158 lastbuf[0] = (Char)last;
1159 lastbuf[1] = 0; 1159 lastbuf[1] = 0;
1160 if (map[first] == ED_UNASSIGNED) { 1160 if (map[first] == ED_UNASSIGNED) {
1161 if (first == last) { 1161 if (first == last) {
1162 (void) keymacro__decode_str(firstbuf, unparsbuf,  1162 (void) keymacro__decode_str(firstbuf, unparsbuf,
1163 sizeof(unparsbuf), STRQQ); 1163 sizeof(unparsbuf), STRQQ);
1164 (void) fprintf(el->el_outfile, 1164 (void) fprintf(el->el_outfile,
1165 "%-15s-> is undefined\n", unparsbuf); 1165 "%-15s-> is undefined\n", unparsbuf);
1166 } 1166 }
1167 return; 1167 return;
1168 } 1168 }
1169 ep = &el->el_map.help[el->el_map.nfunc]; 1169 ep = &el->el_map.help[el->el_map.nfunc];
1170 for (bp = el->el_map.help; bp < ep; bp++) { 1170 for (bp = el->el_map.help; bp < ep; bp++) {
1171 if (bp->func == map[first]) { 1171 if (bp->func == map[first]) {
1172 if (first == last) { 1172 if (first == last) {
1173 (void) keymacro__decode_str(firstbuf, unparsbuf,  1173 (void) keymacro__decode_str(firstbuf, unparsbuf,
1174 sizeof(unparsbuf), STRQQ); 1174 sizeof(unparsbuf), STRQQ);
1175 (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n", 1175 (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
1176 unparsbuf, bp->name); 1176 unparsbuf, bp->name);
1177 } else { 1177 } else {
1178 (void) keymacro__decode_str(firstbuf, unparsbuf,  1178 (void) keymacro__decode_str(firstbuf, unparsbuf,
1179 sizeof(unparsbuf), STRQQ); 1179 sizeof(unparsbuf), STRQQ);
1180 (void) keymacro__decode_str(lastbuf, extrabuf,  1180 (void) keymacro__decode_str(lastbuf, extrabuf,
1181 sizeof(extrabuf), STRQQ); 1181 sizeof(extrabuf), STRQQ);
1182 (void) fprintf(el->el_outfile, 1182 (void) fprintf(el->el_outfile,
1183 "%-4s to %-7s-> " FSTR "\n", 1183 "%-4s to %-7s-> " FSTR "\n",
1184 unparsbuf, extrabuf, bp->name); 1184 unparsbuf, extrabuf, bp->name);
1185 } 1185 }
1186 return; 1186 return;
1187 } 1187 }
1188 } 1188 }
1189#ifdef MAP_DEBUG 1189#ifdef MAP_DEBUG
1190 if (map == el->el_map.key) { 1190 if (map == el->el_map.key) {
1191 (void) keymacro__decode_str(firstbuf, unparsbuf,  1191 (void) keymacro__decode_str(firstbuf, unparsbuf,
1192 sizeof(unparsbuf), STRQQ); 1192 sizeof(unparsbuf), STRQQ);
1193 (void) fprintf(el->el_outfile, 1193 (void) fprintf(el->el_outfile,
1194 "BUG!!! %s isn't bound to anything.\n", unparsbuf); 1194 "BUG!!! %s isn't bound to anything.\n", unparsbuf);
1195 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n", 1195 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1196 first, el->el_map.key[first]); 1196 first, el->el_map.key[first]);
1197 } else { 1197 } else {
1198 (void) keymacro__decode_str(firstbuf, unparsbuf,  1198 (void) keymacro__decode_str(firstbuf, unparsbuf,
1199 sizeof(unparsbuf), STRQQ); 1199 sizeof(unparsbuf), STRQQ);
1200 (void) fprintf(el->el_outfile, 1200 (void) fprintf(el->el_outfile,
1201 "BUG!!! %s isn't bound to anything.\n", unparsbuf); 1201 "BUG!!! %s isn't bound to anything.\n", unparsbuf);
1202 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n", 1202 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1203 first, el->el_map.alt[first]); 1203 first, el->el_map.alt[first]);
1204 } 1204 }
1205#endif 1205#endif
1206 EL_ABORT((el->el_errfile, "Error printing keys\n")); 1206 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1207} 1207}
1208 1208
1209 1209
1210/* map_print_all_keys(): 1210/* map_print_all_keys():
1211 * Print the function description for all keys. 1211 * Print the function description for all keys.

cvs diff -r1.34 -r1.35 src/lib/libedit/parse.c (expand / switch to unified diff)

--- src/lib/libedit/parse.c 2016/02/16 22:53:14 1.34
+++ src/lib/libedit/parse.c 2016/02/17 19:47:49 1.35
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.34 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 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,56 +27,56 @@ @@ -27,56 +27,56 @@
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[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: parse.c,v 1.34 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * parse.c: parse an editline extended command 45 * parse.c: parse an editline extended command
46 * 46 *
47 * commands are: 47 * commands are:
48 * 48 *
49 * bind 49 * bind
50 * echotc 50 * echotc
51 * edit 51 * edit
52 * gettc 52 * gettc
53 * history 53 * history
54 * settc 54 * settc
55 * setty 55 * setty
56 */ 56 */
57#include <stdlib.h> 57#include <stdlib.h>
58#include <string.h> 58#include <string.h>
59 59
60#include "el.h" 60#include "el.h"
61#include "parse.h" 61#include "parse.h"
62 62
63private const struct { 63private const struct {
64 const Char *name; 64 const Char *name;
65 int (*func)(EditLine *, int, const Char **); 65 int (*func)(EditLine *, int, const Char **);
66} cmds[] = { 66} cmds[] = {
67 { STR("bind"), map_bind }, 67 { STR("bind"), map_bind },
68 { STR("echotc"), terminal_echotc }, 68 { STR("echotc"), terminal_echotc },
69 { STR("edit"), el_editmode }, 69 { STR("edit"), el_editmode },
70 { STR("history"), hist_command }, 70 { STR("history"), hist_command },
71 { STR("telltc"), terminal_telltc }, 71 { STR("telltc"), terminal_telltc },
72 { STR("settc"), terminal_settc }, 72 { STR("settc"), terminal_settc },
73 { STR("setty"), tty_stty }, 73 { STR("setty"), tty_stty },
74 { NULL, NULL } 74 { NULL, NULL }
75}; 75};
76 76
77 77
78/* parse_line(): 78/* parse_line():
79 * Parse a line and dispatch it 79 * Parse a line and dispatch it
80 */ 80 */
81protected int 81protected int
82parse_line(EditLine *el, const Char *line) 82parse_line(EditLine *el, const Char *line)

cvs diff -r1.7 -r1.8 src/lib/libedit/read.h (expand / switch to unified diff)

--- src/lib/libedit/read.h 2009/12/30 22:37:40 1.7
+++ src/lib/libedit/read.h 2016/02/17 19:47:49 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: read.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */ 1/* $NetBSD: read.h,v 1.8 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Anthony Mallet. 8 * by Anthony Mallet.
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.
@@ -30,21 +30,21 @@ @@ -30,21 +30,21 @@
30 */ 30 */
31 31
32/* 32/*
33 * el.read.h: Character reading functions 33 * el.read.h: Character reading functions
34 */ 34 */
35#ifndef _h_el_read 35#ifndef _h_el_read
36#define _h_el_read 36#define _h_el_read
37 37
38typedef int (*el_rfunc_t)(EditLine *, Char *); 38typedef int (*el_rfunc_t)(EditLine *, Char *);
39 39
40typedef struct el_read_t { 40typedef struct el_read_t {
41 el_rfunc_t read_char; /* Function to read a character */ 41 el_rfunc_t read_char; /* Function to read a character */
42} el_read_t; 42} el_read_t;
43  43
44protected int read_init(EditLine *); 44protected int read_init(EditLine *);
45protected void read_prepare(EditLine *); 45protected void read_prepare(EditLine *);
46protected void read_finish(EditLine *); 46protected void read_finish(EditLine *);
47protected int el_read_setfn(EditLine *, el_rfunc_t); 47protected int el_read_setfn(EditLine *, el_rfunc_t);
48protected el_rfunc_t el_read_getfn(EditLine *); 48protected el_rfunc_t el_read_getfn(EditLine *);
49 49
50#endif /* _h_el_read */ 50#endif /* _h_el_read */

cvs diff -r1.124 -r1.125 src/lib/libedit/readline.c (expand / switch to unified diff)

--- src/lib/libedit/readline.c 2016/02/16 19:08:41 1.124
+++ src/lib/libedit/readline.c 2016/02/17 19:47:49 1.125
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: readline.c,v 1.124 2016/02/16 19:08:41 christos Exp $ */ 1/* $NetBSD: readline.c,v 1.125 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
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.
@@ -21,43 +21,43 @@ @@ -21,43 +21,43 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "config.h" 32#include "config.h"
33#if !defined(lint) && !defined(SCCSID) 33#if !defined(lint) && !defined(SCCSID)
34__RCSID("$NetBSD: readline.c,v 1.124 2016/02/16 19:08:41 christos Exp $"); 34__RCSID("$NetBSD: readline.c,v 1.125 2016/02/17 19:47:49 christos Exp $");
35#endif /* not lint && not SCCSID */ 35#endif /* not lint && not SCCSID */
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/stat.h> 38#include <sys/stat.h>
39#include <stdio.h> 
40#include <stdint.h> 
41#include <dirent.h> 
42#include <string.h> 
43#include <pwd.h> 
44#include <ctype.h> 39#include <ctype.h>
45#include <stdlib.h> 40#include <dirent.h>
46#include <unistd.h> 
47#include <limits.h> 
48#include <errno.h> 41#include <errno.h>
49#include <fcntl.h> 42#include <fcntl.h>
 43#include <limits.h>
 44#include <pwd.h>
50#include <setjmp.h> 45#include <setjmp.h>
 46#include <stdint.h>
 47#include <stdio.h>
 48#include <stdlib.h>
 49#include <string.h>
 50#include <unistd.h>
51#include <vis.h> 51#include <vis.h>
52 52
53#include "readline/readline.h" 53#include "readline/readline.h"
54#include "el.h" 54#include "el.h"
55#include "filecomplete.h" 55#include "filecomplete.h"
56 56
57void rl_prep_terminal(int); 57void rl_prep_terminal(int);
58void rl_deprep_terminal(void); 58void rl_deprep_terminal(void);
59 59
60/* for rl_complete() */ 60/* for rl_complete() */
61#define TAB '\r' 61#define TAB '\r'
62 62
63/* see comment at the #ifdef for sense of this */ 63/* see comment at the #ifdef for sense of this */
@@ -256,27 +256,27 @@ _default_history_file(void) @@ -256,27 +256,27 @@ _default_history_file(void)
256 * READLINE compatibility stuff 256 * READLINE compatibility stuff
257 */ 257 */
258 258
259/* 259/*
260 * Set the prompt 260 * Set the prompt
261 */ 261 */
262int 262int
263rl_set_prompt(const char *prompt) 263rl_set_prompt(const char *prompt)
264{ 264{
265 char *p; 265 char *p;
266 266
267 if (!prompt) 267 if (!prompt)
268 prompt = ""; 268 prompt = "";
269 if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)  269 if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
270 return 0; 270 return 0;
271 if (rl_prompt) 271 if (rl_prompt)
272 el_free(rl_prompt); 272 el_free(rl_prompt);
273 rl_prompt = strdup(prompt); 273 rl_prompt = strdup(prompt);
274 if (rl_prompt == NULL) 274 if (rl_prompt == NULL)
275 return -1; 275 return -1;
276 276
277 while ((p = strchr(rl_prompt, RL_PROMPT_END_IGNORE)) != NULL) 277 while ((p = strchr(rl_prompt, RL_PROMPT_END_IGNORE)) != NULL)
278 *p = RL_PROMPT_START_IGNORE; 278 *p = RL_PROMPT_START_IGNORE;
279 279
280 return 0; 280 return 0;
281} 281}
282 282
@@ -350,27 +350,27 @@ rl_initialize(void) @@ -350,27 +350,27 @@ rl_initialize(void)
350 */ 350 */
351 el_set(e, EL_ADDFN, "rl_complete", 351 el_set(e, EL_ADDFN, "rl_complete",
352 "ReadLine compatible completion function", 352 "ReadLine compatible completion function",
353 _el_rl_complete); 353 _el_rl_complete);
354 el_set(e, EL_BIND, "^I", "rl_complete", NULL); 354 el_set(e, EL_BIND, "^I", "rl_complete", NULL);
355 355
356 /* 356 /*
357 * Send TSTP when ^Z is pressed. 357 * Send TSTP when ^Z is pressed.
358 */ 358 */
359 el_set(e, EL_ADDFN, "rl_tstp", 359 el_set(e, EL_ADDFN, "rl_tstp",
360 "ReadLine compatible suspend function", 360 "ReadLine compatible suspend function",
361 _el_rl_tstp); 361 _el_rl_tstp);
362 el_set(e, EL_BIND, "^Z", "rl_tstp", NULL); 362 el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
363  363
364 /* 364 /*
365 * Set some readline compatible key-bindings. 365 * Set some readline compatible key-bindings.
366 */ 366 */
367 el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL); 367 el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL);
368 368
369 /* 369 /*
370 * Allow the use of Home/End keys. 370 * Allow the use of Home/End keys.
371 */ 371 */
372 el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL); 372 el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
373 el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL); 373 el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
374 el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL); 374 el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL);
375 el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL); 375 el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL);
376 el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL); 376 el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL);
@@ -1997,38 +1997,38 @@ rl_callback_read_char(void) @@ -1997,38 +1997,38 @@ rl_callback_read_char(void)
1997 1997
1998 if (done && rl_linefunc != NULL) { 1998 if (done && rl_linefunc != NULL) {
1999 el_set(e, EL_UNBUFFERED, 0); 1999 el_set(e, EL_UNBUFFERED, 0);
2000 if (done == 2) { 2000 if (done == 2) {
2001 if ((wbuf = strdup(buf)) != NULL) 2001 if ((wbuf = strdup(buf)) != NULL)
2002 wbuf[count] = '\0'; 2002 wbuf[count] = '\0';
2003 } else 2003 } else
2004 wbuf = NULL; 2004 wbuf = NULL;
2005 (*(void (*)(const char *))rl_linefunc)(wbuf); 2005 (*(void (*)(const char *))rl_linefunc)(wbuf);
2006 el_set(e, EL_UNBUFFERED, 1); 2006 el_set(e, EL_UNBUFFERED, 1);
2007 } 2007 }
2008} 2008}
2009 2009
2010void  2010void
2011rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc) 2011rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
2012{ 2012{
2013 if (e == NULL) { 2013 if (e == NULL) {
2014 rl_initialize(); 2014 rl_initialize();
2015 } 2015 }
2016 (void)rl_set_prompt(prompt); 2016 (void)rl_set_prompt(prompt);
2017 rl_linefunc = linefunc; 2017 rl_linefunc = linefunc;
2018 el_set(e, EL_UNBUFFERED, 1); 2018 el_set(e, EL_UNBUFFERED, 1);
2019}  2019}
2020 2020
2021void  2021void
2022rl_callback_handler_remove(void) 2022rl_callback_handler_remove(void)
2023{ 2023{
2024 el_set(e, EL_UNBUFFERED, 0); 2024 el_set(e, EL_UNBUFFERED, 0);
2025 rl_linefunc = NULL; 2025 rl_linefunc = NULL;
2026} 2026}
2027 2027
2028void 2028void
2029rl_redisplay(void) 2029rl_redisplay(void)
2030{ 2030{
2031 char a[2]; 2031 char a[2];
2032 a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT]; 2032 a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT];
2033 a[1] = '\0'; 2033 a[1] = '\0';
2034 el_push(e, a); 2034 el_push(e, a);
@@ -2208,27 +2208,27 @@ rl_completion_matches(const char *str, r @@ -2208,27 +2208,27 @@ rl_completion_matches(const char *str, r
2208 if (min > j) 2208 if (min > j)
2209 min = j; 2209 min = j;
2210 } 2210 }
2211 if (min == 0 && *str) { 2211 if (min == 0 && *str) {
2212 if ((list[0] = strdup(str)) == NULL) 2212 if ((list[0] = strdup(str)) == NULL)
2213 goto out; 2213 goto out;
2214 } else { 2214 } else {
2215 if ((list[0] = el_malloc((min + 1) * sizeof(*list[0]))) == NULL) 2215 if ((list[0] = el_malloc((min + 1) * sizeof(*list[0]))) == NULL)
2216 goto out; 2216 goto out;
2217 (void)memcpy(list[0], list[1], min); 2217 (void)memcpy(list[0], list[1], min);
2218 list[0][min] = '\0'; 2218 list[0][min] = '\0';
2219 } 2219 }
2220 return list; 2220 return list;
2221  2221
2222out: 2222out:
2223 el_free(list); 2223 el_free(list);
2224 return NULL; 2224 return NULL;
2225} 2225}
2226 2226
2227char * 2227char *
2228rl_filename_completion_function (const char *text, int state) 2228rl_filename_completion_function (const char *text, int state)
2229{ 2229{
2230 return fn_filename_completion_function(text, state); 2230 return fn_filename_completion_function(text, state);
2231} 2231}
2232 2232
2233void 2233void
2234rl_forced_update_display(void) 2234rl_forced_update_display(void)

cvs diff -r1.43 -r1.44 src/lib/libedit/refresh.c (expand / switch to unified diff)

--- src/lib/libedit/refresh.c 2016/02/16 22:53:14 1.43
+++ src/lib/libedit/refresh.c 2016/02/17 19:47:49 1.44
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: refresh.c,v 1.43 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 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,53 +27,53 @@ @@ -27,53 +27,53 @@
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[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: refresh.c,v 1.43 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: refresh.c,v 1.44 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * refresh.c: Lower level screen refreshing functions 45 * refresh.c: Lower level screen refreshing functions
46 */ 46 */
47#include <stdio.h> 47#include <stdio.h>
48#include <unistd.h> 
49#include <string.h> 48#include <string.h>
 49#include <unistd.h>
50 50
51#include "el.h" 51#include "el.h"
52 52
53private void re_nextline(EditLine *); 53private void re_nextline(EditLine *);
54private void re_addc(EditLine *, wint_t); 54private void re_addc(EditLine *, wint_t);
55private void re_update_line(EditLine *, Char *, Char *, int); 55private void re_update_line(EditLine *, Char *, Char *, int);
56private void re_insert (EditLine *, Char *, int, int, Char *, int); 56private void re_insert (EditLine *, Char *, int, int, Char *, int);
57private void re_delete(EditLine *, Char *, int, int, int); 57private void re_delete(EditLine *, Char *, int, int, int);
58private void re_fastputc(EditLine *, wint_t); 58private void re_fastputc(EditLine *, wint_t);
59private void re_clear_eol(EditLine *, int, int, int); 59private void re_clear_eol(EditLine *, int, int, int);
60private void re__strncopy(Char *, Char *, size_t); 60private void re__strncopy(Char *, Char *, size_t);
61private void re__copy_and_pad(Char *, const Char *, size_t); 61private void re__copy_and_pad(Char *, const Char *, size_t);
62 62
63#ifdef DEBUG_REFRESH 63#ifdef DEBUG_REFRESH
64private void re_printstr(EditLine *, const char *, char *, char *); 64private void re_printstr(EditLine *, const char *, char *, char *);
65#define __F el->el_errfile 65#define __F el->el_errfile
66#define ELRE_ASSERT(a, b, c) do \ 66#define ELRE_ASSERT(a, b, c) do \
67 if (/*CONSTCOND*/ a) { \ 67 if (/*CONSTCOND*/ a) { \
68 (void) fprintf b; \ 68 (void) fprintf b; \
69 c; \ 69 c; \
70 } \ 70 } \
71 while (/*CONSTCOND*/0) 71 while (/*CONSTCOND*/0)
72#define ELRE_DEBUG(a, b) ELRE_ASSERT(a,b,;) 72#define ELRE_DEBUG(a, b) ELRE_ASSERT(a,b,;)
73 73
74/* re_printstr(): 74/* re_printstr():
75 * Print a string on the debugging pty 75 * Print a string on the debugging pty
76 */ 76 */
77private void 77private void
78re_printstr(EditLine *el, const char *str, char *f, char *t) 78re_printstr(EditLine *el, const char *str, char *f, char *t)
79{ 79{
@@ -99,27 +99,27 @@ re_nextline(EditLine *el) @@ -99,27 +99,27 @@ re_nextline(EditLine *el)
99 /* 99 /*
100 * If we would overflow (input is longer than terminal size), 100 * If we would overflow (input is longer than terminal size),
101 * emulate scroll by dropping first line and shuffling the rest. 101 * emulate scroll by dropping first line and shuffling the rest.
102 * We do this via pointer shuffling - it's safe in this case 102 * We do this via pointer shuffling - it's safe in this case
103 * and we avoid memcpy(). 103 * and we avoid memcpy().
104 */ 104 */
105 if (el->el_refresh.r_cursor.v + 1 >= el->el_terminal.t_size.v) { 105 if (el->el_refresh.r_cursor.v + 1 >= el->el_terminal.t_size.v) {
106 int i, lins = el->el_terminal.t_size.v; 106 int i, lins = el->el_terminal.t_size.v;
107 Char *firstline = el->el_vdisplay[0]; 107 Char *firstline = el->el_vdisplay[0];
108 108
109 for(i = 1; i < lins; i++) 109 for(i = 1; i < lins; i++)
110 el->el_vdisplay[i - 1] = el->el_vdisplay[i]; 110 el->el_vdisplay[i - 1] = el->el_vdisplay[i];
111 111
112 firstline[0] = '\0'; /* empty the string */  112 firstline[0] = '\0'; /* empty the string */
113 el->el_vdisplay[i - 1] = firstline; 113 el->el_vdisplay[i - 1] = firstline;
114 } else 114 } else
115 el->el_refresh.r_cursor.v++; 115 el->el_refresh.r_cursor.v++;
116 116
117 ELRE_ASSERT(el->el_refresh.r_cursor.v >= el->el_terminal.t_size.v, 117 ELRE_ASSERT(el->el_refresh.r_cursor.v >= el->el_terminal.t_size.v,
118 (__F, "\r\nre_putc: overflow! r_cursor.v == %d > %d\r\n", 118 (__F, "\r\nre_putc: overflow! r_cursor.v == %d > %d\r\n",
119 el->el_refresh.r_cursor.v, el->el_terminal.t_size.v), 119 el->el_refresh.r_cursor.v, el->el_terminal.t_size.v),
120 abort()); 120 abort());
121} 121}
122 122
123/* re_addc(): 123/* re_addc():
124 * Draw c, expanding tabs, control chars etc. 124 * Draw c, expanding tabs, control chars etc.
125 */ 125 */
@@ -181,27 +181,27 @@ re_putc(EditLine *el, wint_t c, int shif @@ -181,27 +181,27 @@ re_putc(EditLine *el, wint_t c, int shif
181 181
182 el->el_refresh.r_cursor.h += w; /* advance to next place */ 182 el->el_refresh.r_cursor.h += w; /* advance to next place */
183 if (el->el_refresh.r_cursor.h >= el->el_terminal.t_size.h) { 183 if (el->el_refresh.r_cursor.h >= el->el_terminal.t_size.h) {
184 /* assure end of line */ 184 /* assure end of line */
185 el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_terminal.t_size.h] 185 el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_terminal.t_size.h]
186 = '\0'; 186 = '\0';
187 re_nextline(el); 187 re_nextline(el);
188 } 188 }
189} 189}
190 190
191 191
192/* re_refresh(): 192/* re_refresh():
193 * draws the new virtual screen image from the current input 193 * draws the new virtual screen image from the current input
194 * line, then goes line-by-line changing the real image to the new 194 * line, then goes line-by-line changing the real image to the new
195 * virtual image. The routine to re-draw a line can be replaced 195 * virtual image. The routine to re-draw a line can be replaced
196 * easily in hopes of a smarter one being placed there. 196 * easily in hopes of a smarter one being placed there.
197 */ 197 */
198protected void 198protected void
199re_refresh(EditLine *el) 199re_refresh(EditLine *el)
200{ 200{
201 int i, rhdiff; 201 int i, rhdiff;
202 Char *cp, *st; 202 Char *cp, *st;
203 coord_t cur; 203 coord_t cur;
204#ifdef notyet 204#ifdef notyet
205 size_t termsz; 205 size_t termsz;
206#endif 206#endif
207 207
@@ -440,27 +440,27 @@ re_delete(EditLine *el __attribute__((__ @@ -440,27 +440,27 @@ re_delete(EditLine *el __attribute__((__
440private void 440private void
441re__strncopy(Char *a, Char *b, size_t n) 441re__strncopy(Char *a, Char *b, size_t n)
442{ 442{
443 443
444 while (n-- && *b) 444 while (n-- && *b)
445 *a++ = *b++; 445 *a++ = *b++;
446} 446}
447 447
448/* re_clear_eol(): 448/* re_clear_eol():
449 * Find the number of characters we need to clear till the end of line 449 * Find the number of characters we need to clear till the end of line
450 * in order to make sure that we have cleared the previous contents of 450 * in order to make sure that we have cleared the previous contents of
451 * the line. fx and sx is the number of characters inserted or deleted 451 * the line. fx and sx is the number of characters inserted or deleted
452 * in the first or second diff, diff is the difference between the 452 * in the first or second diff, diff is the difference between the
453 * number of characters between the new and old line. 453 * number of characters between the new and old line.
454 */ 454 */
455private void 455private void
456re_clear_eol(EditLine *el, int fx, int sx, int diff) 456re_clear_eol(EditLine *el, int fx, int sx, int diff)
457{ 457{
458 458
459 ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n", 459 ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n",
460 sx, fx, diff)); 460 sx, fx, diff));
461 461
462 if (fx < 0) 462 if (fx < 0)
463 fx = -fx; 463 fx = -fx;
464 if (sx < 0) 464 if (sx < 0)
465 sx = -sx; 465 sx = -sx;
466 if (fx > diff) 466 if (fx > diff)
@@ -1066,27 +1066,27 @@ re_fastputc(EditLine *el, wint_t c) @@ -1066,27 +1066,27 @@ re_fastputc(EditLine *el, wint_t c)
1066 if (el->el_cursor.h >= el->el_terminal.t_size.h) { 1066 if (el->el_cursor.h >= el->el_terminal.t_size.h) {
1067 /* if we must overflow */ 1067 /* if we must overflow */
1068 el->el_cursor.h = 0; 1068 el->el_cursor.h = 0;
1069 1069
1070 /* 1070 /*
1071 * If we would overflow (input is longer than terminal size), 1071 * If we would overflow (input is longer than terminal size),
1072 * emulate scroll by dropping first line and shuffling the rest. 1072 * emulate scroll by dropping first line and shuffling the rest.
1073 * We do this via pointer shuffling - it's safe in this case 1073 * We do this via pointer shuffling - it's safe in this case
1074 * and we avoid memcpy(). 1074 * and we avoid memcpy().
1075 */ 1075 */
1076 if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { 1076 if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) {
1077 int i, lins = el->el_terminal.t_size.v; 1077 int i, lins = el->el_terminal.t_size.v;
1078 Char *firstline = el->el_display[0]; 1078 Char *firstline = el->el_display[0];
1079  1079
1080 for(i = 1; i < lins; i++) 1080 for(i = 1; i < lins; i++)
1081 el->el_display[i - 1] = el->el_display[i]; 1081 el->el_display[i - 1] = el->el_display[i];
1082 1082
1083 re__copy_and_pad(firstline, STR(""), (size_t)0); 1083 re__copy_and_pad(firstline, STR(""), (size_t)0);
1084 el->el_display[i - 1] = firstline; 1084 el->el_display[i - 1] = firstline;
1085 } else { 1085 } else {
1086 el->el_cursor.v++; 1086 el->el_cursor.v++;
1087 el->el_refresh.r_oldcv++; 1087 el->el_refresh.r_oldcv++;
1088 } 1088 }
1089 if (EL_HAS_AUTO_MARGINS) { 1089 if (EL_HAS_AUTO_MARGINS) {
1090 if (EL_HAS_MAGIC_MARGINS) { 1090 if (EL_HAS_MAGIC_MARGINS) {
1091 terminal__putc(el, ' '); 1091 terminal__putc(el, ' ');
1092 terminal__putc(el, '\b'); 1092 terminal__putc(el, '\b');

cvs diff -r1.22 -r1.23 src/lib/libedit/sys.h (expand / switch to unified diff)

--- src/lib/libedit/sys.h 2016/02/16 19:29:51 1.22
+++ src/lib/libedit/sys.h 2016/02/17 19:47:49 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys.h,v 1.22 2016/02/16 19:29:51 christos Exp $ */ 1/* $NetBSD: sys.h,v 1.23 2016/02/17 19:47:49 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.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) 47#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
48# define __attribute__(A) 48# define __attribute__(A)
49#endif 49#endif
50 50
51#ifndef __BEGIN_DECLS 51#ifndef __BEGIN_DECLS
52# ifdef __cplusplus 52# ifdef __cplusplus
53# define __BEGIN_DECLS extern "C" { 53# define __BEGIN_DECLS extern "C" {
54# define __END_DECLS } 54# define __END_DECLS }
55# else 55# else
56# define __BEGIN_DECLS 56# define __BEGIN_DECLS
57# define __END_DECLS 57# define __END_DECLS
58# endif 58# endif
59#endif 59#endif
60  60
61#ifndef public 61#ifndef public
62# define public /* Externally visible functions/variables */ 62# define public /* Externally visible functions/variables */
63#endif 63#endif
64 64
65#ifndef private 65#ifndef private
66# define private static /* Always hidden internals */ 66# define private static /* Always hidden internals */
67#endif 67#endif
68 68
69#ifndef protected 69#ifndef protected
70# define protected /* Redefined from elsewhere to "static" */ 70# define protected /* Redefined from elsewhere to "static" */
71 /* When we want to hide everything */ 71 /* When we want to hide everything */
72#endif 72#endif
73 73
@@ -102,27 +102,27 @@ ssize_t getline(char **line, size_t *len @@ -102,27 +102,27 @@ ssize_t getline(char **line, size_t *len
102 102
103#ifndef HAVE_U_INT32_T 103#ifndef HAVE_U_INT32_T
104typedef unsigned int u_int32_t; 104typedef unsigned int u_int32_t;
105#endif 105#endif
106 106
107#ifndef HAVE_SIZE_MAX 107#ifndef HAVE_SIZE_MAX
108#define SIZE_MAX ((size_t)-1) 108#define SIZE_MAX ((size_t)-1)
109#endif 109#endif
110 110
111#define REGEX /* Use POSIX.2 regular expression functions */ 111#define REGEX /* Use POSIX.2 regular expression functions */
112#undef REGEXP /* Use UNIX V8 regular expression functions */ 112#undef REGEXP /* Use UNIX V8 regular expression functions */
113 113
114#ifndef WIDECHAR 114#ifndef WIDECHAR
115#define setlocale(c, l) /*LINTED*/NULL 115#define setlocale(c, l) /*LINTED*/NULL
116#define nl_langinfo(i) "" 116#define nl_langinfo(i) ""
117#endif 117#endif
118 118
119#if defined(__sun) 119#if defined(__sun)
120extern int tgetent(char *, const char *); 120extern int tgetent(char *, const char *);
121extern int tgetflag(char *); 121extern int tgetflag(char *);
122extern int tgetnum(char *); 122extern int tgetnum(char *);
123extern int tputs(const char *, int, int (*)(int)); 123extern int tputs(const char *, int, int (*)(int));
124extern char* tgoto(const char*, int, int); 124extern char* tgoto(const char*, int, int);
125extern char* tgetstr(char*, char**); 125extern char* tgetstr(char*, char**);
126#endif 126#endif
127 127
128#endif /* _h_sys */ 128#endif /* _h_sys */

cvs diff -r1.21 -r1.22 src/lib/libedit/terminal.c (expand / switch to unified diff)

--- src/lib/libedit/terminal.c 2016/02/16 15:53:48 1.21
+++ src/lib/libedit/terminal.c 2016/02/17 19:47:49 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: terminal.c,v 1.21 2016/02/16 15:53:48 christos Exp $ */ 1/* $NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 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,57 +27,56 @@ @@ -27,57 +27,56 @@
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[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; 38static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
39#else 39#else
40__RCSID("$NetBSD: terminal.c,v 1.21 2016/02/16 15:53:48 christos Exp $"); 40__RCSID("$NetBSD: terminal.c,v 1.22 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * terminal.c: Editor/termcap-curses interface 45 * terminal.c: Editor/termcap-curses interface
46 * We have to declare a static variable here, since the 46 * We have to declare a static variable here, since the
47 * termcap putchar routine does not take an argument! 47 * termcap putchar routine does not take an argument!
48 */ 48 */
49#include <stdio.h> 49#include <sys/types.h>
 50#include <sys/ioctl.h>
 51#include <limits.h>
50#include <signal.h> 52#include <signal.h>
51#include <string.h> 53#include <stdio.h>
52#include <stdlib.h> 54#include <stdlib.h>
 55#include <string.h>
53#include <unistd.h> 56#include <unistd.h>
54#include <limits.h> 
55#ifdef HAVE_TERMCAP_H 57#ifdef HAVE_TERMCAP_H
56#include <termcap.h> 58#include <termcap.h>
57#endif 59#endif
58#ifdef HAVE_CURSES_H 60#ifdef HAVE_CURSES_H
59#include <curses.h> 61#include <curses.h>
60#elif HAVE_NCURSES_H 62#elif HAVE_NCURSES_H
61#include <ncurses.h> 63#include <ncurses.h>
62#endif 64#endif
63 65
64/* Solaris's term.h does horrid things. */ 66/* Solaris's term.h does horrid things. */
65#if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H) 67#if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H)
66#include <term.h> 68#include <term.h>
67#endif 69#endif
68  
69#include <sys/types.h> 
70#include <sys/ioctl.h> 
71 70
72#ifdef _REENTRANT 71#ifdef _REENTRANT
73#include <pthread.h> 72#include <pthread.h>
74#endif 73#endif
75 74
76#include "el.h" 75#include "el.h"
77 76
78/* 77/*
79 * IMPORTANT NOTE: these routines are allowed to look at the current screen 78 * IMPORTANT NOTE: these routines are allowed to look at the current screen
80 * and the current position assuming that it is correct. If this is not 79 * and the current position assuming that it is correct. If this is not
81 * true, then the update will be WRONG! This is (should be) a valid 80 * true, then the update will be WRONG! This is (should be) a valid
82 * assumption... 81 * assumption...
83 */ 82 */
@@ -484,27 +483,27 @@ terminal_free_display(EditLine *el) @@ -484,27 +483,27 @@ terminal_free_display(EditLine *el)
484 } 483 }
485 b = el->el_vdisplay; 484 b = el->el_vdisplay;
486 el->el_vdisplay = NULL; 485 el->el_vdisplay = NULL;
487 if (b != NULL) { 486 if (b != NULL) {
488 for (bufp = b; *bufp != NULL; bufp++) 487 for (bufp = b; *bufp != NULL; bufp++)
489 el_free(*bufp); 488 el_free(*bufp);
490 el_free(b); 489 el_free(b);
491 } 490 }
492} 491}
493 492
494 493
495/* terminal_move_to_line(): 494/* terminal_move_to_line():
496 * move to line <where> (first line == 0) 495 * move to line <where> (first line == 0)
497 * as efficiently as possible 496 * as efficiently as possible
498 */ 497 */
499protected void 498protected void
500terminal_move_to_line(EditLine *el, int where) 499terminal_move_to_line(EditLine *el, int where)
501{ 500{
502 int del; 501 int del;
503 502
504 if (where == el->el_cursor.v) 503 if (where == el->el_cursor.v)
505 return; 504 return;
506 505
507 if (where > el->el_terminal.t_size.v) { 506 if (where > el->el_terminal.t_size.v) {
508#ifdef DEBUG_SCREEN 507#ifdef DEBUG_SCREEN
509 (void) fprintf(el->el_errfile, 508 (void) fprintf(el->el_errfile,
510 "%s: where is ridiculous: %d\r\n", __func__, where); 509 "%s: where is ridiculous: %d\r\n", __func__, where);
@@ -599,27 +598,27 @@ mc_again: @@ -599,27 +598,27 @@ mc_again:
599 (where & ~0x7) 598 (where & ~0x7)
600#ifdef WIDECHAR 599#ifdef WIDECHAR
601 && (el->el_display[ 600 && (el->el_display[
602 el->el_cursor.v][where & 0370] != 601 el->el_cursor.v][where & 0370] !=
603 MB_FILL_CHAR) 602 MB_FILL_CHAR)
604#endif 603#endif
605 ) { 604 ) {
606 /* if not within tab stop */ 605 /* if not within tab stop */
607 for (i = 606 for (i =
608 (el->el_cursor.h & 0370); 607 (el->el_cursor.h & 0370);
609 i < (where & ~0x7); 608 i < (where & ~0x7);
610 i += 8) 609 i += 8)
611 terminal__putc(el, 610 terminal__putc(el,
612 '\t');  611 '\t');
613 /* then tab over */ 612 /* then tab over */
614 el->el_cursor.h = where & ~0x7; 613 el->el_cursor.h = where & ~0x7;
615 } 614 }
616 } 615 }
617 /* 616 /*
618 * it's usually cheaper to just write the 617 * it's usually cheaper to just write the
619 * chars, so we do. 618 * chars, so we do.
620 */ 619 */
621 /* 620 /*
622 * NOTE THAT terminal_overwrite() WILL CHANGE 621 * NOTE THAT terminal_overwrite() WILL CHANGE
623 * el->el_cursor.h!!! 622 * el->el_cursor.h!!!
624 */ 623 */
625 terminal_overwrite(el, &el->el_display[ 624 terminal_overwrite(el, &el->el_display[
@@ -1288,27 +1287,27 @@ terminal_writec(EditLine *el, wint_t c) @@ -1288,27 +1287,27 @@ terminal_writec(EditLine *el, wint_t c)
1288 if (vcnt < 0) 1287 if (vcnt < 0)
1289 vcnt = 0; 1288 vcnt = 0;
1290 visbuf[vcnt] = '\0'; 1289 visbuf[vcnt] = '\0';
1291 terminal_overwrite(el, visbuf, (size_t)vcnt); 1290 terminal_overwrite(el, visbuf, (size_t)vcnt);
1292 terminal__flush(el); 1291 terminal__flush(el);
1293} 1292}
1294 1293
1295 1294
1296/* terminal_telltc(): 1295/* terminal_telltc():
1297 * Print the current termcap characteristics 1296 * Print the current termcap characteristics
1298 */ 1297 */
1299protected int 1298protected int
1300/*ARGSUSED*/ 1299/*ARGSUSED*/
1301terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),  1300terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
1302 const Char **argv __attribute__((__unused__))) 1301 const Char **argv __attribute__((__unused__)))
1303{ 1302{
1304 const struct termcapstr *t; 1303 const struct termcapstr *t;
1305 char **ts; 1304 char **ts;
1306 1305
1307 (void) fprintf(el->el_outfile, "\n\tYour terminal has the\n"); 1306 (void) fprintf(el->el_outfile, "\n\tYour terminal has the\n");
1308 (void) fprintf(el->el_outfile, "\tfollowing characteristics:\n\n"); 1307 (void) fprintf(el->el_outfile, "\tfollowing characteristics:\n\n");
1309 (void) fprintf(el->el_outfile, "\tIt has %d columns and %d lines\n", 1308 (void) fprintf(el->el_outfile, "\tIt has %d columns and %d lines\n",
1310 Val(T_co), Val(T_li)); 1309 Val(T_co), Val(T_li));
1311 (void) fprintf(el->el_outfile, 1310 (void) fprintf(el->el_outfile,
1312 "\tIt has %s meta key\n", EL_HAS_META ? "a" : "no"); 1311 "\tIt has %s meta key\n", EL_HAS_META ? "a" : "no");
1313 (void) fprintf(el->el_outfile, 1312 (void) fprintf(el->el_outfile,
1314 "\tIt can%suse tabs\n", EL_CAN_TAB ? " " : "not "); 1313 "\tIt can%suse tabs\n", EL_CAN_TAB ? " " : "not ");

cvs diff -r1.56 -r1.57 src/lib/libedit/tty.c (expand / switch to unified diff)

--- src/lib/libedit/tty.c 2016/02/16 22:53:14 1.56
+++ src/lib/libedit/tty.c 2016/02/17 19:47:49 1.57
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tty.c,v 1.56 2016/02/16 22:53:14 christos Exp $ */ 1/* $NetBSD: tty.c,v 1.57 2016/02/17 19:47:49 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,39 +27,39 @@ @@ -27,39 +27,39 @@
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[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93"; 38static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
39#else 39#else
40__RCSID("$NetBSD: tty.c,v 1.56 2016/02/16 22:53:14 christos Exp $"); 40__RCSID("$NetBSD: tty.c,v 1.57 2016/02/17 19:47:49 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * tty.c: tty interface stuff 45 * tty.c: tty interface stuff
46 */ 46 */
47#include <assert.h> 47#include <assert.h>
48#include <errno.h> 48#include <errno.h>
49#include <unistd.h> /* for isatty */ 
50#include <strings.h> /* for ffs */ 
51#include <stdlib.h> /* for abort */ 49#include <stdlib.h> /* for abort */
52#include <string.h> 50#include <string.h>
 51#include <strings.h> /* for ffs */
 52#include <unistd.h> /* for isatty */
53 53
54#include "el.h" 54#include "el.h"
55#include "parse.h" 55#include "parse.h"
56 56
57typedef struct ttymodes_t { 57typedef struct ttymodes_t {
58 const char *m_name; 58 const char *m_name;
59 unsigned int m_value; 59 unsigned int m_value;
60 int m_type; 60 int m_type;
61} ttymodes_t; 61} ttymodes_t;
62 62
63typedef struct ttymap_t { 63typedef struct ttymap_t {
64 wint_t nch, och; /* Internal and termio rep of chars */ 64 wint_t nch, och; /* Internal and termio rep of chars */
65 el_action_t bind[3]; /* emacs, vi, and vi-cmd */ 65 el_action_t bind[3]; /* emacs, vi, and vi-cmd */
@@ -968,27 +968,27 @@ tty_update_flags(EditLine *el, int kind) @@ -968,27 +968,27 @@ tty_update_flags(EditLine *el, int kind)
968 968
969 969
970private void 970private void
971tty_update_char(EditLine *el, int mode, int c) { 971tty_update_char(EditLine *el, int mode, int c) {
972 if (!((el->el_tty.t_t[mode][MD_CHAR].t_setmask & C_SH(c))) 972 if (!((el->el_tty.t_t[mode][MD_CHAR].t_setmask & C_SH(c)))
973 && (el->el_tty.t_c[TS_IO][c] != el->el_tty.t_c[EX_IO][c])) 973 && (el->el_tty.t_c[TS_IO][c] != el->el_tty.t_c[EX_IO][c]))
974 el->el_tty.t_c[mode][c] = el->el_tty.t_c[TS_IO][c]; 974 el->el_tty.t_c[mode][c] = el->el_tty.t_c[TS_IO][c];
975 if (el->el_tty.t_t[mode][MD_CHAR].t_clrmask & C_SH(c)) 975 if (el->el_tty.t_t[mode][MD_CHAR].t_clrmask & C_SH(c))
976 el->el_tty.t_c[mode][c] = el->el_tty.t_vdisable; 976 el->el_tty.t_c[mode][c] = el->el_tty.t_vdisable;
977} 977}
978 978
979 979
980/* tty_rawmode(): 980/* tty_rawmode():
981 * Set terminal into 1 character at a time mode. 981 * Set terminal into 1 character at a time mode.
982 */ 982 */
983protected int 983protected int
984tty_rawmode(EditLine *el) 984tty_rawmode(EditLine *el)
985{ 985{
986 986
987 if (el->el_tty.t_mode == ED_IO || el->el_tty.t_mode == QU_IO) 987 if (el->el_tty.t_mode == ED_IO || el->el_tty.t_mode == QU_IO)
988 return 0; 988 return 0;
989 989
990 if (el->el_flags & EDIT_DISABLED) 990 if (el->el_flags & EDIT_DISABLED)
991 return 0; 991 return 0;
992 992
993 if (tty_getty(el, &el->el_tty.t_ts) == -1) { 993 if (tty_getty(el, &el->el_tty.t_ts) == -1) {
994#ifdef DEBUG_TTY 994#ifdef DEBUG_TTY

cvs diff -r1.6 -r1.7 src/lib/libedit/TEST/tc1.c (expand / switch to unified diff)

--- src/lib/libedit/TEST/tc1.c 2014/06/18 20:12:15 1.6
+++ src/lib/libedit/TEST/tc1.c 2016/02/17 19:47:49 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $ */ 1/* $NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 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.
@@ -32,42 +32,42 @@ @@ -32,42 +32,42 @@
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include "config.h" 35#include "config.h"
36#ifndef lint 36#ifndef lint
37__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ 37__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
38 The Regents of the University of California. All rights reserved.\n"); 38 The Regents of the University of California. All rights reserved.\n");
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#if !defined(lint) && !defined(SCCSID) 41#if !defined(lint) && !defined(SCCSID)
42#if 0 42#if 0
43static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93"; 43static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
44#else 44#else
45__RCSID("$NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $"); 45__RCSID("$NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $");
46#endif 46#endif
47#endif /* not lint && not SCCSID */ 47#endif /* not lint && not SCCSID */
48 48
49/* 49/*
50 * test.c: A little test program 50 * test.c: A little test program
51 */ 51 */
52#include <stdio.h> 
53#include <string.h> 
54#include <signal.h> 
55#include <sys/wait.h> 52#include <sys/wait.h>
56#include <ctype.h> 53#include <ctype.h>
57#include <stdlib.h> 
58#include <unistd.h> 
59#include <dirent.h> 54#include <dirent.h>
60#include <locale.h> 55#include <locale.h>
 56#include <signal.h>
 57#include <stdio.h>
 58#include <stdlib.h>
 59#include <string.h>
 60#include <unistd.h>
61 61
62#include "histedit.h" 62#include "histedit.h"
63 63
64static int continuation = 0; 64static int continuation = 0;
65volatile sig_atomic_t gotsig = 0; 65volatile sig_atomic_t gotsig = 0;
66 66
67static unsigned char complete(EditLine *, int); 67static unsigned char complete(EditLine *, int);
68 int main(int, char **); 68 int main(int, char **);
69static char *prompt(EditLine *); 69static char *prompt(EditLine *);
70static void sig(int); 70static void sig(int);
71 71
72static char * 72static char *
73prompt(EditLine *el) 73prompt(EditLine *el)
@@ -147,27 +147,27 @@ main(int argc, char *argv[]) @@ -147,27 +147,27 @@ main(int argc, char *argv[])
147 /* Initialize editline */ 147 /* Initialize editline */
148 el = el_init(*argv, stdin, stdout, stderr); 148 el = el_init(*argv, stdin, stdout, stderr);
149 149
150 el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */ 150 el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */
151 el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */ 151 el_set(el, EL_SIGNAL, 1); /* Handle signals gracefully */
152 el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */ 152 el_set(el, EL_PROMPT_ESC, prompt, '\1');/* Set the prompt function */
153 153
154 /* Tell editline to use this history interface */ 154 /* Tell editline to use this history interface */
155 el_set(el, EL_HIST, history, hist); 155 el_set(el, EL_HIST, history, hist);
156 156
157 /* Add a user-defined function */ 157 /* Add a user-defined function */
158 el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete); 158 el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
159 159
160 /* Bind tab to it */ 160 /* Bind tab to it */
161 el_set(el, EL_BIND, "^I", "ed-complete", NULL); 161 el_set(el, EL_BIND, "^I", "ed-complete", NULL);
162 162
163 /* 163 /*
164 * Bind j, k in vi command mode to previous and next line, instead 164 * Bind j, k in vi command mode to previous and next line, instead
165 * of previous and next history. 165 * of previous and next history.
166 */ 166 */
167 el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL); 167 el_set(el, EL_BIND, "-a", "k", "ed-prev-line", NULL);
168 el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL); 168 el_set(el, EL_BIND, "-a", "j", "ed-next-line", NULL);
169 169
170 /* 170 /*
171 * Source the user's defaults file. 171 * Source the user's defaults file.
172 */ 172 */
173 el_source(el, NULL); 173 el_source(el, NULL);

cvs diff -r1.7 -r1.8 src/lib/libedit/TEST/wtc1.c (expand / switch to unified diff)

--- src/lib/libedit/TEST/wtc1.c 2014/06/18 20:12:15 1.7
+++ src/lib/libedit/TEST/wtc1.c 2016/02/17 19:47:49 1.8
@@ -1,24 +1,24 @@ @@ -1,24 +1,24 @@
1#include <stdio.h> 
2#include <string.h> 
3#include <signal.h> 
4#include <sys/wait.h> 1#include <sys/wait.h>
5#include <err.h> 
6#include <ctype.h> 2#include <ctype.h>
7#include <stdlib.h> 
8#include <unistd.h> 
9#include <dirent.h> 3#include <dirent.h>
 4#include <err.h>
10#include <limits.h> 5#include <limits.h>
11#include <locale.h> 6#include <locale.h>
 7#include <signal.h>
 8#include <stdio.h>
 9#include <stdlib.h>
 10#include <string.h>
 11#include <unistd.h>
12 12
13#include "../histedit.h" 13#include "../histedit.h"
14 14
15 15
16static int continuation; 16static int continuation;
17volatile sig_atomic_t gotsig; 17volatile sig_atomic_t gotsig;
18static const char hfile[] = ".whistory"; 18static const char hfile[] = ".whistory";
19 19
20static wchar_t * 20static wchar_t *
21prompt(EditLine *el) 21prompt(EditLine *el)
22{ 22{
23 static wchar_t a[] = L"\1\033[7m\1Edit$\1\033[0m\1 "; 23 static wchar_t a[] = L"\1\033[7m\1Edit$\1\033[0m\1 ";
24 static wchar_t b[] = L"Edit> "; 24 static wchar_t b[] = L"Edit> ";

cvs diff -r1.7 -r1.8 src/lib/libedit/readline/Makefile (expand / switch to unified diff)

--- src/lib/libedit/readline/Makefile 2003/08/03 09:23:15 1.7
+++ src/lib/libedit/readline/Makefile 2016/02/17 19:47:49 1.8
@@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
1# $NetBSD: Makefile,v 1.7 2003/08/03 09:23:15 lukem Exp $  1# $NetBSD: Makefile,v 1.8 2016/02/17 19:47:49 christos Exp $
2 2
3NOOBJ= # defined 3NOOBJ= # defined
4 4
5.include <bsd.own.mk> 5.include <bsd.own.mk>
6 6
7.PATH: ${NETBSDSRCDIR}/lib/libedit 7.PATH: ${NETBSDSRCDIR}/lib/libedit
8 8
9INCS= readline.h 9INCS= readline.h
10INCSDIR= /usr/include/readline 10INCSDIR= /usr/include/readline
11INCSYMLINKS= readline.h ${INCSDIR}/history.h 11INCSYMLINKS= readline.h ${INCSDIR}/history.h
12 12
13.include <bsd.prog.mk> 13.include <bsd.prog.mk>

cvs diff -r1.38 -r1.39 src/lib/libedit/readline/readline.h (expand / switch to unified diff)

--- src/lib/libedit/readline/readline.h 2016/02/15 21:58:38 1.38
+++ src/lib/libedit/readline/readline.h 2016/02/17 19:47:49 1.39
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: readline.h,v 1.38 2016/02/15 21:58:38 christos Exp $ */ 1/* $NetBSD: readline.h,v 1.39 2016/02/17 19:47:49 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek. 8 * by Jaromir Dolecek.
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.
@@ -43,27 +43,27 @@ typedef void rl_vcpfunc_t(char *); @@ -43,27 +43,27 @@ typedef void rl_vcpfunc_t(char *);
43typedef char **rl_completion_func_t(const char *, int, int); 43typedef char **rl_completion_func_t(const char *, int, int);
44typedef char *rl_compentry_func_t(const char *, int); 44typedef char *rl_compentry_func_t(const char *, int);
45typedef int rl_command_func_t(int, int); 45typedef int rl_command_func_t(int, int);
46 46
47/* only supports length */ 47/* only supports length */
48typedef struct { 48typedef struct {
49 int length; 49 int length;
50} HISTORY_STATE; 50} HISTORY_STATE;
51 51
52typedef void *histdata_t; 52typedef void *histdata_t;
53 53
54typedef struct _hist_entry { 54typedef struct _hist_entry {
55 const char *line; 55 const char *line;
56 histdata_t data; 56 histdata_t data;
57} HIST_ENTRY; 57} HIST_ENTRY;
58 58
59typedef struct _keymap_entry { 59typedef struct _keymap_entry {
60 char type; 60 char type;
61#define ISFUNC 0 61#define ISFUNC 0
62#define ISKMAP 1 62#define ISKMAP 1
63#define ISMACR 2 63#define ISMACR 2
64 Function *function; 64 Function *function;
65} KEYMAP_ENTRY; 65} KEYMAP_ENTRY;
66 66
67#define KEYMAP_SIZE 256 67#define KEYMAP_SIZE 256
68 68
69typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; 69typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
@@ -77,36 +77,36 @@ typedef KEYMAP_ENTRY *Keymap; @@ -77,36 +77,36 @@ typedef KEYMAP_ENTRY *Keymap;
77#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) 77#if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
78#include <sys/ttydefaults.h> 78#include <sys/ttydefaults.h>
79#endif 79#endif
80#ifndef CTRL 80#ifndef CTRL
81#define CTRL(c) ((c) & 037) 81#define CTRL(c) ((c) & 037)
82#endif 82#endif
83#endif 83#endif
84#ifndef UNCTRL 84#ifndef UNCTRL
85#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit) 85#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
86#endif 86#endif
87 87
88#define RUBOUT 0x7f 88#define RUBOUT 0x7f
89#define ABORT_CHAR CTRL('G') 89#define ABORT_CHAR CTRL('G')
90#define RL_READLINE_VERSION 0x0402 90#define RL_READLINE_VERSION 0x0402
91#define RL_PROMPT_START_IGNORE '\1' 91#define RL_PROMPT_START_IGNORE '\1'
92#define RL_PROMPT_END_IGNORE '\2' 92#define RL_PROMPT_END_IGNORE '\2'
93 93
94/* global variables used by readline enabled applications */ 94/* global variables used by readline enabled applications */
95#ifdef __cplusplus 95#ifdef __cplusplus
96extern "C" { 96extern "C" {
97#endif 97#endif
98extern const char *rl_library_version; 98extern const char *rl_library_version;
99extern int rl_readline_version;  99extern int rl_readline_version;
100extern char *rl_readline_name; 100extern char *rl_readline_name;
101extern FILE *rl_instream; 101extern FILE *rl_instream;
102extern FILE *rl_outstream; 102extern FILE *rl_outstream;
103extern char *rl_line_buffer; 103extern char *rl_line_buffer;
104extern int rl_point, rl_end; 104extern int rl_point, rl_end;
105extern int history_base, history_length; 105extern int history_base, history_length;
106extern int max_input_history; 106extern int max_input_history;
107extern char *rl_basic_word_break_characters; 107extern char *rl_basic_word_break_characters;
108extern char *rl_completer_word_break_characters; 108extern char *rl_completer_word_break_characters;
109extern char *rl_completer_quote_characters; 109extern char *rl_completer_quote_characters;
110extern rl_compentry_func_t *rl_completion_entry_function; 110extern rl_compentry_func_t *rl_completion_entry_function;
111extern char *(*rl_completion_word_break_hook)(void); 111extern char *(*rl_completion_word_break_hook)(void);
112extern rl_completion_func_t *rl_attempted_completion_function; 112extern rl_completion_func_t *rl_attempted_completion_function;
@@ -187,30 +187,30 @@ void rl_callback_handler_install(const @@ -187,30 +187,30 @@ void rl_callback_handler_install(const
187void rl_callback_handler_remove(void); 187void rl_callback_handler_remove(void);
188void rl_redisplay(void); 188void rl_redisplay(void);
189int rl_get_previous_history(int, int); 189int rl_get_previous_history(int, int);
190void rl_prep_terminal(int); 190void rl_prep_terminal(int);
191void rl_deprep_terminal(void); 191void rl_deprep_terminal(void);
192int rl_read_init_file(const char *); 192int rl_read_init_file(const char *);
193int rl_parse_and_bind(const char *); 193int rl_parse_and_bind(const char *);
194int rl_variable_bind(const char *, const char *); 194int rl_variable_bind(const char *, const char *);
195void rl_stuff_char(int); 195void rl_stuff_char(int);
196int rl_add_defun(const char *, rl_command_func_t *, int); 196int rl_add_defun(const char *, rl_command_func_t *, int);
197HISTORY_STATE *history_get_history_state(void); 197HISTORY_STATE *history_get_history_state(void);
198void rl_get_screen_size(int *, int *); 198void rl_get_screen_size(int *, int *);
199void rl_set_screen_size(int, int); 199void rl_set_screen_size(int, int);
200char *rl_filename_completion_function (const char *, int); 200char *rl_filename_completion_function (const char *, int);
201int _rl_abort_internal(void); 201int _rl_abort_internal(void);
202int _rl_qsort_string_compare(char **, char **); 202int _rl_qsort_string_compare(char **, char **);
203char **rl_completion_matches(const char *, rl_compentry_func_t *); 203char **rl_completion_matches(const char *, rl_compentry_func_t *);
204void rl_forced_update_display(void); 204void rl_forced_update_display(void);
205int rl_set_prompt(const char *); 205int rl_set_prompt(const char *);
206int rl_on_new_line(void); 206int rl_on_new_line(void);
207 207
208/* 208/*
209 * The following are not implemented 209 * The following are not implemented
210 */ 210 */
211int rl_kill_text(int, int); 211int rl_kill_text(int, int);
212Keymap rl_get_keymap(void); 212Keymap rl_get_keymap(void);
213void rl_set_keymap(Keymap); 213void rl_set_keymap(Keymap);
214Keymap rl_make_bare_keymap(void); 214Keymap rl_make_bare_keymap(void);
215int rl_generic_bind(int, const char *, const char *, Keymap); 215int rl_generic_bind(int, const char *, const char *, Keymap);
216int rl_bind_key_in_map(int, rl_command_func_t *, Keymap); 216int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);