4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When the cursor is on a line past 21,474,748 the indicated
12 percentage of the position is invalid. With that many lines
13 "100%" causes a negative cursor line number, resulting in a crash.
15 Solution: Divide by 100 instead of multiplying. Avoid overflow when
16 computing the line number for "100%".
17 Files: src/buffer.c, src/ex_cmds2.c, src/normal.c
20 *** ../vim-6.2.148/src/buffer.c Sat Sep 27 19:36:46 2003
21 --- src/buffer.c Sat Nov 8 13:21:58 2003
24 (curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
27 ! n = (int)(((long)curwin->w_cursor.lnum * 100L) /
28 (long)curbuf->b_ml.ml_line_count);
29 if (curbuf->b_ml.ml_flags & ML_EMPTY)
32 (curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
35 ! /* With 32 bit longs and more than 21,474,836 lines multiplying by 100
36 ! * causes an overflow, thus for large numbers divide instead. */
37 ! if (curwin->w_cursor.lnum > 1000000L)
38 ! n = (int)(((long)curwin->w_cursor.lnum) /
39 ! ((long)curbuf->b_ml.ml_line_count / 100L));
41 ! n = (int)(((long)curwin->w_cursor.lnum * 100L) /
42 (long)curbuf->b_ml.ml_line_count);
43 if (curbuf->b_ml.ml_flags & ML_EMPTY)
48 STRCPY(str, _("Top"));
50 ! sprintf((char *)str, "%2d%%",
51 ! (int)(above * 100 / (above + below)));
57 STRCPY(str, _("Top"));
59 ! sprintf((char *)str, "%2d%%", above > 1000000L
60 ! ? (int)(above / ((above + below) / 100L))
61 ! : (int)(above * 100L / (above + below)));
65 *** ../vim-6.2.148/src/ex_cmds2.c Sun Oct 12 20:20:38 2003
66 --- src/ex_cmds2.c Sun Nov 9 16:44:15 2003
70 sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
71 page_count + 1 + side,
72 ! (int)((prtpos.bytes_printed * 100)
74 if (!mch_print_begin_page(IObuff))
78 sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
79 page_count + 1 + side,
80 ! prtpos.bytes_printed > 1000000
81 ! ? (int)(prtpos.bytes_printed /
82 ! (bytes_to_print / 100))
83 ! : (int)((prtpos.bytes_printed * 100)
85 if (!mch_print_begin_page(IObuff))
87 *** ../vim-6.2.148/src/normal.c Sun Nov 2 15:49:56 2003
88 --- src/normal.c Sun Nov 9 13:35:44 2003
92 cap->oap->motion_type = MLINE;
94 ! /* round up, so CTRL-G will give same value */
95 ! curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count *
96 cap->count0 + 99L) / 100L;
97 beginline(BL_SOL | BL_FIX);
102 cap->oap->motion_type = MLINE;
104 ! /* Round up, so CTRL-G will give same value. Watch out for a
105 ! * large line count, the line number must not go negative! */
106 ! if (curbuf->b_ml.ml_line_count > 1000000)
107 ! curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L)
108 ! / 100L * cap->count0;
110 ! curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count *
111 cap->count0 + 99L) / 100L;
112 + if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
113 + curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
114 beginline(BL_SOL | BL_FIX);
117 *** ../vim-6.2.148/src/version.c Sun Nov 9 20:26:53 2003
118 --- src/version.c Sun Nov 9 20:29:14 2003
122 { /* Add new patch number below this line */
128 The acknowledged parents of reengineering are Michael Hammer and James Champy.
129 When I say they're the "parents" I don't mean they had sex - and I apologize
130 for making you think about it. I mean they wrote the best-selling business
131 book _Reengineering the Corporation_, which was published in 1993.
132 Businesses flocked to reengineering like frat boys to a drunken
133 cheerleader. (This analogy wasn't necessary, but I'm trying to get my mind
134 off that Hammer and Champy thing.)
135 (Scott Adams - The Dilbert principle)
137 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
138 /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
139 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
140 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///