]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.1243 v7.3.1243
authorBram Moolenaar <Bram@vim.org>
Wed, 26 Jun 2013 10:42:44 +0000 (12:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 26 Jun 2013 10:42:44 +0000 (12:42 +0200)
Problem:    New regexp engine: back references in look-behind match don't
            work. (Lech Lorens)
Solution:   Copy the submatches before a recursive match.

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

index 01bc065b969d7c96ca3bd7e1e71019c0e0c53c8a..cba4001faa4a25a37a6f7e6d7efb01d778f5a0c3 100644 (file)
@@ -290,10 +290,11 @@ static void nfa_dump __ARGS((nfa_regprog_T *prog));
 #endif
 static int *re2post __ARGS((void));
 static nfa_state_T *alloc_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1));
+static void st_error __ARGS((int *postfix, int *end, int *p));
+static int nfa_max_width __ARGS((nfa_state_T *startstate, int depth));
 static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size));
 static void nfa_postprocess __ARGS((nfa_regprog_T *prog));
 static int check_char_class __ARGS((int class, int c));
-static void st_error __ARGS((int *postfix, int *end, int *p));
 static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
 static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
 static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
@@ -3469,6 +3470,7 @@ typedef struct
 #ifdef ENABLE_LOG
 static void log_subsexpr __ARGS((regsubs_T *subs));
 static void log_subexpr __ARGS((regsub_T *sub));
+static char *pim_info __ARGS((nfa_pim_T *pim));
 
     static void
 log_subsexpr(subs)
@@ -3508,7 +3510,8 @@ log_subexpr(sub)
 }
 
     static char *
-pim_info(nfa_pim_T *pim)
+pim_info(pim)
+    nfa_pim_T *pim;
 {
     static char buf[30];
 
@@ -3532,6 +3535,7 @@ 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 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));
 static int state_in_list __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs));
 static void addstate __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int off));
@@ -4319,8 +4323,6 @@ check_char_class(class, c)
     return FAIL;
 }
 
-static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen));
-
 /*
  * Check for a match with subexpression "subidx".
  * Return TRUE if it matches.
@@ -5195,6 +5197,10 @@ nfa_regmatch(prog, start, submatch, m)
                         || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST
                         || t->state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)
                    {
+                       /* Copy submatch info for the recursive call, so that
+                        * \1 can be matched. */
+                       copy_sub_off(&m->norm, &t->subs.norm);
+
                        /*
                         * First try matching the invisible match, then what
                         * follows.
index 7c141797db3e79b04b4077ea2b2f834289308e9f..4fdbcf73e39c256d8f6fecf212fbcc6249d8904a 100644 (file)
@@ -380,6 +380,9 @@ STARTTEST
 :call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i'])
 :call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
 :call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
+:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.com', 'foo.bat/foo.com', 'bat'])
+:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<!$', 'foo.bat/foo.bat'])
+:call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<=$', 'foo.bat/foo.bat', 'foo.bat/foo.bat', 'bat', 'bat'])
 :"
 :"""" Look-behind with limit
 :call add(tl, [2, '<\@<=span.', 'xxspanxx<spanyyy', 'spany'])
index fa31c8a84c21489421c40efc59ada39f29bfc04b..d1f41138534c970e2e9a6aac6bf76b41d5372adf 100644 (file)
@@ -866,6 +866,15 @@ OK 2 - \(\d*\)a \1b
 OK 0 - ^.\(.\).\_..\1.
 OK 1 - ^.\(.\).\_..\1.
 OK 2 - ^.\(.\).\_..\1.
+OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<!$
+OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
+OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
+OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
 OK 0 - <\@<=span.
 OK 1 - <\@<=span.
 OK 2 - <\@<=span.
index cd804017c6508a895a7936ace213a85dd9b9a8bb..c1cf11ddd15a9d6e7b674ca39dea9e63cebb0fb4 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1243,
 /**/
     1242,
 /**/