From 531cffe4fc38f589f9101e6919a880e1722d0115 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 27 May 2018 04:28:39 -0500 Subject: [PATCH] Bugfix: Use a different sentinel in indent We cannot simply replace the escaped closing bracket "\}" by "} //" any more. clang-format happily fixes the apparent misspelling into namespace Foobar { } // namespace Foobar --- contrib/utilities/indent | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/utilities/indent b/contrib/utilities/indent index f09166a19d..d7778cb825 100755 --- a/contrib/utilities/indent +++ b/contrib/utilities/indent @@ -96,19 +96,22 @@ find tests include source examples \ xargs -0 -n 1 -P 10 -I {} bash -c 'dos_to_unix "$@"' _ {} # -# format .inst.in files. We need to replace \{ and \} because it confuses -# clang-format +# format .inst.in files. We need to replace \{ and \} by a sentinel because +# clang-format happily strips away the backslash. Further, there is a minor +# caveat: clang-format automatically renames a comment after a closing +# bracket for a namespace to "} // namespace FooBar". Thus use "namespace" +# as keyword: # format_inst() { f=$1 cp "$f" "$f.tmp" - sed -i.orig 's#\\{#{ //#g' "$f.tmp" - sed -i.orig 's#\\}#} //#g' "$f.tmp" + sed -i.orig 's#\\{#{ // namespace#g' "$f.tmp" + sed -i.orig 's#\\}#} // namespace#g' "$f.tmp" clang-format -i "$f.tmp" - sed -i.orig 's#{ //#\\{#g' "$f.tmp" - sed -i.orig 's#} //#\\}#g' "$f.tmp" + sed -i.orig 's#{ // namespace#\\{#g' "$f.tmp" + sed -i.orig 's#}[ ]*// namespace.*#\\}#g' "$f.tmp" if ! diff -q "$f" "$f.tmp" >/dev/null then cp "$f.tmp" "$f" -- 2.39.5