perl-unicode

Re: utf8_heavy noise

2003-06-21 21:30:08

On Sat, 21 Jun 2003 12:47:23 -0400
Daniel Yacob <perl(_at_)geez(_dot_)org> wrote:


Greetings,

I've submitted to CPAN the module Convert::Digits which provides a
conversion service for digits found in the scripts of unicode.  It
works fine as best as I can tell but non-fatal errors do appear from 
utf8_heavy.pl when working on scripts outside the BMP:

Use of uninitialized value in numeric lt (<) at 
/usr/lib/perl5/5.8.0/utf8_heavy.pl line 197.


This is the first time I've worked with chars outside the BMP so
I don't know what issues to anticipate.  Do I need adjust anything
with the module for this range, or is this a known bug in utf8_heavy?
I'm working with Perl 5.8.0 on RH9.

The error lines will appear when running "make test" or the example
script "examples/digits.pl".  Any advice appreciated.

thanks,

/Daniel

    my $bits;
#.... (snip)
    if ($minbits < 32) {
        my $top = 0;
        while ($list =~ /^([0-9a-fA-F]+)(?:[\t]([0-9a-fA-F]+)?)(?:[ 
\t]([0-9a-fA-F]+))?/mg) {
            my $min = hex $1;
            my $max = defined $2 ? hex $2 : $min;
            my $val = defined $3 ? hex $3 : 0;
            $val += $max - $min if defined $3;
            $top = $val if $val > $top;
        }
        $bits =
            $top > 0xffff ? 32 :
            $top > 0xff ? 16 :
            $top > 1 ? 8 : 1
    }
    $bits = $minbits if $bits < $minbits;


Obviously, when $minbits >= 32, $bits is undefined.
That causes the warning in "$bits < $minbits;".

When the right part of tr/// is beyond BMP
(e.g. tr/0/\x{10000}/), Perl_pmtrans in op.c seems to
call swash_init with bits of 32 (as $minbits).

If $minbits >= 32, $bit must be 32 bit,
even without a quite heavy check of $list.
So, I think that C<if ($minbits < 32)> has a sense
and it is better to initialize $bits.
(But is utf8_heavy.pl not ported for 64-bits?)

#a patch against perl(_at_)19792
--- utf8_heavy.pl~      Thu Jan 23 23:23:32 2003
+++ utf8_heavy.pl       Sun Jun 22 13:04:48 2003
@@ -160,7 +160,7 @@
     }
 
     my $extras;
-    my $bits;
+    my $bits = 0;
 
     my $ORIG = $list;
     if ($list) {
#End of Patch

SADAHIRO Tomoyuki

<Prev in Thread] Current Thread [Next in Thread>