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

Re: sort-mailbox by spam tag score sorting strangeness



* On 2006.11.14, in <20061114065407.GA24879@xxxxxxxxxxxxxxxxxxx>,
*       "Bob Proulx" <bob@xxxxxxxxxx> wrote:
> 
> Negative values less than -1 all seem to sort okay.  It seems to be
> only the absolute values <1 that cause issues.  Why is it sorting this
> so strangely?  Why does it appear to be taking the absolute value of
> the score but only if the score is between -1..1 but is okay outside
> that range?  This is mutt 1.5.9-2sarge2 from Debian Sarge stable.

When the spam marking and sorting was implemented, I had not used
SpamAssassin except for testing, and it never occurred to me that a
message might ever receive a numeric spam score less than 0.  (I'm still
not sure why that makes sense, but it's not for me to rule on -- the
whole point of mutt's spam design is to deal with the spam software that
exists without imposing rules and behaviors.)  But the result is that
the spam sorting code only sorts positive numbers as numbers.  Anything
else is a string.

The spam stuff tries to accomodate a variety of counterspam systems,
including those which give non-numeric spam scores.  As such it actually
tries to sort first numerically and then alphabetically.  That's why
you're seeing this behavior only in certain number ranges -- negative
numbers are in fact getting alpha-sorted against the lexical value of
whatever they're compared to, while positive numbers are numerically
sorted only against other positive numbers, and lexically sorted against
negative ones.  So in the final order, if two adjacent numbers are
both positive, they'll arrange themselves numerically, but the full
list is fundamentally lexical since it contains negative values.  It's
complicated.

There's no way to fix this in configuration -- it requires a code
change.  If you're comfortable recompiling mutt yourself, the change is
trivial: in sort.c, change both occurrences of "strtoul" to "strtol".

-- 
 -D.    dgc@xxxxxxxxxxxx        NSIT    University of Chicago