diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-05-22 07:03:03 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-05-22 07:03:03 +0000 |
commit | e34e826251ce579ecfe0ad357cbb667f4f901827 (patch) | |
tree | f76fbbaf83cd0d2bfbc888d5c290a2e4cb65426c /usr.bin/cvs | |
parent | 7d0e80716bf9682b2cc515d0024958b3069b89de (diff) |
correctly deal with non-zero depths specified in rcsnum_cmp();
from Stefan Sperling
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/rcsnum.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c index db74093c87e..fdee1205582 100644 --- a/usr.bin/cvs/rcsnum.c +++ b/usr.bin/cvs/rcsnum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsnum.c,v 1.52 2008/03/01 20:03:56 joris Exp $ */ +/* $OpenBSD: rcsnum.c,v 1.53 2008/05/22 07:03:02 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -180,8 +180,9 @@ rcsnum_cpy(const RCSNUM *nsrc, RCSNUM *ndst, u_int depth) * Compare the two numbers <n1> and <n2>. Returns -1 if <n1> is larger than * <n2>, 0 if they are both the same, and 1 if <n2> is larger than <n1>. * The <depth> argument specifies how many numbers deep should be checked for - * the result. A value of 0 means that the depth will be the minimum of the - * two numbers. + * the result. A value of 0 means that the depth will be the maximum of the + * two numbers, so that a longer number is considered greater than a shorter + * number if they are equal up to the minimum length. */ int rcsnum_cmp(RCSNUM *n1, RCSNUM *n2, u_int depth) @@ -205,7 +206,12 @@ rcsnum_cmp(RCSNUM *n1, RCSNUM *n2, u_int depth) return (-1); } - if (n1->rn_len > n2->rn_len) + /* If an explicit depth was specified, and we've + * already checked up to depth, consider the + * revision numbers equal. */ + if (depth != 0 && slen == depth) + return (0); + else if (n1->rn_len > n2->rn_len) return (-1); else if (n2->rn_len > n1->rn_len) return (1); |