]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.380 v7.3.380
authorBram Moolenaar <Bram@vim.org>
Wed, 14 Dec 2011 19:21:35 +0000 (20:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 14 Dec 2011 19:21:35 +0000 (20:21 +0100)
Problem:    C-indenting wrong for a function header.
Solution:   Skip to the start paren. (Lech Lorens)

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

index 65f56f4f34be9bc6f1841c52e4197b01c529b1bf..a5a3ad31474f4ad9942fce1361ca8c264e0c129c 100644 (file)
@@ -4943,7 +4943,7 @@ static int        cin_iscomment __ARGS((char_u *));
 static int     cin_islinecomment __ARGS((char_u *));
 static int     cin_isterminated __ARGS((char_u *, int, int));
 static int     cin_isinit __ARGS((void));
-static int     cin_isfuncdecl __ARGS((char_u **, linenr_T));
+static int     cin_isfuncdecl __ARGS((char_u **, linenr_T, linenr_T, int, int));
 static int     cin_isif __ARGS((char_u *));
 static int     cin_iselse __ARGS((char_u *));
 static int     cin_isdo __ARGS((char_u *));
@@ -5585,21 +5585,37 @@ cin_isterminated(s, incl_open, incl_comma)
  * "sp" points to a string with the line.  When looking at other lines it must
  * be restored to the line.  When it's NULL fetch lines here.
  * "lnum" is where we start looking.
+ * "min_lnum" is the line before which we will not be looking.
  */
     static int
-cin_isfuncdecl(sp, first_lnum)
+cin_isfuncdecl(sp, first_lnum, min_lnum, ind_maxparen, ind_maxcomment)
     char_u     **sp;
     linenr_T   first_lnum;
+    linenr_T   min_lnum;
+    int                ind_maxparen;
+    int                ind_maxcomment;
 {
     char_u     *s;
     linenr_T   lnum = first_lnum;
     int                retval = FALSE;
+    pos_T      *trypos;
+    int                just_started = TRUE;
 
     if (sp == NULL)
        s = ml_get(lnum);
     else
        s = *sp;
 
+    if (find_last_paren(s, '(', ')')
+       && (trypos = find_match_paren(ind_maxparen, ind_maxcomment)) != NULL)
+    {
+       lnum = trypos->lnum;
+       if (lnum < min_lnum)
+           return FALSE;
+
+       s = ml_get(lnum);
+    }
+
     /* Ignore line starting with #. */
     if (cin_ispreproc(s))
        return FALSE;
@@ -5650,13 +5666,17 @@ cin_isfuncdecl(sp, first_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 != ')')
+           if (!just_started && (!comma && *s != ',' && *s != ')'))
                break;
+           just_started = FALSE;
        }
        else if (cin_iscomment(s))      /* ignore comments */
            s = cin_skipcomment(s);
        else
+       {
            ++s;
+           just_started = FALSE;
+       }
     }
 
 done:
@@ -7158,7 +7178,8 @@ get_c_indent()
                         * (it's a variable declaration).
                         */
                        if (start_brace != BRACE_IN_COL0
-                               || !cin_isfuncdecl(&l, curwin->w_cursor.lnum))
+                               || !cin_isfuncdecl(&l, curwin->w_cursor.lnum,
+                                            0, ind_maxparen, ind_maxcomment))
                        {
                            /* if the line is terminated with another ','
                             * it is a continued variable initialization.
@@ -8019,7 +8040,9 @@ term_again:
                && vim_strchr(theline, '}') == NULL
                && !cin_ends_in(theline, (char_u *)":", NULL)
                && !cin_ends_in(theline, (char_u *)",", NULL)
-               && cin_isfuncdecl(NULL, cur_curpos.lnum + 1)
+               && cin_isfuncdecl(NULL, cur_curpos.lnum + 1,
+                                 cur_curpos.lnum + 1,
+                                 ind_maxparen, ind_maxcomment)
                && !cin_isterminated(theline, FALSE, TRUE))
        {
            amount = ind_func_type;
@@ -8125,7 +8148,8 @@ term_again:
                 * If the line looks like a function declaration, and we're
                 * not in a comment, put it the left margin.
                 */
-               if (cin_isfuncdecl(NULL, cur_curpos.lnum))  /* XXX */
+               if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0,
+                                  ind_maxparen, ind_maxcomment))  /* XXX */
                    break;
                l = ml_get_curline();
 
@@ -8173,7 +8197,8 @@ term_again:
                 * line (and the ones that follow) needs to be indented as
                 * parameters.
                 */
-               if (cin_isfuncdecl(&l, curwin->w_cursor.lnum))
+               if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0,
+                                  ind_maxparen, ind_maxcomment))
                {
                    amount = ind_param;
                    break;
index 6c43732ab3bcbf150d389bb807175c085745f794..808d03191ad6f15b3d9f891ce4714701daf51dbf 100644 (file)
@@ -1429,7 +1429,7 @@ func(int a
 
 STARTTEST
 :set cino&
-2kdd=4][
+2kdd=7][
 ENDTEST
 
 void func(void)
@@ -1478,7 +1478,29 @@ void func3(void)
        3, 4,
        5, 6};
 
-printf("Don't you dare indent this line incorrectly!\n);
+printf("Don't you dare indent this line incorrectly!\n");
+}
+
+void
+func4(a, b,
+               c)
+int a;
+int b;
+int c;
+{
+}
+
+void
+func5(
+               int a,
+               int b)
+{
+}
+
+void
+func6(
+               int a)
+{
 }
 
 STARTTEST
index ad1db85396cfde45c7164ce474ed879a0ce8e8ec..828166435c47992081086483783dcdd7e6a7ffa9 100644 (file)
@@ -1331,7 +1331,29 @@ void func3(void)
                3, 4,
                5, 6};
 
-       printf("Don't you dare indent this line incorrectly!\n);
+       printf("Don't you dare indent this line incorrectly!\n");
+}
+
+       void
+func4(a, b,
+               c)
+       int a;
+       int b;
+       int c;
+{
+}
+
+       void
+func5(
+               int a,
+               int b)
+{
+}
+
+       void
+func6(
+               int a)
+{
 }
 
 
index 6f2f28c15cdd1b74c11e6fef25ad4afb6192dd97..5a5811381cb6f2031e7b6db8e974f4132201c8c5 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    380,
 /**/
     379,
 /**/