VirtualBox

Changeset 45260 in vbox for trunk/src


Ignore:
Timestamp:
Mar 31, 2013 12:07:11 AM (12 years ago)
Author:
vboxsync
Message:

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.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp

    r43363 r45260  
    194194            const void *pvInputLeft = pvInput;
    195195            void       *pvOutputLeft = pvOutput;
     196            size_t      cchNonRev;
    196197#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. */
    197             if (iconv(hIconv, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
     198            cchNonRev = iconv(hIconv, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
    198199#else
    199             if (iconv(hIconv, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
    200 #endif
     200            cchNonRev = iconv(hIconv, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
     201#endif
     202            if (cchNonRev != (size_t)-1)
    201203            {
    202204                if (!cbInLeft)
     
    210212                        ((char *)pvOutputLeft)[1] = '\0';
    211213                    *ppvOutput = pvOutput;
    212                     return VINF_SUCCESS;
     214                    if (cchNonRev == 0)
     215                        return VINF_SUCCESS;
     216                    return VWRN_NO_TRANSLATION;
    213217                }
    214218                errno = E2BIG;
     
    320324            const void *pvInputLeft = pvInput;
    321325            void       *pvOutputLeft = pvOutput;
     326            size_t      cchNonRev;
    322327#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. */
    323             if (iconv(icHandle, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
     328            cchNonRev = iconv(icHandle, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
    324329#else
    325             if (iconv(icHandle, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft) != (size_t)-1)
    326 #endif
     330            cchNonRev = iconv(icHandle, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
     331#endif
     332            if (cchNonRev != (size_t)-1)
    327333            {
    328334                if (!cbInLeft)
     
    337343                        ((char *)pvOutputLeft)[1] = '\0';
    338344                    *ppvOutput = pvOutput;
    339                     return VINF_SUCCESS;
     345                    if (cchNonRev == 0)
     346                        return VINF_SUCCESS;
     347                    return VWRN_NO_TRANSLATION;
    340348                }
    341349                errno = E2BIG;
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r45257 r45260  
    13971397    char *pszOut;
    13981398    rc = RTStrUtf8ToCurrentCP(&pszOut, pszTest1);
    1399     if (RT_SUCCESS(rc))
     1399    if (rc == VINF_SUCCESS)
    14001400    {
    14011401        RTTESTI_CHECK(!strcmp(pszOut, pszTest1));
     
    14051405    }
    14061406    else
    1407         RTTESTI_CHECK_RC(rc, VERR_NO_TRANSLATION);
     1407        RTTESTI_CHECK_MSG(rc == VWRN_NO_TRANSLATION || rc == VERR_NO_TRANSLATION, ("rc=%Rrc\n", rc));
    14081408
    14091409    RTTestSub(hTest, "VERR_NO_TRANSLATION/RTUtf16ToLatin1");
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette