To: vim_dev@googlegroups.com
Subject: Patch 7.3.1022
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.1022
Problem: Compiler warning for shadowed variable. (John Little)
Solution: Move declaration, rename variables.
Files: src/regexp_nfa.c
*** ../vim-7.3.1021/src/regexp_nfa.c 2013-05-26 14:32:01.000000000 +0200
--- src/regexp_nfa.c 2013-05-26 14:50:27.000000000 +0200
***************
*** 604,610 ****
char_u *endp;
#ifdef FEAT_MBYTE
char_u *old_regparse = regparse;
- int i;
#endif
int extra = 0;
int first;
--- 604,609 ----
***************
*** 827,850 ****
case 'u': /* %uabcd hex 4 */
case 'U': /* %U1234abcd hex 8 */
{
! int i;
switch (c)
{
! case 'd': i = getdecchrs(); break;
! case 'o': i = getoctchrs(); break;
! case 'x': i = gethexchrs(2); break;
! case 'u': i = gethexchrs(4); break;
! case 'U': i = gethexchrs(8); break;
! default: i = -1; break;
}
! if (i < 0)
EMSG2_RET_FAIL(
_("E678: Invalid character after %s%%[dxouU]"),
reg_magic == MAGIC_ALL);
/* TODO: what if a composing character follows? */
! EMIT(i);
}
break;
--- 826,849 ----
case 'u': /* %uabcd hex 4 */
case 'U': /* %U1234abcd hex 8 */
{
! int nr;
switch (c)
{
! case 'd': nr = getdecchrs(); break;
! case 'o': nr = getoctchrs(); break;
! case 'x': nr = gethexchrs(2); break;
! case 'u': nr = gethexchrs(4); break;
! case 'U': nr = gethexchrs(8); break;
! default: nr = -1; break;
}
! if (nr < 0)
EMSG2_RET_FAIL(
_("E678: Invalid character after %s%%[dxouU]"),
reg_magic == MAGIC_ALL);
/* TODO: what if a composing character follows? */
! EMIT(nr);
}
break;
***************
*** 1229,1234 ****
--- 1228,1235 ----
!= (plen = (*mb_ptr2len)(old_regparse))
|| utf_iscomposing(c)))
{
+ int i = 0;
+
/* A base character plus composing characters, or just one
* or more composing characters.
* This requires creating a separate atom as if enclosing
***************
*** 1237,1243 ****
* building the postfix form, not the NFA itself;
* a composing char could be: a, b, c, NFA_COMPOSING
* where 'b' and 'c' are chars with codes > 256. */
- i = 0;
for (;;)
{
EMIT(c);
--- 1238,1243 ----
***************
*** 2923,2931 ****
regsub_T *submatch;
regsub_T *m;
{
- int c;
- int n;
- int i = 0;
int result;
int size = 0;
int match = FALSE;
--- 2923,2928 ----
***************
*** 2939,2944 ****
--- 2936,2942 ----
nfa_list_T *listtbl[2][2];
nfa_list_T *ll;
int listid = 1;
+ int listidx;
nfa_list_T *thislist;
nfa_list_T *nextlist;
nfa_list_T *neglist;
***************
*** 3004,3010 ****
#define ADD_POS_NEG_STATE(node) \
ll = listtbl[result ? 1 : 0][node->negated]; \
if (ll != NULL) \
! addstate(ll, node->out , &t->sub, n, listid + 1, &match);
/*
--- 3002,3008 ----
#define ADD_POS_NEG_STATE(node) \
ll = listtbl[result ? 1 : 0][node->negated]; \
if (ll != NULL) \
! addstate(ll, node->out , &t->sub, clen, listid + 1, &match);
/*
***************
*** 3012,3032 ****
*/
for (;;)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
{
! c = (*mb_ptr2char)(reginput);
! n = (*mb_ptr2len)(reginput);
}
else
#endif
{
! c = *reginput;
! n = 1;
}
! if (c == NUL)
{
! n = 0;
go_to_nextline = FALSE;
}
--- 3010,3033 ----
*/
for (;;)
{
+ int curc;
+ int clen;
+
#ifdef FEAT_MBYTE
if (has_mbyte)
{
! curc = (*mb_ptr2char)(reginput);
! clen = (*mb_ptr2len)(reginput);
}
else
#endif
{
! curc = *reginput;
! clen = 1;
}
! if (curc == NUL)
{
! clen = 0;
go_to_nextline = FALSE;
}
***************
*** 3040,3049 ****
#ifdef ENABLE_LOG
fprintf(log_fd, "------------------------------------------\n");
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, ">>> Thislist has %d states available: ", thislist->n);
! for (i = 0; i < thislist->n; i++)
! fprintf(log_fd, "%d ", abs(thislist->t[i].state->id));
fprintf(log_fd, "\n");
#endif
--- 3041,3054 ----
#ifdef ENABLE_LOG
fprintf(log_fd, "------------------------------------------\n");
fprintf(log_fd, ">>> Reginput is \"%s\"\n", reginput);
! 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);
! {
! int i;
!
! for (i = 0; i < thislist->n; i++)
! fprintf(log_fd, "%d ", abs(thislist->t[i].state->id));
! }
fprintf(log_fd, "\n");
#endif
***************
*** 3057,3072 ****
break;
/* compute nextlist */
! for (i = 0; i < thislist->n || neglist->n > 0; ++i)
{
if (neglist->n > 0)
{
t = &neglist->t[0];
neglist->n--;
! i--;
}
else
! t = &thislist->t[i];
#ifdef NFA_REGEXP_DEBUG_LOG
nfa_set_code(t->state->c);
--- 3062,3077 ----
break;
/* compute nextlist */
! for (listidx = 0; listidx < thislist->n || neglist->n > 0; ++listidx)
{
if (neglist->n > 0)
{
t = &neglist->t[0];
neglist->n--;
! listidx--;
}
else
! t = &thislist->t[listidx];
#ifdef NFA_REGEXP_DEBUG_LOG
nfa_set_code(t->state->c);
***************
*** 3116,3122 ****
* the parent call. */
if (start->c == NFA_MOPEN + 0)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &i);
else
{
*m = t->sub;
--- 3121,3127 ----
* the parent call. */
if (start->c == NFA_MOPEN + 0)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &listidx);
else
{
*m = t->sub;
***************
*** 3190,3196 ****
}
/* t->state->out1 is the corresponding END_INVISIBLE node */
addstate_here(thislist, t->state->out1->out, &t->sub,
! listid, &match, &i);
}
else
{
--- 3195,3201 ----
}
/* t->state->out1 is the corresponding END_INVISIBLE node */
addstate_here(thislist, t->state->out1->out, &t->sub,
! listid, &match, &listidx);
}
else
{
***************
*** 3202,3221 ****
case NFA_BOL:
if (reginput == regline)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &i);
break;
case NFA_EOL:
! if (c == NUL)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &i);
break;
case NFA_BOW:
{
int bow = TRUE;
! if (c == NUL)
bow = FALSE;
#ifdef FEAT_MBYTE
else if (has_mbyte)
--- 3207,3226 ----
case NFA_BOL:
if (reginput == regline)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &listidx);
break;
case NFA_EOL:
! if (curc == NUL)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &listidx);
break;
case NFA_BOW:
{
int bow = TRUE;
! if (curc == NUL)
bow = FALSE;
#ifdef FEAT_MBYTE
else if (has_mbyte)
***************
*** 3230,3242 ****
bow = FALSE;
}
#endif
! else if (!vim_iswordc_buf(c, reg_buf)
|| (reginput > regline
&& vim_iswordc_buf(reginput[-1], reg_buf)))
bow = FALSE;
if (bow)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &i);
break;
}
--- 3235,3247 ----
bow = FALSE;
}
#endif
! else if (!vim_iswordc_buf(curc, reg_buf)
|| (reginput > regline
&& vim_iswordc_buf(reginput[-1], reg_buf)))
bow = FALSE;
if (bow)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &listidx);
break;
}
***************
*** 3260,3277 ****
}
#endif
else if (!vim_iswordc_buf(reginput[-1], reg_buf)
! || (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf)))
eow = FALSE;
if (eow)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &i);
break;
}
#ifdef FEAT_MBYTE
case NFA_COMPOSING:
{
! int mc = c;
int len = 0;
nfa_state_T *end;
nfa_state_T *sta;
--- 3265,3283 ----
}
#endif
else if (!vim_iswordc_buf(reginput[-1], reg_buf)
! || (reginput[0] != NUL
! && vim_iswordc_buf(curc, reg_buf)))
eow = FALSE;
if (eow)
addstate_here(thislist, t->state->out, &t->sub, listid,
! &match, &listidx);
break;
}
#ifdef FEAT_MBYTE
case NFA_COMPOSING:
{
! int mc = curc;
int len = 0;
nfa_state_T *end;
nfa_state_T *sta;
***************
*** 3286,3299 ****
/* Only match composing character(s), ignore base
* character. Used for ".{composing}" and "{composing}"
* (no preceding character). */
! len += mb_char2len(c);
}
if (ireg_icombine)
{
/* If \Z was present, then ignore composing characters.
* When ignoring the base character this always matches. */
/* TODO: How about negated? */
! if (len == 0 && sta->c != c)
result = FAIL;
else
result = OK;
--- 3292,3305 ----
/* Only match composing character(s), ignore base
* character. Used for ".{composing}" and "{composing}"
* (no preceding character). */
! len += mb_char2len(mc);
}
if (ireg_icombine)
{
/* If \Z was present, then ignore composing characters.
* When ignoring the base character this always matches. */
/* TODO: How about negated? */
! if (len == 0 && sta->c != curc)
result = FAIL;
else
result = OK;
***************
*** 3312,3318 ****
/* We don't care about the order of composing characters.
* Get them into cchars[] first. */
! while (len < n)
{
mc = mb_ptr2char(reginput + len);
cchars[ccount++] = mc;
--- 3318,3324 ----
/* We don't care about the order of composing characters.
* Get them into cchars[] first. */
! while (len < clen)
{
mc = mb_ptr2char(reginput + len);
cchars[ccount++] = mc;
***************
*** 3349,3355 ****
case NFA_NEWL:
if (!reg_line_lbr && REG_MULTI
! && c == NUL && reglnum <= reg_maxline)
{
go_to_nextline = TRUE;
/* Pass -1 for the offset, which means taking the position
--- 3355,3361 ----
case NFA_NEWL:
if (!reg_line_lbr && REG_MULTI
! && curc == NUL && reglnum <= reg_maxline)
{
go_to_nextline = TRUE;
/* Pass -1 for the offset, which means taking the position
***************
*** 3375,3409 ****
case NFA_CLASS_RETURN:
case NFA_CLASS_BACKSPACE:
case NFA_CLASS_ESCAPE:
! result = check_char_class(t->state->c, c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_END_NEG_RANGE:
/* This follows a series of negated nodes, like:
* CHAR(x), NFA_NOT, CHAR(y), NFA_NOT etc. */
! if (c > 0)
! addstate(nextlist, t->state->out, &t->sub, n, listid + 1,
! &match);
break;
case NFA_ANY:
/* Any char except '\0', (end of input) does not match. */
! if (c > 0)
! addstate(nextlist, t->state->out, &t->sub, n, listid + 1,
! &match);
break;
/*
* Character classes like \a for alpha, \d for digit etc.
*/
case NFA_IDENT: /* \i */
! result = vim_isIDc(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_SIDENT: /* \I */
! result = !VIM_ISDIGIT(c) && vim_isIDc(c);
ADD_POS_NEG_STATE(t->state);
break;
--- 3381,3415 ----
case NFA_CLASS_RETURN:
case NFA_CLASS_BACKSPACE:
case NFA_CLASS_ESCAPE:
! result = check_char_class(t->state->c, curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_END_NEG_RANGE:
/* This follows a series of negated nodes, like:
* CHAR(x), NFA_NOT, CHAR(y), NFA_NOT etc. */
! if (curc > 0)
! addstate(nextlist, t->state->out, &t->sub, clen,
! listid + 1, &match);
break;
case NFA_ANY:
/* Any char except '\0', (end of input) does not match. */
! if (curc > 0)
! addstate(nextlist, t->state->out, &t->sub, clen,
! listid + 1, &match);
break;
/*
* Character classes like \a for alpha, \d for digit etc.
*/
case NFA_IDENT: /* \i */
! result = vim_isIDc(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_SIDENT: /* \I */
! result = !VIM_ISDIGIT(curc) && vim_isIDc(curc);
ADD_POS_NEG_STATE(t->state);
break;
***************
*** 3413,3429 ****
break;
case NFA_SKWORD: /* \K */
! result = !VIM_ISDIGIT(c) && vim_iswordp_buf(reginput, reg_buf);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_FNAME: /* \f */
! result = vim_isfilec(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_SFNAME: /* \F */
! result = !VIM_ISDIGIT(c) && vim_isfilec(c);
ADD_POS_NEG_STATE(t->state);
break;
--- 3419,3436 ----
break;
case NFA_SKWORD: /* \K */
! result = !VIM_ISDIGIT(curc)
! && vim_iswordp_buf(reginput, reg_buf);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_FNAME: /* \f */
! result = vim_isfilec(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_SFNAME: /* \F */
! result = !VIM_ISDIGIT(curc) && vim_isfilec(curc);
ADD_POS_NEG_STATE(t->state);
break;
***************
*** 3433,3529 ****
break;
case NFA_SPRINT: /* \P */
! result = !VIM_ISDIGIT(c) && ptr2cells(reginput) == 1;
ADD_POS_NEG_STATE(t->state);
break;
case NFA_WHITE: /* \s */
! result = vim_iswhite(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NWHITE: /* \S */
! result = c != NUL && !vim_iswhite(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_DIGIT: /* \d */
! result = ri_digit(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NDIGIT: /* \D */
! result = c != NUL && !ri_digit(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_HEX: /* \x */
! result = ri_hex(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NHEX: /* \X */
! result = c != NUL && !ri_hex(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_OCTAL: /* \o */
! result = ri_octal(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NOCTAL: /* \O */
! result = c != NUL && !ri_octal(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_WORD: /* \w */
! result = ri_word(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NWORD: /* \W */
! result = c != NUL && !ri_word(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_HEAD: /* \h */
! result = ri_head(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NHEAD: /* \H */
! result = c != NUL && !ri_head(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_ALPHA: /* \a */
! result = ri_alpha(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NALPHA: /* \A */
! result = c != NUL && !ri_alpha(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_LOWER: /* \l */
! result = ri_lower(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NLOWER: /* \L */
! result = c != NUL && !ri_lower(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_UPPER: /* \u */
! result = ri_upper(c);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NUPPER: /* \U */
! result = c != NUL && !ri_upper(c);
ADD_POS_NEG_STATE(t->state);
break;
--- 3440,3536 ----
break;
case NFA_SPRINT: /* \P */
! result = !VIM_ISDIGIT(curc) && ptr2cells(reginput) == 1;
ADD_POS_NEG_STATE(t->state);
break;
case NFA_WHITE: /* \s */
! result = vim_iswhite(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NWHITE: /* \S */
! result = curc != NUL && !vim_iswhite(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_DIGIT: /* \d */
! result = ri_digit(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NDIGIT: /* \D */
! result = curc != NUL && !ri_digit(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_HEX: /* \x */
! result = ri_hex(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NHEX: /* \X */
! result = curc != NUL && !ri_hex(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_OCTAL: /* \o */
! result = ri_octal(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NOCTAL: /* \O */
! result = curc != NUL && !ri_octal(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_WORD: /* \w */
! result = ri_word(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NWORD: /* \W */
! result = curc != NUL && !ri_word(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_HEAD: /* \h */
! result = ri_head(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NHEAD: /* \H */
! result = curc != NUL && !ri_head(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_ALPHA: /* \a */
! result = ri_alpha(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NALPHA: /* \A */
! result = curc != NUL && !ri_alpha(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_LOWER: /* \l */
! result = ri_lower(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NLOWER: /* \L */
! result = curc != NUL && !ri_lower(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_UPPER: /* \u */
! result = ri_upper(curc);
ADD_POS_NEG_STATE(t->state);
break;
case NFA_NUPPER: /* \U */
! result = curc != NUL && !ri_upper(curc);
ADD_POS_NEG_STATE(t->state);
break;
***************
*** 3549,3565 ****
/* TODO: put this in #ifdef later */
if (t->state->c < -256)
EMSGN("INTERNAL: Negative state char: %ld", t->state->c);
! result = (no_Magic(t->state->c) == c);
if (!result)
result = ireg_ic == TRUE
! && MB_TOLOWER(t->state->c) == MB_TOLOWER(c);
#ifdef FEAT_MBYTE
/* If there is a composing character which is not being
* ignored there can be no match. Match with composing
* character uses NFA_COMPOSING above. */
if (result && enc_utf8 && !ireg_icombine
! && n != utf_char2len(c))
result = FALSE;
#endif
ADD_POS_NEG_STATE(t->state);
--- 3556,3572 ----
/* TODO: put this in #ifdef later */
if (t->state->c < -256)
EMSGN("INTERNAL: Negative state char: %ld", t->state->c);
! result = (no_Magic(t->state->c) == curc);
if (!result)
result = ireg_ic == TRUE
! && MB_TOLOWER(t->state->c) == MB_TOLOWER(curc);
#ifdef FEAT_MBYTE
/* If there is a composing character which is not being
* ignored there can be no match. Match with composing
* character uses NFA_COMPOSING above. */
if (result && enc_utf8 && !ireg_icombine
! && clen != utf_char2len(curc))
result = FALSE;
#endif
ADD_POS_NEG_STATE(t->state);
***************
*** 3578,3598 ****
#ifdef ENABLE_LOG
fprintf(log_fd, "(---) STARTSTATE\n");
#endif
! addstate(nextlist, start, m, n, listid + 1, &match);
}
#ifdef ENABLE_LOG
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));
fprintf(log_fd, "\n");
#endif
nextchar:
/* Advance to the next character, or advance to the next line, or
* finish. */
! if (n != 0)
! reginput += n;
else if (go_to_nextline)
reg_nextline();
else
--- 3585,3609 ----
#ifdef ENABLE_LOG
fprintf(log_fd, "(---) STARTSTATE\n");
#endif
! addstate(nextlist, start, m, clen, listid + 1, &match);
}
#ifdef ENABLE_LOG
fprintf(log_fd, ">>> Thislist had %d states available: ", thislist->n);
! {
! int i;
!
! for (i = 0; i < thislist->n; i++)
! fprintf(log_fd, "%d ", abs(thislist->t[i].state->id));
! }
fprintf(log_fd, "\n");
#endif
nextchar:
/* Advance to the next character, or advance to the next line, or
* finish. */
! if (clen != 0)
! reginput += clen;
else if (go_to_nextline)
reg_nextline();
else
*** ../vim-7.3.1021/src/version.c 2013-05-26 14:32:01.000000000 +0200
--- src/version.c 2013-05-26 14:39:12.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
{ /* Add new patch number below this line */
+ /**/
+ 1022,
/**/
--
Female engineers become irresistible at the age of consent and remain that
way until about thirty minutes after their clinical death. Longer if it's a
warm day.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///