Patch 7.2.241
Problem:    When using a combination of ":bufdo" and "doautoall" we may end up
            in the wrong directory. (Ajit Thakkar)
            Crash when triggering an autocommand in ":vimgrep".  (Yukihiro
            Nakadaira)
Solution:   Clear w_localdir and globaldir when using the aucmd_win.
            Use a separate flag to decide aucmd_win needs to be restored.
Files:      src/fileio.c, src/globals.h, src/structs.h


*** ../vim-7.2.240/src/fileio.c 2009-07-01 17:11:40.000000000 +0200
--- src/fileio.c        2009-07-22 19:08:55.000000000 +0200
***************
*** 8420,8425 ****
--- 8420,8429 ----
        if (aucmd_win == NULL)
            win = curwin;
      }
+     if (win == NULL && aucmd_win_used)
+       /* Strange recursive autocommand, fall back to using the current
+        * window.  Expect a few side effects... */
+       win = curwin;
  
      aco->save_curwin = curwin;
      aco->save_curbuf = curbuf;
***************
*** 8428,8433 ****
--- 8432,8438 ----
        /* There is a window for "buf" in the current tab page, make it the
         * curwin.  This is preferred, it has the least side effects (esp. if
         * "buf" is curbuf). */
+       aco->use_aucmd_win = FALSE;
        curwin = win;
      }
      else
***************
*** 8436,8444 ****
--- 8441,8460 ----
         * effects, insert it in a the current tab page.
         * Anything related to a window (e.g., setting folds) may have
         * unexpected results. */
+       aco->use_aucmd_win = TRUE;
+       aucmd_win_used = TRUE;
        aucmd_win->w_buffer = buf;
        ++buf->b_nwindows;
        win_init_empty(aucmd_win); /* set cursor and topline to safe values */
+       vim_free(aucmd_win->w_localdir);
+       aucmd_win->w_localdir = NULL;
+ 
+       /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
+        * win_enter_ext(). */
+       aucmd_win->w_localdir = NULL;
+       aco->globaldir = globaldir;
+       globaldir = NULL;
+ 
  
  #ifdef FEAT_WINDOWS
        /* Split the current window, put the aucmd_win in the upper half.
***************
*** 8472,8478 ****
      int dummy;
  #endif
  
!     if (aco->new_curwin == aucmd_win)
      {
        --curbuf->b_nwindows;
  #ifdef FEAT_WINDOWS
--- 8488,8494 ----
      int dummy;
  #endif
  
!     if (aco->use_aucmd_win)
      {
        --curbuf->b_nwindows;
  #ifdef FEAT_WINDOWS
***************
*** 8499,8504 ****
--- 8515,8521 ----
        /* Remove the window and frame from the tree of frames. */
        (void)winframe_remove(curwin, &dummy, NULL);
        win_remove(curwin, NULL);
+       aucmd_win_used = FALSE;
        last_status(FALSE);         /* may need to remove last status line */
        restore_snapshot(SNAP_AUCMD_IDX, FALSE);
        (void)win_comp_pos();   /* recompute window positions */
***************
*** 8517,8522 ****
--- 8534,8542 ----
  #endif
        curbuf = curwin->w_buffer;
  
+       vim_free(globaldir);
+       globaldir = aco->globaldir;
+ 
        /* the buffer contents may have changed */
        check_cursor();
        if (curwin->w_topline > curbuf->b_ml.ml_line_count)
***************
*** 8541,8547 ****
  #endif
        {
            /* Restore the buffer which was previously edited by curwin, if
!            * it was chagned, we are still the same window and the buffer is
             * valid. */
            if (curwin == aco->new_curwin
                    && curbuf != aco->new_curbuf
--- 8561,8567 ----
  #endif
        {
            /* Restore the buffer which was previously edited by curwin, if
!            * it was changed, we are still the same window and the buffer is
             * valid. */
            if (curwin == aco->new_curwin
                    && curbuf != aco->new_curbuf
*** ../vim-7.2.240/src/globals.h        2009-06-16 16:01:34.000000000 +0200
--- src/globals.h       2009-07-22 19:50:53.000000000 +0200
***************
*** 541,546 ****
--- 541,547 ----
  
  #ifdef FEAT_AUTOCMD
  EXTERN win_T  *aucmd_win;     /* window used in aucmd_prepbuf() */
+ EXTERN int    aucmd_win_used INIT(= FALSE);   /* aucmd_win is being used */
  #endif
  
  /*
*** ../vim-7.2.240/src/structs.h        2009-07-09 18:24:24.000000000 +0200
--- src/structs.h       2009-07-22 18:58:35.000000000 +0200
***************
*** 2288,2296 ****
--- 2288,2298 ----
  {
      buf_T     *save_curbuf;   /* saved curbuf */
  #ifdef FEAT_AUTOCMD
+     int               use_aucmd_win;  /* using aucmd_win */
      win_T     *save_curwin;   /* saved curwin */
      win_T     *new_curwin;    /* new curwin */
      buf_T     *new_curbuf;    /* new curbuf */
+     char_u    *globaldir;     /* saved value of globaldir */
  #endif
  } aco_save_T;
  
*** ../vim-7.2.240/src/version.c        2009-07-29 11:10:31.000000000 +0200
--- src/version.c       2009-07-29 12:06:31.000000000 +0200
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     241,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...".

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui