summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2013-03-31 00:07:11 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2013-03-31 00:07:11 +0000
commit1f4cd9dfff0c4d250ecab33f44c41466b70b4daf (patch)
treee1d909b93595c6a31b0978557f75d8e7d75a5df6
parent4ef8f122cde07f4f5b839a941032e0c435835482 (diff)
downloadVirtualBox-svn-1f4cd9dfff0c4d250ecab33f44c41466b70b4daf.tar.gz
We should probably check the iconv return value a little more closely. Currently trying VWRN_NO_TRANSLATION instead of VERR_NO_TRANSLATION as tstUtf8 originally expected. Adjusted tstUtf8. Seen trouble in this area on testboxsh1 where neither LC_ALL, LANG nor LC_CTYPE were set.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@45260 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r--src/VBox/Runtime/r3/posix/utf8-posix.cpp20
-rw-r--r--src/VBox/Runtime/testcase/tstUtf8.cpp4
2 files changed, 16 insertions, 8 deletions
diff --git a/src/VBox/Runtime/r3/posix/utf8-posix.cpp b/src/VBox/Runtime/r3/posix/utf8-posix.cpp
index d0400b4950e..fef93672de9 100644
--- a/src/VBox/Runtime/r3/posix/utf8-posix.cpp
+++ b/src/VBox/Runtime/r3/posix/utf8-posix.cpp
@@ -193,11 +193,13 @@ static int rtstrConvertCached(const void *pvInput, size_t cbInput, const char *p
size_t cbOutLeft = cbOutput2;
const void *pvInputLeft = pvInput;
void *pvOutputLeft = pvOutput;
+ size_t cchNonRev;
#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)) /* there are different opinions about the constness of the input buffer. */
- if (iconv(hIconv, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
+ cchNonRev = iconv(hIconv, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
#else
- if (iconv(hIconv, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
+ cchNonRev = iconv(hIconv, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
#endif
+ if (cchNonRev != (size_t)-1)
{
if (!cbInLeft)
{
@@ -209,7 +211,9 @@ static int rtstrConvertCached(const void *pvInput, size_t cbInput, const char *p
if (fUcs2Term)
((char *)pvOutputLeft)[1] = '\0';
*ppvOutput = pvOutput;
- return VINF_SUCCESS;
+ if (cchNonRev == 0)
+ return VINF_SUCCESS;
+ return VWRN_NO_TRANSLATION;
}
errno = E2BIG;
}
@@ -319,11 +323,13 @@ static int rtStrConvertUncached(const void *pvInput, size_t cbInput, const char
size_t cbOutLeft = cbOutput2;
const void *pvInputLeft = pvInput;
void *pvOutputLeft = pvOutput;
+ size_t cchNonRev;
#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)) /* there are different opinions about the constness of the input buffer. */
- if (iconv(icHandle, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
+ cchNonRev = iconv(icHandle, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
#else
- if (iconv(icHandle, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
+ cchNonRev = iconv(icHandle, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
#endif
+ if (cchNonRev != (size_t)-1)
{
if (!cbInLeft)
{
@@ -336,7 +342,9 @@ static int rtStrConvertUncached(const void *pvInput, size_t cbInput, const char
if (fUcs2Term)
((char *)pvOutputLeft)[1] = '\0';
*ppvOutput = pvOutput;
- return VINF_SUCCESS;
+ if (cchNonRev == 0)
+ return VINF_SUCCESS;
+ return VWRN_NO_TRANSLATION;
}
errno = E2BIG;
}
diff --git a/src/VBox/Runtime/testcase/tstUtf8.cpp b/src/VBox/Runtime/testcase/tstUtf8.cpp
index dec4df06cb0..1344fccee48 100644
--- a/src/VBox/Runtime/testcase/tstUtf8.cpp
+++ b/src/VBox/Runtime/testcase/tstUtf8.cpp
@@ -1396,7 +1396,7 @@ static void testNoTransation(RTTEST hTest)
RTTestSub(hTest, "VERR_NO_TRANSLATION/RTStrUtf8ToCurrentCP");
char *pszOut;
rc = RTStrUtf8ToCurrentCP(&pszOut, pszTest1);
- if (RT_SUCCESS(rc))
+ if (rc == VINF_SUCCESS)
{
RTTESTI_CHECK(!strcmp(pszOut, pszTest1));
RTTestIPrintf(RTTESTLVL_ALWAYS, "CurrentCP is UTF-8 or similar (LC_ALL=%s LANG=%s LC_CTYPE=%s)\n",
@@ -1404,7 +1404,7 @@ static void testNoTransation(RTTEST hTest)
RTStrFree(pszOut);
}
else
- RTTESTI_CHECK_RC(rc, VERR_NO_TRANSLATION);
+ RTTESTI_CHECK_MSG(rc == VWRN_NO_TRANSLATION || rc == VERR_NO_TRANSLATION, ("rc=%Rrc\n", rc));
RTTestSub(hTest, "VERR_NO_TRANSLATION/RTUtf16ToLatin1");
rc = RTUtf16ToLatin1(s_swzTest1, &pszOut);