astepano / rpms / vim

Forked from rpms/vim 6 years ago
Clone
4d9e12f
To: vim_dev@googlegroups.com
4d9e12f
Subject: Patch 7.4.446
4d9e12f
Fcc: outbox
4d9e12f
From: Bram Moolenaar <Bram@moolenaar.net>
4d9e12f
Mime-Version: 1.0
4d9e12f
Content-Type: text/plain; charset=UTF-8
4d9e12f
Content-Transfer-Encoding: 8bit
4d9e12f
------------
4d9e12f
4d9e12f
Patch 7.4.446
4d9e12f
Problem:    In some situations, when setting up an environment to trigger an
4d9e12f
	    autocommand, the environment is not properly restored.
4d9e12f
Solution:   Check the return value of switch_win() and call restore_win()
4d9e12f
	    always.  (Daniel Hahler)
4d9e12f
Files:	    src/eval.c, src/misc2.c, src/window.c
4d9e12f
4d9e12f
4d9e12f
*** ../vim-7.4.445/src/eval.c	2014-09-09 23:11:46.368586569 +0200
4d9e12f
--- src/eval.c	2014-09-19 14:09:27.238402767 +0200
4d9e12f
***************
4d9e12f
*** 12086,12100 ****
4d9e12f
      {
4d9e12f
  	/* Set tp to be our tabpage, temporarily.  Also set the window to the
4d9e12f
  	 * first window in the tabpage, otherwise the window is not valid. */
4d9e12f
! 	switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, tp, TRUE);
4d9e12f
! 
4d9e12f
! 	/* look up the variable */
4d9e12f
! 	/* Let gettabvar({nr}, "") return the "t:" dictionary. */
4d9e12f
! 	v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE);
4d9e12f
! 	if (v != NULL)
4d9e12f
  	{
4d9e12f
! 	    copy_tv(&v->di_tv, rettv);
4d9e12f
! 	    done = TRUE;
4d9e12f
  	}
4d9e12f
  
4d9e12f
  	/* restore previous notion of curwin */
4d9e12f
--- 12086,12102 ----
4d9e12f
      {
4d9e12f
  	/* Set tp to be our tabpage, temporarily.  Also set the window to the
4d9e12f
  	 * first window in the tabpage, otherwise the window is not valid. */
4d9e12f
! 	if (switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, tp, TRUE)
4d9e12f
! 									== OK)
4d9e12f
  	{
4d9e12f
! 	    /* look up the variable */
4d9e12f
! 	    /* Let gettabvar({nr}, "") return the "t:" dictionary. */
4d9e12f
! 	    v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE);
4d9e12f
! 	    if (v != NULL)
4d9e12f
! 	    {
4d9e12f
! 		copy_tv(&v->di_tv, rettv);
4d9e12f
! 		done = TRUE;
4d9e12f
! 	    }
4d9e12f
  	}
4d9e12f
  
4d9e12f
  	/* restore previous notion of curwin */
4d9e12f
***************
4d9e12f
*** 12233,12254 ****
4d9e12f
      {
4d9e12f
  	/* Set curwin to be our win, temporarily.  Also set the tabpage,
4d9e12f
  	 * otherwise the window is not valid. */
4d9e12f
! 	switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE);
4d9e12f
! 
4d9e12f
! 	if (*varname == '&')	/* window-local-option */
4d9e12f
! 	{
4d9e12f
! 	    if (get_option_tv(&varname, rettv, 1) == OK)
4d9e12f
! 		done = TRUE;
4d9e12f
! 	}
4d9e12f
! 	else
4d9e12f
  	{
4d9e12f
! 	    /* Look up the variable. */
4d9e12f
! 	    /* Let getwinvar({nr}, "") return the "w:" dictionary. */
4d9e12f
! 	    v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE);
4d9e12f
! 	    if (v != NULL)
4d9e12f
  	    {
4d9e12f
! 		copy_tv(&v->di_tv, rettv);
4d9e12f
! 		done = TRUE;
4d9e12f
  	    }
4d9e12f
  	}
4d9e12f
  
4d9e12f
--- 12235,12258 ----
4d9e12f
      {
4d9e12f
  	/* Set curwin to be our win, temporarily.  Also set the tabpage,
4d9e12f
  	 * otherwise the window is not valid. */
4d9e12f
! 	if (switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE) == OK)
4d9e12f
  	{
4d9e12f
! 	    if (*varname == '&')	/* window-local-option */
4d9e12f
  	    {
4d9e12f
! 		if (get_option_tv(&varname, rettv, 1) == OK)
4d9e12f
! 		    done = TRUE;
4d9e12f
! 	    }
4d9e12f
! 	    else
4d9e12f
! 	    {
4d9e12f
! 		/* Look up the variable. */
4d9e12f
! 		/* Let getwinvar({nr}, "") return the "w:" dictionary. */
4d9e12f
! 		v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w',
4d9e12f
! 							      varname, FALSE);
4d9e12f
! 		if (v != NULL)
4d9e12f
! 		{
4d9e12f
! 		    copy_tv(&v->di_tv, rettv);
4d9e12f
! 		    done = TRUE;
4d9e12f
! 		}
4d9e12f
  	    }
4d9e12f
  	}
4d9e12f
  
4d9e12f
***************
4d9e12f
*** 17252,17285 ****
4d9e12f
      if (win != NULL && varname != NULL && varp != NULL)
4d9e12f
      {
4d9e12f
  #ifdef FEAT_WINDOWS
4d9e12f
! 	if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == FAIL)
4d9e12f
! 	    return;
4d9e12f
  #endif
4d9e12f
- 
4d9e12f
- 	if (*varname == '&')
4d9e12f
  	{
4d9e12f
! 	    long	numval;
4d9e12f
! 	    char_u	*strval;
4d9e12f
! 	    int		error = FALSE;
4d9e12f
  
4d9e12f
! 	    ++varname;
4d9e12f
! 	    numval = get_tv_number_chk(varp, &error);
4d9e12f
! 	    strval = get_tv_string_buf_chk(varp, nbuf);
4d9e12f
! 	    if (!error && strval != NULL)
4d9e12f
! 		set_option_value(varname, numval, strval, OPT_LOCAL);
4d9e12f
! 	}
4d9e12f
! 	else
4d9e12f
! 	{
4d9e12f
! 	    winvarname = alloc((unsigned)STRLEN(varname) + 3);
4d9e12f
! 	    if (winvarname != NULL)
4d9e12f
  	    {
4d9e12f
! 		STRCPY(winvarname, "w:");
4d9e12f
! 		STRCPY(winvarname + 2, varname);
4d9e12f
! 		set_var(winvarname, varp, TRUE);
4d9e12f
! 		vim_free(winvarname);
4d9e12f
  	    }
4d9e12f
  	}
4d9e12f
- 
4d9e12f
  #ifdef FEAT_WINDOWS
4d9e12f
  	restore_win(save_curwin, save_curtab, TRUE);
4d9e12f
  #endif
4d9e12f
--- 17256,17288 ----
4d9e12f
      if (win != NULL && varname != NULL && varp != NULL)
4d9e12f
      {
4d9e12f
  #ifdef FEAT_WINDOWS
4d9e12f
! 	if (switch_win(&save_curwin, &save_curtab, win, tp, TRUE) == OK)
4d9e12f
  #endif
4d9e12f
  	{
4d9e12f
! 	    if (*varname == '&')
4d9e12f
! 	    {
4d9e12f
! 		long	numval;
4d9e12f
! 		char_u	*strval;
4d9e12f
! 		int		error = FALSE;
4d9e12f
  
4d9e12f
! 		++varname;
4d9e12f
! 		numval = get_tv_number_chk(varp, &error);
4d9e12f
! 		strval = get_tv_string_buf_chk(varp, nbuf);
4d9e12f
! 		if (!error && strval != NULL)
4d9e12f
! 		    set_option_value(varname, numval, strval, OPT_LOCAL);
4d9e12f
! 	    }
4d9e12f
! 	    else
4d9e12f
  	    {
4d9e12f
! 		winvarname = alloc((unsigned)STRLEN(varname) + 3);
4d9e12f
! 		if (winvarname != NULL)
4d9e12f
! 		{
4d9e12f
! 		    STRCPY(winvarname, "w:");
4d9e12f
! 		    STRCPY(winvarname + 2, varname);
4d9e12f
! 		    set_var(winvarname, varp, TRUE);
4d9e12f
! 		    vim_free(winvarname);
4d9e12f
! 		}
4d9e12f
  	    }
4d9e12f
  	}
4d9e12f
  #ifdef FEAT_WINDOWS
4d9e12f
  	restore_win(save_curwin, save_curtab, TRUE);
4d9e12f
  #endif
4d9e12f
*** ../vim-7.4.445/src/misc2.c	2014-08-10 13:34:59.060785459 +0200
4d9e12f
--- src/misc2.c	2014-09-19 14:03:24.314401974 +0200
4d9e12f
***************
4d9e12f
*** 1040,1046 ****
4d9e12f
      entered = TRUE;
4d9e12f
  
4d9e12f
  # ifdef FEAT_AUTOCMD
4d9e12f
!     block_autocmds();	    /* don't want to trigger autocommands here */
4d9e12f
  # endif
4d9e12f
  
4d9e12f
  # ifdef FEAT_WINDOWS
4d9e12f
--- 1040,1047 ----
4d9e12f
      entered = TRUE;
4d9e12f
  
4d9e12f
  # ifdef FEAT_AUTOCMD
4d9e12f
!     /* Don't want to trigger autocommands from here on. */
4d9e12f
!     block_autocmds();
4d9e12f
  # endif
4d9e12f
  
4d9e12f
  # ifdef FEAT_WINDOWS
4d9e12f
*** ../vim-7.4.445/src/window.c	2014-07-30 14:04:49.131603494 +0200
4d9e12f
--- src/window.c	2014-09-19 14:06:52.538402429 +0200
4d9e12f
***************
4d9e12f
*** 1271,1277 ****
4d9e12f
  }
4d9e12f
  
4d9e12f
  /*
4d9e12f
!  * Initialize window "newp" from window"old".
4d9e12f
   * Only the essential things are copied.
4d9e12f
   */
4d9e12f
      static void
4d9e12f
--- 1271,1277 ----
4d9e12f
  }
4d9e12f
  
4d9e12f
  /*
4d9e12f
!  * Initialize window "newp" from window "old".
4d9e12f
   * Only the essential things are copied.
4d9e12f
   */
4d9e12f
      static void
4d9e12f
***************
4d9e12f
*** 6662,6669 ****
4d9e12f
  	|| defined(PROTO)
4d9e12f
  /*
4d9e12f
   * Set "win" to be the curwin and "tp" to be the current tab page.
4d9e12f
!  * restore_win() MUST be called to undo.
4d9e12f
!  * No autocommands will be executed.
4d9e12f
   * When "no_display" is TRUE the display won't be affected, no redraw is
4d9e12f
   * triggered, another tabpage access is limited.
4d9e12f
   * Returns FAIL if switching to "win" failed.
4d9e12f
--- 6662,6669 ----
4d9e12f
  	|| defined(PROTO)
4d9e12f
  /*
4d9e12f
   * Set "win" to be the curwin and "tp" to be the current tab page.
4d9e12f
!  * restore_win() MUST be called to undo, also when FAIL is returned.
4d9e12f
!  * No autocommands will be executed until restore_win() is called.
4d9e12f
   * When "no_display" is TRUE the display won't be affected, no redraw is
4d9e12f
   * triggered, another tabpage access is limited.
4d9e12f
   * Returns FAIL if switching to "win" failed.
4d9e12f
***************
4d9e12f
*** 6696,6707 ****
4d9e12f
  	    goto_tabpage_tp(tp, FALSE, FALSE);
4d9e12f
      }
4d9e12f
      if (!win_valid(win))
4d9e12f
-     {
4d9e12f
- # ifdef FEAT_AUTOCMD
4d9e12f
- 	unblock_autocmds();
4d9e12f
- # endif
4d9e12f
  	return FAIL;
4d9e12f
-     }
4d9e12f
      curwin = win;
4d9e12f
      curbuf = curwin->w_buffer;
4d9e12f
  # endif
4d9e12f
--- 6696,6702 ----
4d9e12f
*** ../vim-7.4.445/src/version.c	2014-09-19 13:46:49.550399801 +0200
4d9e12f
--- src/version.c	2014-09-19 14:25:34.674404880 +0200
4d9e12f
***************
4d9e12f
*** 743,744 ****
4d9e12f
--- 743,746 ----
4d9e12f
  {   /* Add new patch number below this line */
4d9e12f
+ /**/
4d9e12f
+     446,
4d9e12f
  /**/
4d9e12f
4d9e12f
-- 
4d9e12f
hundred-and-one symptoms of being an internet addict:
4d9e12f
160. You get in the elevator and double-click the button for the floor
4d9e12f
     you want.
4d9e12f
4d9e12f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
4d9e12f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
4d9e12f
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
4d9e12f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///