]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.037 v7.4.037
authorBram Moolenaar <Bram@vim.org>
Wed, 25 Sep 2013 16:16:38 +0000 (18:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 Sep 2013 16:16:38 +0000 (18:16 +0200)
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.

src/regexp_nfa.c
src/testdir/test64.in
src/testdir/test64.ok
src/version.c

index cd58b618e2812b65d62b82d9c07736d8b095a56a..216459c4d0b29389ba7ca3c5d4e9671b44945c09 100644 (file)
@@ -3822,6 +3822,7 @@ static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from));
 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));
@@ -3908,6 +3909,29 @@ copy_sub_off(to, from)
     }
 }
 
+/*
+ * 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.
  */
@@ -5308,6 +5332,7 @@ find_match_text(startcol, regstart, match_text)
  * 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,6 +5658,9 @@ nfa_regmatch(prog, start, submatch, m)
                            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
index ef04ba26a68901c0965d1e757ad8b9b36e0b58a8..2df9a6b60e2424d47fdfefdce2bf8694a6766233 100644 (file)
@@ -425,6 +425,7 @@ STARTTEST
 :"
 :" complicated look-behind match
 :call add(tl, [2, '\(r\@<=\|\w\@<!\)\/', 'x = /word/;', '/'])
+:call add(tl, [2, '^[a-z]\+\ze \&\(asdf\)\@<!', 'foo bar', 'foo'])
 :"
 :""""" \@>
 :call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
index a1c3f56e950eb63587128768aa00957efaa1cbe1..401da4071dbb82655a67793376e98a945d68b615 100644 (file)
@@ -983,6 +983,9 @@ OK 2 - \(foo\)\@<=.*
 OK 0 - \(r\@<=\|\w\@<!\)\/
 OK 1 - \(r\@<=\|\w\@<!\)\/
 OK 2 - \(r\@<=\|\w\@<!\)\/
+OK 0 - ^[a-z]\+\ze \&\(asdf\)\@<!
+OK 1 - ^[a-z]\+\ze \&\(asdf\)\@<!
+OK 2 - ^[a-z]\+\ze \&\(asdf\)\@<!
 OK 0 - \(a*\)\@>a
 OK 1 - \(a*\)\@>a
 OK 2 - \(a*\)\@>a
index 2a4bc9c805a86ba4e367cc50d18a1cbc20c0eede..08220ef8415f25be855bd442ff9711125a014f82 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    37,
 /**/
     36,
 /**/