diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 42eedf9b5d4..f55acab881a 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -432,88 +432,6 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file ) } -static USHORT *build_cptable( const union cptable *src, SIZE_T *size ) -{ - unsigned int i, leadbytes = 0; - USHORT *data, *ptr; - - *size = 13 + 1 + 256 + 1 + 1 + 1; - if (src->info.char_size == 2) - { - for (i = leadbytes = 0; i < 256; i++) if (src->dbcs.cp2uni_leadbytes[i]) leadbytes++; - *size += 256 + 256 * leadbytes; - *size += 65536; - *size *= sizeof(USHORT); - } - else - { - if (src->sbcs.cp2uni_glyphs != src->sbcs.cp2uni) *size += 256; - *size *= sizeof(USHORT); - *size += 65536; - } - if (!(data = RtlAllocateHeap( GetProcessHeap(), 0, *size ))) return NULL; - ptr = data; - ptr[0] = 0x0d; - ptr[1] = src->info.codepage; - ptr[2] = src->info.char_size; - ptr[3] = (src->info.def_char & 0xff00 ? - RtlUshortByteSwap( src->info.def_char ) : src->info.def_char); - ptr[4] = src->info.def_unicode_char; - - if (src->info.char_size == 2) - { - USHORT off = src->dbcs.cp2uni_leadbytes[src->info.def_char >> 8] * 256; - ptr[5] = src->dbcs.cp2uni[off + (src->info.def_char & 0xff)]; - - ptr[6] = src->dbcs.uni2cp_low[src->dbcs.uni2cp_high[src->info.def_unicode_char >> 8] - + (src->info.def_unicode_char & 0xff)]; - - ptr += 7; - memcpy( ptr, src->dbcs.lead_bytes, 12 ); - ptr += 6; - *ptr++ = 256 + 3 + (leadbytes + 1) * 256; - for (i = 0; i < 256; i++) *ptr++ = (src->dbcs.cp2uni_leadbytes[i] ? 0 : src->dbcs.cp2uni[i]); - *ptr++ = 0; - for (i = 0; i < 12; i++) if (!src->dbcs.lead_bytes[i]) break; - *ptr++ = i / 2; - for (i = 0; i < 256; i++) *ptr++ = 256 * src->dbcs.cp2uni_leadbytes[i]; - for (i = 0; i < leadbytes; i++, ptr += 256) - memcpy( ptr, src->dbcs.cp2uni + 256 * (i + 1), 256 * sizeof(USHORT) ); - *ptr++ = 4; - for (i = 0; i < 65536; i++) - ptr[i] = src->dbcs.uni2cp_low[src->dbcs.uni2cp_high[i >> 8] + (i & 0xff)]; - } - else - { - char *uni2cp; - - ptr[5] = src->sbcs.cp2uni[src->info.def_char]; - ptr[6] = src->sbcs.uni2cp_low[src->sbcs.uni2cp_high[src->info.def_unicode_char >> 8] - + (src->info.def_unicode_char & 0xff)]; - - ptr += 7; - memset( ptr, 0, 12 ); - ptr += 6; - *ptr++ = 256 + 3 + (src->sbcs.cp2uni_glyphs != src->sbcs.cp2uni ? 256 : 0); - memcpy( ptr, src->sbcs.cp2uni, 256 * sizeof(USHORT) ); - ptr += 256; - if (src->sbcs.cp2uni_glyphs != src->sbcs.cp2uni) - { - *ptr++ = 256; - memcpy( ptr, src->sbcs.cp2uni_glyphs, 256 * sizeof(USHORT) ); - ptr += 256; - } - else *ptr++ = 0; - *ptr++ = 0; - *ptr++ = 0; - uni2cp = (char *)ptr; - for (i = 0; i < 65536; i++) - uni2cp[i] = src->sbcs.uni2cp_low[src->sbcs.uni2cp_high[i >> 8] + (i & 0xff)]; - } - return data; -} - - #if !defined(__APPLE__) && !defined(__ANDROID__) /* these platforms always use UTF-8 */ /* charset to codepage map, sorted by name */ @@ -896,16 +814,7 @@ NTSTATUS WINAPI NtGetNlsSectionPtr( ULONG type, ULONG id, void *unknown, void ** HANDLE file; NTSTATUS status; - if ((status = open_nls_data_file( type, id, &file ))) - { - /* FIXME: special case for codepage table, generate it from the libwine data */ - if (type == NLS_SECTION_CODEPAGE) - { - const union cptable *table = wine_cp_get_table( id ); - if (table && (*ptr = build_cptable( table, size ))) return STATUS_SUCCESS; - } - return status; - } + if ((status = open_nls_data_file( type, id, &file ))) return status; if ((status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileEndOfFileInformation ))) goto done; diff --git a/loader/wine.inf.in b/loader/wine.inf.in index 188737547b8..17f2065e2ae 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -3854,6 +3854,71 @@ winebus.inf winehid.inf [NlsFiles] +c_037.nls +c_10000.nls +c_10001.nls +c_10002.nls +c_10003.nls +c_10004.nls +c_10005.nls +c_10006.nls +c_10007.nls +c_10008.nls +c_10010.nls +c_10017.nls +c_10021.nls +c_10029.nls +c_10079.nls +c_10081.nls +c_10082.nls +c_1026.nls +c_1250.nls +c_1251.nls +c_1252.nls +c_1253.nls +c_1254.nls +c_1255.nls +c_1256.nls +c_1257.nls +c_1258.nls +c_1361.nls +c_20127.nls +c_20866.nls +c_20932.nls +c_21866.nls +c_28591.nls +c_28592.nls +c_28593.nls +c_28594.nls +c_28595.nls +c_28596.nls +c_28597.nls +c_28598.nls +c_28599.nls +c_28603.nls +c_28605.nls +c_437.nls +c_500.nls +c_737.nls +c_775.nls +c_850.nls +c_852.nls +c_855.nls +c_857.nls +c_860.nls +c_861.nls +c_862.nls +c_863.nls +c_864.nls +c_865.nls +c_866.nls +c_869.nls +c_874.nls +c_875.nls +c_932.nls +c_936.nls +c_949.nls +c_950.nls l_intl.nls [WineSourceDirs] diff --git a/nls/Makefile.in b/nls/Makefile.in index dc9893030ad..aa20e9bffbd 100644 --- a/nls/Makefile.in +++ b/nls/Makefile.in @@ -1,2 +1,67 @@ SOURCES = \ + c_037.nls \ + c_10000.nls \ + c_10001.nls \ + c_10002.nls \ + c_10003.nls \ + c_10004.nls \ + c_10005.nls \ + c_10006.nls \ + c_10007.nls \ + c_10008.nls \ + c_10010.nls \ + c_10017.nls \ + c_10021.nls \ + c_10029.nls \ + c_10079.nls \ + c_10081.nls \ + c_10082.nls \ + c_1026.nls \ + c_1250.nls \ + c_1251.nls \ + c_1252.nls \ + c_1253.nls \ + c_1254.nls \ + c_1255.nls \ + c_1256.nls \ + c_1257.nls \ + c_1258.nls \ + c_1361.nls \ + c_20127.nls \ + c_20866.nls \ + c_20932.nls \ + c_21866.nls \ + c_28591.nls \ + c_28592.nls \ + c_28593.nls \ + c_28594.nls \ + c_28595.nls \ + c_28596.nls \ + c_28597.nls \ + c_28598.nls \ + c_28599.nls \ + c_28603.nls \ + c_28605.nls \ + c_437.nls \ + c_500.nls \ + c_737.nls \ + c_775.nls \ + c_850.nls \ + c_852.nls \ + c_855.nls \ + c_857.nls \ + c_860.nls \ + c_861.nls \ + c_862.nls \ + c_863.nls \ + c_864.nls \ + c_865.nls \ + c_866.nls \ + c_869.nls \ + c_874.nls \ + c_875.nls \ + c_932.nls \ + c_936.nls \ + c_949.nls \ + c_950.nls \ l_intl.nls diff --git a/nls/c_037.nls b/nls/c_037.nls new file mode 100644 index 00000000000..887000624ad Binary files /dev/null and b/nls/c_037.nls differ diff --git a/nls/c_10000.nls b/nls/c_10000.nls new file mode 100644 index 00000000000..80f8055857a Binary files /dev/null and b/nls/c_10000.nls differ diff --git a/nls/c_10001.nls b/nls/c_10001.nls new file mode 100644 index 00000000000..9ca745d03cf Binary files /dev/null and b/nls/c_10001.nls differ diff --git a/nls/c_10002.nls b/nls/c_10002.nls new file mode 100644 index 00000000000..1633fe7696a Binary files /dev/null and b/nls/c_10002.nls differ diff --git a/nls/c_10003.nls b/nls/c_10003.nls new file mode 100644 index 00000000000..5ebfefcee5f Binary files /dev/null and b/nls/c_10003.nls differ diff --git a/nls/c_10004.nls b/nls/c_10004.nls new file mode 100644 index 00000000000..ffe7025be6f Binary files /dev/null and b/nls/c_10004.nls differ diff --git a/nls/c_10005.nls b/nls/c_10005.nls new file mode 100644 index 00000000000..c117e2ac078 Binary files /dev/null and b/nls/c_10005.nls differ diff --git a/nls/c_10006.nls b/nls/c_10006.nls new file mode 100644 index 00000000000..a4ddba7a11f Binary files /dev/null and b/nls/c_10006.nls differ diff --git a/nls/c_10007.nls b/nls/c_10007.nls new file mode 100644 index 00000000000..90b87d5b9f0 Binary files /dev/null and b/nls/c_10007.nls differ diff --git a/nls/c_10008.nls b/nls/c_10008.nls new file mode 100644 index 00000000000..0d95ea20fb2 Binary files /dev/null and b/nls/c_10008.nls differ diff --git a/nls/c_10010.nls b/nls/c_10010.nls new file mode 100644 index 00000000000..d8f58efac41 Binary files /dev/null and b/nls/c_10010.nls differ diff --git a/nls/c_10017.nls b/nls/c_10017.nls new file mode 100644 index 00000000000..b2f087072b2 Binary files /dev/null and b/nls/c_10017.nls differ diff --git a/nls/c_10021.nls b/nls/c_10021.nls new file mode 100644 index 00000000000..ecb8a160014 Binary files /dev/null and b/nls/c_10021.nls differ diff --git a/nls/c_10029.nls b/nls/c_10029.nls new file mode 100644 index 00000000000..1ad1d57709b Binary files /dev/null and b/nls/c_10029.nls differ diff --git a/nls/c_10079.nls b/nls/c_10079.nls new file mode 100644 index 00000000000..fd030adb388 Binary files /dev/null and b/nls/c_10079.nls differ diff --git a/nls/c_10081.nls b/nls/c_10081.nls new file mode 100644 index 00000000000..61f1b370086 Binary files /dev/null and b/nls/c_10081.nls differ diff --git a/nls/c_10082.nls b/nls/c_10082.nls new file mode 100644 index 00000000000..3c3b107609b Binary files /dev/null and b/nls/c_10082.nls differ diff --git a/nls/c_1026.nls b/nls/c_1026.nls new file mode 100644 index 00000000000..a6997dd84b5 Binary files /dev/null and b/nls/c_1026.nls differ diff --git a/nls/c_1250.nls b/nls/c_1250.nls new file mode 100644 index 00000000000..d4e2ecb7764 Binary files /dev/null and b/nls/c_1250.nls differ diff --git a/nls/c_1251.nls b/nls/c_1251.nls new file mode 100644 index 00000000000..ed674d95e4b Binary files /dev/null and b/nls/c_1251.nls differ diff --git a/nls/c_1252.nls b/nls/c_1252.nls new file mode 100644 index 00000000000..92ac1b239c3 Binary files /dev/null and b/nls/c_1252.nls differ diff --git a/nls/c_1253.nls b/nls/c_1253.nls new file mode 100644 index 00000000000..5863c7262da Binary files /dev/null and b/nls/c_1253.nls differ diff --git a/nls/c_1254.nls b/nls/c_1254.nls new file mode 100644 index 00000000000..b66107971b8 Binary files /dev/null and b/nls/c_1254.nls differ diff --git a/nls/c_1255.nls b/nls/c_1255.nls new file mode 100644 index 00000000000..819a6b7fef2 Binary files /dev/null and b/nls/c_1255.nls differ diff --git a/nls/c_1256.nls b/nls/c_1256.nls new file mode 100644 index 00000000000..ca7c1cd2827 Binary files /dev/null and b/nls/c_1256.nls differ diff --git a/nls/c_1257.nls b/nls/c_1257.nls new file mode 100644 index 00000000000..da30785167e Binary files /dev/null and b/nls/c_1257.nls differ diff --git a/nls/c_1258.nls b/nls/c_1258.nls new file mode 100644 index 00000000000..5f144909372 Binary files /dev/null and b/nls/c_1258.nls differ diff --git a/nls/c_1361.nls b/nls/c_1361.nls new file mode 100644 index 00000000000..5242021165f Binary files /dev/null and b/nls/c_1361.nls differ diff --git a/nls/c_20127.nls b/nls/c_20127.nls new file mode 100644 index 00000000000..1317a7187a4 Binary files /dev/null and b/nls/c_20127.nls differ diff --git a/nls/c_20866.nls b/nls/c_20866.nls new file mode 100644 index 00000000000..c39a88ab081 Binary files /dev/null and b/nls/c_20866.nls differ diff --git a/nls/c_20932.nls b/nls/c_20932.nls new file mode 100644 index 00000000000..908adc0f25c Binary files /dev/null and b/nls/c_20932.nls differ diff --git a/nls/c_21866.nls b/nls/c_21866.nls new file mode 100644 index 00000000000..ba2d77614cf Binary files /dev/null and b/nls/c_21866.nls differ diff --git a/nls/c_28591.nls b/nls/c_28591.nls new file mode 100644 index 00000000000..2f8fd2d0774 Binary files /dev/null and b/nls/c_28591.nls differ diff --git a/nls/c_28592.nls b/nls/c_28592.nls new file mode 100644 index 00000000000..683d8387ba7 Binary files /dev/null and b/nls/c_28592.nls differ diff --git a/nls/c_28593.nls b/nls/c_28593.nls new file mode 100644 index 00000000000..2c81ca34a0c Binary files /dev/null and b/nls/c_28593.nls differ diff --git a/nls/c_28594.nls b/nls/c_28594.nls new file mode 100644 index 00000000000..c65db932ded Binary files /dev/null and b/nls/c_28594.nls differ diff --git a/nls/c_28595.nls b/nls/c_28595.nls new file mode 100644 index 00000000000..93d97efb794 Binary files /dev/null and b/nls/c_28595.nls differ diff --git a/nls/c_28596.nls b/nls/c_28596.nls new file mode 100644 index 00000000000..9c2a8fccbd8 Binary files /dev/null and b/nls/c_28596.nls differ diff --git a/nls/c_28597.nls b/nls/c_28597.nls new file mode 100644 index 00000000000..4454953ad8e Binary files /dev/null and b/nls/c_28597.nls differ diff --git a/nls/c_28598.nls b/nls/c_28598.nls new file mode 100644 index 00000000000..f86d90379ab Binary files /dev/null and b/nls/c_28598.nls differ diff --git a/nls/c_28599.nls b/nls/c_28599.nls new file mode 100644 index 00000000000..aea82b6fb6a Binary files /dev/null and b/nls/c_28599.nls differ diff --git a/nls/c_28603.nls b/nls/c_28603.nls new file mode 100644 index 00000000000..ec1b63109b9 Binary files /dev/null and b/nls/c_28603.nls differ diff --git a/nls/c_28605.nls b/nls/c_28605.nls new file mode 100644 index 00000000000..85dbcc0ecf4 Binary files /dev/null and b/nls/c_28605.nls differ diff --git a/nls/c_437.nls b/nls/c_437.nls new file mode 100644 index 00000000000..e3d5efd15ed Binary files /dev/null and b/nls/c_437.nls differ diff --git a/nls/c_500.nls b/nls/c_500.nls new file mode 100644 index 00000000000..82adf19b679 Binary files /dev/null and b/nls/c_500.nls differ diff --git a/nls/c_737.nls b/nls/c_737.nls new file mode 100644 index 00000000000..e44870b0968 Binary files /dev/null and b/nls/c_737.nls differ diff --git a/nls/c_775.nls b/nls/c_775.nls new file mode 100644 index 00000000000..b14f9ea5e63 Binary files /dev/null and b/nls/c_775.nls differ diff --git a/nls/c_850.nls b/nls/c_850.nls new file mode 100644 index 00000000000..7b8fcaee181 Binary files /dev/null and b/nls/c_850.nls differ diff --git a/nls/c_852.nls b/nls/c_852.nls new file mode 100644 index 00000000000..4c6cf7c4724 Binary files /dev/null and b/nls/c_852.nls differ diff --git a/nls/c_855.nls b/nls/c_855.nls new file mode 100644 index 00000000000..7048fab4abc Binary files /dev/null and b/nls/c_855.nls differ diff --git a/nls/c_857.nls b/nls/c_857.nls new file mode 100644 index 00000000000..3dace9bb75f Binary files /dev/null and b/nls/c_857.nls differ diff --git a/nls/c_860.nls b/nls/c_860.nls new file mode 100644 index 00000000000..75e5c16e239 Binary files /dev/null and b/nls/c_860.nls differ diff --git a/nls/c_861.nls b/nls/c_861.nls new file mode 100644 index 00000000000..9531420ed68 Binary files /dev/null and b/nls/c_861.nls differ diff --git a/nls/c_862.nls b/nls/c_862.nls new file mode 100644 index 00000000000..40d3d1d8086 Binary files /dev/null and b/nls/c_862.nls differ diff --git a/nls/c_863.nls b/nls/c_863.nls new file mode 100644 index 00000000000..e63f0f07c96 Binary files /dev/null and b/nls/c_863.nls differ diff --git a/nls/c_864.nls b/nls/c_864.nls new file mode 100644 index 00000000000..0ac4fc01c60 Binary files /dev/null and b/nls/c_864.nls differ diff --git a/nls/c_865.nls b/nls/c_865.nls new file mode 100644 index 00000000000..864477a7324 Binary files /dev/null and b/nls/c_865.nls differ diff --git a/nls/c_866.nls b/nls/c_866.nls new file mode 100644 index 00000000000..5c883256cdc Binary files /dev/null and b/nls/c_866.nls differ diff --git a/nls/c_869.nls b/nls/c_869.nls new file mode 100644 index 00000000000..4c74c8e98d4 Binary files /dev/null and b/nls/c_869.nls differ diff --git a/nls/c_874.nls b/nls/c_874.nls new file mode 100644 index 00000000000..c27d8c75ff4 Binary files /dev/null and b/nls/c_874.nls differ diff --git a/nls/c_875.nls b/nls/c_875.nls new file mode 100644 index 00000000000..d99cfb11de0 Binary files /dev/null and b/nls/c_875.nls differ diff --git a/nls/c_932.nls b/nls/c_932.nls new file mode 100644 index 00000000000..44ce6cefb6f Binary files /dev/null and b/nls/c_932.nls differ diff --git a/nls/c_936.nls b/nls/c_936.nls new file mode 100644 index 00000000000..ecbacb15eec Binary files /dev/null and b/nls/c_936.nls differ diff --git a/nls/c_949.nls b/nls/c_949.nls new file mode 100644 index 00000000000..f3dd71c8502 Binary files /dev/null and b/nls/c_949.nls differ diff --git a/nls/c_950.nls b/nls/c_950.nls new file mode 100644 index 00000000000..33a016566fe Binary files /dev/null and b/nls/c_950.nls differ diff --git a/tools/make_makefiles b/tools/make_makefiles index b96fc4f387b..a788c00a93b 100755 --- a/tools/make_makefiles +++ b/tools/make_makefiles @@ -487,10 +487,17 @@ sub update_makefiles(@) sub update_wine_inf() { - my @lines; - - push @lines, "[NlsFiles]", @nls_files, "\n"; + my @lines = ("[NlsFiles]", @nls_files, "\n" ); replace_in_file "loader/wine.inf.in", '^\[NlsFiles\]', '^$', join( "\n", @lines ); + + my @codepages = grep /c_\d+\.nls/, @nls_files; + @lines = ( "[Nls]" ); + foreach my $cp (sort { $a <=> $b; } map { /c_(\d+)\.nls/ && $1; } @codepages) + { + push @lines, sprintf "HKLM,System\\CurrentControlSet\\Control\\Nls\\Codepage,\"%u\",,\"c_%03u.nls\"", $cp, $cp; + } + push @lines, "\n"; + replace_in_file "loader/wine.inf.in", '^\[Nls\]', '^$', join( "\n", @lines ); } my $git_dir = $ENV{GIT_DIR} || ".git"; diff --git a/tools/make_unicode b/tools/make_unicode index bd6126e2561..c55ec5f3d7e 100755 --- a/tools/make_unicode +++ b/tools/make_unicode @@ -1054,14 +1054,76 @@ sub dump_dbcs_table($$$$@) } +################################################################ +# dump an SBCS mapping table in binary format +sub dump_binary_sbcs_table($) +{ + my $codepage = shift; + + my @header = ( 13, $codepage, 1, $default_char, $default_wchar, $cp2uni[$default_char], $uni2cp[$default_wchar] ); + my $wc_offset = 256 + 3 + (@glyph2uni ? 256 : 0); + + print OUTPUT pack "S<*", @header; + print OUTPUT pack "C12", (0) x 12; + print OUTPUT pack "S<*", $wc_offset, map { $_ || 0; } @cp2uni[0 .. 255]; + + if (@glyph2uni) + { + print OUTPUT pack "S<*", 256, get_glyphs_mapping(@cp2uni[0 .. 255]); + } + else + { + print OUTPUT pack "S<*", 0; + } + + print OUTPUT pack "S<*", 0, 0; + + print OUTPUT pack "C*", map { defined $_ ? $_ : $default_char; } @uni2cp[0 .. 65535]; +} + + +################################################################ +# dump a DBCS mapping table in binary format +sub dump_binary_dbcs_table($) +{ + my $codepage = shift; + my @lb_ranges = get_lb_ranges(); + my @header = ( 13, $codepage, 2, $default_char, $default_wchar, $cp2uni[$default_char], $uni2cp[$default_wchar] ); + + my @offsets = (0) x 256; + my $pos = 0; + foreach my $i (@lead_bytes) + { + $offsets[$i] = ($pos += 256); + $cp2uni[$i] = 0; + } + + my $wc_offset = 256 + 3 + 256 * (1 + scalar @lead_bytes); + + print OUTPUT pack "S<*", @header; + print OUTPUT pack "C12", @lb_ranges, 0 x 12; + print OUTPUT pack "S<*", $wc_offset, map { $_ || 0; } @cp2uni[0 .. 255]; + print OUTPUT pack "S<*", 0, scalar @lb_ranges / 2, @offsets; + + foreach my $i (@lead_bytes) + { + my $base = $i << 8; + print OUTPUT pack "S<*", map { defined $_ ? $_ : $default_wchar; } @cp2uni[$base .. $base + 255]; + } + + print OUTPUT pack "S<", 4; + print OUTPUT pack "S<*", map { defined $_ ? $_ : $default_char; } @uni2cp[0 .. 65535]; +} + + ################################################################ # get the list of defined lead byte ranges sub get_lb_ranges() { my @list = (); my @ranges = (); - my $i = 0; - foreach $i (@lead_bytes) { $list[$i] = 1; } + + foreach my $i (@lead_bytes) { $list[$i] = 1; } my $on = 0; for (my $i = 0; $i < 256; $i++) { @@ -2350,6 +2412,18 @@ sub output_codepage_file($$$) else { dump_dbcs_table( $codepage, $comment, $default_char, $default_wchar, get_lb_ranges() ); } close OUTPUT; save_file($output); + + # same thing in binary format + + $output = sprintf "nls/c_%03d.nls", $codepage; + open OUTPUT,">$output.new" or die "Cannot create $output"; + + printf "Building %s\n", $output; + if (!@lead_bytes) { dump_binary_sbcs_table( $codepage ); } + else { dump_binary_dbcs_table( $codepage ); } + + close OUTPUT; + save_file($output); } ################################################################