To: vim_dev@googlegroups.com Subject: Patch 7.4.037 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.037 Problem: Using "\ze" in a sub-pattern does not result in the end of the match to be set. (Axel Bender) Solution: Copy the end of match position when a recursive match was successful. Files: src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok *** ../vim-7.4.036/src/regexp_nfa.c 2013-09-25 16:41:50.000000000 +0200 --- src/regexp_nfa.c 2013-09-25 18:09:59.000000000 +0200 *************** *** 3822,3827 **** --- 3822,3828 ---- static void clear_sub __ARGS((regsub_T *sub)); static void copy_sub __ARGS((regsub_T *to, regsub_T *from)); static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from)); + static void copy_ze_off __ARGS((regsub_T *to, regsub_T *from)); static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2)); static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen)); static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim)); *************** *** 3909,3914 **** --- 3910,3938 ---- } /* + * Like copy_sub() but only do the end of the main match if \ze is present. + */ + static void + copy_ze_off(to, from) + regsub_T *to; + regsub_T *from; + { + if (nfa_has_zend) + { + if (REG_MULTI) + { + if (from->list.multi[0].end.lnum >= 0) + to->list.multi[0].end = from->list.multi[0].end; + } + else + { + if (from->list.line[0].end != NULL) + to->list.line[0].end = from->list.line[0].end; + } + } + } + + /* * Return TRUE if "sub1" and "sub2" have the same start positions. */ static int *************** *** 5308,5313 **** --- 5332,5338 ---- * When "nfa_endp" is not NULL it is a required end-of-match position. * * Return TRUE if there is a match, FALSE otherwise. + * When there is a match "submatch" contains the positions. * Note: Caller must ensure that: start != NULL. */ static int *************** *** 5633,5638 **** --- 5658,5666 ---- if (nfa_has_zsubexpr) copy_sub_off(&t->subs.synt, &m->synt); #endif + /* If the pattern has \ze and it matched in the + * sub pattern, use it. */ + copy_ze_off(&t->subs.norm, &m->norm); /* t->state->out1 is the corresponding * END_INVISIBLE node; Add its out to the current *** ../vim-7.4.036/src/testdir/test64.in 2013-09-25 16:41:50.000000000 +0200 --- src/testdir/test64.in 2013-09-25 18:09:16.000000000 +0200 *************** *** 425,430 **** --- 425,431 ---- :" :" complicated look-behind match :call add(tl, [2, '\(r\@<=\|\w\@ :call add(tl, [2, '\(a*\)\@>a', 'aaaa']) *** ../vim-7.4.036/src/testdir/test64.ok 2013-09-25 16:41:50.000000000 +0200 --- src/testdir/test64.ok 2013-09-25 18:10:05.000000000 +0200 *************** *** 983,988 **** --- 983,991 ---- OK 0 - \(r\@<=\|\w\@a OK 1 - \(a*\)\@>a OK 2 - \(a*\)\@>a *** ../vim-7.4.036/src/version.c 2013-09-25 16:41:50.000000000 +0200 --- src/version.c 2013-09-25 18:14:36.000000000 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 37, /**/ -- MAN: You don't frighten us, English pig-dog! Go and boil your bottoms, son of a silly person. I blow my nose on you, so-called Arthur-king, you and your silly English K...kaniggets. He puts hands to his ears and blows a raspberry. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///