summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-02 17:36:31 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-02 17:36:31 +0100
commit022f9ef16c955d6b5fca0f53b79899c56a3966c5 (patch)
tree8528160f0a3d3d24887d3d548951deb07f71a0d9 /src
parent2d2950198231a31bf87c1cd4322099cc36b0bb93 (diff)
downloadvim-git-022f9ef16c955d6b5fca0f53b79899c56a3966c5.tar.gz
patch 9.0.0028: MS-Windows: tests fail if there is a "runtime" directoryv9.0.0028
Problem: MS-Windows: tests fail if there is a stray "runtime" directory. Solution: Only use a "runtime" directory if it contains "defaults.vim".
Diffstat (limited to 'src')
-rw-r--r--src/filepath.c40
-rw-r--r--src/misc1.c16
-rw-r--r--src/version.c2
3 files changed, 37 insertions, 21 deletions
diff --git a/src/filepath.c b/src/filepath.c
index 854d823c9..f1ae18e0b 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -774,6 +774,26 @@ shorten_dir(char_u *str)
shorten_dir_len(str, 1);
}
+/*
+ * Return TRUE if "fname" is a readable file.
+ */
+ int
+file_is_readable(char_u *fname)
+{
+ int fd;
+
+#ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+#endif
+ if (*fname && !mch_isdir(fname)
+ && (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
+ {
+ close(fd);
+ return TRUE;
+ }
+ return FALSE;
+}
+
#if defined(FEAT_EVAL) || defined(PROTO)
/*
@@ -894,26 +914,6 @@ f_exepath(typval_T *argvars, typval_T *rettv)
}
/*
- * Return TRUE if "fname" is a readable file.
- */
- int
-file_is_readable(char_u *fname)
-{
- int fd;
-
-#ifndef O_NONBLOCK
-# define O_NONBLOCK 0
-#endif
- if (*fname && !mch_isdir(fname)
- && (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
- {
- close(fd);
- return TRUE;
- }
- return FALSE;
-}
-
-/*
* "filereadable()" function
*/
void
diff --git a/src/misc1.c b/src/misc1.c
index 91e208b35..1ab315941 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1655,7 +1655,21 @@ vim_version_dir(char_u *vimdir)
vim_free(p);
p = concat_fnames(vimdir, (char_u *)RUNTIME_DIRNAME, TRUE);
if (p != NULL && mch_isdir(p))
- return p;
+ {
+ char_u *fname = concat_fnames(p, (char_u *)"defaults.vim", TRUE);
+
+ // Check that "defaults.vim" exists in this directory, to avoid picking
+ // up a stray "runtime" directory, it would make many tests fail in
+ // mysterious ways.
+ if (fname != NULL)
+ {
+ int exists = file_is_readable(fname);
+
+ vim_free(fname);
+ if (exists)
+ return p;
+ }
+ }
vim_free(p);
return NULL;
}
diff --git a/src/version.c b/src/version.c
index 458591515..77be61cf8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 28,
+/**/
27,
/**/
26,