Karsten Hopp 6633b1
To: vim-dev@vim.org
Karsten Hopp 6633b1
Subject: Patch 7.1.177
Karsten Hopp 6633b1
Fcc: outbox
Karsten Hopp 6633b1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6633b1
Mime-Version: 1.0
Karsten Hopp 6633b1
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 6633b1
Content-Transfer-Encoding: 8bit
Karsten Hopp 6633b1
------------
Karsten Hopp 6633b1
Karsten Hopp 6633b1
Patch 7.1.177
Karsten Hopp 6633b1
Problem:    Freeing memory twice when in debug mode while reading a script.
Karsten Hopp 6633b1
Solution:   Ignore script input while in debug mode.
Karsten Hopp 6633b1
Files:	    src/ex_cmds2.c, src/getchar.c, src/globals.h
Karsten Hopp 6633b1
Karsten Hopp 6633b1
Karsten Hopp 6633b1
*** ../vim-7.1.176/src/ex_cmds2.c	Thu May 10 20:55:46 2007
Karsten Hopp 6633b1
--- src/ex_cmds2.c	Tue Jan  1 14:13:41 2008
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 93,98 ****
Karsten Hopp 6633b1
--- 93,100 ----
Karsten Hopp 6633b1
      int		save_emsg_silent = emsg_silent;
Karsten Hopp 6633b1
      int		save_redir_off = redir_off;
Karsten Hopp 6633b1
      tasave_T	typeaheadbuf;
Karsten Hopp 6633b1
+     int		typeahead_saved = FALSE;
Karsten Hopp 6633b1
+     int		save_ignore_script;
Karsten Hopp 6633b1
  # ifdef FEAT_EX_EXTRA
Karsten Hopp 6633b1
      int		save_ex_normal_busy;
Karsten Hopp 6633b1
  # endif
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 159,176 ****
Karsten Hopp 6633b1
  	 * This makes sure we get input from the user here and don't interfere
Karsten Hopp 6633b1
  	 * with the commands being executed.  Reset "ex_normal_busy" to avoid
Karsten Hopp 6633b1
  	 * the side effects of using ":normal". Save the stuff buffer and make
Karsten Hopp 6633b1
! 	 * it empty. */
Karsten Hopp 6633b1
  # ifdef FEAT_EX_EXTRA
Karsten Hopp 6633b1
  	save_ex_normal_busy = ex_normal_busy;
Karsten Hopp 6633b1
  	ex_normal_busy = 0;
Karsten Hopp 6633b1
  # endif
Karsten Hopp 6633b1
  	if (!debug_greedy)
Karsten Hopp 6633b1
  	    save_typeahead(&typeaheadbuf);
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
  	cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL);
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
! 	if (!debug_greedy)
Karsten Hopp 6633b1
  	    restore_typeahead(&typeaheadbuf);
Karsten Hopp 6633b1
  # ifdef FEAT_EX_EXTRA
Karsten Hopp 6633b1
  	ex_normal_busy = save_ex_normal_busy;
Karsten Hopp 6633b1
  # endif
Karsten Hopp 6633b1
--- 161,186 ----
Karsten Hopp 6633b1
  	 * This makes sure we get input from the user here and don't interfere
Karsten Hopp 6633b1
  	 * with the commands being executed.  Reset "ex_normal_busy" to avoid
Karsten Hopp 6633b1
  	 * the side effects of using ":normal". Save the stuff buffer and make
Karsten Hopp 6633b1
! 	 * it empty. Set ignore_script to avoid reading from script input. */
Karsten Hopp 6633b1
  # ifdef FEAT_EX_EXTRA
Karsten Hopp 6633b1
  	save_ex_normal_busy = ex_normal_busy;
Karsten Hopp 6633b1
  	ex_normal_busy = 0;
Karsten Hopp 6633b1
  # endif
Karsten Hopp 6633b1
  	if (!debug_greedy)
Karsten Hopp 6633b1
+ 	{
Karsten Hopp 6633b1
  	    save_typeahead(&typeaheadbuf);
Karsten Hopp 6633b1
+ 	    typeahead_saved = TRUE;
Karsten Hopp 6633b1
+ 	    save_ignore_script = ignore_script;
Karsten Hopp 6633b1
+ 	    ignore_script = TRUE;
Karsten Hopp 6633b1
+ 	}
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
  	cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL);
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
! 	if (typeahead_saved)
Karsten Hopp 6633b1
! 	{
Karsten Hopp 6633b1
  	    restore_typeahead(&typeaheadbuf);
Karsten Hopp 6633b1
+ 	    ignore_script = save_ignore_script;
Karsten Hopp 6633b1
+ 	}
Karsten Hopp 6633b1
  # ifdef FEAT_EX_EXTRA
Karsten Hopp 6633b1
  	ex_normal_busy = save_ex_normal_busy;
Karsten Hopp 6633b1
  # endif
Karsten Hopp 6633b1
*** ../vim-7.1.176/src/getchar.c	Fri Dec  7 17:30:04 2007
Karsten Hopp 6633b1
--- src/getchar.c	Tue Jan  1 14:11:42 2008
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 1279,1286 ****
Karsten Hopp 6633b1
      void
Karsten Hopp 6633b1
  free_typebuf()
Karsten Hopp 6633b1
  {
Karsten Hopp 6633b1
!     vim_free(typebuf.tb_buf);
Karsten Hopp 6633b1
!     vim_free(typebuf.tb_noremap);
Karsten Hopp 6633b1
  }
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
  /*
Karsten Hopp 6633b1
--- 1279,1292 ----
Karsten Hopp 6633b1
      void
Karsten Hopp 6633b1
  free_typebuf()
Karsten Hopp 6633b1
  {
Karsten Hopp 6633b1
!     if (typebuf.tb_buf == typebuf_init)
Karsten Hopp 6633b1
! 	EMSG2(_(e_intern2), "Free typebuf 1");
Karsten Hopp 6633b1
!     else
Karsten Hopp 6633b1
! 	vim_free(typebuf.tb_buf);
Karsten Hopp 6633b1
!     if (typebuf.tb_buf == noremapbuf_init)
Karsten Hopp 6633b1
! 	EMSG2(_(e_intern2), "Free typebuf 2");
Karsten Hopp 6633b1
!     else
Karsten Hopp 6633b1
! 	vim_free(typebuf.tb_noremap);
Karsten Hopp 6633b1
  }
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
  /*
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 1359,1364 ****
Karsten Hopp 6633b1
--- 1365,1375 ----
Karsten Hopp 6633b1
  	EMSG(_(e_nesting));
Karsten Hopp 6633b1
  	return;
Karsten Hopp 6633b1
      }
Karsten Hopp 6633b1
+ #ifdef FEAT_EVAL
Karsten Hopp 6633b1
+     if (ignore_script)
Karsten Hopp 6633b1
+ 	/* Not reading from script, also don't open one.  Warning message? */
Karsten Hopp 6633b1
+ 	return;
Karsten Hopp 6633b1
+ #endif
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
      if (scriptin[curscript] != NULL)	/* already reading script */
Karsten Hopp 6633b1
  	++curscript;
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 2346,2352 ****
Karsten Hopp 6633b1
  						   current_menu->silent[idx]);
Karsten Hopp 6633b1
  				}
Karsten Hopp 6633b1
  			    }
Karsten Hopp 6633b1
! #endif /* FEAT_GUI */
Karsten Hopp 6633b1
  			    continue;	/* try mapping again */
Karsten Hopp 6633b1
  			}
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
--- 2357,2363 ----
Karsten Hopp 6633b1
  						   current_menu->silent[idx]);
Karsten Hopp 6633b1
  				}
Karsten Hopp 6633b1
  			    }
Karsten Hopp 6633b1
! #endif /* FEAT_GUI && FEAT_MENU */
Karsten Hopp 6633b1
  			    continue;	/* try mapping again */
Karsten Hopp 6633b1
  			}
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 2862,2872 ****
Karsten Hopp 6633b1
      undo_off = FALSE;		    /* restart undo now */
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
      /*
Karsten Hopp 6633b1
!      * first try script file
Karsten Hopp 6633b1
!      *	If interrupted: Stop reading script files.
Karsten Hopp 6633b1
       */
Karsten Hopp 6633b1
      script_char = -1;
Karsten Hopp 6633b1
!     while (scriptin[curscript] != NULL && script_char < 0)
Karsten Hopp 6633b1
      {
Karsten Hopp 6633b1
  	if (got_int || (script_char = getc(scriptin[curscript])) < 0)
Karsten Hopp 6633b1
  	{
Karsten Hopp 6633b1
--- 2873,2887 ----
Karsten Hopp 6633b1
      undo_off = FALSE;		    /* restart undo now */
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
      /*
Karsten Hopp 6633b1
!      * Get a character from a script file if there is one.
Karsten Hopp 6633b1
!      * If interrupted: Stop reading script files, close them all.
Karsten Hopp 6633b1
       */
Karsten Hopp 6633b1
      script_char = -1;
Karsten Hopp 6633b1
!     while (scriptin[curscript] != NULL && script_char < 0
Karsten Hopp 6633b1
! #ifdef FEAT_EVAL
Karsten Hopp 6633b1
! 	    && !ignore_script
Karsten Hopp 6633b1
! #endif
Karsten Hopp 6633b1
! 	    )
Karsten Hopp 6633b1
      {
Karsten Hopp 6633b1
  	if (got_int || (script_char = getc(scriptin[curscript])) < 0)
Karsten Hopp 6633b1
  	{
Karsten Hopp 6633b1
*** ../vim-7.1.176/src/globals.h	Sat Sep 29 14:15:00 2007
Karsten Hopp 6633b1
--- src/globals.h	Mon Dec 31 17:00:21 2007
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 954,959 ****
Karsten Hopp 6633b1
--- 954,962 ----
Karsten Hopp 6633b1
  EXTERN int	ex_normal_busy INIT(= 0); /* recursiveness of ex_normal() */
Karsten Hopp 6633b1
  EXTERN int	ex_normal_lock INIT(= 0); /* forbid use of ex_normal() */
Karsten Hopp 6633b1
  #endif
Karsten Hopp 6633b1
+ #ifdef FEAT_EVAL
Karsten Hopp 6633b1
+ EXTERN int	ignore_script INIT(= FALSE);  /* ignore script input */
Karsten Hopp 6633b1
+ #endif
Karsten Hopp 6633b1
  EXTERN int	stop_insert_mode;	/* for ":stopinsert" and 'insertmode' */
Karsten Hopp 6633b1
  
Karsten Hopp 6633b1
  EXTERN int	KeyTyped;		/* TRUE if user typed current char */
Karsten Hopp 6633b1
*** ../vim-7.1.176/src/version.c	Mon Dec 31 16:41:31 2007
Karsten Hopp 6633b1
--- src/version.c	Tue Jan  1 14:00:09 2008
Karsten Hopp 6633b1
***************
Karsten Hopp 6633b1
*** 668,669 ****
Karsten Hopp 6633b1
--- 668,671 ----
Karsten Hopp 6633b1
  {   /* Add new patch number below this line */
Karsten Hopp 6633b1
+ /**/
Karsten Hopp 6633b1
+     177,
Karsten Hopp 6633b1
  /**/
Karsten Hopp 6633b1
Karsten Hopp 6633b1
-- 
Karsten Hopp 6633b1
Back up my hard drive?  I can't find the reverse switch!
Karsten Hopp 6633b1
Karsten Hopp 6633b1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6633b1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6633b1
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 6633b1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///