Perl version of dir_hash_c
    Leena Heino 
    Leena.Heino at uta.fi
       
    Wed Jul 27 04:53:42 EDT 2011
    
    
  
On Wed, 27 Jul 2011, subscription at 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 )
    
    
More information about the Info-cyrus
mailing list