]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.178 v7.3.178
authorBram Moolenaar <Bram@vim.org>
Tue, 10 May 2011 09:39:19 +0000 (11:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 10 May 2011 09:39:19 +0000 (11:39 +0200)
Problem:    C-indent doesn't handle code right after { correctly.
Solution:   Fix detecting unterminated line. (Lech Lorens)

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

index 76c95257960a559401acee9dc2c94361d49f5a15..3a94c3c2bc2371fb22a6316946ec9993aa85ab20 100644 (file)
@@ -4983,7 +4983,7 @@ cin_skipcomment(s)
 }
 
 /*
- * Return TRUE if there there is no code at *s.  White space and comments are
+ * Return TRUE if there is no code at *s.  White space and comments are
  * not considered code.
  */
     static int
@@ -5458,8 +5458,11 @@ cin_islinecomment(p)
 }
 
 /*
- * Recognize a line that starts with '{' or '}', or ends with ';', '{' or '}'.
+ * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
+ * '}'.
  * Don't consider "} else" a terminated line.
+ * Don't consider a line where there are unmatched opening braces before '}',
+ * ';' or ',' a terminated line.
  * Return the character terminating the line (ending char's have precedence if
  * both apply in order to determine initializations).
  */
@@ -5470,6 +5473,7 @@ cin_isterminated(s, incl_open, incl_comma)
     int                incl_comma;     /* recognize a trailing comma */
 {
     char_u found_start = 0;
+    unsigned n_open = 0;
 
     s = cin_skipcomment(s);
 
@@ -5480,10 +5484,19 @@ cin_isterminated(s, incl_open, incl_comma)
     {
        /* skip over comments, "" strings and 'c'haracters */
        s = skip_string(cin_skipcomment(s));
-       if ((*s == ';' || (incl_open && *s == '{') || *s == '}'
-                                                || (incl_comma && *s == ','))
+       if (*s == '}' && n_open > 0)
+           --n_open;
+       if (n_open == 0
+               && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
                && cin_nocode(s + 1))
            return *s;
+       else if (*s == '{')
+       {
+           if (incl_open && cin_nocode(s + 1))
+               return *s;
+           else
+               ++n_open;
+       }
 
        if (*s)
            s++;
index 62402fb980e38a6080a6218bab09827478d4b137..8576e275a4d32e10f07888cb06c239fc965827a7 100644 (file)
@@ -1343,6 +1343,22 @@ func(int a
 {
 }
 
+STARTTEST
+:set cino&
+2kdd=][
+ENDTEST
+
+void func(void)
+{
+       if(x==y)
+               if(y==z)
+                       foo=1;
+               else { bar=1;
+                       baz=2;
+               }
+       printf("Foo!\n");
+}
+
 STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/start of AUTO/,$wq! test.out
index 4e2a648114038b1579c8c855d6cbb2dae2bcebf1..3764453a7b919da36a7473aa6cc0e7859ae98f30 100644 (file)
@@ -1204,3 +1204,15 @@ func(int a
 {
 }
 
+
+void func(void)
+{
+       if(x==y)
+               if(y==z)
+                       foo=1;
+               else { bar=1;
+                       baz=2;
+               }
+       printf("Foo!\n");
+}
+
index 0c24bd2f7e0c735dcdd1f2fdf897598b98bd1b01..f69bf4e9e1e9bd625838a072952fe16b1101a805 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    178,
 /**/
     177,
 /**/