[FFmpeg-devel] [PATCH v2] checkasm: Fix the function name sorting algorithm
Michael Niedermayer
michaelni at gmx.at
Mon Sep 28 03:48:38 CEST 2015
On Sun, Sep 27, 2015 at 07:55:06PM +0200, Henrik Gramner wrote:
> The previous implementation was behaving incorrectly in some corner cases.
> ---
> The first version of this patch didn't take care of all possible corner cases,
> but I believe this one does.
> ---
> 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 8c75cc9..d7c2e8a 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -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;
> }
LGTM
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
What does censorship reveal? It reveals fear. -- Julian Assange
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150928/34390d9b/attachment.sig>
More information about the ffmpeg-devel
mailing list