diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/ci.c | 6 | ||||
-rw-r--r-- | usr.bin/rcs/co.c | 9 | ||||
-rw-r--r-- | usr.bin/rcs/rcsclean.c | 48 | ||||
-rw-r--r-- | usr.bin/rcs/rcsdiff.c | 6 | ||||
-rw-r--r-- | usr.bin/rcs/rcsmerge.c | 12 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 21 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.h | 3 |
7 files changed, 63 insertions, 42 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 2a68f687088..d8408bacd0d 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.140 2006/04/12 08:27:31 deraadt Exp $ */ +/* $OpenBSD: ci.c,v 1.141 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -277,7 +277,9 @@ checkin_main(int argc, char **argv) /* XXX - Should we rcsnum_free(pb.newrev)? */ if (rev_str != NULL) - rcs_set_rev(rev_str, &pb.newrev); + if ((pb.newrev = rcs_getrevnum(rev_str, pb.file)) == + NULL) + fatal("invalid revision: %s", rev_str); if (pb.flags & NEWFILE) status = checkin_init(&pb); diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index f16aae93e25..7664ac914b1 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.74 2006/04/12 08:27:31 deraadt Exp $ */ +/* $OpenBSD: co.c,v 1.75 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -176,9 +176,10 @@ checkout_main(int argc, char **argv) rcs_kwexp_set(file, kflag); - if (rev_str != NULL) - rcs_set_rev(rev_str, &rev); - else { + if (rev_str != NULL) { + if ((rev = rcs_getrevnum(rev_str, file)) == NULL) + fatal("invalid revision: %s", rev_str); + } else { rev = rcsnum_alloc(); rcsnum_cpy(file->rf_head, rev, 0); } diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c index 83a76f96f3c..df53c33aff6 100644 --- a/usr.bin/rcs/rcsclean.c +++ b/usr.bin/rcs/rcsclean.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsclean.c,v 1.30 2006/04/12 08:23:30 ray Exp $ */ +/* $OpenBSD: rcsclean.c,v 1.31 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -29,7 +29,7 @@ #include "rcsprog.h" #include "diff.h" -static void rcsclean_file(char *, RCSNUM *); +static void rcsclean_file(char *, const char *); static int nflag = 0; static int kflag = RCS_KWEXP_ERR; @@ -107,18 +107,13 @@ rcsclean_main(int argc, char **argv) while ((dp = readdir(dirp)) != NULL) { if (dp->d_type == DT_DIR) continue; - rcs_set_rev(rev_str, &rev); - rcsclean_file(dp->d_name, rev); - rcsnum_free(rev); + rcsclean_file(dp->d_name, rev_str); } closedir(dirp); } else - for (i = 0; i < argc; i++) { - rcs_set_rev(rev_str, &rev); - rcsclean_file(argv[i], rev); - rcsnum_free(rev); - } + for (i = 0; i < argc; i++) + rcsclean_file(argv[i], rev_str); return (0); } @@ -132,14 +127,14 @@ rcsclean_usage(void) } static void -rcsclean_file(char *fname, RCSNUM *rev) +rcsclean_file(char *fname, const char *rev_str) { int match; RCSFILE *file; char fpath[MAXPATHLEN], numb[64]; - RCSNUM *frev; + RCSNUM *rev; BUF *b1, *b2; - char *s1, *s2, *c1, *c2; + char *c1, *c2; struct stat st; time_t rcs_mtime = -1; @@ -159,12 +154,16 @@ rcsclean_file(char *fname, RCSNUM *rev) rcs_kwexp_set(file, kflag); - if (rev == RCS_HEAD_REV) - frev = file->rf_head; - else - frev = rev; + if (rev_str == NULL) + rev = file->rf_head; + else if ((rev = rcs_getrevnum(rev_str, file)) == NULL) { + cvs_log(LP_ERR, "%s: Symbolic name `%s' is undefined.", + fpath, rev_str); + rcs_close(file); + return; + } - if ((b1 = rcs_getrev(file, frev)) == NULL) { + if ((b1 = rcs_getrev(file, rev)) == NULL) { cvs_log(LP_ERR, "failed to get needed revision"); rcs_close(file); return; @@ -182,12 +181,9 @@ rcsclean_file(char *fname, RCSNUM *rev) c1 = cvs_buf_release(b1); c2 = cvs_buf_release(b2); - for (s1 = c1, s2 = c2; *s1 && *s2; s1++, s2++) { - if (*s1 != *s2) { - match = 0; - break; - } - } + /* XXX - Compare using cvs_buf_len() first. */ + if (strcmp(c1, c2) != 0) + match = 0; xfree(c1); xfree(c2); @@ -196,10 +192,10 @@ rcsclean_file(char *fname, RCSNUM *rev) if ((uflag == 1) && (!TAILQ_EMPTY(&(file->rf_locks)))) { if ((verbose == 1) && (nflag == 0)) { printf("rcs -u%s %s\n", - rcsnum_tostr(frev, numb, sizeof(numb)), + rcsnum_tostr(rev, numb, sizeof(numb)), fpath); } - (void)rcs_lock_remove(file, locker, frev); + (void)rcs_lock_remove(file, locker, rev); } if (TAILQ_EMPTY(&(file->rf_locks))) { diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c index fa9b3f0f8b3..4c6cabbb204 100644 --- a/usr.bin/rcs/rcsdiff.c +++ b/usr.bin/rcs/rcsdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsdiff.c,v 1.46 2006/04/12 08:23:30 ray Exp $ */ +/* $OpenBSD: rcsdiff.c,v 1.47 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -118,11 +118,11 @@ rcsdiff_main(int argc, char **argv) rcs_kwexp_set(file, kflag); if (rev_str1 != NULL) { - if ((rev1 = rcsnum_parse(rev_str1)) == NULL) + if ((rev1 = rcs_getrevnum(rev_str1, file)) == NULL) fatal("bad revision number"); } if (rev_str2 != NULL) { - if ((rev2 = rcsnum_parse(rev_str2)) == NULL) + if ((rev2 = rcs_getrevnum(rev_str2, file)) == NULL) fatal("bad revision number"); } diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c index 4d591d11bd2..2ea3d2d4820 100644 --- a/usr.bin/rcs/rcsmerge.c +++ b/usr.bin/rcs/rcsmerge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsmerge.c,v 1.24 2006/04/12 08:23:30 ray Exp $ */ +/* $OpenBSD: rcsmerge.c,v 1.25 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * All rights reserved. @@ -122,10 +122,12 @@ rcsmerge_main(int argc, char **argv) rev2 = NULL; } - rcs_set_rev(rev_str1, &rev1); - if (rev_str2 != NULL) - rcs_set_rev(rev_str2, &rev2); - else { + if ((rev1 = rcs_getrevnum(rev_str1, file)) == NULL) + fatal("invalid revision: %s", rev_str1); + if (rev_str2 != NULL) { + if ((rev2 = rcs_getrevnum(rev_str2, file)) == NULL) + fatal("invalid revision: %s", rev_str2); + } else { rev2 = rcsnum_alloc(); rcsnum_cpy(file->rf_head, rev2, 0); } diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 42cb17d6614..842d9bbe4a8 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.98 2006/04/12 22:54:23 ray Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.99 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -388,6 +388,25 @@ rcs_setrevstr2(char **str1, char **str2, char *new_str) fatal("too many revision numbers"); } +/* + * Get revision from file. The revision can be specified as a symbol or + * a revision number. + */ +RCSNUM * +rcs_getrevnum(const char *rev_str, RCSFILE *file) +{ + RCSNUM *rev; + + /* Search for symbol. */ + rev = rcs_sym_getrev(file, rev_str); + + /* Search for revision number. */ + if (rev == NULL) + rev = rcsnum_parse(rev_str); + + return (rev); +} + int main(int argc, char **argv) { diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h index b343a821401..c9803614317 100644 --- a/usr.bin/rcs/rcsprog.h +++ b/usr.bin/rcs/rcsprog.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.h,v 1.45 2006/04/12 08:27:31 deraadt Exp $ */ +/* $OpenBSD: rcsprog.h,v 1.46 2006/04/13 00:58:25 ray Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -112,6 +112,7 @@ void rcs_set_mtime(const char *, time_t); char *rcs_choosefile(const char *); int rcs_statfile(char *, char *, size_t); time_t rcs_get_mtime(const char *); +RCSNUM *rcs_getrevnum(const char *, RCSFILE *); void rcs_set_rev(const char *, RCSNUM **); void rcs_setrevstr(char **, char *); void rcs_setrevstr2(char **, char **, char *); |