summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHenrik Gramner <henrik@gramner.com>2015-09-28 16:50:31 +0200
committerAnton Khirnov <anton@khirnov.net>2015-10-03 13:38:03 +0200
commit8bb376cf6b4ab8645daedb8becaa7163656436a4 (patch)
treed580d69b811e9edd39dbe5301cc39634ddd26c49 /tests
parente54d7e4e8ef7d778e2ddc5a60bf7307ed55d6333 (diff)
checkasm: Fix the function name sorting algorithm
The previous implementation was behaving incorrectly in some corner cases. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/checkasm/checkasm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 013e197b43..9219a83111 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 */