VirtualBox

Changeset 108049 in vbox


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

Location:
trunk
Files:
3 edited

Legend:

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

    r108014 r108049  
    309309
    310310/** Default lexer config flags. */
    311 #define RTSCRIPT_LEX_CFG_F_DEFAULT          0
     311#define RTSCRIPT_LEX_CFG_F_DEFAULT                0
    312312/** Case insensitive lexing, keywords and so on must be used lowercase to match
    313313 * as the lexer will convert everything to lowercase internally. */
    314 #define RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE RT_BIT(0)
     314#define RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_LOWER RT_BIT(0)
     315/** Case insensitive lexing, keywords and so on must be used uppercase to match
     316 * as the lexer will convert everything to uppercase internally. */
     317#define RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_UPPER RT_BIT(1)
    315318
    316319
  • trunk/src/VBox/Disassembler/testcase/tstDisasmArmv8-1.cpp

    r106805 r108049  
    127127    "ARMv8 disassembler lexer",
    128128    /** fFlags */
    129     RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE,
     129    RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_LOWER,
    130130    /** pszWhitespace */
    131131    NULL,
  • 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