^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/perl -w
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # winucase_convert.pl -- convert "Windows 8 Upper Case Mapping Table.txt" to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # a two-level set of C arrays.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # Copyright 2013: Jeff Layton <jlayton@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # This program is free software: you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # the Free Software Foundation, either version 3 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) # You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # along with this program. If not, see <https://www.gnu.org/licenses/>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) while(<>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) next if (!/^0x(..)(..)\t0x(....)\t/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) $firstchar = hex($1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) $secondchar = hex($2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) $uppercase = hex($3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) $top[$firstchar][$secondchar] = $uppercase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) for ($i = 0; $i < 256; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) next if (!$top[$i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) printf("static const wchar_t t2_%2.2x[256] = {", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) for ($j = 0; $j < 256; $j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (($j % 8) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) print "\n\t";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) print " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) printf("0x%4.4x,", $top[$i][$j] ? $top[$i][$j] : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) print "\n};\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) printf("static const wchar_t *const toplevel[256] = {", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) for ($i = 0; $i < 256; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (($i % 8) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) print "\n\t";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) } elsif ($top[$i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) print " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) print " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if ($top[$i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) printf("t2_%2.2x,", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) print "NULL,";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) print "\n};\n\n";