@@ -1,8 +0,0 @@
-use Module::Build;
-my $build = Module::Build->new
- (
- module_name => 'Digest::CRC',
- license => 'perl',
- PL_FILES => {},
- );
-$build->create_build_script;
@@ -58,3 +58,13 @@ Revision history for Perl extension Digest::CRC.
- added convenience wrappers for 'cont', #70672
- fixed few issues in xs code, #70674
- added openpgparmor support, #72387
+
+0.19 Sun Feb 8 11:30:09 2015
+ - fixed issue with OO crc64, #101999
+ - remove Build.PL as it seems to have some issues with the XS support
+
+0.20 Sun Feb 8 16:45:13 2015
+ - removed debug code
+
+0.21 Sat Feb 21 13:18:25 2015
+ - new() throwing an error if an unsupported type is specified
@@ -1,6 +1,5 @@
-Build.PL
-CRC.xs
Changes
+CRC.xs
MANIFEST
META.yml
Makefile.PL
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Digest-CRC
-version: 0.11
+version: 0.21
version_from: lib/Digest/CRC.pm
installdirs: site
requires:
@@ -1,4 +1,4 @@
-Digest::CRC version 0.18
+Digest::CRC version 0.21
========================
NAME
@@ -18,9 +18,9 @@ require Exporter;
crc64_hex crc64_base64
);
-$VERSION = '0.18';
+$VERSION = '0.21';
$XS_VERSION = $VERSION;
-$VERSION = eval $VERSION;
+#$VERSION = eval $VERSION;
eval {
# PERL_DL_NONLAZY must be false, or any errors in loading will just
@@ -69,13 +69,13 @@ sub _tabinit($$$) {
$r = $i if $ref;
for (my $j=0; $j<8; $j++) {
if ($ref) {
- $r = ($r>>1)^($r&1&&$poly)
+ $r = ($r>>1)^($r&1&&$poly)
} else {
- if ($r&(1<<($width-1))) {
- $r = ($r<<1)^$poly
- } else {
- $r = ($r<<1)
- }
+ if ($r&(1<<($width-1))) {
+ $r = ($r<<1)^$poly
+ } else {
+ $r = ($r<<1)
+ }
}
}
my $x=$r&2**$width-1;
@@ -134,6 +134,7 @@ ENOXS
sub new {
my $that=shift;
my %params=@_;
+ die if defined($params{type}) && !exists($_typedef{$params{type}}) && $params{type} ne 'crc64';
my $class = ref($that) || $that;
my $self = {map { ($_ => $params{$_}) }
qw(type width init xorout refout poly refin cont)};
@@ -161,7 +162,7 @@ sub reset {
$self->{refin} = $typeparams->[5],
$self->{cont} = $typeparams->[6],
}
- $self->{_tab} = _tabinit($self->{width}, $self->{poly}, $self->{refin});
+ $self->{_tab} = defined($self->{width})?_tabinit($self->{width}, $self->{poly}, $self->{refin}):undef;
$self->{_data} = undef;
$self
}
@@ -223,8 +224,13 @@ sub digest {
my $crc;
if (!$self->{_crc}) {
my $init = $self->{init};
- $crc =_crc($self->{_data},$self->{width},$init,$self->{xorout},
+ if (defined($self->{type}) && $self->{type} eq 'crc64' ||
+ defined($self->{width}) && $self->{width} eq 64) {
+ $crc = _crc64($self->{_data});
+ } else {
+ $crc =_crc($self->{_data},$self->{width},$init,$self->{xorout},
$self->{refin},$self->{refout},$self->{cont},$self->{_tab});
+ }
} else {
$crc = $self->{_crc};
$self->{_crc} = undef;
@@ -251,7 +257,9 @@ sub clone {
poly => $self->{poly},
refin => $self->{refin},
refout => $self->{refout},
- _data => $self->{_data}
+ _data => $self->{_data},
+ cont => $self->{cont},
+ _tab => $self->{_tab}
};
bless $clone, ref $self || $self;
}
@@ -304,7 +312,7 @@ sub crc32 { _cont($_[0],$_[1],@{$_typedef{crc32}}) }
# CRC64
# special XS implementation (_crc64)
-sub crc64 { _crc64($_[0],$_[1]) }
+sub crc64 { _crc64($_[0],defined($_[1])?$_[1]:0) }
sub crc_hex { _encode_hex &crc }
@@ -1,7 +1,7 @@
BEGIN {
$tests = 21;
if ($ENV{'WITH_CRC64'}) {
- $tests++;
+ $tests=$tests+2;
}
$| = 1;
@@ -30,6 +30,10 @@ my ($crc32,$crc16,$crcccitt,$crc8) = (crc32($input),crc16($input),crcccitt($inpu
if ($ENV{'WITH_CRC64'}) {
my $crc64 = crc64($input);
ok($crc64 == 5090661014116757502, 'crc64 '.$crc64);
+ $ctx = Digest::CRC->new(type=>"crc64");
+ $ctx->add($input);
+ $crc64 = $ctx->digest;
+ ok($crc64 == 5090661014116757502, 'OO crc64 '.$crc64);
}
ok($crc32 == 3421780262, 'crc32');
@@ -49,11 +53,11 @@ $crc32=$crc32^0xffffffff;
# addfile
-open(F,"<README")||die "Cannot open Changes";
+open(F,"<README")||die "Cannot open README";
$ctx->addfile(F);
close(F);
my $y = $ctx->digest;
-ok($y == 3613349160, 'OO crc32 with addfile '.$y);
+ok($y == 1662879226, 'OO crc32 with addfile '.$y);
# start at offset >0 with previous checksum result
$ctx = Digest::CRC->new(type=>"crc32",cont=>1,init=>460478609);