astepano / rpms / vim

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