kernel32: Do not allow to combine NORM_IGNORENONSPACE and/or NORM_IGNORESYMBOLS with other LCMAP flags.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
138dc2716e
commit
70a6546753
|
@ -3190,6 +3190,12 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
|
||||||
SetLastError(ERROR_INVALID_FLAGS);
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ((flags & (NORM_IGNORENONSPACE | NORM_IGNORESYMBOLS)) &&
|
||||||
|
(flags & ~(NORM_IGNORENONSPACE | NORM_IGNORESYMBOLS)))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (srclen < 0) srclen = strlenW(src) + 1;
|
if (srclen < 0) srclen = strlenW(src) + 1;
|
||||||
|
|
||||||
|
@ -3218,10 +3224,7 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
|
||||||
{
|
{
|
||||||
for (dst_ptr = dst; srclen && dstlen; src++, srclen--)
|
for (dst_ptr = dst; srclen && dstlen; src++, srclen--)
|
||||||
{
|
{
|
||||||
WCHAR wch = *src;
|
*dst_ptr++ = toupperW(*src);
|
||||||
if ((flags & NORM_IGNORESYMBOLS) && (get_char_typeW(wch) & (C1_PUNCT | C1_SPACE)))
|
|
||||||
continue;
|
|
||||||
*dst_ptr++ = toupperW(wch);
|
|
||||||
dstlen--;
|
dstlen--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3229,10 +3232,7 @@ INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPW
|
||||||
{
|
{
|
||||||
for (dst_ptr = dst; srclen && dstlen; src++, srclen--)
|
for (dst_ptr = dst; srclen && dstlen; src++, srclen--)
|
||||||
{
|
{
|
||||||
WCHAR wch = *src;
|
*dst_ptr++ = tolowerW(*src);
|
||||||
if ((flags & NORM_IGNORESYMBOLS) && (get_char_typeW(wch) & (C1_PUNCT | C1_SPACE)))
|
|
||||||
continue;
|
|
||||||
*dst_ptr++ = tolowerW(wch);
|
|
||||||
dstlen--;
|
dstlen--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2200,6 +2200,10 @@ static const DWORD lcmap_invalid_flags[] = {
|
||||||
LCMAP_HALFWIDTH | LCMAP_FULLWIDTH,
|
LCMAP_HALFWIDTH | LCMAP_FULLWIDTH,
|
||||||
LCMAP_TRADITIONAL_CHINESE | LCMAP_SIMPLIFIED_CHINESE,
|
LCMAP_TRADITIONAL_CHINESE | LCMAP_SIMPLIFIED_CHINESE,
|
||||||
LCMAP_LOWERCASE | SORT_STRINGSORT,
|
LCMAP_LOWERCASE | SORT_STRINGSORT,
|
||||||
|
LCMAP_UPPERCASE | NORM_IGNORESYMBOLS,
|
||||||
|
LCMAP_LOWERCASE | NORM_IGNORESYMBOLS,
|
||||||
|
LCMAP_UPPERCASE | NORM_IGNORENONSPACE,
|
||||||
|
LCMAP_LOWERCASE | NORM_IGNORENONSPACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_LCMapStringA(void)
|
static void test_LCMapStringA(void)
|
||||||
|
@ -2346,6 +2350,14 @@ static void test_LCMapStringA(void)
|
||||||
lstrlenA(symbols_stripped) + 1, ret);
|
lstrlenA(symbols_stripped) + 1, ret);
|
||||||
ok(!lstrcmpA(buf, symbols_stripped), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
|
ok(!lstrcmpA(buf, symbols_stripped), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
|
||||||
|
|
||||||
|
/* test NORM_IGNORESYMBOLS | NORM_IGNORENONSPACE */
|
||||||
|
lstrcpyA(buf, "foo");
|
||||||
|
ret = LCMapStringA(LOCALE_USER_DEFAULT, NORM_IGNORESYMBOLS | NORM_IGNORENONSPACE,
|
||||||
|
lower_case, -1, buf, sizeof(buf));
|
||||||
|
ok(ret == lstrlenA(symbols_stripped) + 1, "LCMapStringA should return %d, ret = %d\n",
|
||||||
|
lstrlenA(symbols_stripped) + 1, ret);
|
||||||
|
ok(!lstrcmpA(buf, symbols_stripped), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
|
||||||
|
|
||||||
/* test srclen = 0 */
|
/* test srclen = 0 */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = LCMapStringA(LOCALE_USER_DEFAULT, 0, upper_case, 0, buf, sizeof(buf));
|
ret = LCMapStringA(LOCALE_USER_DEFAULT, 0, upper_case, 0, buf, sizeof(buf));
|
||||||
|
@ -2480,6 +2492,14 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
|
||||||
lstrlenW(symbols_stripped) + 1, ret);
|
lstrlenW(symbols_stripped) + 1, ret);
|
||||||
ok(!lstrcmpW(buf, symbols_stripped), "%s string comparison mismatch\n", func_name);
|
ok(!lstrcmpW(buf, symbols_stripped), "%s string comparison mismatch\n", func_name);
|
||||||
|
|
||||||
|
/* test NORM_IGNORESYMBOLS | NORM_IGNORENONSPACE */
|
||||||
|
lstrcpyW(buf, fooW);
|
||||||
|
ret = func_ptr(NORM_IGNORESYMBOLS | NORM_IGNORENONSPACE,
|
||||||
|
lower_case, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
||||||
|
ok(ret == lstrlenW(symbols_stripped) + 1, "%s func_ptr should return %d, ret = %d\n", func_name,
|
||||||
|
lstrlenW(symbols_stripped) + 1, ret);
|
||||||
|
ok(!lstrcmpW(buf, symbols_stripped), "%s string comparison mismatch\n", func_name);
|
||||||
|
|
||||||
/* test srclen = 0 */
|
/* test srclen = 0 */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = func_ptr(0, upper_case, 0, buf, sizeof(buf)/sizeof(WCHAR));
|
ret = func_ptr(0, upper_case, 0, buf, sizeof(buf)/sizeof(WCHAR));
|
||||||
|
|
Loading…
Reference in New Issue