2009-01-19 19:51:19 +01:00
|
|
|
#!/usr/bin/perl -w
|
2000-06-09 07:27:21 +02:00
|
|
|
#
|
|
|
|
# Generate code page .c files from ftp.unicode.org descriptions
|
|
|
|
#
|
|
|
|
# Copyright 2000 Alexandre Julliard
|
|
|
|
#
|
2002-03-10 00:29:33 +01:00
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
use strict;
|
|
|
|
|
2010-05-06 18:23:38 +02:00
|
|
|
# base URLs for www.unicode.org files
|
|
|
|
my $MAPPINGS = "http://www.unicode.org/Public/MAPPINGS";
|
2019-12-09 09:38:24 +01:00
|
|
|
my $UNIDATA = "http://www.unicode.org/Public/12.1.0/ucd";
|
2013-06-19 16:05:18 +02:00
|
|
|
my $REPORTS = "http://www.unicode.org/reports";
|
|
|
|
my $RFCS = "http://www.rfc-editor.org/rfc";
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2003-06-27 06:04:59 +02:00
|
|
|
# Sort keys file
|
2013-06-19 16:05:18 +02:00
|
|
|
my $SORTKEYS = "tr10/allkeys.txt";
|
2003-06-27 06:04:59 +02:00
|
|
|
|
2012-04-25 17:56:33 +02:00
|
|
|
# RFC3454 (stringprep data)
|
2013-06-19 16:05:18 +02:00
|
|
|
my $STRINGPREP = "rfc3454.txt";
|
2012-04-25 17:56:33 +02:00
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
# Defaults mapping
|
2011-07-07 15:05:52 +02:00
|
|
|
my $DEFAULTS = "tools/unicode-defaults";
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# Default char for undefined mappings
|
2009-01-19 19:51:19 +01:00
|
|
|
my $DEF_CHAR = ord '?';
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my @allfiles =
|
2000-06-09 07:27:21 +02:00
|
|
|
(
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 37, "VENDORS/MICSFT/EBCDIC/CP037.TXT", 0, "IBM EBCDIC US Canada", 0, 0x6f ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 424, "VENDORS/MISC/CP424.TXT", 0, "IBM EBCDIC Hebrew" ],
|
|
|
|
[ 437, "VENDORS/MICSFT/PC/CP437.TXT", 1, "OEM United States" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 500, "VENDORS/MICSFT/EBCDIC/CP500.TXT", 0, "IBM EBCDIC International", 0, 0x6f ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 737, "VENDORS/MICSFT/PC/CP737.TXT", 1, "OEM Greek 437G" ],
|
|
|
|
[ 775, "VENDORS/MICSFT/PC/CP775.TXT", 1, "OEM Baltic" ],
|
|
|
|
[ 850, "VENDORS/MICSFT/PC/CP850.TXT", 1, "OEM Multilingual Latin 1" ],
|
|
|
|
[ 852, "VENDORS/MICSFT/PC/CP852.TXT", 1, "OEM Slovak Latin 2" ],
|
|
|
|
[ 855, "VENDORS/MICSFT/PC/CP855.TXT", 1, "OEM Cyrillic" ],
|
|
|
|
[ 856, "VENDORS/MISC/CP856.TXT", 0, "Hebrew PC" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 857, "VENDORS/MICSFT/PC/CP857.TXT", 1, "OEM Turkish", 0xf8bb ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 860, "VENDORS/MICSFT/PC/CP860.TXT", 1, "OEM Portuguese" ],
|
|
|
|
[ 861, "VENDORS/MICSFT/PC/CP861.TXT", 1, "OEM Icelandic" ],
|
|
|
|
[ 862, "VENDORS/MICSFT/PC/CP862.TXT", 1, "OEM Hebrew" ],
|
|
|
|
[ 863, "VENDORS/MICSFT/PC/CP863.TXT", 1, "OEM Canadian French" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 864, "VENDORS/MICSFT/PC/CP864.TXT", 0, "OEM Arabic", 0xf8bb ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 865, "VENDORS/MICSFT/PC/CP865.TXT", 1, "OEM Nordic" ],
|
|
|
|
[ 866, "VENDORS/MICSFT/PC/CP866.TXT", 1, "OEM Russian" ],
|
|
|
|
[ 869, "VENDORS/MICSFT/PC/CP869.TXT", 1, "OEM Greek" ],
|
2009-01-19 19:21:55 +01:00
|
|
|
[ 874, "VENDORS/MICSFT/WindowsBestFit/bestfit874.txt", 1, "ANSI/OEM Thai" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 875, "VENDORS/MICSFT/EBCDIC/CP875.TXT", 0, "IBM EBCDIC Greek", 0, 0x6f ],
|
2009-01-19 19:21:55 +01:00
|
|
|
[ 878, "VENDORS/MISC/KOI8-R.TXT", 0, "Russian KOI8" ],
|
|
|
|
[ 932, "VENDORS/MICSFT/WindowsBestFit/bestfit932.txt", 0, "ANSI/OEM Japanese Shift-JIS" ],
|
|
|
|
[ 936, "VENDORS/MICSFT/WindowsBestFit/bestfit936.txt", 0, "ANSI/OEM Simplified Chinese GBK" ],
|
|
|
|
[ 949, "VENDORS/MICSFT/WindowsBestFit/bestfit949.txt", 0, "ANSI/OEM Korean Unified Hangul" ],
|
|
|
|
[ 950, "VENDORS/MICSFT/WindowsBestFit/bestfit950.txt", 0, "ANSI/OEM Traditional Chinese Big5" ],
|
|
|
|
[ 1006, "VENDORS/MISC/CP1006.TXT", 0, "IBM Arabic" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 1026, "VENDORS/MICSFT/EBCDIC/CP1026.TXT", 0, "IBM EBCDIC Latin 5 Turkish", 0, 0x6f ],
|
2009-01-19 19:21:55 +01:00
|
|
|
[ 1250, "VENDORS/MICSFT/WindowsBestFit/bestfit1250.txt", 0, "ANSI Eastern Europe" ],
|
|
|
|
[ 1251, "VENDORS/MICSFT/WindowsBestFit/bestfit1251.txt", 0, "ANSI Cyrillic" ],
|
|
|
|
[ 1252, "VENDORS/MICSFT/WindowsBestFit/bestfit1252.txt", 0, "ANSI Latin 1" ],
|
|
|
|
[ 1253, "VENDORS/MICSFT/WindowsBestFit/bestfit1253.txt", 0, "ANSI Greek" ],
|
|
|
|
[ 1254, "VENDORS/MICSFT/WindowsBestFit/bestfit1254.txt", 0, "ANSI Turkish" ],
|
|
|
|
[ 1255, "VENDORS/MICSFT/WindowsBestFit/bestfit1255.txt", 0, "ANSI Hebrew" ],
|
|
|
|
[ 1256, "VENDORS/MICSFT/WindowsBestFit/bestfit1256.txt", 0, "ANSI Arabic" ],
|
|
|
|
[ 1257, "VENDORS/MICSFT/WindowsBestFit/bestfit1257.txt", 0, "ANSI Baltic" ],
|
|
|
|
[ 1258, "VENDORS/MICSFT/WindowsBestFit/bestfit1258.txt", 0, "ANSI/OEM Viet Nam" ],
|
2013-07-22 10:02:27 +02:00
|
|
|
[ 1361, "VENDORS/MICSFT/WindowsBestFit/bestfit1361.txt", 0, "Korean Johab" ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 10000, "VENDORS/MICSFT/MAC/ROMAN.TXT", 0, "Mac Roman" ],
|
2013-06-26 17:41:41 +02:00
|
|
|
[ 10001, "VENDORS/APPLE/JAPANESE.TXT", 0, "Mac Japanese" ],
|
2013-06-26 17:46:35 +02:00
|
|
|
[ 10002, "VENDORS/APPLE/CHINTRAD.TXT", 0, "Mac Traditional Chinese" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 10003, "VENDORS/APPLE/KOREAN.TXT", 0, "Mac Korean", 0xf8e5 ],
|
2013-08-19 19:00:55 +02:00
|
|
|
[ 10004, "VENDORS/APPLE/ARABIC.TXT", 0, "Mac Arabic", 0xf826 ],
|
2013-08-19 19:02:01 +02:00
|
|
|
[ 10005, "VENDORS/APPLE/HEBREW.TXT", 0, "Mac Hebrew", 0xf7fa ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 10006, "VENDORS/MICSFT/MAC/GREEK.TXT", 0, "Mac Greek" ],
|
|
|
|
[ 10007, "VENDORS/MICSFT/MAC/CYRILLIC.TXT", 0, "Mac Cyrillic" ],
|
2013-06-26 17:51:47 +02:00
|
|
|
[ 10008, "VENDORS/APPLE/CHINSIMP.TXT", 0, "Mac Simplified Chinese" ],
|
2013-06-26 13:38:21 +02:00
|
|
|
[ 10010, "VENDORS/APPLE/ROMANIAN.TXT", 0, "Mac Romanian" ],
|
2013-06-26 12:49:42 +02:00
|
|
|
[ 10017, "VENDORS/APPLE/CYRILLIC.TXT", 0, "Mac Ukrainian" ],
|
2013-06-26 12:52:33 +02:00
|
|
|
[ 10021, "VENDORS/APPLE/THAI.TXT", 0, "Mac Thai" ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 10029, "VENDORS/MICSFT/MAC/LATIN2.TXT", 0, "Mac Latin 2" ],
|
|
|
|
[ 10079, "VENDORS/MICSFT/MAC/ICELAND.TXT", 0, "Mac Icelandic" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 10081, "VENDORS/MICSFT/MAC/TURKISH.TXT", 0, "Mac Turkish", 0xf89f ],
|
2013-06-26 12:54:57 +02:00
|
|
|
[ 10082, "VENDORS/APPLE/CROATIAN.TXT", 0, "Mac Croatian" ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 20127, undef, 0, "US-ASCII (7bit)" ],
|
|
|
|
[ 20866, "VENDORS/MISC/KOI8-R.TXT", 0, "Russian KOI8" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 20932, "OBSOLETE/EASTASIA/JIS/JIS0208.TXT", 0, "EUC-JP", 0, 0x3f, 0x30fb ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 21866, "VENDORS/MISC/KOI8-U.TXT", 0, "Ukrainian KOI8" ],
|
|
|
|
[ 28591, "ISO8859/8859-1.TXT", 0, "ISO 8859-1 Latin 1" ],
|
|
|
|
[ 28592, "ISO8859/8859-2.TXT", 0, "ISO 8859-2 Latin 2 (East European)" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 28593, "ISO8859/8859-3.TXT", 0, "ISO 8859-3 Latin 3 (South European)", 0xf7f5 ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 28594, "ISO8859/8859-4.TXT", 0, "ISO 8859-4 Latin 4 (Baltic old)" ],
|
|
|
|
[ 28595, "ISO8859/8859-5.TXT", 0, "ISO 8859-5 Cyrillic" ],
|
2013-08-19 18:59:40 +02:00
|
|
|
[ 28596, "ISO8859/8859-6.TXT", 0, "ISO 8859-6 Arabic", 0xf7c8 ],
|
|
|
|
[ 28597, "ISO8859/8859-7.TXT", 0, "ISO 8859-7 Greek", 0xf7c5 ],
|
|
|
|
[ 28598, "ISO8859/8859-8.TXT", 0, "ISO 8859-8 Hebrew", 0xf79c ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 28599, "ISO8859/8859-9.TXT", 0, "ISO 8859-9 Latin 5 (Turkish)" ],
|
|
|
|
[ 28600, "ISO8859/8859-10.TXT", 0, "ISO 8859-10 Latin 6 (Nordic)" ],
|
2019-10-17 18:23:37 +02:00
|
|
|
[ 28601, "ISO8859/8859-11.TXT", 0, "ISO 8859-11 Latin (Thai)" ],
|
2007-05-29 23:31:14 +02:00
|
|
|
[ 28603, "ISO8859/8859-13.TXT", 0, "ISO 8859-13 Latin 7 (Baltic)" ],
|
|
|
|
[ 28604, "ISO8859/8859-14.TXT", 0, "ISO 8859-14 Latin 8 (Celtic)" ],
|
|
|
|
[ 28605, "ISO8859/8859-15.TXT", 0, "ISO 8859-15 Latin 9 (Euro)" ],
|
|
|
|
[ 28606, "ISO8859/8859-16.TXT", 0, "ISO 8859-16 Latin 10 (Balkan)" ]
|
2000-06-09 07:27:21 +02:00
|
|
|
);
|
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my %ctype =
|
2000-08-11 22:53:40 +02:00
|
|
|
(
|
|
|
|
"upper" => 0x0001,
|
|
|
|
"lower" => 0x0002,
|
|
|
|
"digit" => 0x0004,
|
|
|
|
"space" => 0x0008,
|
|
|
|
"punct" => 0x0010,
|
|
|
|
"cntrl" => 0x0020,
|
|
|
|
"blank" => 0x0040,
|
|
|
|
"xdigit" => 0x0080,
|
2010-07-19 20:51:59 +02:00
|
|
|
"alpha" => 0x0100,
|
|
|
|
"defin" => 0x0200
|
2000-08-11 22:53:40 +02:00
|
|
|
);
|
|
|
|
|
2014-06-30 16:01:33 +02:00
|
|
|
my %bracket_types =
|
|
|
|
(
|
|
|
|
"o" => 0x0000,
|
|
|
|
"c" => 0x0001,
|
|
|
|
);
|
|
|
|
|
2011-06-27 18:02:39 +02:00
|
|
|
my %indic_types =
|
|
|
|
(
|
|
|
|
"Other" => 0x0000,
|
|
|
|
"Bindu" => 0x0001,
|
|
|
|
"Visarga" => 0x0002,
|
|
|
|
"Avagraha" => 0x0003,
|
|
|
|
"Nukta" => 0x0004,
|
|
|
|
"Virama" => 0x0005,
|
|
|
|
"Vowel_Independent" => 0x0006,
|
|
|
|
"Vowel_Dependent" => 0x0007,
|
|
|
|
"Vowel" => 0x0008,
|
|
|
|
"Consonant_Placeholder" => 0x0009,
|
|
|
|
"Consonant" => 0x000a,
|
|
|
|
"Consonant_Dead" => 0x000b,
|
2014-06-23 16:05:13 +02:00
|
|
|
"Consonant_Succeeding_Repha" => 0x000c,
|
2011-06-27 18:02:39 +02:00
|
|
|
"Consonant_Subjoined" => 0x000d,
|
|
|
|
"Consonant_Medial" => 0x000e,
|
|
|
|
"Consonant_Final" => 0x000f,
|
|
|
|
"Consonant_Head_Letter" => 0x0010,
|
|
|
|
"Modifying_Letter" => 0x0011,
|
|
|
|
"Tone_Letter" => 0x0012,
|
|
|
|
"Tone_Mark" => 0x0013,
|
2014-06-23 16:05:13 +02:00
|
|
|
"Register_Shifter" => 0x0014,
|
|
|
|
"Consonant_Preceding_Repha" => 0x0015,
|
|
|
|
"Pure_Killer" => 0x0016,
|
|
|
|
"Invisible_Stacker" => 0x0017,
|
|
|
|
"Gemination_Mark" => 0x0018,
|
|
|
|
"Cantillation_Mark" => 0x0019,
|
|
|
|
"Non_Joiner" => 0x001a,
|
|
|
|
"Joiner" => 0x001b,
|
|
|
|
"Number_Joiner" => 0x001c,
|
|
|
|
"Number" => 0x001d,
|
2015-10-01 20:55:56 +02:00
|
|
|
"Brahmi_Joining_Number" => 0x001e,
|
|
|
|
"Consonant_With_Stacker" => 0x001f,
|
|
|
|
"Consonant_Prefixed" => 0x0020,
|
|
|
|
"Syllable_Modifier" => 0x0021,
|
2018-07-03 11:50:56 +02:00
|
|
|
"Consonant_Killer" => 0x0022,
|
|
|
|
"Consonant_Initial_Postfixed" => 0x0023,
|
2011-06-27 18:02:39 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
my %matra_types =
|
|
|
|
(
|
|
|
|
"Right" => 0x01,
|
|
|
|
"Left" => 0x02,
|
|
|
|
"Visual_Order_Left" => 0x03,
|
|
|
|
"Left_And_Right" => 0x04,
|
|
|
|
"Top" => 0x05,
|
|
|
|
"Bottom" => 0x06,
|
|
|
|
"Top_And_Bottom" => 0x07,
|
|
|
|
"Top_And_Right" => 0x08,
|
|
|
|
"Top_And_Left" => 0x09,
|
|
|
|
"Top_And_Left_And_Right" => 0x0a,
|
|
|
|
"Bottom_And_Right" => 0x0b,
|
|
|
|
"Top_And_Bottom_And_Right" => 0x0c,
|
|
|
|
"Overstruck" => 0x0d,
|
2017-07-08 15:45:50 +02:00
|
|
|
"Invisible" => 0x0e,
|
|
|
|
"Bottom_And_Left" => 0x0f
|
2011-06-27 18:02:39 +02:00
|
|
|
);
|
|
|
|
|
2012-04-25 17:56:33 +02:00
|
|
|
my %nameprep_flags =
|
|
|
|
(
|
|
|
|
"unassigned" => 0x01,
|
|
|
|
"prohibited" => 0x02,
|
|
|
|
"bidi_ral" => 0x04,
|
|
|
|
"bidi_l" => 0x08
|
|
|
|
);
|
|
|
|
|
2011-06-27 18:01:24 +02:00
|
|
|
my %break_types =
|
|
|
|
(
|
|
|
|
"BK" => 0x0001,
|
|
|
|
"CR" => 0x0002,
|
|
|
|
"LF" => 0x0003,
|
|
|
|
"CM" => 0x0004,
|
|
|
|
"SG" => 0x0005,
|
|
|
|
"GL" => 0x0006,
|
|
|
|
"CB" => 0x0007,
|
|
|
|
"SP" => 0x0008,
|
|
|
|
"ZW" => 0x0009,
|
|
|
|
"NL" => 0x000a,
|
|
|
|
"WJ" => 0x000b,
|
|
|
|
"JL" => 0x000c,
|
|
|
|
"JV" => 0x000d,
|
|
|
|
"JT" => 0x000e,
|
|
|
|
"H2" => 0x000f,
|
|
|
|
"H3" => 0x0010,
|
|
|
|
"XX" => 0x0011,
|
|
|
|
"OP" => 0x0012,
|
|
|
|
"CL" => 0x0013,
|
|
|
|
"CP" => 0x0014,
|
|
|
|
"QU" => 0x0015,
|
|
|
|
"NS" => 0x0016,
|
|
|
|
"EX" => 0x0017,
|
|
|
|
"SY" => 0x0018,
|
|
|
|
"IS" => 0x0019,
|
|
|
|
"PR" => 0x001a,
|
|
|
|
"PO" => 0x001b,
|
|
|
|
"NU" => 0x001c,
|
|
|
|
"AL" => 0x001d,
|
|
|
|
"ID" => 0x001e,
|
|
|
|
"IN" => 0x001f,
|
|
|
|
"HY" => 0x0020,
|
|
|
|
"BB" => 0x0021,
|
|
|
|
"BA" => 0x0022,
|
|
|
|
"SA" => 0x0023,
|
|
|
|
"AI" => 0x0024,
|
2013-07-22 11:12:55 +02:00
|
|
|
"B2" => 0x0025,
|
|
|
|
"HL" => 0x0026,
|
|
|
|
"CJ" => 0x0027,
|
|
|
|
"RI" => 0x0028,
|
2016-06-22 14:00:22 +02:00
|
|
|
"EB" => 0x0029,
|
|
|
|
"EM" => 0x002a,
|
|
|
|
"ZWJ" => 0x002b,
|
2011-06-27 18:01:24 +02:00
|
|
|
);
|
|
|
|
|
2013-11-15 17:37:24 +01:00
|
|
|
my %vertical_types =
|
|
|
|
(
|
|
|
|
"R" => 0x0000,
|
|
|
|
"U" => 0x0001,
|
|
|
|
"Tr" => 0x0002,
|
|
|
|
"Tu" => 0x0003,
|
|
|
|
);
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my %categories =
|
2000-08-11 22:53:40 +02:00
|
|
|
(
|
2010-07-19 20:51:59 +02:00
|
|
|
"Lu" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"upper"}, # Letter, Uppercase
|
|
|
|
"Ll" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"lower"}, # Letter, Lowercase
|
|
|
|
"Lt" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"upper"}|$ctype{"lower"}, # Letter, Titlecase
|
|
|
|
"Mn" => $ctype{"defin"}, # Mark, Non-Spacing
|
|
|
|
"Mc" => $ctype{"defin"}, # Mark, Spacing Combining
|
|
|
|
"Me" => $ctype{"defin"}, # Mark, Enclosing
|
|
|
|
"Nd" => $ctype{"defin"}|$ctype{"digit"}, # Number, Decimal Digit
|
|
|
|
"Nl" => $ctype{"defin"}|$ctype{"alpha"}, # Number, Letter
|
|
|
|
"No" => $ctype{"defin"}, # Number, Other
|
|
|
|
"Zs" => $ctype{"defin"}|$ctype{"space"}, # Separator, Space
|
|
|
|
"Zl" => $ctype{"defin"}|$ctype{"space"}, # Separator, Line
|
|
|
|
"Zp" => $ctype{"defin"}|$ctype{"space"}, # Separator, Paragraph
|
|
|
|
"Cc" => $ctype{"defin"}|$ctype{"cntrl"}, # Other, Control
|
|
|
|
"Cf" => $ctype{"defin"}|$ctype{"cntrl"}, # Other, Format
|
|
|
|
"Cs" => $ctype{"defin"}, # Other, Surrogate
|
|
|
|
"Co" => $ctype{"defin"}, # Other, Private Use
|
|
|
|
"Cn" => $ctype{"defin"}, # Other, Not Assigned
|
|
|
|
"Lm" => $ctype{"defin"}|$ctype{"alpha"}, # Letter, Modifier
|
|
|
|
"Lo" => $ctype{"defin"}|$ctype{"alpha"}, # Letter, Other
|
|
|
|
"Pc" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Connector
|
|
|
|
"Pd" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Dash
|
|
|
|
"Ps" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Open
|
|
|
|
"Pe" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Close
|
|
|
|
"Pi" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Initial quote
|
|
|
|
"Pf" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Final quote
|
|
|
|
"Po" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Other
|
|
|
|
"Sm" => $ctype{"defin"}, # Symbol, Math
|
|
|
|
"Sc" => $ctype{"defin"}, # Symbol, Currency
|
|
|
|
"Sk" => $ctype{"defin"}, # Symbol, Modifier
|
|
|
|
"So" => $ctype{"defin"} # Symbol, Other
|
2000-08-11 22:53:40 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
# a few characters need additional categories that cannot be determined automatically
|
2009-01-19 19:51:19 +01:00
|
|
|
my %special_categories =
|
2000-08-11 22:53:40 +02:00
|
|
|
(
|
|
|
|
"xdigit" => [ ord('0')..ord('9'),ord('A')..ord('F'),ord('a')..ord('f'),
|
|
|
|
0xff10..0xff19, 0xff21..0xff26, 0xff41..0xff46 ],
|
2005-11-17 12:07:04 +01:00
|
|
|
"space" => [ 0x09..0x0d, 0x85 ],
|
|
|
|
"blank" => [ 0x09, 0x20, 0xa0, 0x3000, 0xfeff ],
|
2010-07-19 20:52:15 +02:00
|
|
|
"cntrl" => [ 0x070f, 0x200c, 0x200d,
|
2005-11-17 12:07:04 +01:00
|
|
|
0x200e, 0x200f, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e,
|
|
|
|
0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0xfeff,
|
2010-07-19 20:52:29 +02:00
|
|
|
0xfff9, 0xfffa, 0xfffb ],
|
|
|
|
"punct" => [ 0x24, 0x2b, 0x3c..0x3e, 0x5e, 0x60, 0x7c, 0x7e, 0xa2..0xbe,
|
2010-07-19 20:52:43 +02:00
|
|
|
0xd7, 0xf7 ],
|
|
|
|
"digit" => [ 0xb2, 0xb3, 0xb9 ],
|
|
|
|
"lower" => [ 0x2071, 0x207f ]
|
2000-08-11 22:53:40 +02:00
|
|
|
);
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my %directions =
|
2000-08-11 22:53:40 +02:00
|
|
|
(
|
|
|
|
"L" => 1, # Left-to-Right
|
|
|
|
"R" => 2, # Right-to-Left
|
2010-04-14 12:31:30 +02:00
|
|
|
"AL" => 12, # Right-to-Left Arabic
|
2000-08-11 22:53:40 +02:00
|
|
|
"EN" => 3, # European Number
|
|
|
|
"ES" => 4, # European Number Separator
|
|
|
|
"ET" => 5, # European Number Terminator
|
|
|
|
"AN" => 6, # Arabic Number
|
|
|
|
"CS" => 7, # Common Number Separator
|
2010-04-14 12:31:30 +02:00
|
|
|
"NSM" => 13, # Non-Spacing Mark
|
|
|
|
"BN" => 14, # Boundary Neutral
|
2000-08-11 22:53:40 +02:00
|
|
|
"B" => 8, # Paragraph Separator
|
|
|
|
"S" => 9, # Segment Separator
|
|
|
|
"WS" => 10, # Whitespace
|
2013-10-07 17:18:31 +02:00
|
|
|
"ON" => 11, # Other Neutrals
|
|
|
|
"LRE" => 15, # Left-to-Right Embedding
|
|
|
|
"LRO" => 15, # Left-to-Right Override
|
|
|
|
"RLE" => 15, # Right-to-Left Embedding
|
|
|
|
"RLO" => 15, # Right-to-Left Override
|
|
|
|
"PDF" => 15, # Pop Directional Format
|
|
|
|
"LRI" => 15, # Left-to-Right Isolate
|
|
|
|
"RLI" => 15, # Right-to-Left Isolate
|
|
|
|
"FSI" => 15, # First Strong Isolate
|
|
|
|
"PDI" => 15 # Pop Directional Isolate
|
2000-08-11 22:53:40 +02:00
|
|
|
);
|
|
|
|
|
2019-05-22 11:26:19 +02:00
|
|
|
my %c2_types =
|
|
|
|
(
|
|
|
|
"L" => 1, # C2_LEFTTORIGHT
|
|
|
|
"R" => 2, # C2_RIGHTTOLEFT
|
|
|
|
"AL" => 2, # C2_RIGHTTOLEFT
|
|
|
|
"EN" => 3, # C2_EUROPENUMBER
|
|
|
|
"ES" => 4, # C2_EUROPESEPARATOR
|
|
|
|
"ET" => 5, # C2_EUROPETERMINATOR
|
|
|
|
"AN" => 6, # C2_ARABICNUMBER
|
|
|
|
"CS" => 7, # C2_COMMONSEPARATOR
|
|
|
|
"NSM" => 0, # C2_NOTAPPLICABLE
|
|
|
|
"BN" => 0, # C2_NOTAPPLICABLE
|
|
|
|
"B" => 8, # C2_BLOCKSEPARATOR
|
|
|
|
"S" => 9, # C2_SEGMENTSEPARATOR
|
|
|
|
"WS" => 10, # C2_WHITESPACE
|
|
|
|
"ON" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"LRE" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"LRO" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"RLE" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"RLO" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"PDF" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"LRI" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"RLI" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"FSI" => 11, # C2_OTHERNEUTRAL
|
|
|
|
"PDI" => 11 # C2_OTHERNEUTRAL
|
|
|
|
);
|
|
|
|
|
2019-05-22 15:59:49 +02:00
|
|
|
my %bidi_types =
|
|
|
|
(
|
|
|
|
"ON" => 0, # Other Neutrals
|
|
|
|
"L" => 1, # Left-to-Right
|
|
|
|
"R" => 2, # Right-to-Left
|
|
|
|
"AN" => 3, # Arabic Number
|
|
|
|
"EN" => 4, # European Number
|
|
|
|
"AL" => 5, # Right-to-Left Arabic
|
|
|
|
"NSM" => 6, # Non-Spacing Mark
|
|
|
|
"CS" => 7, # Common Number Separator
|
|
|
|
"ES" => 8, # European Number Separator
|
|
|
|
"ET" => 9, # European Number Terminator
|
|
|
|
"BN" => 10, # Boundary Neutral
|
|
|
|
"S" => 11, # Segment Separator
|
|
|
|
"WS" => 12, # Whitespace
|
|
|
|
"B" => 13, # Paragraph Separator
|
|
|
|
"RLO" => 14, # Right-to-Left Override
|
|
|
|
"RLE" => 15, # Right-to-Left Embedding
|
|
|
|
"LRO" => 16, # Left-to-Right Override
|
|
|
|
"LRE" => 17, # Left-to-Right Embedding
|
|
|
|
"PDF" => 18, # Pop Directional Format
|
|
|
|
"LRI" => 19, # Left-to-Right Isolate
|
|
|
|
"RLI" => 20, # Right-to-Left Isolate
|
|
|
|
"FSI" => 21, # First Strong Isolate
|
|
|
|
"PDI" => 22 # Pop Directional Isolate
|
|
|
|
);
|
|
|
|
|
2010-05-19 17:52:42 +02:00
|
|
|
my %joining_types =
|
|
|
|
(
|
|
|
|
"U" => 0, # Non_Joining
|
|
|
|
"T" => 1, # Transparent
|
|
|
|
"R" => 2, # Right_Joining
|
|
|
|
"L" => 3, # Left_Joining
|
|
|
|
"D" => 4, # Dual_Joining
|
|
|
|
"C" => 5, # Join_Causing
|
|
|
|
);
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my @cp2uni = ();
|
|
|
|
my @lead_bytes = ();
|
|
|
|
my @uni2cp = ();
|
|
|
|
my @unicode_defaults = ();
|
|
|
|
my @unicode_aliases = ();
|
|
|
|
my @tolower_table = ();
|
|
|
|
my @toupper_table = ();
|
|
|
|
my @digitmap_table = ();
|
|
|
|
my @compatmap_table = ();
|
2016-02-09 08:39:54 +01:00
|
|
|
my @category_table = ();
|
|
|
|
my @joining_table = ();
|
2009-01-19 19:51:19 +01:00
|
|
|
my @direction_table = ();
|
|
|
|
my @decomp_table = ();
|
|
|
|
my @compose_table = ();
|
2019-02-08 11:41:24 +01:00
|
|
|
my @combining_class_table = ();
|
2019-02-08 11:41:25 +01:00
|
|
|
my @full_compatmap_table = ();
|
2013-06-26 17:28:15 +02:00
|
|
|
my $default_char;
|
|
|
|
my $default_wchar;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2010-05-19 17:52:42 +02:00
|
|
|
my %joining_forms =
|
|
|
|
(
|
|
|
|
"isolated" => [],
|
|
|
|
"final" => [],
|
|
|
|
"initial" => [],
|
|
|
|
"medial" => []
|
|
|
|
);
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2010-05-06 18:23:38 +02:00
|
|
|
################################################################
|
|
|
|
# fetch a unicode.org file and open it
|
2013-06-19 16:05:18 +02:00
|
|
|
sub open_data_file($$)
|
2010-05-06 18:23:38 +02:00
|
|
|
{
|
2013-06-19 16:05:18 +02:00
|
|
|
my ($base, $name) = @_;
|
|
|
|
(my $dir = "data/$name") =~ s/\/[^\/]+$//;
|
2010-05-06 18:23:38 +02:00
|
|
|
local *FILE;
|
|
|
|
unless (-f "data/$name")
|
|
|
|
{
|
2013-06-19 16:05:18 +02:00
|
|
|
print "Fetching $base/$name...\n";
|
|
|
|
system "mkdir", "-p", $dir;
|
|
|
|
!system "wget", "-q", "-O", "data/$name", "$base/$name" or die "cannot fetch $base/$name";
|
2010-05-06 18:23:38 +02:00
|
|
|
}
|
|
|
|
open FILE, "<data/$name" or die "cannot open data/$name";
|
|
|
|
return *FILE;
|
|
|
|
}
|
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
################################################################
|
|
|
|
# read in the defaults file
|
2009-01-19 19:51:19 +01:00
|
|
|
sub READ_DEFAULTS($)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $filename = shift;
|
|
|
|
my $start;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# first setup a few default mappings
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
open DEFAULTS, "$filename" or die "Cannot open $filename";
|
|
|
|
print "Loading $filename\n";
|
2000-06-09 07:27:21 +02:00
|
|
|
while (<DEFAULTS>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^$/; # skip empty lines
|
|
|
|
if (/^(([0-9a-fA-F]+)(,[0-9a-fA-F]+)*)\s+([0-9a-fA-F]+|'.'|none)\s+(\#.*)?/)
|
|
|
|
{
|
|
|
|
my @src = map hex, split /,/,$1;
|
|
|
|
my $dst = $4;
|
|
|
|
my $comment = $5;
|
|
|
|
if ($#src > 0) { push @unicode_aliases, \@src; }
|
|
|
|
next if ($dst eq "none");
|
|
|
|
$dst = ($dst =~ /\'.\'/) ? ord substr($dst,1,1) : hex $dst;
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $src (@src)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
die "Duplicate value" if defined($unicode_defaults[$src]);
|
|
|
|
$unicode_defaults[$src] = $dst;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "Unrecognized line $_\n";
|
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close DEFAULTS;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# now build mappings from the decomposition field of the Unicode database
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $UNICODE_DATA = open_data_file( $UNIDATA, "UnicodeData.txt" );
|
2010-05-06 18:23:38 +02:00
|
|
|
while (<$UNICODE_DATA>)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
# Decode the fields ...
|
2009-01-19 19:51:19 +01:00
|
|
|
my ($code, $name, $cat, $comb, $bidi,
|
|
|
|
$decomp, $dec, $dig, $num, $mirror,
|
|
|
|
$oldname, $comment, $upper, $lower, $title) = split /;/;
|
|
|
|
my $dst;
|
2000-08-11 22:53:40 +02:00
|
|
|
my $src = hex $code;
|
2000-06-12 03:16:11 +02:00
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
die "unknown category $cat" unless defined $categories{$cat};
|
|
|
|
die "unknown directionality $bidi" unless defined $directions{$bidi};
|
|
|
|
|
|
|
|
$category_table[$src] = $categories{$cat};
|
2019-05-22 10:31:55 +02:00
|
|
|
$direction_table[$src] = $bidi;
|
2010-05-19 17:52:42 +02:00
|
|
|
$joining_table[$src] = $joining_types{"T"} if $cat eq "Mn" || $cat eq "Me" || $cat eq "Cf";
|
2000-08-11 22:53:40 +02:00
|
|
|
|
|
|
|
if ($lower ne "")
|
|
|
|
{
|
|
|
|
$tolower_table[$src] = hex $lower;
|
|
|
|
}
|
|
|
|
if ($upper ne "")
|
|
|
|
{
|
|
|
|
$toupper_table[$src] = hex $upper;
|
|
|
|
}
|
|
|
|
if ($dec ne "")
|
|
|
|
{
|
|
|
|
$category_table[$src] |= $ctype{"digit"};
|
|
|
|
}
|
2003-10-15 04:32:34 +02:00
|
|
|
if ($dig ne "")
|
|
|
|
{
|
|
|
|
$digitmap_table[$src] = ord $dig;
|
|
|
|
}
|
2019-02-08 11:41:24 +01:00
|
|
|
if ($comb ne "")
|
|
|
|
{
|
|
|
|
$combining_class_table[$src] = $comb;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
# copy the category and direction for everything between First/Last pairs
|
|
|
|
if ($name =~ /, First>/) { $start = $src; }
|
|
|
|
if ($name =~ /, Last>/)
|
|
|
|
{
|
|
|
|
while ($start < $src)
|
|
|
|
{
|
|
|
|
$category_table[$start] = $category_table[$src];
|
|
|
|
$direction_table[$start] = $direction_table[$src];
|
|
|
|
$start++;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
next if $decomp eq ""; # no decomposition, skip it
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2019-02-08 11:41:25 +01:00
|
|
|
if ($decomp =~ /^<([a-zA-Z]+)>\s+([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
my @seq = ();
|
|
|
|
for my $ch (split /\s+/, (split /\s+/, $decomp, 2)[1])
|
|
|
|
{
|
|
|
|
push @seq, (hex $ch);
|
|
|
|
}
|
|
|
|
$full_compatmap_table[$src] = \@seq;
|
|
|
|
}
|
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
if ($decomp =~ /^<([a-zA-Z]+)>\s+([0-9a-fA-F]+)$/)
|
|
|
|
{
|
|
|
|
# decomposition of the form "<foo> 1234" -> use char if type is known
|
2003-10-15 04:32:34 +02:00
|
|
|
if (($src >= 0xf900 && $src < 0xfb00) || ($src >= 0xfe30 && $src < 0xfffd))
|
|
|
|
{
|
2003-10-28 22:45:30 +01:00
|
|
|
# Single char decomposition in the compatibility range
|
2003-10-15 04:32:34 +02:00
|
|
|
$compatmap_table[$src] = hex $2;
|
|
|
|
}
|
2010-05-19 17:52:42 +02:00
|
|
|
if ($1 eq "isolated" || $1 eq "final" || $1 eq "initial" || $1 eq "medial")
|
|
|
|
{
|
|
|
|
${joining_forms{$1}}[hex $2] = $src;
|
|
|
|
next;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
next unless ($1 eq "font" ||
|
|
|
|
$1 eq "noBreak" ||
|
|
|
|
$1 eq "circle" ||
|
|
|
|
$1 eq "super" ||
|
|
|
|
$1 eq "sub" ||
|
|
|
|
$1 eq "wide" ||
|
|
|
|
$1 eq "narrow" ||
|
|
|
|
$1 eq "compat" ||
|
|
|
|
$1 eq "small");
|
|
|
|
$dst = hex $2;
|
|
|
|
}
|
|
|
|
elsif ($decomp =~ /^<compat>\s+0020\s+([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
# decomposition "<compat> 0020 1234" -> combining accent
|
|
|
|
$dst = hex $1;
|
|
|
|
}
|
|
|
|
elsif ($decomp =~ /^([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
# decomposition contains only char values without prefix -> use first char
|
|
|
|
$dst = hex $1;
|
2009-01-19 19:51:19 +01:00
|
|
|
$category_table[$src] |= $category_table[$dst] if defined $category_table[$dst];
|
2000-12-29 04:56:06 +01:00
|
|
|
# store decomposition if it contains two chars
|
|
|
|
if ($decomp =~ /^([0-9a-fA-F]+)\s+([0-9a-fA-F]+)$/)
|
|
|
|
{
|
|
|
|
$decomp_table[$src] = [ hex $1, hex $2 ];
|
|
|
|
push @compose_table, [ hex $1, hex $2, $src ];
|
|
|
|
}
|
2019-02-08 11:41:26 +01:00
|
|
|
elsif ($decomp =~ /^([0-9a-fA-F]+)$/)
|
2003-10-15 04:32:34 +02:00
|
|
|
{
|
2019-02-08 11:41:26 +01:00
|
|
|
# Single char decomposition
|
|
|
|
if (hex $1 < 65536)
|
|
|
|
{
|
|
|
|
$decomp_table[$src] = [ hex $1, 0 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($src >= 0xf900 && $src < 0xfb00) || ($src >= 0xfe30 && $src < 0xfffd))
|
|
|
|
{
|
|
|
|
# Single char decomposition in the compatibility range
|
|
|
|
$compatmap_table[$src] = hex $1;
|
|
|
|
}
|
2003-10-15 04:32:34 +02:00
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
next if defined($unicode_defaults[$src]); # may have been set in the defaults file
|
|
|
|
|
|
|
|
# check for loops
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = $dst; ; $i = $unicode_defaults[$i])
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
die sprintf("loop detected for %04x -> %04x",$src,$dst) if $i == $src;
|
|
|
|
last unless defined($unicode_defaults[$i]);
|
|
|
|
}
|
|
|
|
$unicode_defaults[$src] = $dst;
|
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close $UNICODE_DATA;
|
2000-08-11 22:53:40 +02:00
|
|
|
|
|
|
|
# patch the category of some special characters
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $cat (keys %special_categories)
|
2000-08-11 22:53:40 +02:00
|
|
|
{
|
|
|
|
my $flag = $ctype{$cat};
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $i (@{$special_categories{$cat}}) { $category_table[$i] |= $flag; }
|
2000-08-11 22:53:40 +02:00
|
|
|
}
|
2020-01-23 16:54:05 +01:00
|
|
|
|
|
|
|
# remove case mappings that don't round-trip
|
|
|
|
|
|
|
|
for (my $i = 0; $i < @toupper_table; $i++)
|
|
|
|
{
|
|
|
|
next unless defined $toupper_table[$i];
|
|
|
|
my $ch = $toupper_table[$i];
|
|
|
|
$toupper_table[$i] = undef unless defined $tolower_table[$ch] && $tolower_table[$ch] == $i;
|
|
|
|
}
|
|
|
|
for (my $i = 0; $i < @tolower_table; $i++)
|
|
|
|
{
|
|
|
|
next unless defined $tolower_table[$i];
|
|
|
|
my $ch = $tolower_table[$i];
|
|
|
|
$tolower_table[$i] = undef unless defined $toupper_table[$ch] && $toupper_table[$ch] == $i;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
2013-06-26 17:28:15 +02:00
|
|
|
# define a new lead byte
|
|
|
|
sub add_lead_byte($)
|
|
|
|
{
|
|
|
|
my $ch = shift;
|
2019-10-06 13:39:53 +02:00
|
|
|
return if defined $cp2uni[$ch];
|
2013-06-26 17:28:15 +02:00
|
|
|
push @lead_bytes, $ch;
|
|
|
|
$cp2uni[$ch] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# define a new char mapping
|
|
|
|
sub add_mapping($$)
|
|
|
|
{
|
|
|
|
my ($cp, $uni) = @_;
|
|
|
|
$cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
|
|
|
|
$uni2cp[$uni] = $cp unless defined($uni2cp[$uni]);
|
2019-10-06 13:39:53 +02:00
|
|
|
if ($cp > 0xff) { add_lead_byte( $cp >> 8 ); }
|
2013-06-26 17:28:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# parse a standard codepage file
|
|
|
|
sub read_codepage_file($)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
my $name = shift;
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $MAPPINGS, $name );
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2010-05-06 18:23:38 +02:00
|
|
|
while (<$INPUT>)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
2000-06-11 01:12:44 +02:00
|
|
|
next if (/^0x([0-9a-fA-F]+)\s+\#UNDEFINED/); # undefined char
|
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
if (/^0x([0-9a-fA-F]+)\s+\#DBCS LEAD BYTE/)
|
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
add_lead_byte( hex $1 );
|
2000-06-09 07:27:21 +02:00
|
|
|
next;
|
|
|
|
}
|
2013-06-26 17:28:15 +02:00
|
|
|
# 0x12 0x3456
|
2000-06-09 07:27:21 +02:00
|
|
|
if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+(\#.*)?/)
|
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
add_mapping( hex $1, hex $2 );
|
2000-06-09 07:27:21 +02:00
|
|
|
next;
|
|
|
|
}
|
2013-06-26 17:41:41 +02:00
|
|
|
# 0x12 0x3456+0x7890
|
|
|
|
if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\+.*\s+(\#.*)?/)
|
|
|
|
{
|
|
|
|
add_mapping( hex $1, hex $2 );
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
# 0x12 <LR>+0x3456
|
2013-08-19 19:00:55 +02:00
|
|
|
if (/^0x([0-9a-fA-F]+)\s+<LR>\+0x([0-9a-fA-F]+)\s+(\#.*)?/)
|
2013-06-26 17:41:41 +02:00
|
|
|
{
|
|
|
|
add_mapping( hex $1, hex $2 );
|
|
|
|
next;
|
|
|
|
}
|
2013-08-19 19:00:55 +02:00
|
|
|
# 0x12 <RL>+0x3456
|
|
|
|
if (/^0x([0-9a-fA-F]+)\s+<RL>\+0x([0-9a-fA-F]+)\s+(\#.*)?/)
|
|
|
|
{
|
|
|
|
my $uni = hex $2;
|
|
|
|
add_mapping( hex $1, $uni ) if $uni >= 0x80;
|
|
|
|
next;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
die "$name: Unrecognized line $_\n";
|
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close $INPUT;
|
2000-06-11 01:12:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-05 20:39:13 +01:00
|
|
|
################################################################
|
|
|
|
# fill input data for the 20127 (us-ascii) codepage
|
|
|
|
sub fill_20127_codepage()
|
|
|
|
{
|
|
|
|
for (my $i = 0; $i < 128; $i++) { $cp2uni[$i] = $uni2cp[$i] = $i; }
|
|
|
|
for (my $i = 128; $i < 256; $i++) { $cp2uni[$i] = $i & 0x7f; }
|
|
|
|
}
|
|
|
|
|
2007-05-29 23:31:14 +02:00
|
|
|
################################################################
|
|
|
|
# get a mapping including glyph chars for MB_USEGLYPHCHARS
|
|
|
|
|
|
|
|
sub get_glyphs_mapping(@)
|
|
|
|
{
|
|
|
|
$_[0x01] = 0x263a; # (WHITE SMILING FACE)
|
|
|
|
$_[0x02] = 0x263b; # (BLACK SMILING FACE)
|
|
|
|
$_[0x03] = 0x2665; # (BLACK HEART SUIT)
|
|
|
|
$_[0x04] = 0x2666; # (BLACK DIAMOND SUIT)
|
|
|
|
$_[0x05] = 0x2663; # (BLACK CLUB SUIT)
|
|
|
|
$_[0x06] = 0x2660; # (BLACK SPADE SUIT)
|
|
|
|
$_[0x07] = 0x2022; # (BULLET)
|
|
|
|
$_[0x08] = 0x25d8; # (INVERSE BULLET)
|
|
|
|
$_[0x09] = 0x25cb; # (WHITE CIRCLE)
|
|
|
|
$_[0x0a] = 0x25d9; # (INVERSE WHITE CIRCLE)
|
|
|
|
$_[0x0b] = 0x2642; # (MALE SIGN)
|
|
|
|
$_[0x0c] = 0x2640; # (FEMALE SIGN)
|
|
|
|
$_[0x0d] = 0x266a; # (EIGHTH NOTE)
|
|
|
|
$_[0x0e] = 0x266b; # (BEAMED EIGHTH NOTES)
|
|
|
|
$_[0x0f] = 0x263c; # (WHITE SUN WITH RAYS)
|
|
|
|
$_[0x10] = 0x25ba; # (BLACK RIGHT-POINTING POINTER)
|
|
|
|
$_[0x11] = 0x25c4; # (BLACK LEFT-POINTING POINTER)
|
|
|
|
$_[0x12] = 0x2195; # (UP DOWN ARROW)
|
|
|
|
$_[0x13] = 0x203c; # (DOUBLE EXCLAMATION MARK)
|
|
|
|
$_[0x14] = 0x00b6; # (PILCROW SIGN)
|
|
|
|
$_[0x15] = 0x00a7; # (SECTION SIGN)
|
|
|
|
$_[0x16] = 0x25ac; # (BLACK RECTANGLE)
|
|
|
|
$_[0x17] = 0x21a8; # (UP DOWN ARROW WITH BASE)
|
|
|
|
$_[0x18] = 0x2191; # (UPWARDS ARROW)
|
|
|
|
$_[0x19] = 0x2193; # (DOWNWARDS ARROW)
|
|
|
|
$_[0x1a] = 0x2192; # (RIGHTWARDS ARROW)
|
|
|
|
$_[0x1b] = 0x2190; # (LEFTWARDS ARROW)
|
|
|
|
$_[0x1c] = 0x221f; # (RIGHT ANGLE)
|
|
|
|
$_[0x1d] = 0x2194; # (LEFT RIGHT ARROW)
|
|
|
|
$_[0x1e] = 0x25b2; # (BLACK UP-POINTING TRIANGLE)
|
|
|
|
$_[0x1f] = 0x25bc; # (BLACK DOWN-POINTING TRIANGLE)
|
|
|
|
$_[0x7f] = 0x2302; # (HOUSE)
|
|
|
|
return @_;
|
|
|
|
}
|
2007-02-05 20:39:13 +01:00
|
|
|
|
2002-10-02 03:29:22 +02:00
|
|
|
################################################################
|
|
|
|
# build EUC-JP table from the JIS 0208 file
|
|
|
|
# FIXME: for proper EUC-JP we should probably read JIS 0212 too
|
|
|
|
# but this would require 3-byte DBCS characters
|
2009-01-19 19:51:19 +01:00
|
|
|
sub READ_JIS0208_FILE($)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
|
|
|
my $name = shift;
|
|
|
|
|
|
|
|
# ASCII chars
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0x00; $i <= 0x7f; $i++)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
|
|
|
$cp2uni[$i] = $i;
|
|
|
|
$uni2cp[$i] = $i;
|
|
|
|
}
|
|
|
|
|
|
|
|
# JIS X 0201 right plane
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0xa1; $i <= 0xdf; $i++)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
|
|
|
$cp2uni[0x8e00 + $i] = 0xfec0 + $i;
|
|
|
|
$uni2cp[0xfec0 + $i] = 0x8e00 + $i;
|
|
|
|
}
|
|
|
|
|
|
|
|
# lead bytes
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $i (0x8e, 0x8f, 0xa1 .. 0xfe)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
2016-02-09 05:44:26 +01:00
|
|
|
add_lead_byte($i);
|
2002-10-02 03:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# undefined chars
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $i (0x80 .. 0x8d, 0x90 .. 0xa0, 0xff)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
|
|
|
$cp2uni[$i] = $DEF_CHAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Shift-JIS compatibility
|
|
|
|
$uni2cp[0x00a5] = 0x5c;
|
|
|
|
$uni2cp[0x203e] = 0x7e;
|
|
|
|
|
|
|
|
# Fix backslash conversion
|
|
|
|
$cp2uni[0xa1c0] = 0xff3c;
|
|
|
|
$uni2cp[0xff3c] = 0xa1c0;
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $MAPPINGS, $name );
|
2010-05-06 18:23:38 +02:00
|
|
|
while (<$INPUT>)
|
2002-10-02 03:29:22 +02:00
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^0x[0-9a-fA-F]+\s+0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+(\#.*)?/)
|
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $cp = 0x8080 + hex $1;
|
|
|
|
my $uni = hex $2;
|
2002-10-02 03:29:22 +02:00
|
|
|
$cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
|
|
|
|
$uni2cp[$uni] = $cp unless defined($uni2cp[$uni]);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "$name: Unrecognized line $_\n";
|
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close $INPUT;
|
2002-10-02 03:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 06:04:59 +02:00
|
|
|
################################################################
|
|
|
|
# build the sort keys table
|
2020-01-23 17:26:45 +01:00
|
|
|
sub dump_sortkeys($)
|
2003-06-27 06:04:59 +02:00
|
|
|
{
|
2020-01-23 17:26:45 +01:00
|
|
|
my $filename = shift;
|
2003-06-27 06:04:59 +02:00
|
|
|
my @sortkeys = ();
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $REPORTS, $SORTKEYS );
|
2010-05-06 18:23:38 +02:00
|
|
|
while (<$INPUT>)
|
2003-06-27 06:04:59 +02:00
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
next if /^\@version/; # skip @version header
|
|
|
|
if (/^([0-9a-fA-F]+)\s+;\s+\[([*.])([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]+)\]/)
|
|
|
|
{
|
|
|
|
my ($uni,$variable) = (hex $1, $2);
|
|
|
|
next if $uni > 65535;
|
|
|
|
$sortkeys[$uni] = [ $uni, hex $3, hex $4, hex $5, hex $6 ];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^([0-9a-fA-F]+\s+)+;\s+\[[*.]([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]+)\]/)
|
|
|
|
{
|
|
|
|
# multiple character sequence, ignored for now
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "$SORTKEYS: Unrecognized line $_\n";
|
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close $INPUT;
|
2003-06-27 06:04:59 +02:00
|
|
|
|
|
|
|
# compress the keys to 32 bit:
|
|
|
|
# key 1 to 16 bits, key 2 to 8 bits, key 3 to 4 bits, key 4 to 1 bit
|
|
|
|
|
|
|
|
@sortkeys = sort { ${$a}[1] <=> ${$b}[1] or
|
|
|
|
${$a}[2] <=> ${$b}[2] or
|
|
|
|
${$a}[3] <=> ${$b}[3] or
|
|
|
|
${$a}[4] <=> ${$b}[4] or
|
|
|
|
$a cmp $b; } @sortkeys;
|
|
|
|
|
|
|
|
my ($n2, $n3) = (1, 1);
|
|
|
|
my @keys = (-1, -1, -1, -1, -1 );
|
|
|
|
my @flatkeys = ();
|
|
|
|
|
2020-01-23 17:26:45 +01:00
|
|
|
for (my $i = 0; $i < @sortkeys; $i++)
|
2003-06-27 06:04:59 +02:00
|
|
|
{
|
2020-01-23 17:26:45 +01:00
|
|
|
next unless defined $sortkeys[$i];
|
2003-06-27 06:04:59 +02:00
|
|
|
my @current = @{$sortkeys[$i]};
|
|
|
|
if ($current[1] == $keys[1])
|
|
|
|
{
|
|
|
|
if ($current[2] == $keys[2])
|
|
|
|
{
|
|
|
|
if ($current[3] == $keys[3])
|
|
|
|
{
|
|
|
|
# nothing
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$keys[3] = $current[3];
|
|
|
|
$n3++;
|
|
|
|
die if ($n3 >= 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$keys[2] = $current[2];
|
|
|
|
$keys[3] = $current[3];
|
|
|
|
$n2++;
|
|
|
|
$n3 = 1;
|
|
|
|
die if ($n2 >= 256);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$keys[1] = $current[1];
|
|
|
|
$keys[2] = $current[2];
|
|
|
|
$keys[3] = $current[3];
|
|
|
|
$n2 = 1;
|
|
|
|
$n3 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($current[2]) { $current[2] = $n2; }
|
|
|
|
if ($current[3]) { $current[3] = $n3; }
|
|
|
|
if ($current[4]) { $current[4] = 1; }
|
|
|
|
|
|
|
|
$flatkeys[$current[0]] = ($current[1] << 16) | ($current[2] << 8) | ($current[3] << 4) | $current[4];
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:26:45 +01:00
|
|
|
my @array = compress_array( 256, 0xffffffff, @flatkeys[0..65535] );
|
2003-06-27 06:04:59 +02:00
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
printf "Building $filename\n";
|
2003-06-27 06:04:59 +02:00
|
|
|
printf OUTPUT "/* Unicode collation element table */\n";
|
2013-06-19 16:05:18 +02:00
|
|
|
printf OUTPUT "/* generated from %s */\n", "$REPORTS/$SORTKEYS";
|
2003-06-27 06:04:59 +02:00
|
|
|
printf OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2003-06-27 06:04:59 +02:00
|
|
|
|
2020-01-23 17:26:45 +01:00
|
|
|
printf OUTPUT "const unsigned int DECLSPEC_HIDDEN collation_table[%d] =\n{\n", scalar @array;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT " /* offsets */\n%s,\n", dump_array( 32, 0, @array[0..255] );
|
|
|
|
printf OUTPUT " /* values */\n%s\n};\n", dump_array( 32, 0, @array[256..$#array] );
|
2003-06-27 06:04:59 +02:00
|
|
|
close OUTPUT;
|
2009-01-19 19:51:19 +01:00
|
|
|
save_file($filename);
|
2003-06-27 06:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-11 01:12:44 +02:00
|
|
|
################################################################
|
|
|
|
# add default mappings once the file had been read
|
2013-08-19 18:59:40 +02:00
|
|
|
sub add_default_mappings($)
|
2000-06-11 01:12:44 +02:00
|
|
|
{
|
2013-08-19 18:59:40 +02:00
|
|
|
my $first_private = shift;
|
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
# Apply aliases
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $alias (@unicode_aliases)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
my $target = undef;
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $src (@$alias)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
if (defined($uni2cp[$src]))
|
|
|
|
{
|
|
|
|
$target = $uni2cp[$src];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next unless defined($target);
|
|
|
|
|
|
|
|
# At least one char of the alias set is defined, set the others to the same value
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $src (@$alias)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
$uni2cp[$src] = $target unless defined($uni2cp[$src]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# For every src -> target mapping in the defaults table,
|
|
|
|
# make uni2cp[src] = uni2cp[target] if uni2cp[target] is defined
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $src = 0; $src < 65536; $src++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
next if defined($uni2cp[$src]); # source has a definition already
|
|
|
|
next unless defined($unicode_defaults[$src]); # no default for this char
|
|
|
|
my $target = $unicode_defaults[$src];
|
|
|
|
|
|
|
|
# do a recursive mapping until we find a target char that is defined
|
|
|
|
while (!defined($uni2cp[$target]) &&
|
|
|
|
defined($unicode_defaults[$target])) { $target = $unicode_defaults[$target]; }
|
|
|
|
|
|
|
|
if (defined($uni2cp[$target])) { $uni2cp[$src] = $uni2cp[$target]; }
|
|
|
|
}
|
2000-06-11 01:12:44 +02:00
|
|
|
|
2013-08-19 18:59:40 +02:00
|
|
|
# Add a private char mapping for undefined chars
|
|
|
|
|
|
|
|
if ($first_private)
|
|
|
|
{
|
|
|
|
for (my $i = 32; $i < 256; $i++)
|
|
|
|
{
|
|
|
|
next if defined($cp2uni[$i]);
|
|
|
|
$cp2uni[$i] = $first_private;
|
|
|
|
$uni2cp[$first_private] = $i;
|
|
|
|
$first_private++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-11 01:12:44 +02:00
|
|
|
# Add an identity mapping for all undefined chars
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-06-11 01:12:44 +02:00
|
|
|
{
|
|
|
|
next if defined($cp2uni[$i]);
|
|
|
|
next if defined($uni2cp[$i]);
|
|
|
|
$cp2uni[$i] = $uni2cp[$i] = $i;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
2000-06-12 03:16:11 +02:00
|
|
|
################################################################
|
|
|
|
# dump an array of integers
|
2020-01-23 17:39:07 +01:00
|
|
|
sub dump_array($$@)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
2020-01-23 17:39:07 +01:00
|
|
|
my ($bit_width, $default, @array) = @_;
|
|
|
|
my $format = sprintf "0x%%0%ux", $bit_width / 4;
|
2009-01-19 19:51:19 +01:00
|
|
|
my $i;
|
|
|
|
my $ret = " ";
|
2000-06-12 03:16:11 +02:00
|
|
|
for ($i = 0; $i < $#array; $i++)
|
|
|
|
{
|
|
|
|
$ret .= sprintf($format, defined $array[$i] ? $array[$i] : $default);
|
|
|
|
$ret .= (($i % 8) != 7) ? ", " : ",\n ";
|
|
|
|
}
|
|
|
|
$ret .= sprintf($format, defined $array[$i] ? $array[$i] : $default);
|
|
|
|
return $ret;
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
################################################################
|
2013-07-22 12:22:50 +02:00
|
|
|
# dump a unicode->ascii mapping table
|
|
|
|
sub dump_uni2cp_table($$)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-07-22 12:22:50 +02:00
|
|
|
my ($width, $def) = @_;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
# count the number of unicode->ascii subtables that contain something
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
my @lowerbounds;
|
|
|
|
my @upperbounds;
|
|
|
|
my $index = 0;
|
|
|
|
my @filled = (-1) x 256;
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2007-05-29 23:31:14 +02:00
|
|
|
{
|
2013-07-22 12:22:50 +02:00
|
|
|
next unless defined $uni2cp[$i];
|
|
|
|
if ($filled[$i >> 8] == -1)
|
|
|
|
{
|
|
|
|
$lowerbounds[$index] = $i & 0xff;
|
|
|
|
$upperbounds[$index] = 0xff - $lowerbounds[$index];
|
|
|
|
$filled[$i >> 8] = $index * 256;
|
|
|
|
$index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$upperbounds[$index-1] = 0xff - ($i & 0xff);
|
|
|
|
}
|
2007-05-29 23:31:14 +02:00
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
# add defaults mapping at the end
|
|
|
|
$filled[256] = $index * 256;
|
|
|
|
$lowerbounds[$index] = 255;
|
|
|
|
$upperbounds[$index] = 0;
|
|
|
|
$index++;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
# collapse blocks upwards if possible
|
|
|
|
my $removed = 0;
|
|
|
|
$index = 0;
|
|
|
|
for (my $i = 0; $i < 257; $i++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-07-22 12:22:50 +02:00
|
|
|
next if $filled[$i] == -1;
|
|
|
|
if ($upperbounds[$index - 1] > $lowerbounds[$index])
|
|
|
|
{
|
|
|
|
$removed += $lowerbounds[$index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$removed += $upperbounds[$index - 1];
|
|
|
|
$lowerbounds[$index] = $upperbounds[$index - 1];
|
|
|
|
}
|
|
|
|
$filled[$i] -= $removed;
|
|
|
|
$index++;
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# output all the subtables into a single array
|
|
|
|
|
2019-03-22 12:42:13 +01:00
|
|
|
printf OUTPUT "static const unsigned %s uni2cp_low[] =\n{\n", $width == 8 ? "char" : "short";
|
2013-07-22 12:22:50 +02:00
|
|
|
|
|
|
|
for (my $i = $index = 0; $i < 257; $i++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-07-22 12:22:50 +02:00
|
|
|
next if $filled[$i] == -1;
|
|
|
|
my $start = ($i << 8) + $lowerbounds[$index];
|
|
|
|
my $end = ($i << 8) + 255;
|
|
|
|
if ($i == 256)
|
|
|
|
{
|
|
|
|
print OUTPUT " /* defaults */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s\n};\n\n", dump_array( $width, 0, ($def) x ($end - $start + 1) );
|
2013-07-22 12:22:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf OUTPUT " /* 0x%04x .. 0x%04x */\n", $start, $end;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s,\n", dump_array( $width, $def, @uni2cp[$start .. $end] );
|
2013-07-22 12:22:50 +02:00
|
|
|
}
|
|
|
|
$index++;
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# output a table of the offsets of the subtables in the previous array
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-07-22 12:22:50 +02:00
|
|
|
if ($filled[$i] == -1) { $filled[$i] = $filled[256]; }
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT "static const unsigned short uni2cp_high[256] =\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "{\n%s\n};\n\n", dump_array( 16, 0, @filled[0..255] );
|
2013-07-22 12:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump an SBCS mapping table
|
|
|
|
sub dump_sbcs_table($$$$$)
|
|
|
|
{
|
|
|
|
my ($codepage, $has_glyphs, $name, $def, $defw) = @_;
|
|
|
|
my $i;
|
|
|
|
|
|
|
|
# output the ascii->unicode table
|
|
|
|
|
|
|
|
if ($has_glyphs)
|
|
|
|
{
|
|
|
|
printf OUTPUT "static const WCHAR cp2uni[512] =\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "{\n%s", dump_array( 16, $defw, @cp2uni[0 .. 255] );
|
2013-07-22 12:22:50 +02:00
|
|
|
printf OUTPUT ",\n /* glyphs */\n%s\n};\n\n",
|
2020-01-23 17:39:07 +01:00
|
|
|
dump_array( 16, $defw, get_glyphs_mapping(@cp2uni[0 .. 255]) );
|
2013-07-22 12:22:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf OUTPUT "static const WCHAR cp2uni[256] =\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "{\n%s\n};\n\n", dump_array( 16, $defw, @cp2uni[0 .. 255] );
|
2013-07-22 12:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dump_uni2cp_table( 8, $def );
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# output the code page descriptor
|
|
|
|
|
2016-02-24 05:27:48 +01:00
|
|
|
printf OUTPUT "const struct sbcs_table DECLSPEC_HIDDEN cptable_%03d =\n{\n", $codepage;
|
2000-06-10 06:29:16 +02:00
|
|
|
printf OUTPUT " { %d, 1, 0x%04x, 0x%04x, \"%s\" },\n",
|
2009-01-19 19:21:55 +01:00
|
|
|
$codepage, $def, $defw, $name;
|
2000-06-09 07:27:21 +02:00
|
|
|
printf OUTPUT " cp2uni,\n";
|
2007-05-29 23:31:14 +02:00
|
|
|
if ($has_glyphs) { printf OUTPUT " cp2uni + 256,\n"; }
|
|
|
|
else { printf OUTPUT " cp2uni,\n"; }
|
2000-06-09 07:27:21 +02:00
|
|
|
printf OUTPUT " uni2cp_low,\n";
|
|
|
|
printf OUTPUT " uni2cp_high\n};\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump a DBCS mapping table
|
2009-01-19 19:21:55 +01:00
|
|
|
sub dump_dbcs_table($$$$@)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2009-01-19 19:21:55 +01:00
|
|
|
my ($codepage, $name, $def, $defw, @lb_ranges) = @_;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# build a list of lead bytes that are actually used
|
|
|
|
|
|
|
|
my @lblist = ();
|
2009-01-19 19:51:19 +01:00
|
|
|
LBLOOP: for (my $y = 0; $y <= $#lead_bytes; $y++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2016-02-09 05:44:26 +01:00
|
|
|
$cp2uni[$lead_bytes[$y]] = $defw;
|
2000-06-09 07:27:21 +02:00
|
|
|
my $base = $lead_bytes[$y] << 8;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $x = 0; $x < 256; $x++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
if (defined $cp2uni[$base+$x])
|
|
|
|
{
|
|
|
|
push @lblist,$lead_bytes[$y];
|
|
|
|
next LBLOOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my $unused = ($#lead_bytes > $#lblist);
|
|
|
|
|
|
|
|
# output the ascii->unicode table for the single byte chars
|
|
|
|
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT "static const WCHAR cp2uni[%d] =\n", 256 * ($#lblist + 2 + $unused);
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "{\n%s,\n", dump_array( 16, $defw, @cp2uni[0 .. 255] );
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# output the default table for unused lead bytes
|
|
|
|
|
|
|
|
if ($unused)
|
|
|
|
{
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT " /* unused lead bytes */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s,\n", dump_array( 16, 0, ($defw) x 256 );
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# output the ascii->unicode table for each DBCS lead byte
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $y = 0; $y <= $#lblist; $y++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
my $base = $lblist[$y] << 8;
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT " /* lead byte %02x */\n", $lblist[$y];
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, $defw, @cp2uni[$base .. $base+255] );
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT ($y < $#lblist) ? ",\n" : "\n};\n\n";
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# output the lead byte subtables offsets
|
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
my @offsets = (0) x 256;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $x = 0; $x <= $#lblist; $x++) { $offsets[$lblist[$x]] = $x + 1; }
|
2000-06-09 07:27:21 +02:00
|
|
|
if ($unused)
|
|
|
|
{
|
|
|
|
# increment all lead bytes offset to take into account the unused table
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $x = 0; $x <= $#lead_bytes; $x++) { $offsets[$lead_bytes[$x]]++; }
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT "static const unsigned char cp2uni_leadbytes[256] =\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "{\n%s\n};\n\n", dump_array( 8, 0, @offsets );
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-07-22 12:22:50 +02:00
|
|
|
dump_uni2cp_table( 16, $def );
|
2000-06-09 07:27:21 +02:00
|
|
|
|
|
|
|
# output the code page descriptor
|
|
|
|
|
2016-02-24 05:27:48 +01:00
|
|
|
printf OUTPUT "const struct dbcs_table DECLSPEC_HIDDEN cptable_%03d =\n{\n", $codepage;
|
2000-06-10 06:29:16 +02:00
|
|
|
printf OUTPUT " { %d, 2, 0x%04x, 0x%04x, \"%s\" },\n",
|
2009-01-19 19:21:55 +01:00
|
|
|
$codepage, $def, $defw, $name;
|
2000-06-09 07:27:21 +02:00
|
|
|
printf OUTPUT " cp2uni,\n";
|
|
|
|
printf OUTPUT " cp2uni_leadbytes,\n";
|
|
|
|
printf OUTPUT " uni2cp_low,\n";
|
|
|
|
printf OUTPUT " uni2cp_high,\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT " {\n %s\n }\n", dump_array( 8, 0, @lb_ranges, 0, 0 );
|
2000-06-09 07:27:21 +02:00
|
|
|
printf OUTPUT "};\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
2009-01-19 19:21:55 +01:00
|
|
|
# get the list of defined lead byte ranges
|
|
|
|
sub get_lb_ranges()
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
my @list = ();
|
2009-01-19 19:21:55 +01:00
|
|
|
my @ranges = ();
|
2000-06-09 07:27:21 +02:00
|
|
|
my $i = 0;
|
|
|
|
foreach $i (@lead_bytes) { $list[$i] = 1; }
|
|
|
|
my $on = 0;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
if ($on)
|
|
|
|
{
|
2009-01-19 19:21:55 +01:00
|
|
|
if (!defined $list[$i]) { push @ranges, $i-1; $on = 0; }
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-19 19:21:55 +01:00
|
|
|
if ($list[$i]) { push @ranges, $i; $on = 1; }
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
}
|
2009-01-19 19:21:55 +01:00
|
|
|
if ($on) { push @ranges, 0xff; }
|
|
|
|
return @ranges;
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
2011-06-27 18:02:39 +02:00
|
|
|
################################################################
|
|
|
|
# dump the Indic Syllabic Category table
|
|
|
|
sub dump_indic($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my @indic_table;
|
2011-06-27 18:02:39 +02:00
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $UNIDATA, "IndicSyllabicCategory.txt" );
|
2011-06-27 18:02:39 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*#/)
|
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
die "unknown indic $type" unless defined $indic_types{$type};
|
|
|
|
if (hex $1 < 65536)
|
|
|
|
{
|
|
|
|
$indic_table[hex $1] = $indic_types{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*#/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown indic $type" unless defined $indic_types{$type};
|
2016-02-09 05:58:53 +01:00
|
|
|
if (hex $1 < 65536 and hex $2 < 65536)
|
2011-06-27 18:02:39 +02:00
|
|
|
{
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$indic_table[$i] = $indic_types{$type};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
2015-10-01 20:55:56 +02:00
|
|
|
$INPUT = open_data_file( $UNIDATA, "IndicPositionalCategory.txt" );
|
2011-06-27 18:02:39 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z]+)\s*#/)
|
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
die "unknown matra $type" unless defined $matra_types{$type};
|
|
|
|
$indic_table[hex $1] += $matra_types{$type} << 8;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*#/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown matra $type" unless defined $matra_types{$type};
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$indic_table[$i] += $matra_types{$type} << 8;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Indic Syllabic Category */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/IndicSyllabicCategory.txt */\n";
|
2015-10-01 20:55:56 +02:00
|
|
|
print OUTPUT "/* and from $UNIDATA/IndicPositionalCategory.txt */\n";
|
2011-06-27 18:02:39 +02:00
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2011-06-27 18:02:39 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "indic_syllabic_table", $indic_types{'Other'}, @indic_table );
|
2011-06-27 18:02:39 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2011-06-27 18:01:24 +02:00
|
|
|
################################################################
|
|
|
|
# dump the Line Break Properties table
|
|
|
|
sub dump_linebreak($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my @break_table;
|
2011-06-27 18:01:24 +02:00
|
|
|
my $next_group = 0;
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $UNIDATA, "LineBreak.txt" );
|
2011-06-27 18:01:24 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
2016-06-22 14:00:22 +02:00
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z][0-9A-Z])+\s*/)
|
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
die "unknown breaktype $type" unless defined $break_types{$type};
|
|
|
|
$break_table[hex $1] = $break_types{$type};
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z][0-9A-Z])+\s*/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown breaktype $type" unless defined $break_types{$type};
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$break_table[$i] = $break_types{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z])+\s*/)
|
2011-06-27 18:01:24 +02:00
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
die "unknown breaktype $type" unless defined $break_types{$type};
|
|
|
|
$break_table[hex $1] = $break_types{$type};
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z])+\s*/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown breaktype $type" unless defined $break_types{$type};
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$break_table[$i] = $break_types{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Line Break Properties */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/LineBreak.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2011-06-27 18:01:24 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "wine_linebreak_table", $break_types{'XX'}, @break_table );
|
2011-06-27 18:01:24 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2016-07-04 09:44:47 +02:00
|
|
|
my %scripts =
|
|
|
|
(
|
|
|
|
"Unknown" => 0,
|
|
|
|
"Common" => 1,
|
|
|
|
"Inherited" => 2,
|
|
|
|
"Arabic" => 3,
|
|
|
|
"Armenian" => 4,
|
|
|
|
"Avestan" => 5,
|
|
|
|
"Balinese" => 6,
|
|
|
|
"Bamum" => 7,
|
|
|
|
"Batak" => 8,
|
|
|
|
"Bengali" => 9,
|
|
|
|
"Bopomofo" => 10,
|
|
|
|
"Brahmi" => 11,
|
|
|
|
"Braille" => 12,
|
|
|
|
"Buginese" => 13,
|
|
|
|
"Buhid" => 14,
|
|
|
|
"Canadian_Aboriginal" => 15,
|
|
|
|
"Carian" => 16,
|
|
|
|
"Cham" => 17,
|
|
|
|
"Cherokee" => 18,
|
|
|
|
"Coptic" => 19,
|
|
|
|
"Cuneiform" => 20,
|
|
|
|
"Cypriot" => 21,
|
|
|
|
"Cyrillic" => 22,
|
|
|
|
"Deseret" => 23,
|
|
|
|
"Devanagari" => 24,
|
|
|
|
"Egyptian_Hieroglyphs" => 25,
|
|
|
|
"Ethiopic" => 26,
|
|
|
|
"Georgian" => 27,
|
|
|
|
"Glagolitic" => 28,
|
|
|
|
"Gothic" => 29,
|
|
|
|
"Greek" => 30,
|
|
|
|
"Gujarati" => 31,
|
|
|
|
"Gurmukhi" => 32,
|
|
|
|
"Han" => 33,
|
|
|
|
"Hangul" => 34,
|
|
|
|
"Hanunoo" => 35,
|
|
|
|
"Hebrew" => 36,
|
|
|
|
"Hiragana" => 37,
|
|
|
|
"Imperial_Aramaic" => 38,
|
|
|
|
"Inscriptional_Pahlavi" => 39,
|
|
|
|
"Inscriptional_Parthian" => 40,
|
|
|
|
"Javanese" => 41,
|
|
|
|
"Kaithi" => 42,
|
|
|
|
"Kannada" => 43,
|
|
|
|
"Katakana" => 44,
|
|
|
|
"Kayah_Li" => 45,
|
|
|
|
"Kharoshthi" => 46,
|
|
|
|
"Khmer" => 47,
|
|
|
|
"Lao" => 48,
|
|
|
|
"Latin" => 49,
|
|
|
|
"Lepcha" => 50,
|
|
|
|
"Limbu" => 51,
|
|
|
|
"Linear_B" => 52,
|
|
|
|
"Lisu" => 53,
|
|
|
|
"Lycian" => 54,
|
|
|
|
"Lydian" => 55,
|
|
|
|
"Malayalam" => 56,
|
|
|
|
"Mandaic" => 57,
|
|
|
|
"Meetei_Mayek" => 58,
|
|
|
|
"Mongolian" => 59,
|
|
|
|
"Myanmar" => 60,
|
|
|
|
"New_Tai_Lue" => 61,
|
|
|
|
"Nko" => 62,
|
|
|
|
"Ogham" => 63,
|
|
|
|
"Ol_Chiki" => 64,
|
|
|
|
"Old_Italic" => 65,
|
|
|
|
"Old_Persian" => 66,
|
|
|
|
"Old_South_Arabian" => 67,
|
|
|
|
"Old_Turkic" => 68,
|
|
|
|
"Oriya" => 69,
|
|
|
|
"Osmanya" => 70,
|
|
|
|
"Phags_Pa" => 71,
|
|
|
|
"Phoenician" => 72,
|
|
|
|
"Rejang" => 73,
|
|
|
|
"Runic" => 74,
|
|
|
|
"Samaritan" => 75,
|
|
|
|
"Saurashtra" => 76,
|
|
|
|
"Shavian" => 77,
|
|
|
|
"Sinhala" => 78,
|
|
|
|
"Sundanese" => 79,
|
|
|
|
"Syloti_Nagri" => 80,
|
|
|
|
"Syriac" => 81,
|
|
|
|
"Tagalog" => 82,
|
|
|
|
"Tagbanwa" => 83,
|
|
|
|
"Tai_Le" => 84,
|
|
|
|
"Tai_Tham" => 85,
|
|
|
|
"Tai_Viet" => 86,
|
|
|
|
"Tamil" => 87,
|
|
|
|
"Telugu" => 88,
|
|
|
|
"Thaana" => 89,
|
|
|
|
"Thai" => 90,
|
|
|
|
"Tibetan" => 91,
|
|
|
|
"Tifinagh" => 92,
|
|
|
|
"Ugaritic" => 93,
|
|
|
|
"Vai" => 94,
|
|
|
|
"Yi" => 95,
|
|
|
|
# Win8/Win8.1
|
|
|
|
"Chakma" => 96,
|
|
|
|
"Meroitic_Cursive" => 97,
|
|
|
|
"Meroitic_Hieroglyphs" => 98,
|
|
|
|
"Miao" => 99,
|
|
|
|
"Sharada" => 100,
|
|
|
|
"Sora_Sompeng" => 101,
|
|
|
|
"Takri" => 102,
|
|
|
|
# Win10
|
|
|
|
"Bassa_Vah" => 103,
|
|
|
|
"Caucasian_Albanian" => 104,
|
|
|
|
"Duployan" => 105,
|
|
|
|
"Elbasan" => 106,
|
|
|
|
"Grantha" => 107,
|
|
|
|
"Khojki" => 108,
|
|
|
|
"Khudawadi" => 109,
|
|
|
|
"Linear_A" => 110,
|
|
|
|
"Mahajani" => 111,
|
|
|
|
"Manichaean" => 112,
|
|
|
|
"Mende_Kikakui" => 113,
|
|
|
|
"Modi" => 114,
|
|
|
|
"Mro" => 115,
|
|
|
|
"Nabataean" => 116,
|
|
|
|
"Old_North_Arabian" => 117,
|
|
|
|
"Old_Permic" => 118,
|
|
|
|
"Pahawh_Hmong" => 119,
|
|
|
|
"Palmyrene" => 120,
|
|
|
|
"Pau_Cin_Hau" => 121,
|
|
|
|
"Psalter_Pahlavi" => 122,
|
|
|
|
"Siddham" => 123,
|
|
|
|
"Tirhuta" => 124,
|
|
|
|
"Warang_Citi" => 125,
|
2016-11-06 11:56:41 +01:00
|
|
|
# Win10 RS1
|
|
|
|
"Adlam" => 126,
|
|
|
|
"Ahom" => 127,
|
|
|
|
"Anatolian_Hieroglyphs" => 128,
|
|
|
|
"Bhaiksuki" => 129,
|
|
|
|
"Hatran" => 130,
|
|
|
|
"Marchen" => 131,
|
|
|
|
"Multani" => 132,
|
|
|
|
"Newa" => 133,
|
|
|
|
"Old_Hungarian" => 134,
|
|
|
|
"Osage" => 135,
|
|
|
|
"SignWriting" => 136,
|
2018-07-03 11:50:56 +02:00
|
|
|
"Tangut" => 137,
|
|
|
|
# Win10 RS4
|
|
|
|
"Masaram_Gondi" => 138,
|
|
|
|
"Nushu" => 139,
|
|
|
|
"Soyombo" => 140,
|
|
|
|
"Zanabazar_Square" => 141,
|
2019-08-05 12:59:02 +02:00
|
|
|
# Win10 1903
|
|
|
|
"Dogra" => 142,
|
|
|
|
"Gunjala_Gondi" => 143,
|
|
|
|
"Hanifi_Rohingya" => 144,
|
|
|
|
"Makasar" => 145,
|
|
|
|
"Medefaidrin" => 146,
|
|
|
|
"Old_Sogdian" => 147,
|
|
|
|
"Sogdian" => 148,
|
2016-07-04 09:44:47 +02:00
|
|
|
);
|
|
|
|
|
2014-09-23 14:35:04 +02:00
|
|
|
################################################################
|
|
|
|
# dump Script IDs table
|
|
|
|
sub dump_scripts($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my $header = $filename;
|
2016-02-09 08:39:54 +01:00
|
|
|
my @scripts_table;
|
2014-09-26 08:21:27 +02:00
|
|
|
my $script_index;
|
2014-09-23 14:35:04 +02:00
|
|
|
my $i;
|
|
|
|
|
|
|
|
my $INPUT = open_data_file( $UNIDATA, "Scripts.txt" );
|
2016-07-04 09:44:47 +02:00
|
|
|
# Fill the table
|
|
|
|
# Unknown script id is always 0, so undefined scripts are automatically treated as such
|
2014-09-23 14:35:04 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
my $type = "";
|
|
|
|
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
2016-07-04 09:44:47 +02:00
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
|
2014-09-23 14:35:04 +02:00
|
|
|
{
|
|
|
|
$type = $2;
|
|
|
|
if (defined $scripts{$type})
|
|
|
|
{
|
|
|
|
$scripts_table[hex $1] = $scripts{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
2016-07-04 09:44:47 +02:00
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
|
2014-09-23 14:35:04 +02:00
|
|
|
{
|
|
|
|
$type = $3;
|
|
|
|
if (defined $scripts{$type})
|
|
|
|
{
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$scripts_table[$i] = $scripts{$type};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
$header = "$filename.h";
|
|
|
|
open OUTPUT,">$header.new" or die "Cannot create $header";
|
|
|
|
print "Building $header\n";
|
|
|
|
print OUTPUT "/* Unicode Script IDs */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/Scripts.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
|
|
|
|
|
|
|
print OUTPUT "enum unicode_script_id {\n";
|
2016-02-18 23:56:18 +01:00
|
|
|
foreach my $script (sort { $scripts{$a} <=> $scripts{$b} } keys %scripts)
|
2014-09-23 14:35:04 +02:00
|
|
|
{
|
|
|
|
print OUTPUT " Script_$script = $scripts{$script},\n";
|
|
|
|
}
|
2016-07-04 09:44:47 +02:00
|
|
|
print OUTPUT " Script_LastId = ", (scalar keys %scripts) - 1, "\n";
|
2014-09-23 14:35:04 +02:00
|
|
|
print OUTPUT "};\n";
|
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($header);
|
|
|
|
|
|
|
|
$filename = "$filename.c";
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $header";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Script IDs */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/Scripts.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2014-09-23 14:35:04 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "wine_scripts_table", 0, @scripts_table );
|
2014-09-23 14:35:04 +02:00
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2010-05-06 19:51:13 +02:00
|
|
|
################################################################
|
|
|
|
# dump the BiDi mirroring table
|
|
|
|
sub dump_mirroring($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my @mirror_table = ();
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $UNIDATA, "BidiMirroring.txt" );
|
2010-05-06 19:51:13 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
$mirror_table[hex $1] = hex $2;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode BiDi mirroring */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/BidiMirroring.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2019-04-02 16:38:04 +02:00
|
|
|
dump_case_table( "DECLSPEC_HIDDEN wine_mirror_map", @mirror_table );
|
2010-05-06 19:51:13 +02:00
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2014-06-30 16:01:33 +02:00
|
|
|
################################################################
|
|
|
|
# dump the Bidi Brackets
|
|
|
|
sub dump_bracket($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my @bracket_table;
|
2014-06-30 16:01:33 +02:00
|
|
|
|
|
|
|
my $INPUT = open_data_file( $UNIDATA, "BidiBrackets.txt" );
|
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9a-fA-F]+);\s*([con])/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown bracket $type" unless defined $bracket_types{$type};
|
2014-07-09 16:12:30 +02:00
|
|
|
die "characters too distant $1 and $2" if abs(hex($2) - hex($1)) >= 128;
|
2014-06-30 16:01:33 +02:00
|
|
|
$bracket_table[hex $1] = (hex($2) - hex($1)) % 255;
|
|
|
|
$bracket_table[hex $1] += $bracket_types{$type} << 8;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Bidirectional Bracket table */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/BidiBrackets.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2014-06-30 16:01:33 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "bidi_bracket_table", 0, @bracket_table );
|
2014-06-30 16:01:33 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
2010-05-06 19:51:13 +02:00
|
|
|
|
2010-05-19 17:52:42 +02:00
|
|
|
################################################################
|
|
|
|
# dump the Arabic shaping table
|
|
|
|
sub dump_shaping($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my %groups;
|
|
|
|
my $next_group = 0;
|
|
|
|
|
|
|
|
$groups{"No_Joining_Group"} = $next_group++;
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $UNIDATA, "ArabicShaping.txt" );
|
2010-05-19 17:52:42 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;.*;\s*([RLDCUT])\s*;\s*(\w+)/)
|
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
my $group = $3;
|
|
|
|
$groups{$group} = $next_group++ unless defined $groups{$group};
|
|
|
|
$joining_table[hex $1] = $joining_types{$type} | ($groups{$group} << 8);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Arabic shaping */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/ArabicShaping.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2010-05-19 17:52:42 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "wine_shaping_table", 0, @joining_table );
|
2010-05-19 17:52:42 +02:00
|
|
|
|
2016-02-24 05:39:01 +01:00
|
|
|
print OUTPUT "\nconst unsigned short DECLSPEC_HIDDEN wine_shaping_forms[256][4] =\n{\n";
|
2010-05-19 17:52:42 +02:00
|
|
|
for (my $i = 0x600; $i <= 0x6ff; $i++)
|
|
|
|
{
|
|
|
|
printf OUTPUT " { 0x%04x, 0x%04x, 0x%04x, 0x%04x },\n",
|
|
|
|
${joining_forms{"isolated"}}[$i] || $i,
|
|
|
|
${joining_forms{"final"}}[$i] || $i,
|
|
|
|
${joining_forms{"initial"}}[$i] || $i,
|
|
|
|
${joining_forms{"medial"}}[$i] || $i;
|
|
|
|
}
|
|
|
|
print OUTPUT "};\n";
|
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2013-11-15 17:37:24 +01:00
|
|
|
################################################################
|
|
|
|
# dump the Vertical Orientation table
|
|
|
|
sub dump_vertical($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my @vertical_table;
|
2013-11-15 17:37:24 +01:00
|
|
|
|
2017-07-08 15:45:51 +02:00
|
|
|
my $INPUT = open_data_file( $UNIDATA, "VerticalOrientation.txt" );
|
2013-11-15 17:37:24 +01:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next if /^\#/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
|
|
|
|
{
|
|
|
|
my $type = $2;
|
|
|
|
die "unknown vertical $type" unless defined $vertical_types{$type};
|
|
|
|
if (hex $1 < 65536)
|
|
|
|
{
|
|
|
|
$vertical_table[hex $1] = $vertical_types{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)..\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*/)
|
|
|
|
{
|
|
|
|
my $type = $3;
|
|
|
|
die "unknown vertical $type" unless defined $vertical_types{$type};
|
|
|
|
foreach my $i (hex $1 .. hex $2)
|
|
|
|
{
|
|
|
|
$vertical_table[$i] = $vertical_types{$type};
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
die "malformed line $_";
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Vertical Orientation */\n";
|
2017-07-08 15:45:51 +02:00
|
|
|
print OUTPUT "/* generated from $UNIDATA/VerticalOrientation.txt */\n";
|
2013-11-15 17:37:24 +01:00
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2013-11-15 17:37:24 +01:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "vertical_orientation_table", $vertical_types{'R'}, @vertical_table );
|
2013-11-15 17:37:24 +01:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
2010-05-19 17:52:42 +02:00
|
|
|
|
2016-02-18 06:02:10 +01:00
|
|
|
################################################################
|
|
|
|
# dump the digit folding tables
|
2019-11-28 09:05:13 +01:00
|
|
|
sub dump_digit_folding($$)
|
2016-02-18 06:02:10 +01:00
|
|
|
{
|
2019-11-28 09:05:13 +01:00
|
|
|
my ($filename, $compat) = @_;
|
2016-02-18 06:02:10 +01:00
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode digit folding mappings */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2016-02-18 06:02:10 +01:00
|
|
|
|
2019-04-02 16:38:04 +02:00
|
|
|
dump_case_table( "DECLSPEC_HIDDEN wine_digitmap", @digitmap_table );
|
2019-11-28 09:05:13 +01:00
|
|
|
if ($compat)
|
|
|
|
{
|
|
|
|
print OUTPUT "\n";
|
|
|
|
dump_case_table( "DECLSPEC_HIDDEN wine_compatmap", @compatmap_table );
|
|
|
|
}
|
2016-02-18 06:02:10 +01:00
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-12 03:16:11 +02:00
|
|
|
################################################################
|
|
|
|
# dump the case mapping tables
|
2019-03-24 10:21:57 +01:00
|
|
|
sub dump_case_mappings($)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $filename = shift;
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
2016-02-18 06:02:10 +01:00
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode case mappings */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2000-06-12 03:16:11 +02:00
|
|
|
|
2019-03-24 10:21:57 +01:00
|
|
|
dump_case_table( "wine_casemap_lower", @tolower_table );
|
2016-02-18 06:02:10 +01:00
|
|
|
print OUTPUT "\n";
|
2019-03-24 10:21:57 +01:00
|
|
|
dump_case_table( "wine_casemap_upper", @toupper_table );
|
2000-06-12 03:16:11 +02:00
|
|
|
close OUTPUT;
|
2009-01-19 19:51:19 +01:00
|
|
|
save_file($filename);
|
2000-06-12 03:16:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump a case mapping table
|
2019-03-24 10:21:57 +01:00
|
|
|
sub dump_case_table($@)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
|
|
|
my ($name,@table) = @_;
|
|
|
|
|
|
|
|
# count the number of sub tables that contain something
|
2003-10-15 04:32:34 +02:00
|
|
|
# also compute the low and upper populated bounds
|
2000-06-12 03:16:11 +02:00
|
|
|
|
2003-10-15 04:32:34 +02:00
|
|
|
my @lowerbounds = ( 0, 0 );
|
|
|
|
my @upperbounds = ( 0, 255 );
|
|
|
|
my $index = 0;
|
2000-06-12 03:16:11 +02:00
|
|
|
my @filled = ();
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
|
|
|
next unless defined $table[$i];
|
2003-10-15 04:32:34 +02:00
|
|
|
if (!defined $filled[$i >> 8])
|
|
|
|
{
|
|
|
|
$lowerbounds[$index] = $i & 0xff;
|
|
|
|
$upperbounds[$index] = 0xff - $lowerbounds[$index];
|
|
|
|
$filled[$i >> 8] = $index * 256 + 512;
|
|
|
|
$index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$upperbounds[$index-1] = 0xff - ($i & 0xff);
|
|
|
|
}
|
|
|
|
$table[$i] = ($table[$i] - $i) & 0xffff;
|
2000-06-12 03:16:11 +02:00
|
|
|
}
|
2003-10-15 04:32:34 +02:00
|
|
|
|
|
|
|
# Collapse blocks upwards if possible
|
|
|
|
my $removed = 0;
|
|
|
|
$index = 0;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
2003-10-15 04:32:34 +02:00
|
|
|
next unless defined $filled[$i];
|
|
|
|
if ($upperbounds[$index - 1] > $lowerbounds[$index])
|
|
|
|
{
|
|
|
|
$removed = $removed + $lowerbounds[$index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$removed = $removed + $upperbounds[$index - 1];
|
|
|
|
$lowerbounds[$index] = $upperbounds[$index - 1];
|
|
|
|
}
|
|
|
|
$filled[$i] = $filled[$i] - $removed;
|
|
|
|
$index++;
|
2000-06-12 03:16:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# dump the table
|
|
|
|
|
2019-04-02 16:38:04 +02:00
|
|
|
printf OUTPUT "const WCHAR %s[%d] =\n", $name, $index * 256 + 512 - $removed;
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT "{\n /* index */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s,\n", dump_array( 16, 256, @filled );
|
2000-06-12 03:16:11 +02:00
|
|
|
printf OUTPUT " /* defaults */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, (0) x 256 );
|
2003-10-15 04:32:34 +02:00
|
|
|
$index = 0;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-06-12 03:16:11 +02:00
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
2003-10-15 04:32:34 +02:00
|
|
|
printf OUTPUT ",\n /* 0x%02x%02x .. 0x%02xff */\n", $i, $lowerbounds[$index], $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table[($i<<8) + $lowerbounds[$index] .. ($i<<8)+255] );
|
2003-10-15 04:32:34 +02:00
|
|
|
$index++;
|
2000-06-12 03:16:11 +02:00
|
|
|
}
|
|
|
|
printf OUTPUT "\n};\n";
|
|
|
|
}
|
|
|
|
|
2010-05-19 17:52:42 +02:00
|
|
|
################################################################
|
2011-07-07 17:30:35 +02:00
|
|
|
# compress a mapping table by removing identical rows
|
2016-02-09 08:39:54 +01:00
|
|
|
sub compress_array($$@)
|
2010-05-19 17:52:42 +02:00
|
|
|
{
|
2011-07-07 17:30:35 +02:00
|
|
|
my $rows = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my $def = shift;
|
2010-05-19 17:52:42 +02:00
|
|
|
my @table = @_;
|
2011-07-07 17:30:35 +02:00
|
|
|
my $len = @table / $rows;
|
|
|
|
my @array = (0) x $rows;
|
2010-05-19 17:52:42 +02:00
|
|
|
my %sequences;
|
|
|
|
|
|
|
|
# try to merge table rows
|
2011-07-07 17:30:35 +02:00
|
|
|
for (my $row = 0; $row < $rows; $row++)
|
2010-05-19 17:52:42 +02:00
|
|
|
{
|
2016-02-09 08:39:54 +01:00
|
|
|
my @table_row = map { defined($_) ? $_ : $def; } @table[($row * $len)..($row * $len + $len - 1)];
|
2020-01-23 17:26:45 +01:00
|
|
|
my $rowtxt = pack "L*", @table_row;
|
2010-05-19 17:52:42 +02:00
|
|
|
if (defined($sequences{$rowtxt}))
|
|
|
|
{
|
|
|
|
# reuse an existing row
|
|
|
|
$array[$row] = $sequences{$rowtxt};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# create a new row
|
|
|
|
$sequences{$rowtxt} = $array[$row] = $#array + 1;
|
2016-02-09 08:39:54 +01:00
|
|
|
push @array, @table_row;
|
2010-05-19 17:52:42 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-07 17:30:35 +02:00
|
|
|
return @array;
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump a simple char -> 16-bit value mapping table
|
2016-02-09 08:39:54 +01:00
|
|
|
sub dump_simple_mapping($$@)
|
2011-07-07 17:30:35 +02:00
|
|
|
{
|
|
|
|
my $name = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my $def = shift;
|
|
|
|
my @array = compress_array( 256, $def, @_[0..65535] );
|
2010-05-19 17:52:42 +02:00
|
|
|
|
2019-04-02 16:38:04 +02:00
|
|
|
printf OUTPUT "const unsigned short %s[%d] =\n{\n", $name, $#array+1;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT " /* offsets */\n%s,\n", dump_array( 16, 0, @array[0..255] );
|
|
|
|
printf OUTPUT " /* values */\n%s\n};\n", dump_array( 16, 0, @array[256..$#array] );
|
2010-05-19 17:52:42 +02:00
|
|
|
}
|
2000-06-12 03:16:11 +02:00
|
|
|
|
2010-05-06 20:50:14 +02:00
|
|
|
################################################################
|
2011-07-07 17:30:35 +02:00
|
|
|
# dump a char -> 16-bit value mapping table using two-level tables
|
2016-02-09 08:39:54 +01:00
|
|
|
sub dump_two_level_mapping($$@)
|
2011-07-07 17:30:35 +02:00
|
|
|
{
|
|
|
|
my $name = shift;
|
2016-02-09 08:39:54 +01:00
|
|
|
my $def = shift;
|
|
|
|
my @row_array = compress_array( 4096, $def, @_[0..65535] );
|
|
|
|
my @array = compress_array( 256, 0, @row_array[0..4095] );
|
2011-07-07 17:30:35 +02:00
|
|
|
|
|
|
|
for (my $i = 256; $i < @array; $i++) { $array[$i] += @array - 4096; }
|
|
|
|
|
2016-02-24 05:39:01 +01:00
|
|
|
printf OUTPUT "const unsigned short DECLSPEC_HIDDEN %s[%d] =\n{\n", $name, @array + @row_array - 4096;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT " /* level 1 offsets */\n%s,\n", dump_array( 16, 0, @array[0..255] );
|
|
|
|
printf OUTPUT " /* level 2 offsets */\n%s,\n", dump_array( 16, 0, @array[256..$#array] );
|
|
|
|
printf OUTPUT " /* values */\n%s\n};\n", dump_array( 16, 0, @row_array[4096..$#row_array] );
|
2011-07-07 17:30:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
2010-05-06 20:50:14 +02:00
|
|
|
# dump a binary case mapping table in l_intl.nls format
|
|
|
|
sub dump_binary_case_table(@)
|
|
|
|
{
|
|
|
|
my (@table) = @_;
|
2020-01-23 16:45:02 +01:00
|
|
|
my $max_char = 0x10000;
|
|
|
|
my $level1 = $max_char / 16;
|
|
|
|
my $level2 = $level1 / 16;
|
2010-05-06 20:50:14 +02:00
|
|
|
|
2020-01-23 16:45:02 +01:00
|
|
|
my @difftable;
|
|
|
|
for (my $i = 0; $i < @table; $i++)
|
2010-05-06 20:50:14 +02:00
|
|
|
{
|
2020-01-23 16:45:02 +01:00
|
|
|
next unless defined $table[$i];
|
|
|
|
$difftable[$i] = ($table[$i] - $i) & 0xffff;
|
2010-05-06 20:50:14 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 16:45:02 +01:00
|
|
|
my @row_array = compress_array( $level1, 0, @difftable[0..$max_char-1] );
|
|
|
|
my @array = compress_array( $level2, 0, @row_array[0..$level1-1] );
|
|
|
|
for (my $i = $level2; $i < @array; $i++) { $array[$i] += @array - $level1; }
|
|
|
|
return @array, @row_array[$level1..$#row_array];
|
2010-05-06 20:50:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump case mappings for l_intl.nls
|
|
|
|
sub dump_intl_nls($)
|
|
|
|
{
|
2020-01-23 16:45:02 +01:00
|
|
|
my @upper = dump_binary_case_table( @toupper_table );
|
|
|
|
my @lower = dump_binary_case_table( @tolower_table );
|
|
|
|
|
2010-05-06 20:50:14 +02:00
|
|
|
my $filename = shift;
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
printf "Building $filename\n";
|
|
|
|
|
|
|
|
binmode OUTPUT;
|
|
|
|
print OUTPUT pack "S<", 1; # version
|
2020-01-23 16:45:02 +01:00
|
|
|
print OUTPUT pack "S<*", 1 + scalar @upper, @upper;
|
|
|
|
print OUTPUT pack "S<*", 1 + scalar @lower, @lower;
|
2010-05-06 20:50:14 +02:00
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-25 17:56:33 +02:00
|
|
|
sub load_nameprep_range_table($$$)
|
|
|
|
{
|
|
|
|
my ($INPUT, $val, $table_ref) = @_;
|
|
|
|
|
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
if (/^\s*([0-9a-fA-F]+)-([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
my $last = hex $2;
|
|
|
|
$last = 65535 if($last >= 65536);
|
|
|
|
foreach my $i (hex $1 .. $last)
|
|
|
|
{
|
|
|
|
$table_ref->[$i] |= $val;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
if (hex $1 < 65536)
|
|
|
|
{
|
|
|
|
$table_ref->[hex $1] |= $val;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return if (/End\sTable/);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub load_nameprep_map_table($$)
|
|
|
|
{
|
|
|
|
my ($INPUT, $table_ref) = @_;
|
|
|
|
|
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
if (/^\s*([0-9a-fA-F]+);\s;/)
|
|
|
|
{
|
|
|
|
# special value for map to nothing
|
|
|
|
$table_ref->[hex $1] = [0xffff, 0xffff, 0xffff];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+);\s([0-9a-fA-F]+);/)
|
|
|
|
{
|
|
|
|
$table_ref->[hex $1] = [hex $2, 0, 0];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+);\s([0-9a-fA-F]+)\s([0-9a-fA-F]+);/)
|
|
|
|
{
|
|
|
|
$table_ref->[hex $1] = [hex $2, hex $3, 0];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif (/^\s*([0-9a-fA-F]+);\s([0-9a-fA-F]+)\s([0-9a-fA-F]+)\s([0-9a-fA-F]+);/)
|
|
|
|
{
|
|
|
|
$table_ref->[hex $1] = [hex $2, hex $3, hex $4];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return if (/End\sTable/);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump mapping table, prohibited characters set, unassigned
|
|
|
|
# characters, bidirectional rules used by nameprep algorithm
|
|
|
|
sub dump_nameprep($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my @mapping_table = ();
|
2016-02-09 08:39:54 +01:00
|
|
|
my @flags_table;
|
2012-04-25 17:56:33 +02:00
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $RFCS, $STRINGPREP );
|
2012-04-25 17:56:33 +02:00
|
|
|
while (<$INPUT>)
|
|
|
|
{
|
|
|
|
next unless /Start\sTable/;
|
|
|
|
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"unassigned"}, \@flags_table) if (/A.1/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.1.2/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.2.2/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.3/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.4/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.5/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.6/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.7/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.8/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"prohibited"}, \@flags_table) if (/C.9/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"bidi_ral"}, \@flags_table) if (/D.1/);
|
|
|
|
load_nameprep_range_table($INPUT, $nameprep_flags{"bidi_l"}, \@flags_table) if (/D.2/);
|
|
|
|
|
|
|
|
load_nameprep_map_table($INPUT, \@mapping_table) if (/B.1/);
|
|
|
|
load_nameprep_map_table($INPUT, \@mapping_table) if (/B.2/);
|
|
|
|
}
|
|
|
|
close $INPUT;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Nameprep algorithm related data */\n";
|
2013-06-19 16:05:18 +02:00
|
|
|
print OUTPUT "/* generated from $RFCS/$STRINGPREP */\n";
|
2012-04-25 17:56:33 +02:00
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2012-04-25 17:56:33 +02:00
|
|
|
|
2016-02-09 08:39:54 +01:00
|
|
|
dump_two_level_mapping( "nameprep_char_type", 0, @flags_table );
|
2012-04-25 17:56:33 +02:00
|
|
|
|
|
|
|
######### mapping table
|
|
|
|
# first determine all the 16-char subsets that contain something
|
|
|
|
my @filled = ();
|
|
|
|
my $pos = 16*3; # for the null subset
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
|
|
|
{
|
|
|
|
next unless defined $mapping_table[$i];
|
|
|
|
$filled[$i >> 4] = $pos;
|
|
|
|
$pos += 16*3;
|
|
|
|
$i |= 15;
|
|
|
|
}
|
|
|
|
my $total = $pos;
|
|
|
|
|
|
|
|
# now count the 256-char subsets that contain something
|
|
|
|
my @filled_idx = (256) x 256;
|
|
|
|
$pos = 256 + 16;
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled_idx[$i >> 4] = $pos;
|
|
|
|
$pos += 16;
|
|
|
|
$i |= 15;
|
|
|
|
}
|
|
|
|
my $null_offset = $pos;
|
|
|
|
$total += $pos;
|
|
|
|
|
|
|
|
# add the index offsets to the subsets positions
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled[$i] += $null_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
# dump the main index
|
2016-02-24 05:39:01 +01:00
|
|
|
printf OUTPUT "const unsigned short DECLSPEC_HIDDEN nameprep_mapping[%d] =\n", $total;
|
2012-04-25 17:56:33 +02:00
|
|
|
printf OUTPUT "{\n /* index */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @filled_idx );
|
|
|
|
printf OUTPUT ",\n /* null sub-index */\n%s", dump_array( 16, 0, ($null_offset) x 16 );
|
2012-04-25 17:56:33 +02:00
|
|
|
|
|
|
|
# dump the second-level indexes
|
|
|
|
for (my $i = 0; $i < 256; $i++)
|
|
|
|
{
|
|
|
|
next unless ($filled_idx[$i] > 256);
|
|
|
|
my @table = @filled[($i<<4)..($i<<4)+15];
|
|
|
|
for (my $j = 0; $j < 16; $j++) { $table[$j] ||= $null_offset; }
|
|
|
|
printf OUTPUT ",\n /* sub-index %02x */\n", $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2012-04-25 17:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# dump the 16-char subsets
|
|
|
|
printf OUTPUT ",\n /* null mapping */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, (0) x 48 );
|
2012-04-25 17:56:33 +02:00
|
|
|
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
my @table = (0) x 48;
|
|
|
|
for (my $j = 0; $j < 16; $j++)
|
|
|
|
{
|
|
|
|
if (defined $mapping_table[($i<<4) + $j])
|
|
|
|
{
|
|
|
|
$table[3 * $j] = ${$mapping_table[($i << 4) + $j]}[0];
|
|
|
|
$table[3 * $j + 1] = ${$mapping_table[($i << 4) + $j]}[1];
|
|
|
|
$table[3 * $j + 2] = ${$mapping_table[($i << 4) + $j]}[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf OUTPUT ",\n /* 0x%03x0 .. 0x%03xf */\n", $i, $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2012-04-25 17:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
printf OUTPUT "\n};\n";
|
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2019-05-22 10:31:55 +02:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# dump the GetStringTypeW table
|
|
|
|
sub dump_string_type_table($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
printf "Building $filename\n";
|
|
|
|
printf OUTPUT "/* Unicode wctype table */\n";
|
|
|
|
printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
|
|
|
|
printf OUTPUT "#include \"windef.h\"\n\n";
|
|
|
|
|
|
|
|
my @table = @category_table;
|
|
|
|
|
|
|
|
# add the direction in the high 4 bits of the category
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
|
|
|
{
|
2019-05-22 11:26:19 +02:00
|
|
|
$table[$i] |= $c2_types{$direction_table[$i]} << 12 if defined $direction_table[$i];
|
2019-05-22 10:31:55 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 10:13:29 +02:00
|
|
|
dump_two_level_mapping( "wctype_table", 0, @table );
|
2019-05-22 10:31:55 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-22 15:37:29 +02:00
|
|
|
################################################################
|
|
|
|
# dump the bidi direction table
|
|
|
|
sub dump_bidi_dir_table($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
printf "Building $filename\n";
|
|
|
|
printf OUTPUT "/* Unicode BiDi direction table */\n";
|
|
|
|
printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
|
|
|
|
printf OUTPUT "#include \"windef.h\"\n\n";
|
|
|
|
|
|
|
|
my @table;
|
|
|
|
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
|
|
|
{
|
2019-05-22 15:59:49 +02:00
|
|
|
$table[$i] = $bidi_types{$direction_table[$i]} if defined $direction_table[$i];
|
2019-05-22 15:37:29 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 10:13:29 +02:00
|
|
|
dump_two_level_mapping( "bidi_direction_table", $bidi_types{"L"}, @table );
|
2019-05-22 15:37:29 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
################################################################
|
|
|
|
# dump the ctype tables
|
2019-03-23 13:35:33 +01:00
|
|
|
sub dump_ctype_tables($)
|
2000-08-11 22:53:40 +02:00
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $filename = shift;
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
printf "Building $filename\n";
|
2000-08-11 22:53:40 +02:00
|
|
|
printf OUTPUT "/* Unicode ctype tables */\n";
|
|
|
|
printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
printf OUTPUT "#include \"windef.h\"\n\n";
|
2000-08-11 22:53:40 +02:00
|
|
|
|
2019-05-22 10:31:55 +02:00
|
|
|
my @table = @category_table;
|
|
|
|
|
2000-08-11 22:53:40 +02:00
|
|
|
# add the direction in the high 4 bits of the category
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-08-11 22:53:40 +02:00
|
|
|
{
|
2019-05-22 10:31:55 +02:00
|
|
|
$table[$i] |= $directions{$direction_table[$i]} << 12 if defined $direction_table[$i];
|
2000-08-11 22:53:40 +02:00
|
|
|
}
|
|
|
|
|
2019-05-22 10:31:55 +02:00
|
|
|
dump_simple_mapping( "wine_wctype_table", 0, @table );
|
2000-08-11 22:53:40 +02:00
|
|
|
|
|
|
|
close OUTPUT;
|
2009-01-19 19:51:19 +01:00
|
|
|
save_file($filename);
|
2000-08-11 22:53:40 +02:00
|
|
|
}
|
|
|
|
|
2000-12-29 04:56:06 +01:00
|
|
|
|
|
|
|
################################################################
|
2016-02-19 03:33:39 +01:00
|
|
|
# dump the char composition table
|
|
|
|
sub dump_compose_table($)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $filename = shift;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
2016-02-19 03:33:39 +01:00
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode char composition */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2000-12-29 04:56:06 +01:00
|
|
|
|
|
|
|
my @filled = ();
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $i (@compose_table)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
my @comp = @$i;
|
|
|
|
push @{$filled[$comp[1]]}, [ $comp[0], $comp[2] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
# count how many different second chars we have
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
my $count = 0;
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless defined $filled[$i];
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
# build the table of second chars and offsets
|
|
|
|
|
|
|
|
my $pos = $count + 1;
|
2009-01-19 19:51:19 +01:00
|
|
|
my @table = ();
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless defined $filled[$i];
|
|
|
|
push @table, $i, $pos;
|
|
|
|
$pos += @{$filled[$i]};
|
|
|
|
}
|
|
|
|
# terminator with last position
|
|
|
|
push @table, 0, $pos;
|
2016-02-19 03:38:14 +01:00
|
|
|
printf OUTPUT "static const WCHAR table[0x%x] =\n{\n", 2*$pos;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT " /* second chars + offsets */\n%s", dump_array( 16, 0, @table );
|
2000-12-29 04:56:06 +01:00
|
|
|
|
|
|
|
# build the table of first chars and mappings
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless defined $filled[$i];
|
|
|
|
my @table = ();
|
|
|
|
my @list = sort { $a->[0] <=> $b->[0] } @{$filled[$i]};
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $j = 0; $j <= $#list; $j++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
push @table, $list[$j][0], $list[$j][1];
|
|
|
|
}
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT ",\n /* 0x%04x */\n%s", $i, dump_array( 16, 0, @table );
|
2000-12-29 04:56:06 +01:00
|
|
|
}
|
2016-02-19 03:38:14 +01:00
|
|
|
print OUTPUT "\n};\n\n";
|
|
|
|
print OUTPUT <<"EOF";
|
|
|
|
static inline int binary_search( WCHAR ch, int low, int high )
|
|
|
|
{
|
|
|
|
while (low <= high)
|
|
|
|
{
|
|
|
|
int pos = (low + high) / 2;
|
|
|
|
if (table[2 * pos] < ch) low = pos + 1;
|
|
|
|
else if (table[2 * pos] > ch) high = pos - 1;
|
|
|
|
else return pos;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-02-24 05:36:41 +01:00
|
|
|
WCHAR DECLSPEC_HIDDEN wine_compose( const WCHAR *str )
|
2016-02-19 03:38:14 +01:00
|
|
|
{
|
|
|
|
int pos, idx = 1, start = 0, count = $count;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ((pos = binary_search( str[idx], start, count - 1 )) == -1) return 0;
|
|
|
|
if (!idx--) return table[2 * pos + 1];
|
|
|
|
start = table[2 * pos + 1];
|
|
|
|
count = table[2 * pos + 3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2016-02-19 03:33:39 +01:00
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2019-02-08 11:41:25 +01:00
|
|
|
sub dump_full_compat_table()
|
|
|
|
{
|
|
|
|
# first determine all the 16-char subsets that contain something
|
|
|
|
|
|
|
|
my @filled = (0) x 4096;
|
|
|
|
my $pos = 16; # for the null subset
|
|
|
|
my $data_total = 0;
|
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
|
|
|
{
|
|
|
|
next unless defined $full_compatmap_table[$i];
|
|
|
|
if ($filled[$i >> 4] == 0)
|
|
|
|
{
|
|
|
|
$filled[$i >> 4] = $pos;
|
|
|
|
$pos += 16;
|
|
|
|
}
|
|
|
|
$data_total += $#{$full_compatmap_table[$i]} + 1;
|
|
|
|
}
|
|
|
|
my $total = $pos;
|
|
|
|
|
|
|
|
# now count the 256-char subsets that contain something
|
|
|
|
|
|
|
|
my @filled_idx = (256) x 256;
|
|
|
|
$pos = 256 + 16;
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled_idx[$i >> 4] = $pos;
|
|
|
|
$pos += 16;
|
|
|
|
$i |= 15;
|
|
|
|
}
|
|
|
|
my $null_offset = $pos; # null mapping
|
|
|
|
$total += $pos + 1; # add the offset sentinel
|
|
|
|
|
|
|
|
# add the index offsets to the subsets positions
|
|
|
|
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled[$i] += $null_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
# dump the main index
|
|
|
|
|
|
|
|
printf OUTPUT "static const WCHAR compatmap_table[%d] =\n", $total + $data_total;
|
|
|
|
printf OUTPUT "{\n /* index */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @filled_idx );
|
|
|
|
printf OUTPUT ",\n /* null sub-index */\n%s", dump_array( 16, 0, ($null_offset) x 16 );
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
# dump the second-level indexes
|
|
|
|
|
|
|
|
for (my $i = 0; $i < 256; $i++)
|
|
|
|
{
|
|
|
|
next unless ($filled_idx[$i] > 256);
|
|
|
|
my @table = @filled[($i<<4)..($i<<4)+15];
|
|
|
|
for (my $j = 0; $j < 16; $j++) { $table[$j] ||= $null_offset; }
|
|
|
|
printf OUTPUT ",\n /* sub-index %02x */\n", $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2019-02-08 11:41:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# dump the 16-char offsets
|
|
|
|
|
|
|
|
printf OUTPUT ",\n /* null offsets */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, ($total) x (16) );
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
$pos = $total;
|
|
|
|
|
|
|
|
my @data;
|
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
my @table = (0) x (16);
|
|
|
|
for (my $j = 0; $j < 16; $j++)
|
|
|
|
{
|
|
|
|
$table[$j] = $pos;
|
|
|
|
if (defined $full_compatmap_table[($i<<4) + $j])
|
|
|
|
{
|
|
|
|
$pos += $#{$full_compatmap_table[($i<<4) + $j]} + 1;
|
|
|
|
push @data, @{$full_compatmap_table[($i<<4) + $j]};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf OUTPUT ",\n /* offsets 0x%03x0 .. 0x%03xf */\n", $i, $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2019-02-08 11:41:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
my @sentinel = $pos;
|
|
|
|
printf OUTPUT ",\n /* offset sentinel */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @sentinel );
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
printf OUTPUT ",\n /* data */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @data );
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
printf OUTPUT "\n};\n\n";
|
|
|
|
}
|
|
|
|
|
2016-02-19 03:33:39 +01:00
|
|
|
################################################################
|
|
|
|
# dump the char decomposition table
|
2019-12-05 11:22:19 +01:00
|
|
|
sub dump_decompose_table($$)
|
2016-02-19 03:33:39 +01:00
|
|
|
{
|
2019-12-05 11:22:19 +01:00
|
|
|
my ($filename, $compat) = @_;
|
2000-12-29 04:56:06 +01:00
|
|
|
|
2016-02-19 03:33:39 +01:00
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode char composition */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-12-05 11:22:19 +01:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2000-12-29 04:56:06 +01:00
|
|
|
|
|
|
|
# first determine all the 16-char subsets that contain something
|
|
|
|
|
2016-02-19 03:33:39 +01:00
|
|
|
my @filled = (0) x 4096;
|
|
|
|
my $pos = 16*2; # for the null subset
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 65536; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless defined $decomp_table[$i];
|
|
|
|
$filled[$i >> 4] = $pos;
|
|
|
|
$pos += 16*2;
|
|
|
|
$i |= 15;
|
|
|
|
}
|
|
|
|
my $total = $pos;
|
|
|
|
|
|
|
|
# now count the 256-char subsets that contain something
|
|
|
|
|
|
|
|
my @filled_idx = (256) x 256;
|
|
|
|
$pos = 256 + 16;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled_idx[$i >> 4] = $pos;
|
|
|
|
$pos += 16;
|
|
|
|
$i |= 15;
|
|
|
|
}
|
|
|
|
my $null_offset = $pos; # null mapping
|
|
|
|
$total += $pos;
|
|
|
|
|
|
|
|
# add the index offsets to the subsets positions
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
$filled[$i] += $null_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
# dump the main index
|
|
|
|
|
2016-02-19 03:38:14 +01:00
|
|
|
printf OUTPUT "static const WCHAR table[%d] =\n", $total;
|
2000-12-29 04:56:06 +01:00
|
|
|
printf OUTPUT "{\n /* index */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @filled_idx );
|
|
|
|
printf OUTPUT ",\n /* null sub-index */\n%s", dump_array( 16, 0, ($null_offset) x 16 );
|
2000-12-29 04:56:06 +01:00
|
|
|
|
|
|
|
# dump the second-level indexes
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 256; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless ($filled_idx[$i] > 256);
|
|
|
|
my @table = @filled[($i<<4)..($i<<4)+15];
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $j = 0; $j < 16; $j++) { $table[$j] ||= $null_offset; }
|
2000-12-29 04:56:06 +01:00
|
|
|
printf OUTPUT ",\n /* sub-index %02x */\n", $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2000-12-29 04:56:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# dump the 16-char subsets
|
|
|
|
|
|
|
|
printf OUTPUT ",\n /* null mapping */\n";
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, (0) x 32 );
|
2000-12-29 04:56:06 +01:00
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $i = 0; $i < 4096; $i++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
next unless $filled[$i];
|
|
|
|
my @table = (0) x 32;
|
2009-01-19 19:51:19 +01:00
|
|
|
for (my $j = 0; $j < 16; $j++)
|
2000-12-29 04:56:06 +01:00
|
|
|
{
|
|
|
|
if (defined $decomp_table[($i<<4) + $j])
|
|
|
|
{
|
|
|
|
$table[2 * $j] = ${$decomp_table[($i << 4) + $j]}[0];
|
|
|
|
$table[2 * $j + 1] = ${$decomp_table[($i << 4) + $j]}[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf OUTPUT ",\n /* 0x%03x0 .. 0x%03xf */\n", $i, $i;
|
2020-01-23 17:39:07 +01:00
|
|
|
printf OUTPUT "%s", dump_array( 16, 0, @table );
|
2000-12-29 04:56:06 +01:00
|
|
|
}
|
|
|
|
|
2019-12-05 11:22:19 +01:00
|
|
|
print OUTPUT "\n};\n\n";
|
|
|
|
if ($compat)
|
|
|
|
{
|
|
|
|
dump_full_compat_table();
|
|
|
|
print OUTPUT <<"EOF";
|
|
|
|
#include "wine/unicode.h"
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
static const WCHAR *get_compatmap_entry( WCHAR ch, unsigned int *len )
|
|
|
|
{
|
|
|
|
unsigned short offset_offs = compatmap_table[compatmap_table[ch >> 8] + ((ch >> 4) & 0xf)] + (ch & 0xf);
|
|
|
|
unsigned short start = compatmap_table[offset_offs];
|
|
|
|
unsigned short end = compatmap_table[offset_offs + 1];
|
|
|
|
|
|
|
|
if (end > start)
|
|
|
|
{
|
|
|
|
*len = end - start;
|
|
|
|
return compatmap_table + start;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-02-08 11:41:23 +01:00
|
|
|
unsigned int DECLSPEC_HIDDEN wine_decompose( int flags, WCHAR ch, WCHAR *dst, unsigned int dstlen )
|
2016-02-19 03:38:14 +01:00
|
|
|
{
|
2019-02-08 11:41:25 +01:00
|
|
|
const WCHAR *ptr = NULL;
|
|
|
|
unsigned int res, len, dst_pos = 0;
|
2016-02-19 03:38:14 +01:00
|
|
|
|
|
|
|
*dst = ch;
|
2019-02-08 11:41:25 +01:00
|
|
|
|
|
|
|
if (flags & WINE_DECOMPOSE_COMPAT)
|
|
|
|
ptr = get_compatmap_entry( ch, &len );
|
|
|
|
|
|
|
|
if (!ptr)
|
|
|
|
{
|
|
|
|
ptr = table + table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + 2 * (ch & 0xf);
|
2019-02-08 11:41:26 +01:00
|
|
|
len = ptr[1] ? 2 : 1;
|
2019-02-08 11:41:25 +01:00
|
|
|
}
|
|
|
|
|
2016-02-19 03:38:14 +01:00
|
|
|
if (!*ptr) return 1;
|
2019-02-08 11:41:25 +01:00
|
|
|
if (dstlen < len) return 0;
|
|
|
|
/* apply the decomposition recursively */
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
if (!(res = wine_decompose( flags, *ptr++, dst + dst_pos, dstlen - dst_pos - len ))) return 0;
|
|
|
|
dst_pos += res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dst_pos;
|
2016-02-19 03:38:14 +01:00
|
|
|
}
|
|
|
|
EOF
|
2019-12-05 11:22:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print OUTPUT <<"EOF";
|
|
|
|
unsigned int DECLSPEC_HIDDEN wine_decompose( int flags, WCHAR ch, WCHAR *dst, unsigned int dstlen )
|
|
|
|
{
|
|
|
|
const WCHAR *ptr = table + table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + 2 * (ch & 0xf);
|
|
|
|
unsigned int res, len, dst_pos = 0;
|
|
|
|
|
|
|
|
*dst = ch;
|
|
|
|
if (!*ptr) return 1;
|
|
|
|
len = ptr[1] ? 2 : 1;
|
|
|
|
if (dstlen < len) return 0;
|
|
|
|
/* apply the decomposition recursively */
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
if (!(res = wine_decompose( flags, *ptr++, dst + dst_pos, dstlen - dst_pos - len ))) return 0;
|
|
|
|
dst_pos += res;
|
|
|
|
}
|
|
|
|
return dst_pos;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
2000-12-29 04:56:06 +01:00
|
|
|
close OUTPUT;
|
2009-01-19 19:51:19 +01:00
|
|
|
save_file($filename);
|
2000-12-29 04:56:06 +01:00
|
|
|
}
|
|
|
|
|
2019-02-08 11:41:24 +01:00
|
|
|
################################################################
|
|
|
|
# dump the combining class table
|
|
|
|
sub dump_combining_class($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
|
|
|
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
|
|
|
print "Building $filename\n";
|
|
|
|
print OUTPUT "/* Unicode Combining Classes */\n";
|
|
|
|
print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
2019-05-22 17:34:45 +02:00
|
|
|
print OUTPUT "#include \"windef.h\"\n\n";
|
2019-02-08 11:41:24 +01:00
|
|
|
|
|
|
|
dump_two_level_mapping( "combining_class_table", 0, @combining_class_table );
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($filename);
|
|
|
|
}
|
|
|
|
|
2009-01-19 19:21:55 +01:00
|
|
|
################################################################
|
2013-06-26 17:28:15 +02:00
|
|
|
# output a codepage definition file from the global tables
|
|
|
|
sub output_codepage_file($$$$)
|
|
|
|
{
|
|
|
|
my ($codepage, $filename, $comment, $has_glyphs) = @_;
|
|
|
|
|
2016-02-18 06:33:10 +01:00
|
|
|
my $output = sprintf "libs/port/c_%03d.c", $codepage;
|
2013-06-26 17:28:15 +02:00
|
|
|
open OUTPUT,">$output.new" or die "Cannot create $output";
|
2009-01-19 19:21:55 +01:00
|
|
|
|
2013-06-26 17:28:15 +02:00
|
|
|
printf "Building %s from %s (%s)\n", $output, $filename || "hardcoded data", $comment;
|
|
|
|
|
|
|
|
# dump all tables
|
|
|
|
|
|
|
|
printf OUTPUT "/* code page %03d (%s) */\n", $codepage, $comment;
|
|
|
|
if ($filename)
|
|
|
|
{
|
|
|
|
print OUTPUT "/* generated from $MAPPINGS/$filename */\n";
|
|
|
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
|
|
|
|
}
|
|
|
|
printf OUTPUT "#include \"wine/unicode.h\"\n\n";
|
|
|
|
|
|
|
|
if (!@lead_bytes) { dump_sbcs_table( $codepage, $has_glyphs, $comment, $default_char, $default_wchar ); }
|
|
|
|
else { dump_dbcs_table( $codepage, $comment, $default_char, $default_wchar, get_lb_ranges() ); }
|
|
|
|
close OUTPUT;
|
|
|
|
save_file($output);
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# read a "bestfit" Windows mapping file
|
|
|
|
sub read_bestfit_file($)
|
2009-01-19 19:21:55 +01:00
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
my ($filename) = @_;
|
2009-01-19 19:21:55 +01:00
|
|
|
my $state = "";
|
2013-06-26 17:28:15 +02:00
|
|
|
my ($codepage, $width, $count);
|
2009-01-19 19:21:55 +01:00
|
|
|
my ($lb_cur, $lb_end);
|
|
|
|
|
2013-06-19 16:05:18 +02:00
|
|
|
my $INPUT = open_data_file( $MAPPINGS, $filename ) or die "Cannot open $filename";
|
2009-01-19 19:21:55 +01:00
|
|
|
|
2010-05-06 18:23:38 +02:00
|
|
|
while (<$INPUT>)
|
2009-01-19 19:21:55 +01:00
|
|
|
{
|
|
|
|
next if /^;/; # skip comments
|
|
|
|
next if /^\s*$/; # skip empty lines
|
|
|
|
next if /\x1a/; # skip ^Z
|
|
|
|
last if /^ENDCODEPAGE/;
|
|
|
|
|
|
|
|
if (/^CODEPAGE\s+(\d+)/)
|
|
|
|
{
|
|
|
|
$codepage = $1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^CPINFO\s+(\d+)\s+0x([0-9a-fA-f]+)\s+0x([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
$width = $1;
|
2013-06-26 17:28:15 +02:00
|
|
|
$default_char = hex $2;
|
|
|
|
$default_wchar = hex $3;
|
2009-01-19 19:21:55 +01:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^(MBTABLE|WCTABLE|DBCSRANGE|DBCSTABLE)\s+(\d+)/)
|
|
|
|
{
|
|
|
|
$state = $1;
|
|
|
|
$count = $2;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)/)
|
|
|
|
{
|
|
|
|
if ($state eq "MBTABLE")
|
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $cp = hex $1;
|
|
|
|
my $uni = hex $2;
|
2009-01-19 19:21:55 +01:00
|
|
|
$cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($state eq "WCTABLE")
|
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $uni = hex $1;
|
|
|
|
my $cp = hex $2;
|
2009-01-19 19:21:55 +01:00
|
|
|
$uni2cp[$uni] = $cp unless defined($uni2cp[$uni]);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($state eq "DBCSRANGE")
|
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $start = hex $1;
|
|
|
|
my $end = hex $2;
|
2013-06-26 17:28:15 +02:00
|
|
|
for (my $i = $start; $i <= $end; $i++) { add_lead_byte( $i ); }
|
2009-01-19 19:21:55 +01:00
|
|
|
$lb_cur = $start;
|
|
|
|
$lb_end = $end;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($state eq "DBCSTABLE")
|
|
|
|
{
|
2009-01-19 19:51:19 +01:00
|
|
|
my $mb = hex $1;
|
|
|
|
my $uni = hex $2;
|
|
|
|
my $cp = ($lb_cur << 8) | $mb;
|
2009-01-19 19:21:55 +01:00
|
|
|
$cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
|
|
|
|
if (!--$count)
|
|
|
|
{
|
|
|
|
if (++$lb_cur > $lb_end) { $state = "DBCSRANGE"; }
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
2009-01-19 19:51:19 +01:00
|
|
|
die "$filename: Unrecognized line $_\n";
|
2009-01-19 19:21:55 +01:00
|
|
|
}
|
2010-05-06 18:23:38 +02:00
|
|
|
close $INPUT;
|
2009-01-19 19:21:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-09 07:27:21 +02:00
|
|
|
################################################################
|
|
|
|
# read an input file and generate the corresponding .c file
|
2009-01-19 19:51:19 +01:00
|
|
|
sub HANDLE_FILE(@)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-08-19 18:59:40 +02:00
|
|
|
my ($codepage,$filename,$has_glyphs,$comment,$first_private,$def,$defw) = @_;
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2007-02-05 20:39:13 +01:00
|
|
|
@cp2uni = ();
|
|
|
|
@lead_bytes = ();
|
|
|
|
@uni2cp = ();
|
2013-06-26 17:28:15 +02:00
|
|
|
$default_char = $def || $DEF_CHAR;
|
|
|
|
$default_wchar = $defw || $DEF_CHAR;
|
2007-02-05 20:39:13 +01:00
|
|
|
|
2013-06-26 17:28:15 +02:00
|
|
|
# some codepage files are special
|
|
|
|
if ($codepage == 20932)
|
2009-01-19 19:21:55 +01:00
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
READ_JIS0208_FILE( $filename );
|
2013-08-19 18:59:40 +02:00
|
|
|
add_default_mappings( $first_private );
|
2009-01-19 19:21:55 +01:00
|
|
|
}
|
2013-06-26 17:28:15 +02:00
|
|
|
elsif ($codepage == 20127)
|
2007-05-29 23:31:14 +02:00
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
fill_20127_codepage();
|
2013-08-19 18:59:40 +02:00
|
|
|
add_default_mappings( $first_private );
|
2013-06-26 17:28:15 +02:00
|
|
|
}
|
|
|
|
elsif ($filename =~ /\/bestfit/)
|
|
|
|
{
|
|
|
|
read_bestfit_file( $filename );
|
2007-05-29 23:31:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-26 17:28:15 +02:00
|
|
|
read_codepage_file( $filename );
|
2013-08-19 18:59:40 +02:00
|
|
|
if ($codepage == 10001)
|
|
|
|
{
|
|
|
|
# add Shift-JIS mappings
|
|
|
|
read_bestfit_file( "VENDORS/MICSFT/WindowsBestFit/bestfit932.txt" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
add_default_mappings( $first_private );
|
|
|
|
}
|
2007-05-29 23:31:14 +02:00
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2013-06-26 17:28:15 +02:00
|
|
|
output_codepage_file( $codepage, $filename, $comment, $has_glyphs );
|
2005-11-17 12:43:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# save a file if modified
|
|
|
|
sub save_file($)
|
|
|
|
{
|
|
|
|
my $file = shift;
|
2008-04-08 12:19:27 +02:00
|
|
|
if (-f $file && !system "cmp $file $file.new >/dev/null")
|
2005-11-17 12:43:10 +01:00
|
|
|
{
|
|
|
|
unlink "$file.new";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rename "$file.new", "$file";
|
|
|
|
}
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# output the list of codepage tables into the cptable.c file
|
2011-07-07 15:05:52 +02:00
|
|
|
sub output_cptable($)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2011-07-07 15:05:52 +02:00
|
|
|
my $output = shift;
|
2009-01-19 19:51:19 +01:00
|
|
|
my @tables_decl = ();
|
2000-06-09 07:27:21 +02:00
|
|
|
|
2011-07-07 15:05:52 +02:00
|
|
|
printf "Building %s\n", $output;
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $file (@allfiles)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-08-19 18:59:40 +02:00
|
|
|
my ($codepage,$filename) = @$file;
|
2000-06-09 07:27:21 +02:00
|
|
|
push @tables_decl, sprintf("extern union cptable cptable_%03d;\n",$codepage);
|
|
|
|
}
|
|
|
|
|
|
|
|
push @tables_decl, sprintf("\nstatic const union cptable * const cptables[%d] =\n{\n",$#allfiles+1);
|
2009-01-19 19:51:19 +01:00
|
|
|
foreach my $file (@allfiles)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
2013-08-19 18:59:40 +02:00
|
|
|
my ($codepage,$filename) = @$file;
|
2000-06-09 07:27:21 +02:00
|
|
|
push @tables_decl, sprintf(" &cptable_%03d,\n", $codepage);
|
|
|
|
}
|
|
|
|
push @tables_decl, "};";
|
2011-07-07 15:05:52 +02:00
|
|
|
REPLACE_IN_FILE( $output, @tables_decl );
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################
|
|
|
|
# replace the contents of a file between ### cpmap ### marks
|
|
|
|
|
2009-01-19 19:51:19 +01:00
|
|
|
sub REPLACE_IN_FILE($@)
|
2000-06-09 07:27:21 +02:00
|
|
|
{
|
|
|
|
my $name = shift;
|
|
|
|
my @data = @_;
|
|
|
|
my @lines = ();
|
|
|
|
open(FILE,$name) or die "Can't open $name";
|
|
|
|
while (<FILE>)
|
|
|
|
{
|
|
|
|
push @lines, $_;
|
|
|
|
last if /\#\#\# cpmap begin \#\#\#/;
|
|
|
|
}
|
|
|
|
push @lines, @data;
|
|
|
|
while (<FILE>)
|
|
|
|
{
|
|
|
|
if (/\#\#\# cpmap end \#\#\#/) { push @lines, "\n", $_; last; }
|
|
|
|
}
|
|
|
|
push @lines, <FILE>;
|
2005-11-17 12:43:10 +01:00
|
|
|
open(FILE,">$name.new") or die "Can't modify $name";
|
2000-06-09 07:27:21 +02:00
|
|
|
print FILE @lines;
|
|
|
|
close(FILE);
|
2005-11-17 12:43:10 +01:00
|
|
|
save_file($name);
|
2000-06-09 07:27:21 +02:00
|
|
|
}
|
2009-01-19 19:51:19 +01:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# main routine
|
|
|
|
|
2011-07-07 15:05:52 +02:00
|
|
|
chdir ".." if -f "./make_unicode";
|
2009-01-19 19:51:19 +01:00
|
|
|
READ_DEFAULTS( $DEFAULTS );
|
2019-03-24 10:21:57 +01:00
|
|
|
dump_case_mappings( "libs/port/casemap.c" );
|
2020-01-23 17:26:45 +01:00
|
|
|
dump_sortkeys( "libs/port/collation.c" );
|
|
|
|
dump_sortkeys( "dlls/kernelbase/collation.c" );
|
2016-02-19 03:43:35 +01:00
|
|
|
dump_compose_table( "libs/port/compose.c" );
|
2019-12-05 21:40:48 +01:00
|
|
|
dump_compose_table( "dlls/kernelbase/compose.c" );
|
2019-12-05 11:22:19 +01:00
|
|
|
dump_decompose_table( "libs/port/decompose.c", 1 );
|
|
|
|
dump_decompose_table( "dlls/kernelbase/decompose.c", 0 );
|
2019-03-23 13:35:33 +01:00
|
|
|
dump_ctype_tables( "libs/port/wctype.c" );
|
2019-05-22 17:11:39 +02:00
|
|
|
dump_bidi_dir_table( "dlls/gdi32/direction.c" );
|
2019-05-22 15:37:29 +02:00
|
|
|
dump_bidi_dir_table( "dlls/usp10/direction.c" );
|
2019-05-22 17:06:34 +02:00
|
|
|
dump_bidi_dir_table( "dlls/dwrite/direction.c" );
|
2019-12-07 20:29:27 +01:00
|
|
|
dump_string_type_table( "dlls/kernelbase/wctype.c" );
|
2019-11-28 09:05:13 +01:00
|
|
|
dump_digit_folding( "libs/port/digitmap.c", 1 );
|
|
|
|
dump_digit_folding( "dlls/kernelbase/digitmap.c", 0 );
|
2019-02-08 11:41:24 +01:00
|
|
|
dump_combining_class( "libs/port/combclass.c" );
|
2011-07-07 15:05:52 +02:00
|
|
|
dump_mirroring( "dlls/usp10/mirror.c" );
|
2014-10-05 15:16:49 +02:00
|
|
|
dump_mirroring( "dlls/dwrite/mirror.c" );
|
2014-06-30 16:01:33 +02:00
|
|
|
dump_bracket( "dlls/usp10/bracket.c" );
|
2014-09-30 07:56:39 +02:00
|
|
|
dump_bracket( "dlls/dwrite/bracket.c" );
|
2011-07-07 15:05:52 +02:00
|
|
|
dump_shaping( "dlls/usp10/shaping.c" );
|
|
|
|
dump_linebreak( "dlls/usp10/linebreak.c" );
|
2014-09-04 20:35:40 +02:00
|
|
|
dump_linebreak( "dlls/dwrite/linebreak.c" );
|
2014-09-23 14:35:04 +02:00
|
|
|
dump_scripts( "dlls/dwrite/scripts" );
|
2011-07-07 15:05:52 +02:00
|
|
|
dump_indic( "dlls/usp10/indicsyllable.c" );
|
2013-10-07 12:07:04 +02:00
|
|
|
dump_intl_nls("loader/l_intl.nls");
|
2013-11-15 17:37:24 +01:00
|
|
|
dump_vertical( "dlls/gdi32/vertical.c" );
|
|
|
|
dump_vertical( "dlls/wineps.drv/vertical.c" );
|
2012-04-25 17:56:33 +02:00
|
|
|
dump_nameprep( "dlls/kernel32/nameprep.c" );
|
2009-01-19 19:51:19 +01:00
|
|
|
|
|
|
|
foreach my $file (@allfiles) { HANDLE_FILE( @{$file} ); }
|
|
|
|
|
2016-02-18 06:33:10 +01:00
|
|
|
output_cptable("libs/port/cptable.c");
|
2009-01-19 19:51:19 +01:00
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
# Local Variables:
|
2011-07-07 15:05:52 +02:00
|
|
|
# compile-command: "./make_unicode"
|
2009-01-19 19:51:19 +01:00
|
|
|
# End:
|