|
Karsten Hopp |
2d1b1e |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
2d1b1e |
Subject: Patch 7.3.1082
|
|
Karsten Hopp |
2d1b1e |
Fcc: outbox
|
|
Karsten Hopp |
2d1b1e |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
2d1b1e |
Mime-Version: 1.0
|
|
Karsten Hopp |
2d1b1e |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
2d1b1e |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
2d1b1e |
------------
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
Patch 7.3.1082
|
|
Karsten Hopp |
2d1b1e |
Problem: New regexp engine: Problem with \@= matching.
|
|
Karsten Hopp |
2d1b1e |
Solution: Save and restore nfa_match.
|
|
Karsten Hopp |
2d1b1e |
Files: src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
*** ../vim-7.3.1081/src/regexp_nfa.c 2013-05-31 20:49:27.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
--- src/regexp_nfa.c 2013-05-31 21:19:15.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 3332,3342 ****
|
|
Karsten Hopp |
2d1b1e |
int result;
|
|
Karsten Hopp |
2d1b1e |
int size = 0;
|
|
Karsten Hopp |
2d1b1e |
int flag = 0;
|
|
Karsten Hopp |
2d1b1e |
- int old_reglnum = -1;
|
|
Karsten Hopp |
2d1b1e |
int go_to_nextline = FALSE;
|
|
Karsten Hopp |
2d1b1e |
nfa_thread_T *t;
|
|
Karsten Hopp |
2d1b1e |
- char_u *old_reginput = NULL;
|
|
Karsten Hopp |
2d1b1e |
- char_u *old_regline = NULL;
|
|
Karsten Hopp |
2d1b1e |
nfa_list_T list[3];
|
|
Karsten Hopp |
2d1b1e |
nfa_list_T *listtbl[2][2];
|
|
Karsten Hopp |
2d1b1e |
nfa_list_T *ll;
|
|
Karsten Hopp |
2d1b1e |
--- 3332,3339 ----
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 3560,3574 ****
|
|
Karsten Hopp |
2d1b1e |
break;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
case NFA_START_INVISIBLE:
|
|
Karsten Hopp |
2d1b1e |
! /* Save global variables, and call nfa_regmatch() to check if
|
|
Karsten Hopp |
2d1b1e |
! * the current concat matches at this position. The concat
|
|
Karsten Hopp |
2d1b1e |
! * ends with the node NFA_END_INVISIBLE */
|
|
Karsten Hopp |
2d1b1e |
! old_reginput = reginput;
|
|
Karsten Hopp |
2d1b1e |
! old_regline = regline;
|
|
Karsten Hopp |
2d1b1e |
! old_reglnum = reglnum;
|
|
Karsten Hopp |
2d1b1e |
if (listids == NULL)
|
|
Karsten Hopp |
2d1b1e |
{
|
|
Karsten Hopp |
2d1b1e |
! listids = (int *) lalloc(sizeof(int) * nstate, TRUE);
|
|
Karsten Hopp |
2d1b1e |
if (listids == NULL)
|
|
Karsten Hopp |
2d1b1e |
{
|
|
Karsten Hopp |
2d1b1e |
EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!"));
|
|
Karsten Hopp |
2d1b1e |
--- 3557,3574 ----
|
|
Karsten Hopp |
2d1b1e |
break;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
case NFA_START_INVISIBLE:
|
|
Karsten Hopp |
2d1b1e |
! {
|
|
Karsten Hopp |
2d1b1e |
! char_u *save_reginput = reginput;
|
|
Karsten Hopp |
2d1b1e |
! char_u *save_regline = regline;
|
|
Karsten Hopp |
2d1b1e |
! int save_reglnum = reglnum;
|
|
Karsten Hopp |
2d1b1e |
! int save_nfa_match = nfa_match;
|
|
Karsten Hopp |
2d1b1e |
!
|
|
Karsten Hopp |
2d1b1e |
! /* Call nfa_regmatch() to check if the current concat matches
|
|
Karsten Hopp |
2d1b1e |
! * at this position. The concat ends with the node
|
|
Karsten Hopp |
2d1b1e |
! * NFA_END_INVISIBLE */
|
|
Karsten Hopp |
2d1b1e |
if (listids == NULL)
|
|
Karsten Hopp |
2d1b1e |
{
|
|
Karsten Hopp |
2d1b1e |
! listids = (int *)lalloc(sizeof(int) * nstate, TRUE);
|
|
Karsten Hopp |
2d1b1e |
if (listids == NULL)
|
|
Karsten Hopp |
2d1b1e |
{
|
|
Karsten Hopp |
2d1b1e |
EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!"));
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 3588,3594 ****
|
|
Karsten Hopp |
2d1b1e |
result = nfa_regmatch(t->state->out, submatch, m);
|
|
Karsten Hopp |
2d1b1e |
nfa_set_neg_listids(start);
|
|
Karsten Hopp |
2d1b1e |
nfa_restore_listids(start, listids);
|
|
Karsten Hopp |
2d1b1e |
! nfa_match = FALSE;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
#ifdef ENABLE_LOG
|
|
Karsten Hopp |
2d1b1e |
log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
|
|
Karsten Hopp |
2d1b1e |
--- 3588,3599 ----
|
|
Karsten Hopp |
2d1b1e |
result = nfa_regmatch(t->state->out, submatch, m);
|
|
Karsten Hopp |
2d1b1e |
nfa_set_neg_listids(start);
|
|
Karsten Hopp |
2d1b1e |
nfa_restore_listids(start, listids);
|
|
Karsten Hopp |
2d1b1e |
!
|
|
Karsten Hopp |
2d1b1e |
! /* restore position in input text */
|
|
Karsten Hopp |
2d1b1e |
! reginput = save_reginput;
|
|
Karsten Hopp |
2d1b1e |
! regline = save_regline;
|
|
Karsten Hopp |
2d1b1e |
! reglnum = save_reglnum;
|
|
Karsten Hopp |
2d1b1e |
! nfa_match = save_nfa_match;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
#ifdef ENABLE_LOG
|
|
Karsten Hopp |
2d1b1e |
log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 3610,3619 ****
|
|
Karsten Hopp |
2d1b1e |
{
|
|
Karsten Hopp |
2d1b1e |
int j;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
- /* Restore position in input text */
|
|
Karsten Hopp |
2d1b1e |
- reginput = old_reginput;
|
|
Karsten Hopp |
2d1b1e |
- regline = old_regline;
|
|
Karsten Hopp |
2d1b1e |
- reglnum = old_reglnum;
|
|
Karsten Hopp |
2d1b1e |
/* Copy submatch info from the recursive call */
|
|
Karsten Hopp |
2d1b1e |
if (REG_MULTI)
|
|
Karsten Hopp |
2d1b1e |
for (j = 1; j < m->in_use; j++)
|
|
Karsten Hopp |
2d1b1e |
--- 3615,3620 ----
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 3635,3646 ****
|
|
Karsten Hopp |
2d1b1e |
addstate_here(thislist, t->state->out1->out, &t->sub,
|
|
Karsten Hopp |
2d1b1e |
&listidx);
|
|
Karsten Hopp |
2d1b1e |
}
|
|
Karsten Hopp |
2d1b1e |
- else
|
|
Karsten Hopp |
2d1b1e |
- {
|
|
Karsten Hopp |
2d1b1e |
- /* continue with next input char */
|
|
Karsten Hopp |
2d1b1e |
- reginput = old_reginput;
|
|
Karsten Hopp |
2d1b1e |
- }
|
|
Karsten Hopp |
2d1b1e |
break;
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
case NFA_BOL:
|
|
Karsten Hopp |
2d1b1e |
if (reginput == regline)
|
|
Karsten Hopp |
2d1b1e |
--- 3636,3643 ----
|
|
Karsten Hopp |
2d1b1e |
addstate_here(thislist, t->state->out1->out, &t->sub,
|
|
Karsten Hopp |
2d1b1e |
&listidx);
|
|
Karsten Hopp |
2d1b1e |
}
|
|
Karsten Hopp |
2d1b1e |
break;
|
|
Karsten Hopp |
2d1b1e |
+ }
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
case NFA_BOL:
|
|
Karsten Hopp |
2d1b1e |
if (reginput == regline)
|
|
Karsten Hopp |
2d1b1e |
*** ../vim-7.3.1081/src/testdir/test64.in 2013-05-30 22:43:57.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
--- src/testdir/test64.in 2013-05-31 21:14:37.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 305,310 ****
|
|
Karsten Hopp |
2d1b1e |
--- 305,311 ----
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
|
|
Karsten Hopp |
2d1b1e |
+ :call add(tl, [2, '\<\S\+\())\)\@=', '$((i=i+1))', 'i=i+1', '))'])
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
|
|
Karsten Hopp |
2d1b1e |
:call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
|
|
Karsten Hopp |
2d1b1e |
*** ../vim-7.3.1081/src/testdir/test64.ok 2013-05-30 22:43:57.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
--- src/testdir/test64.ok 2013-05-31 21:16:29.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 669,674 ****
|
|
Karsten Hopp |
2d1b1e |
--- 669,677 ----
|
|
Karsten Hopp |
2d1b1e |
OK 0 - \(John.*\)\@=.*Bob
|
|
Karsten Hopp |
2d1b1e |
OK 1 - \(John.*\)\@=.*Bob
|
|
Karsten Hopp |
2d1b1e |
OK 2 - \(John.*\)\@=.*Bob
|
|
Karsten Hopp |
2d1b1e |
+ OK 0 - \<\S\+\())\)\@=
|
|
Karsten Hopp |
2d1b1e |
+ OK 1 - \<\S\+\())\)\@=
|
|
Karsten Hopp |
2d1b1e |
+ OK 2 - \<\S\+\())\)\@=
|
|
Karsten Hopp |
2d1b1e |
OK 0 - .*John\&.*Bob
|
|
Karsten Hopp |
2d1b1e |
OK 1 - .*John\&.*Bob
|
|
Karsten Hopp |
2d1b1e |
OK 2 - .*John\&.*Bob
|
|
Karsten Hopp |
2d1b1e |
*** ../vim-7.3.1081/src/version.c 2013-05-31 20:49:27.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
--- src/version.c 2013-05-31 21:21:12.000000000 +0200
|
|
Karsten Hopp |
2d1b1e |
***************
|
|
Karsten Hopp |
2d1b1e |
*** 730,731 ****
|
|
Karsten Hopp |
2d1b1e |
--- 730,733 ----
|
|
Karsten Hopp |
2d1b1e |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
2d1b1e |
+ /**/
|
|
Karsten Hopp |
2d1b1e |
+ 1082,
|
|
Karsten Hopp |
2d1b1e |
/**/
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
--
|
|
Karsten Hopp |
2d1b1e |
To define recursion, we must first define recursion.
|
|
Karsten Hopp |
2d1b1e |
|
|
Karsten Hopp |
2d1b1e |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
2d1b1e |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
2d1b1e |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
2d1b1e |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|