VirtualBox

Changeset 41670 in vbox


Ignore:
Timestamp:
Jun 12, 2012 2:26:17 PM (12 years ago)
Author:
vboxsync
Message:

RTEnvClone: don't return an error if we found elements without a proper translation (xtracker 5667)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/env.h

    r28800 r41670  
    5555 * environment array.
    5656 *
    57  * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
     57 * @returns IPRT status code. Typical error is VERR_NO_MEMORY. Another
     58 * possible return code is VWRN_NO_TRANSLATION if EnvToClone is RTENV_DEFAULT
     59 * and there was no translation available for one environment variable. In
     60 * that case, the resulting environment will contain fewer elements than the
     61 * original environment.
    5862 *
    5963 * @param   pEnv        Where to store the handle of the new environment block.
  • trunk/include/iprt/err.h

    r40372 r41670  
    757757/** Error while characters translation (unicode and so). */
    758758#define VERR_NO_TRANSLATION                 (-58)
     759/** Error while characters translation (unicode and so). */
     760#define VWRN_NO_TRANSLATION                 58
    759761/** Encountered unicode code point which is reserved for use as endian indicator (0xffff or 0xfffe). */
    760762#define VERR_CODE_POINT_ENDIAN_INDICATOR    (-59)
  • trunk/src/VBox/Runtime/generic/env-generic.cpp

    r36576 r41670  
    240240        {
    241241            /* ASSUMES the default environment is in the current codepage. */
    242             for (size_t iVar = 0; iVar < cVars; iVar++)
    243             {
    244                 int rc2 = RTStrCurrentCPToUtf8(&pIntEnv->papszEnv[iVar], papszEnv[iVar]);
     242            bool fNoTranslation = false;
     243            size_t iDst = 0;
     244            for (size_t iSrc = 0; iSrc < cVars; iSrc++)
     245            {
     246                int rc2 = RTStrCurrentCPToUtf8(&pIntEnv->papszEnv[iDst], papszEnv[iSrc]);
     247                if (rc2 == VERR_NO_TRANSLATION)
     248                {
     249                    fNoTranslation = true;
     250                    continue;
     251                }
    245252                if (RT_FAILURE(rc2))
    246253                {
    247                     pIntEnv->cVars = iVar;
     254                    pIntEnv->cVars = iDst;
    248255                    RTEnvDestroy(pIntEnv);
    249256                    return rc2;
    250257                }
    251             }
     258                iDst++;
     259            }
     260            pIntEnv->cVars = iDst;
     261            if (fNoTranslation)
     262                rc = VWRN_NO_TRANSLATION;
    252263        }
    253264        else
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