perl-unicode

Tk and Encode latest

2002-04-09 06:39:50

Something is still not quite right with Tk and Encode.
Indeed we have gone backwards compared to my patch of Friday:

t/JP.............Deep recursion on subroutine "Encode::find_encoding" at 
/tools/perls/lib/5.7.3/i686-linux-multi/Encode/Alias.pm line 51.
Deep recursion on subroutine "Encode::getEncoding" at 
/tools/perls/lib/5.7.3/i686-linux-multi/Encode.pm line 117.
Deep recursion on subroutine "Encode::Alias::find_alias" at 
/tools/perls/lib/5.7.3/i686-linux-multi/Encode.pm line 97.
make: *** wait: No child processes.  Stop.

(That is Tk's t/JP.t which basicaly tries to display the test file.)

This is with a bleadperl p4 integrated this morning.

Adding some debug this seems to occur looking for 'ucs-2be' which is Tcl/Tk's
name for it.

This is sufficent to reproduce it for me:

../perl -Ilib -MEncode -e 'find_encoding("ucs-2be")'

And the attached patch is sufficent to prune the recursion.

That in turn seems to suffice to fix that problem! (I don't understand why..)

However patch2 adds "names" to the Alias tests.

Next problem is now when Tk tries to probe for U+FF61 it now dies:

UCS-2BE:code point too 
high<\xff61>.Encode::Unicode/tools/perls/lib/5.7.3/i686-linux-multi/Encode/Unicode.pm154
 at /home/p4work/Tkutf8/blib/lib/Tk.pm line 232

Where as UnicodeData.txt has:

FF61;HALFWIDTH IDEOGRAPHIC FULL STOP;Po;0;ON;<narrow> 3002;;;;N;HALFWIDTH 
IDEOGRAPHIC PERIOD;;;;

Which is a legitimate code point!

patch3 corrects that one.

I _think_ that gets me back to where I was. Now I can see if I can get
jis0208 to work ...


--
Nick Ing-Simmons
http://www.ni-s.u-net.com/

--- lib/Encode/Alias.pm.ship    Tue Apr  9 14:10:24 2002
+++ lib/Encode/Alias.pm Tue Apr  9 14:10:12 2002
@@ -24,6 +24,7 @@
     local $_ = shift;
     unless (exists $Alias{$_})
     {
+        $Alias{$_} = undef; # Recursion guard
        for (my $i=0; $i < @Alias; $i += 2)
        {
            my $alias = $Alias[$i];
==== //depot/perlio/ext/Encode/t/Aliases.t#9 - 
/home/p4work/perl/perlio/ext/Encode/t/Aliases.t ====
@@ -26,6 +26,7 @@
            'UCS2'     => 'UCS-2BE',
            'iso-10646-1' => 'UCS-2BE',
            'ucs2-le'  => 'UCS-2LE',
+           'ucs2-be'  => 'UCS-2BE',
            'utf16'    => 'UTF-16',
            'utf32'    => 'UTF-32',
            'utf16-be'  => 'UTF-16BE',
@@ -112,9 +113,9 @@
 
 print "# alias test;  \$ON_EBCDIC == $ON_EBCDIC\n";
 
-foreach my $a (keys %a2c){          
+foreach my $a (keys %a2c){     
     my $e = Encode::find_encoding($a);
-    is((defined($e) and $e->name), $a2c{$a})
+    is((defined($e) and $e->name), $a2c{$a},$a)
        or warn "alias was $a";;
 }
 
@@ -130,18 +131,18 @@
 
 print "# alias test with alias overrides\n";
 
-foreach my $a (keys %a2c){          
+foreach my $a (keys %a2c){     
     my $e = Encode::find_encoding($a);
-    is((defined($e) and $e->name), $a2c{$a})
+    is((defined($e) and $e->name), $a2c{$a}, "Override $a")
        or warn "alias was $a";
 }
 
 print "# alias undef test\n";
 
 Encode::Alias->undef_aliases;
-foreach my $a (keys %a2c){          
+foreach my $a (keys %a2c){     
     my $e = Encode::find_encoding($a);
-    ok(!defined($e) || $e->name =~ /-raw$/o)
+    ok(!defined($e) || $e->name =~ /-raw$/o,"Undef $a")
        or warn "alias was $a";
 }
 
@@ -149,9 +150,9 @@
 
 Encode::Alias->init_aliases;
 init_a2c();
-foreach my $a (keys %a2c){          
+foreach my $a (keys %a2c){     
     my $e = Encode::find_encoding($a);
-    is((defined($e) and $e->name), $a2c{$a})
+    is((defined($e) and $e->name), $a2c{$a}, "Reinit $a")
        or warn "alias was $a";
 }
 __END__
--- lib/Encode/Unicode.pm.ship  Tue Apr  9 14:28:13 2002
+++ lib/Encode/Unicode.pm       Tue Apr  9 14:28:51 2002
@@ -18,7 +18,7 @@
     if ($_[0] < 0xD800){
        return $_[0] > 0;
     }else{
-       return ($_[0] > 0xDFFFF && $_[0] <= 0xFFFF);
+       return ($_[0] > 0xDFFF && $_[0] <= 0xFFFF);
     }
 }