]> granicus.if.org Git - vim/commitdiff
patch 7.4.893 v7.4.893
authorBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2015 14:13:39 +0000 (16:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2015 14:13:39 +0000 (16:13 +0200)
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.

src/misc1.c
src/testdir/test3.in
src/testdir/test3.ok
src/version.c

index 60e814694f15e7c36cdac3fcc8df3ab43f7f6171..aacf610ad8ef887bfddaec42d4731d540853e104 100644 (file)
@@ -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;
index 4fc73a978a05ed98a8e4bdb384ef9f16114a8ead..f3d4f182f8839852e0565f22de0cd06733264943 100644 (file)
@@ -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
index 8fa9caac2113256d911677cdac000b27c44f12b6..477aacc1caa752f384f05a52747557d063319fa1 100644 (file)
@@ -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 */
 
 
index 3722b5aee14b3e58cac80b35064b53b2c0150cea..3c8a9382aaefc95854f4f5feb5b56b5045194565 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    893,
 /**/
     892,
 /**/