Changeset 1791

Show
Ignore:
Timestamp:
11/19/07 18:54:39 (14 months ago)
Author:
miyagawa
Message:

lang/perl/Encode:
Fixed bin/ucmlint logic to do what it's originally supposed to do (I think):

  • Fixed the encode/decode dupe check so it correctly honors the fallback flag 1/3
  • Doesn't give Round-Trip error if e2u or u2e is declared as decode/encode only fallback.

Now ucmlint doesn't give warnings/errors on most of ucms in Encode's own ucm directory (except big5-hkscs.ucm)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Encode/trunk/bin/ucmlint

    r1790 r1791  
    3131 
    3232$| = 1; 
    33 my (%Hdr, %U2E, %E2U); 
     33my (%Hdr, %U2E, %E2U, %Fallback); 
    3434my $in_charmap = 0; 
    3535my $nerror = 0; 
     
    5151for $ARGV (@ARGV){ 
    5252    open UCM, $ARGV or die "$ARGV:$!"; 
    53     %Hdr = %U2E = %E2U = (); 
     53    %Hdr = %U2E = %E2U = %Fallback = (); 
    5454    $in_charmap = $nerror = $nwarning = 0; 
    5555    $. = 0; 
     
    8989            $fb = $1;  
    9090            $Opt{f} and $fb = 0; 
    91             unless ($fb == 1){ # check uni -> enc 
     91            unless ($fb == 3){ # check uni -> enc 
    9292                if (exists $U2E{$uni}){ 
    9393                    nit "dupe encode map: U$uni => $U2E{$uni} and $enc", 1; 
    9494                }else{ 
    9595                    $U2E{$uni} = $enc; 
    96                     if ($Opt{e} and $fb != 3) { 
     96                    $Fallback{$uni}{$enc} = 1 if $fb == 1; 
     97                    if ($Opt{e}) { 
    9798                        my $e = hex2enc($enc); 
    9899                        my $u = hex2uni($uni); 
     
    103104                } 
    104105            } 
    105             unless ($fb == 3){  # check enc -> uni 
     106            unless ($fb == 1){  # check enc -> uni 
    106107                if (exists $E2U{$enc}){ 
    107108                    nit "dupe decode map: $enc => U$E2U{$enc} and U$uni", 1; 
    108109                }else{ 
    109110                    $E2U{$enc} = $uni; 
    110                     if ($Opt{e} and $fb != 1) { 
     111                    $Fallback{$enc}{$uni} = 1 if $fb == 3; 
     112                    if ($Opt{e}) { 
    111113                        my $e = hex2enc($enc); 
    112114                        my $u = hex2uni($uni); 
     
    140142    for my $uni (keys %E2U){ 
    141143        my $enc = $U2E{$uni} or next; # okay 
    142         $E2U{$U2E{$uni}} eq $uni or 
     144        $E2U{$U2E{$uni}} eq $uni or $Fallback{$uni}{$enc} or 
    143145            nit "RT failure: U$uni => $enc =>U$E2U{$U2E{$uni}}"; 
    144146    } 
    145147    for my $enc (keys %E2U){ 
    146         my $uni =  $E2U{$enc} or next; # okay 
    147         $U2E{$E2U{$enc}} eq $enc or 
     148        my $uni = $E2U{$enc} or next; # okay 
     149        $U2E{$E2U{$enc}} eq $enc or $Fallback{$enc}{$uni} or 
    148150            nit "RT failure: $enc => U$uni => $U2E{$E2U{$enc}}"; 
    149151    }