Changeset 1790

Show
Ignore:
Timestamp:
11/19/07 18:48:19 (6 years ago)
Author:
miyagawa
Message:

Encode: spacing fix. no functional change.

Files:
1 modified

Legend:

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

    r1788 r1790  
    4040    my $lstr; 
    4141    if ($level == 2){ 
    42     $lstr = 'notice'; 
     42        $lstr = 'notice'; 
    4343    }elsif ($level == 1){ 
    44     $lstr = 'warning'; $nwarning++; 
     44        $lstr = 'warning'; $nwarning++; 
    4545    }else{ 
    46     $lstr = 'error'; $nerror++; 
     46        $lstr = 'error'; $nerror++; 
    4747    } 
    4848    print "$ARGV:$lstr in line $.: $msg\n"; 
     
    5555    $. = 0; 
    5656    while(<UCM>){ 
    57     chomp; 
    58     s/\s*#.*$//o; /^$/ and next; 
    59     if ($_ eq "CHARMAP"){  
    60         $in_charmap = 1; 
    61         for my $must (qw/code_set_name mb_cur_min mb_cur_max/){ 
    62         exists $Hdr{$must} or nit "<$must> nonexistent"; 
     57        chomp; 
     58        s/\s*#.*$//o; /^$/ and next; 
     59        if ($_ eq "CHARMAP"){  
     60            $in_charmap = 1; 
     61            for my $must (qw/code_set_name mb_cur_min mb_cur_max/){ 
     62                exists $Hdr{$must} or nit "<$must> nonexistent"; 
     63            } 
     64            $Hdr{mb_cur_min} > $Hdr{mb_cur_max} 
     65                and nit sprintf("mb_cur_min(%d) > mb_cur_max(%d)", 
     66                                $Hdr{mb_cur_min},$Hdr{mb_cur_max}); 
     67            $in_charmap = 1; 
     68            next; 
    6369        } 
    64         $Hdr{mb_cur_min} > $Hdr{mb_cur_max} 
    65         and nit sprintf("mb_cur_min(%d) > mb_cur_max(%d)", 
    66                 $Hdr{mb_cur_min},$Hdr{mb_cur_max}); 
    67         $in_charmap = 1; 
    68         next; 
    69     } 
    70     unless ($in_charmap){ 
    71         my($hkey, $hvalue) = /^<(\S+)>\s+[\"\']?([^\"\']+)/o or next; 
    72         $Opt{D} and warn "$hkey => $hvalue"; 
    73         if ($hkey eq "code_set_name"){ # name check 
    74         exists $Hdr{code_set_name}  
    75         and nit "Duplicate <code_set_name>: $hkey"; 
     70        unless ($in_charmap){ 
     71            my($hkey, $hvalue) = /^<(\S+)>\s+[\"\']?([^\"\']+)/o or next; 
     72            $Opt{D} and warn "$hkey => $hvalue"; 
     73            if ($hkey eq "code_set_name"){ # name check 
     74                exists $Hdr{code_set_name}  
     75                    and nit "Duplicate <code_set_name>: $hkey"; 
     76            } 
     77            if ($hkey eq "code_set_alias"){ # alias check 
     78                $hvalue eq $Hdr{code_set_name} 
     79                    and nit qq(alias "$hvalue" is already in <code_set_name>); 
     80            } 
     81            $Hdr{$hkey} = $hvalue; 
     82        }else{ 
     83            my $name = $Hdr{code_set_name}; 
     84            my($unistr, $encstr, $fb) = /^(\S+)\s+(\S+)\s(\S+)/o or next; 
     85            $Opt{v} and nit $_, 2; 
     86            my $uni = uniparse($unistr); 
     87            my $enc = encparse($encstr); 
     88            $fb =~ /^\|([0123])$/ or nit "malformed fallback: $fb"; 
     89            $fb = $1;  
     90            $Opt{f} and $fb = 0; 
     91            unless ($fb == 1){ # check uni -> enc 
     92                if (exists $U2E{$uni}){ 
     93                    nit "dupe encode map: U$uni => $U2E{$uni} and $enc", 1; 
     94                }else{ 
     95                    $U2E{$uni} = $enc; 
     96                    if ($Opt{e} and $fb != 3) { 
     97                        my $e = hex2enc($enc); 
     98                        my $u = hex2uni($uni); 
     99                        my $eu = Encode::encode($name, $u); 
     100                        $e eq $eu 
     101                            or nit qq(encode('$name', $uni) != $enc); 
     102                    } 
     103                } 
     104            } 
     105            unless ($fb == 3){  # check enc -> uni 
     106                if (exists $E2U{$enc}){ 
     107                    nit "dupe decode map: $enc => U$E2U{$enc} and U$uni", 1; 
     108                }else{ 
     109                    $E2U{$enc} = $uni; 
     110                    if ($Opt{e} and $fb != 1) { 
     111                        my $e = hex2enc($enc); 
     112                        my $u = hex2uni($uni); 
     113                        $Opt{D} and warn "$uni, $enc"; 
     114                        my $de = Encode::decode($name, $e); 
     115                        $de eq $u 
     116                            or nit qq(decode('$name', $enc) != $uni); 
     117                    } 
     118                } 
     119            } 
     120            # warn "$uni, $enc, $fb"; 
    76121        } 
    77         if ($hkey eq "code_set_alias"){ # alias check 
    78         $hvalue eq $Hdr{code_set_name} 
    79         and nit qq(alias "$hvalue" is already in <code_set_name>); 
    80         } 
    81         $Hdr{$hkey} = $hvalue; 
    82     }else{ 
    83         my $name = $Hdr{code_set_name}; 
    84         my($unistr, $encstr, $fb) = /^(\S+)\s+(\S+)\s(\S+)/o or next; 
    85         $Opt{v} and nit $_, 2; 
    86         my $uni = uniparse($unistr); 
    87         my $enc = encparse($encstr); 
    88         $fb =~ /^\|([0123])$/ or nit "malformed fallback: $fb"; 
    89         $fb = $1;  
    90         $Opt{f} and $fb = 0; 
    91         unless ($fb == 1){ # check uni -> enc 
    92         if (exists $U2E{$uni}){ 
    93             nit "dupe encode map: U$uni => $U2E{$uni} and $enc", 1; 
    94         }else{ 
    95             $U2E{$uni} = $enc; 
    96             if ($Opt{e} and $fb != 3) { 
    97             my $e = hex2enc($enc); 
    98             my $u = hex2uni($uni); 
    99             my $eu = Encode::encode($name, $u); 
    100             $e eq $eu 
    101                 or nit qq(encode('$name', $uni) != $enc); 
    102             } 
    103         } 
    104         } 
    105         unless ($fb == 3){  # check enc -> uni 
    106         if (exists $E2U{$enc}){ 
    107             nit "dupe decode map: $enc => U$E2U{$enc} and U$uni", 1; 
    108         }else{ 
    109             $E2U{$enc} = $uni; 
    110             if ($Opt{e} and $fb != 1) { 
    111             my $e = hex2enc($enc); 
    112             my $u = hex2uni($uni); 
    113             $Opt{D} and warn "$uni, $enc"; 
    114             my $de = Encode::decode($name, $e); 
    115             $de eq $u 
    116                 or nit qq(decode('$name', $enc) != $uni); 
    117             } 
    118         } 
    119         } 
    120         # warn "$uni, $enc, $fb"; 
    121     } 
    122122    } 
    123123    $in_charmap or nit "Where is CHARMAP?"; 
    124124    checkRT(); 
    125125    printf ("$ARGV: %s error%s found\n",  
    126         ($nerror == 0 ? 'no' : $nerror), 
    127         ($nerror > 1 ? 's' : '')); 
     126            ($nerror == 0 ? 'no' : $nerror), 
     127            ($nerror > 1 ? 's' : '')); 
    128128} 
    129129 
     
    139139sub checkRT{ 
    140140    for my $uni (keys %E2U){ 
    141     my $enc = $U2E{$uni} or next; # okay 
    142     $E2U{$U2E{$uni}} eq $uni or 
    143         nit "RT failure: U$uni => $enc =>U$E2U{$U2E{$uni}}"; 
     141        my $enc = $U2E{$uni} or next; # okay 
     142        $E2U{$U2E{$uni}} eq $uni or 
     143            nit "RT failure: U$uni => $enc =>U$E2U{$U2E{$uni}}"; 
    144144    } 
    145145    for my $enc (keys %E2U){ 
    146     my $uni =  $E2U{$enc} or next; # okay 
    147     $U2E{$E2U{$enc}} eq $enc or 
    148         nit "RT failure: $enc => U$uni => $U2E{$E2U{$enc}}"; 
     146        my $uni =  $E2U{$enc} or next; # okay 
     147        $U2E{$E2U{$enc}} eq $enc or 
     148            nit "RT failure: $enc => U$uni => $U2E{$E2U{$enc}}"; 
    149149    } 
    150150} 
     
    156156    push @u, $1 while($str =~ /\G<U(.*?)>/ig); 
    157157    for my $u (@u){ 
    158     $u =~ /^([0-9A-Za-z]+)$/o 
    159         or nit "malformed Unicode character: $u"; 
     158        $u =~ /^([0-9A-Za-z]+)$/o 
     159            or nit "malformed Unicode character: $u"; 
    160160    } 
    161161    return join(',', @u); 
     
    166166    my @e; 
    167167    for my $e (split /\\x/io, $str){ 
    168     $e or next; # first \x 
    169     $e =~ /^([0-9A-Za-z]{1,2})$/io 
    170         or nit "Hex $e in $str is bogus"; 
    171     push @e, $1; 
     168        $e or next; # first \x 
     169        $e =~ /^([0-9A-Za-z]{1,2})$/io 
     170            or nit "Hex $e in $str is bogus"; 
     171        push @e, $1; 
    172172    } 
    173173    return join(',', @e);