To:
[email protected]
Subject: Patch 7.4b.002
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.4b.002
Problem: Crash searching for \%(\%(\|\d\|-\|\.\)*\|\*\). (Marcin
Szamotulski) Also for \(\)*.
Solution: Do add a state for opening parenthesis, so that we can check if it
was added before at the same position.
Files: src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
*** ../vim-7.4b.001/src/regexp_nfa.c 2013-07-21 18:54:02.000000000 +0200
--- src/regexp_nfa.c 2013-08-01 15:27:19.000000000 +0200
***************
*** 3910,3924 ****
case NFA_ZCLOSE8:
case NFA_ZCLOSE9:
#endif
case NFA_ZEND:
case NFA_SPLIT:
- case NFA_NOPEN:
case NFA_SKIP_CHAR:
/* These nodes are not added themselves but their "out" and/or
* "out1" may be added below. */
break;
! case NFA_MOPEN:
case NFA_MOPEN1:
case NFA_MOPEN2:
case NFA_MOPEN3:
--- 3910,3936 ----
case NFA_ZCLOSE8:
case NFA_ZCLOSE9:
#endif
+ case NFA_MOPEN:
case NFA_ZEND:
case NFA_SPLIT:
case NFA_SKIP_CHAR:
/* These nodes are not added themselves but their "out" and/or
* "out1" may be added below. */
break;
! case NFA_BOL:
! case NFA_BOF:
! /* "^" won't match past end-of-line, don't bother trying.
! * Except when at the end of the line, or when we are going to the
! * next line for a look-behind match. */
! if (reginput > regline
! && *reginput != NUL
! && (nfa_endp == NULL
! || !REG_MULTI
! || reglnum == nfa_endp->se_u.pos.lnum))
! goto skip_add;
! /* FALLTHROUGH */
!
case NFA_MOPEN1:
case NFA_MOPEN2:
case NFA_MOPEN3:
***************
*** 3940,3965 ****
case NFA_ZOPEN8:
case NFA_ZOPEN9:
#endif
case NFA_ZSTART:
! /* These nodes do not need to be added, but we need to bail out
! * when it was tried to be added to this list before. */
! if (state->lastlist[nfa_ll_index] == l->id)
! goto skip_add;
! state->lastlist[nfa_ll_index] = l->id;
! break;
!
! case NFA_BOL:
! case NFA_BOF:
! /* "^" won't match past end-of-line, don't bother trying.
! * Except when at the end of the line, or when we are going to the
! * next line for a look-behind match. */
! if (reginput > regline
! && *reginput != NUL
! && (nfa_endp == NULL
! || !REG_MULTI
! || reglnum == nfa_endp->se_u.pos.lnum))
! goto skip_add;
! /* FALLTHROUGH */
default:
if (state->lastlist[nfa_ll_index] == l->id)
--- 3952,3962 ----
case NFA_ZOPEN8:
case NFA_ZOPEN9:
#endif
+ case NFA_NOPEN:
case NFA_ZSTART:
! /* These nodes need to be added so that we can bail out when it
! * was added to this list before at the same position to avoid an
! * endless loop for "\(\)*" */
default:
if (state->lastlist[nfa_ll_index] == l->id)
***************
*** 6025,6037 ****
#endif
break;
default: /* regular character */
{
int c = t->state->c;
! /* TODO: put this in #ifdef later */
if (c < 0)
EMSGN("INTERNAL: Negative state char: %ld", c);
result = (c == curc);
if (!result && ireg_ic)
--- 6022,6062 ----
#endif
break;
+ case NFA_MOPEN1:
+ case NFA_MOPEN2:
+ case NFA_MOPEN3:
+ case NFA_MOPEN4:
+ case NFA_MOPEN5:
+ case NFA_MOPEN6:
+ case NFA_MOPEN7:
+ case NFA_MOPEN8:
+ case NFA_MOPEN9:
+ #ifdef FEAT_SYN_HL
+ case NFA_ZOPEN:
+ case NFA_ZOPEN1:
+ case NFA_ZOPEN2:
+ case NFA_ZOPEN3:
+ case NFA_ZOPEN4:
+ case NFA_ZOPEN5:
+ case NFA_ZOPEN6:
+ case NFA_ZOPEN7:
+ case NFA_ZOPEN8:
+ case NFA_ZOPEN9:
+ #endif
+ case NFA_NOPEN:
+ case NFA_ZSTART:
+ /* These states are only added to be able to bail out when
+ * they are added again, nothing is to be done. */
+ break;
+
default: /* regular character */
{
int c = t->state->c;
! #ifdef DEBUG
if (c < 0)
EMSGN("INTERNAL: Negative state char: %ld", c);
+ #endif
result = (c == curc);
if (!result && ireg_ic)
*** ../vim-7.4b.001/src/testdir/test64.in 2013-07-21 18:53:22.000000000 +0200
--- src/testdir/test64.in 2013-08-01 15:16:02.000000000 +0200
***************
*** 340,345 ****
--- 340,346 ----
:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo bar '])
:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo xxx ', 'foo'])
:call add(tl, [2, '[ ]\@!\p\%([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:'])
+ :call add(tl, [2, '[ ]\@!\p\([ ]\@!\p\)*:', 'implicit mappings:', 'mappings:', 's'])
:call add(tl, [2, 'm\k\+_\@=\%(_\@!\k\)\@<=\k\+e', 'mx__xe', 'mx__xe'])
:call add(tl, [2, '\%(\U\@<=S\k*\|S\l\)R', 'SuR', 'SuR'])
:"
*** ../vim-7.4b.001/src/testdir/test64.ok 2013-07-21 18:55:44.000000000 +0200
--- src/testdir/test64.ok 2013-08-01 15:28:34.000000000 +0200
***************
*** 776,781 ****
--- 776,784 ----
OK 0 - [ ]\@!\p\%([ ]\@!\p\)*:
OK 1 - [ ]\@!\p\%([ ]\@!\p\)*:
OK 2 - [ ]\@!\p\%([ ]\@!\p\)*:
+ OK 0 - [ ]\@!\p\([ ]\@!\p\)*:
+ OK 1 - [ ]\@!\p\([ ]\@!\p\)*:
+ OK 2 - [ ]\@!\p\([ ]\@!\p\)*:
OK 0 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
OK 1 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
OK 2 - m\k\+_\@=\%(_\@!\k\)\@<=\k\+e
*** ../vim-7.4b.001/src/version.c 2013-08-01 13:20:23.000000000 +0200
--- src/version.c 2013-08-01 15:33:20.000000000 +0200
***************
*** 729,730 ****
--- 729,732 ----
{ /* Add new patch number below this line */
+ /**/
+ 2,
/**/
--
hundred-and-one symptoms of being an internet addict:
34. You laugh at people with a 10 Mbit connection.
/// Bram Moolenaar --
[email protected] --
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 ///