garray_T ga;
char_u *ret;
char_u *save_cpo;
+ int zero_width;
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
save_cpo = p_cpo;
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
+ ga.ga_len + i, TRUE, TRUE, FALSE);
ga.ga_len += i + sublen - 1;
- /* avoid getting stuck on a match with an empty string */
- if (tail == regmatch.endp[0])
+ zero_width = (tail == regmatch.endp[0]
+ || regmatch.startp[0] == regmatch.endp[0]);
+ tail = regmatch.endp[0];
+ if (*tail == NUL)
+ break;
+ if (zero_width)
{
- if (*tail == NUL)
- break;
+ /* avoid getting stuck on a match with an empty string */
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
++ga.ga_len;
}
- else
- {
- tail = regmatch.endp[0];
- if (*tail == NUL)
- break;
- }
if (!do_all)
break;
}
:$put =\"\n\nTEST_7:\"
:$put =substitute('A\16\rA', 'A.', '\=submatch(0)', '')
:$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
+:$put =substitute('-bb', '\zeb', 'a', 'g')
+:$put =substitute('-bb', '\ze', 'c', 'g')
/^TEST_8
ENDTEST