VirtualBox

Changeset 76555 in vbox


Ignore:
Timestamp:
Jan 1, 2019 2:08:55 AM (6 years ago)
Author:
vboxsync
Message:

scm: made header guard #endif massaging configurable and for the time being optional.

Location:
trunk/src/bldprogs
Files:
3 edited

Legend:

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

    r76553 r76555  
    7979    SCMOPT_PRAGMA_ONCE,
    8080    SCMOPT_NO_PRAGMA_ONCE,
     81    SCMOPT_FIX_HEADER_GUARD_ENDIF,
     82    SCMOPT_NO_FIX_HEADER_GUARD_ENDIF,
    8183    SCMOPT_ENDIF_GUARD_COMMENT,
    8284    SCMOPT_NO_ENDIF_GUARD_COMMENT,
     
    185187    /* .fFixHeaderGuards = */                       true,
    186188    /* .fPragmaOnce = */                            true,
     189    /* .fFixHeaderGuardEndif = */                   false,
    187190    /* .fEndifGuardComment = */                     true,
    188191    /* .pszGuardPrefix = */                         (char *)"VBOX_INCLUDED_",
     
    232235    { "--pragma-once",                      SCMOPT_PRAGMA_ONCE,                     RTGETOPT_REQ_NOTHING },
    233236    { "--no-pragma-once",                   SCMOPT_NO_PRAGMA_ONCE,                  RTGETOPT_REQ_NOTHING },
     237    { "--fix-header-guard-endif",           SCMOPT_FIX_HEADER_GUARD_ENDIF,          RTGETOPT_REQ_NOTHING },
     238    { "--no-fix-header-guard-endif",        SCMOPT_NO_FIX_HEADER_GUARD_ENDIF,       RTGETOPT_REQ_NOTHING },
    234239    { "--endif-guard-comment",              SCMOPT_ENDIF_GUARD_COMMENT,             RTGETOPT_REQ_NOTHING },
    235240    { "--no-endif-guard-comment",           SCMOPT_NO_ENDIF_GUARD_COMMENT,          RTGETOPT_REQ_NOTHING },
     
    10601065        case SCMOPT_NO_PRAGMA_ONCE:
    10611066            pSettings->fPragmaOnce = false;
     1067            return VINF_SUCCESS;
     1068
     1069        case SCMOPT_FIX_HEADER_GUARD_ENDIF:
     1070            pSettings->fFixHeaderGuardEndif = true;
     1071            return VINF_SUCCESS;
     1072        case SCMOPT_NO_FIX_HEADER_GUARD_ENDIF:
     1073            pSettings->fFixHeaderGuardEndif = false;
    10621074            return VINF_SUCCESS;
    10631075
     
    27752787                RTPrintf("      Whether to include #pragma once with the header guard.  Default: %RTbool\n", g_Defaults.fPragmaOnce);
    27762788                break;
     2789            case SCMOPT_FIX_HEADER_GUARD_ENDIF:
     2790                RTPrintf("      Whether to fix the #endif of a header guard.  Default: %RTbool\n", g_Defaults.fFixHeaderGuardEndif);
     2791                break;
    27772792            case SCMOPT_ENDIF_GUARD_COMMENT:
    27782793                RTPrintf("      Put a comment on the header guard #endif or not.  Default: %RTbool\n", g_Defaults.fEndifGuardComment);
  • trunk/src/bldprogs/scm.h

    r76553 r76555  
    338338    /** Whether to include a pragma once statement with the header guard. */
    339339    bool            fPragmaOnce;
     340    /** Whether to fix the \#endif part of a header guard. */
     341    bool            fFixHeaderGuardEndif;
    340342    /** Whether to add a comment on the \#endif part of the header guard. */
    341343    bool            fEndifGuardComment;
  • trunk/src/bldprogs/scmrw.cpp

    r76554 r76555  
    31283128     * right kind of comment following it.
    31293129     */
    3130 #if 0
    3131     if (iEndIfOut == 0)
    3132         return ScmError(pState, VERR_PARSE_ERROR, "Expected '#endif' at the end of the file...\n");
    3133     rc = ScmStreamSeekByLine(pIn, iEndIfIn);
    3134     if (RT_FAILURE(rc))
    3135         return false;
    3136     rc = ScmStreamSeekByLine(pOut, iEndIfOut);
    3137     if (RT_FAILURE(rc))
    3138         return false;
    3139 
    3140     pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol);
    3141     if (!pchLine)
    3142         return ScmError(pState, VERR_INTERNAL_ERROR, "ScmStreamGetLine failed re-reading #endif!\n");
    3143 
    3144     char   szTmp[64 + sizeof(szNormalized)];
    3145     size_t cchTmp;
    3146     if (pSettings->fEndifGuardComment)
    3147         cchTmp = RTStrPrintf(szTmp, sizeof(szTmp), "#endif /* !%.*s */", Guard.cch, Guard.psz);
    3148     else
    3149         cchTmp = RTStrPrintf(szTmp, sizeof(szTmp), "#endif"); /* lazy bird */
    3150     fRet |= cchTmp != cchLine || memcmp(szTmp, pchLine, cchTmp) != 0;
    3151     rc = ScmStreamPutLine(pOut, szTmp, cchTmp, enmEol);
    3152     if (RT_FAILURE(rc))
    3153         return false;
    3154 
    3155     /* Copy out the remaining lines (assumes no #pragma once here). */
    3156     while ((pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol)) != NULL)
    3157     {
    3158         rc = ScmStreamPutLine(pOut, pchLine, cchLine, enmEol);
     3130    if (pSettings->fFixHeaderGuardEndif)
     3131    {
     3132        if (iEndIfOut == 0)
     3133            return ScmError(pState, VERR_PARSE_ERROR, "Expected '#endif' at the end of the file...\n");
     3134        rc = ScmStreamSeekByLine(pIn, iEndIfIn);
    31593135        if (RT_FAILURE(rc))
    31603136            return false;
    3161     }
    3162 #else
    3163     RT_NOREF(iEndIfOut, iEndIfIn);
    3164 #endif
     3137        rc = ScmStreamSeekByLine(pOut, iEndIfOut);
     3138        if (RT_FAILURE(rc))
     3139            return false;
     3140
     3141        pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol);
     3142        if (!pchLine)
     3143            return ScmError(pState, VERR_INTERNAL_ERROR, "ScmStreamGetLine failed re-reading #endif!\n");
     3144
     3145        char   szTmp[64 + sizeof(szNormalized)];
     3146        size_t cchTmp;
     3147        if (pSettings->fEndifGuardComment)
     3148            cchTmp = RTStrPrintf(szTmp, sizeof(szTmp), "#endif /* !%.*s */", Guard.cch, Guard.psz);
     3149        else
     3150            cchTmp = RTStrPrintf(szTmp, sizeof(szTmp), "#endif"); /* lazy bird */
     3151        fRet |= cchTmp != cchLine || memcmp(szTmp, pchLine, cchTmp) != 0;
     3152        rc = ScmStreamPutLine(pOut, szTmp, cchTmp, enmEol);
     3153        if (RT_FAILURE(rc))
     3154            return false;
     3155
     3156        /* Copy out the remaining lines (assumes no #pragma once here). */
     3157        while ((pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol)) != NULL)
     3158        {
     3159            rc = ScmStreamPutLine(pOut, pchLine, cchLine, enmEol);
     3160            if (RT_FAILURE(rc))
     3161                return false;
     3162        }
     3163    }
    31653164
    31663165    return fRet;
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