On Wed, 27 Jul 2011, subscript...@innter.net wrote:

> Hello,
>
> I have found that C and Perl versions (tools/rehash) of dir_hash_c have
> different results. For part of mailboxes.
>
> Perl code :
>
> $n = 0;
> foreach my $b (split(/ */, $auth_user)) {
>    $n = (($n << 3) ^ ($n >> 5)) ^ ord($b);
> }
> $h = chr(ord('A') + ($n % 23));
If your perl uses 64bit int and your cyrus imapd is compiled
with 32bit int then you might want change your perl code to something
like this:

$uint32=(2**32);
$n = 0;
foreach my $b (split(/ */, $_)) {
     $n = ((($n << 3) ^ ($n >> 5)) % $uint32) ^ ord($b);
}
$h = chr(ord('A') + ($n % 23));

-- 
   Leena Heino              University of Tampere / Computer Centre
   ( liinu at uta.fi )      ( http://www.uta.fi/laitokset/tkk )
----
Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/

Reply via email to