w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

mk_ucs_isdigit_map.pl (820B)


      1 
      2 open(MAP, "> ucs_isdigit.map");
      3 print MAP <<EOF;
      4 /*
      5    File generated from UnicodeData-4.1.0.txt.
      6 */
      7 
      8 EOF
      9 
     10 for (<DATA>) {
     11   chop;
     12   ($name, $class) = split;
     13   
     14   @cp = ();
     15   
     16   open(UCD, "< private/UnicodeData-4.1.0.txt");
     17   while(<UCD>) {
     18     chop;
     19     @entry = split(';');
     20     last if $entry[0] =~ m/.{5,}/;
     21     if ($entry[2] eq $class) {
     22       push (@cp, $entry[0]);
     23     }
     24   }
     25   close UCD;
     26 
     27   @bs = ();
     28   $last = -1;
     29   $seq = -1;
     30   for my $e (@cp) {
     31     if (++$last != hex $e) {
     32       $seq = $e;
     33       $last = hex $e;
     34       push (@bs, $seq);
     35     }
     36     $end{$seq} = $e;
     37   }
     38   $nobs = @bs;
     39   
     40   print MAP <<EOF;
     41 
     42 #define N_ucs_${name}_map ${nobs}
     43 
     44 static wc_map ucs_${name}_map[ N_ucs_${name}_map ] = {
     45 EOF
     46   
     47   for (@bs) {
     48     print MAP "  { 0x$_, 0x$end{$_} },\n";
     49   }
     50   print MAP <<EOF
     51 };
     52 EOF
     53 }
     54 
     55 __END__
     56 isdigit Nd