@@ -3822,6 +3822,7 @@ static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from));
38223822static void clear_sub __ARGS ((regsub_T * sub ));
38233823static void copy_sub __ARGS ((regsub_T * to , regsub_T * from ));
38243824static void copy_sub_off __ARGS ((regsub_T * to , regsub_T * from ));
3825+ static void copy_ze_off __ARGS ((regsub_T * to , regsub_T * from ));
38253826static int sub_equal __ARGS ((regsub_T * sub1 , regsub_T * sub2 ));
38263827static int match_backref __ARGS ((regsub_T * sub , int subidx , int * bytelen ));
38273828static 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)
39083909 }
39093910}
39103911
3912+ /*
3913+ * Like copy_sub() but only do the end of the main match if \ze is present.
3914+ */
3915+ static void
3916+ copy_ze_off (to , from )
3917+ regsub_T * to ;
3918+ regsub_T * from ;
3919+ {
3920+ if (nfa_has_zend )
3921+ {
3922+ if (REG_MULTI )
3923+ {
3924+ if (from -> list .multi [0 ].end .lnum >= 0 )
3925+ to -> list .multi [0 ].end = from -> list .multi [0 ].end ;
3926+ }
3927+ else
3928+ {
3929+ if (from -> list .line [0 ].end != NULL )
3930+ to -> list .line [0 ].end = from -> list .line [0 ].end ;
3931+ }
3932+ }
3933+ }
3934+
39113935/*
39123936 * Return TRUE if "sub1" and "sub2" have the same start positions.
39133937 */
@@ -5308,6 +5332,7 @@ find_match_text(startcol, regstart, match_text)
53085332 * When "nfa_endp" is not NULL it is a required end-of-match position.
53095333 *
53105334 * Return TRUE if there is a match, FALSE otherwise.
5335+ * When there is a match "submatch" contains the positions.
53115336 * Note: Caller must ensure that: start != NULL.
53125337 */
53135338 static int
@@ -5633,6 +5658,9 @@ nfa_regmatch(prog, start, submatch, m)
56335658 if (nfa_has_zsubexpr )
56345659 copy_sub_off (& t -> subs .synt , & m -> synt );
56355660#endif
5661+ /* If the pattern has \ze and it matched in the
5662+ * sub pattern, use it. */
5663+ copy_ze_off (& t -> subs .norm , & m -> norm );
56365664
56375665 /* t->state->out1 is the corresponding
56385666 * END_INVISIBLE node; Add its out to the current
0 commit comments