kernel32: Move GetStringType functions to kernelbase.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c123637b2d
commit
1b46da5c05
|
@ -39,7 +39,6 @@ C_SRCS = \
|
|||
version.c \
|
||||
virtual.c \
|
||||
volume.c \
|
||||
wctype.c \
|
||||
wer.c
|
||||
|
||||
RC_SRCS = \
|
||||
|
|
|
@ -814,10 +814,10 @@
|
|||
@ stdcall -import GetStartupInfoW(ptr)
|
||||
@ stdcall -import GetStdHandle(long)
|
||||
# @ stub GetStringScripts
|
||||
@ stdcall GetStringTypeA(long long str long ptr)
|
||||
@ stdcall -import GetStringTypeA(long long str long ptr)
|
||||
@ stdcall GetStringTypeExA(long long str long ptr)
|
||||
@ stdcall GetStringTypeExW(long long wstr long ptr)
|
||||
@ stdcall GetStringTypeW(long wstr long ptr)
|
||||
@ stdcall -import GetStringTypeExW(long long wstr long ptr)
|
||||
@ stdcall -import GetStringTypeW(long wstr long ptr)
|
||||
@ stdcall -import GetSystemFileCacheSize(ptr ptr ptr)
|
||||
@ stdcall -import GetSystemDefaultLCID()
|
||||
@ stdcall -import GetSystemDefaultLangID()
|
||||
|
|
|
@ -62,7 +62,6 @@ extern BOOL WINAPI Internal_EnumTimeFormats( TIMEFMT_ENUMPROCW proc, LCID lcid,
|
|||
extern BOOL WINAPI Internal_EnumUILanguages( UILANGUAGE_ENUMPROCW proc, DWORD flags,
|
||||
LONG_PTR param, BOOL unicode );
|
||||
|
||||
extern const unsigned short wctype_table[] DECLSPEC_HIDDEN;
|
||||
extern const unsigned short nameprep_char_type[] DECLSPEC_HIDDEN;
|
||||
extern const WCHAR nameprep_mapping[] DECLSPEC_HIDDEN;
|
||||
|
||||
|
@ -357,135 +356,6 @@ BOOL WINAPI EnumSystemCodePagesA( CODEPAGE_ENUMPROCA proc, DWORD flags )
|
|||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GetStringTypeW (KERNEL32.@)
|
||||
*
|
||||
* See GetStringTypeA.
|
||||
*/
|
||||
BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype )
|
||||
{
|
||||
if (!src)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (count == -1) count = strlenW(src) + 1;
|
||||
switch(type)
|
||||
{
|
||||
case CT_CTYPE1:
|
||||
while (count--) *chartype++ = get_table_entry( wctype_table, *src++ ) & 0xfff;
|
||||
break;
|
||||
case CT_CTYPE2:
|
||||
while (count--) *chartype++ = get_table_entry( wctype_table, *src++ ) >> 12;
|
||||
break;
|
||||
case CT_CTYPE3:
|
||||
{
|
||||
WARN("CT_CTYPE3: semi-stub.\n");
|
||||
while (count--)
|
||||
{
|
||||
int c = *src;
|
||||
WORD type1, type3 = 0; /* C3_NOTAPPLICABLE */
|
||||
|
||||
type1 = get_table_entry( wctype_table, *src++ ) & 0xfff;
|
||||
/* try to construct type3 from type1 */
|
||||
if(type1 & C1_SPACE) type3 |= C3_SYMBOL;
|
||||
if(type1 & C1_ALPHA) type3 |= C3_ALPHA;
|
||||
if ((c>=0x30A0)&&(c<=0x30FF)) type3 |= C3_KATAKANA;
|
||||
if ((c>=0x3040)&&(c<=0x309F)) type3 |= C3_HIRAGANA;
|
||||
if ((c>=0x4E00)&&(c<=0x9FAF)) type3 |= C3_IDEOGRAPH;
|
||||
if (c == 0x0640) type3 |= C3_KASHIDA;
|
||||
if ((c>=0x3000)&&(c<=0x303F)) type3 |= C3_SYMBOL;
|
||||
|
||||
if ((c>=0xD800)&&(c<=0xDBFF)) type3 |= C3_HIGHSURROGATE;
|
||||
if ((c>=0xDC00)&&(c<=0xDFFF)) type3 |= C3_LOWSURROGATE;
|
||||
|
||||
if ((c>=0xFF00)&&(c<=0xFF60)) type3 |= C3_FULLWIDTH;
|
||||
if ((c>=0xFF00)&&(c<=0xFF20)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF3B)&&(c<=0xFF40)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF5B)&&(c<=0xFF60)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF21)&&(c<=0xFF3A)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFF41)&&(c<=0xFF5A)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_FULLWIDTH;
|
||||
if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_SYMBOL;
|
||||
|
||||
if ((c>=0xFF61)&&(c<=0xFFDC)) type3 |= C3_HALFWIDTH;
|
||||
if ((c>=0xFF61)&&(c<=0xFF64)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_KATAKANA;
|
||||
if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_HALFWIDTH;
|
||||
if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_SYMBOL;
|
||||
*chartype++ = type3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GetStringTypeExW (KERNEL32.@)
|
||||
*
|
||||
* See GetStringTypeExA.
|
||||
*/
|
||||
BOOL WINAPI GetStringTypeExW( LCID locale, DWORD type, LPCWSTR src, INT count, LPWORD chartype )
|
||||
{
|
||||
/* locale is ignored for Unicode */
|
||||
return GetStringTypeW( type, src, count, chartype );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GetStringTypeA (KERNEL32.@)
|
||||
*
|
||||
* Get characteristics of the characters making up a string.
|
||||
*
|
||||
* PARAMS
|
||||
* locale [I] Locale Id for the string
|
||||
* type [I] CT_CTYPE1 = classification, CT_CTYPE2 = directionality, CT_CTYPE3 = typographic info
|
||||
* src [I] String to analyse
|
||||
* count [I] Length of src in chars, or -1 if src is NUL terminated
|
||||
* chartype [O] Destination for the calculated characteristics
|
||||
*
|
||||
* RETURNS
|
||||
* Success: TRUE. chartype is filled with the requested characteristics of each char
|
||||
* in src.
|
||||
* Failure: FALSE. Use GetLastError() to determine the cause.
|
||||
*/
|
||||
BOOL WINAPI GetStringTypeA( LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype )
|
||||
{
|
||||
UINT cp;
|
||||
INT countW;
|
||||
LPWSTR srcW;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if(count == -1) count = strlen(src) + 1;
|
||||
|
||||
if (!(cp = get_lcid_codepage( locale )))
|
||||
{
|
||||
FIXME("For locale %04x using current ANSI code page\n", locale);
|
||||
cp = GetACP();
|
||||
}
|
||||
|
||||
countW = MultiByteToWideChar(cp, 0, src, count, NULL, 0);
|
||||
if((srcW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
|
||||
{
|
||||
MultiByteToWideChar(cp, 0, src, count, srcW, countW);
|
||||
/*
|
||||
* NOTE: the target buffer has 1 word for each CHARACTER in the source
|
||||
* string, with multibyte characters there maybe be more bytes in count
|
||||
* than character space in the buffer!
|
||||
*/
|
||||
ret = GetStringTypeW(type, srcW, countW, chartype);
|
||||
HeapFree(GetProcessHeap(), 0, srcW);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GetStringTypeExA (KERNEL32.@)
|
||||
*
|
||||
|
@ -819,12 +689,12 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
|
|||
{
|
||||
for (len = 0; srclen; src++, srclen--)
|
||||
{
|
||||
WCHAR wch = *src;
|
||||
WORD type;
|
||||
/* tests show that win2k just ignores NORM_IGNORENONSPACE,
|
||||
* and skips white space and punctuation characters for
|
||||
* NORM_IGNORESYMBOLS.
|
||||
*/
|
||||
if (get_table_entry( wctype_table, wch ) & (C1_PUNCT | C1_SPACE))
|
||||
if (GetStringTypeW( CT_CTYPE1, src, 1, &type ) && (type & (C1_PUNCT | C1_SPACE)))
|
||||
continue;
|
||||
len++;
|
||||
}
|
||||
|
@ -869,10 +739,11 @@ 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_table_entry( wctype_table, wch ) & (C1_PUNCT | C1_SPACE)))
|
||||
WORD type;
|
||||
if ((flags & NORM_IGNORESYMBOLS) && GetStringTypeW( CT_CTYPE1, src, 1, &type ) &&
|
||||
(type & (C1_PUNCT | C1_SPACE)))
|
||||
continue;
|
||||
*dst_ptr++ = wch;
|
||||
*dst_ptr++ = *src;
|
||||
len--;
|
||||
}
|
||||
goto done;
|
||||
|
|
|
@ -21,4 +21,5 @@ C_SRCS = \
|
|||
string.c \
|
||||
sync.c \
|
||||
thread.c \
|
||||
version.c
|
||||
version.c \
|
||||
wctype.c
|
||||
|
|
|
@ -674,9 +674,9 @@
|
|||
@ stdcall GetStdHandle(long)
|
||||
# @ stub GetStringScripts
|
||||
@ stub GetStringTableEntry
|
||||
@ stdcall GetStringTypeA(long long str long ptr) kernel32.GetStringTypeA
|
||||
@ stdcall GetStringTypeExW(long long wstr long ptr) kernel32.GetStringTypeExW
|
||||
@ stdcall GetStringTypeW(long wstr long ptr) kernel32.GetStringTypeW
|
||||
@ stdcall GetStringTypeA(long long str long ptr)
|
||||
@ stdcall GetStringTypeExW(long long wstr long ptr)
|
||||
@ stdcall GetStringTypeW(long wstr long ptr)
|
||||
# @ stub GetSystemAppDataFolder
|
||||
# @ stub GetSystemAppDataKey
|
||||
# @ stub GetSystemCpuSetInformation
|
||||
|
|
|
@ -45,6 +45,8 @@ extern UINT CDECL __wine_get_unix_codepage(void);
|
|||
extern unsigned int wine_decompose( int flags, WCHAR ch, WCHAR *dst, unsigned int dstlen ) DECLSPEC_HIDDEN;
|
||||
extern WCHAR wine_compose( const WCHAR *str ) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const unsigned short wctype_table[] DECLSPEC_HIDDEN;
|
||||
|
||||
static HANDLE kernel32_handle;
|
||||
|
||||
static const struct registry_value
|
||||
|
@ -329,6 +331,12 @@ void init_locale(void)
|
|||
}
|
||||
|
||||
|
||||
static inline USHORT get_table_entry( const USHORT *table, WCHAR ch )
|
||||
{
|
||||
return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
|
||||
}
|
||||
|
||||
|
||||
static UINT get_lcid_codepage( LCID lcid, ULONG flags )
|
||||
{
|
||||
UINT ret = GetACP();
|
||||
|
@ -2704,6 +2712,115 @@ UINT WINAPI GetOEMCP(void)
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetStringTypeA (kernelbase.@)
|
||||
*/
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH GetStringTypeA( LCID locale, DWORD type, const char *src, int count,
|
||||
WORD *chartype )
|
||||
{
|
||||
UINT cp;
|
||||
INT countW;
|
||||
LPWSTR srcW;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (count == -1) count = strlen(src) + 1;
|
||||
|
||||
cp = get_lcid_codepage( locale, 0 );
|
||||
countW = MultiByteToWideChar(cp, 0, src, count, NULL, 0);
|
||||
if((srcW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
|
||||
{
|
||||
MultiByteToWideChar(cp, 0, src, count, srcW, countW);
|
||||
/*
|
||||
* NOTE: the target buffer has 1 word for each CHARACTER in the source
|
||||
* string, with multibyte characters there maybe be more bytes in count
|
||||
* than character space in the buffer!
|
||||
*/
|
||||
ret = GetStringTypeW(type, srcW, countW, chartype);
|
||||
HeapFree(GetProcessHeap(), 0, srcW);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetStringTypeW (kernelbase.@)
|
||||
*/
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH GetStringTypeW( DWORD type, const WCHAR *src, INT count, WORD *chartype )
|
||||
{
|
||||
if (!src)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (count == -1) count = lstrlenW(src) + 1;
|
||||
switch (type)
|
||||
{
|
||||
case CT_CTYPE1:
|
||||
while (count--) *chartype++ = get_table_entry( wctype_table, *src++ ) & 0xfff;
|
||||
break;
|
||||
case CT_CTYPE2:
|
||||
while (count--) *chartype++ = get_table_entry( wctype_table, *src++ ) >> 12;
|
||||
break;
|
||||
case CT_CTYPE3:
|
||||
{
|
||||
WARN("CT_CTYPE3: semi-stub.\n");
|
||||
while (count--)
|
||||
{
|
||||
int c = *src;
|
||||
WORD type1, type3 = 0; /* C3_NOTAPPLICABLE */
|
||||
|
||||
type1 = get_table_entry( wctype_table, *src++ ) & 0xfff;
|
||||
/* try to construct type3 from type1 */
|
||||
if(type1 & C1_SPACE) type3 |= C3_SYMBOL;
|
||||
if(type1 & C1_ALPHA) type3 |= C3_ALPHA;
|
||||
if ((c>=0x30A0)&&(c<=0x30FF)) type3 |= C3_KATAKANA;
|
||||
if ((c>=0x3040)&&(c<=0x309F)) type3 |= C3_HIRAGANA;
|
||||
if ((c>=0x4E00)&&(c<=0x9FAF)) type3 |= C3_IDEOGRAPH;
|
||||
if (c == 0x0640) type3 |= C3_KASHIDA;
|
||||
if ((c>=0x3000)&&(c<=0x303F)) type3 |= C3_SYMBOL;
|
||||
|
||||
if ((c>=0xD800)&&(c<=0xDBFF)) type3 |= C3_HIGHSURROGATE;
|
||||
if ((c>=0xDC00)&&(c<=0xDFFF)) type3 |= C3_LOWSURROGATE;
|
||||
|
||||
if ((c>=0xFF00)&&(c<=0xFF60)) type3 |= C3_FULLWIDTH;
|
||||
if ((c>=0xFF00)&&(c<=0xFF20)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF3B)&&(c<=0xFF40)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF5B)&&(c<=0xFF60)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF21)&&(c<=0xFF3A)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFF41)&&(c<=0xFF5A)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_FULLWIDTH;
|
||||
if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_SYMBOL;
|
||||
|
||||
if ((c>=0xFF61)&&(c<=0xFFDC)) type3 |= C3_HALFWIDTH;
|
||||
if ((c>=0xFF61)&&(c<=0xFF64)) type3 |= C3_SYMBOL;
|
||||
if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_KATAKANA;
|
||||
if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_ALPHA;
|
||||
if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_HALFWIDTH;
|
||||
if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_SYMBOL;
|
||||
*chartype++ = type3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetStringTypeExW (kernelbase.@)
|
||||
*/
|
||||
BOOL WINAPI DECLSPEC_HOTPATCH GetStringTypeExW( LCID locale, DWORD type, const WCHAR *src, int count,
|
||||
WORD *chartype )
|
||||
{
|
||||
/* locale is ignored for Unicode */
|
||||
return GetStringTypeW( type, src, count, chartype );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetSystemDefaultLCID (kernelbase.@)
|
||||
*/
|
||||
|
|
|
@ -2920,7 +2920,7 @@ dump_ctype_tables( "libs/port/wctype.c" );
|
|||
dump_bidi_dir_table( "dlls/gdi32/direction.c" );
|
||||
dump_bidi_dir_table( "dlls/usp10/direction.c" );
|
||||
dump_bidi_dir_table( "dlls/dwrite/direction.c" );
|
||||
dump_string_type_table( "dlls/kernel32/wctype.c" );
|
||||
dump_string_type_table( "dlls/kernelbase/wctype.c" );
|
||||
dump_digit_folding( "libs/port/digitmap.c", 1 );
|
||||
dump_digit_folding( "dlls/kernelbase/digitmap.c", 0 );
|
||||
dump_combining_class( "libs/port/combclass.c" );
|
||||
|
|
Loading…
Reference in New Issue