summaryrefslogtreecommitdiff
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-23 21:35:48 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-23 21:35:48 +0200
commit99499b1c05f85f83876b828eea3f6e14f0f407b4 (patch)
tree88da7aeb6c66daf0c6555388952334efa8cb642e /src/misc1.c
parent05b8b07e2770b66ab77fdb5e195cae809959bdab (diff)
downloadvim-git-99499b1c05f85f83876b828eea3f6e14f0f407b4.tar.gz
patch 8.1.1371: cannot recover from a swap filev8.1.1371
Problem: Cannot recover from a swap file. Solution: Do not expand environment variables in the swap file name. Do not check the extension when we already know a file is a swap file. (Ken Takata, closes 4415, closes #4369)
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/misc1.c b/src/misc1.c
index e76e4a4a3..550a7273e 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -2691,13 +2691,15 @@ home_replace_save(
* FPC_DIFF if they both exist and are different files.
* FPC_NOTX if they both don't exist.
* FPC_DIFFX if one of them doesn't exist.
- * For the first name environment variables are expanded
+ * For the first name environment variables are expanded if "expandenv" is
+ * TRUE.
*/
int
fullpathcmp(
char_u *s1,
char_u *s2,
- int checkname) /* when both don't exist, check file names */
+ int checkname, // when both don't exist, check file names
+ int expandenv)
{
#ifdef UNIX
char_u exp1[MAXPATHL];
@@ -2706,7 +2708,10 @@ fullpathcmp(
stat_T st1, st2;
int r1, r2;
- expand_env(s1, exp1, MAXPATHL);
+ if (expandenv)
+ expand_env(s1, exp1, MAXPATHL);
+ else
+ vim_strncpy(exp1, s1, MAXPATHL - 1);
r1 = mch_stat((char *)exp1, &st1);
r2 = mch_stat((char *)s2, &st2);
if (r1 != 0 && r2 != 0)
@@ -2741,7 +2746,10 @@ fullpathcmp(
full1 = exp1 + MAXPATHL;
full2 = full1 + MAXPATHL;
- expand_env(s1, exp1, MAXPATHL);
+ if (expandenv)
+ expand_env(s1, exp1, MAXPATHL);
+ else
+ vim_strncpy(exp1, s1, MAXPATHL - 1);
r1 = vim_FullName(exp1, full1, MAXPATHL, FALSE);
r2 = vim_FullName(s2, full2, MAXPATHL, FALSE);
@@ -4027,7 +4035,7 @@ gen_expand_wildcards(
/*
* First expand environment variables, "~/" and "~user/".
*/
- if (has_env_var(p) || *p == '~')
+ if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~')
{
p = expand_env_save_opt(p, TRUE);
if (p == NULL)