summaryrefslogtreecommitdiff
path: root/cpan/Digest-SHA
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2017-10-05 13:32:45 +0100
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2017-10-05 13:32:45 +0100
commit62e112f35767e13ea6edf52391064ba4290d5400 (patch)
tree07165f58706a3772ee873576f7e7f84906b02059 /cpan/Digest-SHA
parent93309f6b79580ff87f973d8f99f1b23d197749d7 (diff)
downloadperl-62e112f35767e13ea6edf52391064ba4290d5400.tar.gz
Update Digest-SHA to CPAN version 5.98
[DELTA] 5.98 Wed Oct 4 00:40:02 MST 2017 - removed "portable" mode from shasum and addfile -- rarely used, mostly in outdated systems -- potentially confusing features (e.g. \r\r\n -> \n) -- Universal Newlines mode (-U) a much cleaner approach -- mimics Universal Newlines in Python - shasum now uses Digest::SHA explicitly -- no longer loads Digest::SHA::PurePerl as an option -- hence no need for -R switch -- Digest::SHA::PurePerl has its own shasum: shasumpp
Diffstat (limited to 'cpan/Digest-SHA')
-rw-r--r--cpan/Digest-SHA/lib/Digest/SHA.pm23
-rw-r--r--cpan/Digest-SHA/shasum89
-rw-r--r--cpan/Digest-SHA/src/sha.c4
-rw-r--r--cpan/Digest-SHA/src/sha.h4
-rw-r--r--cpan/Digest-SHA/src/sha64bit.c4
-rw-r--r--cpan/Digest-SHA/src/sha64bit.h4
-rw-r--r--cpan/Digest-SHA/t/methods.t31
7 files changed, 38 insertions, 121 deletions
diff --git a/cpan/Digest-SHA/lib/Digest/SHA.pm b/cpan/Digest-SHA/lib/Digest/SHA.pm
index e8500367ac..6a60926067 100644
--- a/cpan/Digest-SHA/lib/Digest/SHA.pm
+++ b/cpan/Digest-SHA/lib/Digest/SHA.pm
@@ -8,7 +8,7 @@ use vars qw($VERSION @ISA @EXPORT_OK);
use Fcntl qw(O_RDONLY);
use integer;
-$VERSION = '5.97';
+$VERSION = '5.98';
require Exporter;
require DynaLoader;
@@ -110,8 +110,8 @@ sub addfile {
return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR';
$mode = defined($mode) ? $mode : "";
- my ($binary, $UNIVERSAL, $BITS, $portable) =
- map { $_ eq $mode } ("b", "U", "0", "p");
+ my ($binary, $UNIVERSAL, $BITS) =
+ map { $_ eq $mode } ("b", "U", "0");
## Always interpret "-" to mean STDIN; otherwise use
## sysopen to handle full range of POSIX file names
@@ -132,17 +132,10 @@ sub addfile {
return($self);
}
- binmode(FH) if $binary || $portable || $UNIVERSAL;
+ binmode(FH) if $binary || $UNIVERSAL;
if ($UNIVERSAL && _istext(*FH, $file)) {
$self->_addfileuniv(*FH);
}
- elsif ($portable && _istext(*FH, $file)) {
- while (<FH>) {
- s/\015?\015\012/\012/g;
- s/\015/\012/g;
- $self->add($_);
- }
- }
else { $self->_addfilebin(*FH) }
close(FH);
@@ -617,8 +610,6 @@ argument to one of the following values:
"0" use BITS mode
- "p" use portable mode (to be deprecated)
-
The "U" mode is modeled on Python's "Universal Newlines" concept, whereby
DOS and Mac OS line terminators are converted internally to UNIX newlines
before processing. This ensures consistent digest values when working
@@ -626,12 +617,6 @@ simultaneously across multiple file systems. B<The "U" mode influences
only text files>, namely those passing Perl's I<-T> test; binary files
are processed with no translation whatsoever.
-The "p" mode differs from "U" only in that it treats "\r\r\n" as a single
-newline, a quirky feature designed to accommodate legacy applications that
-occasionally added an extra carriage return before DOS line terminators.
-The "p" mode will be phased out eventually in favor of the cleaner and
-more well-established Universal Newlines concept.
-
The BITS mode ("0") interprets the contents of I<$filename> as a logical
stream of bits, where each ASCII '0' or '1' character represents a 0 or
1 bit, respectively. All other characters are ignored. This provides
diff --git a/cpan/Digest-SHA/shasum b/cpan/Digest-SHA/shasum
index 59c3839b2e..1b9bf6e6f9 100644
--- a/cpan/Digest-SHA/shasum
+++ b/cpan/Digest-SHA/shasum
@@ -4,14 +4,13 @@
##
## Copyright (C) 2003-2017 Mark Shelor, All Rights Reserved
##
- ## Version: 5.97
- ## Wed Sep 6 02:23:02 MST 2017
+ ## Version: 5.98
+ ## Wed Oct 4 00:40:02 MST 2017
## shasum SYNOPSIS adapted from GNU Coreutils sha1sum. Add
## "-a" option for algorithm selection,
- ## "-U" option for Universal Newlines support,
- ## "-0" option for reading bit strings, and
- ## "-p" option for portable digests (to be deprecated).
+ ## "-U" option for Universal Newlines support, and
+ ## "-0" option for reading bit strings.
BEGIN { pop @INC if $INC[-1] eq '.' }
@@ -19,6 +18,7 @@ use strict;
use warnings;
use Fcntl;
use Getopt::Long;
+use Digest::SHA;
my $POD = <<'END_OF_POD';
@@ -42,7 +42,6 @@ shasum - Print or Check SHA Checksums
ASCII '0' interpreted as 0-bit,
ASCII '1' interpreted as 1-bit,
all other characters ignored
- -p, --portable read in portable mode (to be deprecated)
The following three options are useful only when verifying checksums:
-s, --status don't output anything, status code shows success
@@ -60,11 +59,10 @@ shasum - Print or Check SHA Checksums
The sums are computed as described in FIPS PUB 180-4. When checking,
the input should be a former output of this program. The default
mode is to print a line with checksum, a character indicating type
- (`*' for binary, ` ' for text, `U' for UNIVERSAL, `^' for BITS, `?'
- for portable), and name for each FILE. The line starts with a `\'
- character if the FILE name contains either newlines or backslashes,
- which are then replaced by the two-character sequences `\n' and `\\'
- respectively.
+ (`*' for binary, ` ' for text, `U' for UNIVERSAL, `^' for BITS),
+ and name for each FILE. The line starts with a `\' character if the
+ FILE name contains either newlines or backslashes, which are then
+ replaced by the two-character sequences `\n' and `\\' respectively.
Report shasum bugs to mshelor@cpan.org
@@ -100,14 +98,13 @@ Copyright (c) 2003-2017 Mark Shelor <mshelor@cpan.org>.
=head1 SEE ALSO
-I<shasum> is implemented using the Perl module L<Digest::SHA> or
-L<Digest::SHA::PurePerl>.
+I<shasum> is implemented using the Perl module L<Digest::SHA>.
=cut
END_OF_POD
-my $VERSION = "5.97";
+my $VERSION = "5.98";
sub usage {
my($err, $msg) = @_;
@@ -134,8 +131,8 @@ select((select(STDERR), $| = 1)[0]);
## Collect options from command line
-my ($alg, $binary, $check, $text, $status, $quiet, $warn, $help, $version);
-my ($portable, $BITS, $reverse, $UNIVERSAL, $versions);
+my ($alg, $binary, $check, $text, $status, $quiet, $warn, $help);
+my ($version, $BITS, $UNIVERSAL);
eval { Getopt::Long::Configure ("bundling") };
GetOptions(
@@ -144,11 +141,8 @@ GetOptions(
's|status' => \$status, 'w|warn' => \$warn,
'q|quiet' => \$quiet,
'h|help' => \$help, 'v|version' => \$version,
- 'p|portable' => \$portable,
'0|01' => \$BITS,
- 'R|REVERSE' => \$reverse,
'U|UNIVERSAL' => \$UNIVERSAL,
- 'V|VERSIONS' => \$versions,
) or usage(1, "");
@@ -158,7 +152,7 @@ usage(0)
if $help;
usage(1, "shasum: Ambiguous file mode\n")
if scalar(grep {defined $_}
- ($binary, $portable, $text, $BITS, $UNIVERSAL)) > 1;
+ ($binary, $text, $BITS, $UNIVERSAL)) > 1;
usage(1, "shasum: --warn option used only when verifying checksums\n")
if $warn && !$check;
usage(1, "shasum: --status option used only when verifying checksums\n")
@@ -167,27 +161,6 @@ usage(1, "shasum: --quiet option used only when verifying checksums\n")
if $quiet && !$check;
- ## Try to use Digest::SHA. If not installed, use the slower
- ## but functionally equivalent Digest::SHA::PurePerl instead.
-
- ## If option -R is invoked, reverse the module preference,
- ## i.e. try Digest::SHA::PurePerl first, then Digest::SHA.
-
-my @MODS = qw(Digest::SHA Digest::SHA::PurePerl);
-@MODS[0, 1] = @MODS[1, 0] if $reverse;
-
-my $module;
-for (@MODS) {
- my $mod = $_;
- if (eval "require $mod") {
- $module = $mod;
- last;
- }
-}
-die "shasum: Unable to find " . join(" or ", @MODS) . "\n"
- unless defined $module;
-
-
## Default to SHA-1 unless overridden by command line option
$alg = 1 unless defined $alg;
@@ -202,24 +175,16 @@ if ($version) {
exit(0);
}
-if ($versions) {
- print "shasum $VERSION\n";
- print "$module ", eval "\$${module}::VERSION", "\n";
- print "perl ", defined $^V ? sprintf("%vd", $^V) : $], "\n";
- exit(0);
-}
-
## Try to figure out if the OS is DOS-like. If it is,
## default to binary mode when reading files, unless
## explicitly overridden by command line "--text" or
- ## "--UNIVERSAL" or "--portable" options.
+ ## "--UNIVERSAL" options.
my $isDOSish = ($^O =~ /^(MSWin\d\d|os2|dos|mint|cygwin)$/);
-if ($isDOSish) { $binary = 1 unless $text || $UNIVERSAL || $portable }
+if ($isDOSish) { $binary = 1 unless $text || $UNIVERSAL }
-my $modesym = $binary ? '*' : ($UNIVERSAL ? 'U' :
- ($BITS ? '^' : ($portable ? '?' : ' ')));
+my $modesym = $binary ? '*' : ($UNIVERSAL ? 'U' : ($BITS ? '^' : ' '));
## Read from STDIN (-) if no files listed on command line
@@ -232,9 +197,8 @@ my $modesym = $binary ? '*' : ($UNIVERSAL ? 'U' :
sub sumfile {
my $file = shift;
- my $mode = $binary ? 'b' : ($UNIVERSAL ? 'U' :
- ($BITS ? '0' : ($portable ? 'p' : '')));
- my $digest = eval { $module->new($alg)->addfile($file, $mode) };
+ my $mode = $binary ? 'b' : ($UNIVERSAL ? 'U' : ($BITS ? '0' : ''));
+ my $digest = eval { Digest::SHA->new($alg)->addfile($file, $mode) };
if ($@) { warn "shasum: $file: $!\n"; return }
$digest->hexdigest;
}
@@ -253,7 +217,6 @@ sub unescape {
$_ = shift;
s/\\\\/\0/g;
s/\\n/\n/g;
- return if /\\/;
s/\0/\\/g;
return $_;
}
@@ -273,12 +236,10 @@ sub verify {
or sysopen(FH, $checkfile, O_RDONLY)
or die "shasum: $checkfile: $!\n";
while (<FH>) {
- next if /^#/; s/\n$//; s/^[ \t]+//; $num_lines++;
- $bslash = s/^\\//;
- ($sum, $modesym, $fname) =
- /^([\da-fA-F]+)[ \t]([ *?^U])([^\0]*)/;
+ next if /^#/; $num_lines++;
+ ($bslash, $sum, $modesym, $fname) =
+ /^[ \t]*(\\?)([\da-fA-F]+)[ \t]([ *^U])(.+)/;
$alg = defined $sum ? $len2alg{length($sum)} : undef;
- $fname = unescape($fname) if defined $fname && $bslash;
if (grep { ! defined $_ } ($alg, $sum, $modesym, $fname)) {
$alg = 1 unless defined $alg;
warn("shasum: $checkfile: $.: improperly " .
@@ -286,10 +247,10 @@ sub verify {
$fmt_errs++;
next;
}
- $fname =~ s/\r$// unless -e $fname;
+ $fname = unescape($fname) if $bslash;
$rsp = "$fname: "; $num_files++;
- ($binary, $text, $UNIVERSAL, $BITS, $portable) =
- map { $_ eq $modesym } ('*', ' ', 'U', '^', 'p');
+ ($binary, $text, $UNIVERSAL, $BITS) =
+ map { $_ eq $modesym } ('*', ' ', 'U', '^');
$isOK = 0;
unless ($digest = sumfile($fname)) {
$rsp .= "FAILED open or read\n";
diff --git a/cpan/Digest-SHA/src/sha.c b/cpan/Digest-SHA/src/sha.c
index 51f472cd1d..c1f7407fb4 100644
--- a/cpan/Digest-SHA/src/sha.c
+++ b/cpan/Digest-SHA/src/sha.c
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2017 Mark Shelor, All Rights Reserved
*
- * Version: 5.97
- * Wed Sep 6 02:23:02 MST 2017
+ * Version: 5.98
+ * Wed Oct 4 00:40:02 MST 2017
*
*/
diff --git a/cpan/Digest-SHA/src/sha.h b/cpan/Digest-SHA/src/sha.h
index 9fd6feb9e5..afb6af5024 100644
--- a/cpan/Digest-SHA/src/sha.h
+++ b/cpan/Digest-SHA/src/sha.h
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2017 Mark Shelor, All Rights Reserved
*
- * Version: 5.97
- * Wed Sep 6 02:23:02 MST 2017
+ * Version: 5.98
+ * Wed Oct 4 00:40:02 MST 2017
*
*/
diff --git a/cpan/Digest-SHA/src/sha64bit.c b/cpan/Digest-SHA/src/sha64bit.c
index be02564eb5..f9693d27d2 100644
--- a/cpan/Digest-SHA/src/sha64bit.c
+++ b/cpan/Digest-SHA/src/sha64bit.c
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2017 Mark Shelor, All Rights Reserved
*
- * Version: 5.97
- * Wed Sep 6 02:23:02 MST 2017
+ * Version: 5.98
+ * Wed Oct 4 00:40:02 MST 2017
*
*/
diff --git a/cpan/Digest-SHA/src/sha64bit.h b/cpan/Digest-SHA/src/sha64bit.h
index 4e1d7990e7..f6f89592f8 100644
--- a/cpan/Digest-SHA/src/sha64bit.h
+++ b/cpan/Digest-SHA/src/sha64bit.h
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2017 Mark Shelor, All Rights Reserved
*
- * Version: 5.97
- * Wed Sep 6 02:23:02 MST 2017
+ * Version: 5.98
+ * Wed Oct 4 00:40:02 MST 2017
*
* The following macros supply placeholder values that enable the
* sha.c module to successfully compile when 64-bit integer types
diff --git a/cpan/Digest-SHA/t/methods.t b/cpan/Digest-SHA/t/methods.t
index 223bc5399a..a9096d926b 100644
--- a/cpan/Digest-SHA/t/methods.t
+++ b/cpan/Digest-SHA/t/methods.t
@@ -21,7 +21,7 @@ my @out = (
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
);
-my $numtests = 9 + scalar @out;
+my $numtests = 6 + scalar @out;
print "1..$numtests\n";
# attempt to use an invalid algorithm, and check for failure
@@ -72,35 +72,6 @@ $fh->close;
print "not " unless $sha->addfile($tempfile, "b")->hexdigest eq $rsp;
print "ok ", $testnum++, "\n";
- # test addfile portable mode
-
-$fh = FileHandle->new($tempfile, "w");
-binmode($fh);
-print $fh "abc\012" x 2048; # using UNIX newline
-$fh->close;
-
-print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq
- "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51";
-print "ok ", $testnum++, "\n";
-
-$fh = FileHandle->new($tempfile, "w");
-binmode($fh);
-print $fh "abc\015\012" x 2048; # using DOS/Windows newline
-$fh->close;
-
-print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq
- "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51";
-print "ok ", $testnum++, "\n";
-
-$fh = FileHandle->new($tempfile, "w");
-binmode($fh);
-print $fh "abc\015" x 2048; # using early-Mac newline
-$fh->close;
-
-print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq
- "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51";
-print "ok ", $testnum++, "\n";
-
# test addfile "universal newlines" mode
$fh = FileHandle->new($tempfile, "w");