From: Gisle Aas Date: Mon, 30 Dec 2002 07:38:16 +0000 (-0800) Subject: Update for ext/Digest/MD5/ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a03235d71a6ebc5a1eb9cdd3a23e531d8645e9c;p=p5sagit%2Fp5-mst-13.2.git Update for ext/Digest/MD5/ Message-ID: p4raw-id: //depot/perl@18492 --- diff --git a/ext/Digest/MD5/Changes b/ext/Digest/MD5/Changes index a100886..2500b89 100644 --- a/ext/Digest/MD5/Changes +++ b/ext/Digest/MD5/Changes @@ -1,3 +1,17 @@ +2002-12-27 Gisle Aas + + Release 2.21 + + Minor tweaks sync up with bleadperl: + - VMS optimizer tweaks to the Makefile.PL + - MacOS support + - Added alignment test + + Added example to the MD5 POD that shows how to calculate the + digest of Unicode strings. + + + 2002-05-05 Gisle Aas Release 2.20 diff --git a/ext/Digest/MD5/MD5.pm b/ext/Digest/MD5/MD5.pm index 372e007..08e616e 100644 --- a/ext/Digest/MD5/MD5.pm +++ b/ext/Digest/MD5/MD5.pm @@ -3,7 +3,7 @@ package Digest::MD5; use strict; use vars qw($VERSION @ISA @EXPORT_OK); -$VERSION = '2.20'; # $Date: 2002/05/06 05:15:09 $ +$VERSION = '2.21'; # $Date: 2002/12/28 05:30:03 $ require Exporter; *import = \&Exporter::import; @@ -214,6 +214,29 @@ the file: print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n"; +Perl 5.8 support Unicode characters in strings. Since the MD5 +algorithm is only defined for strings of bytes, it can not be used on +strings that contains chars with ordinal number above 255. The MD5 +functions and methods will croak if you try to feed them such input +data: + + use Digest::MD5 qw(md5_hex); + + my $str = "abc\x{300}"; + print md5_hex($str), "\n"; # croaks + # Wide character in subroutine entry + +What you can do is calculate the MD5 checksum of the UTF-8 +representation of such strings. This is achieved by filtering the +string through encode_utf8() function: + + use Digest::MD5 qw(md5_hex); + use Encode qw(encode_utf8); + + my $str = "abc\x{300}"; + print md5_hex(encode_utf8($str)), "\n"; + # 8c2d46911f3f5a326455f0ed7a8ed3b3 + =head1 SEE ALSO L, diff --git a/ext/Digest/MD5/Makefile.PL b/ext/Digest/MD5/Makefile.PL index 3a6450c..ceae949 100644 --- a/ext/Digest/MD5/Makefile.PL +++ b/ext/Digest/MD5/Makefile.PL @@ -4,29 +4,32 @@ use Config qw(%Config); use ExtUtils::MakeMaker; my @extra; +@extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment(); -unless ($Config{d_u32align}) { - @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") - if !($Config{'byteorder'} eq '1234' || - $Config{'byteorder'} eq '4321'); -} -my @optimize = (); if ($^O eq 'VMS') { if (defined($Config{ccname})) { if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) { # VAX compiler optimizer even as late as v6.4 gets stuck - @optimize = ("OPTIMIZE","/Optimize=(NODISJOINT)"); + push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)"); } } } + WriteMakefile( 'NAME' => 'Digest::MD5', 'VERSION_FROM' => 'MD5.pm', MAN3PODS => {}, # Pods will be built by installman. @extra, 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, - @optimize ); exit; + + +sub free_u32_alignment +{ + return 0 if $Config{d_u32align}; + return 1 if $Config{'byteorder'} eq '1234' || $Config{'byteorder'} eq '4321'; + return 0; +} diff --git a/ext/Digest/MD5/t/align.t b/ext/Digest/MD5/t/align.t index 4176062..e9660f3 100644 --- a/ext/Digest/MD5/t/align.t +++ b/ext/Digest/MD5/t/align.t @@ -1,6 +1,8 @@ BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } } # Test that md5 works on unaligned memory blocks diff --git a/ext/Digest/MD5/t/files.t b/ext/Digest/MD5/t/files.t index bf8aa06..073bada 100644 --- a/ext/Digest/MD5/t/files.t +++ b/ext/Digest/MD5/t/files.t @@ -10,11 +10,6 @@ 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.) @@ -22,27 +17,29 @@ my $EXPECT; # 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 = <= 5.008; my $tmp = ; close(FILE);