VirtualBox

Ignore:
Timestamp:
Feb 4, 2025 6:01:30 AM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167328
Message:

Runtime/RTScriptLex*: Allow case insensitivity with converting all characters [a-z] to upper case [A-Z] internally, bugref:10733

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/script/scriptlex.cpp

    r108028 r108049  
    589589    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    590590
     591    /* Case insensitivity with internal lower or upper case conversion is mutually exclusive. */
     592    AssertReturn(   (pCfg->fFlags & (RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_LOWER | RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_UPPER))
     593                 != (RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_LOWER | RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_UPPER), VERR_INVALID_PARAMETER);
     594
    591595    if (!cchBuf)
    592596        cchBuf = _16K;
     
    853857    }
    854858
    855     if (   (pThis->pCfg->fFlags & RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE)
    856         && !(fFlags & RTSCRIPT_LEX_CONV_F_NOTHING))
    857         ch = RT_C_TO_LOWER(ch);
     859    if (!(fFlags & RTSCRIPT_LEX_CONV_F_NOTHING))
     860    {
     861        if (pThis->pCfg->fFlags & RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_LOWER)
     862           ch = RT_C_TO_LOWER(ch);
     863        else if (pThis->pCfg->fFlags & RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_UPPER)
     864           ch = RT_C_TO_UPPER(ch);
     865    }
    858866
    859867    return ch;
     
    923931        /* Some hex prefix? */
    924932        char chNext = RTScriptLexPeekCh(hScriptLex, 1);
    925         if (chNext == 'x')
     933        if (chNext == 'x' || chNext == 'X')
    926934        {
    927935            uBase = 16;
     
    938946    {
    939947        if (   (ch < '0' || ch > '9')
    940             && (ch < 'a' || ch > 'f' || uBase == 10))
     948            && (   (   !(ch >= 'a' && ch <= 'f')
     949                    && !(ch >= 'A' && ch <= 'F'))
     950                || uBase == 10))
    941951        {
    942952            if (pTok->Type.Number.enmType == RTSCRIPTLEXTOKNUMTYPE_INTEGER)
     
    955965            Assert(uBase == 16);
    956966            u64 = (u64 << 4) + 10 + (ch - 'a');
     967        }
     968        else if (ch >= 'A' && ch <= 'F')
     969        {
     970            Assert(uBase == 16);
     971            u64 = (u64 << 4) + 10 + (ch - 'A');
    957972        }
    958973
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