<<< Date Index >>>     <<< Thread Index >>>

Re: sort-mailbox by spam tag score sorting strangeness



I am replying to a note from Wed, 22 Nov 2006.  Sorry about the delay.
I am using the time off around the holidays to catch up on the todo
list.

David Champion wrote:
> Here's a patch to current CVS mutt.  It should apply on your version,
> too; sort.c has changed little.  (Summary: use double float conversion
> instead of signed or unsigned long.)

Yes!  Thank you for that fix.  It has solved the problem.  With that
patch the spam sort functionality is sorting correctly small negative
values as produced by spamassassin's spam score.

> I'll present this for inclusion in CVS.

Sounds good.  Thanks for looking into this problem and finding the fix
for it!

Bob


> Index: sort.c
> ===================================================================
> RCS file: /home/roessler/cvs/mutt/sort.c,v
> retrieving revision 3.9
> diff -u -r3.9 sort.c
> --- sort.c    17 Sep 2005 20:46:11 -0000      3.9
> +++ sort.c    22 Nov 2006 06:57:06 -0000
> @@ -160,6 +160,7 @@
>    char   *aptr, *bptr;
>    int     ahas, bhas;
>    int     result = 0;
> +  double  difference;
>  
>    /* Firstly, require spam attributes for both msgs */
>    /* to compare. Determine which msgs have one.     */
> @@ -183,8 +184,11 @@
>    /* Both have spam attrs. */
>  
>    /* preliminary numeric examination */
> -  result = (strtoul((*ppa)->env->spam->data, &aptr, 10) -
> -            strtoul((*ppb)->env->spam->data, &bptr, 10));
> +  difference = (strtod((*ppa)->env->spam->data, &aptr) -
> +                strtod((*ppb)->env->spam->data, &bptr));
> +
> +  /* map double into comparison (-1, 0, or 1) */
> +  result = (difference < 0.0 ? -1 : difference > 0.0 ? 1 : 0);
>  
>    /* If either aptr or bptr is equal to data, there is no numeric    */
>    /* value for that spam attribute. In this case, compare lexically. */