Change 18865 by [EMAIL PROTECTED] on 2003/03/09 13:50:57

        From Inaba Hiroto: DATA wasn't properly utf8ed
        under 'use encoding'.

Affected files ...

... //depot/perl/MANIFEST#991 edit
... //depot/perl/ext/Encode/MANIFEST#40 edit
... //depot/perl/ext/Encode/t/enc_data.t#1 add
... //depot/perl/toke.c#466 edit

Differences ...

==== //depot/perl/MANIFEST#991 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#990~18851~    Fri Mar  7 22:49:35 2003
+++ perl/MANIFEST       Sun Mar  9 05:50:57 2003
@@ -261,6 +261,7 @@
 ext/Encode/t/CJKT.t            test script
 ext/Encode/t/Encode.t          test script
 ext/Encode/t/Encoder.t         test script
+ext/Encode/t/enc_data.t                test script for utf8 DATA
 ext/Encode/t/enc_eucjp.t       test script
 ext/Encode/t/enc_module.enc    test data for t/enc_module.t
 ext/Encode/t/enc_module.t      test script

==== //depot/perl/ext/Encode/MANIFEST#40 (text) ====
Index: perl/ext/Encode/MANIFEST
--- perl/ext/Encode/MANIFEST#39~18816~  Sun Mar  2 22:17:28 2003
+++ perl/ext/Encode/MANIFEST    Sun Mar  9 05:50:57 2003
@@ -62,6 +62,7 @@
 t/big5-eten.utf        test data
 t/big5-hkscs.enc       test data
 t/big5-hkscs.utf       test data
+t/enc_data.t   test script for utf8 DATA
 t/enc_eucjp.t  test script
 t/enc_module.enc test data for t/enc_module.t
 t/enc_module.t test script

==== //depot/perl/ext/Encode/t/enc_data.t#1 (text) ====
Index: perl/ext/Encode/t/enc_data.t
--- /dev/null   Tue May  5 13:32:27 1998
+++ perl/ext/Encode/t/enc_data.t        Sun Mar  9 05:50:57 2003
@@ -0,0 +1,24 @@
+use encoding 'euc-jp';
+use Test::More tests => 1;
+
+my @a;
+
+while (<DATA>) {
+  chomp;
+  tr/��-��-��/��-��-��/;
+  push @a, $_;
+}
+
+SKIP: {
+  skip("pre-5.8.1 does not do utf8 DATA", 1) if $] < 5.008001;
+  ok(@a == 3 &&
+     $a[0] eq "�����DATA�դ�����Ϥ�ɤ�ΤƤ��ȥǥ���" &&
+     $a[1] eq "���ܸ쥬�������Ѵ��ǥ��륫" &&
+     $a[2] eq "�ɥ����ΤƤ��ȥ򥷥ƥ��ޥ���",
+     "utf8 (euc-jp) DATA")
+}
+
+__DATA__
+�����DATA�ե�����ϥ�ɥ�Υƥ��ȤǤ���
+���ܸ줬�������Ѵ��Ǥ��뤫
+�ɤ����Υƥ��Ȥ򤷤Ƥ��ޤ���

==== //depot/perl/toke.c#466 (text) ====
Index: perl/toke.c
--- perl/toke.c#465~18801~      Sun Mar  2 07:24:22 2003
+++ perl/toke.c Sun Mar  9 05:50:57 2003
@@ -4188,8 +4188,29 @@
                }
 #endif
 #ifdef PERLIO_LAYERS
-               if (UTF && !IN_BYTES)
-                   PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8");
+               if (!IN_BYTES) {
+                   if (UTF)
+                       PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8");
+                   else if (PL_encoding) {
+                       SV *name;
+                       dSP;
+                       ENTER;
+                       SAVETMPS;
+                       PUSHMARK(sp);
+                       EXTEND(SP, 1);
+                       XPUSHs(PL_encoding);
+                       PUTBACK;
+                       call_method("name", G_SCALAR);
+                       SPAGAIN;
+                       name = POPs;
+                       PUTBACK;
+                       PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, 
+                                           Perl_form(aTHX_ ":encoding(%"SVf")",
+                                                     name));
+                       FREETMPS;
+                       LEAVE;
+                   }
+               }
 #endif
                PL_rsfp = Nullfp;
            }
End of Patch.

Reply via email to