aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/diff.c4
-rw-r--r--src/nvim/fileio.c29
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/os/os.h7
-rw-r--r--src/nvim/os/unix_defs.h7
-rw-r--r--src/nvim/os/win_defs.h9
-rw-r--r--src/nvim/os_unix_defs.h3
8 files changed, 28 insertions, 35 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index e7feacd4fb..0ae3d5553e 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -893,15 +893,11 @@ void ex_diffpatch(exarg_T *eap)
|| (os_chdir((char *)dirbuf) != 0)) {
dirbuf[0] = NUL;
} else {
-# ifdef TEMPDIRNAMES
if (vim_tempdir != NULL) {
ignored = os_chdir((char *)vim_tempdir);
} else {
ignored = os_chdir("/tmp");
}
-# else
- ignored = os_chdir("/tmp");
-# endif // ifdef TEMPDIRNAMES
shorten_fnames(TRUE);
}
#endif // ifdef UNIX
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e9a1545846..8dcc066258 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5156,7 +5156,6 @@ void write_lnum_adjust(linenr_T offset)
curbuf->b_no_eol_lnum += offset;
}
-#if defined(TEMPDIRNAMES) || defined(PROTO)
static long temp_count = 0; /* Temp filename counter. */
/*
@@ -5184,9 +5183,6 @@ void vim_deltempdir(void)
}
}
-#endif
-
-#ifdef TEMPDIRNAMES
/*
* Directory "tempdir" was created. Expand this name to a full path and put
* it in "vim_tempdir". This avoids that using ":cd" would confuse us.
@@ -5203,7 +5199,6 @@ static void vim_settempdir(char_u *tempdir)
free(buf);
}
}
-#endif
/*
* vim_tempname(): Return a unique name that can be used for a temp file.
@@ -5218,10 +5213,9 @@ vim_tempname (
int extra_char /* char to use in the name instead of '?' */
)
{
- char_u itmp[TEMPNAMELEN];
+ char_u itmp[TEMP_FILE_PATH_MAXLEN];
-#ifdef TEMPDIRNAMES
- static char *(tempdirs[]) = {TEMPDIRNAMES};
+ static const char *temp_dirs[] = TEMP_DIR_NAMES;
int i;
/*
@@ -5233,11 +5227,11 @@ vim_tempname (
*/
if (vim_tempdir == NULL) {
/*
- * Try the entries in TEMPDIRNAMES to create the temp directory.
+ * Try the entries in `TEMP_DIR_NAMES` to create the temp directory.
*/
- for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i) {
+ for (i = 0; i < (int)(sizeof(temp_dirs) / sizeof(char *)); ++i) {
/* expand $TMP, leave room for "/v1100000/999999999" */
- expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
+ expand_env((char_u *)temp_dirs[i], itmp, TEMP_FILE_PATH_MAXLEN - 20);
if (os_isdir(itmp)) { /* directory exists */
add_pathsep(itmp);
@@ -5259,19 +5253,6 @@ vim_tempname (
}
return NULL;
-
-#else /* TEMPDIRNAMES */
-
- char_u *p;
-
- STRCPY(itmp, TEMPNAME);
- if ((p = vim_strchr(itmp, '?')) != NULL)
- *p = extra_char;
- if (mktemp((char *)itmp) == NULL)
- return NULL;
-
- return vim_strsave(itmp);
-#endif /* TEMPDIRNAMES */
}
#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 871674907b..436ddb768d 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -536,10 +536,8 @@ EXTERN int ru_col; /* column for ruler */
EXTERN int ru_wid; /* 'rulerfmt' width of ruler when non-zero */
EXTERN int sc_col; /* column for shown command */
-#ifdef TEMPDIRNAMES
EXTERN char_u *vim_tempdir INIT(= NULL); /* Name of Vim's own temp dir.
Ends in a slash. */
-#endif
/*
* When starting or exiting some things are done differently (e.g. screen
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 2fb404a148..f951eb9379 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -589,9 +589,7 @@ void ml_close_all(int del_file)
ml_close(buf, del_file && ((buf->b_flags & BF_PRESERVED) == 0
|| vim_strchr(p_cpo, CPO_PRESERVE) == NULL));
spell_delete_wordlist(); /* delete the internal wordlist */
-#ifdef TEMPDIRNAMES
vim_deltempdir(); /* delete created temp directory */
-#endif
}
/*
diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h
index b6148e72bf..b46989d9b4 100644
--- a/src/nvim/os/os.h
+++ b/src/nvim/os/os.h
@@ -7,10 +7,17 @@
#include "nvim/os/fs_defs.h"
#include "nvim/vim.h"
+#ifdef WIN32
+# include "nvim/os/win_defs.h"
+#else
+# include "nvim/os/unix_defs.h"
+#endif
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/fs.h.generated.h"
# include "os/mem.h.generated.h"
# include "os/env.h.generated.h"
# include "os/users.h.generated.h"
#endif
+
#endif // NVIM_OS_OS_H
diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h
new file mode 100644
index 0000000000..197a87bcc5
--- /dev/null
+++ b/src/nvim/os/unix_defs.h
@@ -0,0 +1,7 @@
+#ifndef NEOVIM_OS_UNIX_DEFS_H
+#define NEOVIM_OS_UNIX_DEFS_H
+
+#define TEMP_DIR_NAMES {"$TMPDIR", "/tmp", ".", "$HOME"}
+#define TEMP_FILE_PATH_MAXLEN 256
+
+#endif // NEOVIM_OS_UNIX_DEFS_H
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
new file mode 100644
index 0000000000..49fcb64777
--- /dev/null
+++ b/src/nvim/os/win_defs.h
@@ -0,0 +1,9 @@
+#ifndef NEOVIM_OS_WIN_DEFS_H
+#define NEOVIM_OS_WIN_DEFS_H
+
+#include <windows.h>
+
+#define TEMP_DIR_NAMES {"$TMP", "$TEMP", "$USERPROFILE", ""}
+#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
+
+#endif // NEOVIM_OS_WIN_DEFS_H
diff --git a/src/nvim/os_unix_defs.h b/src/nvim/os_unix_defs.h
index 5ba9d2d98d..0d79117bfd 100644
--- a/src/nvim/os_unix_defs.h
+++ b/src/nvim/os_unix_defs.h
@@ -204,9 +204,6 @@
"~/.nvim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.nvim/after"
# endif
-# define TEMPDIRNAMES "$TMPDIR", "/tmp", ".", "$HOME"
-# define TEMPNAMELEN 256
-
/* Special wildcards that need to be handled by the shell */
#define SPECIAL_WILDCHAR "`'{"