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 = <<EOT;
-a1ee2b18d1e05bdde3a93009e7f9dfda Changes
-5a591a47e8c40fe4b78c744111511c45 README
-c9c83e6dbad5f41722338e67d4428077 MD5.pm
-4850753428db9422e8e5f97b401d5a13 MD5.xs
+ed8efe2e2dbab62fcc9dea2df6682569 Changes
+0565ec21b15c0f23f4c51fb327c8926d README
+0fcdd6d6e33b8772bd4b4832043035cd MD5.pm
+d7fd24455b9160aa8706635d15e6177e MD5.xs
276da0aa4e9a08b7fe09430c9c5690aa rfc1321.txt
EOT
+} elsif ("\n" eq "\015") { # MacOS
+ $EXPECT = <<EOT;
+2879619f967d5fc5a00ffe37b639f2ee Changes
+6c950a0211a5a28f023bb482037698cd README
+4e1043f0a7a266416d8408d6fa96f454 MD5.pm
+6bff95ff70ba43a6c81e255c6510a865 MD5.xs
+754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
+EOT
} else {
+ # This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
$EXPECT = <<EOT;
-3866f3543ef41421c6aed3f198e2e9f5 Changes
-3519f3d02c7c91158f732f0f00064657 README
-01cd8fd24bd46ce1db53074d2af6001a MD5.pm
-1be293491bba726810f8e87671ee0328 MD5.xs
+2879619f967d5fc5a00ffe37b639f2ee Changes
+6c950a0211a5a28f023bb482037698cd README
+4e1043f0a7a266416d8408d6fa96f454 MD5.pm
+6bff95ff70ba43a6c81e255c6510a865 MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
}
next;
}
if ($ENV{EBCDIC_MD5SUM}) {
- use Encode 'from_to';
+ require Encode;
my $data = cat_file($file);
- from_to($data, 'latin1', 'cp1047');
- print md5_hex($data), " $base\n";
+ Encode::from_to($data, 'latin1', 'cp1047');
+ print md5_hex($data), " $base\n";
+ next;
+ }
+ if ($ENV{MAC_MD5SUM}) {
+ my $data = cat_file($file);
+ print md5_hex($data), " $base\n";
next;
}
my $md5bin = pack("H*", $md5hex);
my($file) = @_;
local $/; # slurp
open(FILE, $file) or die "Can't open $file: $!";
+
+ # For PerlIO in case of UTF-8 locales.
+ eval 'binmode(FILE, ":bytes")' if $] >= 5.008;
+
my $tmp = <FILE>;
close(FILE);
$tmp;