Exit ealier from LCMapStringA in the case of LCMAP_SORTKEY.

Don't rely on computing string length by MultiByteToWideChar in
CompareStringA, do it manually.
This commit is contained in:
Dmitry Timoshkov 2003-07-03 18:09:03 +00:00 committed by Alexandre Julliard
parent 104d9d44fd
commit 62efd98687
2 changed files with 8 additions and 0 deletions

View File

@ -1154,6 +1154,7 @@ INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen,
goto map_string_exit; goto map_string_exit;
} }
ret = wine_get_sortkey(flags, srcW, srclenW, dst, dstlen); ret = wine_get_sortkey(flags, srcW, srclenW, dst, dstlen);
goto map_string_exit;
} }
if (flags & SORT_STRINGSORT) if (flags & SORT_STRINGSORT)
@ -1225,6 +1226,9 @@ INT WINAPI CompareStringA(LCID lcid, DWORD style,
return 0; return 0;
} }
if (len1 < 0) len1 = strlen(str1);
if (len2 < 0) len2 = strlen(str2);
GetLocaleInfoW(lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, GetLocaleInfoW(lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
(WCHAR *)&locale_cp, (sizeof(locale_cp)/sizeof(WCHAR))); (WCHAR *)&locale_cp, (sizeof(locale_cp)/sizeof(WCHAR)));

View File

@ -719,6 +719,10 @@ char buffer1[BUFFER_SIZE], buffer2[BUFFER_SIZE];
ret = CompareStringA(lcid, NORM_IGNORECASE, buffer1, -1, buffer2, 0); ret = CompareStringA(lcid, NORM_IGNORECASE, buffer1, -1, buffer2, 0);
ok (ret == 3, "CompareStringA (st1=%s str2=%s) expected result=3, got %d", buffer1, buffer2, ret); ok (ret == 3, "CompareStringA (st1=%s str2=%s) expected result=3, got %d", buffer1, buffer2, ret);
strcpy(buffer1, "Salut"); strcpy(buffer2, "saLuT");
ret = CompareStringA(lcid, NORM_IGNORECASE, buffer1, 5, buffer2, -1);
ok (ret == 2, "CompareStringA (st1=%s str2=%s) expected result=2, got %d", buffer1, buffer2, ret);
} }
void test_LCMapStringA(void) void test_LCMapStringA(void)