Karsten Hopp 38fd38
To: vim-dev@vim.org
Karsten Hopp 38fd38
Subject: Patch 7.2.366
Karsten Hopp 38fd38
Fcc: outbox
Karsten Hopp 38fd38
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 38fd38
Mime-Version: 1.0
Karsten Hopp 38fd38
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 38fd38
Content-Transfer-Encoding: 8bit
Karsten Hopp 38fd38
------------
Karsten Hopp 38fd38
Karsten Hopp 38fd38
Patch 7.2.366
Karsten Hopp 38fd38
Problem:    CTRL-B doesn't go back to the first line of the buffer.
Karsten Hopp 38fd38
Solution:   Avoid an overflow when adding MAXCOL.
Karsten Hopp 38fd38
Files:	    src/move.c
Karsten Hopp 38fd38
Karsten Hopp 38fd38
Karsten Hopp 38fd38
*** ../vim-7.2.365/src/move.c	2010-02-03 17:42:59.000000000 +0100
Karsten Hopp 38fd38
--- src/move.c	2010-02-17 17:49:34.000000000 +0100
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 1610,1616 ****
Karsten Hopp 38fd38
   * Add one line above "lp->lnum".  This can be a filler line, a closed fold or
Karsten Hopp 38fd38
   * a (wrapped) text line.  Uses and sets "lp->fill".
Karsten Hopp 38fd38
   * Returns the height of the added line in "lp->height".
Karsten Hopp 38fd38
!  * Lines above the first one are incredibly high.
Karsten Hopp 38fd38
   */
Karsten Hopp 38fd38
      static void
Karsten Hopp 38fd38
  topline_back(lp)
Karsten Hopp 38fd38
--- 1610,1616 ----
Karsten Hopp 38fd38
   * Add one line above "lp->lnum".  This can be a filler line, a closed fold or
Karsten Hopp 38fd38
   * a (wrapped) text line.  Uses and sets "lp->fill".
Karsten Hopp 38fd38
   * Returns the height of the added line in "lp->height".
Karsten Hopp 38fd38
!  * Lines above the first one are incredibly high: MAXCOL.
Karsten Hopp 38fd38
   */
Karsten Hopp 38fd38
      static void
Karsten Hopp 38fd38
  topline_back(lp)
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 1942,1948 ****
Karsten Hopp 38fd38
  	{
Karsten Hopp 38fd38
  	    loff.lnum = curwin->w_topline;
Karsten Hopp 38fd38
  	    topline_back(&loff);
Karsten Hopp 38fd38
! 	    if (used + loff.height > curwin->w_height)
Karsten Hopp 38fd38
  		break;
Karsten Hopp 38fd38
  	    used += loff.height;
Karsten Hopp 38fd38
  #ifdef FEAT_DIFF
Karsten Hopp 38fd38
--- 1942,1948 ----
Karsten Hopp 38fd38
  	{
Karsten Hopp 38fd38
  	    loff.lnum = curwin->w_topline;
Karsten Hopp 38fd38
  	    topline_back(&loff);
Karsten Hopp 38fd38
! 	    if (loff.height == MAXCOL || used + loff.height > curwin->w_height)
Karsten Hopp 38fd38
  		break;
Karsten Hopp 38fd38
  	    used += loff.height;
Karsten Hopp 38fd38
  #ifdef FEAT_DIFF
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 2021,2027 ****
Karsten Hopp 38fd38
  
Karsten Hopp 38fd38
  	/* Add one line above */
Karsten Hopp 38fd38
  	topline_back(&loff);
Karsten Hopp 38fd38
! 	used += loff.height;
Karsten Hopp 38fd38
  	if (used > curwin->w_height)
Karsten Hopp 38fd38
  	    break;
Karsten Hopp 38fd38
  	if (loff.lnum >= curwin->w_botline
Karsten Hopp 38fd38
--- 2021,2030 ----
Karsten Hopp 38fd38
  
Karsten Hopp 38fd38
  	/* Add one line above */
Karsten Hopp 38fd38
  	topline_back(&loff);
Karsten Hopp 38fd38
! 	if (loff.height == MAXCOL)
Karsten Hopp 38fd38
! 	    used = MAXCOL;
Karsten Hopp 38fd38
! 	else
Karsten Hopp 38fd38
! 	    used += loff.height;
Karsten Hopp 38fd38
  	if (used > curwin->w_height)
Karsten Hopp 38fd38
  	    break;
Karsten Hopp 38fd38
  	if (loff.lnum >= curwin->w_botline
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 2175,2181 ****
Karsten Hopp 38fd38
  	if (below > above)	    /* add a line above the cursor */
Karsten Hopp 38fd38
  	{
Karsten Hopp 38fd38
  	    topline_back(&loff);
Karsten Hopp 38fd38
! 	    used += loff.height;
Karsten Hopp 38fd38
  	    if (used > curwin->w_height)
Karsten Hopp 38fd38
  		break;
Karsten Hopp 38fd38
  	    above += loff.height;
Karsten Hopp 38fd38
--- 2178,2187 ----
Karsten Hopp 38fd38
  	if (below > above)	    /* add a line above the cursor */
Karsten Hopp 38fd38
  	{
Karsten Hopp 38fd38
  	    topline_back(&loff);
Karsten Hopp 38fd38
! 	    if (loff.height == MAXCOL)
Karsten Hopp 38fd38
! 		used = MAXCOL;
Karsten Hopp 38fd38
! 	    else
Karsten Hopp 38fd38
! 		used += loff.height;
Karsten Hopp 38fd38
  	    if (used > curwin->w_height)
Karsten Hopp 38fd38
  		break;
Karsten Hopp 38fd38
  	    above += loff.height;
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 2472,2480 ****
Karsten Hopp 38fd38
  	    while (n <= curwin->w_height && loff.lnum >= 1)
Karsten Hopp 38fd38
  	    {
Karsten Hopp 38fd38
  		topline_back(&loff);
Karsten Hopp 38fd38
! 		n += loff.height;
Karsten Hopp 38fd38
  	    }
Karsten Hopp 38fd38
! 	    if (n <= curwin->w_height)		    /* at begin of file */
Karsten Hopp 38fd38
  	    {
Karsten Hopp 38fd38
  		curwin->w_topline = 1;
Karsten Hopp 38fd38
  #ifdef FEAT_DIFF
Karsten Hopp 38fd38
--- 2478,2489 ----
Karsten Hopp 38fd38
  	    while (n <= curwin->w_height && loff.lnum >= 1)
Karsten Hopp 38fd38
  	    {
Karsten Hopp 38fd38
  		topline_back(&loff);
Karsten Hopp 38fd38
! 		if (loff.height == MAXCOL)
Karsten Hopp 38fd38
! 		    n = MAXCOL;
Karsten Hopp 38fd38
! 		else
Karsten Hopp 38fd38
! 		    n += loff.height;
Karsten Hopp 38fd38
  	    }
Karsten Hopp 38fd38
! 	    if (loff.lnum < 1)			/* at begin of file */
Karsten Hopp 38fd38
  	    {
Karsten Hopp 38fd38
  		curwin->w_topline = 1;
Karsten Hopp 38fd38
  #ifdef FEAT_DIFF
Karsten Hopp 38fd38
*** ../vim-7.2.365/src/version.c	2010-02-17 17:34:38.000000000 +0100
Karsten Hopp 38fd38
--- src/version.c	2010-02-17 18:13:22.000000000 +0100
Karsten Hopp 38fd38
***************
Karsten Hopp 38fd38
*** 683,684 ****
Karsten Hopp 38fd38
--- 683,686 ----
Karsten Hopp 38fd38
  {   /* Add new patch number below this line */
Karsten Hopp 38fd38
+ /**/
Karsten Hopp 38fd38
+     366,
Karsten Hopp 38fd38
  /**/
Karsten Hopp 38fd38
Karsten Hopp 38fd38
-- 
Karsten Hopp 38fd38
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 38fd38
247. You use www.switchboard.com instead of dialing 411 and 555-12-12
Karsten Hopp 38fd38
     for directory assistance.
Karsten Hopp 38fd38
Karsten Hopp 38fd38
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 38fd38
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 38fd38
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 38fd38
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///