Karsten Hopp 2ef74b
To: vim-dev@vim.org
Karsten Hopp 2ef74b
Subject: patch 7.1.073
Karsten Hopp 2ef74b
Fcc: outbox
Karsten Hopp 2ef74b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2ef74b
Mime-Version: 1.0
Karsten Hopp 2ef74b
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 2ef74b
Content-Transfer-Encoding: 8bit
Karsten Hopp 2ef74b
------------
Karsten Hopp 2ef74b
Karsten Hopp 2ef74b
Patch 7.1.073 (after 7.1.062)
Karsten Hopp 2ef74b
Problem:    Wrong cursor position and crash when 'preserveindent' is set.
Karsten Hopp 2ef74b
	    (Charles Campbell)
Karsten Hopp 2ef74b
Solution:   Handle the situation that we start without indent. (Chris
Karsten Hopp 2ef74b
	    Lubinski)
Karsten Hopp 2ef74b
Files:	    src/misc1.c
Karsten Hopp 2ef74b
Karsten Hopp 2ef74b
Karsten Hopp 2ef74b
*** ../vim-7.1.072/src/misc1.c	Sat Aug 11 14:32:10 2007
Karsten Hopp 2ef74b
--- src/misc1.c	Tue Aug 14 21:21:49 2007
Karsten Hopp 2ef74b
***************
Karsten Hopp 2ef74b
*** 104,110 ****
Karsten Hopp 2ef74b
      int		ind_done = 0;	    /* measured in spaces */
Karsten Hopp 2ef74b
      int		tab_pad;
Karsten Hopp 2ef74b
      int		retval = FALSE;
Karsten Hopp 2ef74b
!     int		orig_char_len = 0;  /* number of initial whitespace chars when
Karsten Hopp 2ef74b
  				       'et' and 'pi' are both set */
Karsten Hopp 2ef74b
  
Karsten Hopp 2ef74b
      /*
Karsten Hopp 2ef74b
--- 104,110 ----
Karsten Hopp 2ef74b
      int		ind_done = 0;	    /* measured in spaces */
Karsten Hopp 2ef74b
      int		tab_pad;
Karsten Hopp 2ef74b
      int		retval = FALSE;
Karsten Hopp 2ef74b
!     int		orig_char_len = -1; /* number of initial whitespace chars when
Karsten Hopp 2ef74b
  				       'et' and 'pi' are both set */
Karsten Hopp 2ef74b
  
Karsten Hopp 2ef74b
      /*
Karsten Hopp 2ef74b
***************
Karsten Hopp 2ef74b
*** 159,165 ****
Karsten Hopp 2ef74b
  
Karsten Hopp 2ef74b
  	    /* Fill to next tabstop with a tab, if possible */
Karsten Hopp 2ef74b
  	    tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
Karsten Hopp 2ef74b
! 	    if (todo >= tab_pad && orig_char_len == 0)
Karsten Hopp 2ef74b
  	    {
Karsten Hopp 2ef74b
  		doit = TRUE;
Karsten Hopp 2ef74b
  		todo -= tab_pad;
Karsten Hopp 2ef74b
--- 159,165 ----
Karsten Hopp 2ef74b
  
Karsten Hopp 2ef74b
  	    /* Fill to next tabstop with a tab, if possible */
Karsten Hopp 2ef74b
  	    tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
Karsten Hopp 2ef74b
! 	    if (todo >= tab_pad && orig_char_len == -1)
Karsten Hopp 2ef74b
  	    {
Karsten Hopp 2ef74b
  		doit = TRUE;
Karsten Hopp 2ef74b
  		todo -= tab_pad;
Karsten Hopp 2ef74b
***************
Karsten Hopp 2ef74b
*** 206,216 ****
Karsten Hopp 2ef74b
      /* If 'preserveindent' and 'expandtab' are both set keep the original
Karsten Hopp 2ef74b
       * characters and allocate accordingly.  We will fill the rest with spaces
Karsten Hopp 2ef74b
       * after the if (!curbuf->b_p_et) below. */
Karsten Hopp 2ef74b
!     if (orig_char_len != 0)
Karsten Hopp 2ef74b
      {
Karsten Hopp 2ef74b
  	newline = alloc(orig_char_len + size - ind_done + line_len);
Karsten Hopp 2ef74b
  	if (newline == NULL)
Karsten Hopp 2ef74b
  	    return FALSE;
Karsten Hopp 2ef74b
  	p = oldline;
Karsten Hopp 2ef74b
  	s = newline;
Karsten Hopp 2ef74b
  	while (orig_char_len > 0)
Karsten Hopp 2ef74b
--- 206,220 ----
Karsten Hopp 2ef74b
      /* If 'preserveindent' and 'expandtab' are both set keep the original
Karsten Hopp 2ef74b
       * characters and allocate accordingly.  We will fill the rest with spaces
Karsten Hopp 2ef74b
       * after the if (!curbuf->b_p_et) below. */
Karsten Hopp 2ef74b
!     if (orig_char_len != -1)
Karsten Hopp 2ef74b
      {
Karsten Hopp 2ef74b
  	newline = alloc(orig_char_len + size - ind_done + line_len);
Karsten Hopp 2ef74b
  	if (newline == NULL)
Karsten Hopp 2ef74b
  	    return FALSE;
Karsten Hopp 2ef74b
+ 	todo = size - ind_done;
Karsten Hopp 2ef74b
+ 	ind_len = orig_char_len + todo;    /* Set total length of indent in
Karsten Hopp 2ef74b
+ 					    * characters, which may have been
Karsten Hopp 2ef74b
+ 					    * undercounted until now  */
Karsten Hopp 2ef74b
  	p = oldline;
Karsten Hopp 2ef74b
  	s = newline;
Karsten Hopp 2ef74b
  	while (orig_char_len > 0)
Karsten Hopp 2ef74b
***************
Karsten Hopp 2ef74b
*** 222,230 ****
Karsten Hopp 2ef74b
  	 * than old) */
Karsten Hopp 2ef74b
  	while (vim_iswhite(*p))
Karsten Hopp 2ef74b
  	    (void)*p++;
Karsten Hopp 2ef74b
- 	todo = size - ind_done;
Karsten Hopp 2ef74b
- 	ind_len += todo;    /* Set total length of indent in characters,
Karsten Hopp 2ef74b
- 			     * which may have been undercounted until now  */
Karsten Hopp 2ef74b
  
Karsten Hopp 2ef74b
      }
Karsten Hopp 2ef74b
      else
Karsten Hopp 2ef74b
--- 226,231 ----
Karsten Hopp 2ef74b
*** ../vim-7.1.072/src/version.c	Tue Aug 14 17:54:37 2007
Karsten Hopp 2ef74b
--- src/version.c	Tue Aug 14 22:14:54 2007
Karsten Hopp 2ef74b
***************
Karsten Hopp 2ef74b
*** 668,669 ****
Karsten Hopp 2ef74b
--- 668,671 ----
Karsten Hopp 2ef74b
  {   /* Add new patch number below this line */
Karsten Hopp 2ef74b
+ /**/
Karsten Hopp 2ef74b
+     73,
Karsten Hopp 2ef74b
  /**/
Karsten Hopp 2ef74b
Karsten Hopp 2ef74b
-- 
Karsten Hopp 2ef74b
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 2ef74b
157. You fum through a magazine, you first check to see if it has a web
Karsten Hopp 2ef74b
     address.
Karsten Hopp 2ef74b
Karsten Hopp 2ef74b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2ef74b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2ef74b
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 2ef74b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///