summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/inp.c5
-rw-r--r--usr.bin/patch/patch.c22
-rw-r--r--usr.bin/patch/pch.c13
3 files changed, 13 insertions, 27 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 34a93b590a6..86c3b3759a6 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: inp.c,v 1.3 1996/06/25 23:06:38 deraadt Exp $ */
+/* $OpenBSD: inp.c,v 1.4 1996/07/01 20:40:07 deraadt Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: inp.c,v 1.3 1996/06/25 23:06:38 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.4 1996/07/01 20:40:07 deraadt Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -241,6 +241,7 @@ char *filename;
using_plan_a = FALSE;
if ((ifp = fopen(filename, "r")) == Nullfp)
pfatal2("can't open file %s", filename);
+ (void) unlink(TMPINNAME);
if ((tifd = open(TMPINNAME, O_EXCL|O_CREAT|O_WRONLY, 0666)) < 0)
pfatal2("can't open file %s", TMPINNAME);
while (fgets(buf, sizeof buf, ifp) != Nullch) {
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index dcfb1213cca..dfbe51cba76 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.3 1996/06/25 23:06:39 deraadt Exp $ */
+/* $OpenBSD: patch.c,v 1.4 1996/07/01 20:40:09 deraadt Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -9,7 +9,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: patch.c,v 1.3 1996/06/25 23:06:39 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.4 1996/07/01 20:40:09 deraadt Exp $";
#endif /* not lint */
#include "INTERN.h"
@@ -784,14 +784,9 @@ void
init_output(name)
char *name;
{
- int fd;
-
- if ((fd = open(name, O_EXCL|O_CREAT|O_RDWR, 0666)) == -1 ||
- (ofp = fdopen(fd, "w")) == NULL) {
- if (fd != -1)
- close(fd);
+ ofp = fopen(name, "w");
+ if (ofp == Nullfp)
pfatal2("can't create %s", name);
- }
}
/* Open a file to put hunks we can't locate. */
@@ -800,14 +795,9 @@ void
init_reject(name)
char *name;
{
- int fd;
-
- if ((fd = open(name, O_EXCL|O_CREAT|O_RDWR, 0666)) == -1 ||
- (rejfp = fdopen(fd, "w")) == NULL) {
- if (fd != -1)
- close(fd);
+ rejfp = fopen(name, "w");
+ if (rejfp == Nullfp)
pfatal2("can't create %s", name);
- }
}
/* Copy input file to output, up to wherever hunk is to be applied. */
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 4d2200dc61a..38225fa648a 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: pch.c,v 1.3 1996/06/25 23:06:41 deraadt Exp $ */
+/* $OpenBSD: pch.c,v 1.4 1996/07/01 20:40:10 deraadt Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: pch.c,v 1.3 1996/06/25 23:06:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pch.c,v 1.4 1996/07/01 20:40:10 deraadt Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -54,15 +54,10 @@ void
open_patch_file(filename)
char *filename;
{
- int fd;
-
if (filename == Nullch || !*filename || strEQ(filename, "-")) {
- if ((fd = open(TMPPATNAME, O_EXCL|O_CREAT|O_RDWR, 0666)) == -1 ||
- (pfp = fdopen(fd, "w")) == NULL) {
- if (fd != -1)
- close(fd);
+ pfp = fopen(TMPPATNAME, "w");
+ if (pfp == Nullfp)
pfatal2("can't create %s", TMPPATNAME);
- }
while (fgets(buf, sizeof buf, stdin) != Nullch)
fputs(buf, pfp);
Fclose(pfp);