summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-01-25 19:35:21 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-01-25 15:53:23 -0800
commit381e0669fc3d0771a2c236ad816b6609cb4ff61c (patch)
tree839b0238265b1d1c2c2efc1b1773221de10826c4
parent9f9f916d530e852a471739f625b985cf1346da4a (diff)
downloadtxr-381e0669fc3d0771a2c236ad816b6609cb4ff61c.tar.gz
txr-381e0669fc3d0771a2c236ad816b6609cb4ff61c.tar.bz2
txr-381e0669fc3d0771a2c236ad816b6609cb4ff61c.zip
sub-str: compat check now restores 215 behavior.
* lib.c (sub_str): If compatibility is requested, with a value of 215 or less, then disable the optimization of returning the original string without making a copy. This was found to break the @(freeform) directive. That regression alerts me to the fact that I should have made this subject to compatibility; some user code could be affected. * txr.1: New compat note added, under 215.
-rw-r--r--lib.c4
-rw-r--r--txr.119
2 files changed, 20 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 4fdcaacf..c3428c22 100644
--- a/lib.c
+++ b/lib.c
@@ -4631,7 +4631,9 @@ val sub_str(val str_in, val from, val to)
if (ge(from, to)) {
return null_string;
- } else if (from == zero && eql(to, len)) {
+ } else if (from == zero && eql(to, len) &&
+ (opt_compat == 0 || opt_compat > 215))
+ {
return str_in;
} else {
size_t nchar = c_num(to, self) - c_num(from, self) + 1;
diff --git a/txr.1 b/txr.1
index fb735f5e..bd267a82 100644
--- a/txr.1
+++ b/txr.1
@@ -77144,8 +77144,23 @@ variable. In cases where
resolved the path by adding a suffix,
.code *load-path*
was bound to the unsuffixed name, which was a documented behavior.
-The old behavior is restored if 215 or lower compatibility
-is requested.
+After \*(TX 215, also, the behavior of the
+.code sub-str
+function changed. When the arguments implicate the entire string,
+.code sub-str
+started just returning the original string, and not making a copy.
+The old behavior was to always make a copy.
+The above old behaviors of
+.code load
+and
+.code sub-str
+are restored if 215 or lower compatibility
+is requested. Note, however, that the restoration of the
+.code sub-str
+behavior in response to the compatibility option was only
+introduced in \*(TX 250. In \*(TX 249 and older, the
+compatibility value has no effect on the behavior of
+.codn sub-str .
.IP 202
Up to \*(TX 202, the
.code logxor