comparison src/regexp_nfa.c @ 5893:99374096a76b v7.4.289

updated for version 7.4.289 Problem: Pattern with repeated backreference does not match with new regexp engine. (Urtica Dioica) Solution: Also check the end of a submatch when deciding to put a state in the state list.
author Bram Moolenaar <bram@vim.org>
date Tue, 13 May 2014 15:56:51 +0200
parents 0ea551fa607d
children b871734bf54e
comparison
equal deleted inserted replaced
5892:c545fd75b0ac 5893:99374096a76b
3943 } 3943 }
3944 } 3944 }
3945 3945
3946 /* 3946 /*
3947 * Return TRUE if "sub1" and "sub2" have the same start positions. 3947 * Return TRUE if "sub1" and "sub2" have the same start positions.
3948 * When using back-references also check the end position.
3948 */ 3949 */
3949 static int 3950 static int
3950 sub_equal(sub1, sub2) 3951 sub_equal(sub1, sub2)
3951 regsub_T *sub1; 3952 regsub_T *sub1;
3952 regsub_T *sub2; 3953 regsub_T *sub2;
3974 if (s1 != s2) 3975 if (s1 != s2)
3975 return FALSE; 3976 return FALSE;
3976 if (s1 != -1 && sub1->list.multi[i].start.col 3977 if (s1 != -1 && sub1->list.multi[i].start.col
3977 != sub2->list.multi[i].start.col) 3978 != sub2->list.multi[i].start.col)
3978 return FALSE; 3979 return FALSE;
3980
3981 if (nfa_has_backref)
3982 {
3983 if (i < sub1->in_use)
3984 s1 = sub1->list.multi[i].end.lnum;
3985 else
3986 s1 = -1;
3987 if (i < sub2->in_use)
3988 s2 = sub2->list.multi[i].end.lnum;
3989 else
3990 s2 = -1;
3991 if (s1 != s2)
3992 return FALSE;
3993 if (s1 != -1 && sub1->list.multi[i].end.col
3994 != sub2->list.multi[i].end.col)
3995 return FALSE;
3996 }
3979 } 3997 }
3980 } 3998 }
3981 else 3999 else
3982 { 4000 {
3983 for (i = 0; i < todo; ++i) 4001 for (i = 0; i < todo; ++i)
3990 sp2 = sub2->list.line[i].start; 4008 sp2 = sub2->list.line[i].start;
3991 else 4009 else
3992 sp2 = NULL; 4010 sp2 = NULL;
3993 if (sp1 != sp2) 4011 if (sp1 != sp2)
3994 return FALSE; 4012 return FALSE;
4013 if (nfa_has_backref)
4014 {
4015 if (i < sub1->in_use)
4016 sp1 = sub1->list.line[i].end;
4017 else
4018 sp1 = NULL;
4019 if (i < sub2->in_use)
4020 sp2 = sub2->list.line[i].end;
4021 else
4022 sp2 = NULL;
4023 if (sp1 != sp2)
4024 return FALSE;
4025 }
3995 } 4026 }
3996 } 4027 }
3997 4028
3998 return TRUE; 4029 return TRUE;
3999 } 4030 }