In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/84678a67ca259ccbce00ff78d3f1e977efab9dcc?hp=7ef3083086f16586f909089ba7d9cc1468ffe2c5>
- Log ----------------------------------------------------------------- commit 84678a67ca259ccbce00ff78d3f1e977efab9dcc Author: Steve Hay <[email protected]> Date: Thu Aug 9 12:51:05 2012 +0100 Upgrade Encode to 2.45 M MANIFEST M Porting/Maintainers.pl M cpan/Encode/Changes M cpan/Encode/Encode.pm M cpan/Encode/MANIFEST A cpan/Encode/META.json M cpan/Encode/META.yml M cpan/Encode/Unicode/Unicode.xs M cpan/Encode/encoding.pm M cpan/Encode/lib/Encode/Alias.pm M cpan/Encode/lib/Encode/Encoder.pm M cpan/Encode/lib/Encode/Unicode/UTF7.pm M cpan/Encode/t/Unicode.t commit 62e824cfa5c39d1f0c3dd440e018928522eda88c Author: Steve Hay <[email protected]> Date: Thu Aug 9 08:31:43 2012 +0100 Upgrade to Time-Local 1.2300 Files are already up to date, but Maintainers.pl is not. M Porting/Maintainers.pl commit 5c4723f6d5880988fc67f13afeeb7ca29356f765 Author: Steve Hay <[email protected]> Date: Thu Aug 9 08:21:59 2012 +0100 Upgrade Module-Metadata to 1.000010 M Porting/Maintainers.pl M cpan/Module-Metadata/lib/Module/Metadata.pm M cpan/Module-Metadata/t/metadata.t commit 201db1c76dc6bb7834b23f3a56ca9a0499470bf9 Author: Steve Hay <[email protected]> Date: Thu Aug 9 08:18:27 2012 +0100 Upgrade Module-Load-Conditional to 0.52 M MANIFEST M Porting/Maintainers.pl M cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm M cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t D cpan/Module-Load-Conditional/t/02_Parse_Version.t A cpan/Module-Load-Conditional/t/test_lib/a/X.pm A cpan/Module-Load-Conditional/t/test_lib/b/X.pm M cpan/Module-Load-Conditional/t/to_load/Commented.pm M cpan/Module-Load-Conditional/t/to_load/LoadIt.pm M cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm A cpan/Module-Load-Conditional/t/to_load/NotMain.pm A cpan/Module-Load-Conditional/t/to_load/NotX.pm ----------------------------------------------------------------------- Summary of changes: MANIFEST | 6 +- Porting/Maintainers.pl | 9 +- cpan/Encode/Changes | 25 +++- cpan/Encode/Encode.pm | 177 +++++++++++--------- cpan/Encode/MANIFEST | 1 + cpan/Encode/META.json | 39 +++++ cpan/Encode/META.yml | 37 ++-- cpan/Encode/Unicode/Unicode.xs | 30 ++-- cpan/Encode/encoding.pm | 6 +- cpan/Encode/lib/Encode/Alias.pm | 5 +- cpan/Encode/lib/Encode/Encoder.pm | 2 +- cpan/Encode/lib/Encode/Unicode/UTF7.pm | 5 +- cpan/Encode/t/Unicode.t | 50 +++++- .../lib/Module/Load/Conditional.pm | 97 ++---------- .../t/01_Module_Load_Conditional.t | 40 +++++- cpan/Module-Load-Conditional/t/02_Parse_Version.t | 99 ----------- .../t/test_lib/a/X.pm} | 3 +- cpan/Module-Load-Conditional/t/test_lib/b/X.pm | 5 + .../Module-Load-Conditional/t/to_load/Commented.pm | 2 + cpan/Module-Load-Conditional/t/to_load/LoadIt.pm | 2 + .../t/to_load/MustBe/Loaded.pm | 2 + cpan/Module-Load-Conditional/t/to_load/NotMain.pm | 3 + cpan/Module-Load-Conditional/t/to_load/NotX.pm | 15 ++ cpan/Module-Metadata/lib/Module/Metadata.pm | 22 ++- cpan/Module-Metadata/t/metadata.t | 36 ++++- 25 files changed, 401 insertions(+), 317 deletions(-) create mode 100644 cpan/Encode/META.json delete mode 100644 cpan/Module-Load-Conditional/t/02_Parse_Version.t copy cpan/{Test-Simple/t/lib/Dummy.pm => Module-Load-Conditional/t/test_lib/a/X.pm} (50%) create mode 100644 cpan/Module-Load-Conditional/t/test_lib/b/X.pm create mode 100644 cpan/Module-Load-Conditional/t/to_load/NotMain.pm create mode 100644 cpan/Module-Load-Conditional/t/to_load/NotX.pm diff --git a/MANIFEST b/MANIFEST index 054acc9..2dd04ec 100644 --- a/MANIFEST +++ b/MANIFEST @@ -858,6 +858,7 @@ cpan/Encode/lib/Encode/Supported.pod Documents for supported encodings cpan/Encode/lib/Encode/Unicode/UTF7.pm Encode extension cpan/Encode/Makefile.PL Encode extension makefile writer cpan/Encode/MANIFEST Encode MANIFEST +cpan/Encode/META.json Encode META.json cpan/Encode/META.yml Encode META.yml cpan/Encode/README Encode extension cpan/Encode/Symbol/Makefile.PL Encode extension @@ -1749,12 +1750,15 @@ cpan/Module-Build/t/write_default_maniskip.t cpan/Module-Build/t/xs.t cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm Module::Conditional cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t Module::Conditional tests -cpan/Module-Load-Conditional/t/02_Parse_Version.t Module::Load::Conditional tests +cpan/Module-Load-Conditional/t/test_lib/a/X.pm Module::Conditional tests +cpan/Module-Load-Conditional/t/test_lib/b/X.pm Module::Conditional tests cpan/Module-Load-Conditional/t/to_load/Commented.pm Module::Conditional tests cpan/Module-Load-Conditional/t/to_load/InPod.pm Module::Load::Conditional tests cpan/Module-Load-Conditional/t/to_load/LoadIt.pm Module::Conditional tests cpan/Module-Load-Conditional/t/to_load/LoadMe.pl Module::Conditional tests cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm Module::Load::Conditional tests +cpan/Module-Load-Conditional/t/to_load/NotMain.pm Module::Conditional tests +cpan/Module-Load-Conditional/t/to_load/NotX.pm Module::Conditional tests cpan/Module-Load-Conditional/t/to_load/ToBeLoaded Module::Conditional tests cpan/Module-Loaded/lib/Module/Loaded.pm Module::Loaded cpan/Module-Loaded/t/01_Module-Loaded.t Module::Loaded tests diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 841e5bd..2def238 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -623,7 +623,7 @@ use File::Glob qw(:case); 'Encode' => { 'MAINTAINER' => 'dankogai', - 'DISTRIBUTION' => 'DANKOGAI/Encode-2.44.tar.gz', + 'DISTRIBUTION' => 'DANKOGAI/Encode-2.45.tar.gz', 'FILES' => q[cpan/Encode], 'UPSTREAM' => 'cpan', }, @@ -1274,7 +1274,7 @@ use File::Glob qw(:case); 'Module::Load::Conditional' => { 'MAINTAINER' => 'kane', - 'DISTRIBUTION' => 'BINGOS/Module-Load-Conditional-0.50.tar.gz', + 'DISTRIBUTION' => 'BINGOS/Module-Load-Conditional-0.52.tar.gz', 'FILES' => q[cpan/Module-Load-Conditional], 'UPSTREAM' => 'cpan', }, @@ -1288,7 +1288,7 @@ use File::Glob qw(:case); 'Module::Metadata' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/Module-Metadata-1.000009.tar.gz', + 'DISTRIBUTION' => 'VPIT/Module-Metadata-1.000010.tar.gz', 'FILES' => q[cpan/Module-Metadata], 'EXCLUDED' => [ qr{^maint}, @@ -1927,12 +1927,13 @@ use File::Glob qw(:case); 'Time::Local' => { 'MAINTAINER' => 'drolsky', - 'DISTRIBUTION' => 'FLORA/Time-Local-1.2000.tar.gz', + 'DISTRIBUTION' => 'DROLSKY/Time-Local-1.2300.tar.gz', 'FILES' => q[cpan/Time-Local], 'EXCLUDED' => [ qw( t/pod-coverage.t t/pod.t ), + qr{^t/release-.*\.t}, ], 'UPSTREAM' => 'cpan', }, diff --git a/cpan/Encode/Changes b/cpan/Encode/Changes index 5423421..f48a02f 100644 --- a/cpan/Encode/Changes +++ b/cpan/Encode/Changes @@ -1,8 +1,29 @@ # Revision history for Perl extension Encode. # -# $Id: Changes,v 2.44 2011/08/09 07:49:44 dankogai Exp dankogai $ +# $Id: Changes,v 2.45 2012/08/05 23:08:49 dankogai Exp dankogai $ # -$Revision: 2.44 $ $Date: 2011/08/09 07:49:44 $ +$Revision: 2.45 $ $Date: 2012/08/05 23:08:49 $ +! lib/Encode/Alias.pm + Addressed RT#78125: Missed Mac Alias x-mac-ce + https://rt.cpan.org/Ticket/Display.html?id=78125 +! lib/Encode/Unicode/UTF7.pm + Applied the patch in RT#76711 + https://rt.cpan.org/Ticket/Display.html?id=76711 +! ucm/gsm0338.ucm + Addressed RT#75670: Wrong decoding for GSM 3.38 character \x09 + https://rt.cpan.org/Ticket/Display.html?id=75670 +! Encode.pm + Applied the patch in RT#72519 + https://rt.cpan.org/Ticket/Display.html?id=72519 +! Unicode/Unicode.xs + t/Unicode.t + Bug fixes in Unicode.xs by chansen + https://github.com/dankogai/p5-encode/pull/5 +! Encode.pm + various POD improvements by daxim + https://github.com/dankogai/p5-encode/pull/4 + +2.44 2011/08/09 07:49:44 ! Unicode/Unicode.xs Addressed the following: Date: Fri, 22 Jul 2011 13:58:43 +0200 diff --git a/cpan/Encode/Encode.pm b/cpan/Encode/Encode.pm index 171b2da..ed3c6e3 100644 --- a/cpan/Encode/Encode.pm +++ b/cpan/Encode/Encode.pm @@ -1,10 +1,10 @@ # -# $Id: Encode.pm,v 2.44 2011/08/09 07:49:44 dankogai Exp dankogai $ +# $Id: Encode.pm,v 2.45 2012/08/05 23:08:49 dankogai Exp dankogai $ # package Encode; use strict; use warnings; -our $VERSION = sprintf "%d.%02d", q$Revision: 2.44 $ =~ /(\d+)/g; +our $VERSION = sprintf "%d.%02d", q$Revision: 2.45 $ =~ /(\d+)/g; use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; use XSLoader (); XSLoader::load( __PACKAGE__, $VERSION ); @@ -61,7 +61,7 @@ eval { }; sub encodings { - my $class = shift; + #my $class = shift; my %enc; if ( @_ and $_[0] eq ":all" ) { %enc = ( %Encoding, %ExtModule ); @@ -247,7 +247,7 @@ sub predefine_encodings { package Encode::UTF_EBCDIC; push @Encode::UTF_EBCDIC::ISA, 'Encode::Encoding'; *decode = sub { - my ( $obj, $str, $chk ) = @_; + my ( undef, $str, $chk ) = @_; my $res = ''; for ( my $i = 0 ; $i < length($str) ; $i++ ) { $res .= @@ -259,7 +259,7 @@ sub predefine_encodings { return $res; }; *encode = sub { - my ( $obj, $str, $chk ) = @_; + my ( undef, $str, $chk ) = @_; my $res = ''; for ( my $i = 0 ; $i < length($str) ; $i++ ) { $res .= @@ -278,7 +278,7 @@ sub predefine_encodings { package Encode::Internal; push @Encode::Internal::ISA, 'Encode::Encoding'; *decode = sub { - my ( $obj, $str, $chk ) = @_; + my ( undef, $str, $chk ) = @_; utf8::upgrade($str); $_[1] = '' if $chk; return $str; @@ -303,7 +303,7 @@ sub predefine_encodings { else { Encode::DEBUG and warn __PACKAGE__, " XS off"; *decode = sub { - my ( $obj, $octets, $chk ) = @_; + my ( undef, $octets, $chk ) = @_; my $str = Encode::decode_utf8($octets); if ( defined $str ) { $_[1] = '' if $chk; @@ -312,7 +312,7 @@ sub predefine_encodings { return undef; }; *encode = sub { - my ( $obj, $string, $chk ) = @_; + my ( undef, $string, $chk ) = @_; my $octets = Encode::encode_utf8($string); $_[1] = '' if $chk; return $octets; @@ -320,7 +320,7 @@ sub predefine_encodings { } *cat_decode = sub { # ($obj, $dst, $src, $pos, $trm, $chk) # currently ignores $chk - my ( $obj, undef, undef, $pos, $trm ) = @_; + my ( undef, undef, undef, $pos, $trm ) = @_; my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; use bytes; if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) { @@ -351,7 +351,9 @@ Encode - character encodings in Perl =head1 SYNOPSIS - use Encode; + use Encode qw(decode encode); + $characters = decode('UTF-8', $octets, Encode::FB_CROAK); + $octets = encode('UTF-8', $characters, Encode::FB_CROAK); =head2 Table of Contents @@ -360,16 +362,23 @@ to fit in one document. This one itself explains the top-level APIs and general topics at a glance. For other topics and more details, see the documentation for these modules: - Name Description - -------------------------------------------------------- - Encode::Alias Alias definitions to encodings - Encode::Encoding Encode Implementation Base Class - Encode::Supported List of Supported Encodings - Encode::CN Simplified Chinese Encodings - Encode::JP Japanese Encodings - Encode::KR Korean Encodings - Encode::TW Traditional Chinese Encodings - -------------------------------------------------------- +=over 2 + +=item L<Encode::Alias> - Alias definitions to encodings + +=item L<Encode::Encoding> - Encode Implementation Base Class + +=item L<Encode::Supported> - List of Supported Encodings + +=item L<Encode::CN> - Simplified Chinese Encodings + +=item L<Encode::JP> - Japanese Encodings + +=item L<Encode::KR> - Korean Encodings + +=item L<Encode::TW> - Traditional Chinese Encodings + +=back =head1 DESCRIPTION @@ -396,32 +405,35 @@ process "sequences of bytes". This is not a problem for Perl: because a byte has 256 possible values, it easily fits in Perl's much larger "logical character". -=head2 TERMINOLOGY +This document mostly explains the I<how>. L<perlunitut> and L<perlunifaq> +explain the I<why>. -=over 2 +=head2 TERMINOLOGY -=item * +=head3 character -I<character>: a character in the range 0 .. 2**32-1 (or more); +A character in the range 0 .. 2**32-1 (or more); what Perl's strings are made of. -=item * +=head3 byte -I<byte>: a character in the range 0..255; -A special case of a Perl character. +A character in the range 0..255; +a special case of a Perl character. -=item * +=head3 octet -I<octet>: 8 bits of data, with ordinal values 0..255; -Term for bytes passed to or from a non-Perl context, such as a disk file. - -=back +8 bits of data, with ordinal values 0..255; +term for bytes passed to or from a non-Perl context, such as a disk file, +standard I/O stream, database, command-line argument, environment variable, +socket etc. =head1 THE PERL ENCODING API -=over 2 +=head2 Basic methods + +=head3 encode -=item $octets = encode(ENCODING, STRING[, CHECK]) + $octets = encode(ENCODING, STRING[, CHECK]) Encodes the scalar value I<STRING> from Perl's internal form into I<ENCODING> and returns a sequence of octets. I<ENCODING> can be either a @@ -441,7 +453,9 @@ contains a completely valid utf8 string. See L</"The UTF8 flag"> below. If the $string is C<undef>, then C<undef> is returned. -=item $string = decode(ENCODING, OCTETS[, CHECK]) +=head3 decode + + $string = decode(ENCODING, OCTETS[, CHECK]) This function returns the string that results from decoding the scalar value I<OCTETS>, assumed to be a sequence of octets in I<ENCODING>, into @@ -463,7 +477,9 @@ below. If the $string is C<undef>, then C<undef> is returned. -=item [$obj =] find_encoding(ENCODING) +=head3 find_encoding + + [$obj =] find_encoding(ENCODING) Returns the I<encoding object> corresponding to I<ENCODING>. Returns C<undef> if no matching I<ENCODING> is find. The returned object is @@ -489,15 +505,17 @@ You can therefore save time by reusing this object as follows; ... # now do something with $utf8; } -Besides C<< ->decode >> and C<< ->encode >>, other methods are -available as well. For instance, C<< ->name >> returns the canonical +Besides L</decode> and L</encode>, other methods are +available as well. For instance, C<name()> returns the canonical name of the encoding object. find_encoding("latin1")->name; # iso-8859-1 See L<Encode::Encoding> for details. -=item [$length =] from_to($octets, FROM_ENC, TO_ENC [, CHECK]) +=head3 from_to + + [$length =] from_to($octets, FROM_ENC, TO_ENC [, CHECK]) Converts I<in-place> data between two encodings. The data in $octets must be encoded as octets and I<not> as characters in Perl's internal @@ -513,7 +531,7 @@ and to convert it back: Because the conversion happens in place, the data to be converted cannot be a string constant: it must be a scalar variable. -from_to() returns the length of the converted string in octets on success, +C<from_to()> returns the length of the converted string in octets on success, and C<undef> on error. B<CAVEAT>: The following operations may look the same, but are not: @@ -542,14 +560,18 @@ followed by C<encode> as follows: $octets = encode($to, decode($from, $octets, $check_from), $check_to); -=item $octets = encode_utf8($string); +=head3 encode_utf8 + + $octets = encode_utf8($string); Equivalent to C<$octets = encode("utf8", $string)>. The characters in $string are encoded in Perl's internal format, and the result is returned as a sequence of octets. Because all possible characters in Perl have a (loose, not strict) UTF-8 representation, this function cannot fail. -=item $string = decode_utf8($octets [, CHECK]); +=head3 decode_utf8 + + $string = decode_utf8($octets [, CHECK]); Equivalent to C<$string = decode("utf8", $octets [, CHECK])>. The sequence of octets represented by $octets is decoded @@ -558,8 +580,6 @@ Because not all sequences of octets are valid UTF-8, it is quite possible for this function to fail. For CHECK, see L</"Handling Malformed Data">. -=back - =head2 Listing available encodings use Encode; @@ -591,7 +611,7 @@ To add a new alias to a given encoding, use: define_alias(NEWNAME => ENCODING); After that, I<NEWNAME> can be used as an alias for I<ENCODING>. -<ENCODING> may be either the name of an encoding or an +I<ENCODING> may be either the name of an encoding or an I<encoding object>. Before you do that, first make sure the alias is nonexistent using @@ -602,7 +622,7 @@ For example: Encode::resolve_alias("iso-8859-12") # false; nonexistent Encode::resolve_alias($name) eq $name # true if $name is canonical -resolve_alias() does not need C<use Encode::Alias>; it can be +C<resolve_alias()> does not need C<use Encode::Alias>; it can be imported via C<use Encode qw(resolve_alias)>. See L<Encode::Alias> for details. @@ -614,7 +634,7 @@ IANA Character Set Registry, commonly seen as C<< Content-Type: text/plain; charset=I<WHATEVER> >>. For most cases, the canonical name works, but sometimes it does not, most notably with "utf-8-strict". -As of C<Encode> version 2.21, a new method C<mime_name()> is thereforeadded. +As of C<Encode> version 2.21, a new method C<mime_name()> is therefore added. use Encode; my $enc = find_encoding("UTF-8"); @@ -668,7 +688,7 @@ C<perlio_ok> method on it: perlio_ok("euc-jp") Fortunately, all encodings that come with C<Encode> core are C<PerlIO>-savvy -except for "hz" and "ISO-2022-kr". For the gory details, see +except for C<hz> and C<ISO-2022-kr>. For the gory details, see L<Encode::Encoding> and L<Encode::PerlIO>. =head1 Handling Malformed Data @@ -680,20 +700,15 @@ encountering malformed data. Without I<CHECK>, C<Encode::FB_DEFAULT> As of version 2.12, C<Encode> supports coderef values for C<CHECK>; see below. -=over 2 - -=item B<NOTE:> Not all encoding support this feature - -Some encodings ignore I<CHECK> argument. For example, +B<NOTE:> Not all encodings support this feature. +Some encodings ignore the I<CHECK> argument. For example, L<Encode::Unicode> ignores I<CHECK> and it always croaks on error. -=back - -Now here is the list of I<CHECK> values available +=head2 List of I<CHECK> values -=over 2 +=head3 FB_DEFAULT -=item I<CHECK> = Encode::FB_DEFAULT ( == 0) + I<CHECK> = Encode::FB_DEFAULT ( == 0) If I<CHECK> is 0, encoding and decoding replace any malformed character with a I<substitution character>. When you encode, I<SUBCHAR> is used. @@ -701,13 +716,17 @@ When you decode, the Unicode REPLACEMENT CHARACTER, code point U+FFFD, is used. If the data is supposed to be UTF-8, an optional lexical warning of warning category C<"utf8"> is given. -=item I<CHECK> = Encode::FB_CROAK ( == 1) +=head3 FB_CROAK + + I<CHECK> = Encode::FB_CROAK ( == 1) If I<CHECK> is 1, methods immediately die with an error message. Therefore, when I<CHECK> is 1, you should trap exceptions with C<eval{}>, unless you really want to let it C<die>. -=item I<CHECK> = Encode::FB_QUIET +=head3 FB_QUIET + + I<CHECK> = Encode::FB_QUIET If I<CHECK> is set to C<Encode::FB_QUIET>, encoding and decoding immediately return the portion of the data that has been processed so far when an @@ -724,17 +743,25 @@ code to do exactly that: # $buffer now contains the unprocessed partial character } -=item I<CHECK> = Encode::FB_WARN +=head3 FB_WARN + + I<CHECK> = Encode::FB_WARN This is the same as C<FB_QUIET> above, except that instead of being silent on errors, it issues a warning. This is handy for when you are debugging. +=head3 FB_PERLQQ FB_HTMLCREF FB_XMLCREF + +=over 2 + =item perlqq mode (I<CHECK> = Encode::FB_PERLQQ) =item HTML charref mode (I<CHECK> = Encode::FB_HTMLCREF) =item XML charref mode (I<CHECK> = Encode::FB_XMLCREF) +=back + For encodings that are implemented by the C<Encode::XS> module, C<CHECK> C<==> C<Encode::FB_PERLQQ> puts C<encode> and C<decode> into C<perlqq> fallback mode. @@ -750,7 +777,7 @@ XML uses C<&#xI<HHHH>;> where I<HHHH> is the hexadecimal number. In C<Encode> 2.10 or later, C<LEAVE_SRC> is also implied. -=item The bitmask +=head3 The bitmask These modes are all actually set via a bitmask. Here is how the C<FB_I<XXX>> constants are laid out. You can import the C<FB_I<XXX>> constants via @@ -766,22 +793,18 @@ constants via C<use Encode qw(:fallback_all)>. HTMLCREF 0x0200 XMLCREF 0x0400 -=back - -=over 2 +=head3 LEAVE_SRC -=item Encode::LEAVE_SRC + Encode::LEAVE_SRC If the C<Encode::LEAVE_SRC> bit is I<not> set but I<CHECK> is set, then the second argument to encode() or decode() will be overwritten in place. If you're not interested in this, then bitwise-OR it with the bitmask. -=back - =head2 coderef for CHECK As of C<Encode> 2.12, C<CHECK> can also be a code reference which takes the -ordinal value of the unmapped caharacter as an argument and returns a string +ordinal value of the unmapped character as an argument and returns a string that represents the fallback character. For instance: $ascii = encode("ascii", $utf8, sub{ sprintf "<U+%04X>", shift }); @@ -880,9 +903,9 @@ The following API uses parts of Perl's internals in the current implementation. As such, they are efficient but may change in a future release. -=over 2 +=head3 is_utf8 -=item is_utf8(STRING [, CHECK]) + is_utf8(STRING [, CHECK]) [INTERNAL] Tests whether the UTF8 flag is turned on in the I<STRING>. If I<CHECK> is true, also checks whether I<STRING> contains well-formed @@ -890,7 +913,9 @@ UTF-8. Returns true if successful, false otherwise. As of Perl 5.8.1, L<utf8> also has the C<utf8::is_utf8> function. -=item _utf8_on(STRING) +=head3 _utf8_on + + _utf8_on(STRING) [INTERNAL] Turns the I<STRING>'s internal UTF8 flag B<on>. The I<STRING> is I<not> checked for containing only well-formed UTF-8. Do not use this @@ -901,7 +926,9 @@ if I<STRING> is not a string. B<NOTE>: For security reasons, this function does not work on tainted values. -=item _utf8_off(STRING) +=head3 _utf8_off + + _utf8_off(STRING) [INTERNAL] Turns the I<STRING>'s internal UTF8 flag B<off>. Do not use frivolously. Returns the previous state of the UTF8 flag, or C<undef> if @@ -911,8 +938,6 @@ previous setting. B<NOTE>: For security reasons, this function does not work on tainted values. -=back - =head1 UTF-8 vs. utf8 vs. UTF8 ....We now view strings not as sequences of bytes, but as sequences @@ -981,7 +1006,7 @@ L<perlebcdic>, L<perlfunc/open>, L<perlunicode>, L<perluniintro>, L<perlunifaq>, L<perlunitut> L<utf8>, -the Perl Unicode Mailing List E<lt>[email protected]<gt> +the Perl Unicode Mailing List L<http://lists.perl.org/list/perl-unicode.html> =head1 MAINTAINER diff --git a/cpan/Encode/MANIFEST b/cpan/Encode/MANIFEST index 3fe6582..830cebc 100644 --- a/cpan/Encode/MANIFEST +++ b/cpan/Encode/MANIFEST @@ -202,3 +202,4 @@ ucm/posix-bc.ucm Unicode Character Map ucm/shiftjis.ucm Unicode Character Map ucm/symbol.ucm Unicode Character Map ucm/viscii.ucm Unicode Character Map +META.json Module JSON meta-data (added by MakeMaker) diff --git a/cpan/Encode/META.json b/cpan/Encode/META.json new file mode 100644 index 0000000..d35ca3f --- /dev/null +++ b/cpan/Encode/META.json @@ -0,0 +1,39 @@ +{ + "abstract" : "unknown", + "author" : [ + "unknown" + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Encode", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : {} + } + }, + "release_status" : "stable", + "version" : "2.45" +} diff --git a/cpan/Encode/META.yml b/cpan/Encode/META.yml index d73458f..bcd3f7b 100644 --- a/cpan/Encode/META.yml +++ b/cpan/Encode/META.yml @@ -1,20 +1,21 @@ ---- #YAML:1.0 -name: Encode -version: 2.44 -abstract: ~ -author: [] -license: unknown -distribution_type: module -configure_requires: - ExtUtils::MakeMaker: 0 +--- +abstract: unknown +author: + - unknown build_requires: - ExtUtils::MakeMaker: 0 -requires: {} -no_index: - directory: - - t - - inc -generated_by: ExtUtils::MakeMaker version 6.57_05 + ExtUtils::MakeMaker: 0 +configure_requires: + ExtUtils::MakeMaker: 0 +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921' +license: unknown meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Encode +no_index: + directory: + - t + - inc +requires: {} +version: 2.45 diff --git a/cpan/Encode/Unicode/Unicode.xs b/cpan/Encode/Unicode/Unicode.xs index 039f155..84dfd46 100644 --- a/cpan/Encode/Unicode/Unicode.xs +++ b/cpan/Encode/Unicode/Unicode.xs @@ -1,5 +1,5 @@ /* - $Id: Unicode.xs,v 2.8 2011/08/09 07:49:44 dankogai Exp dankogai $ + $Id: Unicode.xs,v 2.9 2012/08/05 23:08:49 dankogai Exp dankogai $ */ #define PERL_NO_GET_CONTEXT @@ -199,10 +199,6 @@ CODE: *hv_fetch((HV *)SvRV(obj),"Name",4,0), ord); } - if (s+size <= e) { - /* skip the next one as well */ - enc_unpack(aTHX_ &s,e,size,endian); - } ord = FBCHAR; } else { @@ -217,12 +213,23 @@ CODE: ord = FBCHAR; } } - else { - if (s+size > e) { - /* Partial character */ - s -= size; /* back up to 1st half */ - break; /* And exit loop */ + else if (s+size > e) { + if (check) { + if (check & ENCODE_STOP_AT_PARTIAL) { + s -= size; + break; + } + else { + croak("%"SVf":Malformed HI surrogate %"UVxf, + *hv_fetch((HV *)SvRV(obj),"Name",4,0), + ord); + } } + else { + ord = FBCHAR; + } + } + else { lo = enc_unpack(aTHX_ &s,e,size,endian); if (!isLoSurrogate(lo)) { if (check) { @@ -231,6 +238,7 @@ CODE: ord); } else { + s -= size; ord = FBCHAR; } } @@ -348,7 +356,7 @@ CODE: if (ucs2 == -1) { ucs2 = SvTRUE(attr("ucs2", 4)); } - if (ucs2) { + if (ucs2 || ord > 0x10FFFF) { if (check) { croak("%"SVf":code point \"\\x{%"UVxf"}\" too high", *hv_fetch((HV *)SvRV(obj),"Name",4,0),ord); diff --git a/cpan/Encode/encoding.pm b/cpan/Encode/encoding.pm index 24d6e5b..b5335ea 100644 --- a/cpan/Encode/encoding.pm +++ b/cpan/Encode/encoding.pm @@ -1,4 +1,4 @@ -# $Id: encoding.pm,v 2.9 2011/08/09 07:49:44 dankogai Exp dankogai $ +# $Id: encoding.pm,v 2.10 2012/08/05 23:08:49 dankogai Exp dankogai $ package encoding; our $VERSION = '2.6_01'; @@ -104,6 +104,10 @@ sub _get_locale_encoding { sub import { my $class = shift; my $name = shift; + if (!$name){ + require Carp; + Carp::croak("encoding: no encoding specified."); + } if ( $name eq ':_get_locale_encoding' ) { # used by lib/open.pm my $caller = caller(); { diff --git a/cpan/Encode/lib/Encode/Alias.pm b/cpan/Encode/lib/Encode/Alias.pm index d744cc5..9e15fe3 100644 --- a/cpan/Encode/lib/Encode/Alias.pm +++ b/cpan/Encode/lib/Encode/Alias.pm @@ -2,7 +2,7 @@ package Encode::Alias; use strict; use warnings; no warnings 'redefine'; -our $VERSION = do { my @r = ( q$Revision: 2.15 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; +our $VERSION = do { my @r = ( q$Revision: 2.16 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG}; use base qw(Exporter); @@ -209,7 +209,8 @@ sub init_aliases { define_alias( qr/^(?:x[_-])?mac[_-](.*)$/i => '"mac$1"' ); # http://rt.cpan.org/Ticket/Display.html?id=36326 define_alias( qr/^macintosh$/i => '"MacRoman"' ); - + # https://rt.cpan.org/Ticket/Display.html?id=78125 + define_alias( qr/^macce$/i => '"MacCentralEurRoman"' ); # Ououououou. gone. They are differente! # define_alias( qr/\bmacRomanian$/i => '"macRumanian"'); diff --git a/cpan/Encode/lib/Encode/Encoder.pm b/cpan/Encode/lib/Encode/Encoder.pm index 9a46d36..2cde1e8 100644 --- a/cpan/Encode/lib/Encode/Encoder.pm +++ b/cpan/Encode/lib/Encode/Encoder.pm @@ -1,5 +1,5 @@ # -# $Id: Encoder.pm,v 2.2 2011/08/09 07:49:44 dankogai Exp dankogai $ +# $Id: Encoder.pm,v 2.2 2011/08/09 07:49:44 dankogai Exp $ # package Encode::Encoder; use strict; diff --git a/cpan/Encode/lib/Encode/Unicode/UTF7.pm b/cpan/Encode/lib/Encode/Unicode/UTF7.pm index 1d63962..2e0e4d1 100644 --- a/cpan/Encode/lib/Encode/Unicode/UTF7.pm +++ b/cpan/Encode/lib/Encode/Unicode/UTF7.pm @@ -1,5 +1,5 @@ # -# $Id: UTF7.pm,v 2.5 2010/09/18 18:39:51 dankogai Exp $ +# $Id: UTF7.pm,v 2.6 2012/08/05 23:08:49 dankogai Exp dankogai $ # package Encode::Unicode::UTF7; use strict; @@ -7,7 +7,7 @@ use warnings; no warnings 'redefine'; use base qw(Encode::Encoding); __PACKAGE__->Define('UTF-7'); -our $VERSION = do { my @r = ( q$Revision: 2.5 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; +our $VERSION = do { my @r = ( q$Revision: 2.6 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use MIME::Base64; use Encode; @@ -62,6 +62,7 @@ sub decode($$;$) { my ( $obj, $bytes, $chk ) = @_; my $len = length($bytes); my $str = ""; + pos($bytes) = 0; no warnings 'uninitialized'; while ( pos($bytes) < $len ) { if ( $bytes =~ /\G([^+]+)/ogc ) { diff --git a/cpan/Encode/t/Unicode.t b/cpan/Encode/t/Unicode.t index baa502c..b86ed06 100644 --- a/cpan/Encode/t/Unicode.t +++ b/cpan/Encode/t/Unicode.t @@ -1,5 +1,5 @@ # -# $Id: Unicode.t,v 2.2 2009/11/16 14:08:13 dankogai Exp $ +# $Id: Unicode.t,v 2.3 2012/08/05 23:08:49 dankogai Exp dankogai $ # # This script is written entirely in ASCII, even though quoted literals # do include non-BMP unicode characters -- Are you happy, jhi? @@ -20,7 +20,7 @@ BEGIN { use strict; #use Test::More 'no_plan'; -use Test::More tests => 38; +use Test::More tests => 56; use Encode qw(encode decode find_encoding); # @@ -30,7 +30,7 @@ use Encode qw(encode decode find_encoding); my $dankogai = "\x{5c0f}\x{98fc}\x{3000}\x{5f3e}"; my $nasty = "$dankogai\x{1abcd}"; -my $fallback = "$dankogai\x{fffd}"; +my $fallback = "$dankogai\x{fffd}\x{fffd}"; #hi: (0x1abcd - 0x10000) / 0x400 + 0xD800 = 0xd82a #lo: (0x1abcd - 0x10000) % 0x400 + 0xDC00 = 0xdfcd @@ -85,6 +85,50 @@ is(index($@, 'UCS-2BE'), 0, "encode UCS-2BE: exception"); eval { encode('UCS-2LE', $nasty, 1) }; is(index($@, 'UCS-2LE'), 0, "encode UCS-2LE: exception"); +{ + my %tests = ( + 'UCS-2BE' => 'n*', + 'UCS-2LE' => 'v*', + 'UTF-16BE' => 'n*', + 'UTF-16LE' => 'v*', + 'UTF-32BE' => 'N*', + 'UTF-32LE' => 'V*', + ); + + while (my ($enc, $pack) = each(%tests)) { + is(decode($enc, pack($pack, 0xD800, 0x263A)), "\x{FFFD}\x{263A}", + "decode $enc (HI surrogate followed by WHITE SMILING FACE)"); + is(decode($enc, pack($pack, 0xDC00, 0x263A)), "\x{FFFD}\x{263A}", + "decode $enc (LO surrogate followed by WHITE SMILING FACE)"); + } +} + +{ + my %tests = ( + 'UTF-16BE' => 'n*', + 'UTF-16LE' => 'v*', + ); + + while (my ($enc, $pack) = each(%tests)) { + is(decode($enc, pack($pack, 0xD800)), "\x{FFFD}", + "decode $enc (HI surrogate)"); + is(decode($enc, pack($pack, 0x263A, 0xD800)), "\x{263A}\x{FFFD}", + "decode $enc (WHITE SMILING FACE followed by HI surrogate)"); + } +} + +{ + my %tests = ( + 'UTF-16BE' => 'n*', + 'UTF-16LE' => 'v*', + ); + + while (my ($enc, $pack) = each(%tests)) { + is(encode($enc, "\x{110000}"), pack($pack, 0xFFFD), + "ordinals greater than U+10FFFF is replaced with U+FFFD"); + } +} + # # SvGROW test for (en|de)code_xs # diff --git a/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm b/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm index 09ddeae..0470f47 100644 --- a/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm +++ b/cpan/Module-Load-Conditional/lib/Module/Load/Conditional.pm @@ -11,6 +11,8 @@ use File::Spec (); use FileHandle (); use version; +use Module::Metadata (); + use constant ON_VMS => $^O eq 'VMS'; BEGIN { @@ -18,7 +20,7 @@ BEGIN { $FIND_VERSION $ERROR $CHECK_INC_HASH]; use Exporter; @ISA = qw[Exporter]; - $VERSION = '0.50'; + $VERSION = '0.52'; $VERBOSE = 0; $DEPRECATED = 0; $FIND_VERSION = 1; @@ -248,34 +250,17 @@ sub check_install { ? VMS::Filespec::unixify( $filename ) : $filename; - ### user wants us to find the version from files - if( $FIND_VERSION ) { - - my $in_pod = 0; - my $line; - while ( $line = <$fh> ) { - - ### #24062: "Problem with CPANPLUS 0.076 misidentifying - ### versions after installing Text::NSP 1.03" where a - ### VERSION mentioned in the POD was found before - ### the real $VERSION declaration. - if( $line =~ /^=(.{0,3})/ ) { - $in_pod = $1 ne 'cut'; - } - next if $in_pod; + ### if we don't need the version, we're done + last DIR unless $FIND_VERSION; - ### skip lines which doesn't contain VERSION - next unless $line =~ /VERSION/; + ### otherwise, the user wants us to find the version from files + my $mod_info = Module::Metadata->new_from_handle( $fh, $filename ); + my $ver = $mod_info->version( $args->{module} ); - ### try to find a version declaration in this string. - my $ver = __PACKAGE__->_parse_version( $line ); + if( defined $ver ) { + $href->{version} = $ver; - if( defined $ver ) { - $href->{version} = $ver; - - last DIR; - } - } + last DIR; } } } @@ -319,7 +304,7 @@ sub check_install { }; } - if ( $DEPRECATED and version->new($]) >= version->new('5.011') ) { + if ( $DEPRECATED and "$]" >= 5.011 ) { require Module::CoreList; require Config; @@ -332,64 +317,6 @@ sub check_install { return $href; } -sub _parse_version { - my $self = shift; - my $str = shift or return; - my $verbose = shift || 0; - - ### skip commented out lines, they won't eval to anything. - return if $str =~ /^\s*#/; - - ### the following regexp & eval statement comes from the - ### ExtUtils::MakeMaker source (EU::MM_Unix->parse_version) - ### Following #18892, which tells us the original - ### regex breaks under -T, we must modify it so - ### it captures the entire expression, and eval /that/ - ### rather than $_, which is insecure. - my $taint_safe_str = do { $str =~ /(^.*$)/sm; $1 }; - - if( $str =~ /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/ ) { - - print "Evaluating: $str\n" if $verbose; - - ### this creates a string to be eval'd, like: - # package Module::Load::Conditional::_version; - # no strict; - # - # local $VERSION; - # $VERSION=undef; do { - # use version; $VERSION = qv('0.0.3'); - # }; $VERSION - - my $eval = qq{ - package Module::Load::Conditional::_version; - no strict; - - local $1$2; - \$$2=undef; do { - $taint_safe_str - }; \$$2 - }; - - print "Evaltext: $eval\n" if $verbose; - - my $result = do { - local $^W = 0; - eval($eval); - }; - - - my $rv = defined $result ? $result : '0.0'; - - print( $@ ? "Error: $@\n" : "Result: $rv\n" ) if $verbose; - - return $rv; - } - - ### unable to find a version in this string - return; -} - =head2 $bool = can_load( modules => { NAME => VERSION [,NAME => VERSION] }, [verbose => BOOL, nocache => BOOL] ) C<can_load> will take a list of modules, optionally with version diff --git a/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t b/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t index c846e0d..ee5d59e 100644 --- a/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t +++ b/cpan/Module-Load-Conditional/t/01_Module_Load_Conditional.t @@ -132,6 +132,21 @@ use_ok( 'Module::Load::Conditional' ); is( $rv->{version}, 2, " Version is correct" ); } +### test that no package statement means $VERSION is $main::VERSION +{ + my $rv = check_install( module => 'NotMain' ); + ok( $rv, 'Testing $VERSION without package' ); + is( $rv->{version}, undef, " No version info returned" ); +} + +### test that the right $VERSION is picked when there are several packages +{ + my $rv = check_install( module => 'NotX' ); + ok( $rv, 'Testing $VERSION with many packages' ); + ok( $rv->{version}, " Version found" ); + is( $rv->{version}, 3, " Version is correct" ); +} + ### test beta/developer release versions { my $test_ver = $Module::Load::Conditional::VERSION; @@ -150,7 +165,7 @@ use_ok( 'Module::Load::Conditional' ); } ### test $FIND_VERSION -{ local $Module::Load::Conditional::FIND_VERSION = 0; +{ local $Module::Load::Conditional::FIND_VERSION = 0; my $rv = check_install( module => 'Module::Load::Conditional' ); @@ -160,6 +175,29 @@ use_ok( 'Module::Load::Conditional' ); ok( $rv->{uptodate}, " Module marked as uptodate" ); } +### test that check_install() picks up the first match +{ + my ($dir_a, $dir_b) = map File::Spec->catdir($FindBin::Bin, 'test_lib', $_), + qw[a b]; + my $x_pm = File::Spec->catfile($dir_a, 'X.pm'); + + local @INC = ($dir_a, $dir_b); + + my $rv = check_install( module => 'X' ); + + ok( $rv, 'Testing the file picked by check_install ($FIND_VERSION == 1)' ); + is( $rv->{file}, $x_pm, " First file was picked" ); + is( $rv->{version}, '0.01', " Correct version for first file" ); + + local $Module::Load::Conditional::FIND_VERSION = 0; + + $rv = check_install( module => 'X' ); + + ok( $rv, 'Testing the file picked by check_install ($FIND_VERSION == 0)' ); + is( $rv->{file}, $x_pm, " First file was also picked" ); + is( $rv->{version}, undef, " But its VERSION was not required" ); +} + ### test 'can_load' ### { diff --git a/cpan/Module-Load-Conditional/t/02_Parse_Version.t b/cpan/Module-Load-Conditional/t/02_Parse_Version.t deleted file mode 100644 index fb95df7..0000000 --- a/cpan/Module-Load-Conditional/t/02_Parse_Version.t +++ /dev/null @@ -1,99 +0,0 @@ -BEGIN { chdir 't' if -d 't' } - -use strict; -use lib qw[../lib]; -use Test::More 'no_plan'; - -my $Class = 'Module::Load::Conditional'; -my $Meth = '_parse_version'; -my $Verbose = @ARGV ? 1 : 0; - -use_ok( $Class ); - -### versions that should parse -{ for my $str ( __PACKAGE__->_succeed ) { - my $res = $Class->$Meth( $str, $Verbose ); - ok( defined $res, "String '$str' identified as version string" ); - - ### XXX version.pm 0.69 pure perl fails tests under 5.6.2. - ### XXX version.pm <= 0.69 do not have a complete overload - ### implementation, which causes the following error: - ### $ perl -Mversion -le'qv(1)+0' - ### Operation "+": no method found, - ### left argument in overloaded package version, - ### right argument has no overloaded magic at -e line 1 - ### so we do the comparison ourselves, and then feed it to - ### the Test::More::ok(). - ### - ### Mailed jpeacock and p5p about both issues on 25-1-2007: - ### http://xrl.us/uem7 - ### (http://www.xray.mpe.mpg.de/mailing-lists/ - ### perl5-porters/2007-01/msg00805.html) - - ### Quell "Argument isn't numeric in gt" warnings... - my $bool = do { local $^W; $res > 0 }; - - ok( $bool, " Version is '$res'" ); - isnt( $res, '0.0', " Not the default value" ); - } -} - -### version that should fail -{ for my $str ( __PACKAGE__->_fail ) { - my $res = $Class->$Meth( $str, $Verbose ); - ok( ! defined $res, "String '$str' is not a version string" ); - } -} - - -################################ -### -### VERSION declarations to test -### -################################ - -sub _succeed { - return grep { /\S/ } map { s/^\s*//; $_ } split "\n", q[ - $VERSION = 1; - *VERSION = \'1.01'; - use version; $VERSION = qv('0.0.2'); - use version; $VERSION = qv('3.0.14'); - ($VERSION) = '$Revision: 2.03 $' =~ /\s(\d+\.\d+)\s/; - ( $VERSION ) = sprintf "%d.%02d", q$Revision: 1.23 $ =~ m/ (\d+) \. (\d+) /gx; - ($GD::Graph::area::VERSION) = '$Revision: 1.16.2.3 $' =~ /\s([\d.]+)/; - ($GD::Graph::axestype::VERSION) = '$Revision: 1.44.2.14 $' =~ /\s([\d.]+)/; - ($GD::Graph::colour::VERSION) = '$Revision: 1.10 $' =~ /\s([\d.]+)/; - ($GD::Graph::pie::VERSION) = '$Revision: 1.20.2.4 $' =~ /\s([\d.]+)/; - ($GD::Text::Align::VERSION) = '$Revision: 1.18 $' =~ /\s([\d.]+)/; - $VERSION = qv('0.0.1'); - use version; $VERSION = qv('0.0.3'); - $VERSION = do { my @r = ( ( $v = q<Version value="0.20.1"> ) =~ /\d+/g ); sprintf "%d.%02d", $r[0], int( $r[1] / 10 ) }; - ($VERSION) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:16:00 $ - ( $VERSION = q($Id: Tidy.pm,v 1.56 2006/07/19 23:13:33 perltidy Exp $) ) =~ s/^.*\s+(\d+)\/(\d+)\/(\d+).*$/$1$2$3/; # all one line for MakeMaker - ($VERSION) = q $Revision: 2.120 $ =~ /([\d.]+)/; - ($VERSION) = q$Revision: 1.00 $ =~ /([\d.]+)/; - $VERSION = "3.0.8"; - $VERSION = '1.0.5'; - ]; -} - -sub _fail { - return grep { /\S/ } map { s/^\s*//; $_ } split "\n", q[ - use vars qw($VERSION $AUTOLOAD %ERROR $ERROR $Warn $Die); - sub version { $GD::Graph::colour::VERSION } - my $VERS = qr{ $HWS VERSION $HWS \n }xms; - diag( "Testing $main_module \$${main_module}::VERSION" ); - our ( $VERSION, $v, $_VERSION ); - my $seen = { q{::} => { 'VERSION' => 1 } }; # avoid multiple scans - eval "$module->VERSION" - 'VERSION' => '1.030' # Variable and Value - 'VERSION' => '2.121_020' - 'VERSION' => '0.050', # Standard variable $VERSION - use vars qw( $VERSION $seq @FontDirs ); - $VERSION - # *VERSION = \'1.01'; - # ( $VERSION ) = '$Revision: 1.56 $ ' =~ /\$Revision:\s+([^\s]+)/; - #$VERSION = sprintf("%d.%s", map {s/_//g; $_} q$Name: $ =~ /-(\d+)_([\d_]+)/); - #$VERSION = sprintf("%d.%s", map {s/_//g; $_} q$Name: $ =~ /-(\d+)_([\d_]+)/); - ]; -} diff --git a/cpan/Test-Simple/t/lib/Dummy.pm b/cpan/Module-Load-Conditional/t/test_lib/a/X.pm similarity index 50% copy from cpan/Test-Simple/t/lib/Dummy.pm copy to cpan/Module-Load-Conditional/t/test_lib/a/X.pm index cdff79d..df7eacc 100644 --- a/cpan/Test-Simple/t/lib/Dummy.pm +++ b/cpan/Module-Load-Conditional/t/test_lib/a/X.pm @@ -1,6 +1,5 @@ -package Dummy; +package X; -use strict; our $VERSION = '0.01'; 1; diff --git a/cpan/Module-Load-Conditional/t/test_lib/b/X.pm b/cpan/Module-Load-Conditional/t/test_lib/b/X.pm new file mode 100644 index 0000000..9591f98 --- /dev/null +++ b/cpan/Module-Load-Conditional/t/test_lib/b/X.pm @@ -0,0 +1,5 @@ +package X; + +our $VERSION = '0.02'; + +1; diff --git a/cpan/Module-Load-Conditional/t/to_load/Commented.pm b/cpan/Module-Load-Conditional/t/to_load/Commented.pm index 2ee302e..e3f516e 100644 --- a/cpan/Module-Load-Conditional/t/to_load/Commented.pm +++ b/cpan/Module-Load-Conditional/t/to_load/Commented.pm @@ -1,3 +1,5 @@ +package Commented; + # $VERSION = 1; $VERSION = 2; diff --git a/cpan/Module-Load-Conditional/t/to_load/LoadIt.pm b/cpan/Module-Load-Conditional/t/to_load/LoadIt.pm index 87025e8..64517ec 100644 --- a/cpan/Module-Load-Conditional/t/to_load/LoadIt.pm +++ b/cpan/Module-Load-Conditional/t/to_load/LoadIt.pm @@ -1,3 +1,5 @@ +package LoadIt; + $VERSION = 1; 1; diff --git a/cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm b/cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm index e6423f3..ee857dd 100644 --- a/cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm +++ b/cpan/Module-Load-Conditional/t/to_load/MustBe/Loaded.pm @@ -1,3 +1,5 @@ +package MustBe::Loaded; + $VERSION = 0.01; 1; diff --git a/cpan/Module-Load-Conditional/t/to_load/NotMain.pm b/cpan/Module-Load-Conditional/t/to_load/NotMain.pm new file mode 100644 index 0000000..a883761 --- /dev/null +++ b/cpan/Module-Load-Conditional/t/to_load/NotMain.pm @@ -0,0 +1,3 @@ +$VERSION = 1.23; + +1; diff --git a/cpan/Module-Load-Conditional/t/to_load/NotX.pm b/cpan/Module-Load-Conditional/t/to_load/NotX.pm new file mode 100644 index 0000000..ff54409 --- /dev/null +++ b/cpan/Module-Load-Conditional/t/to_load/NotX.pm @@ -0,0 +1,15 @@ +$VERSION = 1; + +package Y; + +$VERSION = 2; + +package NotX; + +$VERSION = 3; + +package X; + +$VERSION = 4; + +1; diff --git a/cpan/Module-Metadata/lib/Module/Metadata.pm b/cpan/Module-Metadata/lib/Module/Metadata.pm index e52a0e2..ce21787 100644 --- a/cpan/Module-Metadata/lib/Module/Metadata.pm +++ b/cpan/Module-Metadata/lib/Module/Metadata.pm @@ -11,7 +11,7 @@ package Module::Metadata; use strict; use vars qw($VERSION); -$VERSION = '1.000009'; +$VERSION = '1.000010'; $VERSION = eval $VERSION; use Carp qw/croak/; @@ -219,7 +219,7 @@ sub new_from_module { # separating into primary & alternative candidates my( %prime, %alt ); foreach my $file (@files) { - my $mapped_filename = File::Spec->abs2rel( $file, $dir ); + my $mapped_filename = File::Spec::Unix->abs2rel( $file, $dir ); my @path = split( /\//, $mapped_filename ); (my $prime_package = join( '::', @path )) =~ s/\.pm$//; @@ -232,10 +232,12 @@ sub new_from_module { my $version = $pm_info->version( $package ); + $prime_package = $package if lc($prime_package) eq lc($package); if ( $package eq $prime_package ) { if ( exists( $prime{$package} ) ) { croak "Unexpected conflict in '$package'; multiple versions found.\n"; } else { + $mapped_filename = "$package.pm" if lc("$package.pm") eq lc($mapped_filename); $prime{$package}{file} = $mapped_filename; $prime{$package}{version} = $version if defined( $version ); } @@ -420,7 +422,7 @@ sub _parse_version_expression { my $line = shift; my( $sig, $var, $pkg ); - if ( $line =~ $VERS_REGEXP ) { + if ( $line =~ /$VERS_REGEXP/o ) { ( $sig, $var, $pkg ) = $2 ? ( $1, $2, $3 ) : ( $4, $5, $6 ); if ( $pkg ) { $pkg = ($pkg eq '::') ? 'main' : $pkg; @@ -456,12 +458,16 @@ sub _parse_fh { chomp( $line ); next if $line =~ /^\s*#/; - $in_pod = ($line =~ /^=(?!cut)/) ? 1 : ($line =~ /^=cut/) ? 0 : $in_pod; + my $is_cut; + if ( $line =~ /^=(.{0,3})/ ) { + $is_cut = $1 eq 'cut'; + $in_pod = !$is_cut; + } # Would be nice if we could also check $in_string or something too last if !$in_pod && $line =~ /^__(?:DATA|END)__$/; - if ( $in_pod || $line =~ /^=cut/ ) { + if ( $in_pod || $is_cut ) { if ( $line =~ /^=head\d\s+(.+)\s*$/ ) { push( @pod, $1 ); @@ -484,9 +490,11 @@ sub _parse_fh { # parse $line to see if it's a $VERSION declaration my( $vers_sig, $vers_fullname, $vers_pkg ) = - $self->_parse_version_expression( $line ); + ($line =~ /VERSION/) + ? $self->_parse_version_expression( $line ) + : (); - if ( $line =~ $PKG_REGEXP ) { + if ( $line =~ /$PKG_REGEXP/o ) { $pkg = $1; push( @pkgs, $pkg ) unless grep( $pkg eq $_, @pkgs ); $vers{$pkg} = (defined $2 ? $2 : undef) unless exists( $vers{$pkg} ); diff --git a/cpan/Module-Metadata/t/metadata.t b/cpan/Module-Metadata/t/metadata.t index ab9c8c4..2b2d58e 100644 --- a/cpan/Module-Metadata/t/metadata.t +++ b/cpan/Module-Metadata/t/metadata.t @@ -203,7 +203,7 @@ package Simple v1.2.3_4 { ); my %modules = reverse @modules; -plan tests => 42 + 2 * keys( %modules ); +plan tests => 51 + 2 * keys( %modules ); require_ok('Module::Metadata'); @@ -246,7 +246,7 @@ $pm_info = Module::Metadata->new_from_handle( $handle, $file ); ok( defined( $pm_info ), 'new_from_handle() succeeds' ); $pm_info = Module::Metadata->new_from_handle( $handle ); is( $pm_info, undef, "new_from_handle() without filename returns undef" ); - +close($handle); # construct from module name, using custom include path $pm_info = Module::Metadata->new_from_module( @@ -582,3 +582,35 @@ is_deeply( $got_pvfd, $exp_pvfd, "package_version_from_directory()" ) is_deeply( $got_provides, $exp_provides, "provides()" ) or diag explain $got_provides; } + +# Check package_versions_from_directory with regard to case-sensitivity +{ + $dist->change_file( 'lib/Simple.pm', <<'---' ); +package simple; +$VERSION = '0.01'; +--- + $dist->regen; + + $pm_info = Module::Metadata->new_from_file('lib/Simple.pm'); + is( $pm_info->name, undef, 'no default package' ); + is( $pm_info->version, undef, 'version for default package' ); + is( $pm_info->version('simple'), '0.01', 'version for lower-case package' ); + is( $pm_info->version('Simple'), undef, 'version for capitalized package' ); + + $dist->change_file( 'lib/Simple.pm', <<'---' ); +package simple; +$VERSION = '0.01'; +package Simple; +$VERSION = '0.02'; +package SiMpLe; +$VERSION = '0.03'; +--- + $dist->regen; + + $pm_info = Module::Metadata->new_from_file('lib/Simple.pm'); + is( $pm_info->name, 'Simple', 'found default package' ); + is( $pm_info->version, '0.02', 'version for default package' ); + is( $pm_info->version('simple'), '0.01', 'version for lower-case package' ); + is( $pm_info->version('Simple'), '0.02', 'version for capitalized package' ); + is( $pm_info->version('SiMpLe'), '0.03', 'version for mixed-case package' ); +} -- Perl5 Master Repository
