From e399236be3482e945afaa12ab6acc05a9eb1bb77 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 18 Sep 2013 11:23:47 +0200 Subject: Improve C++ indenter by handling '},' sequence --- cutl/compiler/cxx-indenter.txx | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'cutl/compiler') diff --git a/cutl/compiler/cxx-indenter.txx b/cutl/compiler/cxx-indenter.txx index 67f9bf0..c3930b3 100644 --- a/cutl/compiler/cxx-indenter.txx +++ b/cutl/compiler/cxx-indenter.txx @@ -376,6 +376,49 @@ namespace cutl break; } + case ',': + { + if (construct_ == con_other) + { + // Handling '},' case. + // + + bool brace (false); + + if (hold_.size () > 1 && hold_.back () == '\n') + { + bool pop_nl (false); + + for (typename hold::reverse_iterator + i (hold_.rbegin ()), e (hold_.rend ()); + i != e; ++i) + { + if (*i != '\n') + { + if (*i == '}') + brace = pop_nl = true; + + break; + } + } + + if (pop_nl) + while (hold_.back () == '\n') + hold_.pop_back (); + } + + output_indentation (); + write (c); + position_++; + + if (brace) + hold_.push_back ('\n'); + } + else + defaulting = true; + + break; + } case ' ': { if (construct_ == con_other) -- cgit v1.1