X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FDigest%2FMD5%2Ft%2Ffiles.t;h=4c41b3279e0f778daec2f783ecdb18add1cbed17;hb=0c8767aeceb5f1c68d6318e2c8809e9913930642;hp=5fcb035e2b5b976273e52d20dd9dcd27a7fb0df5;hpb=9508959b48d9beb1fd6a81c01ef5b8896339ebd4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/Digest/MD5/t/files.t b/ext/Digest/MD5/t/files.t index 5fcb035..4c41b32 100644 --- a/ext/Digest/MD5/t/files.t +++ b/ext/Digest/MD5/t/files.t @@ -10,25 +10,37 @@ print "1..5\n"; use strict; use Digest::MD5 qw(md5 md5_hex md5_base64); -# -# This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt' -# -my $EXPECT; +# To update the EBCDIC section even on a Latin 1 platform, +# run this script with $ENV{EBCDIC_MD5SUM} set to a true value. +# (You'll need to have Perl 5.7.3 or later, to have the Encode installed.) +# (And remember that under the Perl core distribution you should +# also have the $ENV{PERL_CORE} set to a true value.) +# Similarly, to update MacOS section, run with $ENV{MAC_MD5SUM} set. +my $EXPECT; if (ord "A" == 193) { # EBCDIC $EXPECT = <catfile($path, $file); } # print "# file = $file\n"; + unless (-f $file) { + warn "No such file: $file\n"; + next; + } + if ($ENV{EBCDIC_MD5SUM}) { + require Encode; + my $data = cat_file($file); + Encode::from_to($data, 'latin1', 'cp1047'); + print md5_hex($data), " $base\n"; + next; + } + if ($ENV{MAC_MD5SUM}) { + require Encode; + my $data = cat_file($file); + Encode::from_to($data, 'latin1', 'MacRoman'); + print md5_hex($data), " $base\n"; + next; + } my $md5bin = pack("H*", $md5hex); my $md5b64; if ($B64) { @@ -143,7 +175,6 @@ sub digest_file #print "$file $method\n"; open(FILE, $file) or die "Can't open $file: $!"; - binmode(FILE); my $digest = Digest::MD5->new->addfile(*FILE)->$method(); close(FILE); @@ -155,7 +186,10 @@ sub cat_file my($file) = @_; local $/; # slurp open(FILE, $file) or die "Can't open $file: $!"; - binmode(FILE); + + # For PerlIO in case of UTF-8 locales. + eval 'binmode(FILE, ":bytes")' if $] >= 5.008; + my $tmp = ; close(FILE); $tmp;