1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: ":12verbose call F()" may duplicate text while trying to truncate.
13 Solution: Only truncate when there is not enough room. Also check the byte
15 Files: src/buffer.c, src/eval.c, src/ex_getln.c, src/message.c,
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
25 /* make it shorter by removing a bit in the middle */
26 ! len = vim_strsize(buf);
28 ! trunc_string(buf, buf, maxlen);
35 /* make it shorter by removing a bit in the middle */
36 ! if (vim_strsize(buf) > maxlen)
37 ! trunc_string(buf, buf, maxlen, IOSIZE);
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
45 s = tv2string(&argvars[i], &tofree, numbuf2, 0);
48 ! trunc_string(s, buf, MSG_BUF_CLEN);
54 s = tv2string(&argvars[i], &tofree, numbuf2, 0);
57 ! if (vim_strsize(s) > MSG_BUF_CLEN)
59 ! trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
68 s = tv2string(fc->rettv, &tofree, numbuf2, 0);
71 ! trunc_string(s, buf, MSG_BUF_CLEN);
72 ! smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
77 s = tv2string(fc->rettv, &tofree, numbuf2, 0);
80 ! if (vim_strsize(s) > MSG_BUF_CLEN)
82 ! trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
85 ! smsg((char_u *)_("%s returning %s"), sourcing_name, s);
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
94 if (vim_strsize(hist[i].hisstr) > (int)Columns - 10)
95 trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
98 STRCAT(IObuff, hist[i].hisstr);
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));
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
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);
121 ! buf = alloc(room + 2);
123 ! trunc_string(s, buf, room);
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;
140 ! trunc_string(s, buf, room, len);
146 * "s" and "buf" may be equal.
149 ! trunc_string(s, buf, room)
157 * "s" and "buf" may be equal.
160 ! trunc_string(s, buf, room, buflen)
172 /* First part: Start of the string. */
173 ! for (e = 0; len < half; ++e)
180 /* First part: Start of the string. */
181 ! for (e = 0; len < half && e < buflen; ++e)
188 for (n = (*mb_ptr2len)(s + e); --n > 0; )
196 for (n = (*mb_ptr2len)(s + e); --n > 0; )
207 /* Set the middle and copy the last part. */
208 ! mch_memmove(buf + e, "...", (size_t)3);
209 ! STRMOVE(buf + e + 3, s + i);
216 /* Set the middle and copy the last part. */
217 ! if (e + 3 < buflen)
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;
228 ! buf[e - 1] = NUL; // make sure it is truncated
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
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));
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
257 { /* Add new patch number below this line */
263 Hanson's Treatment of Time:
264 There are never enough hours in a day, but always too
265 many days before Saturday.
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 ///