Bugfix for text replacement
This commit is contained in:
parent
ad94012695
commit
d07d2f2530
@ -223,10 +223,10 @@ public find_result_t Text__find(CORD str, CORD pat)
|
||||
public CORD Text__replace(CORD text, CORD pat, CORD replacement, int64_t limit)
|
||||
{
|
||||
if (!text || !pat) return text;
|
||||
CORD ret = NULL;
|
||||
CORD ret = CORD_EMPTY;
|
||||
size_t pos = 0, pat_len = CORD_len(pat);
|
||||
for (size_t found; limit > 0 && (found=CORD_str(text, pos, pat)) != CORD_NOT_FOUND; --limit) {
|
||||
ret = CORD_all(ret, CORD_substr(text, pos, found), replacement);
|
||||
ret = CORD_all(ret, CORD_substr(text, pos, found - pos), replacement);
|
||||
pos = found + pat_len;
|
||||
}
|
||||
size_t str_len = CORD_len(text);
|
||||
|
Loading…
Reference in New Issue
Block a user