[PATCH 4/9] [Mscms]: GetColorDirectory
Eric Pouech
eric.pouech at wanadoo.fr
Wed Nov 8 14:46:59 CST 2006
- fixed incorrect A -> W conversions
- fixed, while I was at it, a couple of missing error codes
(and removed the todo_wine in test file accordingly)
(spotted by valgrind)
A+
---
dlls/mscms/profile.c | 29 +++++++++++++++--------------
dlls/mscms/tests/profile.c | 10 ++--------
2 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/dlls/mscms/profile.c b/dlls/mscms/profile.c
index 0b1b437..b3e840e 100644
--- a/dlls/mscms/profile.c
+++ b/dlls/mscms/profile.c
@@ -78,6 +78,8 @@ BOOL WINAPI GetColorDirectoryA( PCSTR ma
if (machine || !size) return FALSE;
+ sizeW = *size * sizeof(WCHAR);
+
if (!buffer)
{
ret = GetColorDirectoryW( NULL, NULL, &sizeW );
@@ -85,20 +87,17 @@ BOOL WINAPI GetColorDirectoryA( PCSTR ma
return FALSE;
}
- sizeW = *size * sizeof(WCHAR);
-
bufferW = HeapAlloc( GetProcessHeap(), 0, sizeW );
if (bufferW)
{
- ret = GetColorDirectoryW( NULL, bufferW, &sizeW );
- *size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
-
- if (ret)
+ if ((ret = GetColorDirectoryW( NULL, bufferW, &sizeW )))
{
- len = WideCharToMultiByte( CP_ACP, 0, bufferW, *size, buffer, *size, NULL, NULL );
+ *size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
+ len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *size, NULL, NULL );
if (!len) ret = FALSE;
}
+ else *size = sizeW / sizeof(WCHAR);
HeapFree( GetProcessHeap(), 0, bufferW );
}
@@ -139,6 +138,7 @@ BOOL WINAPI GetColorDirectoryW( PCWSTR m
return TRUE;
}
+ SetLastError( ERROR_MORE_DATA );
*size = len;
return FALSE;
}
@@ -389,14 +389,13 @@ BOOL WINAPI GetStandardColorSpaceProfile
if (profileW)
{
- ret = GetStandardColorSpaceProfileW( NULL, id, profileW, &sizeW );
- *size = WideCharToMultiByte( CP_ACP, 0, profileW, -1, NULL, 0, NULL, NULL );
-
- if (ret)
+ if ((ret = GetStandardColorSpaceProfileW( NULL, id, profileW, &sizeW )))
{
- len = WideCharToMultiByte( CP_ACP, 0, profileW, *size, profile, *size, NULL, NULL );
+ *size = WideCharToMultiByte( CP_ACP, 0, profileW, -1, NULL, 0, NULL, NULL );
+ len = WideCharToMultiByte( CP_ACP, 0, profileW, -1, profile, *size, NULL, NULL );
if (!len) ret = FALSE;
}
+ else *size = sizeW / sizeof(WCHAR);
HeapFree( GetProcessHeap(), 0, profileW );
}
@@ -451,20 +450,22 @@ BOOL WINAPI GetStandardColorSpaceProfile
switch (id)
{
- case 0x52474220: /* 'RGB ' */
+ case SPACE_RGB: /* 'RGB ' */
lstrcatW( rgbprofile, rgbprofilefile );
len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
if (*size < len || !profile)
{
*size = len;
- return TRUE;
+ SetLastError( ERROR_MORE_DATA );
+ return FALSE;
}
lstrcpyW( profile, rgbprofile );
break;
default:
+ SetLastError( ERROR_FILE_NOT_FOUND );
return FALSE;
}
return TRUE;
diff --git a/dlls/mscms/tests/profile.c b/dlls/mscms/tests/profile.c
index fda6723..3cf1073 100644
--- a/dlls/mscms/tests/profile.c
+++ b/dlls/mscms/tests/profile.c
@@ -597,7 +597,6 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* 2nd param, */
ret = pGetStandardColorSpaceProfileA(NULL, (DWORD)-1, newprofile, &sizeP);
- todo_wine
ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
SetLastError(0xfaceabee); /* 4th param, */
@@ -612,17 +611,14 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* dereferenced 4th param, */
ret = pGetStandardColorSpaceProfileA(NULL, SPACE_RGB, newprofile, &zero);
- todo_wine
ok( !ret && (GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INSUFFICIENT_BUFFER), "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
} else {
SetLastError(0xfaceabee); /* 3rd param, */
ret = pGetStandardColorSpaceProfileA(NULL, SPACE_RGB, NULL, &sizeP);
- todo_wine
ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
SetLastError(0xfaceabee); /* dereferenced 4th param. */
ret = pGetStandardColorSpaceProfileA(NULL, SPACE_RGB, newprofile, &sizeP);
- todo_wine
ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
}
@@ -642,7 +638,7 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* maybe 2nd param. */
ret = pGetStandardColorSpaceProfileA(NULL, 0, newprofile, &sizeP);
- if (!ret) todo_wine ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
+ if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
else ok( !lstrcmpiA( newprofile, emptyA ) && GetLastError() == 0xfaceabee, "GetStandardColorSpaceProfileA() returns %d (GLE=%d)\n", ret, GetLastError() );
/* Functional checks */
@@ -689,7 +685,6 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* 2nd param, */
ret = pGetStandardColorSpaceProfileW(NULL, (DWORD)-1, newprofile, &sizeP);
- todo_wine
ok( !ret && GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
SetLastError(0xfaceabee); /* 3th param, */
@@ -702,7 +697,6 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* dereferenced 4th param. */
ret = pGetStandardColorSpaceProfileW(NULL, SPACE_RGB, newprofile, &zero);
- todo_wine
ok( !ret && (GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INSUFFICIENT_BUFFER), "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
/* Several invalid parameter checks: */
@@ -721,7 +715,7 @@ static void test_GetStandardColorSpacePr
SetLastError(0xfaceabee); /* maybe 2nd param. */
ret = pGetStandardColorSpaceProfileW(NULL, 0, newprofile, &sizeP);
- if (!ret) todo_wine ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
+ if (!ret) ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
else ok( !lstrcmpiW( newprofile, emptyW ) && GetLastError() == 0xfaceabee, "GetStandardColorSpaceProfileW() returns %d (GLE=%d)\n", ret, GetLastError() );
/* Functional checks */
More information about the wine-patches
mailing list