pass -Wconversiondiff -r1.45 -r1.46 src/lib/libedit/Makefile
(christos)
--- src/lib/libedit/Makefile 2011/07/29 20:56:58 1.45
+++ src/lib/libedit/Makefile 2011/07/29 23:44:44 1.46
@@ -1,24 +1,24 @@ | @@ -1,24 +1,24 @@ | |||
1 | # $NetBSD: Makefile,v 1.45 2011/07/29 20:56:58 christos Exp $ | 1 | # $NetBSD: Makefile,v 1.46 2011/07/29 23:44:44 christos Exp $ | |
2 | # @(#)Makefile 8.1 (Berkeley) 6/4/93 | 2 | # @(#)Makefile 8.1 (Berkeley) 6/4/93 | |
3 | 3 | |||
4 | USE_SHLIBDIR= yes | 4 | USE_SHLIBDIR= yes | |
5 | 5 | |||
6 | WIDECHAR ?= yes | 6 | WIDECHAR ?= yes | |
7 | WARNS= 4 | 7 | WARNS= 4 | |
8 | LIB= edit | 8 | LIB= edit | |
9 | 9 | |||
10 | LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo | 10 | LIBDPLIBS+= terminfo ${.CURDIR}/../libterminfo | |
11 | COPTS+=-Wunused-parameter | 11 | COPTS+=-Wunused-parameter -Wconversion | |
12 | 12 | |||
13 | OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ | 13 | OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ | |
14 | hist.c keymacro.c map.c chartype.c \ | 14 | hist.c keymacro.c map.c chartype.c \ | |
15 | parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c | 15 | parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c | |
16 | 16 | |||
17 | MAN= editline.3 editrc.5 | 17 | MAN= editline.3 editrc.5 | |
18 | 18 | |||
19 | MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ | 19 | MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ | |
20 | editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ | 20 | editline.3 el_gets.3 editline.3 el_getc.3 editline.3 el_push.3 \ | |
21 | editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ | 21 | editline.3 el_parse.3 editline.3 el_set.3 editline.3 el_get.3 \ | |
22 | editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ | 22 | editline.3 el_source.3 editline.3 el_resize.3 editline.3 el_line.3 \ | |
23 | editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ | 23 | editline.3 el_insertstr.3 editline.3 el_deletestr.3 \ | |
24 | editline.3 history_init.3 editline.3 history_end.3 \ | 24 | editline.3 history_init.3 editline.3 history_end.3 \ |
--- src/lib/libedit/chared.c 2011/07/29 15:20:39 1.33
+++ src/lib/libedit/chared.c 2011/07/29 23:44:44 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chared.c,v 1.33 2011/07/29 15:20:39 christos Exp $ */ | 1 | /* $NetBSD: chared.c,v 1.34 2011/07/29 23:44:44 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 | |
38 | static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: chared.c,v 1.33 2011/07/29 15:20:39 christos Exp $"); | 40 | __RCSID("$NetBSD: chared.c,v 1.34 2011/07/29 23:44:44 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 <stdlib.h> | 47 | #include <stdlib.h> | |
48 | #include "el.h" | 48 | #include "el.h" | |
49 | 49 | |||
50 | private void ch__clearmacro (EditLine *); | 50 | private void ch__clearmacro (EditLine *); | |
51 | 51 | |||
52 | /* value to leave unused in line buffer */ | 52 | /* value to leave unused in line buffer */ | |
53 | #define EL_LEAVE 2 | 53 | #define EL_LEAVE 2 | |
@@ -681,27 +681,27 @@ c_gets(EditLine *el, Char *buf, const Ch | @@ -681,27 +681,27 @@ c_gets(EditLine *el, Char *buf, const Ch | |||
681 | len = -1; | 681 | len = -1; | |
682 | break; | 682 | break; | |
683 | } | 683 | } | |
684 | cp--; | 684 | cp--; | |
685 | continue; | 685 | continue; | |
686 | 686 | |||
687 | case 0033: /* ESC */ | 687 | case 0033: /* ESC */ | |
688 | case '\r': /* Newline */ | 688 | case '\r': /* Newline */ | |
689 | case '\n': | 689 | case '\n': | |
690 | buf[len] = ch; | 690 | buf[len] = ch; | |
691 | break; | 691 | break; | |
692 | 692 | |||
693 | default: | 693 | default: | |
694 | if (len >= EL_BUFSIZ - 16) | 694 | if (len >= (ssize_t)(EL_BUFSIZ - 16)) | |
695 | terminal_beep(el); | 695 | terminal_beep(el); | |
696 | else { | 696 | else { | |
697 | buf[len++] = ch; | 697 | buf[len++] = ch; | |
698 | *cp++ = ch; | 698 | *cp++ = ch; | |
699 | } | 699 | } | |
700 | continue; | 700 | continue; | |
701 | } | 701 | } | |
702 | break; | 702 | break; | |
703 | } | 703 | } | |
704 | 704 | |||
705 | el->el_line.buffer[0] = '\0'; | 705 | el->el_line.buffer[0] = '\0'; | |
706 | el->el_line.lastchar = el->el_line.buffer; | 706 | el->el_line.lastchar = el->el_line.buffer; | |
707 | el->el_line.cursor = el->el_line.buffer; | 707 | el->el_line.cursor = el->el_line.buffer; |
--- src/lib/libedit/chartype.c 2011/07/29 15:16:33 1.8
+++ src/lib/libedit/chartype.c 2011/07/29 23:44:44 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chartype.c,v 1.8 2011/07/29 15:16:33 christos Exp $ */ | 1 | /* $NetBSD: chartype.c,v 1.9 2011/07/29 23:44:44 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,32 +28,32 @@ | @@ -28,32 +28,32 @@ | |||
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.8 2011/07/29 15:16:33 christos Exp $"); | 41 | __RCSID("$NetBSD: chartype.c,v 1.9 2011/07/29 23:44:44 christos Exp $"); | |
42 | #endif /* not lint && not SCCSID */ | 42 | #endif /* not lint && not SCCSID */ | |
43 | #include "el.h" | 43 | #include "el.h" | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | 45 | |||
46 | #define CT_BUFSIZ 1024 | 46 | #define CT_BUFSIZ ((size_t)1024) | |
47 | 47 | |||
48 | #ifdef WIDECHAR | 48 | #ifdef WIDECHAR | |
49 | protected void | 49 | protected void | |
50 | ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize) | 50 | ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize) | |
51 | { | 51 | { | |
52 | void *p; | 52 | void *p; | |
53 | if (mincsize > conv->csize) { | 53 | if (mincsize > conv->csize) { | |
54 | conv->csize = mincsize; | 54 | conv->csize = mincsize; | |
55 | p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff)); | 55 | p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff)); | |
56 | if (p == NULL) { | 56 | if (p == NULL) { | |
57 | conv->csize = 0; | 57 | conv->csize = 0; | |
58 | el_free(conv->cbuff); | 58 | el_free(conv->cbuff); | |
59 | conv->cbuff = NULL; | 59 | conv->cbuff = NULL; | |
@@ -73,88 +73,89 @@ ct_conv_buff_resize(ct_buffer_t *conv, s | @@ -73,88 +73,89 @@ ct_conv_buff_resize(ct_buffer_t *conv, s | |||
73 | } | 73 | } | |
74 | } | 74 | } | |
75 | 75 | |||
76 | 76 | |||
77 | public char * | 77 | public char * | |
78 | ct_encode_string(const Char *s, ct_buffer_t *conv) | 78 | ct_encode_string(const Char *s, ct_buffer_t *conv) | |
79 | { | 79 | { | |
80 | char *dst; | 80 | char *dst; | |
81 | ssize_t used = 0; | 81 | ssize_t used = 0; | |
82 | 82 | |||
83 | if (!s) | 83 | if (!s) | |
84 | return NULL; | 84 | return NULL; | |
85 | if (!conv->cbuff) | 85 | if (!conv->cbuff) | |
86 | ct_conv_buff_resize(conv, CT_BUFSIZ, 0); | 86 | ct_conv_buff_resize(conv, CT_BUFSIZ, (size_t)0); | |
87 | if (!conv->cbuff) | 87 | if (!conv->cbuff) | |
88 | return NULL; | 88 | return NULL; | |
89 | 89 | |||
90 | dst = conv->cbuff; | 90 | dst = conv->cbuff; | |
91 | while (*s) { | 91 | while (*s) { | |
92 | used = conv->csize - (dst - conv->cbuff); | 92 | used = conv->csize - (dst - conv->cbuff); | |
93 | if (used < 5) { | 93 | if (used < 5) { | |
94 | used = dst - conv->cbuff; | 94 | used = dst - conv->cbuff; | |
95 | ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, 0); | 95 | ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ, | |
96 | (size_t)0); | |||
96 | if (!conv->cbuff) | 97 | if (!conv->cbuff) | |
97 | return NULL; | 98 | return NULL; | |
98 | dst = conv->cbuff + used; | 99 | dst = conv->cbuff + used; | |
99 | } | 100 | } | |
100 | used = ct_encode_char(dst, 5, *s); | 101 | used = ct_encode_char(dst, (size_t)5, *s); | |
101 | if (used == -1) /* failed to encode, need more buffer space */ | 102 | if (used == -1) /* failed to encode, need more buffer space */ | |
102 | abort(); | 103 | abort(); | |
103 | ++s; | 104 | ++s; | |
104 | dst += used; | 105 | dst += used; | |
105 | } | 106 | } | |
106 | *dst = '\0'; | 107 | *dst = '\0'; | |
107 | return conv->cbuff; | 108 | return conv->cbuff; | |
108 | } | 109 | } | |
109 | 110 | |||
110 | public Char * | 111 | public Char * | |
111 | ct_decode_string(const char *s, ct_buffer_t *conv) | 112 | ct_decode_string(const char *s, ct_buffer_t *conv) | |
112 | { | 113 | { | |
113 | size_t len = 0; | 114 | size_t len = 0; | |
114 | 115 | |||
115 | if (!s) | 116 | if (!s) | |
116 | return NULL; | 117 | return NULL; | |
117 | if (!conv->wbuff) | 118 | if (!conv->wbuff) | |
118 | ct_conv_buff_resize(conv, 0, CT_BUFSIZ); | 119 | ct_conv_buff_resize(conv, (size_t)0, CT_BUFSIZ); | |
119 | if (!conv->wbuff) | 120 | if (!conv->wbuff) | |
120 | return NULL; | 121 | return NULL; | |
121 | 122 | |||
122 | len = ct_mbstowcs(NULL, s, 0); | 123 | len = ct_mbstowcs(NULL, s, (size_t)0); | |
123 | if (len == (size_t)-1) | 124 | if (len == (size_t)-1) | |
124 | return NULL; | 125 | return NULL; | |
125 | if (len > conv->wsize) | 126 | if (len > conv->wsize) | |
126 | ct_conv_buff_resize(conv, 0, len + 1); | 127 | ct_conv_buff_resize(conv, (size_t)0, len + 1); | |
127 | if (!conv->wbuff) | 128 | if (!conv->wbuff) | |
128 | return NULL; | 129 | return NULL; | |
129 | ct_mbstowcs(conv->wbuff, s, conv->wsize); | 130 | ct_mbstowcs(conv->wbuff, s, conv->wsize); | |
130 | return conv->wbuff; | 131 | return conv->wbuff; | |
131 | } | 132 | } | |
132 | 133 | |||
133 | 134 | |||
134 | protected Char ** | 135 | protected Char ** | |
135 | ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv) | 136 | ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv) | |
136 | { | 137 | { | |
137 | size_t bufspace; | 138 | size_t bufspace; | |
138 | int i; | 139 | int i; | |
139 | Char *p; | 140 | Char *p; | |
140 | Char **wargv; | 141 | Char **wargv; | |
141 | ssize_t bytes; | 142 | ssize_t bytes; | |
142 | 143 | |||
143 | /* Make sure we have enough space in the conversion buffer to store all | 144 | /* Make sure we have enough space in the conversion buffer to store all | |
144 | * the argv strings. */ | 145 | * the argv strings. */ | |
145 | for (i = 0, bufspace = 0; i < argc; ++i) | 146 | for (i = 0, bufspace = 0; i < argc; ++i) | |
146 | bufspace += argv[i] ? strlen(argv[i]) + 1 : 0; | 147 | bufspace += argv[i] ? strlen(argv[i]) + 1 : 0; | |
147 | ct_conv_buff_resize(conv, 0, bufspace); | 148 | ct_conv_buff_resize(conv, (size_t)0, bufspace); | |
148 | if (!conv->wsize) | 149 | if (!conv->wsize) | |
149 | return NULL; | 150 | return NULL; | |
150 | 151 | |||
151 | wargv = el_malloc(argc * sizeof(*wargv)); | 152 | wargv = el_malloc(argc * sizeof(*wargv)); | |
152 | 153 | |||
153 | for (i = 0, p = conv->wbuff; i < argc; ++i) { | 154 | for (i = 0, p = conv->wbuff; i < argc; ++i) { | |
154 | if (!argv[i]) { /* don't pass null pointers to mbstowcs */ | 155 | if (!argv[i]) { /* don't pass null pointers to mbstowcs */ | |
155 | wargv[i] = NULL; | 156 | wargv[i] = NULL; | |
156 | continue; | 157 | continue; | |
157 | } else { | 158 | } else { | |
158 | wargv[i] = p; | 159 | wargv[i] = p; | |
159 | bytes = mbstowcs(p, argv[i], bufspace); | 160 | bytes = mbstowcs(p, argv[i], bufspace); | |
160 | } | 161 | } |
--- src/lib/libedit/chartype.h 2010/12/16 17:42:28 1.7
+++ src/lib/libedit/chartype.h 2011/07/29 23:44:44 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chartype.h,v 1.7 2010/12/16 17:42:28 wiz Exp $ */ | 1 | /* $NetBSD: chartype.h,v 1.8 2011/07/29 23:44:44 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. | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * funky encoding that could break us in weird and wonderful ways. */ | 51 | * funky encoding that could break us in weird and wonderful ways. */ | |
52 | #error wchar_t must store ISO 10646 characters | 52 | #error wchar_t must store ISO 10646 characters | |
53 | #endif | 53 | #endif | |
54 | #endif | 54 | #endif | |
55 | 55 | |||
56 | /* Oh for a <uchar.h> with char32_t and __STDC_UTF_32__ in it... | 56 | /* Oh for a <uchar.h> with char32_t and __STDC_UTF_32__ in it... | |
57 | * ref: ISO/IEC DTR 19769 | 57 | * ref: ISO/IEC DTR 19769 | |
58 | */ | 58 | */ | |
59 | #if WCHAR_MAX < INT32_MAX | 59 | #if WCHAR_MAX < INT32_MAX | |
60 | #warning Build environment does not support non-BMP characters | 60 | #warning Build environment does not support non-BMP characters | |
61 | #endif | 61 | #endif | |
62 | 62 | |||
63 | #define ct_mbtowc mbtowc | 63 | #define ct_mbtowc mbtowc | |
64 | #define ct_mbtowc_reset mbtowc(0,0,0) | 64 | #define ct_mbtowc_reset mbtowc(0,0,(size_t)0) | |
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 Int wint_t | 71 | #define Int wint_t | |
72 | #define FUN(prefix,rest) prefix ## _w ## rest | 72 | #define FUN(prefix,rest) prefix ## _w ## rest | |
73 | #define FUNW(type) type ## _w | 73 | #define FUNW(type) type ## _w | |
74 | #define TYPE(type) type ## W | 74 | #define TYPE(type) type ## W | |
75 | #define FSTR "%ls" | 75 | #define FSTR "%ls" | |
76 | #define STR(x) L ## x | 76 | #define STR(x) L ## x | |
77 | #define UC(c) c | 77 | #define UC(c) c | |
@@ -196,27 +196,27 @@ protected size_t ct_enc_width(Char); | @@ -196,27 +196,27 @@ protected size_t ct_enc_width(Char); | |||
196 | #define ct_decode_argv(l, s, b) (s) | 196 | #define ct_decode_argv(l, s, b) (s) | |
197 | #define ct_conv_buff_resize(b, os, ns) | 197 | #define ct_conv_buff_resize(b, os, ns) | |
198 | #define ct_encode_char(d, l, s) (*d = s, 1) | 198 | #define ct_encode_char(d, l, s) (*d = s, 1) | |
199 | #define ct_free_argv(s) | 199 | #define ct_free_argv(s) | |
200 | #endif | 200 | #endif | |
201 | 201 | |||
202 | #ifndef NARROWCHAR | 202 | #ifndef NARROWCHAR | |
203 | /* Encode a characted into the destination buffer, provided there is sufficent | 203 | /* Encode a characted into the destination buffer, provided there is sufficent | |
204 | * buffer space available. Returns the number of bytes used up (zero if the | 204 | * buffer space available. Returns the number of bytes used up (zero if the | |
205 | * character cannot be encoded, -1 if there was not enough space available). */ | 205 | * character cannot be encoded, -1 if there was not enough space available). */ | |
206 | 206 | |||
207 | /* The maximum buffer size to hold the most unwieldly visual representation, | 207 | /* The maximum buffer size to hold the most unwieldly visual representation, | |
208 | * in this case \U+nnnnn. */ | 208 | * in this case \U+nnnnn. */ | |
209 | #define VISUAL_WIDTH_MAX 8 | 209 | #define VISUAL_WIDTH_MAX ((size_t)8) | |
210 | 210 | |||
211 | /* The terminal is thought of in terms of X columns by Y lines. In the cases | 211 | /* The terminal is thought of in terms of X columns by Y lines. In the cases | |
212 | * where a wide character takes up more than one column, the adjacent | 212 | * where a wide character takes up more than one column, the adjacent | |
213 | * occupied column entries will contain this faux character. */ | 213 | * occupied column entries will contain this faux character. */ | |
214 | #define MB_FILL_CHAR ((Char)-1) | 214 | #define MB_FILL_CHAR ((Char)-1) | |
215 | 215 | |||
216 | /* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn | 216 | /* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn | |
217 | * style visual expansions. */ | 217 | * style visual expansions. */ | |
218 | protected int ct_visual_width(Char); | 218 | protected int ct_visual_width(Char); | |
219 | 219 | |||
220 | /* Turn the given character into the appropriate visual format, matching | 220 | /* Turn the given character into the appropriate visual format, matching | |
221 | * the width given by ct_visual_width(). Returns the number of characters used | 221 | * the width given by ct_visual_width(). Returns the number of characters used | |
222 | * up, or -1 if insufficient space. Buffer length is in count of Char's. */ | 222 | * up, or -1 if insufficient space. Buffer length is in count of Char's. */ |
--- src/lib/libedit/el.h 2011/07/28 01:56:27 1.24
+++ src/lib/libedit/el.h 2011/07/29 23:44:44 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: el.h,v 1.24 2011/07/28 01:56:27 christos Exp $ */ | 1 | /* $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 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. | |
@@ -41,27 +41,27 @@ | @@ -41,27 +41,27 @@ | |||
41 | #define _h_el | 41 | #define _h_el | |
42 | /* | 42 | /* | |
43 | * Local defaults | 43 | * Local defaults | |
44 | */ | 44 | */ | |
45 | #define KSHVI | 45 | #define KSHVI | |
46 | #define VIDEFAULT | 46 | #define VIDEFAULT | |
47 | #define ANCHOR | 47 | #define ANCHOR | |
48 | 48 | |||
49 | #include "histedit.h" | 49 | #include "histedit.h" | |
50 | #include "chartype.h" | 50 | #include "chartype.h" | |
51 | #include <stdio.h> | 51 | #include <stdio.h> | |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> | |
53 | 53 | |||
54 | #define EL_BUFSIZ 1024 /* Maximum line size */ | 54 | #define EL_BUFSIZ ((size_t)1024) /* Maximum line size */ | |
55 | 55 | |||
56 | #define HANDLE_SIGNALS 0x01 | 56 | #define HANDLE_SIGNALS 0x01 | |
57 | #define NO_TTY 0x02 | 57 | #define NO_TTY 0x02 | |
58 | #define EDIT_DISABLED 0x04 | 58 | #define EDIT_DISABLED 0x04 | |
59 | #define UNBUFFERED 0x08 | 59 | #define UNBUFFERED 0x08 | |
60 | #define CHARSET_IS_UTF8 0x10 | 60 | #define CHARSET_IS_UTF8 0x10 | |
61 | #define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */ | 61 | #define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */ | |
62 | #define NARROW_HISTORY 0x40 | 62 | #define NARROW_HISTORY 0x40 | |
63 | #define NARROW_READ 0x80 | 63 | #define NARROW_READ 0x80 | |
64 | 64 | |||
65 | typedef int bool_t; /* True or not */ | 65 | typedef int bool_t; /* True or not */ | |
66 | 66 | |||
67 | typedef unsigned char el_action_t; /* Index to command array */ | 67 | typedef unsigned char el_action_t; /* Index to command array */ |
--- src/lib/libedit/filecomplete.c 2011/07/29 20:58:07 1.28
+++ src/lib/libedit/filecomplete.c 2011/07/29 23:44:44 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: filecomplete.c,v 1.28 2011/07/29 20:58:07 christos Exp $ */ | 1 | /* $NetBSD: filecomplete.c,v 1.29 2011/07/29 23:44:44 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,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
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.28 2011/07/29 20:58:07 christos Exp $"); | 34 | __RCSID("$NetBSD: filecomplete.c,v 1.29 2011/07/29 23:44:44 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> | 39 | #include <stdio.h> | |
40 | #include <dirent.h> | 40 | #include <dirent.h> | |
41 | #include <string.h> | 41 | #include <string.h> | |
42 | #include <pwd.h> | 42 | #include <pwd.h> | |
43 | #include <ctype.h> | 43 | #include <ctype.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <unistd.h> | 45 | #include <unistd.h> | |
46 | #include <limits.h> | 46 | #include <limits.h> | |
47 | #include <errno.h> | 47 | #include <errno.h> | |
@@ -562,16 +562,16 @@ fn_complete(EditLine *el, | @@ -562,16 +562,16 @@ fn_complete(EditLine *el, | |||
562 | } | 562 | } | |
563 | el_free(temp); | 563 | el_free(temp); | |
564 | return retval; | 564 | return retval; | |
565 | } | 565 | } | |
566 | 566 | |||
567 | /* | 567 | /* | |
568 | * el-compatible wrapper around rl_complete; needed for key binding | 568 | * el-compatible wrapper around rl_complete; needed for key binding | |
569 | */ | 569 | */ | |
570 | /* ARGSUSED */ | 570 | /* ARGSUSED */ | |
571 | unsigned char | 571 | unsigned char | |
572 | _el_fn_complete(EditLine *el, int ch __attribute__((__unused__))) | 572 | _el_fn_complete(EditLine *el, int ch __attribute__((__unused__))) | |
573 | { | 573 | { | |
574 | return (unsigned char)fn_complete(el, NULL, NULL, | 574 | return (unsigned char)fn_complete(el, NULL, NULL, | |
575 | break_chars, NULL, NULL, 100, | 575 | break_chars, NULL, NULL, (size_t)100, | |
576 | NULL, NULL, NULL, NULL); | 576 | NULL, NULL, NULL, NULL); | |
577 | } | 577 | } |
--- src/lib/libedit/history.c 2011/07/29 20:58:07 1.44
+++ src/lib/libedit/history.c 2011/07/29 23:44:44 1.45
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: history.c,v 1.44 2011/07/29 20:58:07 christos Exp $ */ | 1 | /* $NetBSD: history.c,v 1.45 2011/07/29 23:44:44 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 | |
38 | static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: history.c,v 1.44 2011/07/29 20:58:07 christos Exp $"); | 40 | __RCSID("$NetBSD: history.c,v 1.45 2011/07/29 23:44:44 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 <string.h> | |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> | |
49 | #include <stdarg.h> | 49 | #include <stdarg.h> | |
50 | #include <vis.h> | 50 | #include <vis.h> | |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> | |
52 | 52 | |||
53 | static const char hist_cookie[] = "_HiStOrY_V2_\n"; | 53 | static const char hist_cookie[] = "_HiStOrY_V2_\n"; | |
@@ -750,27 +750,27 @@ history_load(TYPE(History) *h, const cha | @@ -750,27 +750,27 @@ history_load(TYPE(History) *h, const cha | |||
750 | ptr = h_malloc((max_size = 1024) * sizeof(*ptr)); | 750 | ptr = h_malloc((max_size = 1024) * sizeof(*ptr)); | |
751 | if (ptr == NULL) | 751 | if (ptr == NULL) | |
752 | goto done; | 752 | goto done; | |
753 | for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) { | 753 | for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) { | |
754 | char c = line[sz]; | 754 | char c = line[sz]; | |
755 | 755 | |||
756 | if (sz != 0 && line[sz - 1] == '\n') | 756 | if (sz != 0 && line[sz - 1] == '\n') | |
757 | line[--sz] = '\0'; | 757 | line[--sz] = '\0'; | |
758 | else | 758 | else | |
759 | line[sz] = '\0'; | 759 | line[sz] = '\0'; | |
760 | 760 | |||
761 | if (max_size < sz) { | 761 | if (max_size < sz) { | |
762 | char *nptr; | 762 | char *nptr; | |
763 | max_size = (sz + 1024) & ~1023; | 763 | max_size = (sz + 1024) & (size_t)~1023; | |
764 | nptr = h_realloc(ptr, max_size * sizeof(*ptr)); | 764 | nptr = h_realloc(ptr, max_size * sizeof(*ptr)); | |
765 | if (nptr == NULL) { | 765 | if (nptr == NULL) { | |
766 | i = -1; | 766 | i = -1; | |
767 | goto oomem; | 767 | goto oomem; | |
768 | } | 768 | } | |
769 | ptr = nptr; | 769 | ptr = nptr; | |
770 | } | 770 | } | |
771 | (void) strunvis(ptr, line); | 771 | (void) strunvis(ptr, line); | |
772 | line[sz] = c; | 772 | line[sz] = c; | |
773 | if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) { | 773 | if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) { | |
774 | i = -1; | 774 | i = -1; | |
775 | goto oomem; | 775 | goto oomem; | |
776 | } | 776 | } | |
@@ -806,27 +806,27 @@ history_save(TYPE(History) *h, const cha | @@ -806,27 +806,27 @@ history_save(TYPE(History) *h, const cha | |||
806 | goto done; | 806 | goto done; | |
807 | if (fputs(hist_cookie, fp) == EOF) | 807 | if (fputs(hist_cookie, fp) == EOF) | |
808 | goto done; | 808 | goto done; | |
809 | ptr = h_malloc((max_size = 1024) * sizeof(*ptr)); | 809 | ptr = h_malloc((max_size = 1024) * sizeof(*ptr)); | |
810 | if (ptr == NULL) | 810 | if (ptr == NULL) | |
811 | goto done; | 811 | goto done; | |
812 | for (i = 0, retval = HLAST(h, &ev); | 812 | for (i = 0, retval = HLAST(h, &ev); | |
813 | retval != -1; | 813 | retval != -1; | |
814 | retval = HPREV(h, &ev), i++) { | 814 | retval = HPREV(h, &ev), i++) { | |
815 | str = ct_encode_string(ev.str, &conv); | 815 | str = ct_encode_string(ev.str, &conv); | |
816 | len = strlen(str) * 4; | 816 | len = strlen(str) * 4; | |
817 | if (len >= max_size) { | 817 | if (len >= max_size) { | |
818 | char *nptr; | 818 | char *nptr; | |
819 | max_size = (len + 1024) & ~1023; | 819 | max_size = (len + 1024) & (size_t)~1023; | |
820 | nptr = h_realloc(ptr, max_size * sizeof(*ptr)); | 820 | nptr = h_realloc(ptr, max_size * sizeof(*ptr)); | |
821 | if (nptr == NULL) { | 821 | if (nptr == NULL) { | |
822 | i = -1; | 822 | i = -1; | |
823 | goto oomem; | 823 | goto oomem; | |
824 | } | 824 | } | |
825 | ptr = nptr; | 825 | ptr = nptr; | |
826 | } | 826 | } | |
827 | (void) strvis(ptr, str, VIS_WHITE); | 827 | (void) strvis(ptr, str, VIS_WHITE); | |
828 | (void) fprintf(fp, "%s\n", ptr); | 828 | (void) fprintf(fp, "%s\n", ptr); | |
829 | } | 829 | } | |
830 | oomem: | 830 | oomem: | |
831 | h_free(ptr); | 831 | h_free(ptr); | |
832 | done: | 832 | done: |
--- src/lib/libedit/keymacro.c 2011/07/29 15:16:33 1.5
+++ src/lib/libedit/keymacro.c 2011/07/29 23:44:44 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: keymacro.c,v 1.5 2011/07/29 15:16:33 christos Exp $ */ | 1 | /* $NetBSD: keymacro.c,v 1.6 2011/07/29 23:44:44 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 | |
38 | static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: keymacro.c,v 1.5 2011/07/29 15:16:33 christos Exp $"); | 40 | __RCSID("$NetBSD: keymacro.c,v 1.6 2011/07/29 23:44:44 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). | |
@@ -255,27 +255,27 @@ keymacro_delete(EditLine *el, const Char | @@ -255,27 +255,27 @@ keymacro_delete(EditLine *el, const Char | |||
255 | /* keymacro_print(): | 255 | /* keymacro_print(): | |
256 | * Print the binding associated with key key. | 256 | * Print the binding associated with key key. | |
257 | * Print entire el->el_keymacro.map if null | 257 | * Print entire el->el_keymacro.map if null | |
258 | */ | 258 | */ | |
259 | protected void | 259 | protected void | |
260 | keymacro_print(EditLine *el, const Char *key) | 260 | keymacro_print(EditLine *el, const Char *key) | |
261 | { | 261 | { | |
262 | 262 | |||
263 | /* do nothing if el->el_keymacro.map is empty and null key specified */ | 263 | /* do nothing if el->el_keymacro.map is empty and null key specified */ | |
264 | if (el->el_keymacro.map == NULL && *key == 0) | 264 | if (el->el_keymacro.map == NULL && *key == 0) | |
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, 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 | */ | |
280 | private int | 280 | private int | |
281 | node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) | 281 | node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) |
--- src/lib/libedit/read.c 2011/07/29 15:16:33 1.65
+++ src/lib/libedit/read.c 2011/07/29 23:44:44 1.66
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: read.c,v 1.65 2011/07/29 15:16:33 christos Exp $ */ | 1 | /* $NetBSD: read.c,v 1.66 2011/07/29 23:44:44 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,42 +27,42 @@ | @@ -27,42 +27,42 @@ | |||
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 | |
38 | static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: read.c,v 1.65 2011/07/29 15:16:33 christos Exp $"); | 40 | __RCSID("$NetBSD: read.c,v 1.66 2011/07/29 23:44:44 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 <errno.h> | 48 | #include <errno.h> | |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> | |
50 | #include <unistd.h> | 50 | #include <unistd.h> | |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> | |
52 | #include <limits.h> | 52 | #include <limits.h> | |
53 | #include "el.h" | 53 | #include "el.h" | |
54 | 54 | |||
55 | #define OKCMD -1 /* must be -1! */ | 55 | #define OKCMD -1 /* must be -1! */ | |
56 | 56 | |||
57 | private int read__fixio(int, int); | 57 | private int read__fixio(int, int); | |
58 | private int read_preread(EditLine *); | 58 | private int read_preread(EditLine *); | |
59 | private int read_char(EditLine *, Char *); | 59 | private int read_char(EditLine *, Char *); | |
60 | private int read_getcmd(EditLine *, el_action_t *, Char *); | 60 | private int read_getcmd(EditLine *, el_action_t *, Char *); | |
61 | private void read_pop(c_macro_t *); | 61 | private void read_pop(c_macro_t *); | |
62 | 62 | |||
63 | /* read_init(): | 63 | /* read_init(): | |
64 | * Initialize the read stuff | 64 | * Initialize the read stuff | |
65 | */ | 65 | */ | |
66 | protected int | 66 | protected int | |
67 | read_init(EditLine *el) | 67 | read_init(EditLine *el) | |
68 | { | 68 | { | |
@@ -123,35 +123,35 @@ read_debug(EditLine *el) | @@ -123,35 +123,35 @@ read_debug(EditLine *el) | |||
123 | * Try to recover from a read error | 123 | * Try to recover from a read error | |
124 | */ | 124 | */ | |
125 | /* ARGSUSED */ | 125 | /* ARGSUSED */ | |
126 | private int | 126 | private int | |
127 | read__fixio(int fd __attribute__((__unused__)), int e) | 127 | read__fixio(int fd __attribute__((__unused__)), int e) | |
128 | { | 128 | { | |
129 | 129 | |||
130 | switch (e) { | 130 | switch (e) { | |
131 | case -1: /* Make sure that the code is reachable */ | 131 | case -1: /* Make sure that the code is reachable */ | |
132 | 132 | |||
133 | #ifdef EWOULDBLOCK | 133 | #ifdef EWOULDBLOCK | |
134 | case EWOULDBLOCK: | 134 | case EWOULDBLOCK: | |
135 | #ifndef TRY_AGAIN | 135 | #ifndef TRY_AGAIN | |
136 | #define TRY_AGAIN | 136 | #define TRY_AGAIN | |
137 | #endif | 137 | #endif | |
138 | #endif /* EWOULDBLOCK */ | 138 | #endif /* EWOULDBLOCK */ | |
139 | 139 | |||
140 | #if defined(POSIX) && defined(EAGAIN) | 140 | #if defined(POSIX) && defined(EAGAIN) | |
141 | #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN | 141 | #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN | |
142 | case EAGAIN: | 142 | case EAGAIN: | |
143 | #ifndef TRY_AGAIN | 143 | #ifndef TRY_AGAIN | |
144 | #define TRY_AGAIN | 144 | #define TRY_AGAIN | |
145 | #endif | 145 | #endif | |
146 | #endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */ | 146 | #endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */ | |
147 | #endif /* POSIX && EAGAIN */ | 147 | #endif /* POSIX && EAGAIN */ | |
148 | 148 | |||
149 | e = 0; | 149 | e = 0; | |
150 | #ifdef TRY_AGAIN | 150 | #ifdef TRY_AGAIN | |
151 | #if defined(F_SETFL) && defined(O_NDELAY) | 151 | #if defined(F_SETFL) && defined(O_NDELAY) | |
152 | if ((e = fcntl(fd, F_GETFL, 0)) == -1) | 152 | if ((e = fcntl(fd, F_GETFL, 0)) == -1) | |
153 | return -1; | 153 | return -1; | |
154 | 154 | |||
155 | if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1) | 155 | if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1) | |
156 | return -1; | 156 | return -1; | |
157 | else | 157 | else | |
@@ -252,31 +252,31 @@ read_getcmd(EditLine *el, el_action_t *c | @@ -252,31 +252,31 @@ read_getcmd(EditLine *el, el_action_t *c | |||
252 | #ifdef KANJI | 252 | #ifdef KANJI | |
253 | if ((*ch & 0200)) { | 253 | if ((*ch & 0200)) { | |
254 | el->el_state.metanext = 0; | 254 | el->el_state.metanext = 0; | |
255 | cmd = CcViMap[' ']; | 255 | cmd = CcViMap[' ']; | |
256 | break; | 256 | break; | |
257 | } else | 257 | } else | |
258 | #endif /* KANJI */ | 258 | #endif /* KANJI */ | |
259 | 259 | |||
260 | if (el->el_state.metanext) { | 260 | if (el->el_state.metanext) { | |
261 | el->el_state.metanext = 0; | 261 | el->el_state.metanext = 0; | |
262 | *ch |= 0200; | 262 | *ch |= 0200; | |
263 | } | 263 | } | |
264 | #ifdef WIDECHAR | 264 | #ifdef WIDECHAR | |
265 | if (*ch >= N_KEYS) | 265 | if (*ch >= N_KEYS) | |
266 | cmd = ED_INSERT; | 266 | cmd = ED_INSERT; | |
267 | else | 267 | else | |
268 | #endif | 268 | #endif | |
269 | cmd = el->el_map.current[(unsigned char) *ch]; | 269 | cmd = el->el_map.current[(unsigned char) *ch]; | |
270 | if (cmd == ED_SEQUENCE_LEAD_IN) { | 270 | if (cmd == ED_SEQUENCE_LEAD_IN) { | |
271 | keymacro_value_t val; | 271 | keymacro_value_t val; | |
272 | switch (keymacro_get(el, ch, &val)) { | 272 | switch (keymacro_get(el, ch, &val)) { | |
273 | case XK_CMD: | 273 | case XK_CMD: | |
274 | cmd = val.cmd; | 274 | cmd = val.cmd; | |
275 | break; | 275 | break; | |
276 | case XK_STR: | 276 | case XK_STR: | |
277 | FUN(el,push)(el, val.str); | 277 | FUN(el,push)(el, val.str); | |
278 | break; | 278 | break; | |
279 | #ifdef notyet | 279 | #ifdef notyet | |
280 | case XK_EXE: | 280 | case XK_EXE: | |
281 | /* XXX: In the future to run a user function */ | 281 | /* XXX: In the future to run a user function */ | |
282 | RunCommand(val.str); | 282 | RunCommand(val.str); | |
@@ -286,51 +286,51 @@ read_getcmd(EditLine *el, el_action_t *c | @@ -286,51 +286,51 @@ read_getcmd(EditLine *el, el_action_t *c | |||
286 | EL_ABORT((el->el_errfile, "Bad XK_ type \n")); | 286 | EL_ABORT((el->el_errfile, "Bad XK_ type \n")); | |
287 | break; | 287 | break; | |
288 | } | 288 | } | |
289 | } | 289 | } | |
290 | if (el->el_map.alt == NULL) | 290 | if (el->el_map.alt == NULL) | |
291 | el->el_map.current = el->el_map.key; | 291 | el->el_map.current = el->el_map.key; | |
292 | } while (cmd == ED_SEQUENCE_LEAD_IN); | 292 | } while (cmd == ED_SEQUENCE_LEAD_IN); | |
293 | *cmdnum = cmd; | 293 | *cmdnum = cmd; | |
294 | return OKCMD; | 294 | return OKCMD; | |
295 | } | 295 | } | |
296 | 296 | |||
297 | #ifdef WIDECHAR | 297 | #ifdef WIDECHAR | |
298 | /* utf8_islead(): | 298 | /* utf8_islead(): | |
299 | * Test whether a byte is a leading byte of a UTF-8 sequence. | 299 | * Test whether a byte is a leading byte of a UTF-8 sequence. | |
300 | */ | 300 | */ | |
301 | private int | 301 | private int | |
302 | utf8_islead(unsigned char c) | 302 | utf8_islead(int c) | |
303 | { | 303 | { | |
304 | return c < 0x80 || /* single byte char */ | 304 | return c < 0x80 || /* single byte char */ | |
305 | (c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */ | 305 | (c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */ | |
306 | } | 306 | } | |
307 | #endif | 307 | #endif | |
308 | 308 | |||
309 | /* read_char(): | 309 | /* read_char(): | |
310 | * Read a character from the tty. | 310 | * Read a character from the tty. | |
311 | */ | 311 | */ | |
312 | private int | 312 | private int | |
313 | read_char(EditLine *el, Char *cp) | 313 | read_char(EditLine *el, Char *cp) | |
314 | { | 314 | { | |
315 | ssize_t num_read; | 315 | ssize_t num_read; | |
316 | int tried = 0; | 316 | int tried = 0; | |
317 | char cbuf[MB_LEN_MAX]; | 317 | char cbuf[MB_LEN_MAX]; | |
318 | int cbp = 0; | 318 | size_t cbp = 0; | |
319 | int bytes = 0; | 319 | int bytes = 0; | |
320 | 320 | |||
321 | again: | 321 | again: | |
322 | el->el_signal->sig_no = 0; | 322 | el->el_signal->sig_no = 0; | |
323 | while ((num_read = read(el->el_infd, cbuf + cbp, 1)) == -1) { | 323 | while ((num_read = read(el->el_infd, cbuf + cbp, (size_t)1)) == -1) { | |
324 | switch (el->el_signal->sig_no) { | 324 | switch (el->el_signal->sig_no) { | |
325 | case SIGCONT: | 325 | case SIGCONT: | |
326 | FUN(el,set)(el, EL_REFRESH); | 326 | FUN(el,set)(el, EL_REFRESH); | |
327 | /*FALLTHROUGH*/ | 327 | /*FALLTHROUGH*/ | |
328 | case SIGWINCH: | 328 | case SIGWINCH: | |
329 | sig_set(el); | 329 | sig_set(el); | |
330 | goto again; | 330 | goto again; | |
331 | default: | 331 | default: | |
332 | break; | 332 | break; | |
333 | } | 333 | } | |
334 | if (!tried && read__fixio(el->el_infd, errno) == 0) | 334 | if (!tried && read__fixio(el->el_infd, errno) == 0) | |
335 | tried = 1; | 335 | tried = 1; | |
336 | else { | 336 | else { | |
@@ -482,27 +482,27 @@ FUN(el,gets)(EditLine *el, int *nread) | @@ -482,27 +482,27 @@ FUN(el,gets)(EditLine *el, int *nread) | |||
482 | 482 | |||
483 | if (nread == NULL) | 483 | if (nread == NULL) | |
484 | nread = &nrb; | 484 | nread = &nrb; | |
485 | *nread = 0; | 485 | *nread = 0; | |
486 | 486 | |||
487 | if (el->el_flags & NO_TTY) { | 487 | if (el->el_flags & NO_TTY) { | |
488 | size_t idx; | 488 | size_t idx; | |
489 | 489 | |||
490 | cp = el->el_line.buffer; | 490 | cp = el->el_line.buffer; | |
491 | while ((num = (*el->el_read.read_char)(el, cp)) == 1) { | 491 | while ((num = (*el->el_read.read_char)(el, cp)) == 1) { | |
492 | /* make sure there is space for next character */ | 492 | /* make sure there is space for next character */ | |
493 | if (cp + 1 >= el->el_line.limit) { | 493 | if (cp + 1 >= el->el_line.limit) { | |
494 | idx = (cp - el->el_line.buffer); | 494 | idx = (cp - el->el_line.buffer); | |
495 | if (!ch_enlargebufs(el, 2)) | 495 | if (!ch_enlargebufs(el, (size_t)2)) | |
496 | break; | 496 | break; | |
497 | cp = &el->el_line.buffer[idx]; | 497 | cp = &el->el_line.buffer[idx]; | |
498 | } | 498 | } | |
499 | cp++; | 499 | cp++; | |
500 | if (el->el_flags & UNBUFFERED) | 500 | if (el->el_flags & UNBUFFERED) | |
501 | break; | 501 | break; | |
502 | if (cp[-1] == '\r' || cp[-1] == '\n') | 502 | if (cp[-1] == '\r' || cp[-1] == '\n') | |
503 | break; | 503 | break; | |
504 | } | 504 | } | |
505 | if (num == -1) { | 505 | if (num == -1) { | |
506 | if (errno == EINTR) | 506 | if (errno == EINTR) | |
507 | cp = el->el_line.buffer; | 507 | cp = el->el_line.buffer; | |
508 | el->el_errno = errno; | 508 | el->el_errno = errno; | |
@@ -534,27 +534,27 @@ FUN(el,gets)(EditLine *el, int *nread) | @@ -534,27 +534,27 @@ FUN(el,gets)(EditLine *el, int *nread) | |||
534 | size_t idx; | 534 | size_t idx; | |
535 | 535 | |||
536 | if ((el->el_flags & UNBUFFERED) == 0) | 536 | if ((el->el_flags & UNBUFFERED) == 0) | |
537 | cp = el->el_line.buffer; | 537 | cp = el->el_line.buffer; | |
538 | else | 538 | else | |
539 | cp = el->el_line.lastchar; | 539 | cp = el->el_line.lastchar; | |
540 | 540 | |||
541 | terminal__flush(el); | 541 | terminal__flush(el); | |
542 | 542 | |||
543 | while ((num = (*el->el_read.read_char)(el, cp)) == 1) { | 543 | while ((num = (*el->el_read.read_char)(el, cp)) == 1) { | |
544 | /* make sure there is space next character */ | 544 | /* make sure there is space next character */ | |
545 | if (cp + 1 >= el->el_line.limit) { | 545 | if (cp + 1 >= el->el_line.limit) { | |
546 | idx = (cp - el->el_line.buffer); | 546 | idx = (cp - el->el_line.buffer); | |
547 | if (!ch_enlargebufs(el, 2)) | 547 | if (!ch_enlargebufs(el, (size_t)2)) | |
548 | break; | 548 | break; | |
549 | cp = &el->el_line.buffer[idx]; | 549 | cp = &el->el_line.buffer[idx]; | |
550 | } | 550 | } | |
551 | cp++; | 551 | cp++; | |
552 | crlf = cp[-1] == '\r' || cp[-1] == '\n'; | 552 | crlf = cp[-1] == '\r' || cp[-1] == '\n'; | |
553 | if (el->el_flags & UNBUFFERED) | 553 | if (el->el_flags & UNBUFFERED) | |
554 | break; | 554 | break; | |
555 | if (crlf) | 555 | if (crlf) | |
556 | break; | 556 | break; | |
557 | } | 557 | } | |
558 | 558 | |||
559 | if (num == -1) { | 559 | if (num == -1) { | |
560 | if (errno == EINTR) | 560 | if (errno == EINTR) | |
@@ -667,27 +667,27 @@ FUN(el,gets)(EditLine *el, int *nread) | @@ -667,27 +667,27 @@ FUN(el,gets)(EditLine *el, int *nread) | |||
667 | 667 | |||
668 | case CC_NEWLINE: /* normal end of line */ | 668 | case CC_NEWLINE: /* normal end of line */ | |
669 | num = (int)(el->el_line.lastchar - el->el_line.buffer); | 669 | num = (int)(el->el_line.lastchar - el->el_line.buffer); | |
670 | break; | 670 | break; | |
671 | 671 | |||
672 | case CC_FATAL: /* fatal error, reset to known state */ | 672 | case CC_FATAL: /* fatal error, reset to known state */ | |
673 | #ifdef DEBUG_READ | 673 | #ifdef DEBUG_READ | |
674 | (void) fprintf(el->el_errfile, | 674 | (void) fprintf(el->el_errfile, | |
675 | "*** editor fatal ERROR ***\r\n\n"); | 675 | "*** editor fatal ERROR ***\r\n\n"); | |
676 | #endif /* DEBUG_READ */ | 676 | #endif /* DEBUG_READ */ | |
677 | /* put (real) cursor in a known place */ | 677 | /* put (real) cursor in a known place */ | |
678 | re_clear_display(el); /* reset the display stuff */ | 678 | re_clear_display(el); /* reset the display stuff */ | |
679 | ch_reset(el, 1); /* reset the input pointers */ | 679 | ch_reset(el, 1); /* reset the input pointers */ | |
680 | re_refresh(el); /* print the prompt again */ | 680 | re_refresh(el); /* print the prompt again */ | |
681 | break; | 681 | break; | |
682 | 682 | |||
683 | case CC_ERROR: | 683 | case CC_ERROR: | |
684 | default: /* functions we don't know about */ | 684 | default: /* functions we don't know about */ | |
685 | #ifdef DEBUG_READ | 685 | #ifdef DEBUG_READ | |
686 | (void) fprintf(el->el_errfile, | 686 | (void) fprintf(el->el_errfile, | |
687 | "*** editor ERROR ***\r\n\n"); | 687 | "*** editor ERROR ***\r\n\n"); | |
688 | #endif /* DEBUG_READ */ | 688 | #endif /* DEBUG_READ */ | |
689 | terminal_beep(el); | 689 | terminal_beep(el); | |
690 | terminal__flush(el); | 690 | terminal__flush(el); | |
691 | break; | 691 | break; | |
692 | } | 692 | } | |
693 | el->el_state.argument = 1; | 693 | el->el_state.argument = 1; |
--- src/lib/libedit/readline.c 2011/07/29 20:58:07 1.97
+++ src/lib/libedit/readline.c 2011/07/29 23:44:44 1.98
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: readline.c,v 1.97 2011/07/29 20:58:07 christos Exp $ */ | 1 | /* $NetBSD: readline.c,v 1.98 2011/07/29 23:44:44 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,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
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.97 2011/07/29 20:58:07 christos Exp $"); | 34 | __RCSID("$NetBSD: readline.c,v 1.98 2011/07/29 23:44:44 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> | 39 | #include <stdio.h> | |
40 | #include <dirent.h> | 40 | #include <dirent.h> | |
41 | #include <string.h> | 41 | #include <string.h> | |
42 | #include <pwd.h> | 42 | #include <pwd.h> | |
43 | #include <ctype.h> | 43 | #include <ctype.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <unistd.h> | 45 | #include <unistd.h> | |
46 | #include <limits.h> | 46 | #include <limits.h> | |
47 | #include <errno.h> | 47 | #include <errno.h> | |
@@ -211,43 +211,40 @@ _getc_function(EditLine *el __attribute_ | @@ -211,43 +211,40 @@ _getc_function(EditLine *el __attribute_ | |||
211 | return 0; | 211 | return 0; | |
212 | *c = i; | 212 | *c = i; | |
213 | return 1; | 213 | return 1; | |
214 | } | 214 | } | |
215 | 215 | |||
216 | static void | 216 | static void | |
217 | _resize_fun(EditLine *el, void *a) | 217 | _resize_fun(EditLine *el, void *a) | |
218 | { | 218 | { | |
219 | const LineInfo *li; | 219 | const LineInfo *li; | |
220 | char **ap = a; | 220 | char **ap = a; | |
221 | 221 | |||
222 | li = el_line(el); | 222 | li = el_line(el); | |
223 | /* a cheesy way to get rid of const cast. */ | 223 | /* a cheesy way to get rid of const cast. */ | |
224 | *ap = memchr(li->buffer, *li->buffer, 1); | 224 | *ap = memchr(li->buffer, *li->buffer, (size_t)1); | |
225 | } | 225 | } | |
226 | 226 | |||
227 | static const char _dothistory[] = "/.history"; | |||
228 | ||||
229 | static const char * | 227 | static const char * | |
230 | _default_history_file(void) | 228 | _default_history_file(void) | |
231 | { | 229 | { | |
232 | struct passwd *p; | 230 | struct passwd *p; | |
233 | static char path[PATH_MAX]; | 231 | static char path[PATH_MAX]; | |
234 | 232 | |||
235 | if (*path) | 233 | if (*path) | |
236 | return path; | 234 | return path; | |
237 | if ((p = getpwuid(getuid())) == NULL) | 235 | if ((p = getpwuid(getuid())) == NULL) | |
238 | return NULL; | 236 | return NULL; | |
239 | strlcpy(path, p->pw_dir, PATH_MAX); | 237 | (void)snprintf(path, sizeof(path), "%s/.history", p->pw_dir); | |
240 | strlcat(path, _dothistory, PATH_MAX); | |||
241 | return path; | 238 | return path; | |
242 | } | 239 | } | |
243 | 240 | |||
244 | /* | 241 | /* | |
245 | * READLINE compatibility stuff | 242 | * READLINE compatibility stuff | |
246 | */ | 243 | */ | |
247 | 244 | |||
248 | /* | 245 | /* | |
249 | * Set the prompt | 246 | * Set the prompt | |
250 | */ | 247 | */ | |
251 | int | 248 | int | |
252 | rl_set_prompt(const char *prompt) | 249 | rl_set_prompt(const char *prompt) | |
253 | { | 250 | { | |
@@ -1179,52 +1176,53 @@ history_truncate_file (const char *filen | @@ -1179,52 +1176,53 @@ history_truncate_file (const char *filen | |||
1179 | strcpy(template, _history_tmp_template); | 1176 | strcpy(template, _history_tmp_template); | |
1180 | if ((fd = mkstemp(template)) == -1) { | 1177 | if ((fd = mkstemp(template)) == -1) { | |
1181 | ret = errno; | 1178 | ret = errno; | |
1182 | goto out1; | 1179 | goto out1; | |
1183 | } | 1180 | } | |
1184 | 1181 | |||
1185 | if ((tp = fdopen(fd, "r+")) == NULL) { | 1182 | if ((tp = fdopen(fd, "r+")) == NULL) { | |
1186 | close(fd); | 1183 | close(fd); | |
1187 | ret = errno; | 1184 | ret = errno; | |
1188 | goto out2; | 1185 | goto out2; | |
1189 | } | 1186 | } | |
1190 | 1187 | |||
1191 | for(;;) { | 1188 | for(;;) { | |
1192 | if (fread(buf, sizeof(buf), 1, fp) != 1) { | 1189 | if (fread(buf, sizeof(buf), (size_t)1, fp) != 1) { | |
1193 | if (ferror(fp)) { | 1190 | if (ferror(fp)) { | |
1194 | ret = errno; | 1191 | ret = errno; | |
1195 | break; | 1192 | break; | |
1196 | } | 1193 | } | |
1197 | if (fseeko(fp, (off_t)sizeof(buf) * count, SEEK_SET) == | 1194 | if (fseeko(fp, (off_t)sizeof(buf) * count, SEEK_SET) == | |
1198 | (off_t)-1) { | 1195 | (off_t)-1) { | |
1199 | ret = errno; | 1196 | ret = errno; | |
1200 | break; | 1197 | break; | |
1201 | } | 1198 | } | |
1202 | left = fread(buf, 1, sizeof(buf), fp); | 1199 | left = fread(buf, (size_t)1, sizeof(buf), fp); | |
1203 | if (ferror(fp)) { | 1200 | if (ferror(fp)) { | |
1204 | ret = errno; | 1201 | ret = errno; | |
1205 | break; | 1202 | break; | |
1206 | } | 1203 | } | |
1207 | if (left == 0) { | 1204 | if (left == 0) { | |
1208 | count--; | 1205 | count--; | |
1209 | left = sizeof(buf); | 1206 | left = sizeof(buf); | |
1210 | } else if (fwrite(buf, (size_t)left, 1, tp) != 1) { | 1207 | } else if (fwrite(buf, (size_t)left, (size_t)1, tp) | |
1208 | != 1) { | |||
1211 | ret = errno; | 1209 | ret = errno; | |
1212 | break; | 1210 | break; | |
1213 | } | 1211 | } | |
1214 | fflush(tp); | 1212 | fflush(tp); | |
1215 | break; | 1213 | break; | |
1216 | } | 1214 | } | |
1217 | if (fwrite(buf, sizeof(buf), 1, tp) != 1) { | 1215 | if (fwrite(buf, sizeof(buf), (size_t)1, tp) != 1) { | |
1218 | ret = errno; | 1216 | ret = errno; | |
1219 | break; | 1217 | break; | |
1220 | } | 1218 | } | |
1221 | count++; | 1219 | count++; | |
1222 | } | 1220 | } | |
1223 | if (ret) | 1221 | if (ret) | |
1224 | goto out3; | 1222 | goto out3; | |
1225 | cp = buf + left - 1; | 1223 | cp = buf + left - 1; | |
1226 | if(*cp != '\n') | 1224 | if(*cp != '\n') | |
1227 | cp++; | 1225 | cp++; | |
1228 | for(;;) { | 1226 | for(;;) { | |
1229 | while (--cp >= buf) { | 1227 | while (--cp >= buf) { | |
1230 | if (*cp == '\n') { | 1228 | if (*cp == '\n') { | |
@@ -1234,58 +1232,58 @@ history_truncate_file (const char *filen | @@ -1234,58 +1232,58 @@ history_truncate_file (const char *filen | |||
1234 | cp = buf; | 1232 | cp = buf; | |
1235 | } | 1233 | } | |
1236 | break; | 1234 | break; | |
1237 | } | 1235 | } | |
1238 | } | 1236 | } | |
1239 | } | 1237 | } | |
1240 | if (nlines <= 0 || count == 0) | 1238 | if (nlines <= 0 || count == 0) | |
1241 | break; | 1239 | break; | |
1242 | count--; | 1240 | count--; | |
1243 | if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) < 0) { | 1241 | if (fseeko(tp, (off_t)sizeof(buf) * count, SEEK_SET) < 0) { | |
1244 | ret = errno; | 1242 | ret = errno; | |
1245 | break; | 1243 | break; | |
1246 | } | 1244 | } | |
1247 | if (fread(buf, sizeof(buf), 1, tp) != 1) { | 1245 | if (fread(buf, sizeof(buf), (size_t)1, tp) != 1) { | |
1248 | if (ferror(tp)) { | 1246 | if (ferror(tp)) { | |
1249 | ret = errno; | 1247 | ret = errno; | |
1250 | break; | 1248 | break; | |
1251 | } | 1249 | } | |
1252 | ret = EAGAIN; | 1250 | ret = EAGAIN; | |
1253 | break; | 1251 | break; | |
1254 | } | 1252 | } | |
1255 | cp = buf + sizeof(buf); | 1253 | cp = buf + sizeof(buf); | |
1256 | } | 1254 | } | |
1257 | 1255 | |||
1258 | if (ret || nlines > 0) | 1256 | if (ret || nlines > 0) | |
1259 | goto out3; | 1257 | goto out3; | |
1260 | 1258 | |||
1261 | if (fseeko(fp, 0, SEEK_SET) == (off_t)-1) { | 1259 | if (fseeko(fp, (off_t)0, SEEK_SET) == (off_t)-1) { | |
1262 | ret = errno; | 1260 | ret = errno; | |
1263 | goto out3; | 1261 | goto out3; | |
1264 | } | 1262 | } | |
1265 | 1263 | |||
1266 | if (fseeko(tp, (off_t)sizeof(buf) * count + (cp - buf), SEEK_SET) == | 1264 | if (fseeko(tp, (off_t)sizeof(buf) * count + (cp - buf), SEEK_SET) == | |
1267 | (off_t)-1) { | 1265 | (off_t)-1) { | |
1268 | ret = errno; | 1266 | ret = errno; | |
1269 | goto out3; | 1267 | goto out3; | |
1270 | } | 1268 | } | |
1271 | 1269 | |||
1272 | for(;;) { | 1270 | for(;;) { | |
1273 | if ((left = fread(buf, 1, sizeof(buf), tp)) == 0) { | 1271 | if ((left = fread(buf, (size_t)1, sizeof(buf), tp)) == 0) { | |
1274 | if (ferror(fp)) | 1272 | if (ferror(fp)) | |
1275 | ret = errno; | 1273 | ret = errno; | |
1276 | break; | 1274 | break; | |
1277 | } | 1275 | } | |
1278 | if (fwrite(buf, (size_t)left, 1, fp) != 1) { | 1276 | if (fwrite(buf, (size_t)left, (size_t)1, fp) != 1) { | |
1279 | ret = errno; | 1277 | ret = errno; | |
1280 | break; | 1278 | break; | |
1281 | } | 1279 | } | |
1282 | } | 1280 | } | |
1283 | fflush(fp); | 1281 | fflush(fp); | |
1284 | if((off = ftello(fp)) > 0) | 1282 | if((off = ftello(fp)) > 0) | |
1285 | (void)ftruncate(fileno(fp), off); | 1283 | (void)ftruncate(fileno(fp), off); | |
1286 | out3: | 1284 | out3: | |
1287 | fclose(tp); | 1285 | fclose(tp); | |
1288 | out2: | 1286 | out2: | |
1289 | unlink(template); | 1287 | unlink(template); | |
1290 | out1: | 1288 | out1: | |
1291 | fclose(fp); | 1289 | fclose(fp); | |
@@ -2045,27 +2043,27 @@ _rl_event_read_char(EditLine *el, char * | @@ -2045,27 +2043,27 @@ _rl_event_read_char(EditLine *el, char * | |||
2045 | { | 2043 | { | |
2046 | int n; | 2044 | int n; | |
2047 | ssize_t num_read = 0; | 2045 | ssize_t num_read = 0; | |
2048 | 2046 | |||
2049 | *cp = '\0'; | 2047 | *cp = '\0'; | |
2050 | while (rl_event_hook) { | 2048 | while (rl_event_hook) { | |
2051 | 2049 | |||
2052 | (*rl_event_hook)(); | 2050 | (*rl_event_hook)(); | |
2053 | 2051 | |||
2054 | #if defined(FIONREAD) | 2052 | #if defined(FIONREAD) | |
2055 | if (ioctl(el->el_infd, FIONREAD, &n) < 0) | 2053 | if (ioctl(el->el_infd, FIONREAD, &n) < 0) | |
2056 | return -1; | 2054 | return -1; | |
2057 | if (n) | 2055 | if (n) | |
2058 | num_read = read(el->el_infd, cp, 1); | 2056 | num_read = read(el->el_infd, cp, (size_t)1); | |
2059 | else | 2057 | else | |
2060 | num_read = 0; | 2058 | num_read = 0; | |
2061 | #elif defined(F_SETFL) && defined(O_NDELAY) | 2059 | #elif defined(F_SETFL) && defined(O_NDELAY) | |
2062 | if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0) | 2060 | if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0) | |
2063 | return -1; | 2061 | return -1; | |
2064 | if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) | 2062 | if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) | |
2065 | return -1; | 2063 | return -1; | |
2066 | num_read = read(el->el_infd, cp, 1); | 2064 | num_read = read(el->el_infd, cp, 1); | |
2067 | if (fcntl(el->el_infd, F_SETFL, n)) | 2065 | if (fcntl(el->el_infd, F_SETFL, n)) | |
2068 | return -1; | 2066 | return -1; | |
2069 | #else | 2067 | #else | |
2070 | /* not non-blocking, but what you gonna do? */ | 2068 | /* not non-blocking, but what you gonna do? */ | |
2071 | num_read = read(el->el_infd, cp, 1); | 2069 | num_read = read(el->el_infd, cp, 1); |
--- src/lib/libedit/refresh.c 2011/07/28 01:05:20 1.36
+++ src/lib/libedit/refresh.c 2011/07/29 23:44:45 1.37
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: refresh.c,v 1.36 2011/07/28 01:05:20 christos Exp $ */ | 1 | /* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 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 | |
38 | static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: refresh.c,v 1.36 2011/07/28 01:05:20 christos Exp $"); | 40 | __RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 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 <ctype.h> | 48 | #include <ctype.h> | |
49 | #include <unistd.h> | 49 | #include <unistd.h> | |
50 | #include <string.h> | 50 | #include <string.h> | |
51 | 51 | |||
52 | #include "el.h" | 52 | #include "el.h" | |
53 | 53 | |||
@@ -1071,27 +1071,27 @@ re_fastputc(EditLine *el, Int c) | @@ -1071,27 +1071,27 @@ re_fastputc(EditLine *el, Int c) | |||
1071 | /* | 1071 | /* | |
1072 | * If we would overflow (input is longer than terminal size), | 1072 | * If we would overflow (input is longer than terminal size), | |
1073 | * emulate scroll by dropping first line and shuffling the rest. | 1073 | * emulate scroll by dropping first line and shuffling the rest. | |
1074 | * We do this via pointer shuffling - it's safe in this case | 1074 | * We do this via pointer shuffling - it's safe in this case | |
1075 | * and we avoid memcpy(). | 1075 | * and we avoid memcpy(). | |
1076 | */ | 1076 | */ | |
1077 | if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { | 1077 | if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { | |
1078 | int i, lins = el->el_terminal.t_size.v; | 1078 | int i, lins = el->el_terminal.t_size.v; | |
1079 | Char *firstline = el->el_display[0]; | 1079 | Char *firstline = el->el_display[0]; | |
1080 | 1080 | |||
1081 | for(i = 1; i < lins; i++) | 1081 | for(i = 1; i < lins; i++) | |
1082 | el->el_display[i - 1] = el->el_display[i]; | 1082 | el->el_display[i - 1] = el->el_display[i]; | |
1083 | 1083 | |||
1084 | re__copy_and_pad(firstline, STR(""), 0); | 1084 | re__copy_and_pad(firstline, STR(""), (size_t)0); | |
1085 | el->el_display[i - 1] = firstline; | 1085 | el->el_display[i - 1] = firstline; | |
1086 | } else { | 1086 | } else { | |
1087 | el->el_cursor.v++; | 1087 | el->el_cursor.v++; | |
1088 | el->el_refresh.r_oldcv++; | 1088 | el->el_refresh.r_oldcv++; | |
1089 | } | 1089 | } | |
1090 | if (EL_HAS_AUTO_MARGINS) { | 1090 | if (EL_HAS_AUTO_MARGINS) { | |
1091 | if (EL_HAS_MAGIC_MARGINS) { | 1091 | if (EL_HAS_MAGIC_MARGINS) { | |
1092 | terminal__putc(el, ' '); | 1092 | terminal__putc(el, ' '); | |
1093 | terminal__putc(el, '\b'); | 1093 | terminal__putc(el, '\b'); | |
1094 | } | 1094 | } | |
1095 | } else { | 1095 | } else { | |
1096 | terminal__putc(el, '\r'); | 1096 | terminal__putc(el, '\r'); | |
1097 | terminal__putc(el, '\n'); | 1097 | terminal__putc(el, '\n'); |
--- src/lib/libedit/search.c 2011/07/29 15:16:33 1.27
+++ src/lib/libedit/search.c 2011/07/29 23:44:45 1.28
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: search.c,v 1.27 2011/07/29 15:16:33 christos Exp $ */ | 1 | /* $NetBSD: search.c,v 1.28 2011/07/29 23:44:45 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 | |
38 | static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: search.c,v 1.27 2011/07/29 15:16:33 christos Exp $"); | 40 | __RCSID("$NetBSD: search.c,v 1.28 2011/07/29 23:44:45 christos Exp $"); | |
41 | #endif | 41 | #endif | |
42 | #endif /* not lint && not SCCSID */ | 42 | #endif /* not lint && not SCCSID */ | |
43 | 43 | |||
44 | /* | 44 | /* | |
45 | * search.c: History and character search functions | 45 | * search.c: History and character search functions | |
46 | */ | 46 | */ | |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> | |
48 | #if defined(REGEX) | 48 | #if defined(REGEX) | |
49 | #include <regex.h> | 49 | #include <regex.h> | |
50 | #elif defined(REGEXP) | 50 | #elif defined(REGEXP) | |
51 | #include <regexp.h> | 51 | #include <regexp.h> | |
52 | #endif | 52 | #endif | |
53 | #include "el.h" | 53 | #include "el.h" | |
@@ -118,27 +118,28 @@ el_match(const Char *str, const Char *pa | @@ -118,27 +118,28 @@ el_match(const Char *str, const Char *pa | |||
118 | #elif defined (REGEXP) | 118 | #elif defined (REGEXP) | |
119 | regexp *rp; | 119 | regexp *rp; | |
120 | int rv; | 120 | int rv; | |
121 | #else | 121 | #else | |
122 | extern char *re_comp(const char *); | 122 | extern char *re_comp(const char *); | |
123 | extern int re_exec(const char *); | 123 | extern int re_exec(const char *); | |
124 | #endif | 124 | #endif | |
125 | 125 | |||
126 | if (Strstr(str, pat) != 0) | 126 | if (Strstr(str, pat) != 0) | |
127 | return 1; | 127 | return 1; | |
128 | 128 | |||
129 | #if defined(REGEX) | 129 | #if defined(REGEX) | |
130 | if (regcomp(&re, ct_encode_string(pat, &conv), 0) == 0) { | 130 | if (regcomp(&re, ct_encode_string(pat, &conv), 0) == 0) { | |
131 | rv = regexec(&re, ct_encode_string(str, &conv), 0, NULL, 0) == 0; | 131 | rv = regexec(&re, ct_encode_string(str, &conv), (size_t)0, NULL, | |
132 | 0) == 0; | |||
132 | regfree(&re); | 133 | regfree(&re); | |
133 | } else { | 134 | } else { | |
134 | rv = 0; | 135 | rv = 0; | |
135 | } | 136 | } | |
136 | return rv; | 137 | return rv; | |
137 | #elif defined(REGEXP) | 138 | #elif defined(REGEXP) | |
138 | if ((re = regcomp(ct_encode_string(pat, &conv))) != NULL) { | 139 | if ((re = regcomp(ct_encode_string(pat, &conv))) != NULL) { | |
139 | rv = regexec(re, ct_encode_string(str, &conv)); | 140 | rv = regexec(re, ct_encode_string(str, &conv)); | |
140 | el_free(re); | 141 | el_free(re); | |
141 | } else { | 142 | } else { | |
142 | rv = 0; | 143 | rv = 0; | |
143 | } | 144 | } | |
144 | return rv; | 145 | return rv; |
--- src/lib/libedit/terminal.c 2011/07/29 15:20:39 1.6
+++ src/lib/libedit/terminal.c 2011/07/29 23:44:45 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: terminal.c,v 1.6 2011/07/29 15:20:39 christos Exp $ */ | 1 | /* $NetBSD: terminal.c,v 1.7 2011/07/29 23:44:45 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 | |
38 | static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; | 38 | static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: terminal.c,v 1.6 2011/07/29 15:20:39 christos Exp $"); | 40 | __RCSID("$NetBSD: terminal.c,v 1.7 2011/07/29 23:44:45 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 <stdio.h> | |
50 | #include <signal.h> | 50 | #include <signal.h> | |
51 | #include <string.h> | 51 | #include <string.h> | |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> | |
53 | #include <unistd.h> | 53 | #include <unistd.h> | |
@@ -72,27 +72,27 @@ __RCSID("$NetBSD: terminal.c,v 1.6 2011/ | @@ -72,27 +72,27 @@ __RCSID("$NetBSD: terminal.c,v 1.6 2011/ | |||
72 | #ifdef _REENTRANT | 72 | #ifdef _REENTRANT | |
73 | #include <pthread.h> | 73 | #include <pthread.h> | |
74 | #endif | 74 | #endif | |
75 | 75 | |||
76 | #include "el.h" | 76 | #include "el.h" | |
77 | 77 | |||
78 | /* | 78 | /* | |
79 | * IMPORTANT NOTE: these routines are allowed to look at the current screen | 79 | * 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 | 80 | * 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 | 81 | * true, then the update will be WRONG! This is (should be) a valid | |
82 | * assumption... | 82 | * assumption... | |
83 | */ | 83 | */ | |
84 | 84 | |||
85 | #define TC_BUFSIZE 2048 | 85 | #define TC_BUFSIZE ((size_t)2048) | |
86 | 86 | |||
87 | #define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \ | 87 | #define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \ | |
88 | el->el_terminal.t_str[a][0] != '\0') | 88 | el->el_terminal.t_str[a][0] != '\0') | |
89 | #define Str(a) el->el_terminal.t_str[a] | 89 | #define Str(a) el->el_terminal.t_str[a] | |
90 | #define Val(a) el->el_terminal.t_val[a] | 90 | #define Val(a) el->el_terminal.t_val[a] | |
91 | 91 | |||
92 | private const struct termcapstr { | 92 | private const struct termcapstr { | |
93 | const char *name; | 93 | const char *name; | |
94 | const char *long_name; | 94 | const char *long_name; | |
95 | } tstr[] = { | 95 | } tstr[] = { | |
96 | #define T_al 0 | 96 | #define T_al 0 | |
97 | { "al", "add new blank line" }, | 97 | { "al", "add new blank line" }, | |
98 | #define T_bl 1 | 98 | #define T_bl 1 | |
@@ -343,44 +343,44 @@ terminal_alloc(EditLine *el, const struc | @@ -343,44 +343,44 @@ terminal_alloc(EditLine *el, const struc | |||
343 | */ | 343 | */ | |
344 | if (clen <= tlen) { | 344 | if (clen <= tlen) { | |
345 | if (*str) | 345 | if (*str) | |
346 | (void) strcpy(*str, cap); /* XXX strcpy is safe */ | 346 | (void) strcpy(*str, cap); /* XXX strcpy is safe */ | |
347 | return; | 347 | return; | |
348 | } | 348 | } | |
349 | /* | 349 | /* | |
350 | * New string is longer; see if we have enough space to append | 350 | * New string is longer; see if we have enough space to append | |
351 | */ | 351 | */ | |
352 | if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) { | 352 | if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) { | |
353 | /* XXX strcpy is safe */ | 353 | /* XXX strcpy is safe */ | |
354 | (void) strcpy(*str = &el->el_terminal.t_buf[ | 354 | (void) strcpy(*str = &el->el_terminal.t_buf[ | |
355 | el->el_terminal.t_loc], cap); | 355 | el->el_terminal.t_loc], cap); | |
356 | el->el_terminal.t_loc += (int)clen + 1; /* one for \0 */ | 356 | el->el_terminal.t_loc += clen + 1; /* one for \0 */ | |
357 | return; | 357 | return; | |
358 | } | 358 | } | |
359 | /* | 359 | /* | |
360 | * Compact our buffer; no need to check compaction, cause we know it | 360 | * Compact our buffer; no need to check compaction, cause we know it | |
361 | * fits... | 361 | * fits... | |
362 | */ | 362 | */ | |
363 | tlen = 0; | 363 | tlen = 0; | |
364 | for (tmp = tlist; tmp < &tlist[T_str]; tmp++) | 364 | for (tmp = tlist; tmp < &tlist[T_str]; tmp++) | |
365 | if (*tmp != NULL && *tmp != '\0' && *tmp != *str) { | 365 | if (*tmp != NULL && *tmp != '\0' && *tmp != *str) { | |
366 | char *ptr; | 366 | char *ptr; | |
367 | 367 | |||
368 | for (ptr = *tmp; *ptr != '\0'; termbuf[tlen++] = *ptr++) | 368 | for (ptr = *tmp; *ptr != '\0'; termbuf[tlen++] = *ptr++) | |
369 | continue; | 369 | continue; | |
370 | termbuf[tlen++] = '\0'; | 370 | termbuf[tlen++] = '\0'; | |
371 | } | 371 | } | |
372 | memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE); | 372 | memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE); | |
373 | el->el_terminal.t_loc = (int)tlen; | 373 | el->el_terminal.t_loc = tlen; | |
374 | if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) { | 374 | if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) { | |
375 | (void) fprintf(el->el_errfile, | 375 | (void) fprintf(el->el_errfile, | |
376 | "Out of termcap string space.\n"); | 376 | "Out of termcap string space.\n"); | |
377 | return; | 377 | return; | |
378 | } | 378 | } | |
379 | /* XXX strcpy is safe */ | 379 | /* XXX strcpy is safe */ | |
380 | (void) strcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc], | 380 | (void) strcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc], | |
381 | cap); | 381 | cap); | |
382 | el->el_terminal.t_loc += (int)clen + 1; /* one for \0 */ | 382 | el->el_terminal.t_loc += (int)clen + 1; /* one for \0 */ | |
383 | return; | 383 | return; | |
384 | } | 384 | } | |
385 | 385 | |||
386 | 386 | |||
@@ -659,27 +659,27 @@ terminal_overwrite(EditLine *el, const C | @@ -659,27 +659,27 @@ terminal_overwrite(EditLine *el, const C | |||
659 | el->el_cursor.h++; | 659 | el->el_cursor.h++; | |
660 | } while (--n); | 660 | } while (--n); | |
661 | 661 | |||
662 | if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */ | 662 | if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */ | |
663 | if (EL_HAS_AUTO_MARGINS) { /* yes */ | 663 | if (EL_HAS_AUTO_MARGINS) { /* yes */ | |
664 | el->el_cursor.h = 0; | 664 | el->el_cursor.h = 0; | |
665 | el->el_cursor.v++; | 665 | el->el_cursor.v++; | |
666 | if (EL_HAS_MAGIC_MARGINS) { | 666 | if (EL_HAS_MAGIC_MARGINS) { | |
667 | /* force the wrap to avoid the "magic" | 667 | /* force the wrap to avoid the "magic" | |
668 | * situation */ | 668 | * situation */ | |
669 | Char c; | 669 | Char c; | |
670 | if ((c = el->el_display[el->el_cursor.v] | 670 | if ((c = el->el_display[el->el_cursor.v] | |
671 | [el->el_cursor.h]) != '\0') { | 671 | [el->el_cursor.h]) != '\0') { | |
672 | terminal_overwrite(el, &c, 1); | 672 | terminal_overwrite(el, &c, (size_t)1); | |
673 | #ifdef WIDECHAR | 673 | #ifdef WIDECHAR | |
674 | while (el->el_display[el->el_cursor.v] | 674 | while (el->el_display[el->el_cursor.v] | |
675 | [el->el_cursor.h] == MB_FILL_CHAR) | 675 | [el->el_cursor.h] == MB_FILL_CHAR) | |
676 | el->el_cursor.h++; | 676 | el->el_cursor.h++; | |
677 | #endif | 677 | #endif | |
678 | } else { | 678 | } else { | |
679 | terminal__putc(el, ' '); | 679 | terminal__putc(el, ' '); | |
680 | el->el_cursor.h = 1; | 680 | el->el_cursor.h = 1; | |
681 | } | 681 | } | |
682 | } | 682 | } | |
683 | } else /* no wrap, but cursor stays on screen */ | 683 | } else /* no wrap, but cursor stays on screen */ | |
684 | el->el_cursor.h = el->el_terminal.t_size.h - 1; | 684 | el->el_cursor.h = el->el_terminal.t_size.h - 1; | |
685 | } | 685 | } | |
@@ -1226,27 +1226,27 @@ terminal_tputs(EditLine *el, const char | @@ -1226,27 +1226,27 @@ terminal_tputs(EditLine *el, const char | |||
1226 | #endif | 1226 | #endif | |
1227 | } | 1227 | } | |
1228 | 1228 | |||
1229 | /* terminal__putc(): | 1229 | /* terminal__putc(): | |
1230 | * Add a character | 1230 | * Add a character | |
1231 | */ | 1231 | */ | |
1232 | protected int | 1232 | protected int | |
1233 | terminal__putc(EditLine *el, Int c) | 1233 | terminal__putc(EditLine *el, Int c) | |
1234 | { | 1234 | { | |
1235 | char buf[MB_LEN_MAX +1]; | 1235 | char buf[MB_LEN_MAX +1]; | |
1236 | ssize_t i; | 1236 | ssize_t i; | |
1237 | if (c == MB_FILL_CHAR) | 1237 | if (c == MB_FILL_CHAR) | |
1238 | return 0; | 1238 | return 0; | |
1239 | i = ct_encode_char(buf, MB_LEN_MAX, c); | 1239 | i = ct_encode_char(buf, (size_t)MB_LEN_MAX, c); | |
1240 | if (i <= 0) | 1240 | if (i <= 0) | |
1241 | return (int)i; | 1241 | return (int)i; | |
1242 | buf[i] = '\0'; | 1242 | buf[i] = '\0'; | |
1243 | return fputs(buf, el->el_outfile); | 1243 | return fputs(buf, el->el_outfile); | |
1244 | } | 1244 | } | |
1245 | 1245 | |||
1246 | /* terminal__flush(): | 1246 | /* terminal__flush(): | |
1247 | * Flush output | 1247 | * Flush output | |
1248 | */ | 1248 | */ | |
1249 | protected void | 1249 | protected void | |
1250 | terminal__flush(EditLine *el) | 1250 | terminal__flush(EditLine *el) | |
1251 | { | 1251 | { | |
1252 | 1252 |
--- src/lib/libedit/terminal.h 2011/07/28 01:56:27 1.2
+++ src/lib/libedit/terminal.h 2011/07/29 23:44:45 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: terminal.h,v 1.2 2011/07/28 01:56:27 christos Exp $ */ | 1 | /* $NetBSD: terminal.h,v 1.3 2011/07/29 23:44:45 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. | |
@@ -53,27 +53,27 @@ typedef struct { | @@ -53,27 +53,27 @@ typedef struct { | |||
53 | const char *t_name; /* the terminal name */ | 53 | const char *t_name; /* the terminal name */ | |
54 | coord_t t_size; /* # lines and cols */ | 54 | coord_t t_size; /* # lines and cols */ | |
55 | int t_flags; | 55 | int t_flags; | |
56 | #define TERM_CAN_INSERT 0x001 /* Has insert cap */ | 56 | #define TERM_CAN_INSERT 0x001 /* Has insert cap */ | |
57 | #define TERM_CAN_DELETE 0x002 /* Has delete cap */ | 57 | #define TERM_CAN_DELETE 0x002 /* Has delete cap */ | |
58 | #define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ | 58 | #define TERM_CAN_CEOL 0x004 /* Has CEOL cap */ | |
59 | #define TERM_CAN_TAB 0x008 /* Can use tabs */ | 59 | #define TERM_CAN_TAB 0x008 /* Can use tabs */ | |
60 | #define TERM_CAN_ME 0x010 /* Can turn all attrs. */ | 60 | #define TERM_CAN_ME 0x010 /* Can turn all attrs. */ | |
61 | #define TERM_CAN_UP 0x020 /* Can move up */ | 61 | #define TERM_CAN_UP 0x020 /* Can move up */ | |
62 | #define TERM_HAS_META 0x040 /* Has a meta key */ | 62 | #define TERM_HAS_META 0x040 /* Has a meta key */ | |
63 | #define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ | 63 | #define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */ | |
64 | #define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ | 64 | #define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */ | |
65 | char *t_buf; /* Termcap buffer */ | 65 | char *t_buf; /* Termcap buffer */ | |
66 | int t_loc; /* location used */ | 66 | size_t t_loc; /* location used */ | |
67 | char **t_str; /* termcap strings */ | 67 | char **t_str; /* termcap strings */ | |
68 | int *t_val; /* termcap values */ | 68 | int *t_val; /* termcap values */ | |
69 | char *t_cap; /* Termcap buffer */ | 69 | char *t_cap; /* Termcap buffer */ | |
70 | funckey_t *t_fkey; /* Array of keys */ | 70 | funckey_t *t_fkey; /* Array of keys */ | |
71 | } el_terminal_t; | 71 | } el_terminal_t; | |
72 | 72 | |||
73 | /* | 73 | /* | |
74 | * fKey indexes | 74 | * fKey indexes | |
75 | */ | 75 | */ | |
76 | #define A_K_DN 0 | 76 | #define A_K_DN 0 | |
77 | #define A_K_UP 1 | 77 | #define A_K_UP 1 | |
78 | #define A_K_LT 2 | 78 | #define A_K_LT 2 | |
79 | #define A_K_RT 3 | 79 | #define A_K_RT 3 |
--- src/lib/libedit/vi.c 2011/07/29 20:58:07 1.38
+++ src/lib/libedit/vi.c 2011/07/29 23:44:45 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vi.c,v 1.38 2011/07/29 20:58:07 christos Exp $ */ | 1 | /* $NetBSD: vi.c,v 1.39 2011/07/29 23:44:45 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,27 +32,27 @@ | @@ -32,27 +32,27 @@ | |||
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include "config.h" | 35 | #include "config.h" | |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> | |
37 | #include <unistd.h> | 37 | #include <unistd.h> | |
38 | #include <limits.h> | 38 | #include <limits.h> | |
39 | #include <sys/wait.h> | 39 | #include <sys/wait.h> | |
40 | 40 | |||
41 | #if !defined(lint) && !defined(SCCSID) | 41 | #if !defined(lint) && !defined(SCCSID) | |
42 | #if 0 | 42 | #if 0 | |
43 | static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; | 43 | static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93"; | |
44 | #else | 44 | #else | |
45 | __RCSID("$NetBSD: vi.c,v 1.38 2011/07/29 20:58:07 christos Exp $"); | 45 | __RCSID("$NetBSD: vi.c,v 1.39 2011/07/29 23:44:45 christos Exp $"); | |
46 | #endif | 46 | #endif | |
47 | #endif /* not lint && not SCCSID */ | 47 | #endif /* not lint && not SCCSID */ | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * vi.c: Vi mode commands. | 50 | * vi.c: Vi mode commands. | |
51 | */ | 51 | */ | |
52 | #include "el.h" | 52 | #include "el.h" | |
53 | 53 | |||
54 | private el_action_t cv_action(EditLine *, Int); | 54 | private el_action_t cv_action(EditLine *, Int); | |
55 | private el_action_t cv_paste(EditLine *, Int); | 55 | private el_action_t cv_paste(EditLine *, Int); | |
56 | 56 | |||
57 | /* cv_action(): | 57 | /* cv_action(): | |
58 | * Handle vi actions. | 58 | * Handle vi actions. | |
@@ -1027,27 +1027,27 @@ vi_histedit(EditLine *el, Int c __attrib | @@ -1027,27 +1027,27 @@ vi_histedit(EditLine *el, Int c __attrib | |||
1027 | return CC_ERROR; | 1027 | return CC_ERROR; | |
1028 | } | 1028 | } | |
1029 | line = el_malloc(len * sizeof(*line)); | 1029 | line = el_malloc(len * sizeof(*line)); | |
1030 | if (line == NULL) { | 1030 | if (line == NULL) { | |
1031 | el_free(cp); | 1031 | el_free(cp); | |
1032 | return CC_ERROR; | 1032 | return CC_ERROR; | |
1033 | } | 1033 | } | |
1034 | Strncpy(line, el->el_line.buffer, len); | 1034 | Strncpy(line, el->el_line.buffer, len); | |
1035 | line[len] = '\0'; | 1035 | line[len] = '\0'; | |
1036 | ct_wcstombs(cp, line, TMP_BUFSIZ - 1); | 1036 | ct_wcstombs(cp, line, TMP_BUFSIZ - 1); | |
1037 | cp[TMP_BUFSIZ - 1] = '\0'; | 1037 | cp[TMP_BUFSIZ - 1] = '\0'; | |
1038 | len = strlen(cp); | 1038 | len = strlen(cp); | |
1039 | write(fd, cp, len); | 1039 | write(fd, cp, len); | |
1040 | write(fd, "\n", 1); | 1040 | write(fd, "\n", (size_t)1); | |
1041 | pid = fork(); | 1041 | pid = fork(); | |
1042 | switch (pid) { | 1042 | switch (pid) { | |
1043 | case -1: | 1043 | case -1: | |
1044 | close(fd); | 1044 | close(fd); | |
1045 | unlink(tempfile); | 1045 | unlink(tempfile); | |
1046 | el_free(cp); | 1046 | el_free(cp); | |
1047 | el_free(line); | 1047 | el_free(line); | |
1048 | return CC_ERROR; | 1048 | return CC_ERROR; | |
1049 | case 0: | 1049 | case 0: | |
1050 | close(fd); | 1050 | close(fd); | |
1051 | execlp("vi", "vi", tempfile, (char *)NULL); | 1051 | execlp("vi", "vi", tempfile, (char *)NULL); | |
1052 | exit(0); | 1052 | exit(0); | |
1053 | /*NOTREACHED*/ | 1053 | /*NOTREACHED*/ |