make_unicode: Add a wctype table in kernel32 for GetStringTypeW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alexandre Julliard 2019-05-22 10:31:55 +02:00
parent 4a6e69ad3a
commit f09dade9cb
4 changed files with 2201 additions and 8 deletions

View File

@ -43,6 +43,7 @@ C_SRCS = \
version.c \
virtual.c \
volume.c \
wctype.c \
wer.c
RC_SRCS = \

View File

@ -281,6 +281,14 @@ static inline unsigned short get_table_entry( const unsigned short *table, WCHAR
return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
}
/* the character type contains the C1_* flags in the low 12 bits */
/* and the C2_* type in the high 4 bits */
static inline unsigned short get_wctype( WCHAR ch )
{
extern const unsigned short wctype_table[];
return wctype_table[wctype_table[ch >> 8] + (ch & 0xff)];
}
/***********************************************************************
* get_lcid_codepage
*
@ -3089,10 +3097,10 @@ BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype
switch(type)
{
case CT_CTYPE1:
while (count--) *chartype++ = get_char_typeW( *src++ ) & 0xfff;
while (count--) *chartype++ = get_wctype( *src++ ) & 0xfff;
break;
case CT_CTYPE2:
while (count--) *chartype++ = type2_map[get_char_typeW( *src++ ) >> 12];
while (count--) *chartype++ = type2_map[get_wctype( *src++ ) >> 12];
break;
case CT_CTYPE3:
{
@ -3102,7 +3110,7 @@ BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype
int c = *src;
WORD type1, type3 = 0; /* C3_NOTAPPLICABLE */
type1 = get_char_typeW( *src++ ) & 0xfff;
type1 = get_wctype( *src++ ) & 0xfff;
/* try to construct type3 from type1 */
if(type1 & C1_SPACE) type3 |= C3_SYMBOL;
if(type1 & C1_ALPHA) type3 |= C3_ALPHA;
@ -3539,7 +3547,7 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
* and skips white space and punctuation characters for
* NORM_IGNORESYMBOLS.
*/
if (get_char_typeW(wch) & (C1_PUNCT | C1_SPACE))
if (get_wctype(wch) & (C1_PUNCT | C1_SPACE))
continue;
len++;
}
@ -3585,7 +3593,7 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
for (len = dstlen, dst_ptr = dst; srclen && len; src++, srclen--)
{
WCHAR wch = *src;
if ((flags & NORM_IGNORESYMBOLS) && (get_char_typeW(wch) & (C1_PUNCT | C1_SPACE)))
if ((flags & NORM_IGNORESYMBOLS) && (get_wctype(wch) & (C1_PUNCT | C1_SPACE)))
continue;
*dst_ptr++ = wch;
len--;

File diff suppressed because it is too large Load Diff

View File

@ -440,7 +440,7 @@ sub READ_DEFAULTS($)
die "unknown directionality $bidi" unless defined $directions{$bidi};
$category_table[$src] = $categories{$cat};
$direction_table[$src] = $directions{$bidi};
$direction_table[$src] = $bidi;
$joining_table[$src] = $joining_types{"T"} if $cat eq "Mn" || $cat eq "Me" || $cat eq "Cf";
if ($lower ne "")
@ -2177,6 +2177,33 @@ sub dump_nameprep($)
save_file($filename);
}
################################################################
# 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++)
{
$table[$i] |= $directions{$direction_table[$i]} << 12 if defined $direction_table[$i];
}
dump_simple_mapping( "DECLSPEC_HIDDEN wctype_table", 0, @table );
close OUTPUT;
save_file($filename);
}
################################################################
# dump the ctype tables
sub dump_ctype_tables($)
@ -2188,13 +2215,15 @@ sub dump_ctype_tables($)
printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
printf OUTPUT "#include \"wine/unicode.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++)
{
$category_table[$i] |= $direction_table[$i] << 12 if defined $direction_table[$i];
$table[$i] |= $directions{$direction_table[$i]} << 12 if defined $direction_table[$i];
}
dump_simple_mapping( "wine_wctype_table", 0, @category_table );
dump_simple_mapping( "wine_wctype_table", 0, @table );
close OUTPUT;
save_file($filename);
@ -2772,6 +2801,7 @@ dump_sortkeys( "libs/port/collation.c", READ_SORTKEYS_FILE() );
dump_compose_table( "libs/port/compose.c" );
dump_decompose_table( "libs/port/decompose.c" );
dump_ctype_tables( "libs/port/wctype.c" );
dump_string_type_table( "dlls/kernel32/wctype.c" );
dump_digit_folding( "libs/port/digitmap.c" );
dump_combining_class( "libs/port/combclass.c" );
dump_mirroring( "dlls/usp10/mirror.c" );