]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/readline/readline52-005
Merge remote-tracking branch 'stevee/axel-log-fix' into next
[ipfire-2.x.git] / src / patches / readline / readline52-005
CommitLineData
f19b3cb6
MT
1 READLINE PATCH REPORT
2 =====================
3
4Readline-Release: 5.2
5Patch-ID: readline52-005
6
7Bug-Reported-by: Thomas Loeber <ifp@loeber1.de>
8Bug-Reference-ID: <200703082223.08919.ifp@loeber1.de>
9Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-03/msg00036.html
10
11Bug-Description:
12
13When rl_read_key returns -1, indicating that readline's controlling terminal
14has been invalidated for some reason (e.g., receiving a SIGHUP), the error
15status was not reported correctly to the caller. This could cause input
16loops.
17
18Patch:
19
20*** ../readline-5.2/complete.c Fri Jul 28 11:35:49 2006
21--- complete.c Tue Mar 13 08:50:16 2007
22***************
23*** 429,433 ****
24 if (c == 'n' || c == 'N' || c == RUBOUT)
25 return (0);
26! if (c == ABORT_CHAR)
27 _rl_abort_internal ();
28 if (for_pager && (c == NEWLINE || c == RETURN))
29--- 440,444 ----
30 if (c == 'n' || c == 'N' || c == RUBOUT)
31 return (0);
32! if (c == ABORT_CHAR || c < 0)
33 _rl_abort_internal ();
34 if (for_pager && (c == NEWLINE || c == RETURN))
35*** ../readline-5.2/input.c Wed Aug 16 15:15:16 2006
36--- input.c Wed May 2 16:07:59 2007
37***************
38*** 514,518 ****
39 int size;
40 {
41! int mb_len = 0;
42 size_t mbchar_bytes_length;
43 wchar_t wc;
44--- 522,526 ----
45 int size;
46 {
47! int mb_len, c;
48 size_t mbchar_bytes_length;
49 wchar_t wc;
50***************
51*** 521,531 ****
52 memset(&ps, 0, sizeof (mbstate_t));
53 memset(&ps_back, 0, sizeof (mbstate_t));
54!
55 while (mb_len < size)
56 {
57 RL_SETSTATE(RL_STATE_MOREINPUT);
58! mbchar[mb_len++] = rl_read_key ();
59 RL_UNSETSTATE(RL_STATE_MOREINPUT);
60
61 mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
62 if (mbchar_bytes_length == (size_t)(-1))
63--- 529,545 ----
64 memset(&ps, 0, sizeof (mbstate_t));
65 memset(&ps_back, 0, sizeof (mbstate_t));
66!
67! mb_len = 0;
68 while (mb_len < size)
69 {
70 RL_SETSTATE(RL_STATE_MOREINPUT);
71! c = rl_read_key ();
72 RL_UNSETSTATE(RL_STATE_MOREINPUT);
73
74+ if (c < 0)
75+ break;
76+
77+ mbchar[mb_len++] = c;
78+
79 mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
80 if (mbchar_bytes_length == (size_t)(-1))
81***************
82*** 565,569 ****
83 c = first;
84 memset (mb, 0, mlen);
85! for (i = 0; i < mlen; i++)
86 {
87 mb[i] = (char)c;
88--- 579,583 ----
89 c = first;
90 memset (mb, 0, mlen);
91! for (i = 0; c >= 0 && i < mlen; i++)
92 {
93 mb[i] = (char)c;
94*** ../readline-5.2/isearch.c Mon Dec 26 17:18:53 2005
95--- isearch.c Fri Mar 9 14:30:59 2007
96***************
97*** 328,333 ****
98
99 f = (rl_command_func_t *)NULL;
100!
101! /* Translate the keys we do something with to opcodes. */
102 if (c >= 0 && _rl_keymap[c].type == ISFUNC)
103 {
104--- 328,340 ----
105
106 f = (rl_command_func_t *)NULL;
107!
108! if (c < 0)
109! {
110! cxt->sflags |= SF_FAILED;
111! cxt->history_pos = cxt->last_found_line;
112! return -1;
113! }
114!
115! /* Translate the keys we do something with to opcodes. */
116 if (c >= 0 && _rl_keymap[c].type == ISFUNC)
117 {
118*** ../readline-5.2/misc.c Mon Dec 26 17:20:46 2005
119--- misc.c Fri Mar 9 14:44:11 2007
120***************
121*** 147,150 ****
122--- 147,152 ----
123 rl_clear_message ();
124 RL_UNSETSTATE(RL_STATE_NUMERICARG);
125+ if (key < 0)
126+ return -1;
127 return (_rl_dispatch (key, _rl_keymap));
128 }
129*** ../readline-5.2/readline.c Wed Aug 16 15:00:36 2006
130--- readline.c Fri Mar 9 14:47:24 2007
131***************
132*** 646,649 ****
133--- 669,677 ----
134 {
135 nkey = _rl_subseq_getchar (cxt->okey);
136+ if (nkey < 0)
137+ {
138+ _rl_abort_internal ();
139+ return -1;
140+ }
141 r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
142 cxt->flags |= KSEQ_DISPATCHED;
143*** ../readline-5.2/text.c Fri Jul 28 11:55:27 2006
144--- text.c Sun Mar 25 13:41:38 2007
145***************
146*** 858,861 ****
147--- 864,870 ----
148 RL_UNSETSTATE(RL_STATE_MOREINPUT);
149
150+ if (c < 0)
151+ return -1;
152+
153 #if defined (HANDLE_SIGNALS)
154 if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
155***************
156*** 1521,1524 ****
157--- 1530,1536 ----
158 mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
159
160+ if (mb_len <= 0)
161+ return -1;
162+
163 if (count < 0)
164 return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
165***************
166*** 1537,1540 ****
167--- 1549,1555 ----
168 RL_UNSETSTATE(RL_STATE_MOREINPUT);
169
170+ if (c < 0)
171+ return -1;
172+
173 if (count < 0)
174 return (_rl_char_search_internal (-count, bdir, c));
175*** ../readline-5.2/vi_mode.c Sat Jul 29 16:42:28 2006
176--- vi_mode.c Fri Mar 9 15:02:11 2007
177***************
178*** 887,890 ****
179--- 887,897 ----
180 c = rl_read_key ();
181 RL_UNSETSTATE(RL_STATE_MOREINPUT);
182+
183+ if (c < 0)
184+ {
185+ *nextkey = 0;
186+ return -1;
187+ }
188+
189 *nextkey = c;
190
191***************
192*** 903,906 ****
193--- 910,918 ----
194 c = rl_read_key (); /* real command */
195 RL_UNSETSTATE(RL_STATE_MOREINPUT);
196+ if (c < 0)
197+ {
198+ *nextkey = 0;
199+ return -1;
200+ }
201 *nextkey = c;
202 }
203***************
204*** 1225,1236 ****
205 _rl_callback_generic_arg *data;
206 {
207 #if defined (HANDLE_MULTIBYTE)
208! _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
209 #else
210 RL_SETSTATE(RL_STATE_MOREINPUT);
211! _rl_vi_last_search_char = rl_read_key ();
212 RL_UNSETSTATE(RL_STATE_MOREINPUT);
213 #endif
214
215 _rl_callback_func = 0;
216 _rl_want_redisplay = 1;
217--- 1243,1262 ----
218 _rl_callback_generic_arg *data;
219 {
220+ int c;
221 #if defined (HANDLE_MULTIBYTE)
222! c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
223 #else
224 RL_SETSTATE(RL_STATE_MOREINPUT);
225! c = rl_read_key ();
226 RL_UNSETSTATE(RL_STATE_MOREINPUT);
227 #endif
228
229+ if (c <= 0)
230+ return -1;
231+
232+ #if !defined (HANDLE_MULTIBYTE)
233+ _rl_vi_last_search_char = c;
234+ #endif
235+
236 _rl_callback_func = 0;
237 _rl_want_redisplay = 1;
238***************
239*** 1248,1251 ****
240--- 1274,1278 ----
241 int count, key;
242 {
243+ int c;
244 #if defined (HANDLE_MULTIBYTE)
245 static char *target;
246***************
247*** 1294,1302 ****
248 {
249 #if defined (HANDLE_MULTIBYTE)
250! _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
251 #else
252 RL_SETSTATE(RL_STATE_MOREINPUT);
253! _rl_vi_last_search_char = rl_read_key ();
254 RL_UNSETSTATE(RL_STATE_MOREINPUT);
255 #endif
256 }
257--- 1321,1335 ----
258 {
259 #if defined (HANDLE_MULTIBYTE)
260! c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
261! if (c <= 0)
262! return -1;
263! _rl_vi_last_search_mblen = c;
264 #else
265 RL_SETSTATE(RL_STATE_MOREINPUT);
266! c = rl_read_key ();
267 RL_UNSETSTATE(RL_STATE_MOREINPUT);
268+ if (c < 0)
269+ return -1;
270+ _rl_vi_last_search_char = c;
271 #endif
272 }
273***************
274*** 1468,1471 ****
275--- 1501,1507 ----
276 RL_UNSETSTATE(RL_STATE_MOREINPUT);
277
278+ if (c < 0)
279+ return -1;
280+
281 #if defined (HANDLE_MULTIBYTE)
282 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
283***************
284*** 1486,1489 ****
285--- 1522,1528 ----
286 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
287
288+ if (c < 0)
289+ return -1;
290+
291 _rl_callback_func = 0;
292 _rl_want_redisplay = 1;
293***************
294*** 1517,1520 ****
295--- 1556,1562 ----
296 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
297
298+ if (c < 0)
299+ return -1;
300+
301 return (_rl_vi_change_char (count, c, mb));
302 }
303***************
304*** 1651,1655 ****
305 RL_UNSETSTATE(RL_STATE_MOREINPUT);
306
307! if (ch < 'a' || ch > 'z')
308 {
309 rl_ding ();
310--- 1693,1697 ----
311 RL_UNSETSTATE(RL_STATE_MOREINPUT);
312
313! if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
314 {
315 rl_ding ();
316***************
317*** 1703,1707 ****
318 return 0;
319 }
320! else if (ch < 'a' || ch > 'z')
321 {
322 rl_ding ();
323--- 1745,1749 ----
324 return 0;
325 }
326! else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
327 {
328 rl_ding ();