Ben Fritz wrote: > Thanks, everyone. The curwin->w_localdir variable was exactly what I > was looking for, and the tertiary operator makes it a little clearer > what is going on in the directory restore code. > > I took your suggestions and additionally moved the directory restore > calls into the ((un)?load|wipe)_dummy_buffer functions so that it is > easier to maintain in the future, if these functions are used > elsewhere. The root cause of the problem was that many of the > functions from buffer.c called by these dummy_buffer functions were > using the DO_AUTOCHDIR macro, though presumably an appropriately > defined autocmd would do the same thing, so whenever we touch the > dummy buffer we need to restore the directory. Presumably creating a > "dummy buffer" should never have lasting effects on the current > directory!
Thanks, I'll put the patch in the todo list. > Updated patch attached to fix that 'autochdir' causes :vimgrep to > fail, based on 7.3.421. I did have one more question: I noticed that > the pre-existing code dynamically allocates memory of static size > MAXPATHL for both dirname_start and dirname_now. I have kept this and > done the same thing for the restore_start_dir function I added, but I > wonder, is there a reason the path string cannot be stack-allocated > instead? Is it to limit stack size or something, since MAXPATHL can be > somewhat large? As a rule of thumb: A function should not put more than about 1000 bytes on the stack. Les if it used recursively. That's because we can gracefully handle out-of-memory allocations but not out-of-stack errors, these cause a crash. -- Apparently, 1 in 5 people in the world are Chinese. And there are 5 people in my family, so it must be one of them. It's either my mum or my dad. Or my older brother Colin. Or my younger brother Ho-Cha-Chu. But I think it's Colin. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ 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
