mkutable (6f26c71d76bb795b30684affb3b57870a7926b26) | mkutable (d713e0891ff9ab8246245c3206851d486ecfdd37) |
---|---|
1#! /usr/bin/perl | 1#!/usr/bin/env perl |
2use strict; 3 4my $USAGE = <<__EOF__; 5 usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt 6 -n = take non-matching types 7 -f = zero-based type field (default 2) 8__EOF__ 9 --- 42 unchanged lines hidden (view full) --- 52 } 53 } 54 55 my $date = `date`; 56 chomp $date; 57 print "/* Generated by \"$0 $args\" on $date */\n"; 58 59 my $last_code = 0; | 2use strict; 3 4my $USAGE = <<__EOF__; 5 usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt 6 -n = take non-matching types 7 -f = zero-based type field (default 2) 8__EOF__ 9 --- 42 unchanged lines hidden (view full) --- 52 } 53 } 54 55 my $date = `date`; 56 chomp $date; 57 print "/* Generated by \"$0 $args\" on $date */\n"; 58 59 my $last_code = 0; |
60 my $start_range = 0; |
|
60 while (<>) { 61 chomp; 62 s/#.*//; 63 my @fields = split /;/; 64 next if not @fields; 65 my ($lo_code, $hi_code); 66 my $codes = $fields[0]; 67 if ($codes =~ /(\w+)\.\.(\w+)/) { 68 $lo_code = hex $1; 69 $hi_code = hex $2; 70 } else { 71 $lo_code = $hi_code = hex $codes; 72 } | 61 while (<>) { 62 chomp; 63 s/#.*//; 64 my @fields = split /;/; 65 next if not @fields; 66 my ($lo_code, $hi_code); 67 my $codes = $fields[0]; 68 if ($codes =~ /(\w+)\.\.(\w+)/) { 69 $lo_code = hex $1; 70 $hi_code = hex $2; 71 } else { 72 $lo_code = $hi_code = hex $codes; 73 } |
74 if ($fields[1] =~ /, First>$/) { 75 die "invalid Unicode data: First with range" if $hi_code != $lo_code; 76 $start_range = $lo_code; 77 next; 78 } 79 if ($fields[1] =~ /, Last>$/) { 80 die "invalid Unicode data: Last without First" if not $start_range; 81 $lo_code = $start_range; 82 $start_range = 0; 83 } elsif ($start_range) { 84 die "invalid Unicode data: First without Last"; 85 } |
|
73 my $type = $fields[$type_field]; 74 $type =~ s/\s//g; 75 for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) { 76 output(\%out, $last_code, 77 $force_space{$last_code} ? 'Zs' : $force_compose{$last_code} ? 'Mn' : $type); 78 } 79 } 80 output(\%out, $last_code); --- 32 unchanged lines hidden --- | 86 my $type = $fields[$type_field]; 87 $type =~ s/\s//g; 88 for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) { 89 output(\%out, $last_code, 90 $force_space{$last_code} ? 'Zs' : $force_compose{$last_code} ? 'Mn' : $type); 91 } 92 } 93 output(\%out, $last_code); --- 32 unchanged lines hidden --- |