]> mj.ucw.cz Git - libucw.git/blobdiff - charset/misc/table2h
lib: removed breada :-)
[libucw.git] / charset / misc / table2h
index 81bbb185493bab7e2a2ce7842f4be119357bff2f..92a35d5924efe2db3ad7a69f4f6e9789245b27ca 100755 (executable)
@@ -9,9 +9,13 @@ $type=$ARGV[1];
 
 while (<STDIN>) {
        chomp;
+       /^#/ && next;
+       /^\s*$/ && next;
+       s/^0x//;
        ($i,$j) = split/\s+/;
        ($i =~ /^(..)(..)$/) || die "Syntax error at $i";
        $table{$1} = "$name" . "_$1";
+       die if defined $val{$i};
        $val{$i} = $j;
 }
 
@@ -20,7 +24,7 @@ print "/* Generated automatically by gentab. Please don't edit. */\n\n";
 for($i=0; $i<256; $i++) {
        $x = sprintf("%02X", $i);
        if (defined($table{$x})) {
-               print "static $type $table{$x}\[256\] = \{\n";
+               print "static const $type $table{$x}\[256\] = \{\n";
                for($j=0; $j<256; $j++) {
                        $y = $x . sprintf("%02X", $j);
                        if ($val{$y}) { print $val{$y}; }
@@ -32,7 +36,7 @@ for($i=0; $i<256; $i++) {
        }
 }
 
-print "$type \*$name\[256\] = \{\n";
+print "const $type \*$name\[256\] = \{\n";
 for($j=0; $j<256; $j++) {
        $y = sprintf("%02X", $j);
        if (defined $table{$y}) { print $table{$y}; }