summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/m4/eval.c13
-rw-r--r--usr.bin/m4/misc.c14
-rw-r--r--usr.bin/m4/serv.c12
-rw-r--r--usr.bin/patch/inp.c5
-rw-r--r--usr.bin/patch/patch.c22
-rw-r--r--usr.bin/patch/pch.c13
6 files changed, 23 insertions, 56 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index 2a5b8594941..ef14aa34604 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.4 1996/06/26 05:36:11 deraadt Exp $ */
+/* $OpenBSD: eval.c,v 1.5 1996/07/01 20:40:27 deraadt Exp $ */
/* $NetBSD: eval.c,v 1.5 1996/01/13 23:25:23 pk Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: eval.c,v 1.4 1996/06/26 05:36:11 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: eval.c,v 1.5 1996/07/01 20:40:27 deraadt Exp $";
#endif
#endif /* not lint */
@@ -52,7 +52,6 @@ static char rcsid[] = "$OpenBSD: eval.c,v 1.4 1996/06/26 05:36:11 deraadt Exp $"
*/
#include <sys/types.h>
-#include <sys/file.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
@@ -665,18 +664,12 @@ void
dodiv(n)
register int n;
{
- int fd;
-
if (n < 0 || n >= MAXOUT)
n = 0; /* bitbucket */
if (outfile[n] == NULL) {
m4temp[UNIQUE] = n + '0';
- if ((fd = open(m4temp, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 ||
- (outfile[n] = fdopen(fd, "w")) == NULL) {
- if (fd != -1)
- close(fd);
+ if ((outfile[n] = fopen(m4temp, "w")) == NULL)
oops("%s: cannot divert.", m4temp);
- }
}
oindex = n;
active = outfile[n];
diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c
index 1b161f1c393..da514c1fe60 100644
--- a/usr.bin/m4/misc.c
+++ b/usr.bin/m4/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.3 1996/06/26 05:36:15 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.4 1996/07/01 20:40:28 deraadt Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
@@ -41,12 +41,11 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1996/06/26 05:36:15 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.4 1996/07/01 20:40:28 deraadt Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
-#include <sys/file.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
@@ -155,20 +154,15 @@ int n;
{
register int c;
register FILE *dfil;
- int fd;
if (active == outfile[n])
oops("%s: diversion still active.", "undivert");
(void) fclose(outfile[n]);
outfile[n] = NULL;
m4temp[UNIQUE] = n + '0';
-
- if ((fd = open(m4temp, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 ||
- (dfil = fdopen(fd, "r")) == NULL) {
- if (fd != -1)
- close(fd);
+ if ((dfil = fopen(m4temp, "r")) == NULL)
oops("%s: cannot undivert.", m4temp);
- } else
+ else
while ((c = getc(dfil)) != EOF)
putc(c, active);
(void) fclose(dfil);
diff --git a/usr.bin/m4/serv.c b/usr.bin/m4/serv.c
index f264a550ef4..e423c5987d2 100644
--- a/usr.bin/m4/serv.c
+++ b/usr.bin/m4/serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: serv.c,v 1.3 1996/06/26 05:36:16 deraadt Exp $ */
+/* $OpenBSD: serv.c,v 1.4 1996/07/01 20:40:29 deraadt Exp $ */
/* $NetBSD: serv.c,v 1.7 1995/09/28 05:37:47 tls Exp $ */
/*
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)serv.c 5.4 (Berkeley) 1/21/94";
#else
-static char rcsid[] = "$OpenBSD: serv.c,v 1.3 1996/06/26 05:36:16 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: serv.c,v 1.4 1996/07/01 20:40:29 deraadt Exp $";
#endif
#endif /* not lint */
@@ -337,18 +337,12 @@ register int argc;
dodiv(n)
register int n;
{
- int fd;
-
if (n < 0 || n >= MAXOUT)
n = 0; /* bitbucket */
if (outfile[n] == NULL) {
m4temp[UNIQUE] = n + '0';
- if ((fd = open(m4temp, O_RDWR|O_EXECL|O_CREAT, 0666)) == -1 ||
- (outfile[n] = fdopen(fd, "w")) == NULL) {
- if (fd != -1)
- close(fd);
+ if ((outfile[n] = fopen(m4temp, "w")) == NULL)
error("m4: cannot divert.");
- }
}
oindex = n;
active = outfile[n];
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);