r23581 - in /branches/upstream/libdigest-md5-file-perl/current: Changes File.pm META.yml README t/1.t
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sat Jul 26 15:21:15 UTC 2008
Author: gregoa
Date: Sat Jul 26 15:21:13 2008
New Revision: 23581
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=23581
Log:
[svn-upgrade] Integrating new upstream version, libdigest-md5-file-perl (0.07)
Modified:
branches/upstream/libdigest-md5-file-perl/current/Changes
branches/upstream/libdigest-md5-file-perl/current/File.pm
branches/upstream/libdigest-md5-file-perl/current/META.yml
branches/upstream/libdigest-md5-file-perl/current/README
branches/upstream/libdigest-md5-file-perl/current/t/1.t
Modified: branches/upstream/libdigest-md5-file-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-md5-file-perl/current/Changes?rev=23581&op=diff
==============================================================================
--- branches/upstream/libdigest-md5-file-perl/current/Changes (original)
+++ branches/upstream/libdigest-md5-file-perl/current/Changes Sat Jul 26 15:21:13 2008
@@ -1,5 +1,10 @@
Revision history for Perl extension Digest::MD5::File.
+0.07 Thu Jul 23 10:31:33 2008
+ - rt 34703
+ - argument logic before filehandle fetch so that they'll apply
+ - read small chunk of file handles instead if readline() to avoid various issues
+
0.06 Sat Nov 24 12:15:26 2007
- rt 30618
- rt 29653
Modified: branches/upstream/libdigest-md5-file-perl/current/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-md5-file-perl/current/File.pm?rev=23581&op=diff
==============================================================================
--- branches/upstream/libdigest-md5-file-perl/current/File.pm (original)
+++ branches/upstream/libdigest-md5-file-perl/current/File.pm Sat Jul 26 15:21:13 2008
@@ -41,7 +41,7 @@
Digest::MD5->import(keys %imp);
}
-our $VERSION = '0.06';
+our $VERSION = '0.07';
my $getfh = sub {
my $file = shift;
@@ -65,9 +65,9 @@
sub Digest::MD5::adddir {
my $md5 = shift;
my $base = shift;
- for( keys %{ _dir($base, undef, undef, 3) }) {
- next if !$_;
- my $file = File::Spec->catfile($base, $_);
+ for my $key ( keys %{ _dir($base, undef, undef, 3) }) {
+ next if !$key;
+ my $file = File::Spec->catfile($base, $key);
$md5->addpath($file) or carp "addpath $file failed: $!" if !-d $file;
}
return 1;
@@ -87,7 +87,7 @@
$_md5func = \&file_md5_base64 if $type eq '2';
opendir(DIR, $dir) or return;
- my @dircont = grep( $_ ne '.' && $_ ne '..', readdir(DIR));
+ my @dircont = grep { $_ ne '.' && $_ ne '..' } readdir(DIR);
closedir DIR;
for my $file( @dircont ) {
@@ -140,38 +140,43 @@
}
sub file_md5 {
- my $fh = $getfh->(shift()) or return;
- my ($bn,$ut) = @_;
+ my ($file,$bn,$ut) = @_;
local $BINMODE = $bn if defined $bn;
local $UTF8 = $ut if defined $ut;
+ my $fh = $getfh->($file) or return;
+
my $md5 = Digest::MD5->new();
- while(<$fh>) {
- $md5->add( $UTF8 ? Encode::encode_utf8($_) : $_ );
+ my $buf;
+ while(my $l = read($fh, $buf, 1024)) {
+ $md5->add( $UTF8 ? Encode::encode_utf8($buf) : $buf );
}
return $md5->digest;
}
sub file_md5_hex {
- my $fh = $getfh->(shift()) or return;
- my ($bn,$ut) = @_;
+ my ($file,$bn,$ut) = @_;
local $BINMODE = $bn if defined $bn;
local $UTF8 = $ut if defined $ut;
+ my $fh = $getfh->($file) or return;
+
my $md5 = Digest::MD5->new();
- while(<$fh>) {
- $md5->add( $UTF8 ? Encode::encode_utf8($_) : $_ );
+ my $buf;
+ while(my $l = read($fh, $buf, 1024)) {
+ $md5->add( $UTF8 ? Encode::encode_utf8($buf) : $buf );
}
return $md5->hexdigest;
}
sub file_md5_base64 {
- my $fh = $getfh->(shift()) or return;
- my ($bn,$ut) = @_;
+ my ($file,$bn,$ut) = @_;
local $BINMODE = $bn if defined $bn;
local $UTF8 = $ut if defined $ut;
+ my $fh = $getfh->($file) or return;
my $md5 = Digest::MD5->new();
- while(<$fh>) {
- $md5->add( $UTF8 ? Encode::encode_utf8($_) : $_ );
+ my $buf;
+ while(my $l = read($fh, $buf, 1024)) {
+ $md5->add( $UTF8 ? Encode::encode_utf8($buf) : $buf );
}
return $md5->b64digest;
}
@@ -206,14 +211,15 @@
local $BINMODE = $bn if defined $bn;
local $UTF8 = $ut if defined $ut;
if(ref $fl eq 'ARRAY') {
- for(@{ $fl }) {
- $md5->addpath($_, $bn, $ut) or return;
+ for my $pth (@{ $fl }) {
+ $md5->addpath($pth, $bn, $ut) or return;
}
}
else {
my $fh = $getfh->($fl) or return;
- while(<$fh>) {
- !$UTF8 ? $md5->add($_) : $md5->add(Encode::encode_utf8($_));
+ my $buf;
+ while(my $l = read($fh, $buf, 1024)) {
+ !$UTF8 ? $md5->add($buf) : $md5->add(Encode::encode_utf8($buf));
}
}
return 1;
Modified: branches/upstream/libdigest-md5-file-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-md5-file-perl/current/META.yml?rev=23581&op=diff
==============================================================================
--- branches/upstream/libdigest-md5-file-perl/current/META.yml (original)
+++ branches/upstream/libdigest-md5-file-perl/current/META.yml Sat Jul 26 15:21:13 2008
@@ -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-MD5-File
-version: 0.06
+version: 0.07
version_from: File.pm
installdirs: site
requires:
Modified: branches/upstream/libdigest-md5-file-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-md5-file-perl/current/README?rev=23581&op=diff
==============================================================================
--- branches/upstream/libdigest-md5-file-perl/current/README (original)
+++ branches/upstream/libdigest-md5-file-perl/current/README Sat Jul 26 15:21:13 2008
@@ -1,4 +1,4 @@
-Digest/MD5/File version 0.06
+Digest/MD5/File version 0.07
============================
See Pod for documentation or
Modified: branches/upstream/libdigest-md5-file-perl/current/t/1.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-md5-file-perl/current/t/1.t?rev=23581&op=diff
==============================================================================
--- branches/upstream/libdigest-md5-file-perl/current/t/1.t (original)
+++ branches/upstream/libdigest-md5-file-perl/current/t/1.t Sat Jul 26 15:21:13 2008
@@ -1,9 +1,15 @@
-use Test::More tests => 3;
+use Test::More tests => 5;
BEGIN { use_ok('Digest::MD5::File') };
chdir 't';
-ok( Digest::MD5::File::file_md5_hex('hello-world') eq '2cad20c19a8eb9bb11a9f76527aec9bc', 'simple calc' );
+
+for(1..2) {
+ ok($_ == 1, 'pre do not clobber $_');
+ ok( Digest::MD5::File::file_md5_hex('hello-world') eq '2cad20c19a8eb9bb11a9f76527aec9bc', 'simple calc' );
+ ok($_ == 1, 'pst do not clobber $_');
+ last;
+}
my $hr = Digest::MD5::File::dir_md5_hex('teststruct');
More information about the Pkg-perl-cvs-commits
mailing list