summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-08 07:55:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-08 07:55:34 -0700
commit2b00fdfe4bc329fbf4d1dd32835a2476c7c1e2f6 (patch)
tree10b0ac85281ff220829d0e46a145d2f0a7982423
parent347c06761a1a01fb1c8bda56bf636d05ffb34b3a (diff)
downloadtxr-2b00fdfe4bc329fbf4d1dd32835a2476c7c1e2f6.tar.gz
txr-2b00fdfe4bc329fbf4d1dd32835a2476c7c1e2f6.tar.bz2
txr-2b00fdfe4bc329fbf4d1dd32835a2476c7c1e2f6.zip
Fix 2011-12-03 regression. The freeform directive code
relies on lazy_str_get_trailing_list and the behavior of that function changed because (split-str "" any-separator) changed from returning nil to returning the empty string. The resulting behavior change of lazy_str_get_trailing_list was later described in the documentation, thereby codifying it. This patch changes the lazy_str_get_trailing_list behavior, which is poor, and causes infinite looping. We do not want an extra empty string prepended, because it looks like a spurious line. * lib.c (lazy_str_get_trailing_list): if split_str produces a the list (""), then just return the unmaterialized list from the lazy string without prepending that one-element list to it. * txr.1: Updated documentation for lazy-str-get-trailing-list.
-rw-r--r--ChangeLog20
-rw-r--r--lib.c3
-rw-r--r--txr.131
3 files changed, 42 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 961af894..50bfaabb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2014-10-08 Kaz Kylheku <kaz@kylheku.com>
+
+ Fix 2011-12-03 regression. The freeform directive code
+ relies on lazy_str_get_trailing_list and the behavior
+ of that function changed because (split-str "" any-separator)
+ changed from returning nil to returning the empty string.
+ The resulting behavior change of lazy_str_get_trailing_list was later
+ described in the documentation, thereby codifying it.
+
+ This patch changes the lazy_str_get_trailing_list behavior,
+ which is poor, and causes infinite looping. We do not want
+ an extra empty string prepended, because it looks like
+ a spurious line.
+
+ * lib.c (lazy_str_get_trailing_list): if split_str produces
+ a the list (""), then just return the unmaterialized list from
+ the lazy string without prepending that one-element list to it.
+
+ * txr.1: Updated documentation for lazy-str-get-trailing-list.
+
2014-10-05 Kaz Kylheku <kaz@kylheku.com>
Version 99.
diff --git a/lib.c b/lib.c
index 0b107c93..d121177a 100644
--- a/lib.c
+++ b/lib.c
@@ -4987,6 +4987,9 @@ val lazy_str_get_trailing_list(val lstr, val index)
val split_suffix = split_str(sub_str(lstr->ls.prefix, index, nil),
or2(car(lstr->ls.opts), lit("\n")));
+ if (!cdr(split_suffix) && equal(car(split_suffix), null_string))
+ return lstr->ls.list;
+
return nappend2(split_suffix, lstr->ls.list);
}
}
diff --git a/txr.1 b/txr.1
index 101f464d..7f4b5cb8 100644
--- a/txr.1
+++ b/txr.1
@@ -16376,30 +16376,37 @@ materialized lazy string.
.desc
The
.code lazy-str-get-trailing-list
-function is a sort of inverse operation to
-the lazy string from its associated list.
+function can be considered, in some way, an inverse operation to
+the production of the lazy string from its associated list.
-First, the string is forced up through the position
+First,
+.meta string
+is forced up through the position
.metn index .
+That is the only extent to which
+.meta string
+is modified by this function.
-Next, the materialized part of the string starting at position
+Next, the suffix of the materialized part of the lazy string starting at
+position
.metn index ,
-through to the end, is split into pieces on occurrences of the terminator
-character, which had been given as the
+is split into pieces on occurrences of the
+terminator character (which had been given as the
.meta terminator
argument in the
.code lazy-str
-constructor, and defaults to the newline character.
+constructor, and defaults to newline). If the
+.meta index
+position is beyond the part of the string which can be materialized
+(in adherence with the lazy string's
+.meta limit-count
+constructor parameter), then the list of pieces is considered
+to be empty.
Finally, a list is returned consisting of the pieces produced by the split,
to which is appended the remaining list of the string which has not yet been
forced to materialize.
-If
-.meta index
-is a position which cannot be forced, then the lazy string's
-remaining list is returned, with single null string prepended to it.
-
.coNP Functions @, length-str-> @, length-str->= @ length-str-< and @ length-str-<=
.synb
.mets (length-str-> < string << len )