summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-10-13 16:13:39 +0200
committerBram Moolenaar <Bram@vim.org>2015-10-13 16:13:39 +0200
commitd1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479 (patch)
treefc48b9da7efe42238ba08d191af9dd0e31f45a34
parent9d6ca1cc5ebb6e61cc2ef73aecfbb0bdbb65432f (diff)
patch 7.4.893v7.4.893
Problem: C indenting is wrong below a "case (foo):" because it is recognized as a C++ base class construct. Issue #38. Solution: Check for the case keyword.
-rw-r--r--src/misc1.c9
-rw-r--r--src/testdir/test3.in27
-rw-r--r--src/testdir/test3.ok27
-rw-r--r--src/version.c2
4 files changed, 64 insertions, 1 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 60e814694f..aacf610ad8 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -6555,7 +6555,7 @@ cin_is_cpp_baseclass(cached)
pos->lnum = lnum;
line = ml_get(lnum);
- s = cin_skipcomment(line);
+ s = line;
for (;;)
{
if (*s == NUL)
@@ -6564,6 +6564,13 @@ cin_is_cpp_baseclass(cached)
break;
/* Continue in the cursor line. */
line = ml_get(++lnum);
+ s = line;
+ }
+ if (s == line)
+ {
+ /* don't recognize "case (foo):" as a baseclass */
+ if (cin_iscase(s, FALSE))
+ break;
s = cin_skipcomment(line);
if (*s == NUL)
continue;
diff --git a/src/testdir/test3.in b/src/testdir/test3.in
index 4fc73a978a..f3d4f182f8 100644
--- a/src/testdir/test3.in
+++ b/src/testdir/test3.in
@@ -932,6 +932,33 @@ if (1)
a = 1;
}
+void func()
+{
+switch (foo)
+{
+case (bar):
+if (baz())
+quux();
+break;
+case (shmoo):
+if (!bar)
+{
+}
+case (foo1):
+switch (bar)
+{
+case baz:
+baz_f();
+break;
+}
+break;
+default:
+baz();
+baz();
+break;
+}
+}
+
/* end of AUTO */
STARTTEST
diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok
index 8fa9caac21..477aacc1ca 100644
--- a/src/testdir/test3.ok
+++ b/src/testdir/test3.ok
@@ -920,6 +920,33 @@ void getstring() {
a = 1;
}
+void func()
+{
+ switch (foo)
+ {
+ case (bar):
+ if (baz())
+ quux();
+ break;
+ case (shmoo):
+ if (!bar)
+ {
+ }
+ case (foo1):
+ switch (bar)
+ {
+ case baz:
+ baz_f();
+ break;
+ }
+ break;
+ default:
+ baz();
+ baz();
+ break;
+ }
+}
+
/* end of AUTO */
diff --git a/src/version.c b/src/version.c
index 3722b5aee1..3c8a9382aa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 893,
+/**/
892,
/**/
891,