aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cutl/compiler/cxx-indenter.txx43
-rw-r--r--tests/compiler/cxx-indenter/driver.cxx5
-rw-r--r--tests/compiler/cxx-indenter/output.std15
3 files changed, 63 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)
diff --git a/tests/compiler/cxx-indenter/driver.cxx b/tests/compiler/cxx-indenter/driver.cxx
index 511b6d4..665c6ab 100644
--- a/tests/compiler/cxx-indenter/driver.cxx
+++ b/tests/compiler/cxx-indenter/driver.cxx
@@ -115,6 +115,11 @@ main ()
<< "\"'name')\");"
<< "}";
+ os << "namespace N"
+ << "{"
+ << "static int i[] = {{0,\n0},{1,\n1}};"
+ << "}";
+
/*
@@ TODO: still misindents (if-else association problem)
diff --git a/tests/compiler/cxx-indenter/output.std b/tests/compiler/cxx-indenter/output.std
index 0e59a26..79e74f4 100644
--- a/tests/compiler/cxx-indenter/output.std
+++ b/tests/compiler/cxx-indenter/output.std
@@ -86,3 +86,18 @@ while (false);
"'name')");
}
+namespace N
+{
+ static int i[] =
+ {
+ {
+ 0,
+ 0
+ },
+ {
+ 1,
+ 1
+ }
+ };
+}
+