From edd7a8c5ddd99bd0c02b4218d43bccb562809d55 Mon Sep 17 00:00:00 2001 From: Pavel Platto Date: Thu, 19 Jun 2014 00:58:04 +0300 Subject: Remove #ifdefs TEMPDIRNAMES and add TEMPDIRNAMES for Windows Vim does not define TEMPDIRNAMES for all systems, but it is defined for all systems supported by Neovim. Temporary directory names for Windows was obtained from GetTempPath() function documentation at MSDN. Additionally small renamings were performed. --- src/nvim/diff.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/nvim/diff.c') 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 -- cgit From 29e0cd1571b773feb7fd61118930cdac7d83e38c Mon Sep 17 00:00:00 2001 From: Pavel Platto Date: Thu, 19 Jun 2014 23:46:51 +0300 Subject: Refactor vim_tempname - temp_count is uint32_t now instead of long because it supposed to be at most 999999999 (comment on line 5227) temporary files. The most probably it was a long for compatibility with systems where int is 16-bit. - Use "nvim" as prefix for temp folder name instead of "v" - Remove unused parameter from vim_tempname --- src/nvim/diff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 0ae3d5553e..37210e447c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -661,9 +661,9 @@ void ex_diffupdate(exarg_T *eap) } // We need three temp file names. - char_u *tmp_orig = vim_tempname('o'); - char_u *tmp_new = vim_tempname('n'); - char_u *tmp_diff = vim_tempname('d'); + char_u *tmp_orig = vim_tempname(); + char_u *tmp_new = vim_tempname(); + char_u *tmp_diff = vim_tempname(); if ((tmp_orig == NULL) || (tmp_new == NULL) || (tmp_diff == NULL)) { goto theend; @@ -852,9 +852,9 @@ void ex_diffpatch(exarg_T *eap) #endif // ifdef UNIX // We need two temp file names. // Name of original temp file. - char_u *tmp_orig = vim_tempname('o'); + char_u *tmp_orig = vim_tempname(); // Name of patched temp file. - char_u *tmp_new = vim_tempname('n'); + char_u *tmp_new = vim_tempname(); if ((tmp_orig == NULL) || (tmp_new == NULL)) { goto theend; -- cgit From 8cfa7b3d15f503ff4fd4fc1df26bca109b31497b Mon Sep 17 00:00:00 2001 From: Pavel Platto Date: Sat, 21 Jun 2014 14:07:51 +0300 Subject: Add vim_gettempdir(), remove global vim_tempdir vim_gettempdir() and vim_maketempdir() was extracted from vim_tempname(). --- src/nvim/diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 37210e447c..be4a923d14 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -893,11 +893,11 @@ void ex_diffpatch(exarg_T *eap) || (os_chdir((char *)dirbuf) != 0)) { dirbuf[0] = NUL; } else { - if (vim_tempdir != NULL) { - ignored = os_chdir((char *)vim_tempdir); - } else { - ignored = os_chdir("/tmp"); + char *tempdir = (char *)vim_gettempdir(); + if (tempdir == NULL) { + tempdir = "/tmp"; } + os_chdir(tempdir); shorten_fnames(TRUE); } #endif // ifdef UNIX -- cgit From 286ce271e730a2e6883c244912b36bca007f6ddc Mon Sep 17 00:00:00 2001 From: Pavel Platto Date: Sun, 22 Jun 2014 13:03:08 +0300 Subject: Extract `tempfile` module from fileio Though this module is relatively small it has very clear boundaries. The last argument for extracting `tempfile` was the errors which I got when I was writing unittests for it: `cimport './src/nvim/fileio.h'` does not work for some reason. --- src/nvim/diff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index be4a923d14..ab0c80112f 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -30,6 +30,7 @@ #include "nvim/path.h" #include "nvim/screen.h" #include "nvim/strings.h" +#include "nvim/tempfile.h" #include "nvim/undo.h" #include "nvim/window.h" #include "nvim/os/os.h" -- cgit