From 64b5520346c75ec479042a114390a0bf71909723 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 6 May 2016 14:19:04 -0400 Subject: 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. --- Source/cmFileCommand.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/cmFileCommand.cxx') diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 575051e610..41b0939fcc 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2436,11 +2436,13 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) { std::ostringstream e; + /* clang-format off */ e << "RPATH_CHANGE could not write new RPATH:\n" << " " << newRPath << "\n" << "to the file:\n" << " " << file << "\n" << emsg; + /* clang-format on */ this->SetError(e.str()); success = false; } @@ -2511,9 +2513,11 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) if(!cmSystemTools::RemoveRPath(file, &emsg, &removed)) { std::ostringstream e; + /* clang-format off */ e << "RPATH_REMOVE could not remove RPATH from file:\n" << " " << file << "\n" << emsg; + /* clang-format on */ this->SetError(e.str()); success = false; } @@ -2668,11 +2672,13 @@ bool cmFileCommand::HandleRename(std::vector const& args) { std::string err = cmSystemTools::GetLastSystemError(); std::ostringstream e; + /* clang-format off */ e << "RENAME failed to rename\n" << " " << oldname << "\n" << "to\n" << " " << newname << "\n" << "because: " << err << "\n"; + /* clang-format on */ this->SetError(e.str()); return false; } -- cgit v1.2.1