summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-09-16 16:52:45 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-09-17 01:46:02 +0200
commit51147ca57dde618fc348b0fab3902f21007da644 (patch)
treed8f1629b2c27732613faa279573ba975da82f538
parent4b6267d62f56161d0242bef85a7d72d1e16c1d0f (diff)
downloadpatch-51147ca57dde618fc348b0fab3902f21007da644.tar.gz
Stop using mktemp() for TMPINNAME
* src/inp.c (plan_b): Compute TMPINNAME with make_tempfile() if needed instead of precomputing it in src/patch.c (main).
-rw-r--r--ChangeLog3
-rw-r--r--src/inp.c16
-rw-r--r--src/patch.c1
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 95e8688..19af831 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,9 @@
* bootstrap.conf: Use the gnulib tempname module.
* src/util.c (make_tempfile): New function.
+ * src/inp.c (plan_b): Compute TMPINNAME with make_tempfile() if needed
+ instead of precomputing it in src/patch.c (main).
+
2010-07-27 Tim Waugh <twaugh@redhat.com>
* src/patch.c: Stops "patch --get 1" from segfaulting.
diff --git a/src/inp.c b/src/inp.c
index fb262f1..8507d09 100644
--- a/src/inp.c
+++ b/src/inp.c
@@ -353,16 +353,22 @@ plan_b (char const *filename)
char const *rev;
size_t revlen;
lin line = 1;
- int exclusive;
if (instat.st_size == 0)
filename = NULL_DEVICE;
if (! (ifp = fopen (filename, binary_transput ? "rb" : "r")))
pfatal ("Can't open file %s", quotearg (filename));
- exclusive = TMPINNAME_needs_removal ? 0 : O_EXCL;
- TMPINNAME_needs_removal = 1;
- tifd = create_file (TMPINNAME, O_RDWR | O_BINARY | exclusive, (mode_t) 0,
- true);
+ if (TMPINNAME_needs_removal)
+ {
+ /* Reopen the existing temporary file. */
+ tifd = create_file (TMPINNAME, O_RDWR | O_BINARY, 0, true);
+ }
+ else
+ {
+ tifd = make_tempfile (&TMPINNAME, 'i', NULL, O_RDWR | O_BINARY,
+ S_IRUSR | S_IWUSR);
+ TMPINNAME_needs_removal = 1;
+ }
i = 0;
len = 0;
maxlen = 1;
diff --git a/src/patch.c b/src/patch.c
index 4f9562d..8f1a03a 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -140,7 +140,6 @@ main (int argc, char **argv)
/* Cons up the names of the global temporary files.
Do this before `cleanup' can possibly be called (e.g. by `pfatal'). */
TMPOUTNAME = make_temp ('o');
- TMPINNAME = make_temp ('i');
TMPREJNAME = make_temp ('r');
TMPPATNAME = make_temp ('p');