[BusyBox-cvs] CVS update of busybox/libbb (interface.c)

Glenn McGrath bug1 at codepoet.org
Fri Jul 23 01:49:47 UTC 2004


    Date: Thursday, July 22, 2004 @ 19:49:47
  Author: bug1
    Path: /var/cvs/busybox/libbb

Modified: interface.c (1.22 -> 1.23)

Fix for a bug identied by Harald Kuthe, when using many interfaces (29 
in this case) the order was incorrect and there were duplicate entries. 


Index: busybox/libbb/interface.c
diff -u busybox/libbb/interface.c:1.22 busybox/libbb/interface.c:1.23
--- busybox/libbb/interface.c:1.22	Wed Apr 14 11:57:11 2004
+++ busybox/libbb/interface.c	Thu Jul 22 19:49:46 2004
@@ -889,30 +889,25 @@
 }
 
 /* like strcmp(), but knows about numbers */
-static int nstrcmp(const char *astr, const char *b)
+static int nstrcmp(const char *a, const char *b)
 {
-	const char *a = astr;
+	const char *a_ptr = a;
+	const char *b_ptr = b;
 
 	while (*a == *b) {
-		if (*a == '\0')
+		if (*a == '\0') {
 			return 0;
+		}
+		if (!isdigit(*a) && isdigit(*(a+1))) {
+			a_ptr = a+1;
+			b_ptr = b+1;
+		}
 		a++;
 		b++;
 	}
-	if (isdigit(*a)) {
-		if (!isdigit(*b))
-			return -1;
-		while (a > astr) {
-			a--;
-			if (!isdigit(*a)) {
-				a++;
-				break;
-			}
-			if (!isdigit(*b))
-				return -1;
-			b--;
-		}
-		return atoi(a) > atoi(b) ? 1 : -1;
+
+	if (isdigit(*a) && isdigit(*b)) {
+		return atoi(a_ptr) > atoi(b_ptr) ? 1 : -1;
 	}
 	return *a - *b;
 }



More information about the busybox-cvs mailing list