Commit a5da5252 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

kernel32: Fix LCMapString(LCMAP_HALFWIDTH) in some cases.

parent ef2df8ed
...@@ -3626,21 +3626,17 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW ...@@ -3626,21 +3626,17 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
{ {
/* map full-width character to half-width one, /* map full-width character to half-width one,
e.g. U+30A2 -> U+FF71, U+30D7 -> U+FF8C U+FF9F. */ e.g. U+30A2 -> U+FF71, U+30D7 -> U+FF8C U+FF9F. */
if (map_to_halfwidth(wch, dst_ptr, dstlen) == 2) if (map_to_halfwidth(wch, dst_ptr, len) == 2)
{ {
dstlen--; len--;
dst_ptr++; dst_ptr++;
if (!dstlen) if (!len) break;
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return 0;
}
} }
} }
else else
*dst_ptr = wch; *dst_ptr = wch;
} }
if (!(flags & (LCMAP_UPPERCASE | LCMAP_LOWERCASE))) if (!(flags & (LCMAP_UPPERCASE | LCMAP_LOWERCASE)) || srclen)
goto done; goto done;
srclen = dst_ptr - dst; srclen = dst_ptr - dst;
......
...@@ -2516,7 +2516,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f ...@@ -2516,7 +2516,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 1); ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 1);
todo_wine ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"%s should return 0 and ERROR_INSUFFICIENT_BUFFER, got %d\n", func_name, ret); "%s should return 0 and ERROR_INSUFFICIENT_BUFFER, got %d\n", func_name, ret);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
...@@ -2525,7 +2525,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f ...@@ -2525,7 +2525,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
"%s should return 0 and ERROR_INSUFFICIENT_BUFFER, got %d\n", func_name, ret); "%s should return 0 and ERROR_INSUFFICIENT_BUFFER, got %d\n", func_name, ret);
ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 3); ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 3);
todo_wine ok(ret == 3, "%s ret %d, expected value 3\n", func_name, ret); ok(ret == 3, "%s ret %d, expected value 3\n", func_name, ret);
ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 4); ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_UPPERCASE, buf, 2, buf2, 4);
ok(ret == 3, "%s ret %d, expected value 3\n", func_name, ret); ok(ret == 3, "%s ret %d, expected value 3\n", func_name, ret);
......
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