Commit 8d11c087 authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Fix NormalizeString() return value and last error.

parent a7cc191a
...@@ -6034,12 +6034,10 @@ static void test_NormalizeString(void) ...@@ -6034,12 +6034,10 @@ static void test_NormalizeString(void)
dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, NULL, 0 ); dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, NULL, 0 );
ok( dstlen > lstrlenW(ptest->str), "%s:%d: wrong len %d / %d\n", ok( dstlen > lstrlenW(ptest->str), "%s:%d: wrong len %d / %d\n",
wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW(ptest->str) ); wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW(ptest->str) );
todo_wine
ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n", ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n",
wine_dbgstr_w(ptest->str), i, GetLastError()); wine_dbgstr_w(ptest->str), i, GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, dst, dstlen ); dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, dst, dstlen );
todo_wine
ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n", ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n",
wine_dbgstr_w(ptest->str), i, GetLastError()); wine_dbgstr_w(ptest->str), i, GetLastError());
ok(dstlen == lstrlenW( dst )+1, "%s:%d: Copied length differed: was %d, should be %d\n", ok(dstlen == lstrlenW( dst )+1, "%s:%d: Copied length differed: was %d, should be %d\n",
...@@ -6086,33 +6084,33 @@ static void test_NormalizeString(void) ...@@ -6086,33 +6084,33 @@ static void test_NormalizeString(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationD, part0_str1, -1, dst, 1 ); dstlen = pNormalizeString( NormalizationD, part0_str1, -1, dst, 1 );
todo_wine ok( dstlen <= 0, "wrong len %d\n", dstlen ); ok( dstlen <= 0, "wrong len %d\n", dstlen );
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 1 ); dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 1 );
todo_wine ok( dstlen <= 0, "wrong len %d\n", dstlen ); ok( dstlen <= 0, "wrong len %d\n", dstlen );
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationC, part0_str2, -1, NULL, 0 ); dstlen = pNormalizeString( NormalizationC, part0_str2, -1, NULL, 0 );
ok( dstlen == 12, "wrong len %d\n", dstlen ); ok( dstlen == 12, "wrong len %d\n", dstlen );
todo_wine ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 3 ); dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 3 );
ok( dstlen == 3, "wrong len %d\n", dstlen ); ok( dstlen == 3, "wrong len %d\n", dstlen );
todo_wine ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationC, part0_str2, 0, NULL, 0 ); dstlen = pNormalizeString( NormalizationC, part0_str2, 0, NULL, 0 );
ok( dstlen == 0, "wrong len %d\n", dstlen ); ok( dstlen == 0, "wrong len %d\n", dstlen );
todo_wine ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
dstlen = pNormalizeString( NormalizationC, part0_str2, 0, dst, 3 ); dstlen = pNormalizeString( NormalizationC, part0_str2, 0, dst, 3 );
ok( dstlen == 0, "wrong len %d\n", dstlen ); ok( dstlen == 0, "wrong len %d\n", dstlen );
todo_wine ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
/* size estimations */ /* size estimations */
...@@ -6144,11 +6142,11 @@ static void test_NormalizeString(void) ...@@ -6144,11 +6142,11 @@ static void test_NormalizeString(void)
if (i == 0 || i == 2) if (i == 0 || i == 2)
{ {
ok( dstlen == srclen, "%d: wrong len %d\n", i, dstlen ); ok( dstlen == srclen, "%d: wrong len %d\n", i, dstlen );
todo_wine ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
} }
else else
{ {
todo_wine ok( dstlen < -expect, "%d: wrong len %d\n", i, dstlen ); ok( dstlen < -expect, "%d: wrong len %d\n", i, dstlen );
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError()); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
} }
if (pRtlNormalizeString) if (pRtlNormalizeString)
...@@ -6185,12 +6183,13 @@ static void test_NormalizeString(void) ...@@ -6185,12 +6183,13 @@ static void test_NormalizeString(void)
case NormalizationKD: case NormalizationKD:
case 13: /* Idn */ case 13: /* Idn */
todo_wine_if (i == 13) todo_wine_if (i == 13)
{
ok( dstlen > 0, "%d: wrong len %d\n", i, dstlen ); ok( dstlen > 0, "%d: wrong len %d\n", i, dstlen );
todo_wine ok( GetLastError() == ERROR_SUCCESS, "%d: got error %u\n", i, GetLastError()); ok( GetLastError() == ERROR_SUCCESS, "%d: got error %u\n", i, GetLastError());
}
break; break;
default: default:
ok( dstlen <= 0, "%d: wrong len %d\n", i, dstlen ); ok( dstlen <= 0, "%d: wrong len %d\n", i, dstlen );
todo_wine_if (i)
ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %u\n", i, GetLastError()); ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %u\n", i, GetLastError());
break; break;
} }
......
...@@ -4923,7 +4923,19 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co ...@@ -4923,7 +4923,19 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co
INT WINAPI DECLSPEC_HOTPATCH NormalizeString(NORM_FORM form, const WCHAR *src, INT src_len, INT WINAPI DECLSPEC_HOTPATCH NormalizeString(NORM_FORM form, const WCHAR *src, INT src_len,
WCHAR *dst, INT dst_len) WCHAR *dst, INT dst_len)
{ {
set_ntstatus( RtlNormalizeString( form, src, src_len, dst, &dst_len )); NTSTATUS status = RtlNormalizeString( form, src, src_len, dst, &dst_len );
switch (status)
{
case STATUS_OBJECT_NAME_NOT_FOUND:
status = STATUS_INVALID_PARAMETER;
break;
case STATUS_BUFFER_TOO_SMALL:
case STATUS_NO_UNICODE_TRANSLATION:
dst_len = -dst_len;
break;
}
SetLastError( RtlNtStatusToDosError( status ));
return dst_len; return dst_len;
} }
......
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