home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.2.149 < prev    next >
Encoding:
Internet Message Format  |  2003-11-08  |  4.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.149
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.149
  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.
  14.         (Daniel Goujot)
  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
  18.  
  19.  
  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
  22. ***************
  23. *** 2719,2725 ****
  24.           (curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
  25.                                 || curbuf->b_p_ro) ?
  26.                                       " " : "");
  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)
  30.       {
  31. --- 2719,2731 ----
  32.           (curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
  33.                                 || curbuf->b_p_ro) ?
  34.                                       " " : "");
  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));
  40. !     else
  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)
  44.       {
  45. ***************
  46. *** 3755,3762 ****
  47.       else if (above <= 0)
  48.       STRCPY(str, _("Top"));
  49.       else
  50. !     sprintf((char *)str, "%2d%%",
  51. !         (int)(above * 100 / (above + below)));
  52.   }
  53.   #endif
  54.   
  55. --- 3761,3769 ----
  56.       else if (above <= 0)
  57.       STRCPY(str, _("Top"));
  58.       else
  59. !     sprintf((char *)str, "%2d%%", above > 1000000L
  60. !                     ? (int)(above / ((above + below) / 100L))
  61. !                     : (int)(above * 100L / (above + below)));
  62.   }
  63.   #endif
  64.   
  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
  67. ***************
  68. *** 3401,3407 ****
  69.   
  70.               sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
  71.                   page_count + 1 + side,
  72. !                 (int)((prtpos.bytes_printed * 100)
  73.                                  / bytes_to_print));
  74.               if (!mch_print_begin_page(IObuff))
  75.               goto print_fail;
  76. --- 3401,3410 ----
  77.   
  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)
  84.                                  / bytes_to_print));
  85.               if (!mch_print_begin_page(IObuff))
  86.               goto print_fail;
  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
  89. ***************
  90. *** 5814,5822 ****
  91.       {
  92.           cap->oap->motion_type = MLINE;
  93.           setpcmark();
  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);
  98.       }
  99.       }
  100. --- 5814,5829 ----
  101.       {
  102.           cap->oap->motion_type = MLINE;
  103.           setpcmark();
  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;
  109. !         else
  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);
  115.       }
  116.       }
  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
  119. ***************
  120. *** 639,640 ****
  121. --- 639,642 ----
  122.   {   /* Add new patch number below this line */
  123. + /**/
  124. +     149,
  125.   /**/
  126.  
  127. -- 
  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)
  136.  
  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  ///
  141.