Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but well-organized streaming blocks are best left manually formatted. Find blocks of the form os << "...\n" "...\n" ; using the command $ git ls-files -z -- Source | egrep -v -z '^Source/kwsys/' | xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \ '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}' Find blocks of the form os << "...\n" << "...\n" << "...\n"; using the command $ git ls-files -z -- Source | egrep -v -z '^Source/kwsys/' | xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \ '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}' Surround such blocks with the pair /* clang-format off */ ... /* clang-format on */ in order to protect them from update by clang-format. Use the C-style `/*...*/` comments instead of C++-style `//...` comments in order to prevent them from ever being swallowed by re-formatting of surrounding comments.
Showing
- Source/CPack/cmCPackNSISGenerator.cxx 2 additions, 0 deletionsSource/CPack/cmCPackNSISGenerator.cxx
- Source/CTest/cmCTestBuildCommand.cxx 2 additions, 0 deletionsSource/CTest/cmCTestBuildCommand.cxx
- Source/CTest/cmCTestCVS.cxx 2 additions, 0 deletionsSource/CTest/cmCTestCVS.cxx
- Source/CTest/cmCTestGlobalVC.cxx 2 additions, 0 deletionsSource/CTest/cmCTestGlobalVC.cxx
- Source/CTest/cmCTestMultiProcessHandler.cxx 2 additions, 0 deletionsSource/CTest/cmCTestMultiProcessHandler.cxx
- Source/CTest/cmCTestSubmitHandler.cxx 2 additions, 0 deletionsSource/CTest/cmCTestSubmitHandler.cxx
- Source/cmAddCustomTargetCommand.cxx 2 additions, 0 deletionsSource/cmAddCustomTargetCommand.cxx
- Source/cmAddExecutableCommand.cxx 2 additions, 0 deletionsSource/cmAddExecutableCommand.cxx
- Source/cmCacheManager.cxx 4 additions, 0 deletionsSource/cmCacheManager.cxx
- Source/cmComputeLinkInformation.cxx 8 additions, 0 deletionsSource/cmComputeLinkInformation.cxx
- Source/cmConfigureFileCommand.cxx 2 additions, 0 deletionsSource/cmConfigureFileCommand.cxx
- Source/cmCoreTryCompile.cxx 6 additions, 0 deletionsSource/cmCoreTryCompile.cxx
- Source/cmDocumentation.cxx 4 additions, 0 deletionsSource/cmDocumentation.cxx
- Source/cmExportCommand.cxx 2 additions, 0 deletionsSource/cmExportCommand.cxx
- Source/cmExportFileGenerator.cxx 22 additions, 0 deletionsSource/cmExportFileGenerator.cxx
- Source/cmExportInstallFileGenerator.cxx 8 additions, 0 deletionsSource/cmExportInstallFileGenerator.cxx
- Source/cmExtraCodeBlocksGenerator.cxx 2 additions, 0 deletionsSource/cmExtraCodeBlocksGenerator.cxx
- Source/cmExtraKateGenerator.cxx 4 additions, 0 deletionsSource/cmExtraKateGenerator.cxx
- Source/cmFileCommand.cxx 6 additions, 0 deletionsSource/cmFileCommand.cxx
- Source/cmFindPackageCommand.cxx 2 additions, 0 deletionsSource/cmFindPackageCommand.cxx
Loading
Please register or sign in to comment