From a47d9d3a9b6ba3fed577b04ac6562ee2c611e440 Mon Sep 17 00:00:00 2001 From: Niall O'Higgins Date: Mon, 1 May 2006 18:17:40 +0000 Subject: - fix a case in rcs_getrev() handling of branches where variant was not being increased and thus no progress could be made in the loop. bug noticed in rcsdiff(1) by sturm@ ok joris@ --- usr.bin/cvs/rcs.c | 9 +++++++-- usr.bin/rcs/rcs.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 342dcbf50f8..036424a27a8 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.170 2006/04/25 10:31:39 xsa Exp $ */ +/* $OpenBSD: rcs.c,v 1.171 2006/05/01 18:17:39 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -1163,7 +1163,7 @@ BUF* rcs_getrev(RCSFILE *rfp, RCSNUM *frev) { u_int i, numlen; - int isbranch, lookonbranch; + int isbranch, lookonbranch, found; size_t len; void *bp; RCSNUM *crev, *rev, *brev; @@ -1235,6 +1235,8 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev) /* Apply patches backwards to get the right version. */ do { + found = 0; + if (rcsnum_cmp(rfp->rf_head, rev, 0) == 0) break; @@ -1257,9 +1259,12 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev) if (i == numlen) { crev = rb->rb_num; + found = 1; break; } } + if (found == 0) + crev = rdp->rd_next; } else { crev = rdp->rd_next; } diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c index 2eca0e99d7f..5721b2b211c 100644 --- a/usr.bin/rcs/rcs.c +++ b/usr.bin/rcs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.5 2006/04/29 05:31:28 ray Exp $ */ +/* $OpenBSD: rcs.c,v 1.6 2006/05/01 18:17:39 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -1121,7 +1121,7 @@ BUF* rcs_getrev(RCSFILE *rfp, RCSNUM *frev) { u_int i, numlen; - int isbranch, lookonbranch; + int isbranch, lookonbranch, found; size_t len; void *bp; RCSNUM *crev, *rev, *brev; @@ -1193,6 +1193,8 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev) /* Apply patches backwards to get the right version. */ do { + found = 0; + if (rcsnum_cmp(rfp->rf_head, rev, 0) == 0) break; @@ -1215,9 +1217,12 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev) if (i == numlen) { crev = rb->rb_num; + found = 1; break; } } + if (found == 0) + crev = rdp->rd_next; } else { crev = rdp->rd_next; } -- cgit v1.2.3