1#!/usr/bin/perl
2
3open( I, "< /usr/share/perl/5.10.0/unicore/UnicodeData.txt" ) || die;
4while ( <I> ) {
5    #0069;LATIN SMALL LETTER I;Ll;0;L;;;;;N;;;0049;;0049
6    ($cp,$desc,$cl,$j,$j,$j,$j,$j,$j,$j,$j,$j,$equiv) = split( /;/, $_ );
7    $isalpha[hex $cp] = 1 if ( $cl =~ /^L/ );
8    $isdigit[hex $cp] = 1 if ( $cl =~ /^N/ );
9    $desc[hex $cp] = $desc;
10}
11
12$n = $#isalpha;
13$n = $#isdigit if ( $#isdigit > $n );
14
15open( O, "> unicode-isalnum.inc" ) || die;
16$i = 0;
17print O '// Generated by $Id$', "\n",
18        "static const uint numLetters = ", $#isalpha + 1, ";\n",
19        "static const uint numDigits = ", $#isdigit + 1, ";\n",
20        "static const struct { bool isAlpha:1; bool isDigit:1; } unidata[", $n + 1, "] = {\n";
21while ( $i <= $n ) {
22    print O "    { ";
23    if ( defined( $isalpha[$i] ) ) {
24        print O "true, ";
25    }
26    else {
27        print O "false, ";
28    }
29    if ( defined( $isdigit[$i] ) ) {
30        print O "true";
31    }
32    else {
33        print O "false";
34    }
35    print O " }";
36    print O "," if ( $i < $n );
37    print O " // ", $desc[$i], "\n";
38    $i++;
39}
40print O "};\n";
41