Commit 3cd0834a authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

kernel32: Change LCMapStringW to LCMapStringEx and call it from LCMapStringW.

parent 823e214e
......@@ -805,6 +805,7 @@
@ stdcall -i386 -private -register K32Thk1632Prolog() krnl386.exe16.K32Thk1632Prolog
@ stdcall LCIDToLocaleName(long ptr long long)
@ stdcall LCMapStringA(long long str long ptr long)
@ stdcall LCMapStringEx(wstr long wstr long ptr long ptr ptr long)
@ stdcall LCMapStringW(long long wstr long ptr long)
@ stdcall LZClose(long)
# @ stub LZCloseFile
......
......@@ -2493,17 +2493,35 @@ BOOL WINAPI GetStringTypeExA( LCID locale, DWORD type, LPCSTR src, INT count, LP
return GetStringTypeA(locale, type, src, count, chartype);
}
/*************************************************************************
* LCMapStringW (KERNEL32.@)
* LCMapStringEx (KERNEL32.@)
*
* See LCMapStringA.
* Map characters in a locale sensitive string.
*
* PARAMS
* name [I] Locale name for the conversion.
* flags [I] Flags controlling the mapping (LCMAP_ constants from "winnls.h")
* src [I] String to map
* srclen [I] Length of src in chars, or -1 if src is NUL terminated
* dst [O] Destination for mapped string
* dstlen [I] Length of dst in characters
* version [I] reserved, must be NULL
* reserved [I] reserved, must be NULL
* lparam [I] reserved, must be 0
*
* RETURNS
* Success: The length of the mapped string in dst, including the NUL terminator.
* Failure: 0. Use GetLastError() to determine the cause.
*/
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
LPWSTR dst, INT dstlen)
INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen,
LPNLSVERSIONINFO version, LPVOID reserved, LPARAM lparam)
{
LPWSTR dst_ptr;
if (version) FIXME("unsupported version structure %p\n", version);
if (reserved) FIXME("unsupported reserved pointer %p\n", reserved);
if (lparam) FIXME("unsupported lparam %lx\n", lparam);
if (!src || !srclen || dstlen < 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
......@@ -2522,8 +2540,6 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
if (!dstlen) dst = NULL;
lcid = ConvertDefaultLocale(lcid);
if (flags & LCMAP_SORTKEY)
{
INT ret;
......@@ -2535,8 +2551,8 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
if (srclen < 0) srclen = strlenW(src);
TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n",
lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen);
TRACE("(%s,0x%08x,%s,%d,%p,%d)\n",
debugstr_w(name), flags, debugstr_wn(src, srclen), srclen, dst, dstlen);
ret = wine_get_sortkey(flags, src, srclen, (char *)dst, dstlen);
if (ret == 0)
......@@ -2555,8 +2571,8 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
if (srclen < 0) srclen = strlenW(src) + 1;
TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n",
lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen);
TRACE("(%s,0x%08x,%s,%d,%p,%d)\n",
debugstr_w(name), flags, debugstr_wn(src, srclen), srclen, dst, dstlen);
if (!dst) /* return required string length */
{
......@@ -2625,6 +2641,20 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
}
/*************************************************************************
* LCMapStringW (KERNEL32.@)
*
* See LCMapStringA.
*/
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen,
LPWSTR dst, INT dstlen)
{
TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n",
lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen);
return LCMapStringEx(NULL, flags, src, srclen, dst, dstlen, NULL, NULL, 0);
}
/*************************************************************************
* LCMapStringA (KERNEL32.@)
*
* Map characters in a locale sensitive string.
......@@ -2693,7 +2723,7 @@ INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen,
goto map_string_exit;
}
dstlenW = LCMapStringW(lcid, flags, srcW, srclenW, NULL, 0);
dstlenW = LCMapStringEx(NULL, flags, srcW, srclenW, NULL, 0, NULL, NULL, 0);
if (!dstlenW)
goto map_string_exit;
......@@ -2704,7 +2734,7 @@ INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen,
goto map_string_exit;
}
LCMapStringW(lcid, flags, srcW, srclenW, dstW, dstlenW);
LCMapStringEx(NULL, flags, srcW, srclenW, dstW, dstlenW, NULL, NULL, 0);
ret = WideCharToMultiByte(locale_cp, 0, dstW, dstlenW, dst, dstlen, NULL, NULL);
HeapFree(GetProcessHeap(), 0, dstW);
......
......@@ -1652,8 +1652,18 @@ static INT LCMapStringW_wrapper(DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst
static void test_LCMapStringW(void)
{
int ret;
WCHAR buf[256];
trace("testing LCMapStringW\n");
SetLastError(0xdeadbeef);
ret = LCMapStringW((LCID)-1, LCMAP_LOWERCASE, upper_case, -1, buf, sizeof(buf)/sizeof(WCHAR));
todo_wine {
ok(!ret, "LCMapStringW should fail with bad lcid\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %d\n", GetLastError());
}
test_lcmapstring_unicode(LCMapStringW_wrapper, "LCMapStringW:");
}
......@@ -1665,16 +1675,24 @@ static INT LCMapStringEx_wrapper(DWORD flags, LPCWSTR src, INT srclen, LPWSTR ds
static void test_LCMapStringEx(void)
{
int ret;
WCHAR buf[256];
WCHAR buf[256], badname[] = {'w', 'i', 'n', 'e', 't', 'e', 's', 't', 0};
if (!pLCMapStringEx)
{
skip( "LCMapStringEx not available\n" );
win_skip( "LCMapStringEx not available\n" );
return;
}
trace("testing LCMapStringEx\n");
SetLastError(0xdeadbeef);
ret = pLCMapStringEx(badname, LCMAP_LOWERCASE,
upper_case, -1, buf, sizeof(buf)/sizeof(WCHAR), NULL, NULL, 0);
todo_wine {
ok(!ret, "LCMapStringEx should fail with bad locale name\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %d\n", GetLastError());
}
/* test reserved parameters */
ret = pLCMapStringEx(LOCALE_NAME_USER_DEFAULT, LCMAP_LOWERCASE,
upper_case, -1, buf, sizeof(buf)/sizeof(WCHAR), NULL, NULL, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment