n = NMAX / 16; /* NMAX is divisible by 16 */
at line 103 of adler 32 repeats always the same operation because
NMAX is a #define.
Harbour uses this:
#define BASE 65521 /* largest prime smaller than 65536 */
#define NMAX 5552 /* largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <=
2^32-1 */
HB_EXPORT ULONG hb_adler32( ULONG adler, const BYTE *buf, ULONG len )
{
ULONG s1 = adler & 0xffff;
ULONG s2 = ( adler >> 16 ) & 0xffff;
if( buf && len )
{
do
{
int i = len < NMAX ? len : NMAX;
len -= i;
do
{
s1 += ( UCHAR ) *buf++;
s2 += s1;
}
while( --i );
s1 %= BASE;
s2 %= BASE;
}
while( len );
}
return ( s2 << 16 ) | s1;
}
and the final value is returned to prg level in different way.
hb_adler32([<x,...>]) return as hb_retnint( hb_adler32( ( ULONG ) hb_parnl( 2
), ( BYTE * ) szString, hb_parclen( 1 ) ) );
hb_checksum(<x>) return as hb_retnd( (LONG) adler32( ulSum, ( const BYTE
*) pString->item.asString.value,
pString->item.asString.length ) );
hb_retnd is returning negative values.
Best regards,
Miguel Angel marchuet
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers