summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoris <joris@openbsd.org>2008-05-22 07:03:02 +0000
committerjoris <joris@openbsd.org>2008-05-22 07:03:02 +0000
commit32128e2aa13f99baf7d43927013340af1accc6d9 (patch)
treed52d5d2f71c7ff777b7c2e6a355d326b4aa13aa8
parentSpacing; Stefan Sperling. (diff)
downloadwireguard-openbsd-32128e2aa13f99baf7d43927013340af1accc6d9.tar.xz
wireguard-openbsd-32128e2aa13f99baf7d43927013340af1accc6d9.zip
correctly deal with non-zero depths specified in rcsnum_cmp();
from Stefan Sperling
-rw-r--r--usr.bin/cvs/rcsnum.c14
-rw-r--r--usr.bin/rcs/rcsnum.c14
2 files changed, 20 insertions, 8 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);
diff --git a/usr.bin/rcs/rcsnum.c b/usr.bin/rcs/rcsnum.c
index 4103882a456..176de241de8 100644
--- a/usr.bin/rcs/rcsnum.c
+++ b/usr.bin/rcs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.10 2008/01/31 16:36:11 tobias Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.11 2008/05/22 07:03:02 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -188,8 +188,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(const RCSNUM *n1, const RCSNUM *n2, u_int depth)
@@ -210,7 +211,12 @@ rcsnum_cmp(const RCSNUM *n1, const 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);