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