Magellan Linux

Contents of /trunk/readline/patches/readline-5.0-fixes-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 7032 byte(s)
-import

1 Submitted By: Jim Gifford (patches at jg555 dot com)
2 Date: 2004-09-29
3 Initial Package Version: 5.0
4 Origin: Various
5 Upstream Status: Already Applied
6 Description: This patch contains various fixes recommended
7 by the author Chet. The original patches are
8 avaiable at ftp://ftp.cwru.edu/pub/bash/readline-5.0-patches
9 This patch contains 001-005
10
11 diff -Naur readline-5.0.orig/display.c readline-5.0/display.c
12 --- readline-5.0.orig/display.c 2004-05-28 02:57:51.000000000 +0000
13 +++ readline-5.0/display.c 2004-09-29 16:50:55.112047008 +0000
14 @@ -201,7 +201,7 @@
15 int *lp, *lip, *niflp, *vlp;
16 {
17 char *r, *ret, *p;
18 - int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars;
19 + int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
20
21 /* Short-circuit if we can. */
22 if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
23 @@ -222,6 +222,7 @@
24 r = ret = (char *)xmalloc (l + 1);
25
26 invfl = 0; /* invisible chars in first line of prompt */
27 + invflset = 0; /* we only want to set invfl once */
28
29 for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
30 {
31 @@ -249,7 +250,10 @@
32 while (l--)
33 *r++ = *p++;
34 if (!ignoring)
35 - rl += ind - pind;
36 + {
37 + rl += ind - pind;
38 + physchars += _rl_col_width (pmt, pind, ind);
39 + }
40 else
41 ninvis += ind - pind;
42 p--; /* compensate for later increment */
43 @@ -259,16 +263,19 @@
44 {
45 *r++ = *p;
46 if (!ignoring)
47 - rl++; /* visible length byte counter */
48 + {
49 + rl++; /* visible length byte counter */
50 + physchars++;
51 + }
52 else
53 ninvis++; /* invisible chars byte counter */
54 }
55
56 - if (rl >= _rl_screenwidth)
57 - invfl = ninvis;
58 -
59 - if (ignoring == 0)
60 - physchars++;
61 + if (invflset == 0 && rl >= _rl_screenwidth)
62 + {
63 + invfl = ninvis;
64 + invflset = 1;
65 + }
66 }
67 }
68
69 @@ -351,14 +358,14 @@
70 local_prompt = expand_prompt (p, &prompt_visible_length,
71 &prompt_last_invisible,
72 (int *)NULL,
73 - (int *)NULL);
74 + &prompt_physical_chars);
75 c = *t; *t = '\0';
76 /* The portion of the prompt string up to and including the
77 final newline is now null-terminated. */
78 local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
79 (int *)NULL,
80 &prompt_invis_chars_first_line,
81 - &prompt_physical_chars);
82 + (int *)NULL);
83 *t = c;
84 return (prompt_prefix_length);
85 }
86 @@ -417,7 +424,7 @@
87 register int in, out, c, linenum, cursor_linenum;
88 register char *line;
89 int c_pos, inv_botlin, lb_botlin, lb_linenum;
90 - int newlines, lpos, temp, modmark;
91 + int newlines, lpos, temp, modmark, n0, num;
92 char *prompt_this_line;
93 #if defined (HANDLE_MULTIBYTE)
94 wchar_t wc;
95 @@ -573,6 +580,7 @@
96
97 #if defined (HANDLE_MULTIBYTE)
98 memset (_rl_wrapped_line, 0, vis_lbsize);
99 + num = 0;
100 #endif
101
102 /* prompt_invis_chars_first_line is the number of invisible characters in
103 @@ -591,13 +599,32 @@
104 probably too much work for the benefit gained. How many people have
105 prompts that exceed two physical lines?
106 Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
107 +#if defined (HANDLE_MULTIBYTE)
108 + n0 = num;
109 + temp = local_prompt ? strlen (local_prompt) : 0;
110 + while (num < temp)
111 + {
112 + if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
113 + {
114 + num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
115 + break;
116 + }
117 + num++;
118 + }
119 + temp = num +
120 +#else
121 temp = ((newlines + 1) * _rl_screenwidth) +
122 +#endif /* !HANDLE_MULTIBYTE */
123 ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
124 : ((newlines == 1) ? wrap_offset : 0))
125 : ((newlines == 0) ? wrap_offset :0));
126
127 inv_lbreaks[++newlines] = temp;
128 +#if defined (HANDLE_MULTIBYTE)
129 + lpos -= _rl_col_width (local_prompt, n0, num);
130 +#else
131 lpos -= _rl_screenwidth;
132 +#endif
133 }
134
135 prompt_last_screen_line = newlines;
136 diff -Naur readline-5.0.orig/mbutil.c readline-5.0/mbutil.c
137 --- readline-5.0.orig/mbutil.c 2004-01-14 14:44:52.000000000 +0000
138 +++ readline-5.0/mbutil.c 2004-09-29 16:50:58.864476552 +0000
139 @@ -126,11 +126,11 @@
140 if (find_non_zero)
141 {
142 tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
143 - while (wcwidth (wc) == 0)
144 + while (tmp > 0 && wcwidth (wc) == 0)
145 {
146 point += tmp;
147 tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
148 - if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
149 + if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
150 break;
151 }
152 }
153 diff -Naur readline-5.0.orig/misc.c readline-5.0/misc.c
154 --- readline-5.0.orig/misc.c 2004-07-07 12:56:32.000000000 +0000
155 +++ readline-5.0/misc.c 2004-09-29 16:50:53.976219680 +0000
156 @@ -276,12 +276,6 @@
157 _rl_saved_line_for_history->line = savestring (rl_line_buffer);
158 _rl_saved_line_for_history->data = (char *)rl_undo_list;
159 }
160 - else if (STREQ (rl_line_buffer, _rl_saved_line_for_history->line) == 0)
161 - {
162 - free (_rl_saved_line_for_history->line);
163 - _rl_saved_line_for_history->line = savestring (rl_line_buffer);
164 - _rl_saved_line_for_history->data = (char *)rl_undo_list; /* XXX possible memleak */
165 - }
166
167 return 0;
168 }
169 diff -Naur readline-5.0.orig/vi_mode.c readline-5.0/vi_mode.c
170 --- readline-5.0.orig/vi_mode.c 2004-07-13 18:08:27.000000000 +0000
171 +++ readline-5.0/vi_mode.c 2004-09-29 16:50:56.286868408 +0000
172 @@ -272,10 +272,12 @@
173 switch (key)
174 {
175 case '?':
176 + _rl_free_saved_history_line ();
177 rl_noninc_forward_search (count, key);
178 break;
179
180 case '/':
181 + _rl_free_saved_history_line ();
182 rl_noninc_reverse_search (count, key);
183 break;
184
185 @@ -690,7 +692,7 @@
186 {
187 wchar_t wc;
188 char mb[MB_LEN_MAX+1];
189 - int mblen;
190 + int mblen, p;
191 mbstate_t ps;
192
193 memset (&ps, 0, sizeof (mbstate_t));
194 @@ -713,11 +715,14 @@
195 /* Vi is kind of strange here. */
196 if (wc)
197 {
198 + p = rl_point;
199 mblen = wcrtomb (mb, wc, &ps);
200 if (mblen >= 0)
201 mb[mblen] = '\0';
202 rl_begin_undo_group ();
203 - rl_delete (1, 0);
204 + rl_vi_delete (1, 0);
205 + if (rl_point < p) /* Did we retreat at EOL? */
206 + rl_point++; /* XXX - should we advance more than 1 for mbchar? */
207 rl_insert_text (mb);
208 rl_end_undo_group ();
209 rl_vi_check ();
210 @@ -1310,12 +1315,16 @@
211 rl_vi_delete (1, c);
212 #if defined (HANDLE_MULTIBYTE)
213 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
214 - while (_rl_insert_char (1, c))
215 - {
216 - RL_SETSTATE (RL_STATE_MOREINPUT);
217 - c = rl_read_key ();
218 - RL_UNSETSTATE (RL_STATE_MOREINPUT);
219 - }
220 + {
221 + if (rl_point < p) /* Did we retreat at EOL? */
222 + rl_point++;
223 + while (_rl_insert_char (1, c))
224 + {
225 + RL_SETSTATE (RL_STATE_MOREINPUT);
226 + c = rl_read_key ();
227 + RL_UNSETSTATE (RL_STATE_MOREINPUT);
228 + }
229 + }
230 else
231 #endif
232 {