aboutsummaryrefslogtreecommitdiff
path: root/cutl/compiler/cxx-indenter.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-18 11:23:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-18 11:23:47 +0200
commite399236be3482e945afaa12ab6acc05a9eb1bb77 (patch)
treeac8d1380d84769d14df07a4f1fcf93e2193d851e /cutl/compiler/cxx-indenter.txx
parent7777dce64be826d070b17312d7e82b6ce8eb21de (diff)
Improve C++ indenter by handling '},' sequence
Diffstat (limited to 'cutl/compiler/cxx-indenter.txx')
-rw-r--r--cutl/compiler/cxx-indenter.txx43
1 files changed, 43 insertions, 0 deletions
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)