diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-04-28 13:02:09 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-04-28 13:02:09 +0200 |
commit | 8d2d71d4bbd7f13817e7f42ce02b31c4a17ed66f (patch) | |
tree | d9e971cde37bc1c33f83b5d04bd65650843f480f | |
parent | f1fda2d6e591a5b5bb549e4ca30c9029c544eea9 (diff) | |
download | vim-git-8d2d71d4bbd7f13817e7f42ce02b31c4a17ed66f.tar.gz |
updated for version 7.3.164v7.3.164
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.
-rw-r--r-- | src/misc1.c | 31 | ||||
-rw-r--r-- | src/testdir/test3.in | 29 | ||||
-rw-r--r-- | src/testdir/test3.ok | 21 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 77 insertions, 6 deletions
diff --git a/src/misc1.c b/src/misc1.c index f09a5bdb7..8e3552ad6 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -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); diff --git a/src/testdir/test3.in b/src/testdir/test3.in index 35582bd9c..62402fb98 100644 --- a/src/testdir/test3.in +++ b/src/testdir/test3.in @@ -1315,6 +1315,35 @@ int main () } 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 ENDTEST diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok index 8c015a338..4e2a64811 100644 --- a/src/testdir/test3.ok +++ b/src/testdir/test3.ok @@ -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 + ) +{ +} + diff --git a/src/version.c b/src/version.c index 37a7034df..8fb7cf353 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 164, +/**/ 163, /**/ 162, |