summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-03-31 13:33:08 +0200
committerBram Moolenaar <Bram@vim.org>2015-03-31 13:33:08 +0200
commite5c421cfd70a4d864faa0fac4e9f2dd6cdf5881d (patch)
tree77b845e567cd28c87bf4e9226384cccf04ab645b /src
parent1ca2e361a869c58a775b5fabb2aaf4e2675ea7ba (diff)
downloadvim-git-e5c421cfd70a4d864faa0fac4e9f2dd6cdf5881d.tar.gz
updated for version 7.4.684v7.4.684
Problem: When starting several Vim instances in diff mode, the temp files used may not be unique. (Issue 353) Solution: Add an argument to vim_tempname() to keep the file.
Diffstat (limited to 'src')
-rw-r--r--src/diff.c10
-rw-r--r--src/eval.c4
-rw-r--r--src/ex_cmds.c6
-rw-r--r--src/fileio.c15
-rw-r--r--src/hardcopy.c2
-rw-r--r--src/if_cscope.c2
-rw-r--r--src/memline.c2
-rw-r--r--src/misc1.c2
-rw-r--r--src/os_unix.c2
-rw-r--r--src/proto/fileio.pro2
-rw-r--r--src/quickfix.c2
-rw-r--r--src/spell.c2
-rw-r--r--src/version.c2
13 files changed, 29 insertions, 24 deletions
diff --git a/src/diff.c b/src/diff.c
index caee6e5a5..aec54c2b0 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -688,9 +688,9 @@ ex_diffupdate(eap)
return;
/* We need three temp file names. */
- tmp_orig = vim_tempname('o');
- tmp_new = vim_tempname('n');
- tmp_diff = vim_tempname('d');
+ tmp_orig = vim_tempname('o', TRUE);
+ tmp_new = vim_tempname('n', TRUE);
+ tmp_diff = vim_tempname('d', TRUE);
if (tmp_orig == NULL || tmp_new == NULL || tmp_diff == NULL)
goto theend;
@@ -920,8 +920,8 @@ ex_diffpatch(eap)
#endif
/* We need two temp file names. */
- tmp_orig = vim_tempname('o');
- tmp_new = vim_tempname('n');
+ tmp_orig = vim_tempname('o', FALSE);
+ tmp_new = vim_tempname('n', FALSE);
if (tmp_orig == NULL || tmp_new == NULL)
goto theend;
diff --git a/src/eval.c b/src/eval.c
index ebd7e379e..5b06a30a5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -18775,7 +18775,7 @@ get_cmd_output_as_rettv(argvars, rettv, retlist)
* Write the string to a temp file, to be used for input of the shell
* command.
*/
- if ((infile = vim_tempname('i')) == NULL)
+ if ((infile = vim_tempname('i', TRUE)) == NULL)
{
EMSG(_(e_notmp));
goto errret;
@@ -19134,7 +19134,7 @@ f_tempname(argvars, rettv)
static int x = 'A';
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = vim_tempname(x);
+ rettv->vval.v_string = vim_tempname(x, FALSE);
/* Advance 'x' to use A-Z and 0-9, so that there are at least 34 different
* names. Skip 'I' and 'O', they are used for shell redirection. */
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index ef0ec1ffe..978d516f7 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1158,8 +1158,8 @@ do_filter(line1, line2, eap, cmd, do_in, do_out)
}
else
#endif
- if ((do_in && (itmp = vim_tempname('i')) == NULL)
- || (do_out && (otmp = vim_tempname('o')) == NULL))
+ if ((do_in && (itmp = vim_tempname('i', FALSE)) == NULL)
+ || (do_out && (otmp = vim_tempname('o', FALSE)) == NULL))
{
EMSG(_(e_notmp));
goto filterend;
@@ -1963,7 +1963,7 @@ write_viminfo(file, forceit)
if (fp_out == NULL)
{
vim_free(tempname);
- if ((tempname = vim_tempname('o')) != NULL)
+ if ((tempname = vim_tempname('o', TRUE)) != NULL)
fp_out = mch_fopen((char *)tempname, WRITEBIN);
}
diff --git a/src/fileio.c b/src/fileio.c
index 388446a48..9965920c5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2872,7 +2872,7 @@ readfile_charconvert(fname, fenc, fdp)
char_u *tmpname;
char_u *errmsg = NULL;
- tmpname = vim_tempname('r');
+ tmpname = vim_tempname('r', FALSE);
if (tmpname == NULL)
errmsg = (char_u *)_("Can't find temp file for conversion");
else
@@ -4288,7 +4288,7 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
*/
if (*p_ccv != NUL)
{
- wfname = vim_tempname('w');
+ wfname = vim_tempname('w', FALSE);
if (wfname == NULL) /* Can't write without a tempfile! */
{
errmsg = (char_u *)_("E214: Can't find temp file for writing");
@@ -7344,14 +7344,16 @@ vim_settempdir(tempdir)
/*
* vim_tempname(): Return a unique name that can be used for a temp file.
*
- * The temp file is NOT created.
+ * The temp file is NOT garanteed to be created. If "keep" is FALSE it is
+ * garanteed to NOT be created.
*
* The returned pointer is to allocated memory.
* The returned pointer is NULL if no valid name was found.
*/
char_u *
-vim_tempname(extra_char)
+vim_tempname(extra_char, keep)
int extra_char UNUSED; /* char to use in the name instead of '?' */
+ int keep UNUSED;
{
#ifdef USE_TMPNAM
char_u itmp[L_tmpnam]; /* use tmpnam() */
@@ -7487,8 +7489,9 @@ vim_tempname(extra_char)
buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */
if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
return NULL;
- /* GetTempFileName() will create the file, we don't want that */
- (void)DeleteFile(itmp);
+ if (!keep)
+ /* GetTempFileName() will create the file, we don't want that */
+ (void)DeleteFile(itmp);
/* Backslashes in a temp file name cause problems when filtering with
* "sh". NOTE: This also checks 'shellcmdflag' to help those people who
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 1e795e6b5..95a367d49 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -2751,7 +2751,7 @@ mch_print_init(psettings, jobname, forceit)
/* If the user didn't specify a file name, use a temp file. */
if (psettings->outfile == NULL)
{
- prt_ps_file_name = vim_tempname('p');
+ prt_ps_file_name = vim_tempname('p', TRUE);
if (prt_ps_file_name == NULL)
{
EMSG(_(e_notmp));
diff --git a/src/if_cscope.c b/src/if_cscope.c
index f72a96b9c..2b4ba0813 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -1269,7 +1269,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline)
{
/* fill error list */
FILE *f;
- char_u *tmp = vim_tempname('c');
+ char_u *tmp = vim_tempname('c', TRUE);
qf_info_T *qi = NULL;
win_T *wp = NULL;
diff --git a/src/memline.c b/src/memline.c
index d62697d6b..730496c18 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -757,7 +757,7 @@ ml_open_file(buf)
/* For a spell buffer use a temp file name. */
if (buf->b_spell)
{
- fname = vim_tempname('s');
+ fname = vim_tempname('s', FALSE);
if (fname != NULL)
(void)mf_open_file(mfp, fname); /* consumes fname! */
buf->b_may_swap = FALSE;
diff --git a/src/misc1.c b/src/misc1.c
index bd1fe255b..5a3451319 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -11049,7 +11049,7 @@ get_cmd_output(cmd, infile, flags, ret_len)
return NULL;
/* get a name for the temp file */
- if ((tempname = vim_tempname('o')) == NULL)
+ if ((tempname = vim_tempname('o', FALSE)) == NULL)
{
EMSG(_(e_notmp));
return NULL;
diff --git a/src/os_unix.c b/src/os_unix.c
index df045a50f..57c013f50 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5838,7 +5838,7 @@ mch_expand_wildcards(num_pat, pat, num_file, file, flags)
/*
* get a name for the temp file
*/
- if ((tempname = vim_tempname('o')) == NULL)
+ if ((tempname = vim_tempname('o', FALSE)) == NULL)
{
EMSG(_(e_notmp));
return FAIL;
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
index 45e7b3872..32d7bce31 100644
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -23,7 +23,7 @@ void buf_reload __ARGS((buf_T *buf, int orig_mode));
void buf_store_time __ARGS((buf_T *buf, struct stat *st, char_u *fname));
void write_lnum_adjust __ARGS((linenr_T offset));
void vim_deltempdir __ARGS((void));
-char_u *vim_tempname __ARGS((int extra_char));
+char_u *vim_tempname __ARGS((int extra_char, int keep));
void forward_slash __ARGS((char_u *fname));
void aubuflocal_remove __ARGS((buf_T *buf));
int au_has_group __ARGS((char_u *name));
diff --git a/src/quickfix.c b/src/quickfix.c
index abb4a6ecf..186520a9f 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2945,7 +2945,7 @@ get_mef_name()
if (*p_mef == NUL)
{
- name = vim_tempname('e');
+ name = vim_tempname('e', FALSE);
if (name == NULL)
EMSG(_(e_notmp));
return name;
diff --git a/src/spell.c b/src/spell.c
index 31bfa952f..80a7d18fe 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -9426,7 +9426,7 @@ spell_add_word(word, len, bad, idx, undo)
{
if (int_wordlist == NULL)
{
- int_wordlist = vim_tempname('s');
+ int_wordlist = vim_tempname('s', FALSE);
if (int_wordlist == NULL)
return;
}
diff --git a/src/version.c b/src/version.c
index a4729caf8..f4ed01a64 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 684,
+/**/
683,
/**/
682,