This queue is for tickets about the Digest-CRC CPAN distribution.

Report information
The Basics
Id:
70672
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
OLIMAUL [...] cpan.org
Requestors:
pebolle [...] tiscali.nl
Cc:
AdminCc:

BugTracker
Severity:
Wishlist
Broken in:
0.17
Fixed in:
(no value)



Subject: Add convenience wrappers to 'cont' support for Functional style
0) In bug #70535 'cont' support was added to the Functional style. This patch adds convenience wrappers using 'cont' for the predefined CRC algorithms (crc8, crcccitt, crc16, crc32 and crc64). 1) Interface looks like this: $digest = crc8($string0); $digest = crc8($string1, $digest); This interface is similar to what String::CRC32 uses. The python module zlib also uses that interface for its adler32() and crc32() methods.
Subject: wrappers.patch
diff -up Digest-CRC-0.17/lib/Digest/CRC.pm.cont Digest-CRC-0.17/lib/Digest/CRC.pm --- Digest-CRC-0.17/lib/Digest/CRC.pm.cont 2011-08-27 14:22:37.000000000 +0200 +++ Digest-CRC-0.17/lib/Digest/CRC.pm 2011-08-28 11:12:20.259642895 +0200 @@ -258,32 +258,41 @@ sub crc { _crc($message,$width,$init,$xorout,$refin,$refout,$cont,_tabinit($width,$poly,$refin)); } +sub _cont { + my ($message,$init,@parameters) = @_; + if (defined $init) { + $parameters[1] = $init; + $parameters[6] = 1; + } + crc($message,@parameters); +} + # CRC8 # poly: 07, width: 8, init: 00, revin: no, revout: no, xorout: no -sub crc8 { crc($_[0],@{$_typedef{crc8}}) } +sub crc8 { _cont($_[0],$_[1],@{$_typedef{crc8}}) } # CRC-CCITT standard # poly: 1021, width: 16, init: ffff, refin: no, refout: no, xorout: no -sub crcccitt { crc($_[0],@{$_typedef{crcccitt}}) } +sub crcccitt { _cont($_[0],$_[1],@{$_typedef{crcccitt}}) } # CRC16 # poly: 8005, width: 16, init: 0000, revin: yes, revout: yes, xorout: no -sub crc16 { crc($_[0],@{$_typedef{crc16}}) } +sub crc16 { _cont($_[0],$_[1],@{$_typedef{crc16}}) } # CRC32 # poly: 04C11DB7, width: 32, init: FFFFFFFF, revin: yes, revout: yes, # xorout: FFFFFFFF # equivalent to: cksum -o3 -sub crc32 { crc($_[0],@{$_typedef{crc32}}) } +sub crc32 { _cont($_[0],$_[1],@{$_typedef{crc32}}) } # CRC64 # special XS implementation (_crc64) -sub crc64 { _crc64($_[0]) } +sub crc64 { _crc64($_[0],$_[1]) } sub crc_hex { _encode_hex &crc } --- Digest-CRC-0.17/CRC.xs.cont 2011-08-27 14:22:37.000000000 +0200 +++ Digest-CRC-0.17/CRC.xs 2011-08-28 12:03:44.847624335 +0200 @@ -156,12 +156,12 @@ RETVAL SV * -_crc64(message) +_crc64(message, crc=0) SV * message + UV crc PREINIT: unsigned long long poly64rev = 0xd800000000000000ULL; - unsigned long long crc = 0x0000000000000000ULL; unsigned long long part; int i, j; static int init = 0;
Hi, thanks for the patch. It is part of version 0.18 which I uploaded a few minutes ago. Oliver


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.