Karsten Hopp d1bffb
To: vim_dev@googlegroups.com
Karsten Hopp d1bffb
Subject: Patch 7.4.690
Karsten Hopp d1bffb
Fcc: outbox
Karsten Hopp d1bffb
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d1bffb
Mime-Version: 1.0
Karsten Hopp d1bffb
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d1bffb
Content-Transfer-Encoding: 8bit
Karsten Hopp d1bffb
------------
Karsten Hopp d1bffb
Karsten Hopp d1bffb
Patch 7.4.690
Karsten Hopp d1bffb
Problem:    Memory access errors when changing indent in Ex mode. Also missing
Karsten Hopp d1bffb
	    redraw when using CTRL-U. (Knil Ino)
Karsten Hopp d1bffb
Solution:   Update pointers after calling ga_grow().
Karsten Hopp d1bffb
Files:	    src/ex_getln.c
Karsten Hopp d1bffb
Karsten Hopp d1bffb
Karsten Hopp d1bffb
*** ../vim-7.4.689/src/ex_getln.c	2015-03-21 17:32:14.054780051 +0100
Karsten Hopp d1bffb
--- src/ex_getln.c	2015-04-03 16:53:12.181002764 +0200
Karsten Hopp d1bffb
***************
Karsten Hopp d1bffb
*** 2245,2250 ****
Karsten Hopp d1bffb
--- 2245,2253 ----
Karsten Hopp d1bffb
      got_int = FALSE;
Karsten Hopp d1bffb
      while (!got_int)
Karsten Hopp d1bffb
      {
Karsten Hopp d1bffb
+ 	long    sw;
Karsten Hopp d1bffb
+ 	char_u *s;
Karsten Hopp d1bffb
+ 
Karsten Hopp d1bffb
  	if (ga_grow(&line_ga, 40) == FAIL)
Karsten Hopp d1bffb
  	    break;
Karsten Hopp d1bffb
  
Karsten Hopp d1bffb
***************
Karsten Hopp d1bffb
*** 2296,2308 ****
Karsten Hopp d1bffb
  		msg_col = startcol;
Karsten Hopp d1bffb
  		msg_clr_eos();
Karsten Hopp d1bffb
  		line_ga.ga_len = 0;
Karsten Hopp d1bffb
! 		continue;
Karsten Hopp d1bffb
  	    }
Karsten Hopp d1bffb
  
Karsten Hopp d1bffb
  	    if (c1 == Ctrl_T)
Karsten Hopp d1bffb
  	    {
Karsten Hopp d1bffb
! 		long	    sw = get_sw_value(curbuf);
Karsten Hopp d1bffb
! 
Karsten Hopp d1bffb
  		p = (char_u *)line_ga.ga_data;
Karsten Hopp d1bffb
  		p[line_ga.ga_len] = NUL;
Karsten Hopp d1bffb
  		indent = get_indent_str(p, 8, FALSE);
Karsten Hopp d1bffb
--- 2299,2310 ----
Karsten Hopp d1bffb
  		msg_col = startcol;
Karsten Hopp d1bffb
  		msg_clr_eos();
Karsten Hopp d1bffb
  		line_ga.ga_len = 0;
Karsten Hopp d1bffb
! 		goto redraw;
Karsten Hopp d1bffb
  	    }
Karsten Hopp d1bffb
  
Karsten Hopp d1bffb
  	    if (c1 == Ctrl_T)
Karsten Hopp d1bffb
  	    {
Karsten Hopp d1bffb
! 		sw = get_sw_value(curbuf);
Karsten Hopp d1bffb
  		p = (char_u *)line_ga.ga_data;
Karsten Hopp d1bffb
  		p[line_ga.ga_len] = NUL;
Karsten Hopp d1bffb
  		indent = get_indent_str(p, 8, FALSE);
Karsten Hopp d1bffb
***************
Karsten Hopp d1bffb
*** 2310,2318 ****
Karsten Hopp d1bffb
  add_indent:
Karsten Hopp d1bffb
  		while (get_indent_str(p, 8, FALSE) < indent)
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
! 		    char_u *s = skipwhite(p);
Karsten Hopp d1bffb
! 
Karsten Hopp d1bffb
! 		    ga_grow(&line_ga, 1);
Karsten Hopp d1bffb
  		    mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
Karsten Hopp d1bffb
  		    *s = ' ';
Karsten Hopp d1bffb
  		    ++line_ga.ga_len;
Karsten Hopp d1bffb
--- 2312,2320 ----
Karsten Hopp d1bffb
  add_indent:
Karsten Hopp d1bffb
  		while (get_indent_str(p, 8, FALSE) < indent)
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
! 		    ga_grow(&line_ga, 2);  /* one more for the NUL */
Karsten Hopp d1bffb
! 		    p = (char_u *)line_ga.ga_data;
Karsten Hopp d1bffb
! 		    s = skipwhite(p);
Karsten Hopp d1bffb
  		    mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
Karsten Hopp d1bffb
  		    *s = ' ';
Karsten Hopp d1bffb
  		    ++line_ga.ga_len;
Karsten Hopp d1bffb
***************
Karsten Hopp d1bffb
*** 2361,2373 ****
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
  		    p[line_ga.ga_len] = NUL;
Karsten Hopp d1bffb
  		    indent = get_indent_str(p, 8, FALSE);
Karsten Hopp d1bffb
! 		    --indent;
Karsten Hopp d1bffb
! 		    indent -= indent % get_sw_value(curbuf);
Karsten Hopp d1bffb
  		}
Karsten Hopp d1bffb
  		while (get_indent_str(p, 8, FALSE) > indent)
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
! 		    char_u *s = skipwhite(p);
Karsten Hopp d1bffb
! 
Karsten Hopp d1bffb
  		    mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
Karsten Hopp d1bffb
  		    --line_ga.ga_len;
Karsten Hopp d1bffb
  		}
Karsten Hopp d1bffb
--- 2363,2377 ----
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
  		    p[line_ga.ga_len] = NUL;
Karsten Hopp d1bffb
  		    indent = get_indent_str(p, 8, FALSE);
Karsten Hopp d1bffb
! 		    if (indent > 0)
Karsten Hopp d1bffb
! 		    {
Karsten Hopp d1bffb
! 			--indent;
Karsten Hopp d1bffb
! 			indent -= indent % get_sw_value(curbuf);
Karsten Hopp d1bffb
! 		    }
Karsten Hopp d1bffb
  		}
Karsten Hopp d1bffb
  		while (get_indent_str(p, 8, FALSE) > indent)
Karsten Hopp d1bffb
  		{
Karsten Hopp d1bffb
! 		    s = skipwhite(p);
Karsten Hopp d1bffb
  		    mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
Karsten Hopp d1bffb
  		    --line_ga.ga_len;
Karsten Hopp d1bffb
  		}
Karsten Hopp d1bffb
*** ../vim-7.4.689/src/version.c	2015-04-03 14:56:43.940840314 +0200
Karsten Hopp d1bffb
--- src/version.c	2015-04-03 17:02:19.739047689 +0200
Karsten Hopp d1bffb
***************
Karsten Hopp d1bffb
*** 743,744 ****
Karsten Hopp d1bffb
--- 743,746 ----
Karsten Hopp d1bffb
  {   /* Add new patch number below this line */
Karsten Hopp d1bffb
+ /**/
Karsten Hopp d1bffb
+     690,
Karsten Hopp d1bffb
  /**/
Karsten Hopp d1bffb
Karsten Hopp d1bffb
-- 
Karsten Hopp d1bffb
No man may purchase alcohol without written consent from his wife.
Karsten Hopp d1bffb
		[real standing law in Pennsylvania, United States of America]
Karsten Hopp d1bffb
Karsten Hopp d1bffb
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d1bffb
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d1bffb
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d1bffb
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///