From: Jarkko Hietaniemi Date: Wed, 9 Jul 2003 08:12:32 +0000 (+0000) Subject: Upgrade to Encode 1.97. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f139f4c25cbb5efe1153fc2070b9a8b96fdf844;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Encode 1.97. p4raw-id: //depot/perl@20090 --- diff --git a/ext/Encode/Changes b/ext/Encode/Changes index 7251f5d..5f8b52c 100644 --- a/ext/Encode/Changes +++ b/ext/Encode/Changes @@ -1,8 +1,18 @@ # Revision history for Perl extension Encode. # -# $Id: Changes,v 1.96 2003/06/18 09:29:02 dankogai Exp $ +# $Id: Changes,v 1.97 2003/07/08 21:52:14 dankogai Exp $ # -$Revision: 1.96 $ $Date: 2003/06/18 09:29:02 $ +$Revision: 1.97 $ $Date: 2003/07/08 21:52:14 $ +! encoding.pm lib/Encode/Guess.pm lib/Encode/Alias.pm + lib/Encode/JP/JIS7.pm lib/Encode/Encoder.pm Encode.pm + $DEBUG replaced with DEBUG() so perl optimizes better, + by Rafael with further fixes by dankogai + Message-Id: <20030705222023.1f24e041.rgarciasuarez@free.fr> +! lib/Encode/Aliases.pm + Was: define_alias( qr/\bGB[-_ ]?2312(?:\D.*$|$)/i => '"euc-cn"' ); + Now: define_alias( qr/\bGB[-_ ]?2312(?!-?raw)/i => '"euc-cn"' ); + So new hash seeding introduced in bleedperl works. + Message-Id: <20030629100937.GD20285@vipunen.hut.fi> ! lib/Encode/Guess.pm $Encode::Guess::NoUTFAutoGuess is added so you can turn off automatic utf(8|16|32) guessing -- originally by Autrijus diff --git a/ext/Encode/Encode.pm b/ext/Encode/Encode.pm index db74b6a..248586a 100644 --- a/ext/Encode/Encode.pm +++ b/ext/Encode/Encode.pm @@ -1,10 +1,10 @@ # -# $Id: Encode.pm,v 1.96 2003/06/18 09:29:02 dankogai Exp $ +# $Id: Encode.pm,v 1.97 2003/07/08 21:52:14 dankogai Exp $ # package Encode; use strict; -our $VERSION = do { my @r = (q$Revision: 1.96 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; -our $DEBUG = 0; +our $VERSION = do { my @r = (q$Revision: 1.97 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +sub DEBUG () { 0 } use XSLoader (); XSLoader::load(__PACKAGE__, $VERSION); @@ -60,7 +60,7 @@ sub encodings }else{ %enc = %Encoding; for my $mod (map {m/::/o ? $_ : "Encode::$_" } @_){ - $DEBUG and warn $mod; + DEBUG and warn $mod; for my $enc (keys %ExtModule){ $ExtModule{$enc} eq $mod and $enc{$enc} = $mod; } @@ -258,11 +258,11 @@ sub predefine_encodings{ push @Encode::utf8::ISA, 'Encode::Encoding'; # if ($use_xs){ - $DEBUG and warn __PACKAGE__, " XS on"; + Encode::DEBUG and warn __PACKAGE__, " XS on"; *decode = \&decode_xs; *encode = \&encode_xs; }else{ - $DEBUG and warn __PACKAGE__, " XS off"; + Encode::DEBUG and warn __PACKAGE__, " XS off"; *decode = sub{ my ($obj,$octets,$chk) = @_; my $str = Encode::decode_utf8($octets); diff --git a/ext/Encode/META.yml b/ext/Encode/META.yml index 075c6a9..1216c72 100644 --- a/ext/Encode/META.yml +++ b/ext/Encode/META.yml @@ -1,6 +1,6 @@ #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Encode -version: 1.96 +version: 1.97 version_from: Encode.pm installdirs: perl requires: diff --git a/ext/Encode/encoding.pm b/ext/Encode/encoding.pm index 3fc6e43..8992307 100644 --- a/ext/Encode/encoding.pm +++ b/ext/Encode/encoding.pm @@ -1,10 +1,10 @@ -# $Id: encoding.pm,v 1.45 2003/06/18 09:29:02 dankogai Exp $ +# $Id: encoding.pm,v 1.46 2003/07/08 21:52:14 dankogai Exp $ package encoding; -our $VERSION = do { my @r = (q$Revision: 1.45 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.46 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; use Encode; use strict; -our $DEBUG = 0; +sub DEBUG () { 0 } BEGIN { if (ord("A") == 193) { @@ -42,7 +42,7 @@ sub import { } $name = $enc->name; # canonize unless ($arg{Filter}) { - $DEBUG and warn "_exception($name) = ", _exception($name); + DEBUG and warn "_exception($name) = ", _exception($name); _exception($name) or ${^ENCODING} = $enc; $HAS_PERLIO or return 1; }else{ @@ -56,14 +56,13 @@ sub import { filter_add(sub{ my $status = filter_read(); if ($status > 0){ - # $DEBUG and warn $_; $_ = $enc->decode($_, 1); - $DEBUG and warn $_; + DEBUG and warn $_; } $status ; }); }; - } $DEBUG and warn "Filter installed"; + } DEBUG and warn "Filter installed"; defined ${^UNICODE} and ${^UNICODE} != 0 and return 1; for my $h (qw(STDIN STDOUT)){ if ($arg{$h}){ diff --git a/ext/Encode/lib/Encode/Alias.pm b/ext/Encode/lib/Encode/Alias.pm index 70b3dd8..1abfcaf 100644 --- a/ext/Encode/lib/Encode/Alias.pm +++ b/ext/Encode/lib/Encode/Alias.pm @@ -2,8 +2,8 @@ package Encode::Alias; use strict; no warnings 'redefine'; use Encode; -our $VERSION = do { my @r = (q$Revision: 1.36 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; -our $DEBUG = 0; +our $VERSION = do { my @r = (q$Revision: 1.37 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +sub DEBUG () { 0 } use base qw(Exporter); @@ -32,13 +32,13 @@ sub find_alias my $new; if (ref($alias) eq 'Regexp' && $find =~ $alias) { - $DEBUG and warn "eval $val"; + DEBUG and warn "eval $val"; $new = eval $val; - $DEBUG and $@ and warn "$val, $@"; + DEBUG and $@ and warn "$val, $@"; } elsif (ref($alias) eq 'CODE') { - $DEBUG and warn "$alias", "->", "($find)"; + DEBUG and warn "$alias", "->", "($find)"; $new = $alias->($find); } elsif (lc($find) eq lc($alias)) @@ -48,7 +48,7 @@ sub find_alias if (defined($new)) { next if $new eq $find; # avoid (direct) recursion on bugs - $DEBUG and warn "$alias, $new"; + DEBUG and warn "$alias, $new"; my $enc = (ref($new)) ? $new : Encode::find_encoding($new); if ($enc) { @@ -58,7 +58,7 @@ sub find_alias } } } - if ($DEBUG){ + if (DEBUG){ my $name; if (my $e = $Alias{$find}){ $name = $e->name; @@ -82,17 +82,17 @@ sub define_alias for my $k (@a){ if (ref($alias) eq 'Regexp' && $k =~ $alias) { - $DEBUG and warn "delete \$Alias\{$k\}"; + DEBUG and warn "delete \$Alias\{$k\}"; delete $Alias{$k}; } elsif (ref($alias) eq 'CODE') { - $DEBUG and warn "delete \$Alias\{$k\}"; + DEBUG and warn "delete \$Alias\{$k\}"; delete $Alias{$alias->($name)}; } } }else{ - $DEBUG and warn "delete \$Alias\{$alias\}"; + DEBUG and warn "delete \$Alias\{$alias\}"; delete $Alias{$alias}; } } diff --git a/ext/Encode/lib/Encode/Encoder.pm b/ext/Encode/lib/Encode/Encoder.pm index 5f2451b..dfa53f4 100644 --- a/ext/Encode/lib/Encode/Encoder.pm +++ b/ext/Encode/lib/Encode/Encoder.pm @@ -1,17 +1,17 @@ # -# $Id: Encoder.pm,v 0.6 2003/02/06 01:52:11 dankogai Exp $ +# $Id: Encoder.pm,v 0.7 2003/07/08 21:52:14 dankogai Exp $ # package Encode::Encoder; use strict; use warnings; -our $VERSION = do { my @r = (q$Revision: 0.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 0.7 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw ( encoder ); our $AUTOLOAD; -our $DEBUG = 0; +sub DEBUG () { 0 } use Encode qw(encode decode find_encoding from_to); use Carp; @@ -66,7 +66,7 @@ sub bytes { } sub DESTROY{ # defined so it won't autoload. - $DEBUG and warn shift; + DEBUG and warn shift; } sub AUTOLOAD { @@ -77,7 +77,7 @@ sub AUTOLOAD { $myname =~ s/.*://; # strip fully-qualified portion my $obj = find_encoding($myname) or confess __PACKAGE__, ": unknown encoding: $myname"; - $DEBUG and warn $self->{encoding}, " => ", $obj->name; + DEBUG and warn $self->{encoding}, " => ", $obj->name; if ($self->{encoding}){ from_to($self->{data}, $self->{encoding}, $obj->name, 1); }else{ diff --git a/ext/Encode/lib/Encode/Guess.pm b/ext/Encode/lib/Encode/Guess.pm index 5858f81..8a4f04c 100644 --- a/ext/Encode/lib/Encode/Guess.pm +++ b/ext/Encode/lib/Encode/Guess.pm @@ -2,10 +2,10 @@ package Encode::Guess; use strict; use Encode qw(:fallbacks find_encoding); -our $VERSION = do { my @r = (q$Revision: 1.8 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.9 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; my $Canon = 'Guess'; -our $DEBUG = 0; +sub DEBUG () { 0 } our %DEF_SUSPECTS = map { $_ => find_encoding($_) } qw(ascii utf8); $Encode::Encoding{$Canon} = bless { @@ -42,7 +42,7 @@ sub add_suspects{ for my $c (@_){ my $e = find_encoding($c) or die "Unknown encoding: $c"; $self->{Suspects}{$e->name} = $e; - $DEBUG and warn "Added: ", $e->name; + DEBUG and warn "Added: ", $e->name; } } @@ -100,7 +100,7 @@ sub guess { $char & 0xff00 and $le++; } } - $DEBUG and warn "$utf, be == $be, le == $le"; + DEBUG and warn "$utf, be == $be, le == $le"; $be == $le and return "Encodings ambiguous between $utf BE and LE ($be, $le)"; @@ -112,7 +112,7 @@ sub guess { for my $c (@_){ my $e = find_encoding($c) or die "Unknown encoding: $c"; $try{$e->name} = $e; - $DEBUG and warn "Added: ", $e->name; + DEBUG and warn "Added: ", $e->name; } my $nline = 1; for my $line (split /\r\n?|\n/, $octet){ @@ -130,10 +130,10 @@ sub guess { my $scratch = $line; $try{$k}->decode($scratch, FB_QUIET); if ($scratch eq ''){ - $DEBUG and warn sprintf("%4d:%-24s ok\n", $nline, $k); + DEBUG and warn sprintf("%4d:%-24s ok\n", $nline, $k); }else{ use bytes (); - $DEBUG and + DEBUG and warn sprintf("%4d:%-24s not ok; %d bytes left\n", $nline, $k, bytes::length($scratch)); delete $ok{$k}; diff --git a/ext/Encode/lib/Encode/JP/JIS7.pm b/ext/Encode/lib/Encode/JP/JIS7.pm index 01a7f0e..b08cb6c 100644 --- a/ext/Encode/lib/Encode/JP/JIS7.pm +++ b/ext/Encode/lib/Encode/JP/JIS7.pm @@ -1,7 +1,7 @@ package Encode::JP::JIS7; use strict; -our $VERSION = do { my @r = (q$Revision: 1.11 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +our $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; use Encode qw(:fallbacks); @@ -24,8 +24,6 @@ sub needs_lines { 1 } use Encode::CJKConstants qw(:all); -our $DEBUG = 0; - # # decode is identical for all 2022 variants #