VirtualBox

Changeset 57615 in vbox for trunk


Ignore:
Timestamp:
Sep 4, 2015 2:43:08 AM (9 years ago)
Author:
vboxsync
Message:

RTPathGlob: build and bug fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/path/RTPathGlob.cpp

    r57613 r57615  
    203203        RTDIRENTRY      DirEntry;
    204204        /** Padding the buffer to an unreasonably large size. */
    205         uint8_t         abPadding[RTPATH_MAX + RT_OFFSETOF(RTDIRENTRY, szName)];
     205        uint8_t         abPadding[RTPATH_MAX + sizeof(RTDIRENTRY)];
    206206    } u;
    207207
     
    443443    {
    444444        char *pchSep = strchr(pszPath, chSep);
    445         if (iItem > 0)
     445
     446        /* We ignore empty strings, which is probably not entirely correct,
     447           but works better on DOS based system with many entries added
     448           without checking whether there is a trailing separator or not.
     449           Thus, the current directory is only searched if a '.' is present
     450           in the PATH. */
     451        if (pchSep == pszPath)
     452            pszPath++;
     453        else if (iItem > 0)
    446454        {
    447455            /* If we didn't find a separator, the item doesn't exists. Quit. */
     
    449457                break;
    450458
    451             /* We ignore empty strings, which is probably not entirely correct,
    452                but works better on DOS based system with many entries added
    453                without checking whether there is a trailing separator or not.
    454                Thus, the current directory is only searched if a '.' is present
    455                in the PATH. */
    456             if (pchSep != pszPath)
    457             {
    458                 pszPath = pchSep;
    459                 iItem--;
    460             }
    461             pszPath++;
     459            pszPath = pchSep + 1;
     460            iItem--;
    462461        }
    463462        else
    464463        {
    465464            /* We've reached the item we wanted. */
    466             size_t cchComp = pchSep ? pszPath - pchSep : strlen(pszPath);
     465            size_t cchComp = pchSep ? pchSep - pszPath : strlen(pszPath);
    467466            if (cchComp < cbBuf)
    468467            {
     
    474473            else
    475474                rc = VERR_BUFFER_OVERFLOW;
     475            *pcchValue = cchComp;
    476476            break;
    477477        }
     
    10721072                if (cchPattern == 0)
    10731073                {
    1074                     pInstr->enmOpCode = iFirst + 1 == pAllocator->iNext
     1074                    pInstr->enmOpCode = iFirst + 1U == pAllocator->iNext
    10751075                                      ? RTPATHMATCHOP_RETURN_MATCH_EXCEPT_DOT_AND_DOTDOT : RTPATHMATCHOP_RETURN_MATCH;
    10761076                    break;
    10771077                }
    10781078
    1079                 pInstr->enmOpCode = iFirst + 1 == pAllocator->iNext
     1079                pInstr->enmOpCode = iFirst + 1U == pAllocator->iNext
    10801080                                  ? RTPATHMATCHOP_ZERO_OR_MORE_EXCEPT_DOT_AND_DOTDOT : RTPATHMATCHOP_ZERO_OR_MORE;
    10811081                pInstr->uOp2      = (uint16_t)offInput;
     
    12251225                        pchPattern += cchVarNm + 1;
    12261226                        cchPattern -= cchVarNm + 1;
    1227                         AssertMsgReturn(!g_aVariables[iVar].fFirstOnly || iFirst + 1 == pAllocator->iNext,
     1227                        AssertMsgReturn(!g_aVariables[iVar].fFirstOnly || iFirst + 1U == pAllocator->iNext,
    12281228                                        ("Glob variable '%s' should be first\n", g_aVariables[iVar].pszName),
    12291229                                        VERR_PATH_MATCH_VARIABLE_MUST_BE_FIRST);
     
    12451245        while (cchPlain < cchPattern)
    12461246        {
    1247             char const ch = pchPattern[cchPlain];
     1247            ch = pchPattern[cchPlain];
    12481248            if (!ASMBitTest(s_bmMetaChars, (uint8_t)ch))
    12491249            { /* probable */ }
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