Re: Patch 8.2.3920

2021-12-28 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 29-Dec-2021 00:16, Bram Moolenaar wrote:
> > Patch 8.2.3920
> > Problem:Restoring directory after using another window is inefficient.
> > Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
> >  only when needed.
> > Files:  src/evalwindow.c, src/testdir/test_autochdir.vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) spits out this error message if 
> FEAT_AUTOCHDIR is not defined (which is only defined if 
> FEAT_NETBEANS_INTG or FEAT_BIG are defined):
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD evalwindow.c -o 
> gobjnative/evalwindow.o
> evalwindow.c: In function 'f_win_execute':
> evalwindow.c:719:33: error: 'p_acd' undeclared (first use in this function)
>    719 | if (cwd_status == OK && p_acd)
>    | ^
> evalwindow.c:719:33: note: each undeclared identifier is reported only 
> once for each function it appears in
> make: *** [Make_cyg_ming.mak:1162: gobjnative/evalwindow.o] Error 1
> 
> 
> The attached patch makes the error go away but I'm not sure that it is 
> correct.

Not quite, the directory still needs to be restored.  But I can see
where the problem is.

-- 
All true wisdom is found on T-shirts.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228200415.A65081C0641%40moolenaar.net.


Re: Patch 8.2.3920

2021-12-28 Fir de Conversatie John Marriott


On 29-Dec-2021 00:16, Bram Moolenaar wrote:

Patch 8.2.3920
Problem:Restoring directory after using another window is inefficient.
Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
 only when needed.
Files:  src/evalwindow.c, src/testdir/test_autochdir.vim



After this patch, mingw64 (gcc 11.2.0) spits out this error message if 
FEAT_AUTOCHDIR is not defined (which is only defined if 
FEAT_NETBEANS_INTG or FEAT_BIG are defined):


gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD evalwindow.c -o 
gobjnative/evalwindow.o

evalwindow.c: In function 'f_win_execute':
evalwindow.c:719:33: error: 'p_acd' undeclared (first use in this function)
  719 | if (cwd_status == OK && p_acd)
  | ^
evalwindow.c:719:33: note: each undeclared identifier is reported only 
once for each function it appears in

make: *** [Make_cyg_ming.mak:1162: gobjnative/evalwindow.o] Error 1


The attached patch makes the error go away but I'm not sure that it is 
correct.


Cheers
John

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/d5abd208-c29c-5912-bed1-6f47b4d7f651%40internode.on.net.
--- evalwindow.c.orig   2021-12-29 06:15:24.855364100 +1100
+++ evalwindow.c2021-12-29 06:38:46.01094 +1100
@@ -707,6 +707,7 @@
 if (wp != NULL && tp != NULL)
 {
pos_T   curpos = wp->w_cursor;
+#ifdef FEAT_AUTOCHDIR
char_u  cwd[MAXPATHL];
int cwd_status;
char_u  autocwd[MAXPATHL];
@@ -722,6 +723,7 @@
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
  && STRCMP(cwd, autocwd) == 0;
}
+#endif
 
if (switch_win_noblock(_curwin, _curtab, wp, tp, TRUE) == OK)
{
@@ -729,10 +731,12 @@
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
+#ifdef FEAT_AUTOCHDIR
if (apply_acd)
do_autochdir();
else if (cwd_status == OK)
mch_chdir((char *)cwd);
+#endif
 
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))


Patch 8.2.3920

2021-12-28 Fir de Conversatie Bram Moolenaar


Patch 8.2.3920
Problem:Restoring directory after using another window is inefficient.
Solution:   Only restore the directory for win_execute().  Apply 'autochdir'
only when needed.
Files:  src/evalwindow.c, src/testdir/test_autochdir.vim


*** ../vim-8.2.3919/src/evalwindow.c2021-12-20 21:35:55.314175835 +
--- src/evalwindow.c2021-12-28 13:13:08.477118501 +
***
*** 707,712 
--- 707,727 
  if (wp != NULL && tp != NULL)
  {
pos_T   curpos = wp->w_cursor;
+   char_u  cwd[MAXPATHL];
+   int cwd_status;
+   char_u  autocwd[MAXPATHL];
+   int apply_acd = FALSE;
+ 
+   cwd_status = mch_dirname(cwd, MAXPATHL);
+ 
+   // If 'acd' is set, check we are using that directory.  If yes, then
+   // apply 'acd' afterwards, otherwise restore the current directory.
+   if (cwd_status == OK && p_acd)
+   {
+   do_autochdir();
+   apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
+ && STRCMP(cwd, autocwd) == 0;
+   }
  
if (switch_win_noblock(_curwin, _curtab, wp, tp, TRUE) == OK)
{
***
*** 714,719 
--- 729,738 
execute_common(argvars, rettv, 1);
}
restore_win_noblock(save_curwin, save_curtab, TRUE);
+   if (apply_acd)
+   do_autochdir();
+   else if (cwd_status == OK)
+   mch_chdir((char *)cwd);
  
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
***
*** 1316,1324 
// to the first valid window.
win_goto(firstwin);
  # endif
- 
- // If called by win_execute() and executing the command changed the
- // directory, it now has to be restored.
- fix_current_dir();
  }
  #endif
--- 1335,1339 
*** ../vim-8.2.3919/src/testdir/test_autochdir.vim  2021-12-05 
13:39:57.624815980 +
--- src/testdir/test_autochdir.vim  2021-12-28 12:17:38.450766408 +
***
*** 51,56 
--- 51,76 
endtry
  endfunc
  
+ func Test_acd_win_execute()
+   let cwd = getcwd()
+   set acd
+   call test_autochdir()
+ 
+   call mkdir('Xfile')
+   let winid = win_getid()
+   new Xfile/file
+   call assert_match('testdir.Xfile$', getcwd())
+   cd ..
+   call assert_match('testdir$', getcwd())
+   call win_execute(winid, 'echo')
+   call assert_match('testdir$', getcwd())
+ 
+   bwipe!
+   set noacd
+   call chdir(cwd)
+   call delete('Xfile', 'rf')
+ endfunc
+ 
  func Test_verbose_pwd()
let cwd = getcwd()
call test_autochdir()
*** ../vim-8.2.3919/src/version.c   2021-12-28 11:24:44.636994380 +
--- src/version.c   2021-12-28 12:50:41.287915926 +
***
*** 751,752 
--- 751,754 
  {   /* Add new patch number below this line */
+ /**/
+ 3920,
  /**/

-- 
The difference between theory and practice, is that in theory, there
is no difference between theory and practice.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228131600.E8A271C0641%40moolenaar.net.