changeset 4549:849180347ac3 v7.3.1022

updated for version 7.3.1022 Problem: Compiler warning for shadowed variable. (John Little) Solution: Move declaration, rename variables.
author Bram Moolenaar <bram@vim.org>
date Sun, 26 May 2013 14:54:12 +0200
parents f070418bd2ce
children 9d84d115161f
files src/regexp_nfa.c src/version.c
diffstat 2 files changed, 94 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -604,7 +604,6 @@ nfa_regatom()
     char_u	*endp;
 #ifdef FEAT_MBYTE
     char_u	*old_regparse = regparse;
-    int		i;
 #endif
     int		extra = 0;
     int		first;
@@ -827,24 +826,24 @@ nfa_regatom()
 		case 'u':   /* %uabcd hex 4 */
 		case 'U':   /* %U1234abcd hex 8 */
 		    {
-			int i;
+			int nr;
 
 			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;
+			    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 (i < 0)
+			if (nr < 0)
 			    EMSG2_RET_FAIL(
 			       _("E678: Invalid character after %s%%[dxouU]"),
 				    reg_magic == MAGIC_ALL);
 			/* TODO: what if a composing character follows? */
-			EMIT(i);
+			EMIT(nr);
 		    }
 		    break;
 
@@ -1229,6 +1228,8 @@ nfa_do_multibyte:
 			    != (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,7 +1238,6 @@ nfa_do_multibyte:
 		     * 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);
@@ -2923,9 +2923,6 @@ nfa_regmatch(start, submatch, m)
     regsub_T		*submatch;
     regsub_T		*m;
 {
-    int		c;
-    int		n;
-    int		i = 0;
     int		result;
     int		size = 0;
     int		match = FALSE;
@@ -2939,6 +2936,7 @@ nfa_regmatch(start, submatch, m)
     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,7 +3002,7 @@ nfa_regmatch(start, submatch, m)
 #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);
+	addstate(ll, node->out , &t->sub, clen, listid + 1, &match);
 
 
     /*
@@ -3012,21 +3010,24 @@ nfa_regmatch(start, submatch, m)
      */
     for (;;)
     {
+	int	curc;
+	int	clen;
+
 #ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
-	    c = (*mb_ptr2char)(reginput);
-	    n = (*mb_ptr2len)(reginput);
+	    curc = (*mb_ptr2char)(reginput);
+	    clen = (*mb_ptr2len)(reginput);
 	}
 	else
 #endif
 	{
-	    c = *reginput;
-	    n = 1;
+	    curc = *reginput;
+	    clen = 1;
 	}
-	if (c == NUL)
+	if (curc == NUL)
 	{
-	    n = 0;
+	    clen = 0;
 	    go_to_nextline = FALSE;
 	}
 
@@ -3040,10 +3041,14 @@ nfa_regmatch(start, submatch, m)
 #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, ">>> Advanced one character ... Current char is %c (code %d) \n", curc, (int)curc);
 	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");
 #endif
 
@@ -3057,16 +3062,16 @@ nfa_regmatch(start, submatch, m)
 	    break;
 
 	/* 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)
 	    {
 		t = &neglist->t[0];
 		neglist->n--;
-		i--;
+		listidx--;
 	    }
 	    else
-		t = &thislist->t[i];
+		t = &thislist->t[listidx];
 
 #ifdef NFA_REGEXP_DEBUG_LOG
 	    nfa_set_code(t->state->c);
@@ -3116,7 +3121,7 @@ nfa_regmatch(start, submatch, m)
 		 * the parent call. */
 		if (start->c == NFA_MOPEN + 0)
 		    addstate_here(thislist, t->state->out, &t->sub, listid,
-								  &match, &i);
+							    &match, &listidx);
 		else
 		{
 		    *m = t->sub;
@@ -3190,7 +3195,7 @@ nfa_regmatch(start, submatch, m)
 			}
 		    /* t->state->out1 is the corresponding END_INVISIBLE node */
 		    addstate_here(thislist, t->state->out1->out, &t->sub,
-							  listid, &match, &i);
+						    listid, &match, &listidx);
 		}
 		else
 		{
@@ -3202,20 +3207,20 @@ nfa_regmatch(start, submatch, m)
 	    case NFA_BOL:
 		if (reginput == regline)
 		    addstate_here(thislist, t->state->out, &t->sub, listid,
-								  &match, &i);
+							    &match, &listidx);
 		break;
 
 	    case NFA_EOL:
-		if (c == NUL)
+		if (curc == NUL)
 		    addstate_here(thislist, t->state->out, &t->sub, listid,
-								  &match, &i);
+							    &match, &listidx);
 		break;
 
 	    case NFA_BOW:
 	    {
 		int bow = TRUE;
 
-		if (c == NUL)
+		if (curc == NUL)
 		    bow = FALSE;
 #ifdef FEAT_MBYTE
 		else if (has_mbyte)
@@ -3230,13 +3235,13 @@ nfa_regmatch(start, submatch, m)
 			bow = FALSE;
 		}
 #endif
-		else if (!vim_iswordc_buf(c, reg_buf)
+		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, &i);
+							    &match, &listidx);
 		break;
 	    }
 
@@ -3260,18 +3265,19 @@ nfa_regmatch(start, submatch, m)
 		}
 #endif
 		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;
 		if (eow)
 		    addstate_here(thislist, t->state->out, &t->sub, listid,
-								  &match, &i);
+							    &match, &listidx);
 		break;
 	    }
 
 #ifdef FEAT_MBYTE
 	    case NFA_COMPOSING:
 	    {
-		int	    mc = c;
+		int	    mc = curc;
 		int	    len = 0;
 		nfa_state_T *end;
 		nfa_state_T *sta;
@@ -3286,14 +3292,14 @@ nfa_regmatch(start, submatch, m)
 		    /* Only match composing character(s), ignore base
 		     * character.  Used for ".{composing}" and "{composing}"
 		     * (no preceding character). */
-		    len += mb_char2len(c);
+		    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 != c)
+		    if (len == 0 && sta->c != curc)
 			result = FAIL;
 		    else
 			result = OK;
@@ -3312,7 +3318,7 @@ nfa_regmatch(start, submatch, m)
 
 		    /* We don't care about the order of composing characters.
 		     * Get them into cchars[] first. */
-		    while (len < n)
+		    while (len < clen)
 		    {
 			mc = mb_ptr2char(reginput + len);
 			cchars[ccount++] = mc;
@@ -3349,7 +3355,7 @@ nfa_regmatch(start, submatch, m)
 
 	    case NFA_NEWL:
 		if (!reg_line_lbr && REG_MULTI
-					&& c == NUL && reglnum <= reg_maxline)
+				     && curc == NUL && reglnum <= reg_maxline)
 		{
 		    go_to_nextline = TRUE;
 		    /* 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_BACKSPACE:
 	    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);
 		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);
+		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 (c > 0)
-		    addstate(nextlist, t->state->out, &t->sub, n, listid + 1,
-								    &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(c);
+		result = vim_isIDc(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_SIDENT:	/*  \I	*/
-		result = !VIM_ISDIGIT(c) && vim_isIDc(c);
+		result = !VIM_ISDIGIT(curc) && vim_isIDc(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
@@ -3413,17 +3419,18 @@ nfa_regmatch(start, submatch, m)
 		break;
 
 	    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);
 		break;
 
 	    case NFA_FNAME:	/*  \f	*/
-		result = vim_isfilec(c);
+		result = vim_isfilec(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_SFNAME:	/*  \F	*/
-		result = !VIM_ISDIGIT(c) && vim_isfilec(c);
+		result = !VIM_ISDIGIT(curc) && vim_isfilec(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
@@ -3433,97 +3440,97 @@ nfa_regmatch(start, submatch, m)
 		break;
 
 	    case NFA_SPRINT:	/*  \P	*/
-		result = !VIM_ISDIGIT(c) && ptr2cells(reginput) == 1;
+		result = !VIM_ISDIGIT(curc) && ptr2cells(reginput) == 1;
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_WHITE:	/*  \s	*/
-		result = vim_iswhite(c);
+		result = vim_iswhite(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NWHITE:	/*  \S	*/
-		result = c != NUL && !vim_iswhite(c);
+		result = curc != NUL && !vim_iswhite(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_DIGIT:	/*  \d	*/
-		result = ri_digit(c);
+		result = ri_digit(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NDIGIT:	/*  \D	*/
-		result = c != NUL && !ri_digit(c);
+		result = curc != NUL && !ri_digit(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_HEX:	/*  \x	*/
-		result = ri_hex(c);
+		result = ri_hex(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NHEX:	/*  \X	*/
-		result = c != NUL && !ri_hex(c);
+		result = curc != NUL && !ri_hex(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_OCTAL:	/*  \o	*/
-		result = ri_octal(c);
+		result = ri_octal(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NOCTAL:	/*  \O	*/
-		result = c != NUL && !ri_octal(c);
+		result = curc != NUL && !ri_octal(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_WORD:	/*  \w	*/
-		result = ri_word(c);
+		result = ri_word(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NWORD:	/*  \W	*/
-		result = c != NUL && !ri_word(c);
+		result = curc != NUL && !ri_word(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_HEAD:	/*  \h	*/
-		result = ri_head(c);
+		result = ri_head(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NHEAD:	/*  \H	*/
-		result = c != NUL && !ri_head(c);
+		result = curc != NUL && !ri_head(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_ALPHA:	/*  \a	*/
-		result = ri_alpha(c);
+		result = ri_alpha(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NALPHA:	/*  \A	*/
-		result = c != NUL && !ri_alpha(c);
+		result = curc != NUL && !ri_alpha(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_LOWER:	/*  \l	*/
-		result = ri_lower(c);
+		result = ri_lower(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NLOWER:	/*  \L	*/
-		result = c != NUL && !ri_lower(c);
+		result = curc != NUL && !ri_lower(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_UPPER:	/*  \u	*/
-		result = ri_upper(c);
+		result = ri_upper(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
 	    case NFA_NUPPER:	/* \U	*/
-		result = c != NUL && !ri_upper(c);
+		result = curc != NUL && !ri_upper(curc);
 		ADD_POS_NEG_STATE(t->state);
 		break;
 
@@ -3549,17 +3556,17 @@ nfa_regmatch(start, submatch, m)
 		/* 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);
+		result = (no_Magic(t->state->c) == curc);
 
 		if (!result)
 		    result = ireg_ic == TRUE
-				&& MB_TOLOWER(t->state->c) == MB_TOLOWER(c);
+			       && 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
-						      && n != utf_char2len(c))
+						&& clen != utf_char2len(curc))
 		    result = FALSE;
 #endif
 		ADD_POS_NEG_STATE(t->state);
@@ -3578,21 +3585,25 @@ nfa_regmatch(start, submatch, m)
 #ifdef ENABLE_LOG
 	    fprintf(log_fd, "(---) STARTSTATE\n");
 #endif
-	    addstate(nextlist, start, m, n, listid + 1, &match);
+	    addstate(nextlist, start, m, clen, 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));
+	{
+	    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 (n != 0)
-	    reginput += n;
+	if (clen != 0)
+	    reginput += clen;
 	else if (go_to_nextline)
 	    reg_nextline();
 	else
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1022,
+/**/
     1021,
 /**/
     1020,