Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/lib Pull up revision 1.21 (request...
details: https://anonhg.NetBSD.org/src/rev/786a5a81d77e
branches: netbsd-1-4
changeset: 470334:786a5a81d77e
user: he <he%NetBSD.org@localhost>
date: Thu Feb 10 21:23:49 2000 +0000
description:
Pull up revision 1.21 (requested by abs):
Handle ``nb<N>'' suffix in dewey decimal comparisons.
diffstat:
usr.sbin/pkg_install/lib/str.c | 45 ++++++++++++++++++++++++++++++++---------
1 files changed, 35 insertions(+), 10 deletions(-)
diffs (78 lines):
diff -r e43a3253fd9a -r 786a5a81d77e usr.sbin/pkg_install/lib/str.c
--- a/usr.sbin/pkg_install/lib/str.c Tue Feb 08 23:36:27 2000 +0000
+++ b/usr.sbin/pkg_install/lib/str.c Thu Feb 10 21:23:49 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: str.c,v 1.14.2.5 2000/01/31 21:00:05 he Exp $ */
+/* $NetBSD: str.c,v 1.14.2.6 2000/02/10 21:23:49 he Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
#else
-__RCSID("$NetBSD: str.c,v 1.14.2.5 2000/01/31 21:00:05 he Exp $");
+__RCSID("$NetBSD: str.c,v 1.14.2.6 2000/02/10 21:23:49 he Exp $");
#endif
#endif
@@ -105,13 +105,35 @@
{
int ad;
int bd;
+ char *a_nb;
+ char *b_nb;
+ int in_nb = 0;
int cmp;
+ /* Null out 'n' in any "nb" suffixes for initial pass */
+ if ((a_nb = strstr(a, "nb")))
+ *a_nb = 0;
+ if ((b_nb = strstr(b, "nb")))
+ *b_nb = 0;
+
for (;;) {
if (*a == 0 && *b == 0) {
- cmp = 0;
- break;
+ if (!in_nb && (a_nb || b_nb)) {
+ /*
+ * If exact match on first pass, test
+ * "nb<X>" suffixes in second pass
+ */
+ in_nb = 1;
+ if (a_nb)
+ a = a_nb + 2; /* Skip "nb" suffix */
+ if (b_nb)
+ b = b_nb + 2; /* Skip "nb" suffix */
+ } else {
+ cmp = 0;
+ break;
+ }
}
+
ad = bd = 0;
for (; *a && *a != '.'; a++) {
ad = (ad * 10) + (*a - '0');
@@ -122,13 +144,16 @@
if ((cmp = ad - bd) != 0) {
break;
}
- if (*a == '.') {
- a++;
- }
- if (*b == '.') {
- b++;
- }
+ if (*a == '.')
+ ++a;
+ if (*b == '.')
+ ++b;
}
+ /* Replace any nulled 'n' */
+ if (a_nb)
+ *a_nb = 'n';
+ if (b_nb)
+ *b_nb = 'n';
return (op == GE) ? cmp >= 0 : (op == GT) ? cmp > 0 : (op == LE) ? cmp <= 0 : cmp < 0;
}
Home |
Main Index |
Thread Index |
Old Index