Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install/lib * shuffle variable names in findbes...
details: https://anonhg.NetBSD.org/src/rev/e71e916505f7
branches: trunk
changeset: 488090:e71e916505f7
user: hubertf <hubertf%NetBSD.org@localhost>
date: Sun Jun 18 01:29:30 2000 +0000
description:
* shuffle variable names in findbestmatchingname_fn() around
a bit, to make them more descriptive
* in findbestmatchingname_fn, fix a bug where a null pointer wasn't
caught (I wonder why we didn't actually hit that case...)
* Bugfix in findbestmatchingname_fn: when comparing, strip off any
trailing ".tgz", as this will give wrong results. "1.9.8.tgz" was
found to be greater than "1.9.8.1".
diffstat:
usr.sbin/pkg_install/lib/str.c | 42 ++++++++++++++++++++++++++++++++++--------
1 files changed, 34 insertions(+), 8 deletions(-)
diffs (66 lines):
diff -r 41c62326620f -r e71e916505f7 usr.sbin/pkg_install/lib/str.c
--- a/usr.sbin/pkg_install/lib/str.c Sun Jun 18 01:29:17 2000 +0000
+++ b/usr.sbin/pkg_install/lib/str.c Sun Jun 18 01:29:30 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: str.c,v 1.21 2000/02/07 11:26:26 abs Exp $ */
+/* $NetBSD: str.c,v 1.22 2000/06/18 01:29:30 hubertf 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.21 2000/02/07 11:26:26 abs Exp $");
+__RCSID("$NetBSD: str.c,v 1.22 2000/06/18 01:29:30 hubertf Exp $");
#endif
#endif
@@ -330,16 +330,42 @@
* Also called for FTP matching
*/
int
-findbestmatchingname_fn(const char *pkg, char *data)
+findbestmatchingname_fn(const char *found, char *best)
{
- char *s1, *s2;
+ char *found_version, *best_version;
+ char *found_tgz, *best_tgz;
+ char found_no_tgz[255];
+ char best_no_tgz[255];
+
+ found_version = strrchr(found, '-') + 1;
+ found_tgz = strstr(found, ".tgz");
+ if (found_tgz) {
+ /* strip off any ".tgz" */
+ strncpy(found_no_tgz, found_version, found_tgz-found_version);
+ found_no_tgz[found_tgz-found_version] = '\0';
+ found_version = found_no_tgz;
+ }
- s1 = strrchr(pkg, '-') + 1;
- s2 = strrchr(data, '-') + 1;
+ best_version=NULL;
+ if (best && best[0] != '\0') {
+ best_version = strrchr(best, '-') + 1;
+ best_tgz = strstr(best, ".tgz");
+ if (best_tgz) {
+ /* strip off any ".tgz" */
+ strncpy(best_no_tgz, best_version, best_tgz-best_version);
+ best_no_tgz[best_tgz-best_version] = '\0';
+ best_version = best_no_tgz;
+ }
+ }
- if (data[0] == '\0' || deweycmp(s1, GT, s2)) {
- strcpy(data, pkg);
+ found_version, best_version); fflush(stdout);
+
+ if (best == NULL || best[0] == '\0' || deweycmp(found_version, GT, best_version)) {
+ /* found pkg(version) is bigger than current "best"
+ * version - remember! */
+ strcpy(best, found);
}
+
return 0;
}
Home |
Main Index |
Thread Index |
Old Index