]> git.pld-linux.org Git - packages/vim.git/blame - 7.1.093
- updated to 0.7.5
[packages/vim.git] / 7.1.093
CommitLineData
0a7814d6
AG
1To: vim-dev@vim.org
2Subject: patch 7.1.093
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.1.093
11Problem: Reading past end of a screen line when determining cell width.
12 (Dominique Pelle)
13Solution: Add an argument to mb_off2cells() for the maximum offset.
14Files: src/globals.h, src/gui.c, src/mbyte.c, src/proto/mbyte.pro,
15 src/screen.c
16
17
18*** ../vim-7.1.092/src/globals.h Thu Aug 30 12:24:21 2007
19--- src/globals.h Wed Aug 29 22:27:45 2007
20***************
21*** 801,807 ****
22 EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
23 EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
24 EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
25! EXTERN int (*mb_off2cells) __ARGS((unsigned off)) INIT(= latin_off2cells);
26 EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
27 EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
28
29--- 801,807 ----
30 EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
31 EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
32 EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
33! EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
34 EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
35 EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
36
37*** ../vim-7.1.092/src/gui.c Wed Aug 15 20:07:53 2007
38--- src/gui.c Wed Aug 29 22:16:51 2007
39***************
40*** 1080,1086 ****
41 cur_width = gui.char_width;
42 }
43 #ifdef FEAT_MBYTE
44! if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col) > 1)
45 {
46 /* Double wide character. */
47 if (shape_table[idx].shape != SHAPE_VER)
48--- 1080,1087 ----
49 cur_width = gui.char_width;
50 }
51 #ifdef FEAT_MBYTE
52! if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
53! LineOffset[gui.row] + screen_Columns) > 1)
54 {
55 /* Double wide character. */
56 if (shape_table[idx].shape != SHAPE_VER)
57***************
58*** 1159,1165 ****
59 #endif
60
61 # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
62! || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
63 if (gui_has_tabline())
64 text_area_y += gui.tabline_height;
65 #endif
66--- 1160,1166 ----
67 #endif
68
69 # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
70! || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
71 if (gui_has_tabline())
72 text_area_y += gui.tabline_height;
73 #endif
74*** ../vim-7.1.092/src/mbyte.c Sat Aug 11 13:57:31 2007
75--- src/mbyte.c Thu Aug 30 13:48:30 2007
76***************
77*** 1310,1329 ****
78 /*
79 * mb_off2cells() function pointer.
80 * Return number of display cells for char at ScreenLines[off].
81! * Caller must make sure "off" and "off + 1" are valid!
82 */
83 /*ARGSUSED*/
84 int
85! latin_off2cells(off)
86 unsigned off;
87 {
88 return 1;
89 }
90
91 int
92! dbcs_off2cells(off)
93 unsigned off;
94 {
95 /* Number of cells is equal to number of bytes, except for euc-jp when
96 * the first byte is 0x8e. */
97 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
98--- 1310,1335 ----
99 /*
100 * mb_off2cells() function pointer.
101 * Return number of display cells for char at ScreenLines[off].
102! * We make sure that the offset used is less than "max_off".
103 */
104 /*ARGSUSED*/
105 int
106! latin_off2cells(off, max_off)
107 unsigned off;
108+ unsigned max_off;
109 {
110 return 1;
111 }
112
113 int
114! dbcs_off2cells(off, max_off)
115 unsigned off;
116+ unsigned max_off;
117 {
118+ /* never check beyond end of the line */
119+ if (off >= max_off)
120+ return 1;
121+
122 /* Number of cells is equal to number of bytes, except for euc-jp when
123 * the first byte is 0x8e. */
124 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
125***************
126*** 1332,1341 ****
127 }
128
129 int
130! utf_off2cells(off)
131 unsigned off;
132 {
133! return ScreenLines[off + 1] == 0 ? 2 : 1;
134 }
135
136 /*
137--- 1338,1348 ----
138 }
139
140 int
141! utf_off2cells(off, max_off)
142 unsigned off;
143+ unsigned max_off;
144 {
145! return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1;
146 }
147
148 /*
149***************
150*** 2899,2910 ****
151 if (composing_hangul)
152 return TRUE;
153 #endif
154! if (enc_dbcs != 0)
155! return dbcs_off2cells(LineOffset[row] + col) > 1;
156! if (enc_utf8)
157! return (col + 1 < Columns
158! && ScreenLines[LineOffset[row] + col + 1] == 0);
159! return FALSE;
160 }
161
162 # if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
163--- 2906,2913 ----
164 if (composing_hangul)
165 return TRUE;
166 #endif
167! return (*mb_off2cells)(LineOffset[row] + col,
168! LineOffset[row] + screen_Columns) > 1;
169 }
170
171 # if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
172*** ../vim-7.1.092/src/proto/mbyte.pro Sat May 5 20:02:52 2007
173--- src/proto/mbyte.pro Wed Aug 29 20:49:02 2007
174***************
175*** 12,20 ****
176 int utf_ptr2cells __ARGS((char_u *p));
177 int dbcs_ptr2cells __ARGS((char_u *p));
178 int latin_char2cells __ARGS((int c));
179! int latin_off2cells __ARGS((unsigned off));
180! int dbcs_off2cells __ARGS((unsigned off));
181! int utf_off2cells __ARGS((unsigned off));
182 int latin_ptr2char __ARGS((char_u *p));
183 int utf_ptr2char __ARGS((char_u *p));
184 int mb_ptr2char_adv __ARGS((char_u **pp));
185--- 12,20 ----
186 int utf_ptr2cells __ARGS((char_u *p));
187 int dbcs_ptr2cells __ARGS((char_u *p));
188 int latin_char2cells __ARGS((int c));
189! int latin_off2cells __ARGS((unsigned off, unsigned max_off));
190! int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
191! int utf_off2cells __ARGS((unsigned off, unsigned max_off));
192 int latin_ptr2char __ARGS((char_u *p));
193 int utf_ptr2char __ARGS((char_u *p));
194 int mb_ptr2char_adv __ARGS((char_u **pp));
195*** ../vim-7.1.092/src/screen.c Sun Aug 5 20:10:16 2007
196--- src/screen.c Thu Aug 30 10:31:26 2007
197***************
198*** 1024,1030 ****
199 type = VALID;
200 }
201
202! /* Trick: we want to avoid clearning the screen twice. screenclear() will
203 * set "screen_cleared" to TRUE. The special value MAYBE (which is still
204 * non-zero and thus not FALSE) will indicate that screenclear() was not
205 * called. */
206--- 1024,1030 ----
207 type = VALID;
208 }
209
210! /* Trick: we want to avoid clearing the screen twice. screenclear() will
211 * set "screen_cleared" to TRUE. The special value MAYBE (which is still
212 * non-zero and thus not FALSE) will indicate that screenclear() was not
213 * called. */
214***************
215*** 4632,4638 ****
216
217 /*
218 * At end of screen line and there is more to come: Display the line
219! * so far. If there is no more to display it is catched above.
220 */
221 if ((
222 #ifdef FEAT_RIGHTLEFT
223--- 4632,4638 ----
224
225 /*
226 * At end of screen line and there is more to come: Display the line
227! * so far. If there is no more to display it is caught above.
228 */
229 if ((
230 #ifdef FEAT_RIGHTLEFT
231***************
232*** 4709,4717 ****
233 #endif
234 #ifdef FEAT_MBYTE
235 && !(has_mbyte
236! && ((*mb_off2cells)(LineOffset[screen_row]) == 2
237 || (*mb_off2cells)(LineOffset[screen_row - 1]
238! + (int)Columns - 2) == 2))
239 #endif
240 )
241 {
242--- 4709,4721 ----
243 #endif
244 #ifdef FEAT_MBYTE
245 && !(has_mbyte
246! && ((*mb_off2cells)(LineOffset[screen_row],
247! LineOffset[screen_row] + screen_Columns)
248! == 2
249 || (*mb_off2cells)(LineOffset[screen_row - 1]
250! + (int)Columns - 2,
251! LineOffset[screen_row] + screen_Columns)
252! == 2))
253 #endif
254 )
255 {
256***************
257*** 4871,4876 ****
258--- 4875,4884 ----
259 {
260 unsigned off_from;
261 unsigned off_to;
262+ #ifdef FEAT_MBYTE
263+ unsigned max_off_from;
264+ unsigned max_off_to;
265+ #endif
266 int col = 0;
267 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
268 int hl;
269***************
270*** 4897,4902 ****
271--- 4905,4914 ----
272
273 off_from = (unsigned)(current_ScreenLine - ScreenLines);
274 off_to = LineOffset[row] + coloff;
275+ #ifdef FEAT_MBYTE
276+ max_off_from = off_from + screen_Columns;
277+ max_off_to = LineOffset[row] + screen_Columns;
278+ #endif
279
280 #ifdef FEAT_RIGHTLEFT
281 if (rlflag)
282***************
283*** 4931,4937 ****
284 {
285 #ifdef FEAT_MBYTE
286 if (has_mbyte && (col + 1 < endcol))
287! char_cells = (*mb_off2cells)(off_from);
288 else
289 char_cells = 1;
290 #endif
291--- 4943,4949 ----
292 {
293 #ifdef FEAT_MBYTE
294 if (has_mbyte && (col + 1 < endcol))
295! char_cells = (*mb_off2cells)(off_from, max_off_from);
296 else
297 char_cells = 1;
298 #endif
299***************
300*** 5008,5014 ****
301 * ScreenLinesUC[] is sufficient. */
302 if (char_cells == 1
303 && col + 1 < endcol
304! && (*mb_off2cells)(off_to) > 1)
305 {
306 /* Writing a single-cell character over a double-cell
307 * character: need to redraw the next cell. */
308--- 5020,5026 ----
309 * ScreenLinesUC[] is sufficient. */
310 if (char_cells == 1
311 && col + 1 < endcol
312! && (*mb_off2cells)(off_to, max_off_to) > 1)
313 {
314 /* Writing a single-cell character over a double-cell
315 * character: need to redraw the next cell. */
316***************
317*** 5017,5024 ****
318 }
319 else if (char_cells == 2
320 && col + 2 < endcol
321! && (*mb_off2cells)(off_to) == 1
322! && (*mb_off2cells)(off_to + 1) > 1)
323 {
324 /* Writing the second half of a double-cell character over
325 * a double-cell character: need to redraw the second
326--- 5029,5036 ----
327 }
328 else if (char_cells == 2
329 && col + 2 < endcol
330! && (*mb_off2cells)(off_to, max_off_to) == 1
331! && (*mb_off2cells)(off_to + 1, max_off_to) > 1)
332 {
333 /* Writing the second half of a double-cell character over
334 * a double-cell character: need to redraw the second
335***************
336*** 5037,5046 ****
337 * char over the left halve of an existing one. */
338 if (has_mbyte && col + char_cells == endcol
339 && ((char_cells == 1
340! && (*mb_off2cells)(off_to) > 1)
341 || (char_cells == 2
342! && (*mb_off2cells)(off_to) == 1
343! && (*mb_off2cells)(off_to + 1) > 1)))
344 clear_next = TRUE;
345 #endif
346
347--- 5049,5058 ----
348 * char over the left halve of an existing one. */
349 if (has_mbyte && col + char_cells == endcol
350 && ((char_cells == 1
351! && (*mb_off2cells)(off_to, max_off_to) > 1)
352 || (char_cells == 2
353! && (*mb_off2cells)(off_to, max_off_to) == 1
354! && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
355 clear_next = TRUE;
356 #endif
357
358***************
359*** 5180,5189 ****
360 /* find previous character by counting from first
361 * column and get its width. */
362 unsigned off = LineOffset[row];
363
364 while (off < off_to)
365 {
366! prev_cells = (*mb_off2cells)(off);
367 off += prev_cells;
368 }
369 }
370--- 5192,5202 ----
371 /* find previous character by counting from first
372 * column and get its width. */
373 unsigned off = LineOffset[row];
374+ unsigned max_off = LineOffset[row] + screen_Columns;
375
376 while (off < off_to)
377 {
378! prev_cells = (*mb_off2cells)(off, max_off);
379 off += prev_cells;
380 }
381 }
382***************
383*** 5369,5375 ****
384 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
385
386 /*
387! * Get the lenght of an item as it will be shown in the status line.
388 */
389 static int
390 status_match_len(xp, s)
391--- 5382,5388 ----
392 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
393
394 /*
395! * Get the length of an item as it will be shown in the status line.
396 */
397 static int
398 status_match_len(xp, s)
399***************
400*** 5435,5441 ****
401 int row;
402 char_u *buf;
403 int len;
404! int clen; /* lenght in screen cells */
405 int fillchar;
406 int attr;
407 int i;
408--- 5448,5454 ----
409 int row;
410 char_u *buf;
411 int len;
412! int clen; /* length in screen cells */
413 int fillchar;
414 int attr;
415 int i;
416***************
417*** 6187,6192 ****
418--- 6200,6206 ----
419 char_u *ptr = text;
420 int c;
421 #ifdef FEAT_MBYTE
422+ unsigned max_off;
423 int mbyte_blen = 1;
424 int mbyte_cells = 1;
425 int u8c = 0;
426***************
427*** 6203,6208 ****
428--- 6217,6225 ----
429 return;
430
431 off = LineOffset[row] + col;
432+ #ifdef FEAT_MBYTE
433+ max_off = LineOffset[row] + screen_Columns;
434+ #endif
435 while (col < screen_Columns
436 && (len < 0 || (int)(ptr - text) < len)
437 && *ptr != NUL)
438***************
439*** 6326,6344 ****
440 else if (has_mbyte
441 && (len < 0 ? ptr[mbyte_blen] == NUL
442 : ptr + mbyte_blen >= text + len)
443! && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
444 || (mbyte_cells == 2
445! && (*mb_off2cells)(off) == 1
446! && (*mb_off2cells)(off + 1) > 1)))
447 clear_next_cell = TRUE;
448
449 /* Make sure we never leave a second byte of a double-byte behind,
450 * it confuses mb_off2cells(). */
451 if (enc_dbcs
452! && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
453 || (mbyte_cells == 2
454! && (*mb_off2cells)(off) == 1
455! && (*mb_off2cells)(off + 1) > 1)))
456 ScreenLines[off + mbyte_blen] = 0;
457 #endif
458 ScreenLines[off] = c;
459--- 6343,6361 ----
460 else if (has_mbyte
461 && (len < 0 ? ptr[mbyte_blen] == NUL
462 : ptr + mbyte_blen >= text + len)
463! && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
464 || (mbyte_cells == 2
465! && (*mb_off2cells)(off, max_off) == 1
466! && (*mb_off2cells)(off + 1, max_off) > 1)))
467 clear_next_cell = TRUE;
468
469 /* Make sure we never leave a second byte of a double-byte behind,
470 * it confuses mb_off2cells(). */
471 if (enc_dbcs
472! && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
473 || (mbyte_cells == 2
474! && (*mb_off2cells)(off, max_off) == 1
475! && (*mb_off2cells)(off + 1, max_off) > 1)))
476 ScreenLines[off + mbyte_blen] = 0;
477 #endif
478 ScreenLines[off] = c;
479***************
480*** 6924,6929 ****
481--- 6941,6949 ----
482 {
483 int r, c;
484 int off;
485+ #ifdef FEAT_MBYTE
486+ int max_off;
487+ #endif
488
489 /* Can't use ScreenLines unless initialized */
490 if (ScreenLines == NULL)
491***************
492*** 6934,6943 ****
493 for (r = row; r < row + height; ++r)
494 {
495 off = LineOffset[r];
496 for (c = col; c < col + width; ++c)
497 {
498 #ifdef FEAT_MBYTE
499! if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
500 {
501 screen_char_2(off + c, r, c);
502 ++c;
503--- 6954,6966 ----
504 for (r = row; r < row + height; ++r)
505 {
506 off = LineOffset[r];
507+ #ifdef FEAT_MBYTE
508+ max_off = off + screen_Columns;
509+ #endif
510 for (c = col; c < col + width; ++c)
511 {
512 #ifdef FEAT_MBYTE
513! if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
514 {
515 screen_char_2(off + c, r, c);
516 ++c;
517***************
518*** 6947,6953 ****
519 {
520 screen_char(off + c, r, c);
521 #ifdef FEAT_MBYTE
522! if (utf_off2cells(off + c) > 1)
523 ++c;
524 #endif
525 }
526--- 6970,6976 ----
527 {
528 screen_char(off + c, r, c);
529 #ifdef FEAT_MBYTE
530! if (utf_off2cells(off + c, max_off) > 1)
531 ++c;
532 #endif
533 }
534*** ../vim-7.1.092/src/version.c Thu Aug 30 12:50:00 2007
535--- src/version.c Thu Aug 30 13:45:25 2007
536***************
537*** 668,669 ****
538--- 668,671 ----
539 { /* Add new patch number below this line */
540+ /**/
541+ 93,
542 /**/
543
544--
545There is a fine line between courage and foolishness.
546Unfortunately, it's not a fence.
547
548 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
549/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
550\\\ download, build and distribute -- http://www.A-A-P.org ///
551 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 0.075688 seconds and 4 git commands to generate.