diff options
author | Brad King <brad.king@kitware.com> | 2016-05-06 14:19:04 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-06 14:25:55 -0400 |
commit | 64b5520346c75ec479042a114390a0bf71909723 (patch) | |
tree | bea1373e84594ba036fe50eea3eab86375d63aa6 /Source/cmGlobalVisualStudio7Generator.cxx | |
parent | 73601ff831faa80a188e5997ee048b6986b00a5c (diff) | |
download | cmake-64b5520346c75ec479042a114390a0bf71909723.tar.gz |
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.
Diffstat (limited to 'Source/cmGlobalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 058183cf87..a5ee336d43 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -704,6 +704,7 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend( fout.SetCopyIfDifferent(true); std::string guid = this->GetGUID(pname.c_str()); + /* clang-format off */ fout << "<?xml version=\"1.0\" encoding = \"" << this->Encoding() << "\"?>\n" @@ -716,9 +717,11 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend( "\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n" "\t<Configurations>\n" ; + /* clang-format on */ for(std::vector<std::string>::iterator i = configs.begin(); i != configs.end(); ++i) { + /* clang-format off */ fout << "\t\t<Configuration\n" "\t\t\tName=\"" << *i << "|Win32\"\n" @@ -730,13 +733,16 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend( "\t\t\tCharacterSet=\"2\">\n" "\t\t</Configuration>\n" ; + /* clang-format on */ } + /* clang-format off */ fout << "\t</Configurations>\n" "\t<Files></Files>\n" "\t<Globals></Globals>\n" "</VisualStudioProject>\n" ; + /* clang-format on */ if(fout.Close()) { |