diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2005-10-18 01:22:15 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2005-10-18 01:22:15 +0000 |
commit | 3e3f56b0a6c8f5f053f6a2a188676a5e1ed64295 (patch) | |
tree | 708d9f91a84c1eed0b7c7c6e641379d1f96bf874 /usr.bin | |
parent | ca9e031aa8f1babfe7e3a3579d5b02e315ff433c (diff) |
use rcs_set_rev() instead of duplicating code all over the
place to set a variable to the given revision number;
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/ci.c | 30 | ||||
-rw-r--r-- | usr.bin/rcs/co.c | 42 | ||||
-rw-r--r-- | usr.bin/rcs/rcsclean.c | 7 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 14 | ||||
-rw-r--r-- | usr.bin/rcs/rcsprog.h | 3 |
5 files changed, 27 insertions, 69 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 752c02fd5a8..0f5299a6fef 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.44 2005/10/18 01:10:28 joris Exp $ */ +/* $OpenBSD: ci.c,v 1.45 2005/10/18 01:22:14 joris Exp $ */ /* * Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -102,24 +102,14 @@ checkin_main(int argc, char **argv) } break; case 'f': - if (rcs_optarg != NULL) { - if ((newrev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit(1); - } - } + rcs_set_rev(rcs_optarg, &newrev); force = 1; break; case 'h': (usage)(); exit(0); case 'l': - if (rcs_optarg != NULL) { - if ((newrev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit(1); - } - } + rcs_set_rev(rcs_optarg, &newrev); lkmode = LOCK_LOCK; break; case 'm': @@ -151,21 +141,11 @@ checkin_main(int argc, char **argv) verbose = 0; break; case 'r': + rcs_set_rev(rcs_optarg, &newrev); rflag = 1; - if (rcs_optarg != NULL) { - if ((newrev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit(1); - } - } break; case 'u': - if (rcs_optarg != NULL) { - if ((newrev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit(1); - } - } + rcs_set_rev(rcs_optarg, &newrev); lkmode = LOCK_UNLOCK; break; case 'V': diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index 0bf353dfe72..3173ae021c3 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.18 2005/10/17 15:33:12 joris Exp $ */ +/* $OpenBSD: co.c,v 1.19 2005/10/18 01:22:14 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -61,53 +61,21 @@ checkout_main(int argc, char **argv) while ((ch = rcs_getopt(argc, argv, "f::l::qr::u::V")) != -1) { switch (ch) { case 'f': - if (rev != RCS_HEAD_REV) - cvs_log(LP_WARN, - "redefinition of revision number"); - if (rcs_optarg != NULL) { - if ((rev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit (1); - } - } + rcs_set_rev(rcs_optarg, &rev); fflag = 1; break; case 'l': - if (rev != RCS_HEAD_REV) - cvs_log(LP_WARN, - "redefinition of revision number"); - if (rcs_optarg != NULL) { - if ((rev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit (1); - } - } + rcs_set_rev(rcs_optarg, &rev); lock = LOCK_LOCK; break; case 'q': verbose = 0; break; case 'r': - if (rev != RCS_HEAD_REV) - cvs_log(LP_WARN, - "redefinition of revision number"); - if (rcs_optarg != NULL) { - if ((rev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit (1); - } - } + rcs_set_rev(rcs_optarg, &rev); break; case 'u': - if (rev != RCS_HEAD_REV) - cvs_log(LP_WARN, - "redefinition of revision number"); - if (rcs_optarg != NULL) { - if ((rev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit (1); - } - } + rcs_set_rev(rcs_optarg, &rev); lock = LOCK_UNLOCK; break; case 'V': diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c index 6642cd2855f..e7a8ee8bdbb 100644 --- a/usr.bin/rcs/rcsclean.c +++ b/usr.bin/rcs/rcsclean.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsclean.c,v 1.7 2005/10/13 12:35:30 joris Exp $ */ +/* $OpenBSD: rcsclean.c,v 1.8 2005/10/18 01:22:14 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -70,10 +70,7 @@ rcsclean_main(int argc, char **argv) verbose = 0; break; case 'r': - if ((rev = rcsnum_parse(rcs_optarg)) == NULL) { - cvs_log(LP_ERR, "bad revision number"); - exit(1); - } + rcs_set_rev(rcs_optarg, &rev); break; case 'V': printf("%s\n", rcs_version); diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 39c14379a90..b1edc119367 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.30 2005/10/16 00:25:14 joris Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.31 2005/10/18 01:22:14 joris Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -64,6 +64,18 @@ struct rcs_prog { { "ident", ident_main, ident_usage }, }; +void +rcs_set_rev(const char *str, RCSNUM **rev) +{ + if (*rev != RCS_HEAD_REV) + cvs_log(LP_WARN, "redefinition of revision number"); + + if ((*rev = rcsnum_parse(str)) == NULL) { + cvs_log(LP_ERR, "bad revision number '%s'", str); + exit (1); + } +} + int rcs_init(char *envstr, char **argv, int argvlen) { diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h index fce375dde20..7835895a459 100644 --- a/usr.bin/rcs/rcsprog.h +++ b/usr.bin/rcs/rcsprog.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.h,v 1.13 2005/10/17 15:33:12 joris Exp $ */ +/* $OpenBSD: rcsprog.h,v 1.14 2005/10/18 01:22:14 joris Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -45,6 +45,7 @@ void rcsclean_usage(void); void rlog_usage(void); void ident_usage(void); void (*usage)(void); +void rcs_set_rev(const char *, RCSNUM **); int rcs_init(char *, char **, int); int rcs_getopt(int, char **, const char *); |