diff options
author | nicm <nicm> | 2019-11-24 18:37:23 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-11-24 18:37:23 +0000 |
commit | 20c1f1aec6f29a87d738897f80242c6dff4c808b (patch) | |
tree | 80711ba3406a1bc33c7d16b13348983bc5c37c38 | |
parent | 3c312a915094fe566c323aee35387d144cdeb6b2 (diff) |
Only substitute patterns starting with ^ once.
-rw-r--r-- | regsub.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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'; |