diff options
author | Vincent Labrecque <vincent@cvs.openbsd.org> | 2004-07-14 19:40:11 +0000 |
---|---|---|
committer | Vincent Labrecque <vincent@cvs.openbsd.org> | 2004-07-14 19:40:11 +0000 |
commit | 5413010c52cb975a0b7a9de289793c5f175840d0 (patch) | |
tree | 358fa5c80b5e35df4746ed357e0884567e51a1d1 /usr.bin | |
parent | 579c71893c1c7bc2949f343c706c4672d1103744 (diff) |
fix rcs_findrev()'s searching algorithm
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/rcs.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 4d517bfa325..1ae03651d42 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.5 2004/07/14 19:22:43 vincent Exp $ */ +/* $OpenBSD: rcs.c,v 1.6 2004/07/14 19:40:10 vincent Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -616,19 +616,25 @@ rcs_findrev(RCSFILE *rfp, RCSNUM *rev) u_int cmplen; struct rcs_delta *rdp; struct rcs_dlist *hp; - + int found; + cmplen = 2; hp = &(rfp->rf_delta); - TAILQ_FOREACH(rdp, hp, rd_list) { - if (rcsnum_cmp(rdp->rd_num, rev, cmplen) == 0) { - if (cmplen == rev->rn_len) - return (rdp); - - hp = &(rdp->rd_snodes); - cmplen += 2; + do { + found = 0; + TAILQ_FOREACH(rdp, hp, rd_list) { + if (rcsnum_cmp(rdp->rd_num, rev, cmplen) == 0) { + if (cmplen == rev->rn_len) + return (rdp); + + hp = &(rdp->rd_snodes); + cmplen += 2; + found = 1; + break; + } } - } + } while (found && cmplen < rev->rn_len); return (NULL); } |