[FFmpeg-cvslog] checkasm: Fix the function name sorting algorithm

Henrik Gramner git at videolan.org
Mon Oct 5 11:08:39 CEST 2015


ffmpeg | branch: master | Henrik Gramner <henrik at gramner.com> | Mon Sep 28 16:50:31 2015 +0200| [8bb376cf6b4ab8645daedb8becaa7163656436a4] | committer: Anton Khirnov

checkasm: Fix the function name sorting algorithm

The previous implementation was behaving incorrectly in some corner cases.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8bb376cf6b4ab8645daedb8becaa7163656436a4
---

 tests/checkasm/checkasm.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 013e197..9219a83 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -280,12 +280,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 */



More information about the ffmpeg-cvslog mailing list