summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-05-27 05:49:15 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-05-27 05:49:15 +0000
commit21be1db1b7c2070593e7732c1c3d20c574a7845d (patch)
tree8e2cda7a29306dd5aa527f2feca80a41aa42fc93
parent43205cef80d4f7ad59a6a71c15a3202e9191ab95 (diff)
Remove rcs_statfile(). It was just a wrapper for rcs_choosefile(),
handling exceptions oddly. OK joris@
-rw-r--r--usr.bin/rcs/ci.c18
-rw-r--r--usr.bin/rcs/co.c8
-rw-r--r--usr.bin/rcs/rcsclean.c4
-rw-r--r--usr.bin/rcs/rcsdiff.c8
-rw-r--r--usr.bin/rcs/rcsmerge.c6
-rw-r--r--usr.bin/rcs/rcsprog.c18
-rw-r--r--usr.bin/rcs/rcsutil.c23
-rw-r--r--usr.bin/rcs/rcsutil.h3
-rw-r--r--usr.bin/rcs/rlog.c8
9 files changed, 37 insertions, 59 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index d35fe2a77a2..c2103f85b6c 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.174 2006/05/17 19:37:40 xsa Exp $ */
+/* $OpenBSD: ci.c,v 1.175 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -235,12 +235,8 @@ checkin_main(int argc, char **argv)
if ((workfile_fd = open(pb.filename, O_RDONLY)) == -1)
err(1, "%s", pb.filename);
- /*
- * Test for existence of ,v file. If we are expected to
- * create one, set NEWFILE flag.
- */
- fd = rcs_statfile(pb.filename, pb.fpath, sizeof(pb.fpath),
- pb.flags);
+ /* Find RCS file path. */
+ fd = rcs_choosefile(pb.filename, pb.fpath, sizeof(pb.fpath));
if (fd < 0) {
if (pb.openflags & RCS_CREATE)
@@ -262,14 +258,6 @@ checkin_main(int argc, char **argv)
pb.openflags &= ~RCS_CREATE;
}
- /*
- * If we are to create a new ,v file, we must decide where it
- * should go.
- */
- if (pb.flags & NEWFILE)
- fd = rcs_choosefile(pb.filename,
- pb.fpath, sizeof(pb.fpath));
-
pb.file = rcs_open(pb.fpath, fd, pb.openflags, pb.fmode);
if (pb.file == NULL)
errx(1, "failed to open rcsfile `%s'", pb.fpath);
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 4202937c27f..914880d8904 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.91 2006/05/17 19:37:40 xsa Exp $ */
+/* $OpenBSD: co.c,v 1.92 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -151,9 +151,11 @@ checkout_main(int argc, char **argv)
err(1, "getlogin");
for (i = 0; i < argc; i++) {
- fd = rcs_statfile(argv[i], fpath, sizeof(fpath), flags);
- if (fd < 0)
+ fd = rcs_choosefile(argv[i], fpath, sizeof(fpath));
+ if (fd < 0) {
+ warnx("%s", fpath);
continue;
+ }
if (!(flags & QUIET))
(void)fprintf(stderr, "%s --> %s\n", fpath,
diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c
index 634d53c78af..91d424762db 100644
--- a/usr.bin/rcs/rcsclean.c
+++ b/usr.bin/rcs/rcsclean.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsclean.c,v 1.46 2006/05/09 12:33:42 ray Exp $ */
+/* $OpenBSD: rcsclean.c,v 1.47 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -137,7 +137,7 @@ rcsclean_file(char *fname, const char *rev_str)
file = NULL;
rev = NULL;
- if ((fd = rcs_statfile(fname, fpath, sizeof(fpath), flags)) < 0)
+ if ((fd = rcs_choosefile(fname, fpath, sizeof(fpath))) < 0)
goto out;
if ((file = rcs_open(fpath, fd, RCS_RDWR)) == NULL)
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index 5e414452082..63ab036f468 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.64 2006/05/09 12:33:42 ray Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.65 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -115,9 +115,11 @@ rcsdiff_main(int argc, char **argv)
}
for (i = 0; i < argc; i++) {
- fd = rcs_statfile(argv[i], fpath, sizeof(fpath), flags);
- if (fd < 0)
+ fd = rcs_choosefile(argv[i], fpath, sizeof(fpath));
+ if (fd < 0) {
+ warnx("%s", fpath);
continue;
+ }
if ((file = rcs_open(fpath, fd,
RCS_READ|RCS_PARSE_FULLY)) == NULL)
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c
index cff23ff4270..312aafe5700 100644
--- a/usr.bin/rcs/rcsmerge.c
+++ b/usr.bin/rcs/rcsmerge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsmerge.c,v 1.45 2006/05/14 15:23:10 xsa Exp $ */
+/* $OpenBSD: rcsmerge.c,v 1.46 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -107,8 +107,8 @@ rcsmerge_main(int argc, char **argv)
if (argc > 2 || (argc == 2 && argv[1] != NULL))
warnx("warning: excess arguments ignored");
- if ((fd = rcs_statfile(argv[0], fpath, sizeof(fpath), flags)) < 0)
- return (status);
+ if ((fd = rcs_choosefile(argv[0], fpath, sizeof(fpath))) < 0)
+ errx(status, "%s", fpath);
if (!(flags & QUIET))
(void)fprintf(stderr, "RCS file: %s\n", fpath);
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index 07aa2a9cfe5..0f58ce68da3 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.127 2006/05/19 07:52:38 xsa Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.128 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -202,10 +202,14 @@ rcs_main(int argc, char **argv)
while ((ch = rcs_getopt(argc, argv, RCSPROG_OPTSTRING)) != -1) {
switch (ch) {
case 'A':
- ofd = rcs_statfile(rcs_optarg, ofpath,
- sizeof(ofpath), flags);
- if (ofd < 0)
+ /* XXX - Should we process this after all flags? */
+ ofd = rcs_choosefile(rcs_optarg, ofpath,
+ sizeof(ofpath));
+ if (ofd < 0) {
+ if (!(flags & RCS_CREATE))
+ warnx("%s", ofpath);
exit(1);
+ }
rcsflags |= CO_ACLAPPEND;
break;
case 'a':
@@ -303,9 +307,11 @@ rcs_main(int argc, char **argv)
}
for (i = 0; i < argc; i++) {
- fd = rcs_statfile(argv[i], fpath, sizeof(fpath), flags);
- if (fd < 0 && !(flags & RCS_CREATE))
+ fd = rcs_choosefile(argv[i], fpath, sizeof(fpath));
+ if (fd < 0 && !(flags & RCS_CREATE)) {
+ warnx("%s", fpath);
continue;
+ }
if (!(rcsflags & QUIET))
(void)fprintf(stderr, "RCS file: %s\n", fpath);
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index dbffca483c3..b8542fa1959 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.11 2006/05/27 02:58:02 ray Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.12 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -267,27 +267,6 @@ rcs_choosefile(const char *filename, char *out, size_t len)
}
/*
- * Find the name of an RCS file, given a file name `fname'. If an RCS
- * file is found, the name is copied to the `len' sized buffer `out'.
- * Returns 0 if RCS file was found, -1 otherwise.
- */
-int
-rcs_statfile(char *fname, char *out, size_t len, int flags)
-{
- int fd;
-
- fd = rcs_choosefile(fname, out, len);
- if (fd == -1 && !(flags & RCS_CREATE)) {
- if (strcmp(__progname, "rcsclean") != 0 &&
- strcmp(__progname, "ci") != 0)
- warnx("%s", out);
- return (-1);
- }
-
- return (fd);
-}
-
-/*
* Allocate an RCSNUM and store in <rev>.
*/
void
diff --git a/usr.bin/rcs/rcsutil.h b/usr.bin/rcs/rcsutil.h
index 977e370431a..b7d2e703458 100644
--- a/usr.bin/rcs/rcsutil.h
+++ b/usr.bin/rcs/rcsutil.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.h,v 1.4 2006/04/27 07:59:33 xsa Exp $ */
+/* $OpenBSD: rcsutil.h,v 1.5 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -52,7 +52,6 @@ struct rcs_argvector {
int rcs_getopt(int, char **, const char *);
void rcs_set_mtime(RCSFILE *, time_t);
int rcs_choosefile(const char *, char *, size_t);
-int rcs_statfile(char *, char *, size_t, int);
time_t rcs_get_mtime(RCSFILE *);
RCSNUM *rcs_getrevnum(const char *, RCSFILE *);
char *rcs_prompt(const char *);
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index f53fb27e892..53898cda822 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.54 2006/05/09 12:33:42 ray Exp $ */
+/* $OpenBSD: rlog.c,v 1.55 2006/05/27 05:49:14 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -136,9 +136,11 @@ rlog_main(int argc, char **argv)
}
for (i = 0; i < argc; i++) {
- fd = rcs_statfile(argv[i], fpath, sizeof(fpath), 0);
- if (fd < 0)
+ fd = rcs_choosefile(argv[i], fpath, sizeof(fpath));
+ if (fd < 0) {
+ warnx("%s", fpath);
continue;
+ }
if ((file = rcs_open(fpath, fd,
RCS_READ|RCS_PARSE_FULLY)) == NULL)