VirtualBox

Changeset 2409 in kBuild for trunk/src/kObjCache/kObjCache.c


Ignore:
Timestamp:
Jun 16, 2010 11:46:56 PM (15 years ago)
Author:
bird
Message:

kObjCache: windows _spawnvp quoting and some other fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kObjCache/kObjCache.c

    r2375 r2409  
    7070#if defined(__WIN__)
    7171# include <Windows.h>
     72# include "quoted_spawn.h"
    7273#endif
    7374
     
    325326 * @param   pszPath1    The first path.
    326327 * @param   pszPath2    The second path.
    327  * @param   cch         The number of characters to compare.
    328  */
    329 static int ArePathsIdentical(const char *pszPath1, const char *pszPath2, size_t cch)
     328 */
     329static int ArePathsIdentical(const char *pszPath1, const char *pszPath2)
    330330{
    331331#if defined(__OS2__) || defined(__WIN__)
    332     if (strnicmp(pszPath1, pszPath2, cch))
     332    if (stricmp(pszPath1, pszPath2))
    333333    {
    334334        /* Slashes may differ, compare char by char. */
    335335        const char *psz1 = pszPath1;
    336336        const char *psz2 = pszPath2;
    337         for (;cch; psz1++, psz2++, cch--)
     337        for (;;)
     338        {
     339            if (*psz1 != *psz2)
     340            {
     341                if (    tolower(*psz1) != tolower(*psz2)
     342                    &&  toupper(*psz1) != toupper(*psz2)
     343                    &&  *psz1 != '/'
     344                    &&  *psz1 != '\\'
     345                    &&  *psz2 != '/'
     346                    &&  *psz2 != '\\')
     347                    return 0;
     348            }
     349            if (!*psz1)
     350                break;
     351            psz1++;
     352            psz2++;
     353        }
     354    }
     355    return 1;
     356#else
     357    return !strcmp(pszPath1, pszPath2);
     358#endif
     359}
     360
     361/**
     362 * Compares two path strings to see if they are identical.
     363 *
     364 * This doesn't do anything fancy, just the case ignoring and
     365 * slash unification.
     366 *
     367 * @returns 1 if equal, 0 otherwise.
     368 * @param   pszPath1    The first path.
     369 * @param   pszPath2    The second path.
     370 * @param   cch         The number of characters to compare.
     371 */
     372static int ArePathsIdenticalN(const char *pszPath1, const char *pszPath2, size_t cch)
     373{
     374#if defined(__OS2__) || defined(__WIN__)
     375    if (strnicmp(pszPath1, pszPath2, cch))
     376    {
     377        /* Slashes may differ, compare char by char. */
     378        const char *psz1 = pszPath1;
     379        const char *psz2 = pszPath2;
     380        for ( ; cch; psz1++, psz2++, cch--)
    338381        {
    339382            if (*psz1 != *psz2)
     
    372415     * This is indeed a bit tricky, so we'll try the easy way first...
    373416     */
    374     if (ArePathsIdentical(pszPath, pszDir, cchDir))
     417    if (ArePathsIdenticalN(pszPath, pszDir, cchDir))
    375418    {
    376419        if (pszPath[cchDir])
     
    382425    {
    383426        pszAbsPath = AbsPath(pszPath);
    384         if (ArePathsIdentical(pszAbsPath, pszDir, cchDir))
     427        if (ArePathsIdenticalN(pszAbsPath, pszDir, cchDir))
    385428        {
    386429            if (pszPath[cchDir])
     
    11441187        size_t cch = strlen(papszArgv[i]);
    11451188        if (    cch < cchIgnorePath
    1146             ||  !ArePathsIdentical(papszArgv[i] + cch - cchIgnorePath, pszIgnorePath, cch))
     1189            ||  !ArePathsIdenticalN(papszArgv[i] + cch - cchIgnorePath, pszIgnorePath, cch))
    11471190            kOCSumUpdate(pSum, &Ctx, papszArgv[i], cch + 1);
    11481191    }
     
    15811624
    15821625    errno = 0;
     1626# ifdef __WIN__
     1627    rc = quoted_spawnvp(_P_WAIT, papszArgv[0], papszArgv);
     1628# else
    15831629    rc = _spawnvp(_P_WAIT, papszArgv[0], papszArgv);
     1630# endif
    15841631    if (rc < 0)
    15851632        FatalDie("%s - _spawnvp failed (rc=0x%p): %s\n", pszMsg, rc, strerror(errno));
    15861633    if (rc > 0)
    15871634        FatalDie("%s - failed rc=%d\n", pszMsg, (int)rc);
    1588     if (fdStdOut)
     1635    if (fdStdOut != -1)
    15891636    {
    15901637        close(STDOUT_FILENO);
     
    16841731#if defined(__OS2__) || defined(__WIN__)
    16851732    errno = 0;
     1733# ifdef __WIN__
     1734    pid = quoted_spawnvp(_P_NOWAIT, papszArgv[0], papszArgv);
     1735# else
    16861736    pid = _spawnvp(_P_NOWAIT, papszArgv[0], papszArgv);
     1737# endif
    16871738    if (pid == -1)
    16881739        FatalDie("precompile - _spawnvp failed: %s\n", strerror(errno));
     
    34903541        PKOCDIGEST pDigest = &pCache->paDigests[i];
    34913542        if (ArePathsIdentical(kOCDigestAbsPath(pDigest, pCache->pszDir),
    3492                               kOCEntryAbsPath(pEntry), ~0U))
     3543                              kOCEntryAbsPath(pEntry)))
    34933544        {
    34943545            unsigned cLeft;
Note: See TracChangeset for help on using the changeset viewer.

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