mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
updated for version 7.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.
This commit is contained in:
29
src/misc1.c
29
src/misc1.c
@@ -5396,8 +5396,7 @@ cin_get_equal_amount(lnum)
|
|||||||
cin_ispreproc(s)
|
cin_ispreproc(s)
|
||||||
char_u *s;
|
char_u *s;
|
||||||
{
|
{
|
||||||
s = skipwhite(s);
|
if (*skipwhite(s) == '#')
|
||||||
if (*s == '#')
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -5513,6 +5512,10 @@ cin_isfuncdecl(sp, first_lnum)
|
|||||||
else
|
else
|
||||||
s = *sp;
|
s = *sp;
|
||||||
|
|
||||||
|
/* Ignore line starting with #. */
|
||||||
|
if (cin_ispreproc(s))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
|
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
|
||||||
{
|
{
|
||||||
if (cin_iscomment(s)) /* ignore comments */
|
if (cin_iscomment(s)) /* ignore comments */
|
||||||
@@ -5538,13 +5541,29 @@ cin_isfuncdecl(sp, first_lnum)
|
|||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (*s == ',' && cin_nocode(s + 1))
|
if ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s))
|
||||||
|
{
|
||||||
|
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 (;;)
|
||||||
{
|
{
|
||||||
/* ',' at the end: continue looking in the next line */
|
|
||||||
if (lnum >= curbuf->b_ml.ml_line_count)
|
if (lnum >= curbuf->b_ml.ml_line_count)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
s = ml_get(++lnum);
|
s = ml_get(++lnum);
|
||||||
|
if (!cin_ispreproc(s))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lnum >= curbuf->b_ml.ml_line_count)
|
||||||
|
break;
|
||||||
|
/* 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 */
|
else if (cin_iscomment(s)) /* ignore comments */
|
||||||
s = cin_skipcomment(s);
|
s = cin_skipcomment(s);
|
||||||
|
@@ -1314,6 +1314,35 @@ int main ()
|
|||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
if (cond1 &&
|
if (cond1 &&
|
||||||
|
cond2
|
||||||
|
)
|
||||||
|
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
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@@ -1183,3 +1183,24 @@ int main ()
|
|||||||
foo;
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -714,6 +714,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
164,
|
||||||
/**/
|
/**/
|
||||||
163,
|
163,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user