From 8d041a6271be114a06f362fc190099514b76c9db Mon Sep 17 00:00:00 2001 From: Xavier Santolaria Date: Sat, 15 Apr 2006 19:35:20 +0000 Subject: dont stupidly duplicate code. make rlog use rcs_rev_select() and thus nuke rlog_rev_select(). OK niallo@. --- usr.bin/rcs/rcsprog.c | 5 ++-- usr.bin/rcs/rcsprog.h | 3 +- usr.bin/rcs/rlog.c | 80 ++------------------------------------------------- 3 files changed, 6 insertions(+), 82 deletions(-) diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 5cc47489d97..8f896ca6119 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.103 2006/04/14 23:29:01 joris Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.104 2006/04/15 19:35:19 xsa Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau * All rights reserved. @@ -66,7 +66,6 @@ struct cvs_wklhead rcs_temp_files; void sighdlr(int); static void rcs_set_description(RCSFILE *, const char *); static void rcs_attach_symbol(RCSFILE *, const char *); -static u_int rcs_rev_select(RCSFILE *, char *); /* ARGSUSED */ void @@ -905,7 +904,7 @@ rcs_set_description(RCSFILE *file, const char *in) xfree(content); } -static u_int +u_int rcs_rev_select(RCSFILE *file, char *range) { int i; diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h index c9803614317..506d8c39132 100644 --- a/usr.bin/rcs/rcsprog.h +++ b/usr.bin/rcs/rcsprog.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.h,v 1.46 2006/04/13 00:58:25 ray Exp $ */ +/* $OpenBSD: rcsprog.h,v 1.47 2006/04/15 19:35:19 xsa Exp $ */ /* * Copyright (c) 2005 Joris Vink * All rights reserved. @@ -113,6 +113,7 @@ 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 *); +u_int rcs_rev_select(RCSFILE *, char *); void rcs_set_rev(const char *, RCSNUM **); void rcs_setrevstr(char **, char *); void rcs_setrevstr2(char **, char **, char *); diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c index b4b0ec17091..8d4f8a50f33 100644 --- a/usr.bin/rcs/rlog.c +++ b/usr.bin/rcs/rlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlog.c,v 1.45 2006/04/14 23:29:01 joris Exp $ */ +/* $OpenBSD: rlog.c,v 1.46 2006/04/15 19:35:19 xsa Exp $ */ /* * Copyright (c) 2005 Joris Vink * Copyright (c) 2005, 2006 Xavier Santolaria @@ -32,7 +32,6 @@ static void rlog_file(const char *, RCSFILE *); static void rlog_rev_print(struct rcs_delta *); -static u_int rlog_rev_select(RCSFILE *); #define RLOG_OPTSTRING "hLl::NqRr::s:TtVw::x::z::" #define REVSEP "----------------------------" @@ -173,7 +172,7 @@ rlog_file(const char *fname, RCSFILE *file) char *workfile, *p; if (rflag == 1) - nrev = rlog_rev_select(file); + nrev = rcs_rev_select(file, revisions); else nrev = file->rf_ndelta; @@ -342,78 +341,3 @@ rlog_rev_print(struct rcs_delta *rdp) printf("%s", rdp->rd_log); } - -static u_int -rlog_rev_select(RCSFILE *file) -{ - int i; - u_int nrev; - char *ep; - char *lstr, *rstr; - struct rcs_delta *rdp; - struct cvs_argvector *revargv, *revrange; - RCSNUM lnum, rnum; - - nrev = 0; - (void)memset(&lnum, 0, sizeof(lnum)); - (void)memset(&rnum, 0, sizeof(rnum)); - - if (revisions == NULL) { - TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) - if (rcsnum_cmp(rdp->rd_num, file->rf_head, 0) == 0) { - rdp->rd_flags |= RCS_RD_SELECT; - return (1); - } - return (0); - } - - revargv = cvs_strsplit(revisions, ","); - for (i = 0; revargv->argv[i] != NULL; i++) { - revrange = cvs_strsplit(revargv->argv[i], ":"); - if (revrange->argv[0] == NULL) - /* should not happen */ - fatal("invalid revision range: %s", revargv->argv[i]); - else if (revrange->argv[1] == NULL) - lstr = rstr = revrange->argv[0]; - else { - if (revrange->argv[2] != NULL) - fatal("invalid revision range: %s", - revargv->argv[i]); - lstr = revrange->argv[0]; - rstr = revrange->argv[1]; - if (strcmp(lstr, "") == 0) - lstr = NULL; - if (strcmp(rstr, "") == 0) - rstr = NULL; - } - - if (lstr == NULL) - lstr = RCS_HEAD_INIT; - if (rcsnum_aton(lstr, &ep, &lnum) == 0 || (*ep != '\0')) - fatal("invalid revision: %s", lstr); - - if (rstr != NULL) { - if (rcsnum_aton(rstr, &ep, &rnum) == 0 || (*ep != '\0')) - fatal("invalid revision: %s", rstr); - } else - rcsnum_cpy(file->rf_head, &rnum, 0); - - cvs_argv_destroy(revrange); - - TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) - if (rcsnum_cmp(rdp->rd_num, &lnum, 0) <= 0 && - rcsnum_cmp(rdp->rd_num, &rnum, 0) >= 0 && - !(rdp->rd_flags & RCS_RD_SELECT)) { - rdp->rd_flags |= RCS_RD_SELECT; - nrev++; - } - } - cvs_argv_destroy(revargv); - - if (lnum.rn_id != NULL) - xfree(lnum.rn_id); - if (rnum.rn_id != NULL) - xfree(rnum.rn_id); - - return (nrev); -} -- cgit v1.2.3