VirtualBox

Changeset 76572 in vbox for trunk/src/bldprogs


Ignore:
Timestamp:
Jan 1, 2019 4:55:08 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127874
Message:

scm: Added header relative dir specs.

Location:
trunk/src/bldprogs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bldprogs/scm.cpp

    r76555 r76572  
    10911091            if (*pValueUnion->psz != '\0')
    10921092            {
     1093                if (   strcmp(pValueUnion->psz, "{dir}") == 0
     1094                    || strcmp(pValueUnion->psz, "{parent}") == 0)
     1095                    return RTStrDupEx(&pSettings->pszGuardRelativeToDir, pValueUnion->psz);
    10931096                if (cchDir == 1 && *pchDir == '/')
    10941097                {
     
    27952798            case SCMOPT_GUARD_RELATIVE_TO_DIR:
    27962799                RTPrintf("      Header guard should be normalized relative to given dir.\n"
     2800                         "      When relative to settings files, no preceeding slash.\n"
     2801                         "      Header relative directory specification: {dir} and {parent}\n"
    27972802                         "      If empty no normalization takes place.  Default: '%s'\n", g_Defaults.pszGuardRelativeToDir);
    27982803                break;
  • trunk/src/bldprogs/scmrw.cpp

    r76556 r76572  
    28792879            return ScmError(pState, rc, "Guard prefix too long (or something): %s\n", pSettings->pszGuardPrefix);
    28802880        cchNormalized = strlen(szNormalized);
    2881         rc = RTPathCalcRelative(&szNormalized[cchNormalized], sizeof(szNormalized) - cchNormalized,
    2882                                 pSettings->pszGuardRelativeToDir, pState->pszFilename);
     2881        if (strcmp(pSettings->pszGuardRelativeToDir, "{dir}") == 0)
     2882            rc = RTStrCopy(&szNormalized[cchNormalized], sizeof(szNormalized) - cchNormalized,
     2883                           RTPathFilename(pState->pszFilename));
     2884        else if (strcmp(pSettings->pszGuardRelativeToDir, "{parent}") == 0)
     2885        {
     2886            const char *pszSrc = RTPathFilename(pState->pszFilename);
     2887            if (!pszSrc || (uintptr_t)&pszSrc[-2] < (uintptr_t)pState->pszFilename || !RTPATH_IS_SLASH(pszSrc[-1]))
     2888                return ScmError(pState, VERR_INTERNAL_ERROR, "Error calculating {parent} header guard!\n");
     2889            pszSrc -= 2;
     2890            while (   (uintptr_t)pszSrc > (uintptr_t)pState->pszFilename
     2891                   && !RTPATH_IS_SLASH(pszSrc[-1])
     2892                   && !RTPATH_IS_VOLSEP(pszSrc[-1]))
     2893                pszSrc--;
     2894            rc = RTStrCopy(&szNormalized[cchNormalized], sizeof(szNormalized) - cchNormalized, pszSrc);
     2895        }
     2896        else
     2897            rc = RTPathCalcRelative(&szNormalized[cchNormalized], sizeof(szNormalized) - cchNormalized,
     2898                                    pSettings->pszGuardRelativeToDir, pState->pszFilename);
    28832899        if (RT_FAILURE(rc))
    28842900            return ScmError(pState, rc, "Error calculating guard prefix (RTPathCalcRelative): %Rrc\n", rc);
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