Changeset 94905 in vbox
- Timestamp:
- May 7, 2022 4:10:49 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151312
- Location:
- trunk/src/bldprogs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scm.cpp
r94038 r94905 93 93 SCMOPT_UNRESTRICTED_ASM_MEM_PAGE_USE, 94 94 SCMOPT_NO_PAGE_RESTRICTIONS, 95 SCMOPT_NO_RC_USE, 96 SCMOPT_UNRESTRICTED_RC_USE, 95 97 SCMOPT_UPDATE_COPYRIGHT_YEAR, 96 98 SCMOPT_NO_UPDATE_COPYRIGHT_YEAR, … … 202 204 /* .fOnlyGuestHostPage = */ false, 203 205 /* .fNoASMMemPageUse = */ false, 206 /* .fOnlyHrcVrcInsteadOfRc */ false, 204 207 /* .fUpdateCopyrightYear = */ false, 205 208 /* .fExternalCopyright = */ false, … … 259 262 { "--no-ASMMemPage-use", SCMOPT_NO_ASM_MEM_PAGE_USE, RTGETOPT_REQ_NOTHING }, 260 263 { "--unrestricted-ASMMemPage-use", SCMOPT_UNRESTRICTED_ASM_MEM_PAGE_USE, RTGETOPT_REQ_NOTHING }, 264 { "--no-rc-use", SCMOPT_NO_RC_USE, RTGETOPT_REQ_NOTHING }, 265 { "--unrestricted-rc-use", SCMOPT_UNRESTRICTED_RC_USE, RTGETOPT_REQ_NOTHING }, 261 266 { "--update-copyright-year", SCMOPT_UPDATE_COPYRIGHT_YEAR, RTGETOPT_REQ_NOTHING }, 262 267 { "--no-update-copyright-year", SCMOPT_NO_UPDATE_COPYRIGHT_YEAR, RTGETOPT_REQ_NOTHING }, … … 323 328 SCM_REWRITER_CFG(g_UnicodeChecks, "unicode-checks", rewrite_UnicodeChecks); 324 329 SCM_REWRITER_CFG(g_PageChecks, "page-checks", rewrite_PageChecks); 330 SCM_REWRITER_CFG(g_ForceHrcVrcInsteadOfRc, "force-hrc-vrc-no-rc", rewrite_ForceHrcVrcInsteadOfRc); 325 331 SCM_REWRITER_CFG(g_Copyright_CstyleComment, "copyright-c-style", rewrite_Copyright_CstyleComment); 326 332 SCM_REWRITER_CFG(g_Copyright_HashComment, "copyright-hash-style", rewrite_Copyright_HashComment); … … 368 374 &g_UnicodeChecks, 369 375 &g_PageChecks, 376 &g_ForceHrcVrcInsteadOfRc, 370 377 &g_C_and_CPP, 371 378 }; … … 416 423 &g_UnicodeChecks, 417 424 &g_PageChecks, 425 &g_ForceHrcVrcInsteadOfRc, 418 426 &g_Copyright_CstyleComment, 419 427 &g_FixFlowerBoxMarkers, … … 434 442 &g_UnicodeChecks, 435 443 &g_PageChecks, 444 &g_ForceHrcVrcInsteadOfRc, 436 445 &g_Copyright_CstyleComment, 437 446 /// @todo &g_FixFlowerBoxMarkers, … … 1196 1205 case SCMOPT_UNRESTRICTED_ASM_MEM_PAGE_USE: 1197 1206 pSettings->fNoASMMemPageUse = false; 1207 return VINF_SUCCESS; 1208 1209 case SCMOPT_NO_RC_USE: 1210 pSettings->fOnlyHrcVrcInsteadOfRc = true; 1211 return VINF_SUCCESS; 1212 case SCMOPT_UNRESTRICTED_RC_USE: 1213 pSettings->fOnlyHrcVrcInsteadOfRc = false; 1198 1214 return VINF_SUCCESS; 1199 1215 … … 2928 2944 g_Defaults.fNoASMMemPageUse); 2929 2945 break; 2946 case SCMOPT_NO_RC_USE: 2947 RTPrintf(" No rc declaration allowed, must instead use\n" 2948 " vrc for IPRT status codes and hrc for COM status codes. Default: %RTbool\n", 2949 g_Defaults.fOnlyHrcVrcInsteadOfRc); 2950 break; 2930 2951 case SCMOPT_UPDATE_COPYRIGHT_YEAR: 2931 2952 RTPrintf(" Update the copyright year. Default: %RTbool\n", g_Defaults.fUpdateCopyrightYear); -
trunk/src/bldprogs/scm.h
r93556 r94905 254 254 FNSCMREWRITER rewrite_UnicodeChecks; 255 255 FNSCMREWRITER rewrite_PageChecks; 256 FNSCMREWRITER rewrite_ForceHrcVrcInsteadOfRc; 256 257 FNSCMREWRITER rewrite_Copyright_CstyleComment; 257 258 FNSCMREWRITER rewrite_Copyright_HashComment; … … 361 362 /** No ASMMemIsZeroPage or ASMMemZeroPage calls allowed (C/C++). */ 362 363 bool fNoASMMemPageUse; 364 /** No rc declarations allowed, only hrc or vrc depending on the result type. */ 365 bool fOnlyHrcVrcInsteadOfRc; 363 366 364 367 /** Update the copyright year. */ -
trunk/src/bldprogs/scmrw.cpp
r93945 r94905 3334 3334 3335 3335 /** 3336 * Checks for usage of rc in code instead of vrc for IPRT status codes (int) and hrc for COM 3337 * status codes (HRESULT). 3338 * 3339 * @returns true if modifications were made, false if not. 3340 * @param pIn The input stream. 3341 * @param pOut The output stream. 3342 * @param pSettings The settings. 3343 * 3344 * @note Used in Main to avoid ambiguity when just using rc. 3345 */ 3346 bool rewrite_ForceHrcVrcInsteadOfRc(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings) 3347 { 3348 RT_NOREF(pOut); 3349 if (!pSettings->fOnlyHrcVrcInsteadOfRc) 3350 return false; 3351 3352 static const SCMMATCHWORD s_aHresultVrc[] = 3353 { 3354 { RT_STR_TUPLE("HRESULT"), 0, true, false }, 3355 { RT_STR_TUPLE("vrc"), 1, true, false } 3356 }; 3357 3358 static const SCMMATCHWORD s_aIntHrc[] = 3359 { 3360 { RT_STR_TUPLE("int"), 0, true, false }, 3361 { RT_STR_TUPLE("hrc"), 1, true, false } 3362 }; 3363 3364 uint32_t iLine = 0; 3365 SCMEOL enmEol; 3366 size_t cchLine; 3367 const char *pchLine; 3368 RTERRINFOSTATIC ErrInfo; 3369 while ((pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol)) != NULL) 3370 { 3371 iLine++; 3372 3373 /* Look for forbidden declarations first. */ 3374 size_t offNext = 0; 3375 int rc = ScmMatchWords(pchLine, cchLine, s_aHresultVrc, RT_ELEMENTS(s_aHresultVrc), 3376 &offNext, NULL /*paIdentifiers*/, RTErrInfoInitStatic(&ErrInfo)); 3377 if (RT_SUCCESS(rc)) 3378 { 3379 ScmFixManually(pState, "%u:%zu: 'HRESULT vrc' is not allowed! Use 'HRESULT hrc' instead.\n", 3380 iLine, offNext); 3381 continue; 3382 } 3383 3384 rc = ScmMatchWords(pchLine, cchLine, s_aIntHrc, RT_ELEMENTS(s_aIntHrc), 3385 &offNext, NULL /*paIdentifiers*/, RTErrInfoInitStatic(&ErrInfo)); 3386 if (RT_SUCCESS(rc)) 3387 { 3388 ScmFixManually(pState, "%u:%zu: 'int hrc' is not allowed! Use 'int vrc' instead.\n", 3389 iLine, offNext); 3390 continue; 3391 } 3392 3393 const RTSTRTUPLE RcTuple = { RT_STR_TUPLE("rc") }; 3394 size_t const cchWord = RcTuple.cch; 3395 if (cchLine >= cchWord) 3396 { 3397 const char *pchHit = (const char *)memchr(pchLine, *RcTuple.psz, cchLine); 3398 while (pchHit) 3399 { 3400 size_t cchLeft = (uintptr_t)&pchLine[cchLine] - (uintptr_t)pchHit; 3401 if ( cchLeft >= cchWord 3402 && memcmp(pchHit, RcTuple.psz, cchWord) == 0 3403 && ( pchHit == pchLine 3404 || !ScmIsCIdentifierChar(pchHit[-1])) 3405 && ( cchLeft == cchWord 3406 || !ScmIsCIdentifierChar(pchHit[cchWord])) ) 3407 ScmFixManually(pState, "%u:%zu: %s is not allowed! Use hrc or vrc instead.\n", 3408 iLine, pchHit - pchLine + 1, RcTuple.psz); 3409 3410 /* next */ 3411 cchLeft -= 1; 3412 if (cchLeft < cchWord) 3413 break; 3414 pchHit = (const char *)memchr(pchHit + 1, *RcTuple.psz, cchLeft); 3415 } 3416 } 3417 } 3418 3419 return false; 3420 } 3421 3422 3423 /** 3336 3424 * Rewrite a C/C++ source or header file. 3337 3425 *
Note:
See TracChangeset
for help on using the changeset viewer.