Re: [CSCMail-Users] Billenium Bug
Brought to you by:
countzer0
|
From: Count Z. <cou...@cy...> - 2001-10-09 13:49:03
|
> Hi Steve,
>
> I fixed this for Pronto on Sept. 9th when it all happened. Here is what
> you need to do:
>
> $message_clist->set_compare_func(\&my_sort_func);
>
> sub my_sort_func
> {
> my ($clist, $first, $second) = @_;
> if ($first =~ /^\d+$/) {
What if we are sorting the subject field and one node is numeric, and the
other is text? This will attempt to sort that numerically (incorrect)
> if ($first > $second) { return -1; }
> if ($first == $second) { return 0; }
> return 2;
Why not use <=> ? thats what it's for....
> }
> my @stuff = ($first,$second);
A two element array?
> my @sorted = sort {uc($a) cmp uc($b)} @stuff;
Sort our two elements the first time using cmp... (which compares them...)
> if ($sorted[0] eq $first) { return -1; }
compare two elements (why? you just did that...)
> if ($first eq $second) { return 0; }
compare two elements (redundant)
> return 2;
> }
Oh, you just re-implimented cmp!?
Ouch!
Try:
sub my_sort_func {
my ($clist, $a, $b) = @_;
# Might as well handle sortdir here (not strictly needed)
if ($clist->{'sortdir'} eq "descending") {
my $tmp = $a;
$a = $b;
$b = $tmp;
}
# Are both nodes numeric?
if ($a =~ /^\d+$/ and $b =~ /^\d+$/) {
return ($a <=> $b);
# nope....
} else {
return (uc($a) cmp uc($b));
}
}
CSCMail users: I will be releasing version 1.7.10 in the next few days that
addresses this bug as well encorporating quite a few other code cleanups...
In fact, the reason I am not releasing it right this second involves these
code cleanups... I was in the middle of re-coding the way Folders are
handled internally, as well as getting rid of the "no more than 99 normal
folders" restriction (this involves folders with id's equal to or greater
than 100 being treated as "virtual" search folders... I am adding a new
field to the database that handles the type of folder so there will no
longer be any arbitrary limits to the number of folders)
I guess I should release a 1.6.x version that fixes this bug as well? Is
anyone still using 1.6.x?
-CZ
|