Add better NULL checks to lstrcmp[i](A/W) functions.
This commit is contained in:
parent
def7188731
commit
91d63c0cb6
|
@ -2356,8 +2356,15 @@ INT WINAPI CompareStringA(LCID lcid, DWORD style,
|
|||
*/
|
||||
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
|
||||
{
|
||||
int ret = CompareStringA(GetThreadLocale(), 0, str1, -1, str2, -1);
|
||||
int ret;
|
||||
|
||||
if ((str1 == NULL) && (str2 == NULL)) return 0;
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
ret = CompareStringA(GetThreadLocale(), 0, str1, -1, str2, -1);
|
||||
if (ret) ret -= 2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2378,8 +2385,15 @@ int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
|
|||
*/
|
||||
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
|
||||
{
|
||||
int ret = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, str1, -1, str2, -1);
|
||||
int ret;
|
||||
|
||||
if ((str1 == NULL) && (str2 == NULL)) return 0;
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
ret = CompareStringA(GetThreadLocale(), NORM_IGNORECASE, str1, -1, str2, -1);
|
||||
if (ret) ret -= 2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2390,8 +2404,15 @@ int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
|
|||
*/
|
||||
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
|
||||
{
|
||||
int ret = CompareStringW(GetThreadLocale(), 0, str1, -1, str2, -1);
|
||||
int ret;
|
||||
|
||||
if ((str1 == NULL) && (str2 == NULL)) return 0;
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
ret = CompareStringW(GetThreadLocale(), 0, str1, -1, str2, -1);
|
||||
if (ret) ret -= 2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2402,8 +2423,15 @@ int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
|
|||
*/
|
||||
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
|
||||
{
|
||||
int ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, -1, str2, -1);
|
||||
int ret;
|
||||
|
||||
if ((str1 == NULL) && (str2 == NULL)) return 0;
|
||||
if (str1 == NULL) return -1;
|
||||
if (str2 == NULL) return 1;
|
||||
|
||||
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, -1, str2, -1);
|
||||
if (ret) ret -= 2;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -795,8 +795,17 @@ static void test_CompareStringA()
|
|||
ok(!ret, "CompareStringA must fail with invalid flag\n");
|
||||
|
||||
ret = lstrcmpA("", "");
|
||||
ok (!ret, "lstrcmpA(\"\", \"\") should return 0, got %d\n", ret);
|
||||
ok (ret == 0, "lstrcmpA(\"\", \"\") should return 0, got %d\n", ret);
|
||||
|
||||
ret = lstrcmpA(NULL, NULL);
|
||||
ok (ret == 0, "lstrcmpA(NULL, NULL) should return 0, got %d\n", ret);
|
||||
|
||||
ret = lstrcmpA("", NULL);
|
||||
ok (ret == 1, "lstrcmpA(\"\", NULL) should return 1, got %d\n", ret);
|
||||
|
||||
ret = lstrcmpA(NULL, "");
|
||||
ok (ret == -1, "lstrcmpA(NULL, \"\") should return -1, got %d\n", ret);
|
||||
|
||||
ret = CompareStringA(LOCALE_SYSTEM_DEFAULT,0,"EndDialog",-1,"_Property",-1);
|
||||
ok( ret == 3, "EndDialog vs _Property ... expected 3, got %d\n", ret);
|
||||
|
||||
|
|
Loading…
Reference in New Issue