]> git.sesse.net Git - ffmpeg/commitdiff
checkasm: Fix the function name sorting algorithm
authorHenrik Gramner <henrik@gramner.com>
Sat, 26 Sep 2015 18:15:35 +0000 (20:15 +0200)
committerHenrik Gramner <henrik@gramner.com>
Mon, 28 Sep 2015 14:38:23 +0000 (16:38 +0200)
The previous implementation was behaving incorrectly in some corner cases.

tests/checkasm/checkasm.c

index 2f967e3937e91ac87a83fa5cbd5ad6c55fb1c902..d4680f08de8f42222f61b20e734e5aab637ea54d 100644 (file)
@@ -289,12 +289,16 @@ static void print_benchs(CheckasmFunc *f)
 /* ASCIIbetical sort except preserving natural order for numbers */
 static int cmp_func_names(const char *a, const char *b)
 {
+    const char *start = a;
     int ascii_diff, digit_diff;
 
-    for (; !(ascii_diff = *a - *b) && *a; a++, b++);
+    for (; !(ascii_diff = *(const unsigned char*)a - *(const unsigned char*)b) && *a; a++, b++);
     for (; av_isdigit(*a) && av_isdigit(*b); a++, b++);
 
-    return (digit_diff = av_isdigit(*a) - av_isdigit(*b)) ? digit_diff : ascii_diff;
+    if (a > start && av_isdigit(a[-1]) && (digit_diff = av_isdigit(*a) - av_isdigit(*b)))
+        return digit_diff;
+
+    return ascii_diff;
 }
 
 /* Perform a tree rotation in the specified direction and return the new root */