Changeset 76555 in vbox
- Timestamp:
- Jan 1, 2019 2:08:55 AM (6 years ago)
- Location:
- trunk/src/bldprogs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scm.cpp
r76553 r76555 79 79 SCMOPT_PRAGMA_ONCE, 80 80 SCMOPT_NO_PRAGMA_ONCE, 81 SCMOPT_FIX_HEADER_GUARD_ENDIF, 82 SCMOPT_NO_FIX_HEADER_GUARD_ENDIF, 81 83 SCMOPT_ENDIF_GUARD_COMMENT, 82 84 SCMOPT_NO_ENDIF_GUARD_COMMENT, … … 185 187 /* .fFixHeaderGuards = */ true, 186 188 /* .fPragmaOnce = */ true, 189 /* .fFixHeaderGuardEndif = */ false, 187 190 /* .fEndifGuardComment = */ true, 188 191 /* .pszGuardPrefix = */ (char *)"VBOX_INCLUDED_", … … 232 235 { "--pragma-once", SCMOPT_PRAGMA_ONCE, RTGETOPT_REQ_NOTHING }, 233 236 { "--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 }, 234 239 { "--endif-guard-comment", SCMOPT_ENDIF_GUARD_COMMENT, RTGETOPT_REQ_NOTHING }, 235 240 { "--no-endif-guard-comment", SCMOPT_NO_ENDIF_GUARD_COMMENT, RTGETOPT_REQ_NOTHING }, … … 1060 1065 case SCMOPT_NO_PRAGMA_ONCE: 1061 1066 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; 1062 1074 return VINF_SUCCESS; 1063 1075 … … 2775 2787 RTPrintf(" Whether to include #pragma once with the header guard. Default: %RTbool\n", g_Defaults.fPragmaOnce); 2776 2788 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; 2777 2792 case SCMOPT_ENDIF_GUARD_COMMENT: 2778 2793 RTPrintf(" Put a comment on the header guard #endif or not. Default: %RTbool\n", g_Defaults.fEndifGuardComment); -
trunk/src/bldprogs/scm.h
r76553 r76555 338 338 /** Whether to include a pragma once statement with the header guard. */ 339 339 bool fPragmaOnce; 340 /** Whether to fix the \#endif part of a header guard. */ 341 bool fFixHeaderGuardEndif; 340 342 /** Whether to add a comment on the \#endif part of the header guard. */ 341 343 bool fEndifGuardComment; -
trunk/src/bldprogs/scmrw.cpp
r76554 r76555 3128 3128 * right kind of comment following it. 3129 3129 */ 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); 3159 3135 if (RT_FAILURE(rc)) 3160 3136 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 } 3165 3164 3166 3165 return fRet;
Note:
See TracChangeset
for help on using the changeset viewer.