summaryrefslogtreecommitdiff
path: root/usr.bin/rcs/rcsprog.c
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-08-16 07:39:16 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-08-16 07:39:16 +0000
commitdd109580266c56df7b5feb24de5100e6d457579f (patch)
treeb386c6f592769599dd4e9d5d096971816e90aa69 /usr.bin/rcs/rcsprog.c
parent65bc33032d45046943c4d18a409e2c0e7d02b696 (diff)
Improve rcs_buf_load() by setting errno appropriately on failure and
never print errors or quit on error. Fix usages of rcs_buf_load() and rcs_set_description. Also plug an fd leak. OK xsa@
Diffstat (limited to 'usr.bin/rcs/rcsprog.c')
-rw-r--r--usr.bin/rcs/rcsprog.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index dcb72fe07e6..0c6c45a766c 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.131 2006/05/29 21:17:44 ray Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.132 2006/08/16 07:39:15 ray Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -312,13 +312,25 @@ rcs_main(int argc, char **argv)
if (!(rcsflags & QUIET))
(void)fprintf(stderr, "RCS file: %s\n", fpath);
- if ((file = rcs_open(fpath, fd, flags, fmode)) == NULL)
+ if ((file = rcs_open(fpath, fd, flags, fmode)) == NULL) {
+ close(fd);
continue;
+ }
- if (rcsflags & DESCRIPTION)
- rcs_set_description(file, descfile);
- else if (flags & RCS_CREATE)
- rcs_set_description(file, NULL);
+ if (rcsflags & DESCRIPTION) {
+ if (rcs_set_description(file, descfile) == -1) {
+ warn("%s", descfile);
+ rcs_close(file);
+ continue;
+ }
+ }
+ else if (flags & RCS_CREATE) {
+ if (rcs_set_description(file, NULL) == -1) {
+ warn("stdin");
+ rcs_close(file);
+ continue;
+ }
+ }
if (rcsflags & PRESERVETIME)
rcs_mtime = rcs_get_mtime(file);