mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
updated for version 7.3.1012
Problem: \Z does not work properly with the new regexp engine. Solution: Make \Z work. Add tests.
This commit is contained in:
@@ -1184,14 +1184,15 @@ collection:
|
|||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
} /* if exists closing ] */
|
} /* if exists closing ] */
|
||||||
else if (reg_strict)
|
|
||||||
|
if (reg_strict)
|
||||||
{
|
{
|
||||||
syntax_error = TRUE;
|
syntax_error = TRUE;
|
||||||
EMSG_RET_FAIL(_(e_missingbracket));
|
EMSG_RET_FAIL(_(e_missingbracket));
|
||||||
}
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
@@ -1214,7 +1215,7 @@ nfa_do_multibyte:
|
|||||||
EMIT(c);
|
EMIT(c);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
if (i += utf_char2len(c) >= plen)
|
if ((i += utf_char2len(c)) >= plen)
|
||||||
break;
|
break;
|
||||||
c = utf_ptr2char(old_regparse + i);
|
c = utf_ptr2char(old_regparse + i);
|
||||||
}
|
}
|
||||||
@@ -2269,7 +2270,7 @@ post2nfa(postfix, end, nfa_calc_size)
|
|||||||
/* TODO */
|
/* TODO */
|
||||||
if (regflags & RF_ICOMBINE)
|
if (regflags & RF_ICOMBINE)
|
||||||
{
|
{
|
||||||
goto normalchar;
|
/* use the base character only */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
@@ -3145,23 +3146,31 @@ nfa_regmatch(start, submatch, m)
|
|||||||
result = OK;
|
result = OK;
|
||||||
sta = t->state->out;
|
sta = t->state->out;
|
||||||
len = 0;
|
len = 0;
|
||||||
while (sta->c != NFA_END_COMPOSING && len < n)
|
if (ireg_icombine)
|
||||||
{
|
{
|
||||||
if (len > 0)
|
/* If \Z was present, then ignore composing characters. */
|
||||||
mc = mb_ptr2char(reginput + len);
|
/* TODO: How about negated? */
|
||||||
if (mc != sta->c)
|
if (sta->c != c)
|
||||||
break;
|
result = FAIL;
|
||||||
len += mb_char2len(mc);
|
len = n;
|
||||||
sta = sta->out;
|
while (sta->c != NFA_END_COMPOSING)
|
||||||
|
sta = sta->out;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
while (sta->c != NFA_END_COMPOSING && len < n)
|
||||||
|
{
|
||||||
|
if (len > 0)
|
||||||
|
mc = mb_ptr2char(reginput + len);
|
||||||
|
if (mc != sta->c)
|
||||||
|
break;
|
||||||
|
len += mb_char2len(mc);
|
||||||
|
sta = sta->out;
|
||||||
|
}
|
||||||
|
|
||||||
/* if input char length doesn't match regexp char length */
|
/* if input char length doesn't match regexp char length */
|
||||||
if (len < n || sta->c != NFA_END_COMPOSING)
|
if (len < n || sta->c != NFA_END_COMPOSING)
|
||||||
result = FAIL;
|
result = FAIL;
|
||||||
end = t->state->out1; /* NFA_END_COMPOSING */
|
end = t->state->out1; /* NFA_END_COMPOSING */
|
||||||
/* If \Z was present, then ignore composing characters */
|
|
||||||
if (ireg_icombine)
|
|
||||||
result = 1 ^ sta->negated;
|
|
||||||
ADD_POS_NEG_STATE(end);
|
ADD_POS_NEG_STATE(end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,15 @@ STARTTEST
|
|||||||
|
|
||||||
:"""" Test \Z
|
:"""" Test \Z
|
||||||
:call add(tl, ['ú\Z', 'x'])
|
:call add(tl, ['ú\Z', 'x'])
|
||||||
|
:call add(tl, ['יהוה\Z', 'יהוה', 'יהוה'])
|
||||||
|
:call add(tl, ['יְהוָה\Z', 'יהוה', 'יהוה'])
|
||||||
|
:call add(tl, ['יהוה\Z', 'יְהוָה', 'יְהוָה'])
|
||||||
|
:call add(tl, ['יְהוָה\Z', 'יְהוָה', 'יְהוָה'])
|
||||||
|
:call add(tl, ['יְ\Z', 'וְיַ', 'יַ'])
|
||||||
|
:call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
|
||||||
|
:call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200dxy", "ק\u200dx"])
|
||||||
|
:call add(tl, ["ק\u200dx\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
|
||||||
|
:call add(tl, ["ק\u200dx\\Z", "xק\u200dxy", "ק\u200dx"])
|
||||||
|
|
||||||
:"""" Combining different tests and features
|
:"""" Combining different tests and features
|
||||||
:call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd'])
|
:call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd'])
|
||||||
|
@@ -12,4 +12,13 @@ OK - \%#=1\f\+
|
|||||||
OK - .ม
|
OK - .ม
|
||||||
OK - .ม่
|
OK - .ม่
|
||||||
OK - ú\Z
|
OK - ú\Z
|
||||||
|
OK - יהוה\Z
|
||||||
|
OK - יְהוָה\Z
|
||||||
|
OK - יהוה\Z
|
||||||
|
OK - יְהוָה\Z
|
||||||
|
OK - יְ\Z
|
||||||
|
OK - קֹx\Z
|
||||||
|
OK - קֹx\Z
|
||||||
|
OK - קx\Z
|
||||||
|
OK - קx\Z
|
||||||
OK - [^[=a=]]\+
|
OK - [^[=a=]]\+
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1012,
|
||||||
/**/
|
/**/
|
||||||
1011,
|
1011,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user