summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/rcs.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2010-10-20 19:53:54 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2010-10-20 19:53:54 +0000
commit4bb524a26cf8dbc3f4e455b25d68b291c57a5466 (patch)
tree5f9f06acb1fa9fb2a8b326d68449b3895f59189f /usr.bin/cvs/rcs.c
parent0e7638169c58781079efc0eab384dbe94783283a (diff)
Remove the need for rp_file in parser structure, instead keep only one
FILE pointer in RCSFILE. This fixes some ugliness in closing an fdopen()ed FILE and its underlying file descriptor. Notified by Joerg Sonnenberger <joerg at britannica dot bec to de> discussed with and ok nicm
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r--usr.bin/cvs/rcs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index cf497afb73c..ebffcca0445 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.304 2010/10/15 08:46:23 tobias Exp $ */
+/* $OpenBSD: rcs.c,v 1.305 2010/10/20 19:53:53 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -176,7 +176,10 @@ rcs_open(const char *path, int fd, int flags, ...)
rfp->rf_path = xstrdup(path);
rfp->rf_flags = flags | RCS_SLOCK | RCS_SYNCED;
rfp->rf_mode = fmode;
- rfp->rf_fd = fd;
+ if (fd == -1)
+ rfp->rf_file = NULL;
+ else if ((rfp->rf_file = fdopen(fd, "r")) == NULL)
+ fatal("rcs_open: %s: fdopen: %s", path, strerror(errno));
rfp->rf_dead = 0;
TAILQ_INIT(&(rfp->rf_delta));
@@ -252,6 +255,8 @@ rcs_close(RCSFILE *rfp)
if (rfp->rf_branch != NULL)
rcsnum_free(rfp->rf_branch);
+ if (rfp->rf_file != NULL)
+ fclose(rfp->rf_file);
if (rfp->rf_path != NULL)
xfree(rfp->rf_path);
if (rfp->rf_comment != NULL)