Changeset 92185 in vbox for trunk/src/bldprogs
- Timestamp:
- Nov 2, 2021 9:52:35 PM (3 years ago)
- Location:
- trunk/src/bldprogs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/scm.cpp
r82968 r92185 115 115 SCMOPT_SKIP_SVN_SYNC_PROCESS, 116 116 SCMOPT_DONT_SKIP_SVN_SYNC_PROCESS, 117 SCMOPT_SKIP_UNICODE_CHECKS, 118 SCMOPT_DONT_SKIP_UNICODE_CHECKS, 117 119 SCMOPT_TAB_SIZE, 118 120 SCMOPT_WIDTH, … … 203 205 /* .fSetSvnKeywords = */ false, 204 206 /* .fSkipSvnSyncProcess = */ false, 207 /* .fSkipUnicodeChecks = */ false, 205 208 /* .cchTab = */ 8, 206 209 /* .cchWidth = */ 130, … … 266 269 { "--skip-svn-sync-process", SCMOPT_SKIP_SVN_SYNC_PROCESS, RTGETOPT_REQ_NOTHING }, 267 270 { "--dont-skip-svn-sync-process", SCMOPT_DONT_SKIP_SVN_SYNC_PROCESS, RTGETOPT_REQ_NOTHING }, 271 { "--skip-unicode-checks", SCMOPT_SKIP_UNICODE_CHECKS, RTGETOPT_REQ_NOTHING }, 272 { "--dont-skip-unicode-checks", SCMOPT_DONT_SKIP_UNICODE_CHECKS, RTGETOPT_REQ_NOTHING }, 268 273 { "--tab-size", SCMOPT_TAB_SIZE, RTGETOPT_REQ_UINT8 }, 269 274 { "--width", SCMOPT_WIDTH, RTGETOPT_REQ_UINT8 }, … … 305 310 SCM_REWRITER_CFG(g_SvnKeywords, "svn-keywords", rewrite_SvnKeywords); 306 311 SCM_REWRITER_CFG(g_SvnSyncProcess, "svn-sync-process", rewrite_SvnSyncProcess); 312 SCM_REWRITER_CFG(g_UnicodeChecks, "unicode-checks", rewrite_UnicodeChecks); 307 313 SCM_REWRITER_CFG(g_Copyright_CstyleComment, "copyright-c-style", rewrite_Copyright_CstyleComment); 308 314 SCM_REWRITER_CFG(g_Copyright_HashComment, "copyright-hash-style", rewrite_Copyright_HashComment); … … 348 354 &g_Fix_C_and_CPP_Todos, 349 355 &g_Fix_Err_H, 356 &g_UnicodeChecks, 350 357 &g_C_and_CPP, 351 358 }; … … 356 363 &g_SvnNoExecutable, 357 364 &g_SvnSyncProcess, 365 &g_UnicodeChecks, 358 366 &g_Makefile_kup 359 367 }; … … 367 375 &g_SvnKeywords, 368 376 &g_SvnSyncProcess, 377 &g_UnicodeChecks, 369 378 &g_Copyright_HashComment, 370 379 &g_Makefile_kmk … … 379 388 &g_SvnKeywords, 380 389 &g_SvnSyncProcess, 390 &g_UnicodeChecks, 381 391 &g_Copyright_HashComment, 382 392 }; … … 391 401 &g_SvnKeywords, 392 402 &g_SvnSyncProcess, 403 &g_UnicodeChecks, 393 404 &g_Copyright_CstyleComment, 394 405 &g_FixFlowerBoxMarkers, 395 406 &g_Fix_C_and_CPP_Todos, 396 407 &g_Fix_Err_H, 397 &g_C_and_CPP 408 &g_C_and_CPP, 398 409 }; 399 410 … … 407 418 &g_SvnKeywords, 408 419 &g_SvnSyncProcess, 420 &g_UnicodeChecks, 409 421 &g_Copyright_CstyleComment, 410 422 /// @todo &g_FixFlowerBoxMarkers, … … 422 434 &g_SvnKeywords, 423 435 &g_SvnSyncProcess, 436 &g_UnicodeChecks, 424 437 &g_Copyright_CstyleComment, 425 438 }; … … 433 446 &g_SvnKeywords, 434 447 &g_SvnSyncProcess, 448 &g_UnicodeChecks, 435 449 &g_Copyright_CstyleComment, 436 450 }; … … 445 459 &g_SvnKeywords, 446 460 &g_SvnSyncProcess, 461 &g_UnicodeChecks, 447 462 &g_Copyright_CstyleComment, 448 463 }; … … 457 472 &g_SvnKeywords, 458 473 &g_SvnSyncProcess, 474 &g_UnicodeChecks, 459 475 &g_Copyright_SemicolonComment, 460 476 }; … … 469 485 &g_SvnKeywords, 470 486 &g_SvnSyncProcess, 487 &g_UnicodeChecks, 471 488 &g_Copyright_SemicolonComment, 472 489 }; … … 478 495 &g_StripTrailingBlanks, 479 496 &g_SvnSyncProcess, 497 &g_UnicodeChecks, 480 498 &g_Copyright_HashComment, 481 499 }; … … 487 505 &g_StripTrailingBlanks, 488 506 &g_SvnSyncProcess, 507 &g_UnicodeChecks, 489 508 &g_Copyright_RemComment, 490 509 }; … … 496 515 &g_StripTrailingBlanks, 497 516 &g_SvnSyncProcess, 517 &g_UnicodeChecks, 498 518 &g_Copyright_TickComment, 499 519 }; … … 505 525 &g_StripTrailingBlanks, 506 526 &g_SvnSyncProcess, 527 &g_UnicodeChecks, 507 528 &g_Copyright_HashComment, 508 529 }; … … 516 537 &g_SvnKeywords, 517 538 &g_SvnSyncProcess, 539 &g_UnicodeChecks, 518 540 &g_Copyright_PythonComment, 519 541 }; … … 527 549 &g_SvnKeywords, 528 550 &g_SvnSyncProcess, 551 &g_UnicodeChecks, 529 552 &g_Copyright_HashComment, 530 553 }; … … 539 562 &g_SvnNoExecutable, 540 563 &g_SvnSyncProcess, 564 &g_UnicodeChecks, 541 565 &g_Copyright_SemicolonComment, 542 566 }; … … 551 575 &g_SvnNoExecutable, 552 576 &g_SvnSyncProcess, 577 &g_UnicodeChecks, 553 578 &g_Copyright_SemicolonComment, 554 579 }; … … 563 588 &g_SvnKeywords, 564 589 &g_SvnSyncProcess, 590 &g_UnicodeChecks, 565 591 &g_Copyright_CstyleComment, 566 592 &g_FixFlowerBoxMarkers, … … 577 603 &g_SvnKeywords, 578 604 &g_SvnSyncProcess, 605 &g_UnicodeChecks, 579 606 &g_Copyright_HashComment, 580 607 }; … … 596 623 &g_SvnKeywords, 597 624 &g_SvnSyncProcess, 625 &g_UnicodeChecks, 598 626 /** @todo copyright is in an XML comment. */ 599 627 }; … … 608 636 &g_SvnKeywords, 609 637 &g_SvnSyncProcess, 638 &g_UnicodeChecks, 610 639 /** @todo copyright is in an XML comment. */ 611 640 }; … … 620 649 &g_SvnKeywords, 621 650 &g_SvnSyncProcess, 651 &g_UnicodeChecks, 622 652 /** @todo copyright is in an XML comment. */ 623 653 }; … … 631 661 &g_SvnKeywords, 632 662 &g_SvnSyncProcess, 663 &g_UnicodeChecks, 633 664 &g_Copyright_HashComment, 634 665 }; … … 640 671 &g_SvnKeywords, 641 672 &g_SvnSyncProcess, 673 &g_UnicodeChecks, 642 674 /** @todo figure out copyright for Qt resource XML files. */ 643 675 }; … … 655 687 &g_SvnKeywords, 656 688 &g_SvnSyncProcess, 689 &g_UnicodeChecks, 657 690 /** @todo copyright is in an XML 'comment' element. */ 658 691 }; … … 667 700 &g_SvnNoExecutable, 668 701 &g_SvnSyncProcess, 702 &g_UnicodeChecks, 669 703 &g_Copyright_SemicolonComment, 670 704 }; … … 679 713 &g_SvnNoExecutable, 680 714 &g_SvnSyncProcess, 715 &g_UnicodeChecks, 681 716 &g_Copyright_SqlComment, 682 717 }; … … 691 726 &g_SvnNoExecutable, 692 727 &g_SvnSyncProcess, 728 &g_UnicodeChecks, 693 729 &g_Copyright_CstyleComment, 694 730 }; … … 701 737 &g_SvnNoExecutable, 702 738 &g_SvnSyncProcess, 739 &g_UnicodeChecks, 703 740 /** @todo check for plain copyright + license in text files. */ 704 741 }; … … 711 748 &g_SvnNoExecutable, 712 749 &g_SvnSyncProcess, 750 &g_UnicodeChecks, 713 751 }; 714 752 … … 726 764 &g_AdjustTrailingLines, 727 765 &g_SvnSyncProcess, 766 &g_UnicodeChecks, 728 767 &g_Copyright_HashComment, 729 768 }; … … 1213 1252 case SCMOPT_DONT_SKIP_SVN_SYNC_PROCESS: 1214 1253 pSettings->fSkipSvnSyncProcess = false; 1254 return VINF_SUCCESS; 1255 1256 case SCMOPT_SKIP_UNICODE_CHECKS: 1257 pSettings->fSkipUnicodeChecks = true; 1258 return VINF_SUCCESS; 1259 case SCMOPT_DONT_SKIP_UNICODE_CHECKS: 1260 pSettings->fSkipUnicodeChecks = false; 1215 1261 return VINF_SUCCESS; 1216 1262 … … 2829 2875 case SCMOPT_SET_SVN_KEYWORDS: RTPrintf(" Default: %RTbool\n", g_Defaults.fSetSvnKeywords); break; 2830 2876 case SCMOPT_SKIP_SVN_SYNC_PROCESS: RTPrintf(" Default: %RTbool\n", g_Defaults.fSkipSvnSyncProcess); break; 2877 case SCMOPT_SKIP_UNICODE_CHECKS: RTPrintf(" Default: %RTbool\n", g_Defaults.fSkipUnicodeChecks); break; 2831 2878 case SCMOPT_TAB_SIZE: RTPrintf(" Default: %u\n", g_Defaults.cchTab); break; 2832 2879 case SCMOPT_WIDTH: RTPrintf(" Default: %u\n", g_Defaults.cchWidth); break; -
trunk/src/bldprogs/scm.h
r85121 r92185 250 250 FNSCMREWRITER rewrite_SvnKeywords; 251 251 FNSCMREWRITER rewrite_SvnSyncProcess; 252 FNSCMREWRITER rewrite_UnicodeChecks; 252 253 FNSCMREWRITER rewrite_Copyright_CstyleComment; 253 254 FNSCMREWRITER rewrite_Copyright_HashComment; … … 374 375 /** Skip checking svn:sync-process. */ 375 376 bool fSkipSvnSyncProcess; 377 /** Skip the unicode checks. */ 378 bool fSkipUnicodeChecks; 376 379 /** Tab size. */ 377 380 uint8_t cchTab; -
trunk/src/bldprogs/scmrw.cpp
r82968 r92185 1059 1059 else if (rc != VERR_NOT_FOUND) 1060 1060 ScmError(pState, rc, "ScmSvnQueryProperty: %Rrc\n", rc); 1061 1062 return false; 1063 } 1064 1065 /** 1066 * Checks the that there is no bidirectional unicode fun in the file. 1067 * 1068 * @returns false - the state carries these kinds of changes. 1069 * @param pState The rewriter state. 1070 * @param pIn The input stream. 1071 * @param pOut The output stream. 1072 * @param pSettings The settings. 1073 */ 1074 bool rewrite_UnicodeChecks(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings) 1075 { 1076 RT_NOREF2(pIn, pOut); 1077 if (pSettings->fSkipUnicodeChecks) 1078 return false; 1079 1080 /* 1081 * Just scan the input for weird stuff and fail if we find anything we don't like. 1082 */ 1083 uint32_t iLine = 0; 1084 SCMEOL enmEol; 1085 size_t cchLine; 1086 const char *pchLine; 1087 while ((pchLine = ScmStreamGetLine(pIn, &cchLine, &enmEol)) != NULL) 1088 { 1089 iLine++; 1090 const char *pchCur = pchLine; 1091 size_t cchLeft = cchLine; 1092 while (cchLeft > 0) 1093 { 1094 RTUNICP uc = 0; 1095 int rc = RTStrGetCpNEx(&pchCur, &cchLeft, &uc); 1096 if (RT_SUCCESS(rc)) 1097 { 1098 const char *pszWhat; 1099 switch (uc) 1100 { 1101 default: 1102 continue; 1103 1104 /* Potentially evil bi-directional control codes (Table I, trojan-source.pdf): */ 1105 case 0x202a: pszWhat = "LRE - left-to-right embedding"; break; 1106 case 0x202b: pszWhat = "RLE - right-to-left embedding"; break; 1107 case 0x202d: pszWhat = "LRO - left-to-right override"; break; 1108 case 0x202e: pszWhat = "RLO - right-to-left override"; break; 1109 case 0x2066: pszWhat = "LRI - left-to-right isolate"; break; 1110 case 0x2067: pszWhat = "RLI - right-to-left isolate"; break; 1111 case 0x2068: pszWhat = "FSI - first strong isolate"; break; 1112 case 0x202c: pszWhat = "PDF - pop directional formatting (LRE, RLE, LRO, RLO)"; break; 1113 case 0x2069: pszWhat = "PDI - pop directional isolate (LRI, RLI)"; break; 1114 1115 /** @todo add checks for homoglyphs too. */ 1116 } 1117 #if 1 1118 ScmError(pState, rc, "%u:%zu: Evil unicode codepoint: %s\n", iLine, pchCur - pchLine, pszWhat); 1119 #else 1120 ScmVerbose(pState, 0, "%u:%zu: Evil unicode codepoint: %s\n", iLine, pchCur - pchLine, pszWhat); 1121 #endif 1122 } 1123 else 1124 #if 1 1125 ScmError(pState, rc, "%u:%zu: Invalid UTF-8 encoding: %Rrc\n", iLine, pchCur - pchLine, rc); 1126 #else 1127 ScmVerbose(pState, 0, "%u:%zu: Invalid UTF-8 encoding: %Rrc\n", iLine, pchCur - pchLine, rc); 1128 #endif 1129 } 1130 } 1061 1131 1062 1132 return false;
Note:
See TracChangeset
for help on using the changeset viewer.