0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.3.1022

Problem:    Compiler warning for shadowed variable. (John Little)
Solution:   Move declaration, rename variables.
This commit is contained in:
Bram Moolenaar 2013-05-26 14:54:12 +02:00
parent 3f1682e808
commit 7cd4d9c17c
2 changed files with 94 additions and 81 deletions

View File

@ -604,7 +604,6 @@ nfa_regatom()
char_u *endp; char_u *endp;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
char_u *old_regparse = regparse; char_u *old_regparse = regparse;
int i;
#endif #endif
int extra = 0; int extra = 0;
int first; int first;
@ -827,24 +826,24 @@ nfa_regatom()
case 'u': /* %uabcd hex 4 */ case 'u': /* %uabcd hex 4 */
case 'U': /* %U1234abcd hex 8 */ case 'U': /* %U1234abcd hex 8 */
{ {
int i; int nr;
switch (c) switch (c)
{ {
case 'd': i = getdecchrs(); break; case 'd': nr = getdecchrs(); break;
case 'o': i = getoctchrs(); break; case 'o': nr = getoctchrs(); break;
case 'x': i = gethexchrs(2); break; case 'x': nr = gethexchrs(2); break;
case 'u': i = gethexchrs(4); break; case 'u': nr = gethexchrs(4); break;
case 'U': i = gethexchrs(8); break; case 'U': nr = gethexchrs(8); break;
default: i = -1; break; default: nr = -1; break;
} }
if (i < 0) if (nr < 0)
EMSG2_RET_FAIL( EMSG2_RET_FAIL(
_("E678: Invalid character after %s%%[dxouU]"), _("E678: Invalid character after %s%%[dxouU]"),
reg_magic == MAGIC_ALL); reg_magic == MAGIC_ALL);
/* TODO: what if a composing character follows? */ /* TODO: what if a composing character follows? */
EMIT(i); EMIT(nr);
} }
break; break;
@ -1229,6 +1228,8 @@ nfa_do_multibyte:
!= (plen = (*mb_ptr2len)(old_regparse)) != (plen = (*mb_ptr2len)(old_regparse))
|| utf_iscomposing(c))) || utf_iscomposing(c)))
{ {
int i = 0;
/* A base character plus composing characters, or just one /* A base character plus composing characters, or just one
* or more composing characters. * or more composing characters.
* This requires creating a separate atom as if enclosing * This requires creating a separate atom as if enclosing
@ -1237,7 +1238,6 @@ nfa_do_multibyte:
* building the postfix form, not the NFA itself; * building the postfix form, not the NFA itself;
* a composing char could be: a, b, c, NFA_COMPOSING * a composing char could be: a, b, c, NFA_COMPOSING
* where 'b' and 'c' are chars with codes > 256. */ * where 'b' and 'c' are chars with codes > 256. */
i = 0;
for (;;) for (;;)
{ {
EMIT(c); EMIT(c);
@ -2923,9 +2923,6 @@ nfa_regmatch(start, submatch, m)
regsub_T *submatch; regsub_T *submatch;
regsub_T *m; regsub_T *m;
{ {
int c;
int n;
int i = 0;
int result; int result;
int size = 0; int size = 0;
int match = FALSE; int match = FALSE;
@ -2939,6 +2936,7 @@ nfa_regmatch(start, submatch, m)
nfa_list_T *listtbl[2][2]; nfa_list_T *listtbl[2][2];
nfa_list_T *ll; nfa_list_T *ll;
int listid = 1; int listid = 1;
int listidx;
nfa_list_T *thislist; nfa_list_T *thislist;
nfa_list_T *nextlist; nfa_list_T *nextlist;
nfa_list_T *neglist; nfa_list_T *neglist;
@ -3004,7 +3002,7 @@ nfa_regmatch(start, submatch, m)
#define ADD_POS_NEG_STATE(node) \ #define ADD_POS_NEG_STATE(node) \
ll = listtbl[result ? 1 : 0][node->negated]; \ ll = listtbl[result ? 1 : 0][node->negated]; \
if (ll != NULL) \ if (ll != NULL) \
addstate(ll, node->out , &t->sub, n, listid + 1, &match); addstate(ll, node->out , &t->sub, clen, listid + 1, &match);
/* /*
@ -3012,21 +3010,24 @@ nfa_regmatch(start, submatch, m)
*/ */
for (;;) for (;;)
{ {
int curc;
int clen;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
c = (*mb_ptr2char)(reginput); curc = (*mb_ptr2char)(reginput);
n = (*mb_ptr2len)(reginput); clen = (*mb_ptr2len)(reginput);
} }
else else
#endif #endif
{ {
c = *reginput; curc = *reginput;
n = 1; clen = 1;
} }
if (c == NUL) if (curc == NUL)
{ {
n = 0; clen = 0;
go_to_nextline = FALSE; go_to_nextline = FALSE;
} }
@ -3040,10 +3041,14 @@ nfa_regmatch(start, submatch, m)
#ifdef ENABLE_LOG #ifdef ENABLE_LOG
fprintf(log_fd, "------------------------------------------\n"); fprintf(log_fd, "------------------------------------------\n");
fprintf(log_fd, ">>> Reginput is \"%s\"\n", reginput); fprintf(log_fd, ">>> Reginput is \"%s\"\n", reginput);
fprintf(log_fd, ">>> Advanced one character ... Current char is %c (code %d) \n", c, (int)c); fprintf(log_fd, ">>> Advanced one character ... Current char is %c (code %d) \n", curc, (int)curc);
fprintf(log_fd, ">>> Thislist has %d states available: ", thislist->n); fprintf(log_fd, ">>> Thislist has %d states available: ", thislist->n);
for (i = 0; i < thislist->n; i++) {
fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); int i;
for (i = 0; i < thislist->n; i++)
fprintf(log_fd, "%d ", abs(thislist->t[i].state->id));
}
fprintf(log_fd, "\n"); fprintf(log_fd, "\n");
#endif #endif
@ -3057,16 +3062,16 @@ nfa_regmatch(start, submatch, m)
break; break;
/* compute nextlist */ /* compute nextlist */
for (i = 0; i < thislist->n || neglist->n > 0; ++i) for (listidx = 0; listidx < thislist->n || neglist->n > 0; ++listidx)
{ {
if (neglist->n > 0) if (neglist->n > 0)
{ {
t = &neglist->t[0]; t = &neglist->t[0];
neglist->n--; neglist->n--;
i--; listidx--;
} }
else else
t = &thislist->t[i]; t = &thislist->t[listidx];
#ifdef NFA_REGEXP_DEBUG_LOG #ifdef NFA_REGEXP_DEBUG_LOG
nfa_set_code(t->state->c); nfa_set_code(t->state->c);
@ -3116,7 +3121,7 @@ nfa_regmatch(start, submatch, m)
* the parent call. */ * the parent call. */
if (start->c == NFA_MOPEN + 0) if (start->c == NFA_MOPEN + 0)
addstate_here(thislist, t->state->out, &t->sub, listid, addstate_here(thislist, t->state->out, &t->sub, listid,
&match, &i); &match, &listidx);
else else
{ {
*m = t->sub; *m = t->sub;
@ -3190,7 +3195,7 @@ nfa_regmatch(start, submatch, m)
} }
/* t->state->out1 is the corresponding END_INVISIBLE node */ /* t->state->out1 is the corresponding END_INVISIBLE node */
addstate_here(thislist, t->state->out1->out, &t->sub, addstate_here(thislist, t->state->out1->out, &t->sub,
listid, &match, &i); listid, &match, &listidx);
} }
else else
{ {
@ -3202,20 +3207,20 @@ nfa_regmatch(start, submatch, m)
case NFA_BOL: case NFA_BOL:
if (reginput == regline) if (reginput == regline)
addstate_here(thislist, t->state->out, &t->sub, listid, addstate_here(thislist, t->state->out, &t->sub, listid,
&match, &i); &match, &listidx);
break; break;
case NFA_EOL: case NFA_EOL:
if (c == NUL) if (curc == NUL)
addstate_here(thislist, t->state->out, &t->sub, listid, addstate_here(thislist, t->state->out, &t->sub, listid,
&match, &i); &match, &listidx);
break; break;
case NFA_BOW: case NFA_BOW:
{ {
int bow = TRUE; int bow = TRUE;
if (c == NUL) if (curc == NUL)
bow = FALSE; bow = FALSE;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
else if (has_mbyte) else if (has_mbyte)
@ -3230,13 +3235,13 @@ nfa_regmatch(start, submatch, m)
bow = FALSE; bow = FALSE;
} }
#endif #endif
else if (!vim_iswordc_buf(c, reg_buf) else if (!vim_iswordc_buf(curc, reg_buf)
|| (reginput > regline || (reginput > regline
&& vim_iswordc_buf(reginput[-1], reg_buf))) && vim_iswordc_buf(reginput[-1], reg_buf)))
bow = FALSE; bow = FALSE;
if (bow) if (bow)
addstate_here(thislist, t->state->out, &t->sub, listid, addstate_here(thislist, t->state->out, &t->sub, listid,
&match, &i); &match, &listidx);
break; break;
} }
@ -3260,18 +3265,19 @@ nfa_regmatch(start, submatch, m)
} }
#endif #endif
else if (!vim_iswordc_buf(reginput[-1], reg_buf) else if (!vim_iswordc_buf(reginput[-1], reg_buf)
|| (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf))) || (reginput[0] != NUL
&& vim_iswordc_buf(curc, reg_buf)))
eow = FALSE; eow = FALSE;
if (eow) if (eow)
addstate_here(thislist, t->state->out, &t->sub, listid, addstate_here(thislist, t->state->out, &t->sub, listid,
&match, &i); &match, &listidx);
break; break;
} }
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
case NFA_COMPOSING: case NFA_COMPOSING:
{ {
int mc = c; int mc = curc;
int len = 0; int len = 0;
nfa_state_T *end; nfa_state_T *end;
nfa_state_T *sta; nfa_state_T *sta;
@ -3286,14 +3292,14 @@ nfa_regmatch(start, submatch, m)
/* Only match composing character(s), ignore base /* Only match composing character(s), ignore base
* character. Used for ".{composing}" and "{composing}" * character. Used for ".{composing}" and "{composing}"
* (no preceding character). */ * (no preceding character). */
len += mb_char2len(c); len += mb_char2len(mc);
} }
if (ireg_icombine) if (ireg_icombine)
{ {
/* If \Z was present, then ignore composing characters. /* If \Z was present, then ignore composing characters.
* When ignoring the base character this always matches. */ * When ignoring the base character this always matches. */
/* TODO: How about negated? */ /* TODO: How about negated? */
if (len == 0 && sta->c != c) if (len == 0 && sta->c != curc)
result = FAIL; result = FAIL;
else else
result = OK; result = OK;
@ -3312,7 +3318,7 @@ nfa_regmatch(start, submatch, m)
/* We don't care about the order of composing characters. /* We don't care about the order of composing characters.
* Get them into cchars[] first. */ * Get them into cchars[] first. */
while (len < n) while (len < clen)
{ {
mc = mb_ptr2char(reginput + len); mc = mb_ptr2char(reginput + len);
cchars[ccount++] = mc; cchars[ccount++] = mc;
@ -3349,7 +3355,7 @@ nfa_regmatch(start, submatch, m)
case NFA_NEWL: case NFA_NEWL:
if (!reg_line_lbr && REG_MULTI if (!reg_line_lbr && REG_MULTI
&& c == NUL && reglnum <= reg_maxline) && curc == NUL && reglnum <= reg_maxline)
{ {
go_to_nextline = TRUE; go_to_nextline = TRUE;
/* Pass -1 for the offset, which means taking the position /* Pass -1 for the offset, which means taking the position
@ -3375,35 +3381,35 @@ nfa_regmatch(start, submatch, m)
case NFA_CLASS_RETURN: case NFA_CLASS_RETURN:
case NFA_CLASS_BACKSPACE: case NFA_CLASS_BACKSPACE:
case NFA_CLASS_ESCAPE: case NFA_CLASS_ESCAPE:
result = check_char_class(t->state->c, c); result = check_char_class(t->state->c, curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_END_NEG_RANGE: case NFA_END_NEG_RANGE:
/* This follows a series of negated nodes, like: /* This follows a series of negated nodes, like:
* CHAR(x), NFA_NOT, CHAR(y), NFA_NOT etc. */ * CHAR(x), NFA_NOT, CHAR(y), NFA_NOT etc. */
if (c > 0) if (curc > 0)
addstate(nextlist, t->state->out, &t->sub, n, listid + 1, addstate(nextlist, t->state->out, &t->sub, clen,
&match); listid + 1, &match);
break; break;
case NFA_ANY: case NFA_ANY:
/* Any char except '\0', (end of input) does not match. */ /* Any char except '\0', (end of input) does not match. */
if (c > 0) if (curc > 0)
addstate(nextlist, t->state->out, &t->sub, n, listid + 1, addstate(nextlist, t->state->out, &t->sub, clen,
&match); listid + 1, &match);
break; break;
/* /*
* Character classes like \a for alpha, \d for digit etc. * Character classes like \a for alpha, \d for digit etc.
*/ */
case NFA_IDENT: /* \i */ case NFA_IDENT: /* \i */
result = vim_isIDc(c); result = vim_isIDc(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_SIDENT: /* \I */ case NFA_SIDENT: /* \I */
result = !VIM_ISDIGIT(c) && vim_isIDc(c); result = !VIM_ISDIGIT(curc) && vim_isIDc(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
@ -3413,17 +3419,18 @@ nfa_regmatch(start, submatch, m)
break; break;
case NFA_SKWORD: /* \K */ case NFA_SKWORD: /* \K */
result = !VIM_ISDIGIT(c) && vim_iswordp_buf(reginput, reg_buf); result = !VIM_ISDIGIT(curc)
&& vim_iswordp_buf(reginput, reg_buf);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_FNAME: /* \f */ case NFA_FNAME: /* \f */
result = vim_isfilec(c); result = vim_isfilec(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_SFNAME: /* \F */ case NFA_SFNAME: /* \F */
result = !VIM_ISDIGIT(c) && vim_isfilec(c); result = !VIM_ISDIGIT(curc) && vim_isfilec(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
@ -3433,97 +3440,97 @@ nfa_regmatch(start, submatch, m)
break; break;
case NFA_SPRINT: /* \P */ case NFA_SPRINT: /* \P */
result = !VIM_ISDIGIT(c) && ptr2cells(reginput) == 1; result = !VIM_ISDIGIT(curc) && ptr2cells(reginput) == 1;
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_WHITE: /* \s */ case NFA_WHITE: /* \s */
result = vim_iswhite(c); result = vim_iswhite(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NWHITE: /* \S */ case NFA_NWHITE: /* \S */
result = c != NUL && !vim_iswhite(c); result = curc != NUL && !vim_iswhite(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_DIGIT: /* \d */ case NFA_DIGIT: /* \d */
result = ri_digit(c); result = ri_digit(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NDIGIT: /* \D */ case NFA_NDIGIT: /* \D */
result = c != NUL && !ri_digit(c); result = curc != NUL && !ri_digit(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_HEX: /* \x */ case NFA_HEX: /* \x */
result = ri_hex(c); result = ri_hex(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NHEX: /* \X */ case NFA_NHEX: /* \X */
result = c != NUL && !ri_hex(c); result = curc != NUL && !ri_hex(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_OCTAL: /* \o */ case NFA_OCTAL: /* \o */
result = ri_octal(c); result = ri_octal(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NOCTAL: /* \O */ case NFA_NOCTAL: /* \O */
result = c != NUL && !ri_octal(c); result = curc != NUL && !ri_octal(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_WORD: /* \w */ case NFA_WORD: /* \w */
result = ri_word(c); result = ri_word(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NWORD: /* \W */ case NFA_NWORD: /* \W */
result = c != NUL && !ri_word(c); result = curc != NUL && !ri_word(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_HEAD: /* \h */ case NFA_HEAD: /* \h */
result = ri_head(c); result = ri_head(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NHEAD: /* \H */ case NFA_NHEAD: /* \H */
result = c != NUL && !ri_head(c); result = curc != NUL && !ri_head(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_ALPHA: /* \a */ case NFA_ALPHA: /* \a */
result = ri_alpha(c); result = ri_alpha(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NALPHA: /* \A */ case NFA_NALPHA: /* \A */
result = c != NUL && !ri_alpha(c); result = curc != NUL && !ri_alpha(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_LOWER: /* \l */ case NFA_LOWER: /* \l */
result = ri_lower(c); result = ri_lower(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NLOWER: /* \L */ case NFA_NLOWER: /* \L */
result = c != NUL && !ri_lower(c); result = curc != NUL && !ri_lower(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_UPPER: /* \u */ case NFA_UPPER: /* \u */
result = ri_upper(c); result = ri_upper(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
case NFA_NUPPER: /* \U */ case NFA_NUPPER: /* \U */
result = c != NUL && !ri_upper(c); result = curc != NUL && !ri_upper(curc);
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
break; break;
@ -3549,17 +3556,17 @@ nfa_regmatch(start, submatch, m)
/* TODO: put this in #ifdef later */ /* TODO: put this in #ifdef later */
if (t->state->c < -256) if (t->state->c < -256)
EMSGN("INTERNAL: Negative state char: %ld", t->state->c); EMSGN("INTERNAL: Negative state char: %ld", t->state->c);
result = (no_Magic(t->state->c) == c); result = (no_Magic(t->state->c) == curc);
if (!result) if (!result)
result = ireg_ic == TRUE result = ireg_ic == TRUE
&& MB_TOLOWER(t->state->c) == MB_TOLOWER(c); && MB_TOLOWER(t->state->c) == MB_TOLOWER(curc);
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
/* If there is a composing character which is not being /* If there is a composing character which is not being
* ignored there can be no match. Match with composing * ignored there can be no match. Match with composing
* character uses NFA_COMPOSING above. */ * character uses NFA_COMPOSING above. */
if (result && enc_utf8 && !ireg_icombine if (result && enc_utf8 && !ireg_icombine
&& n != utf_char2len(c)) && clen != utf_char2len(curc))
result = FALSE; result = FALSE;
#endif #endif
ADD_POS_NEG_STATE(t->state); ADD_POS_NEG_STATE(t->state);
@ -3578,21 +3585,25 @@ nfa_regmatch(start, submatch, m)
#ifdef ENABLE_LOG #ifdef ENABLE_LOG
fprintf(log_fd, "(---) STARTSTATE\n"); fprintf(log_fd, "(---) STARTSTATE\n");
#endif #endif
addstate(nextlist, start, m, n, listid + 1, &match); addstate(nextlist, start, m, clen, listid + 1, &match);
} }
#ifdef ENABLE_LOG #ifdef ENABLE_LOG
fprintf(log_fd, ">>> Thislist had %d states available: ", thislist->n); fprintf(log_fd, ">>> Thislist had %d states available: ", thislist->n);
for (i = 0; i< thislist->n; i++) {
fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); int i;
for (i = 0; i < thislist->n; i++)
fprintf(log_fd, "%d ", abs(thislist->t[i].state->id));
}
fprintf(log_fd, "\n"); fprintf(log_fd, "\n");
#endif #endif
nextchar: nextchar:
/* Advance to the next character, or advance to the next line, or /* Advance to the next character, or advance to the next line, or
* finish. */ * finish. */
if (n != 0) if (clen != 0)
reginput += n; reginput += clen;
else if (go_to_nextline) else if (go_to_nextline)
reg_nextline(); reg_nextline();
else else

View File

@ -728,6 +728,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 */
/**/
1022,
/**/ /**/
1021, 1021,
/**/ /**/