Mercurial > vim
comparison src/eval.c @ 5388:8ced827b2e8b v7.4.045
updated for version 7.4.045
Problem: substitute() does not work properly when the pattern starts with
"\ze".
Solution: Detect an empty match. (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 29 Sep 2013 21:11:05 +0200 |
parents | 8336fd924e05 |
children | c21b2f52f1dd |
comparison
equal
deleted
inserted
replaced
5387:057fb77e28f3 | 5388:8ced827b2e8b |
---|---|
24299 int do_all; | 24299 int do_all; |
24300 char_u *tail; | 24300 char_u *tail; |
24301 garray_T ga; | 24301 garray_T ga; |
24302 char_u *ret; | 24302 char_u *ret; |
24303 char_u *save_cpo; | 24303 char_u *save_cpo; |
24304 int zero_width; | |
24304 | 24305 |
24305 /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */ | 24306 /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */ |
24306 save_cpo = p_cpo; | 24307 save_cpo = p_cpo; |
24307 p_cpo = empty_option; | 24308 p_cpo = empty_option; |
24308 | 24309 |
24337 mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); | 24338 mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); |
24338 /* add the substituted text */ | 24339 /* add the substituted text */ |
24339 (void)vim_regsub(®match, sub, (char_u *)ga.ga_data | 24340 (void)vim_regsub(®match, sub, (char_u *)ga.ga_data |
24340 + ga.ga_len + i, TRUE, TRUE, FALSE); | 24341 + ga.ga_len + i, TRUE, TRUE, FALSE); |
24341 ga.ga_len += i + sublen - 1; | 24342 ga.ga_len += i + sublen - 1; |
24342 /* avoid getting stuck on a match with an empty string */ | 24343 zero_width = (tail == regmatch.endp[0] |
24343 if (tail == regmatch.endp[0]) | 24344 || regmatch.startp[0] == regmatch.endp[0]); |
24345 tail = regmatch.endp[0]; | |
24346 if (*tail == NUL) | |
24347 break; | |
24348 if (zero_width) | |
24344 { | 24349 { |
24345 if (*tail == NUL) | 24350 /* avoid getting stuck on a match with an empty string */ |
24346 break; | |
24347 *((char_u *)ga.ga_data + ga.ga_len) = *tail++; | 24351 *((char_u *)ga.ga_data + ga.ga_len) = *tail++; |
24348 ++ga.ga_len; | 24352 ++ga.ga_len; |
24349 } | |
24350 else | |
24351 { | |
24352 tail = regmatch.endp[0]; | |
24353 if (*tail == NUL) | |
24354 break; | |
24355 } | 24353 } |
24356 if (!do_all) | 24354 if (!do_all) |
24357 break; | 24355 break; |
24358 } | 24356 } |
24359 | 24357 |