]> git.ipfire.org Git - ipfire-3.x.git/blob - vim/patches/vim-7.3.407.patch0
Merge remote-tracking branch 'ms/openvswitch'
[ipfire-3.x.git] / vim / patches / vim-7.3.407.patch0
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.407
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.407
11 Problem: ":12verbose call F()" may duplicate text while trying to truncate.
12 (Thinca)
13 Solution: Only truncate when there is not enough room. Also check the byte
14 length of the buffer.
15 Files: src/buffer.c, src/eval.c, src/ex_getln.c, src/message.c,
16 src/proto/message.pro
17
18
19 *** ../vim-7.3.406/src/buffer.c 2011-12-30 13:39:04.000000000 +0100
20 --- src/buffer.c 2012-01-20 18:37:43.000000000 +0100
21 ***************
22 *** 3258,3266 ****
23 if (maxlen > 0)
24 {
25 /* make it shorter by removing a bit in the middle */
26 ! len = vim_strsize(buf);
27 ! if (len > maxlen)
28 ! trunc_string(buf, buf, maxlen);
29 }
30 }
31 }
32 --- 3258,3265 ----
33 if (maxlen > 0)
34 {
35 /* make it shorter by removing a bit in the middle */
36 ! if (vim_strsize(buf) > maxlen)
37 ! trunc_string(buf, buf, maxlen, IOSIZE);
38 }
39 }
40 }
41 *** ../vim-7.3.406/src/eval.c 2012-01-10 22:26:12.000000000 +0100
42 --- src/eval.c 2012-01-20 20:43:32.000000000 +0100
43 ***************
44 *** 22163,22170 ****
45 s = tv2string(&argvars[i], &tofree, numbuf2, 0);
46 if (s != NULL)
47 {
48 ! trunc_string(s, buf, MSG_BUF_CLEN);
49 ! msg_puts(buf);
50 vim_free(tofree);
51 }
52 }
53 --- 22163,22174 ----
54 s = tv2string(&argvars[i], &tofree, numbuf2, 0);
55 if (s != NULL)
56 {
57 ! if (vim_strsize(s) > MSG_BUF_CLEN)
58 ! {
59 ! trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
60 ! s = buf;
61 ! }
62 ! msg_puts(s);
63 vim_free(tofree);
64 }
65 }
66 ***************
67 *** 22252,22259 ****
68 s = tv2string(fc->rettv, &tofree, numbuf2, 0);
69 if (s != NULL)
70 {
71 ! trunc_string(s, buf, MSG_BUF_CLEN);
72 ! smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
73 vim_free(tofree);
74 }
75 }
76 --- 22256,22267 ----
77 s = tv2string(fc->rettv, &tofree, numbuf2, 0);
78 if (s != NULL)
79 {
80 ! if (vim_strsize(s) > MSG_BUF_CLEN)
81 ! {
82 ! trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
83 ! s = buf;
84 ! }
85 ! smsg((char_u *)_("%s returning %s"), sourcing_name, s);
86 vim_free(tofree);
87 }
88 }
89 *** ../vim-7.3.406/src/ex_getln.c 2011-12-08 18:44:47.000000000 +0100
90 --- src/ex_getln.c 2012-01-20 18:40:46.000000000 +0100
91 ***************
92 *** 5923,5929 ****
93 hist[i].hisnum);
94 if (vim_strsize(hist[i].hisstr) > (int)Columns - 10)
95 trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
96 ! (int)Columns - 10);
97 else
98 STRCAT(IObuff, hist[i].hisstr);
99 msg_outtrans(IObuff);
100 --- 5923,5929 ----
101 hist[i].hisnum);
102 if (vim_strsize(hist[i].hisstr) > (int)Columns - 10)
103 trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
104 ! (int)Columns - 10, IOSIZE - STRLEN(IObuff));
105 else
106 STRCAT(IObuff, hist[i].hisstr);
107 msg_outtrans(IObuff);
108 *** ../vim-7.3.406/src/message.c 2012-01-10 22:26:12.000000000 +0100
109 --- src/message.c 2012-01-20 20:38:29.000000000 +0100
110 ***************
111 *** 222,236 ****
112 if (enc_utf8)
113 /* may have up to 18 bytes per cell (6 per char, up to two
114 * composing chars) */
115 ! buf = alloc((room + 2) * 18);
116 else if (enc_dbcs == DBCS_JPNU)
117 /* may have up to 2 bytes per cell for euc-jp */
118 ! buf = alloc((room + 2) * 2);
119 else
120 #endif
121 ! buf = alloc(room + 2);
122 if (buf != NULL)
123 ! trunc_string(s, buf, room);
124 }
125 }
126 return buf;
127 --- 222,237 ----
128 if (enc_utf8)
129 /* may have up to 18 bytes per cell (6 per char, up to two
130 * composing chars) */
131 ! len = (room + 2) * 18;
132 else if (enc_dbcs == DBCS_JPNU)
133 /* may have up to 2 bytes per cell for euc-jp */
134 ! len = (room + 2) * 2;
135 else
136 #endif
137 ! len = room + 2;
138 ! buf = alloc(len);
139 if (buf != NULL)
140 ! trunc_string(s, buf, room, len);
141 }
142 }
143 return buf;
144 ***************
145 *** 241,250 ****
146 * "s" and "buf" may be equal.
147 */
148 void
149 ! trunc_string(s, buf, room)
150 char_u *s;
151 char_u *buf;
152 int room;
153 {
154 int half;
155 int len;
156 --- 242,252 ----
157 * "s" and "buf" may be equal.
158 */
159 void
160 ! trunc_string(s, buf, room, buflen)
161 char_u *s;
162 char_u *buf;
163 int room;
164 + int buflen;
165 {
166 int half;
167 int len;
168 ***************
169 *** 257,263 ****
170 len = 0;
171
172 /* First part: Start of the string. */
173 ! for (e = 0; len < half; ++e)
174 {
175 if (s[e] == NUL)
176 {
177 --- 259,265 ----
178 len = 0;
179
180 /* First part: Start of the string. */
181 ! for (e = 0; len < half && e < buflen; ++e)
182 {
183 if (s[e] == NUL)
184 {
185 ***************
186 *** 274,280 ****
187 if (has_mbyte)
188 for (n = (*mb_ptr2len)(s + e); --n > 0; )
189 {
190 ! ++e;
191 buf[e] = s[e];
192 }
193 #endif
194 --- 276,283 ----
195 if (has_mbyte)
196 for (n = (*mb_ptr2len)(s + e); --n > 0; )
197 {
198 ! if (++e == buflen)
199 ! break;
200 buf[e] = s[e];
201 }
202 #endif
203 ***************
204 *** 319,326 ****
205 }
206
207 /* Set the middle and copy the last part. */
208 ! mch_memmove(buf + e, "...", (size_t)3);
209 ! STRMOVE(buf + e + 3, s + i);
210 }
211
212 /*
213 --- 322,340 ----
214 }
215
216 /* Set the middle and copy the last part. */
217 ! if (e + 3 < buflen)
218 ! {
219 ! mch_memmove(buf + e, "...", (size_t)3);
220 ! len = STRLEN(s + i) + 1;
221 ! if (len >= buflen - e - 3)
222 ! len = buflen - e - 3 - 1;
223 ! mch_memmove(buf + e + 3, s + i, len);
224 ! buf[e + 3 + len - 1] = NUL;
225 ! }
226 ! else
227 ! {
228 ! buf[e - 1] = NUL; // make sure it is truncated
229 ! }
230 }
231
232 /*
233 *** ../vim-7.3.406/src/proto/message.pro 2011-01-17 20:08:03.000000000 +0100
234 --- src/proto/message.pro 2012-01-20 18:51:19.000000000 +0100
235 ***************
236 *** 4,10 ****
237 int msg_attr __ARGS((char_u *s, int attr));
238 int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
239 char_u *msg_strtrunc __ARGS((char_u *s, int force));
240 ! void trunc_string __ARGS((char_u *s, char_u *buf, int room));
241 void reset_last_sourcing __ARGS((void));
242 void msg_source __ARGS((int attr));
243 int emsg_not_now __ARGS((void));
244 --- 4,10 ----
245 int msg_attr __ARGS((char_u *s, int attr));
246 int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
247 char_u *msg_strtrunc __ARGS((char_u *s, int force));
248 ! void trunc_string __ARGS((char_u *s, char_u *buf, int room, int buflen));
249 void reset_last_sourcing __ARGS((void));
250 void msg_source __ARGS((int attr));
251 int emsg_not_now __ARGS((void));
252 *** ../vim-7.3.406/src/version.c 2012-01-20 17:57:47.000000000 +0100
253 --- src/version.c 2012-01-20 20:42:23.000000000 +0100
254 ***************
255 *** 716,717 ****
256 --- 716,719 ----
257 { /* Add new patch number below this line */
258 + /**/
259 + 407,
260 /**/
261
262 --
263 Hanson's Treatment of Time:
264 There are never enough hours in a day, but always too
265 many days before Saturday.
266
267 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
268 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
269 \\\ an exciting new programming language -- http://www.Zimbu.org ///
270 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///