free_cd_dir()
{
vim_free(prev_dir);
+ prev_dir = NULL;
}
#endif
*errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\"");
return NULL;
}
+ result = shorten_fname1(result);
break;
case SPEC_ABUF: /* buffer number for autocommand */
#endif
#if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
- defined(FEAT_QUICKFIX) || defined(PROTO)
+ defined(FEAT_QUICKFIX) || defined(FEAT_AUTOCMD) || defined(PROTO)
/*
* Try to find a shortname by comparing the fullname with the current
* directory.
/*
* Set the file name to be used for <afile>.
+ * Make a copy to avoid that changing a buffer name or directory makes it
+ * invalid.
*/
if (fname_io == NULL)
{
}
else
autocmd_fname = fname_io;
+ if (autocmd_fname != NULL)
+ autocmd_fname = FullName_save(autocmd_fname, FALSE);
/*
* Set the buffer number to be used for <abuf>.
vim_free(sourcing_name);
sourcing_name = save_sourcing_name;
sourcing_lnum = save_sourcing_lnum;
+ vim_free(autocmd_fname);
autocmd_fname = save_autocmd_fname;
autocmd_bufnr = save_autocmd_bufnr;
autocmd_match = save_autocmd_match;