diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-13 07:26:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-13 07:26:46 -0700 |
commit | aa2c5e904ee8b5095498f97a5e89fa47cad886db (patch) | |
tree | 379fab4f7fa1b38ef919337ec2dc183d24bd5ca7 | |
parent | 004ba77b2d682cd68943f68a587950eb855c4816 (diff) | |
download | txr-aa2c5e904ee8b5095498f97a5e89fa47cad886db.tar.gz txr-aa2c5e904ee8b5095498f97a5e89fa47cad886db.tar.bz2 txr-aa2c5e904ee8b5095498f97a5e89fa47cad886db.zip |
regex: regsub wrongly destructive.
* regex.c (regsub): When the regex argument is actually a function, we
must copy the string, because replace_str is destructive.
-rw-r--r-- | regex.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2875,10 +2875,11 @@ val regsub(val regex, val repl, val str) { val rf = from(range); val rt = to(range); + val scopy = copy_str(str); - return replace_str(str, if3(isfunc, - funcall1(repl, sub_str(str, rf, rt)), - repl), + return replace_str(scopy, if3(isfunc, + funcall1(repl, sub_str(scopy, rf, rt)), + repl), rf, rt); } } else { |