0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

updated for version 7.4.071

Problem:    Passing limits around too often.
Solution:   Use limits from buffer.
This commit is contained in:
Bram Moolenaar
2013-11-06 04:01:36 +01:00
parent dce7c91de9
commit 84dbb62fca
4 changed files with 95 additions and 144 deletions

View File

@@ -7857,8 +7857,7 @@ in_cinkeys(keytyped, when, line_is_empty)
if (try_match && keytyped == ':') if (try_match && keytyped == ':')
{ {
p = ml_get_curline(); p = ml_get_curline();
if (cin_iscase(p, FALSE) || cin_isscopedecl(p) if (cin_iscase(p, FALSE) || cin_isscopedecl(p) || cin_islabel())
|| cin_islabel(30))
return TRUE; return TRUE;
/* Need to get the line again after cin_islabel(). */ /* Need to get the line again after cin_islabel(). */
p = ml_get_curline(); p = ml_get_curline();
@@ -7868,7 +7867,7 @@ in_cinkeys(keytyped, when, line_is_empty)
{ {
p[curwin->w_cursor.col - 1] = ' '; p[curwin->w_cursor.col - 1] = ' ';
i = (cin_iscase(p, FALSE) || cin_isscopedecl(p) i = (cin_iscase(p, FALSE) || cin_isscopedecl(p)
|| cin_islabel(30)); || cin_islabel());
p = ml_get_curline(); p = ml_get_curline();
p[curwin->w_cursor.col - 1] = ':'; p[curwin->w_cursor.col - 1] = ':';
if (i) if (i)

View File

@@ -5191,11 +5191,18 @@ FullName_save(fname, force)
#if defined(FEAT_CINDENT) || defined(FEAT_SYN_HL) #if defined(FEAT_CINDENT) || defined(FEAT_SYN_HL)
static char_u *skip_string __ARGS((char_u *p)); static char_u *skip_string __ARGS((char_u *p));
static pos_T *ind_find_start_comment __ARGS((void));
/* /*
* Find the start of a comment, not knowing if we are in a comment right now. * Find the start of a comment, not knowing if we are in a comment right now.
* Search starts at w_cursor.lnum and goes backwards. * Search starts at w_cursor.lnum and goes backwards.
*/ */
static pos_T *
ind_find_start_comment() /* XXX */
{
return find_start_comment(curbuf->b_ind_maxcomment);
}
pos_T * pos_T *
find_start_comment(ind_maxcomment) /* XXX */ find_start_comment(ind_maxcomment) /* XXX */
int ind_maxcomment; int ind_maxcomment;
@@ -5313,7 +5320,7 @@ static int cin_islabel_skip __ARGS((char_u **));
static int cin_isdefault __ARGS((char_u *)); static int cin_isdefault __ARGS((char_u *));
static char_u *after_label __ARGS((char_u *l)); static char_u *after_label __ARGS((char_u *l));
static int get_indent_nolabel __ARGS((linenr_T lnum)); static int get_indent_nolabel __ARGS((linenr_T lnum));
static int skip_label __ARGS((linenr_T, char_u **pp, int ind_maxcomment)); static int skip_label __ARGS((linenr_T, char_u **pp));
static int cin_first_id_amount __ARGS((void)); static int cin_first_id_amount __ARGS((void));
static int cin_get_equal_amount __ARGS((linenr_T lnum)); static int cin_get_equal_amount __ARGS((linenr_T lnum));
static int cin_ispreproc __ARGS((char_u *)); static int cin_ispreproc __ARGS((char_u *));
@@ -5322,24 +5329,24 @@ static int cin_iscomment __ARGS((char_u *));
static int cin_islinecomment __ARGS((char_u *)); static int cin_islinecomment __ARGS((char_u *));
static int cin_isterminated __ARGS((char_u *, int, int)); static int cin_isterminated __ARGS((char_u *, int, int));
static int cin_isinit __ARGS((void)); static int cin_isinit __ARGS((void));
static int cin_isfuncdecl __ARGS((char_u **, linenr_T, linenr_T, int, int)); static int cin_isfuncdecl __ARGS((char_u **, linenr_T, linenr_T));
static int cin_isif __ARGS((char_u *)); static int cin_isif __ARGS((char_u *));
static int cin_iselse __ARGS((char_u *)); static int cin_iselse __ARGS((char_u *));
static int cin_isdo __ARGS((char_u *)); static int cin_isdo __ARGS((char_u *));
static int cin_iswhileofdo __ARGS((char_u *, linenr_T, int)); static int cin_iswhileofdo __ARGS((char_u *, linenr_T));
static int cin_is_if_for_while_before_offset __ARGS((char_u *line, int *poffset)); static int cin_is_if_for_while_before_offset __ARGS((char_u *line, int *poffset));
static int cin_iswhileofdo_end __ARGS((int terminated, int ind_maxparen, int ind_maxcomment)); static int cin_iswhileofdo_end __ARGS((int terminated));
static int cin_isbreak __ARGS((char_u *)); static int cin_isbreak __ARGS((char_u *));
static int cin_is_cpp_baseclass __ARGS((colnr_T *col)); static int cin_is_cpp_baseclass __ARGS((colnr_T *col));
static int get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass)); static int get_baseclass_amount __ARGS((int col));
static int cin_ends_in __ARGS((char_u *, char_u *, char_u *)); static int cin_ends_in __ARGS((char_u *, char_u *, char_u *));
static int cin_starts_with __ARGS((char_u *s, char *word)); static int cin_starts_with __ARGS((char_u *s, char *word));
static int cin_skip2pos __ARGS((pos_T *trypos)); static int cin_skip2pos __ARGS((pos_T *trypos));
static pos_T *find_start_brace __ARGS((int)); static pos_T *find_start_brace __ARGS((void));
static pos_T *find_match_paren __ARGS((int, int)); static pos_T *find_match_paren __ARGS((int));
static int corr_ind_maxparen __ARGS((int ind_maxparen, pos_T *startpos)); static int corr_ind_maxparen __ARGS((pos_T *startpos));
static int find_last_paren __ARGS((char_u *l, int start, int end)); static int find_last_paren __ARGS((char_u *l, int start, int end));
static int find_match __ARGS((int lookfor, linenr_T ourscope, int ind_maxparen, int ind_maxcomment)); static int find_match __ARGS((int lookfor, linenr_T ourscope));
static int cin_is_cpp_namespace __ARGS((char_u *)); static int cin_is_cpp_namespace __ARGS((char_u *));
/* /*
@@ -5444,8 +5451,7 @@ cin_islabel_skip(s)
* Note: curwin->w_cursor must be where we are looking for the label. * Note: curwin->w_cursor must be where we are looking for the label.
*/ */
int int
cin_islabel(ind_maxcomment) /* XXX */ cin_islabel() /* XXX */
int ind_maxcomment;
{ {
char_u *s; char_u *s;
@@ -5479,7 +5485,7 @@ cin_islabel(ind_maxcomment) /* XXX */
* If we're in a comment now, skip to the start of the comment. * If we're in a comment now, skip to the start of the comment.
*/ */
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
if ((trypos = find_start_comment(ind_maxcomment)) != NULL) /* XXX */ if ((trypos = ind_find_start_comment()) != NULL) /* XXX */
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
line = ml_get_curline(); line = ml_get_curline();
@@ -5725,10 +5731,9 @@ get_indent_nolabel(lnum) /* XXX */
* ^ * ^
*/ */
static int static int
skip_label(lnum, pp, ind_maxcomment) skip_label(lnum, pp)
linenr_T lnum; linenr_T lnum;
char_u **pp; char_u **pp;
int ind_maxcomment;
{ {
char_u *l; char_u *l;
int amount; int amount;
@@ -5738,8 +5743,7 @@ skip_label(lnum, pp, ind_maxcomment)
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
l = ml_get_curline(); l = ml_get_curline();
/* XXX */ /* XXX */
if (cin_iscase(l, FALSE) || cin_isscopedecl(l) if (cin_iscase(l, FALSE) || cin_isscopedecl(l) || cin_islabel())
|| cin_islabel(ind_maxcomment))
{ {
amount = get_indent_nolabel(lnum); amount = get_indent_nolabel(lnum);
l = after_label(ml_get_curline()); l = after_label(ml_get_curline());
@@ -5983,12 +5987,10 @@ cin_isterminated(s, incl_open, incl_comma)
* "min_lnum" is the line before which we will not be looking. * "min_lnum" is the line before which we will not be looking.
*/ */
static int static int
cin_isfuncdecl(sp, first_lnum, min_lnum, ind_maxparen, ind_maxcomment) cin_isfuncdecl(sp, first_lnum, min_lnum)
char_u **sp; char_u **sp;
linenr_T first_lnum; linenr_T first_lnum;
linenr_T min_lnum; linenr_T min_lnum;
int ind_maxparen;
int ind_maxcomment;
{ {
char_u *s; char_u *s;
linenr_T lnum = first_lnum; linenr_T lnum = first_lnum;
@@ -6002,7 +6004,7 @@ cin_isfuncdecl(sp, first_lnum, min_lnum, ind_maxparen, ind_maxcomment)
s = *sp; s = *sp;
if (find_last_paren(s, '(', ')') if (find_last_paren(s, '(', ')')
&& (trypos = find_match_paren(ind_maxparen, ind_maxcomment)) != NULL) && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
{ {
lnum = trypos->lnum; lnum = trypos->lnum;
if (lnum < min_lnum) if (lnum < min_lnum)
@@ -6110,10 +6112,9 @@ cin_isdo(p)
* ')' and ';'. The condition may be spread over several lines. * ')' and ';'. The condition may be spread over several lines.
*/ */
static int static int
cin_iswhileofdo(p, lnum, ind_maxparen) /* XXX */ cin_iswhileofdo(p, lnum) /* XXX */
char_u *p; char_u *p;
linenr_T lnum; linenr_T lnum;
int ind_maxparen;
{ {
pos_T cursor_save; pos_T cursor_save;
pos_T *trypos; pos_T *trypos;
@@ -6133,7 +6134,8 @@ cin_iswhileofdo(p, lnum, ind_maxparen) /* XXX */
++p; ++p;
++curwin->w_cursor.col; ++curwin->w_cursor.col;
} }
if ((trypos = findmatchlimit(NULL, 0, 0, ind_maxparen)) != NULL if ((trypos = findmatchlimit(NULL, 0, 0,
curbuf->b_ind_maxparen)) != NULL
&& *cin_skipcomment(ml_get_pos(trypos) + 1) == ';') && *cin_skipcomment(ml_get_pos(trypos) + 1) == ';')
retval = TRUE; retval = TRUE;
curwin->w_cursor = cursor_save; curwin->w_cursor = cursor_save;
@@ -6196,10 +6198,8 @@ probablyFound:
* Adjust the cursor to the line with "while". * Adjust the cursor to the line with "while".
*/ */
static int static int
cin_iswhileofdo_end(terminated, ind_maxparen, ind_maxcomment) cin_iswhileofdo_end(terminated)
int terminated; int terminated;
int ind_maxparen;
int ind_maxcomment;
{ {
char_u *line; char_u *line;
char_u *p; char_u *p;
@@ -6223,7 +6223,7 @@ cin_iswhileofdo_end(terminated, ind_maxparen, ind_maxcomment)
* before the matching '('. XXX */ * before the matching '('. XXX */
i = (int)(p - line); i = (int)(p - line);
curwin->w_cursor.col = i; curwin->w_cursor.col = i;
trypos = find_match_paren(ind_maxparen, ind_maxcomment); trypos = find_match_paren(curbuf->b_ind_maxparen);
if (trypos != NULL) if (trypos != NULL)
{ {
s = cin_skipcomment(ml_get(trypos->lnum)); s = cin_skipcomment(ml_get(trypos->lnum));
@@ -6415,11 +6415,8 @@ cin_is_cpp_baseclass(col)
} }
static int static int
get_baseclass_amount(col, ind_maxparen, ind_maxcomment, ind_cpp_baseclass) get_baseclass_amount(col)
int col; int col;
int ind_maxparen;
int ind_maxcomment;
int ind_cpp_baseclass;
{ {
int amount; int amount;
colnr_T vcol; colnr_T vcol;
@@ -6429,11 +6426,10 @@ get_baseclass_amount(col, ind_maxparen, ind_maxcomment, ind_cpp_baseclass)
{ {
amount = get_indent(); amount = get_indent();
if (find_last_paren(ml_get_curline(), '(', ')') if (find_last_paren(ml_get_curline(), '(', ')')
&& (trypos = find_match_paren(ind_maxparen, && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
ind_maxcomment)) != NULL)
amount = get_indent_lnum(trypos->lnum); /* XXX */ amount = get_indent_lnum(trypos->lnum); /* XXX */
if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL)) if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL))
amount += ind_cpp_baseclass; amount += curbuf->b_ind_cpp_baseclass;
} }
else else
{ {
@@ -6441,8 +6437,8 @@ get_baseclass_amount(col, ind_maxparen, ind_maxcomment, ind_cpp_baseclass)
getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
amount = (int)vcol; amount = (int)vcol;
} }
if (amount < ind_cpp_baseclass) if (amount < curbuf->b_ind_cpp_baseclass)
amount = ind_cpp_baseclass; amount = curbuf->b_ind_cpp_baseclass;
return amount; return amount;
} }
@@ -6526,8 +6522,7 @@ cin_skip2pos(trypos)
/* } */ /* } */
static pos_T * static pos_T *
find_start_brace(ind_maxcomment) /* XXX */ find_start_brace() /* XXX */
int ind_maxcomment;
{ {
pos_T cursor_save; pos_T cursor_save;
pos_T *trypos; pos_T *trypos;
@@ -6543,7 +6538,7 @@ find_start_brace(ind_maxcomment) /* XXX */
pos = NULL; pos = NULL;
/* ignore the { if it's in a // or / * * / comment */ /* ignore the { if it's in a // or / * * / comment */
if ((colnr_T)cin_skip2pos(trypos) == trypos->col if ((colnr_T)cin_skip2pos(trypos) == trypos->col
&& (pos = find_start_comment(ind_maxcomment)) == NULL) /* XXX */ && (pos = ind_find_start_comment()) == NULL) /* XXX */
break; break;
if (pos != NULL) if (pos != NULL)
curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.lnum = pos->lnum;
@@ -6557,9 +6552,8 @@ find_start_brace(ind_maxcomment) /* XXX */
* Return NULL if no match found. * Return NULL if no match found.
*/ */
static pos_T * static pos_T *
find_match_paren(ind_maxparen, ind_maxcomment) /* XXX */ find_match_paren(ind_maxparen) /* XXX */
int ind_maxparen; int ind_maxparen;
int ind_maxcomment;
{ {
pos_T cursor_save; pos_T cursor_save;
pos_T *trypos; pos_T *trypos;
@@ -6576,7 +6570,7 @@ find_match_paren(ind_maxparen, ind_maxcomment) /* XXX */
pos_copy = *trypos; /* copy trypos, findmatch will change it */ pos_copy = *trypos; /* copy trypos, findmatch will change it */
trypos = &pos_copy; trypos = &pos_copy;
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
if (find_start_comment(ind_maxcomment) != NULL) /* XXX */ if (ind_find_start_comment() != NULL) /* XXX */
trypos = NULL; trypos = NULL;
} }
} }
@@ -6591,15 +6585,14 @@ find_match_paren(ind_maxparen, ind_maxcomment) /* XXX */
* looking a few lines further. * looking a few lines further.
*/ */
static int static int
corr_ind_maxparen(ind_maxparen, startpos) corr_ind_maxparen(startpos)
int ind_maxparen;
pos_T *startpos; pos_T *startpos;
{ {
long n = (long)startpos->lnum - (long)curwin->w_cursor.lnum; long n = (long)startpos->lnum - (long)curwin->w_cursor.lnum;
if (n > 0 && n < ind_maxparen / 2) if (n > 0 && n < curbuf->b_ind_maxparen / 2)
return ind_maxparen - (int)n; return curbuf->b_ind_maxparen - (int)n;
return ind_maxparen; return curbuf->b_ind_maxparen;
} }
/* /*
@@ -6937,7 +6930,7 @@ get_c_indent()
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
original_line_islabel = cin_islabel(curbuf->b_ind_maxcomment); /* XXX */ original_line_islabel = cin_islabel(); /* XXX */
/* /*
* #defines and so on always go at the left when included in 'cinkeys'. * #defines and so on always go at the left when included in 'cinkeys'.
@@ -6973,7 +6966,7 @@ get_c_indent()
* comment, try using the 'comments' option. * comment, try using the 'comments' option.
*/ */
else if (!cin_iscomment(theline) else if (!cin_iscomment(theline)
&& (trypos = find_start_comment(curbuf->b_ind_maxcomment)) != NULL) && (trypos = ind_find_start_comment()) != NULL)
/* XXX */ /* XXX */
{ {
int lead_start_len = 2; int lead_start_len = 2;
@@ -7126,11 +7119,9 @@ get_c_indent()
/* /*
* Are we inside parentheses or braces? * Are we inside parentheses or braces?
*/ /* XXX */ */ /* XXX */
else if (((trypos = find_match_paren(curbuf->b_ind_maxparen, else if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL
curbuf->b_ind_maxcomment)) != NULL
&& curbuf->b_ind_java == 0) && curbuf->b_ind_java == 0)
|| (tryposBrace = || (tryposBrace = find_start_brace()) != NULL
find_start_brace(curbuf->b_ind_maxcomment)) != NULL
|| trypos != NULL) || trypos != NULL)
{ {
if (trypos != NULL && tryposBrace != NULL) if (trypos != NULL && tryposBrace != NULL)
@@ -7170,8 +7161,7 @@ get_c_indent()
curwin->w_cursor.lnum = lnum; curwin->w_cursor.lnum = lnum;
/* Skip a comment. XXX */ /* Skip a comment. XXX */
if ((trypos = find_start_comment(curbuf->b_ind_maxcomment)) if ((trypos = ind_find_start_comment()) != NULL)
!= NULL)
{ {
lnum = trypos->lnum + 1; lnum = trypos->lnum + 1;
continue; continue;
@@ -7179,8 +7169,7 @@ get_c_indent()
/* XXX */ /* XXX */
if ((trypos = find_match_paren( if ((trypos = find_match_paren(
corr_ind_maxparen(curbuf->b_ind_maxparen, &cur_curpos), corr_ind_maxparen(&cur_curpos))) != NULL
curbuf->b_ind_maxcomment)) != NULL
&& trypos->lnum == our_paren_pos.lnum && trypos->lnum == our_paren_pos.lnum
&& trypos->col == our_paren_pos.col) && trypos->col == our_paren_pos.col)
{ {
@@ -7223,8 +7212,7 @@ get_c_indent()
curwin->w_cursor.lnum = outermost.lnum; curwin->w_cursor.lnum = outermost.lnum;
curwin->w_cursor.col = outermost.col; curwin->w_cursor.col = outermost.col;
trypos = find_match_paren(curbuf->b_ind_maxparen, trypos = find_match_paren(curbuf->b_ind_maxparen);
curbuf->b_ind_maxcomment);
} while (trypos && trypos->lnum == outermost.lnum); } while (trypos && trypos->lnum == outermost.lnum);
curwin->w_cursor = cursor_save; curwin->w_cursor = cursor_save;
@@ -7235,8 +7223,7 @@ get_c_indent()
cin_is_if_for_while_before_offset(line, &outermost.col); cin_is_if_for_while_before_offset(line, &outermost.col);
} }
amount = skip_label(our_paren_pos.lnum, &look, amount = skip_label(our_paren_pos.lnum, &look);
curbuf->b_ind_maxcomment);
look = skipwhite(look); look = skipwhite(look);
if (*look == '(') if (*look == '(')
{ {
@@ -7366,8 +7353,7 @@ get_c_indent()
{ {
curwin->w_cursor.lnum = our_paren_pos.lnum; curwin->w_cursor.lnum = our_paren_pos.lnum;
curwin->w_cursor.col = col; curwin->w_cursor.col = col;
if (find_match_paren(curbuf->b_ind_maxparen, if (find_match_paren(curbuf->b_ind_maxparen) != NULL)
curbuf->b_ind_maxcomment) != NULL)
amount += curbuf->b_ind_unclosed2; amount += curbuf->b_ind_unclosed2;
else else
{ {
@@ -7435,8 +7421,8 @@ get_c_indent()
*/ */
lnum = ourscope; lnum = ourscope;
if (find_last_paren(start, '(', ')') if (find_last_paren(start, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen, && (trypos = find_match_paren(curbuf->b_ind_maxparen))
curbuf->b_ind_maxcomment)) != NULL) != NULL)
lnum = trypos->lnum; lnum = trypos->lnum;
/* /*
@@ -7449,7 +7435,7 @@ get_c_indent()
&& cin_iscase(skipwhite(ml_get_curline()), FALSE))) && cin_iscase(skipwhite(ml_get_curline()), FALSE)))
amount = get_indent(); amount = get_indent();
else else
amount = skip_label(lnum, &l, curbuf->b_ind_maxcomment); amount = skip_label(lnum, &l);
start_brace = BRACE_AT_END; start_brace = BRACE_AT_END;
} }
@@ -7478,14 +7464,12 @@ get_c_indent()
lookfor = LOOKFOR_INITIAL; lookfor = LOOKFOR_INITIAL;
if (cin_iselse(theline)) if (cin_iselse(theline))
lookfor = LOOKFOR_IF; lookfor = LOOKFOR_IF;
else if (cin_iswhileofdo(theline, cur_curpos.lnum, else if (cin_iswhileofdo(theline, cur_curpos.lnum)) /* XXX */
curbuf->b_ind_maxparen)) /* XXX */
lookfor = LOOKFOR_DO; lookfor = LOOKFOR_DO;
if (lookfor != LOOKFOR_INITIAL) if (lookfor != LOOKFOR_INITIAL)
{ {
curwin->w_cursor.lnum = cur_curpos.lnum; curwin->w_cursor.lnum = cur_curpos.lnum;
if (find_match(lookfor, ourscope, curbuf->b_ind_maxparen, if (find_match(lookfor, ourscope) == OK)
curbuf->b_ind_maxcomment) == OK)
{ {
amount = get_indent(); /* XXX */ amount = get_indent(); /* XXX */
goto theend; goto theend;
@@ -7611,7 +7595,7 @@ get_c_indent()
* If we're in a comment now, skip to the start of the * If we're in a comment now, skip to the start of the
* comment. * comment.
*/ */
trypos = find_start_comment(curbuf->b_ind_maxcomment); trypos = ind_find_start_comment();
if (trypos != NULL) if (trypos != NULL)
{ {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
@@ -7636,9 +7620,7 @@ get_c_indent()
* (it's a variable declaration). * (it's a variable declaration).
*/ */
if (start_brace != BRACE_IN_COL0 if (start_brace != BRACE_IN_COL0
|| !cin_isfuncdecl(&l, curwin->w_cursor.lnum, || !cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))
0, curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment))
{ {
/* if the line is terminated with another ',' /* if the line is terminated with another ','
* it is a continued variable initialization. * it is a continued variable initialization.
@@ -7670,12 +7652,10 @@ get_c_indent()
trypos = NULL; trypos = NULL;
if (find_last_paren(l, '(', ')')) if (find_last_paren(l, '(', ')'))
trypos = find_match_paren( trypos = find_match_paren(
curbuf->b_ind_maxparen, curbuf->b_ind_maxparen);
curbuf->b_ind_maxcomment);
if (trypos == NULL && find_last_paren(l, '{', '}')) if (trypos == NULL && find_last_paren(l, '{', '}'))
trypos = find_start_brace( trypos = find_start_brace();
curbuf->b_ind_maxcomment);
if (trypos != NULL) if (trypos != NULL)
{ {
@@ -7733,8 +7713,7 @@ get_c_indent()
/* If we're in a comment now, skip to the start of /* If we're in a comment now, skip to the start of
* the comment. */ * the comment. */
trypos = find_start_comment( trypos = ind_find_start_comment();
curbuf->b_ind_maxcomment);
if (trypos != NULL) if (trypos != NULL)
{ {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
@@ -7764,8 +7743,7 @@ get_c_indent()
/* /*
* If we're in a comment now, skip to the start of the comment. * If we're in a comment now, skip to the start of the comment.
*/ /* XXX */ */ /* XXX */
if ((trypos = find_start_comment(curbuf->b_ind_maxcomment)) if ((trypos = ind_find_start_comment()) != NULL)
!= NULL)
{ {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -7819,8 +7797,7 @@ get_c_indent()
* Check that this case label is not for another * Check that this case label is not for another
* switch() * switch()
*/ /* XXX */ */ /* XXX */
if ((trypos = find_start_brace( if ((trypos = find_start_brace()) == NULL
curbuf->b_ind_maxcomment)) == NULL
|| trypos->lnum == ourscope) || trypos->lnum == ourscope)
{ {
amount = get_indent(); /* XXX */ amount = get_indent(); /* XXX */
@@ -7894,8 +7871,8 @@ get_c_indent()
*/ */
if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL)
{ {
if (find_last_paren(l, '{', '}') && (trypos = if (find_last_paren(l, '{', '}')
find_start_brace(curbuf->b_ind_maxcomment)) != NULL) && (trypos = find_start_brace()) != NULL)
{ {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -7906,7 +7883,7 @@ get_c_indent()
/* /*
* Ignore jump labels with nothing after them. * Ignore jump labels with nothing after them.
*/ */
if (!curbuf->b_ind_js && cin_islabel(curbuf->b_ind_maxcomment)) if (!curbuf->b_ind_js && cin_islabel())
{ {
l = after_label(ml_get_curline()); l = after_label(ml_get_curline());
if (l == NULL || cin_nocode(l)) if (l == NULL || cin_nocode(l))
@@ -7952,10 +7929,7 @@ get_c_indent()
} }
else else
/* XXX */ /* XXX */
amount = get_baseclass_amount(col, amount = get_baseclass_amount(col);
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment,
curbuf->b_ind_cpp_baseclass);
break; break;
} }
else if (lookfor == LOOKFOR_CPP_BASECLASS) else if (lookfor == LOOKFOR_CPP_BASECLASS)
@@ -7997,9 +7971,7 @@ get_c_indent()
* matching it will take us back to the start of the line. * matching it will take us back to the start of the line.
*/ */
(void)find_last_paren(l, '(', ')'); (void)find_last_paren(l, '(', ')');
trypos = find_match_paren( trypos = find_match_paren(corr_ind_maxparen(&cur_curpos));
corr_ind_maxparen(curbuf->b_ind_maxparen,
&cur_curpos), curbuf->b_ind_maxcomment);
/* /*
* If we are looking for ',', we also look for matching * If we are looking for ',', we also look for matching
@@ -8007,7 +7979,7 @@ get_c_indent()
*/ */
if (trypos == NULL && terminated == ',' if (trypos == NULL && terminated == ','
&& find_last_paren(l, '{', '}')) && find_last_paren(l, '{', '}'))
trypos = find_start_brace(curbuf->b_ind_maxcomment); trypos = find_start_brace();
if (trypos != NULL) if (trypos != NULL)
{ {
@@ -8051,8 +8023,7 @@ get_c_indent()
* ignoring any jump label. XXX * ignoring any jump label. XXX
*/ */
if (!curbuf->b_ind_js) if (!curbuf->b_ind_js)
cur_amount = skip_label(curwin->w_cursor.lnum, cur_amount = skip_label(curwin->w_cursor.lnum, &l);
&l, curbuf->b_ind_maxcomment);
else else
cur_amount = get_indent(); cur_amount = get_indent();
/* /*
@@ -8162,11 +8133,9 @@ get_c_indent()
curwin->w_cursor.col = curwin->w_cursor.col =
(colnr_T)(l - ml_get_curline()) + 1; (colnr_T)(l - ml_get_curline()) + 1;
if ((trypos = find_start_brace( if ((trypos = find_start_brace()) == NULL
curbuf->b_ind_maxcomment)) == NULL || find_match(LOOKFOR_IF, trypos->lnum)
|| find_match(LOOKFOR_IF, trypos->lnum, == FAIL)
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment) == FAIL)
break; break;
} }
} }
@@ -8261,8 +8230,7 @@ get_c_indent()
* If so: Ignore until the matching "do". * If so: Ignore until the matching "do".
*/ */
/* XXX */ /* XXX */
else if (cin_iswhileofdo_end(terminated, curbuf->b_ind_maxparen, else if (cin_iswhileofdo_end(terminated))
curbuf->b_ind_maxcomment))
{ {
/* /*
* Found an unterminated line after a while ();, line up * Found an unterminated line after a while ();, line up
@@ -8380,8 +8348,7 @@ term_again:
l = ml_get_curline(); l = ml_get_curline();
if (find_last_paren(l, '(', ')') if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren( && (trypos = find_match_paren(
curbuf->b_ind_maxparen, curbuf->b_ind_maxparen)) != NULL)
curbuf->b_ind_maxcomment)) != NULL)
{ {
/* /*
* Check if we are on a case label now. This is * Check if we are on a case label now. This is
@@ -8415,8 +8382,7 @@ term_again:
* Get indent and pointer to text for current line, * Get indent and pointer to text for current line,
* ignoring any jump label. * ignoring any jump label.
*/ */
amount = skip_label(curwin->w_cursor.lnum, amount = skip_label(curwin->w_cursor.lnum, &l);
&l, curbuf->b_ind_maxcomment);
if (theline[0] == '{') if (theline[0] == '{')
amount += curbuf->b_ind_open_extra; amount += curbuf->b_ind_open_extra;
@@ -8439,11 +8405,9 @@ term_again:
&& cin_iselse(l) && cin_iselse(l)
&& whilelevel == 0) && whilelevel == 0)
{ {
if ((trypos = find_start_brace( if ((trypos = find_start_brace()) == NULL
curbuf->b_ind_maxcomment)) == NULL || find_match(LOOKFOR_IF, trypos->lnum)
|| find_match(LOOKFOR_IF, trypos->lnum, == FAIL)
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment) == FAIL)
break; break;
continue; continue;
} }
@@ -8453,9 +8417,8 @@ term_again:
* that block. * that block.
*/ */
l = ml_get_curline(); l = ml_get_curline();
if (find_last_paren(l, '{', '}') if (find_last_paren(l, '{', '}') /* XXX */
&& (trypos = find_start_brace( && (trypos = find_start_brace()) != NULL)
curbuf->b_ind_maxcomment)) != NULL) /* XXX */
{ {
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
/* if not "else {" check for terminated again */ /* if not "else {" check for terminated again */
@@ -8516,9 +8479,7 @@ term_again:
&& !cin_ends_in(theline, (char_u *)":", NULL) && !cin_ends_in(theline, (char_u *)":", 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, cur_curpos.lnum + 1)
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment)
&& !cin_isterminated(theline, FALSE, TRUE)) && !cin_isterminated(theline, FALSE, TRUE))
{ {
amount = curbuf->b_ind_func_type; amount = curbuf->b_ind_func_type;
@@ -8540,8 +8501,7 @@ term_again:
/* /*
* If we're in a comment now, skip to the start of the comment. * If we're in a comment now, skip to the start of the comment.
*/ /* XXX */ */ /* XXX */
if ((trypos = find_start_comment( if ((trypos = ind_find_start_comment()) != NULL)
curbuf->b_ind_maxcomment)) != NULL)
{ {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@@ -8561,9 +8521,7 @@ term_again:
if (n) if (n)
{ {
/* XXX */ /* XXX */
amount = get_baseclass_amount(col, curbuf->b_ind_maxparen, amount = get_baseclass_amount(col);
curbuf->b_ind_maxcomment,
curbuf->b_ind_cpp_baseclass);
break; break;
} }
@@ -8595,8 +8553,7 @@ term_again:
/* take us back to opening paren */ /* take us back to opening paren */
if (find_last_paren(l, '(', ')') if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren( && (trypos = find_match_paren(
curbuf->b_ind_maxparen, curbuf->b_ind_maxparen)) != NULL)
curbuf->b_ind_maxcomment)) != NULL)
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
/* For a line ending in ',' that is a continuation line go /* For a line ending in ',' that is a continuation line go
@@ -8627,9 +8584,7 @@ term_again:
* If the line looks like a function declaration, and we're * If the line looks like a function declaration, and we're
* not in a comment, put it the left margin. * not in a comment, put it the left margin.
*/ */
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0, if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment)) /* XXX */
break; break;
l = ml_get_curline(); l = ml_get_curline();
@@ -8677,9 +8632,7 @@ term_again:
* line (and the ones that follow) needs to be indented as * line (and the ones that follow) needs to be indented as
* parameters. * parameters.
*/ */
if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0, if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0))
curbuf->b_ind_maxparen,
curbuf->b_ind_maxcomment))
{ {
amount = curbuf->b_ind_param; amount = curbuf->b_ind_param;
break; break;
@@ -8710,8 +8663,7 @@ term_again:
*/ */
find_last_paren(l, '(', ')'); find_last_paren(l, '(', ')');
if ((trypos = find_match_paren(curbuf->b_ind_maxparen, if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
curbuf->b_ind_maxcomment)) != NULL)
curwin->w_cursor = *trypos; curwin->w_cursor = *trypos;
amount = get_indent(); /* XXX */ amount = get_indent(); /* XXX */
break; break;
@@ -8754,11 +8706,9 @@ theend:
} }
static int static int
find_match(lookfor, ourscope, ind_maxparen, ind_maxcomment) find_match(lookfor, ourscope)
int lookfor; int lookfor;
linenr_T ourscope; linenr_T ourscope;
int ind_maxparen;
int ind_maxcomment;
{ {
char_u *look; char_u *look;
pos_T *theirscope; pos_T *theirscope;
@@ -8788,13 +8738,13 @@ find_match(lookfor, ourscope, ind_maxparen, ind_maxcomment)
if (cin_iselse(look) if (cin_iselse(look)
|| cin_isif(look) || cin_isif(look)
|| cin_isdo(look) /* XXX */ || cin_isdo(look) /* XXX */
|| cin_iswhileofdo(look, curwin->w_cursor.lnum, ind_maxparen)) || cin_iswhileofdo(look, curwin->w_cursor.lnum))
{ {
/* /*
* if we've gone outside the braces entirely, * if we've gone outside the braces entirely,
* we must be out of scope... * we must be out of scope...
*/ */
theirscope = find_start_brace(ind_maxcomment); /* XXX */ theirscope = find_start_brace(); /* XXX */
if (theirscope == NULL) if (theirscope == NULL)
break; break;
@@ -8832,7 +8782,7 @@ find_match(lookfor, ourscope, ind_maxparen, ind_maxcomment)
* if it was a "while" then we need to go back to * if it was a "while" then we need to go back to
* another "do", so increment whilelevel. XXX * another "do", so increment whilelevel. XXX
*/ */
if (cin_iswhileofdo(look, curwin->w_cursor.lnum, ind_maxparen)) if (cin_iswhileofdo(look, curwin->w_cursor.lnum))
{ {
++whilelevel; ++whilelevel;
continue; continue;

View File

@@ -81,7 +81,7 @@ void add_pathsep __ARGS((char_u *p));
char_u *FullName_save __ARGS((char_u *fname, int force)); char_u *FullName_save __ARGS((char_u *fname, int force));
pos_T *find_start_comment __ARGS((int ind_maxcomment)); pos_T *find_start_comment __ARGS((int ind_maxcomment));
void do_c_expr_indent __ARGS((void)); void do_c_expr_indent __ARGS((void));
int cin_islabel __ARGS((int ind_maxcomment)); int cin_islabel __ARGS((void));
int cin_iscase __ARGS((char_u *s, int strict)); int cin_iscase __ARGS((char_u *s, int strict));
int cin_isscopedecl __ARGS((char_u *s)); int cin_isscopedecl __ARGS((char_u *s));
void parse_cino __ARGS((buf_T *buf)); void parse_cino __ARGS((buf_T *buf));

View File

@@ -738,6 +738,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 */
/**/
71,
/**/ /**/
70, 70,
/**/ /**/