Only substitute patterns starting with ^ once.

pull/1985/head
nicm 2019-11-24 18:37:23 +00:00
parent 3c312a9150
commit 20c1f1aec6
1 changed files with 6 additions and 0 deletions

View File

@ -107,6 +107,12 @@ regsub(const char *pattern, const char *with, const char *text, int flags)
start = m[0].rm_eo + 1;
empty = 1;
}
/* Stop now if anchored to start. */
if (*pattern == '^') {
regsub_copy(&buf, &len, text, start, end);
break;
}
}
buf[len] = '\0';