From 384262e2f0effb4b7bbd2effa9311899fa253799 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 11 Jan 2015 10:08:32 -0800 Subject: * lib.c (make_like): Bugfix. (make-like nil "abc") must return the empty string, not nil. Only lists of non-characters fail to convert to a string. Since programs may depend on the hitherto wrong, undocumented behavior, this is made subject to compatibility. * txr.1: Added compatibility note. --- ChangeLog | 11 +++++++++++ lib.c | 4 ++++ txr.1 | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 52c8a16f..4e01eb8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-01-11 Kaz Kylheku + + * lib.c (make_like): Bugfix. (make-like nil "abc") + must return the empty string, not nil. Only + lists of non-characters fail to convert to a string. + Since programs may depend on the hitherto wrong, + undocumented behavior, this is made subject to + compatibility. + + * txr.1: Added compatibility note. + 2015-01-11 Kaz Kylheku * eval.c (merge_wrap): Make generic over sequences. diff --git a/lib.c b/lib.c index a6f01a66..41a9c29f 100644 --- a/lib.c +++ b/lib.c @@ -504,6 +504,10 @@ val make_like(val list, val thatobj) case STR: case LIT: case LSTR: + if (!opt_compat || opt_compat > 101) { + if (!cdr(list)) + return null_string; + } if (is_chr(car(list))) return cat_str(list, nil); break; diff --git a/txr.1 b/txr.1 index 8b329d7b..fb1b3c37 100644 --- a/txr.1 +++ b/txr.1 @@ -26443,6 +26443,18 @@ can be emulated is \*(TX 97. Here are values which have a special meaning as arguments to the .code -C option, along with a description of what behaviors are affected: +.IP 101 +Up to \*(TX 101, the +.code make-like +function incorrectly returned +.code nil +when converting the empty list +.code nil +to string type. This affects numerous generic sequence functions, +causing their result to be +.code nil +instead of an empty string. + .IP 100 Up to \*(TX 100, the .code split-str -- cgit v1.2.3