Change 16085 by jhi@alpha on 2002/04/22 19:48:20

        Upgrade to Encode 1.57, from Dan Kogai.

Affected files ...

.... //depot/perl/ext/Encode/Changes#24 edit
.... //depot/perl/ext/Encode/Encode.pm#100 edit
.... //depot/perl/ext/Encode/Encode.xs#74 edit
.... //depot/perl/ext/Encode/Unicode/Unicode.pm#3 edit
.... //depot/perl/ext/Encode/lib/Encode/CN/HZ.pm#10 edit
.... //depot/perl/ext/Encode/lib/Encode/Encoding.pm#13 edit
.... //depot/perl/ext/Encode/lib/Encode/JP/JIS7.pm#5 edit
.... //depot/perl/ext/Encode/lib/Encode/KR/2022_KR.pm#6 edit
.... //depot/perl/ext/Encode/t/JP.t#17 edit
.... //depot/perl/ext/Encode/t/KR.t#5 edit
.... //depot/perl/ext/Encode/t/jperl.t#6 edit
.... //depot/perl/ext/Encode/t/perlio.t#6 edit

Differences ...

==== //depot/perl/ext/Encode/Changes#24 (text) ====
Index: perl/ext/Encode/Changes
--- perl/ext/Encode/Changes.~1~ Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/Changes     Mon Apr 22 14:00:05 2002
@@ -1,9 +1,20 @@
 # Revision history for Perl extension Encode.
 #
-# $Id: Changes,v 1.56 2002/04/22 09:48:07 dankogai Exp dankogai $
+# $Id: Changes,v 1.57 2002/04/22 20:27:30 dankogai Exp dankogai $
 #
 
-$Revision: 1.56 $ $Date: 2002/04/22 09:48:07 $
+$Revision: 1.57 $ $Date: 2002/04/22 20:27:30 $
+! t/JP.t t/KR.t t/perlio.t
+  unless (find PerlIO::Layer 'perlio') ... line is back again.
+  t/JP.t and t/KR.t were supposed to work but maybe '>:utf8' lines
+  need PerlIO.  Sigh....
+! Encode.xs Unicode/Unicode.pm lib/Encode/JP/JIS7.pm t/perlio.t
+  ->perlio_ok now does eval{ require PerlIO::encoding } there so
+  it correctly returns 1 when PerlIO::encoding is yet loaded.
+! Encode.xs
+  perl-current patch #16072 reflected
+
+1.56 2002/04/22 09:48:07 
 ! Encode.pm encoding.pm t/perlio.t t/jperl.t
   New PerlIO::encoding 0.04 compliance met
 
@@ -443,7 +454,7 @@
   Typo fixes and improvements by jhi
   Message-Id: <[EMAIL PROTECTED]>, et al.
 
-1.11  $Date: 2002/04/22 09:48:07 $
+1.11  $Date: 2002/04/22 20:27:30 $
 + t/encoding.t
 + t/jperl.t
 ! MANIFEST

==== //depot/perl/ext/Encode/Encode.pm#100 (text) ====
Index: perl/ext/Encode/Encode.pm
--- perl/ext/Encode/Encode.pm.~1~       Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/Encode.pm   Mon Apr 22 14:00:05 2002
@@ -1,6 +1,6 @@
 package Encode;
 use strict;
-our $VERSION = do { my @r = (q$Revision: 1.56 $ =~ /\d+/g); sprintf "%d."."%02d" x 
$#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.57 $ =~ /\d+/g); sprintf "%d."."%02d" x 
+$#r, @r };
 our $DEBUG = 0;
 use XSLoader ();
 XSLoader::load 'Encode';
@@ -65,9 +65,8 @@
 }
 
 sub perlio_ok{
-    exists $INC{"PerlIO/encoding.pm"} or return 0;
     my $obj = ref($_[0]) ? $_[0] : find_encoding($_[0]);
-    $obj->can("perlio_ok") and return $obj->perlio_ok() unless $@;
+    $obj->can("perlio_ok") and return $obj->perlio_ok();
     return 0; # safety net
 }
 

==== //depot/perl/ext/Encode/Encode.xs#74 (text) ====
Index: perl/ext/Encode/Encode.xs
--- perl/ext/Encode/Encode.xs.~1~       Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/Encode.xs   Mon Apr 22 14:00:05 2002
@@ -1,5 +1,5 @@
 /*
- $Id: Encode.xs,v 1.33 2002/04/22 03:43:05 dankogai Exp $
+ $Id: Encode.xs,v 1.34 2002/04/22 20:27:30 dankogai Exp dankogai $
  */
 
 #define PERL_NO_GET_CONTEXT
@@ -23,6 +23,7 @@
                         return (y)0; /* fool picky compilers */ \
                          }
 /**/
+
 UNIMPLEMENTED(_encoded_utf8_to_bytes, I32)
 UNIMPLEMENTED(_encoded_bytes_to_utf8, I32)
 
@@ -280,6 +281,7 @@
 CODE:
 {
     encode_t *enc = INT2PTR(encode_t *, SvIV(SvRV(obj)));
+    require_pv(PERLIO_FILENAME);
     if (hv_exists(get_hv("INC", 0), 
                  PERLIO_FILENAME, strlen(PERLIO_FILENAME)))
     {

==== //depot/perl/ext/Encode/Unicode/Unicode.pm#3 (text) ====
Index: perl/ext/Encode/Unicode/Unicode.pm
--- perl/ext/Encode/Unicode/Unicode.pm.~1~      Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/Unicode/Unicode.pm  Mon Apr 22 14:00:05 2002
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-our $VERSION = do { my @r = (q$Revision: 1.34 $ =~ /\d+/g); sprintf "%d."."%02d" x 
$#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.35 $ =~ /\d+/g); sprintf "%d."."%02d" x 
+$#r, @r };
 
 use XSLoader;
 XSLoader::load(__PACKAGE__,$VERSION);
@@ -50,8 +50,12 @@
 sub needs_lines { 0 };
 
 sub perlio_ok { 
-    exists $INC{"PerlIO/encoding.pm"} or return 0;
-    return 1;
+    eval{ require PerlIO::encoding };
+    if ($@){
+       return 0;
+    }else{
+       return 1;
+    }
 }
 
 

==== //depot/perl/ext/Encode/lib/Encode/CN/HZ.pm#10 (text) ====
Index: perl/ext/Encode/lib/Encode/CN/HZ.pm
--- perl/ext/Encode/lib/Encode/CN/HZ.pm.~1~     Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/lib/Encode/CN/HZ.pm Mon Apr 22 14:00:05 2002
@@ -3,7 +3,7 @@
 use strict;
 
 use vars qw($VERSION);
-$VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r 
};
+$VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r 
+};
 
 use Encode ();
 use Encode::CN;
@@ -19,8 +19,6 @@
 sub needs_lines  { 1 }
 
 sub perlio_ok { 
-    # exists $INC{"PerlIO/encoding.pm"} or return 0;
-    # PerlIO::encoding->VERSION >= 0.03 and return 1;
     return 0; # for the time being
 }
 

==== //depot/perl/ext/Encode/lib/Encode/Encoding.pm#13 (text) ====
Index: perl/ext/Encode/lib/Encode/Encoding.pm
--- perl/ext/Encode/lib/Encode/Encoding.pm.~1~  Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/lib/Encode/Encoding.pm      Mon Apr 22 14:00:05 2002
@@ -1,7 +1,7 @@
 package Encode::Encoding;
 # Base class for classes which implement encodings
 use strict;
-our $VERSION = do { my @r = (q$Revision: 1.27 $ =~ /\d+/g); sprintf "%d."."%02d" x 
$#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.28 $ =~ /\d+/g); sprintf "%d."."%02d" x 
+$#r, @r };
 
 sub Define
 {
@@ -127,7 +127,15 @@
 method so that it returns 1 when PerlIO is enabled.  Here is an
 example;
 
- sub perlio_ok { exists $INC{"PerlIO/encoding.pm"} }
+ sub perlio_ok { 
+     eval { require PerlIO::encoding };
+     if ($@){
+        return 0;
+     }else{
+        return 1;
+     }
+  }
+
 
 By default, this method is defined as follows;
 

==== //depot/perl/ext/Encode/lib/Encode/JP/JIS7.pm#5 (text) ====
Index: perl/ext/Encode/lib/Encode/JP/JIS7.pm
--- perl/ext/Encode/lib/Encode/JP/JIS7.pm.~1~   Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/lib/Encode/JP/JIS7.pm       Mon Apr 22 14:00:05 2002
@@ -1,7 +1,7 @@
 package Encode::JP::JIS7;
 use strict;
 
-our $VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x 
$#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x 
+$#r, @r };
 
 use Encode qw(:fallbacks);
 
@@ -24,9 +24,12 @@
 sub needs_lines { 1 }
 
 sub perlio_ok { 
-    exists $INC{"PerlIO/encoding.pm"} or return 0;
-    PerlIO::encoding->VERSION >= 0.03 and return 1;
-    return 0;
+    eval{ require PerlIO::encoding };
+    if ($@){
+        return 0;
+    }else{
+        return (PerlIO::encoding->VERSION >= 0.03);
+    }
 }
 
 use Encode::CJKConstants qw(:all);

==== //depot/perl/ext/Encode/lib/Encode/KR/2022_KR.pm#6 (text) ====
Index: perl/ext/Encode/lib/Encode/KR/2022_KR.pm
--- perl/ext/Encode/lib/Encode/KR/2022_KR.pm.~1~        Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/lib/Encode/KR/2022_KR.pm    Mon Apr 22 14:00:05 2002
@@ -4,7 +4,7 @@
 
 use strict;
 
-our $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x 
$#r, @r };
+our $VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x 
+$#r, @r };
 
 
 my $canon = 'iso-2022-kr';
@@ -16,8 +16,6 @@
 sub needs_lines { 1 }
 
 sub perlio_ok { 
-    #exists $INC{"PerlIO/encoding.pm"} or return 0;
-    #PerlIO::encoding->VERSION >= 0.03 and return 1;
     return 0; # for the time being
 }
 

==== //depot/perl/ext/Encode/t/JP.t#17 (text) ====
Index: perl/ext/Encode/t/JP.t
--- perl/ext/Encode/t/JP.t.~1~  Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/t/JP.t      Mon Apr 22 14:00:05 2002
@@ -12,6 +12,10 @@
        print "1..0 # Skip: EBCDIC\n";
        exit 0;
     }
+    unless (PerlIO::Layer->find('perlio')){
+       print "1..0 # Skip: PerlIO required\n";
+       exit 0;
+    }
     $| = 1;
 }
 use strict;
@@ -53,6 +57,7 @@
     is(compare_text($utf, $ref), 0, "$utf eq $ref");
     
     open $src, "<:utf8", $ref or die "$ref : $!";
+    binmode($src);
     $uni = join('', <$src>);
     close $src;
 

==== //depot/perl/ext/Encode/t/KR.t#5 (text) ====
Index: perl/ext/Encode/t/KR.t
--- perl/ext/Encode/t/KR.t.~1~  Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/t/KR.t      Mon Apr 22 14:00:05 2002
@@ -8,23 +8,23 @@
       print "1..0 # Skip: Encode was not built\n";
       exit 0;
     }
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: PerlIO was not built\n";
+    if (ord("A") == 193) {
+       print "1..0 # Skip: EBCDIC\n";
        exit 0;
     }
-    if (ord("A") == 193) {
-       print "1..0 # Skip: EBCDIC\n";
+    unless (PerlIO::Layer->find('perlio')){
+       print "1..0 # Skip: PerlIO required\n";
        exit 0;
     }
     $| = 1;
 }
 use strict;
-use Test::More tests => 15;
+use Test::More tests => 11;
 #use Test::More qw(no_plan);
 use Encode;
 use File::Basename;
 use File::Spec;
-use File::Compare;
+use File::Compare qw(compare_text);
 require_ok "Encode::KR";
 
 my ($src, $uni, $dst, $txt, $euc, $utf, $ref, $rnd);
@@ -34,48 +34,59 @@
 is($enc->name,'euc-kr');
 my $dir = dirname(__FILE__);
 
-my @subcodings = qw(ksc5601);
-
-for my $subcoding (@subcodings){
-    $euc = File::Spec->catfile($dir,"$subcoding.euc");
+for my $charset (qw(ksc5601)){
+    $euc = File::Spec->catfile($dir,"$charset.euc");
     $utf = File::Spec->catfile($dir,"$$.utf8");
-    $ref = File::Spec->catfile($dir,"$subcoding.ref");
+    $ref = File::Spec->catfile($dir,"$charset.ref");
     $rnd = File::Spec->catfile($dir,"$$.rnd");
-    print "# Basic decode test\n";
-    open($src,"<",$euc) || die "Cannot open $euc:$!";
+
+    open($src,"<",$euc) or die "Cannot open $euc:$!";
     binmode($src);
-    ok(defined($src) && fileno($src));
     $txt = join('',<$src>);
-    open($dst,">:utf8",$utf) || die "Cannot open $utf:$!";
+    close($src);
+    
+    eval{ $uni = $enc->decode($txt, 1) }; 
+    $@ and print $@;
+    ok(defined($uni),  "decode $charset");
+    is(length($txt),0, "decode $charset completely");
+
+    open($dst,">:utf8",$utf) or die "Cannot open $utf:$!";
     binmode($dst);
-    ok(defined($dst) && fileno($dst));
-    eval{ $uni = $enc->decode($txt,1) };
-    $@ and print $@;
-    ok(defined($uni));
-    is(length($txt),0);
     print $dst $uni;
-    close($dst);
-    close($src);
-    ok(compare($utf,$ref) == 0);
-}
+    close($dst); 
+    is(compare_text($utf, $ref), 0, "$utf eq $ref");
+    
+    open $src, "<:utf8", $ref or die "$ref : $!";
+    binmode($src);
+    $uni = join('', <$src>);
+    close $src;
+
+    for my $canon (qw(euc-kr)){
+       my $test = \&is;
+       if   ($charset eq 'jisx0201'){
+           $canon eq 'iso-2022-jp'   and $test = \&isnt;
+           $canon eq 'iso-2022-jp-1' and $test = \&isnt;
+       }elsif($charset eq 'jisx0212'){
+           $canon eq 'shiftjis'    and   $test = \&isnt;
+           $canon eq 'iso-2022-jp' and   $test = \&isnt;
+       }
+       my $rt = ($test eq \&is) ? 'RT' : 'non-RT';
+       $test->($uni, decode($canon, encode($canon, $uni)), 
+             "$rt $charset $canon");
+       
+     }
 
-print "# Basic encode test\n";
-open($src,"<:utf8",$ref) || die "Cannot open $ref:$!";
-binmode($src);
-ok(defined($src) && fileno($src));
-$uni = join('',<$src>);
-open($dst,">",$rnd) || die "Cannot open $rnd:$!";
-binmode($dst);
-ok(defined($dst) && fileno($dst));
-$txt = $enc->encode($uni,1);
-ok(defined($txt));
-is(length($uni),0);
-print $dst $txt;
-close($dst);
-close($src);
-ok(compare($euc,$rnd) == 0);
+    eval{ $txt = $enc->encode($uni,1) };    
+    $@ and print $@;
+    ok(defined($txt),   "encode $charset");
+    is(length($uni), 0, "encode $charset completely");
 
-is($enc->name,'euc-kr');
+    open($dst,">", $rnd) or die "Cannot open $utf:$!";
+    binmode($dst);
+    print $dst $txt;
+    close($dst); 
+    is(compare_text($euc, $rnd), 0 => "$rnd eq $euc");
+}
 
 END {
  1 while unlink($utf,$rnd);

==== //depot/perl/ext/Encode/t/jperl.t#6 (text) ====
Index: perl/ext/Encode/t/jperl.t
--- perl/ext/Encode/t/jperl.t.~1~       Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/t/jperl.t   Mon Apr 22 14:00:05 2002
@@ -1,5 +1,5 @@
 #
-# $Id: jperl.t,v 1.23 2002/04/22 09:48:07 dankogai Exp dankogai $
+# $Id: jperl.t,v 1.23 2002/04/22 09:48:07 dankogai Exp $
 #
 # This script is written in euc-jp
 

==== //depot/perl/ext/Encode/t/perlio.t#6 (text) ====
Index: perl/ext/Encode/t/perlio.t
--- perl/ext/Encode/t/perlio.t.~1~      Mon Apr 22 14:00:05 2002
+++ perl/ext/Encode/t/perlio.t  Mon Apr 22 14:00:05 2002
@@ -12,6 +12,10 @@
        print "1..0 # Skip: EBCDIC\n";
        exit 0;
     }
+    unless (PerlIO::Layer->find('perlio')){
+        print "1..0 # Skip: PerlIO required\n";
+        exit 0;
+    }
     $| = 1;
 }
 
@@ -28,8 +32,6 @@
 our $DEBUG = 0;
 
 use Encode (":all");
-eval { require PerlIO::encoding };
-
 {
     no warnings;
     @ARGV and $DEBUG = shift;
End of Patch.

Reply via email to