source: patches/readline-5.2-fixes-3.patch@ bfb94b2

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since bfb94b2 was c30178f, checked in by Jim Gifford <clfs@…>, 17 years ago

Added: readline-5.2-fixes-3.patch

  • Property mode set to 100644
File size: 12.5 KB
RevLine 
[c30178f]1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
2Date: 2007-09-03
3Initial Package Version: 5.2
4Origin: ftp://ftp.cwru.edu/pub/bash/readline-5.2-patches
5Upstream Status: From Upstream
6Description: Contains patches 001-007 from upstream
7
8diff -Naur readline-5.2.orig/complete.c readline-5.2/complete.c
9--- readline-5.2.orig/complete.c 2006-07-28 08:35:49.000000000 -0700
10+++ readline-5.2/complete.c 2007-09-03 22:06:46.000000000 -0700
11@@ -428,7 +428,7 @@
12 return (1);
13 if (c == 'n' || c == 'N' || c == RUBOUT)
14 return (0);
15- if (c == ABORT_CHAR)
16+ if (c == ABORT_CHAR || c < 0)
17 _rl_abort_internal ();
18 if (for_pager && (c == NEWLINE || c == RETURN))
19 return (2);
20diff -Naur readline-5.2.orig/display.c readline-5.2/display.c
21--- readline-5.2.orig/display.c 2006-09-14 11:20:12.000000000 -0700
22+++ readline-5.2/display.c 2007-09-03 22:06:48.000000000 -0700
23@@ -561,6 +561,17 @@
24 wrap_offset = prompt_invis_chars_first_line = 0;
25 }
26
27+#if defined (HANDLE_MULTIBYTE)
28+#define CHECK_INV_LBREAKS() \
29+ do { \
30+ if (newlines >= (inv_lbsize - 2)) \
31+ { \
32+ inv_lbsize *= 2; \
33+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
34+ _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
35+ } \
36+ } while (0)
37+#else
38 #define CHECK_INV_LBREAKS() \
39 do { \
40 if (newlines >= (inv_lbsize - 2)) \
41@@ -569,6 +580,7 @@
42 inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
43 } \
44 } while (0)
45+#endif /* HANDLE_MULTIBYTE */
46
47 #if defined (HANDLE_MULTIBYTE)
48 #define CHECK_LPOS() \
49@@ -1506,11 +1518,31 @@
50 {
51 /* Non-zero if we're increasing the number of lines. */
52 int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
53+ /* If col_lendiff is > 0, implying that the new string takes up more
54+ screen real estate than the old, but lendiff is < 0, meaning that it
55+ takes fewer bytes, we need to just output the characters starting
56+ from the first difference. These will overwrite what is on the
57+ display, so there's no reason to do a smart update. This can really
58+ only happen in a multibyte environment. */
59+ if (lendiff < 0)
60+ {
61+ _rl_output_some_chars (nfd, temp);
62+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
63+ /* If nfd begins before any invisible characters in the prompt,
64+ adjust _rl_last_c_pos to account for wrap_offset and set
65+ cpos_adjusted to let the caller know. */
66+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
67+ {
68+ _rl_last_c_pos -= wrap_offset;
69+ cpos_adjusted = 1;
70+ }
71+ return;
72+ }
73 /* Sometimes it is cheaper to print the characters rather than
74 use the terminal's capabilities. If we're growing the number
75 of lines, make sure we actually cause the new line to wrap
76 around on auto-wrapping terminals. */
77- if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
78+ else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
79 {
80 /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
81 _rl_horizontal_scroll_mode == 1, inserting the characters with
82@@ -1586,8 +1618,22 @@
83 temp = nls - nfd;
84 if (temp > 0)
85 {
86+ /* If nfd begins at the prompt, or before the invisible
87+ characters in the prompt, we need to adjust _rl_last_c_pos
88+ in a multibyte locale to account for the wrap offset and
89+ set cpos_adjusted accordingly. */
90 _rl_output_some_chars (nfd, temp);
91- _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
92+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
93+ {
94+ _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
95+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
96+ {
97+ _rl_last_c_pos -= wrap_offset;
98+ cpos_adjusted = 1;
99+ }
100+ }
101+ else
102+ _rl_last_c_pos += temp;
103 }
104 }
105 /* Otherwise, print over the existing material. */
106@@ -1595,8 +1641,20 @@
107 {
108 if (temp > 0)
109 {
110+ /* If nfd begins at the prompt, or before the invisible
111+ characters in the prompt, we need to adjust _rl_last_c_pos
112+ in a multibyte locale to account for the wrap offset and
113+ set cpos_adjusted accordingly. */
114 _rl_output_some_chars (nfd, temp);
115 _rl_last_c_pos += col_temp; /* XXX */
116+ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
117+ {
118+ if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
119+ {
120+ _rl_last_c_pos -= wrap_offset;
121+ cpos_adjusted = 1;
122+ }
123+ }
124 }
125 lendiff = (oe - old) - (ne - new);
126 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
127@@ -1732,7 +1790,10 @@
128 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
129 {
130 dpos = _rl_col_width (data, 0, new);
131- if (dpos > prompt_last_invisible) /* XXX - don't use woff here */
132+ /* Use NEW when comparing against the last invisible character in the
133+ prompt string, since they're both buffer indices and DPOS is a
134+ desired display position. */
135+ if (new > prompt_last_invisible) /* XXX - don't use woff here */
136 {
137 dpos -= woff;
138 /* Since this will be assigned to _rl_last_c_pos at the end (more
139@@ -2380,6 +2441,8 @@
140
141 if (end <= start)
142 return 0;
143+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
144+ return (end - start);
145
146 memset (&ps, 0, sizeof (mbstate_t));
147
148diff -Naur readline-5.2.orig/input.c readline-5.2/input.c
149--- readline-5.2.orig/input.c 2006-08-16 12:15:16.000000000 -0700
150+++ readline-5.2/input.c 2007-09-03 22:06:51.000000000 -0700
151@@ -133,8 +133,11 @@
152 return (0);
153
154 *key = ibuffer[pop_index++];
155-
156+#if 0
157 if (pop_index >= ibuffer_len)
158+#else
159+ if (pop_index > ibuffer_len)
160+#endif
161 pop_index = 0;
162
163 return (1);
164@@ -250,7 +253,8 @@
165 while (chars_avail--)
166 {
167 k = (*rl_getc_function) (rl_instream);
168- rl_stuff_char (k);
169+ if (rl_stuff_char (k) == 0)
170+ break; /* some problem; no more room */
171 if (k == NEWLINE || k == RETURN)
172 break;
173 }
174@@ -373,7 +377,11 @@
175 RL_SETSTATE (RL_STATE_INPUTPENDING);
176 }
177 ibuffer[push_index++] = key;
178+#if 0
179 if (push_index >= ibuffer_len)
180+#else
181+ if (push_index > ibuffer_len)
182+#endif
183 push_index = 0;
184
185 return 1;
186@@ -513,20 +521,26 @@
187 char *mbchar;
188 int size;
189 {
190- int mb_len = 0;
191+ int mb_len, c;
192 size_t mbchar_bytes_length;
193 wchar_t wc;
194 mbstate_t ps, ps_back;
195
196 memset(&ps, 0, sizeof (mbstate_t));
197 memset(&ps_back, 0, sizeof (mbstate_t));
198-
199+
200+ mb_len = 0;
201 while (mb_len < size)
202 {
203 RL_SETSTATE(RL_STATE_MOREINPUT);
204- mbchar[mb_len++] = rl_read_key ();
205+ c = rl_read_key ();
206 RL_UNSETSTATE(RL_STATE_MOREINPUT);
207
208+ if (c < 0)
209+ break;
210+
211+ mbchar[mb_len++] = c;
212+
213 mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
214 if (mbchar_bytes_length == (size_t)(-1))
215 break; /* invalid byte sequence for the current locale */
216@@ -564,7 +578,7 @@
217
218 c = first;
219 memset (mb, 0, mlen);
220- for (i = 0; i < mlen; i++)
221+ for (i = 0; c >= 0 && i < mlen; i++)
222 {
223 mb[i] = (char)c;
224 memset (&ps, 0, sizeof (mbstate_t));
225diff -Naur readline-5.2.orig/isearch.c readline-5.2/isearch.c
226--- readline-5.2.orig/isearch.c 2005-12-26 14:18:53.000000000 -0800
227+++ readline-5.2/isearch.c 2007-09-03 22:06:46.000000000 -0700
228@@ -327,8 +327,15 @@
229 rl_command_func_t *f;
230
231 f = (rl_command_func_t *)NULL;
232-
233- /* Translate the keys we do something with to opcodes. */
234+
235+ if (c < 0)
236+ {
237+ cxt->sflags |= SF_FAILED;
238+ cxt->history_pos = cxt->last_found_line;
239+ return -1;
240+ }
241+
242+ /* Translate the keys we do something with to opcodes. */
243 if (c >= 0 && _rl_keymap[c].type == ISFUNC)
244 {
245 f = _rl_keymap[c].function;
246diff -Naur readline-5.2.orig/misc.c readline-5.2/misc.c
247--- readline-5.2.orig/misc.c 2005-12-26 14:20:46.000000000 -0800
248+++ readline-5.2/misc.c 2007-09-03 22:06:46.000000000 -0700
249@@ -146,6 +146,8 @@
250 rl_restore_prompt ();
251 rl_clear_message ();
252 RL_UNSETSTATE(RL_STATE_NUMERICARG);
253+ if (key < 0)
254+ return -1;
255 return (_rl_dispatch (key, _rl_keymap));
256 }
257 }
258diff -Naur readline-5.2.orig/readline.c readline-5.2/readline.c
259--- readline-5.2.orig/readline.c 2006-08-16 12:00:36.000000000 -0700
260+++ readline-5.2/readline.c 2007-09-03 22:06:46.000000000 -0700
261@@ -645,6 +645,11 @@
262 if ((cxt->flags & KSEQ_DISPATCHED) == 0)
263 {
264 nkey = _rl_subseq_getchar (cxt->okey);
265+ if (nkey < 0)
266+ {
267+ _rl_abort_internal ();
268+ return -1;
269+ }
270 r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
271 cxt->flags |= KSEQ_DISPATCHED;
272 }
273diff -Naur readline-5.2.orig/text.c readline-5.2/text.c
274--- readline-5.2.orig/text.c 2006-07-28 08:55:27.000000000 -0700
275+++ readline-5.2/text.c 2007-09-03 22:06:46.000000000 -0700
276@@ -857,6 +857,9 @@
277 c = rl_read_key ();
278 RL_UNSETSTATE(RL_STATE_MOREINPUT);
279
280+ if (c < 0)
281+ return -1;
282+
283 #if defined (HANDLE_SIGNALS)
284 if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
285 _rl_restore_tty_signals ();
286@@ -1520,6 +1523,9 @@
287
288 mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
289
290+ if (mb_len <= 0)
291+ return -1;
292+
293 if (count < 0)
294 return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
295 else
296@@ -1536,6 +1542,9 @@
297 c = rl_read_key ();
298 RL_UNSETSTATE(RL_STATE_MOREINPUT);
299
300+ if (c < 0)
301+ return -1;
302+
303 if (count < 0)
304 return (_rl_char_search_internal (-count, bdir, c));
305 else
306diff -Naur readline-5.2.orig/vi_mode.c readline-5.2/vi_mode.c
307--- readline-5.2.orig/vi_mode.c 2006-07-29 13:42:28.000000000 -0700
308+++ readline-5.2/vi_mode.c 2007-09-03 22:06:46.000000000 -0700
309@@ -886,6 +886,13 @@
310 RL_SETSTATE(RL_STATE_MOREINPUT);
311 c = rl_read_key ();
312 RL_UNSETSTATE(RL_STATE_MOREINPUT);
313+
314+ if (c < 0)
315+ {
316+ *nextkey = 0;
317+ return -1;
318+ }
319+
320 *nextkey = c;
321
322 if (!member (c, vi_motion))
323@@ -902,6 +909,11 @@
324 RL_SETSTATE(RL_STATE_MOREINPUT);
325 c = rl_read_key (); /* real command */
326 RL_UNSETSTATE(RL_STATE_MOREINPUT);
327+ if (c < 0)
328+ {
329+ *nextkey = 0;
330+ return -1;
331+ }
332 *nextkey = c;
333 }
334 else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
335@@ -1224,14 +1236,22 @@
336 _rl_vi_callback_char_search (data)
337 _rl_callback_generic_arg *data;
338 {
339+ int c;
340 #if defined (HANDLE_MULTIBYTE)
341- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
342+ c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
343 #else
344 RL_SETSTATE(RL_STATE_MOREINPUT);
345- _rl_vi_last_search_char = rl_read_key ();
346+ c = rl_read_key ();
347 RL_UNSETSTATE(RL_STATE_MOREINPUT);
348 #endif
349
350+ if (c <= 0)
351+ return -1;
352+
353+#if !defined (HANDLE_MULTIBYTE)
354+ _rl_vi_last_search_char = c;
355+#endif
356+
357 _rl_callback_func = 0;
358 _rl_want_redisplay = 1;
359
360@@ -1247,6 +1267,7 @@
361 rl_vi_char_search (count, key)
362 int count, key;
363 {
364+ int c;
365 #if defined (HANDLE_MULTIBYTE)
366 static char *target;
367 static int tlen;
368@@ -1293,11 +1314,17 @@
369 else
370 {
371 #if defined (HANDLE_MULTIBYTE)
372- _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
373+ c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
374+ if (c <= 0)
375+ return -1;
376+ _rl_vi_last_search_mblen = c;
377 #else
378 RL_SETSTATE(RL_STATE_MOREINPUT);
379- _rl_vi_last_search_char = rl_read_key ();
380+ c = rl_read_key ();
381 RL_UNSETSTATE(RL_STATE_MOREINPUT);
382+ if (c < 0)
383+ return -1;
384+ _rl_vi_last_search_char = c;
385 #endif
386 }
387 }
388@@ -1467,6 +1494,9 @@
389 c = rl_read_key ();
390 RL_UNSETSTATE(RL_STATE_MOREINPUT);
391
392+ if (c < 0)
393+ return -1;
394+
395 #if defined (HANDLE_MULTIBYTE)
396 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
397 c = _rl_read_mbstring (c, mb, mlen);
398@@ -1485,6 +1515,9 @@
399
400 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
401
402+ if (c < 0)
403+ return -1;
404+
405 _rl_callback_func = 0;
406 _rl_want_redisplay = 1;
407
408@@ -1516,6 +1549,9 @@
409 else
410 _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
411
412+ if (c < 0)
413+ return -1;
414+
415 return (_rl_vi_change_char (count, c, mb));
416 }
417
418@@ -1650,7 +1686,7 @@
419 ch = rl_read_key ();
420 RL_UNSETSTATE(RL_STATE_MOREINPUT);
421
422- if (ch < 'a' || ch > 'z')
423+ if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
424 {
425 rl_ding ();
426 return -1;
427@@ -1702,7 +1738,7 @@
428 rl_point = rl_mark;
429 return 0;
430 }
431- else if (ch < 'a' || ch > 'z')
432+ else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
433 {
434 rl_ding ();
435 return -1;
Note: See TracBrowser for help on using the repository browser.