]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.164 v7.3.164
authorBram Moolenaar <Bram@vim.org>
Thu, 28 Apr 2011 11:02:09 +0000 (13:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 28 Apr 2011 11:02:09 +0000 (13:02 +0200)
Problem:    C-indenting: a preprocessor statement confuses detection of a
            function delcaration.
Solution:   Ignore preprocessor lines. (Lech Lorens)  Also recognize the style
            to put a comma before the argument name.

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

index f09a5bdb7fca1b16dc49a1c25fabfa7530105f60..8e3552ad67bb5447011b3e398004894d62ed801c 100644 (file)
@@ -5396,8 +5396,7 @@ cin_get_equal_amount(lnum)
 cin_ispreproc(s)
     char_u *s;
 {
-    s = skipwhite(s);
-    if (*s == '#')
+    if (*skipwhite(s) == '#')
        return TRUE;
     return FALSE;
 }
@@ -5513,6 +5512,10 @@ cin_isfuncdecl(sp, first_lnum)
     else
        s = *sp;
 
+    /* Ignore line starting with #. */
+    if (cin_ispreproc(s))
+       return FALSE;
+
     while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
     {
        if (cin_iscomment(s))   /* ignore comments */
@@ -5538,13 +5541,29 @@ cin_isfuncdecl(sp, first_lnum)
                retval = TRUE;
            goto done;
        }
-       if (*s == ',' && cin_nocode(s + 1))
+       if ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s))
        {
-           /* ',' at the end: continue looking in the next line */
+           int comma = (*s == ',');
+
+           /* ',' at the end: continue looking in the next line.
+            * At the end: check for ',' in the next line, for this style:
+            * func(arg1
+            *       , arg2) */
+           for (;;)
+           {
+               if (lnum >= curbuf->b_ml.ml_line_count)
+                   break;
+               s = ml_get(++lnum);
+               if (!cin_ispreproc(s))
+                   break;
+           }
            if (lnum >= curbuf->b_ml.ml_line_count)
                break;
-
-           s = ml_get(++lnum);
+           /* Require a comma at end of the line or a comma or ')' at the
+            * start of next line. */
+           s = skipwhite(s);
+           if (!comma && *s != ',' && *s != ')')
+               break;
        }
        else if (cin_iscomment(s))      /* ignore comments */
            s = cin_skipcomment(s);
index 35582bd9c2379cf7d2e218d324e4fdb5bc5816fc..62402fb980e38a6080a6218bab09827478d4b137 100644 (file)
@@ -1314,6 +1314,35 @@ int main ()
                foo;
 }
 
+STARTTEST
+:set cino=(0,ts
+2kdd=][
+ENDTEST
+
+void func(int a
+#if defined(FOO)
+                 , int b
+                 , int c
+#endif
+                )
+{
+}
+
+STARTTEST
+:set cino=(0
+2kdd=][
+ENDTEST
+
+void
+func(int a
+#if defined(FOO)
+                 , int b
+                 , int c
+#endif
+                )
+{
+}
+
 STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/start of AUTO/,$wq! test.out
index 8c015a3389360a6113a119fb0452892c5bb17f51..4e2a648114038b1579c8c855d6cbb2dae2bcebf1 100644 (file)
@@ -1183,3 +1183,24 @@ int main ()
                foo;
 }
 
+
+void func(int a
+#if defined(FOO)
+                 , int b
+                 , int c
+#endif
+                )
+{
+}
+
+
+       void
+func(int a
+#if defined(FOO)
+        , int b
+        , int c
+#endif
+       )
+{
+}
+
index 37a7034df25765322868ce8ba2b94b48efaa7ee2..8fb7cf35394273fb7acd4631b6211d9285fba592 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    164,
 /**/
     163,
 /**/