summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.407
blob: d5ac1330c4322730caabafaeee0360184a24559e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
To: vim_dev@googlegroups.com
Subject: Patch 7.3.407
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.407
Problem:    ":12verbose call F()" may duplicate text while trying to truncate.
	    (Thinca)
Solution:   Only truncate when there is not enough room.  Also check the byte
	    length of the buffer.
Files:	    src/buffer.c, src/eval.c, src/ex_getln.c, src/message.c,
	    src/proto/message.pro


*** ../vim-7.3.406/src/buffer.c	2011-12-30 13:39:04.000000000 +0100
--- src/buffer.c	2012-01-20 18:37:43.000000000 +0100
***************
*** 3258,3266 ****
  	    if (maxlen > 0)
  	    {
  		/* make it shorter by removing a bit in the middle */
! 		len = vim_strsize(buf);
! 		if (len > maxlen)
! 		    trunc_string(buf, buf, maxlen);
  	    }
  	}
      }
--- 3258,3265 ----
  	    if (maxlen > 0)
  	    {
  		/* make it shorter by removing a bit in the middle */
! 		if (vim_strsize(buf) > maxlen)
! 		    trunc_string(buf, buf, maxlen, IOSIZE);
  	    }
  	}
      }
*** ../vim-7.3.406/src/eval.c	2012-01-10 22:26:12.000000000 +0100
--- src/eval.c	2012-01-20 20:43:32.000000000 +0100
***************
*** 22163,22170 ****
  			s = tv2string(&argvars[i], &tofree, numbuf2, 0);
  			if (s != NULL)
  			{
! 			    trunc_string(s, buf, MSG_BUF_CLEN);
! 			    msg_puts(buf);
  			    vim_free(tofree);
  			}
  		    }
--- 22163,22174 ----
  			s = tv2string(&argvars[i], &tofree, numbuf2, 0);
  			if (s != NULL)
  			{
! 			    if (vim_strsize(s) > MSG_BUF_CLEN)
! 			    {
! 				trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
! 				s = buf;
! 			    }
! 			    msg_puts(s);
  			    vim_free(tofree);
  			}
  		    }
***************
*** 22252,22259 ****
  	    s = tv2string(fc->rettv, &tofree, numbuf2, 0);
  	    if (s != NULL)
  	    {
! 		trunc_string(s, buf, MSG_BUF_CLEN);
! 		smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
  		vim_free(tofree);
  	    }
  	}
--- 22256,22267 ----
  	    s = tv2string(fc->rettv, &tofree, numbuf2, 0);
  	    if (s != NULL)
  	    {
! 		if (vim_strsize(s) > MSG_BUF_CLEN)
! 		{
! 		    trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
! 		    s = buf;
! 		}
! 		smsg((char_u *)_("%s returning %s"), sourcing_name, s);
  		vim_free(tofree);
  	    }
  	}
*** ../vim-7.3.406/src/ex_getln.c	2011-12-08 18:44:47.000000000 +0100
--- src/ex_getln.c	2012-01-20 18:40:46.000000000 +0100
***************
*** 5923,5929 ****
  							      hist[i].hisnum);
  		    if (vim_strsize(hist[i].hisstr) > (int)Columns - 10)
  			trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
! 							   (int)Columns - 10);
  		    else
  			STRCAT(IObuff, hist[i].hisstr);
  		    msg_outtrans(IObuff);
--- 5923,5929 ----
  							      hist[i].hisnum);
  		    if (vim_strsize(hist[i].hisstr) > (int)Columns - 10)
  			trunc_string(hist[i].hisstr, IObuff + STRLEN(IObuff),
! 				  (int)Columns - 10, IOSIZE - STRLEN(IObuff));
  		    else
  			STRCAT(IObuff, hist[i].hisstr);
  		    msg_outtrans(IObuff);
*** ../vim-7.3.406/src/message.c	2012-01-10 22:26:12.000000000 +0100
--- src/message.c	2012-01-20 20:38:29.000000000 +0100
***************
*** 222,236 ****
  	    if (enc_utf8)
  		/* may have up to 18 bytes per cell (6 per char, up to two
  		 * composing chars) */
! 		buf = alloc((room + 2) * 18);
  	    else if (enc_dbcs == DBCS_JPNU)
  		/* may have up to 2 bytes per cell for euc-jp */
! 		buf = alloc((room + 2) * 2);
  	    else
  #endif
! 		buf = alloc(room + 2);
  	    if (buf != NULL)
! 		trunc_string(s, buf, room);
  	}
      }
      return buf;
--- 222,237 ----
  	    if (enc_utf8)
  		/* may have up to 18 bytes per cell (6 per char, up to two
  		 * composing chars) */
! 		len = (room + 2) * 18;
  	    else if (enc_dbcs == DBCS_JPNU)
  		/* may have up to 2 bytes per cell for euc-jp */
! 		len = (room + 2) * 2;
  	    else
  #endif
! 		len = room + 2;
! 	    buf = alloc(len);
  	    if (buf != NULL)
! 		trunc_string(s, buf, room, len);
  	}
      }
      return buf;
***************
*** 241,250 ****
   * "s" and "buf" may be equal.
   */
      void
! trunc_string(s, buf, room)
      char_u	*s;
      char_u	*buf;
      int		room;
  {
      int		half;
      int		len;
--- 242,252 ----
   * "s" and "buf" may be equal.
   */
      void
! trunc_string(s, buf, room, buflen)
      char_u	*s;
      char_u	*buf;
      int		room;
+     int		buflen;
  {
      int		half;
      int		len;
***************
*** 257,263 ****
      len = 0;
  
      /* First part: Start of the string. */
!     for (e = 0; len < half; ++e)
      {
  	if (s[e] == NUL)
  	{
--- 259,265 ----
      len = 0;
  
      /* First part: Start of the string. */
!     for (e = 0; len < half && e < buflen; ++e)
      {
  	if (s[e] == NUL)
  	{
***************
*** 274,280 ****
  	if (has_mbyte)
  	    for (n = (*mb_ptr2len)(s + e); --n > 0; )
  	    {
! 		++e;
  		buf[e] = s[e];
  	    }
  #endif
--- 276,283 ----
  	if (has_mbyte)
  	    for (n = (*mb_ptr2len)(s + e); --n > 0; )
  	    {
! 		if (++e == buflen)
! 		    break;
  		buf[e] = s[e];
  	    }
  #endif
***************
*** 319,326 ****
      }
  
      /* Set the middle and copy the last part. */
!     mch_memmove(buf + e, "...", (size_t)3);
!     STRMOVE(buf + e + 3, s + i);
  }
  
  /*
--- 322,340 ----
      }
  
      /* Set the middle and copy the last part. */
!     if (e + 3 < buflen)
!     {
! 	mch_memmove(buf + e, "...", (size_t)3);
! 	len = STRLEN(s + i) + 1;
! 	if (len >= buflen - e - 3)
! 	    len = buflen - e - 3 - 1;
! 	mch_memmove(buf + e + 3, s + i, len);
! 	buf[e + 3 + len - 1] = NUL;
!     }
!     else
!     {
! 	buf[e - 1] = NUL;  // make sure it is truncated
!     }
  }
  
  /*
*** ../vim-7.3.406/src/proto/message.pro	2011-01-17 20:08:03.000000000 +0100
--- src/proto/message.pro	2012-01-20 18:51:19.000000000 +0100
***************
*** 4,10 ****
  int msg_attr __ARGS((char_u *s, int attr));
  int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
  char_u *msg_strtrunc __ARGS((char_u *s, int force));
! void trunc_string __ARGS((char_u *s, char_u *buf, int room));
  void reset_last_sourcing __ARGS((void));
  void msg_source __ARGS((int attr));
  int emsg_not_now __ARGS((void));
--- 4,10 ----
  int msg_attr __ARGS((char_u *s, int attr));
  int msg_attr_keep __ARGS((char_u *s, int attr, int keep));
  char_u *msg_strtrunc __ARGS((char_u *s, int force));
! void trunc_string __ARGS((char_u *s, char_u *buf, int room, int buflen));
  void reset_last_sourcing __ARGS((void));
  void msg_source __ARGS((int attr));
  int emsg_not_now __ARGS((void));
*** ../vim-7.3.406/src/version.c	2012-01-20 17:57:47.000000000 +0100
--- src/version.c	2012-01-20 20:42:23.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     407,
  /**/

-- 
Hanson's Treatment of Time:
	There are never enough hours in a day, but always too
	many days before Saturday.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///