Fri Mar 6 15:19:04 2009 UTC ()
Merge lib/dewey.c rev 1.11 from pkg_install:
Avoid sign comparision issues.


(joerg)
diff -r1.3 -r1.4 pkgsrc/pkgtools/pbulk/files/pbulk/lib/match.c

cvs diff -r1.3 -r1.4 pkgsrc/pkgtools/pbulk/files/pbulk/lib/match.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/pbulk/files/pbulk/lib/match.c 2008/09/22 11:31:16 1.3
+++ pkgsrc/pkgtools/pbulk/files/pbulk/lib/match.c 2009/03/06 15:19:04 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: match.c,v 1.3 2008/09/22 11:31:16 joerg Exp $ */ 1/* $NetBSD: match.c,v 1.4 2009/03/06 15:19:04 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright © 2002 Alistair G. Crooks. All rights reserved. 4 * Copyright © 2002 Alistair G. Crooks. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote 14 * 3. The name of the author may not be used to endorse or promote
@@ -263,29 +263,28 @@ result(int cmp, int tst) @@ -263,29 +263,28 @@ result(int cmp, int tst)
263 case DEWEY_EQ: 263 case DEWEY_EQ:
264 return cmp == 0; 264 return cmp == 0;
265 case DEWEY_NE: 265 case DEWEY_NE:
266 return cmp != 0; 266 return cmp != 0;
267 default: 267 default:
268 return 0; 268 return 0;
269 } 269 }
270} 270}
271 271
272/* do the test on the 2 vectors */ 272/* do the test on the 2 vectors */
273static int 273static int
274vtest(arr_t *lhs, int tst, arr_t *rhs) 274vtest(arr_t *lhs, int tst, arr_t *rhs)
275{ 275{
 276 unsigned int c, i;
276 int cmp; 277 int cmp;
277 int c; 
278 int i; 
279 278
280 for (i = 0, c = MAX(lhs->c, rhs->c) ; i < c ; i++) { 279 for (i = 0, c = MAX(lhs->c, rhs->c) ; i < c ; i++) {
281 if ((cmp = DIGIT(lhs->v, lhs->c, i) - DIGIT(rhs->v, rhs->c, i)) != 0) { 280 if ((cmp = DIGIT(lhs->v, lhs->c, i) - DIGIT(rhs->v, rhs->c, i)) != 0) {
282 return result(cmp, tst); 281 return result(cmp, tst);
283 } 282 }
284 } 283 }
285 return result(lhs->netbsd - rhs->netbsd, tst); 284 return result(lhs->netbsd - rhs->netbsd, tst);
286} 285}
287 286
288/* 287/*
289 * Compare two dewey decimal numbers 288 * Compare two dewey decimal numbers
290 */ 289 */
291static int 290static int
@@ -343,27 +342,27 @@ dewey_match(const char *pattern, const c @@ -343,27 +342,27 @@ dewey_match(const char *pattern, const c
343 if ((n = dewey_mktest(&op2, sep2)) < 0) { 342 if ((n = dewey_mktest(&op2, sep2)) < 0) {
344 return 0; 343 return 0;
345 } 344 }
346 /* compare upper limit */ 345 /* compare upper limit */
347 if (!dewey_cmp(version, op2, sep2+n)) 346 if (!dewey_cmp(version, op2, sep2+n))
348 return 0; 347 return 0;
349 } 348 }
350 } 349 }
351 350
352 /* compare only pattern / lower limit */ 351 /* compare only pattern / lower limit */
353 if (sep2) { 352 if (sep2) {
354 char ver[PKG_PATTERN_MAX]; 353 char ver[PKG_PATTERN_MAX];
355 354
356 strlcpy(ver, sep, MIN(sizeof(ver), sep2-sep+1)); 355 strlcpy(ver, sep, MIN((ssize_t)sizeof(ver), sep2-sep+1));
357 if (dewey_cmp(version, op, ver)) 356 if (dewey_cmp(version, op, ver))
358 return 1; 357 return 1;
359 } 358 }
360 else { 359 else {
361 if (dewey_cmp(version, op, sep)) 360 if (dewey_cmp(version, op, sep))
362 return 1; 361 return 1;
363 } 362 }
364 363
365 return 0; 364 return 0;
366} 365}
367 366
368 367
369/* 368/*