diff options
-rw-r--r-- | eval.c | 27 | ||||
-rw-r--r-- | match.c | 17 | ||||
-rw-r--r-- | txr.1 | 17 |
3 files changed, 47 insertions, 14 deletions
@@ -2528,10 +2528,11 @@ val format_field(val obj, val modifier, val filter, val eval_fun) } } - if (listp(obj)) - str = cat_str(mapcar(func_n1(tostringp), obj), sep); - else - str = if3(stringp(obj), obj, tostringp(obj)); + str = if3(stringp(obj), + obj, + if3(if3(opt_compat && opt_compat <= 174, listp(obj), seqp(obj)), + cat_str(mapcar(func_n1(tostringp), obj), sep), + tostringp(obj))); { val filter_sym = getplist(plist, filter_k); @@ -2587,19 +2588,27 @@ val subst_vars(val forms, val env, val filter) val modifiers = third(form); val str = eval(expr, env, form); - /* If the object is a list, we let format_field deal with the + /* If the object is a sequence, we let format_field deal with the conversion to text, because the modifiers influence how it is done. */ - if (!stringp(str) && !listp(str)) - str = tostringp(str); + str = if3(stringp(str), + str, + if3(if3(opt_compat && opt_compat <= 174, + listp(str), seqp(str)), + str, + tostringp(str))); if (modifiers) { forms = cons(format_field(str, modifiers, filter, curry_123_1(func_n3(eval), env, form)), rest(forms)); } else { - if (listp(str)) - str = cat_str(mapcar(func_n1(tostringp), str), lit(" ")); + if (!stringp(str)) + str = if3(if3(opt_compat && opt_compat <= 174, + listp(str), seqp(str)), + cat_str(mapcar(func_n1(tostringp), str), lit(" ")), + str); + forms = cons(filter_string_tree(filter, str), rest(forms)); } @@ -1631,19 +1631,26 @@ static val tx_subst_vars(val spec, val bindings, val filter) val modifiers = third(elem); val str = txeval(spec, expr, bindings); - /* If the object is a list, we let format_field deal with the + /* If the object is a sequence, we let format_field deal with the conversion to text, because the modifiers influence how it is done. */ - if (!stringp(str) && !listp(str)) - str = tostringp(str); + str = if3(stringp(str), + str, + if3(if3(opt_compat && opt_compat <= 174, + listp(str), seqp(str)), + str, + tostringp(str))); if (modifiers) { spec = cons(format_field(str, modifiers, filter, curry_123_2(func_n3(txeval), spec, bindings)), rest(spec)); } else { - if (listp(str)) - str = cat_str(mapcar(func_n1(tostringp), str), lit(" ")); + if (!stringp(str)) + str = if3(if3(opt_compat && opt_compat <= 174, + listp(str), seqp(str)), + cat_str(mapcar(func_n1(tostringp), str), lit(" ")), + str); spec = cons(filter_string_tree(filter, str), rest(spec)); } @@ -53367,6 +53367,23 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 174 +A value of 174 or lower restores a previous behavior of variable substitution +in the +.code output +directive and in quasiliterals in both the \*(TX pattern language and \*(TL. +The behavior in question is the evaluation of the element indexing or +range selection modifier, exemplified by +.codn "@{a [2]}" . +The previous behavior was that if the variable is of any type other +than list, it is converted to a string (unless it already is one). +The indexing then applies to the string. If it is a list then the +indexing or range selection applies to the original list value, +prior to conversion to text. The current behavior is that indexing +and range selection is applied to the original value if that value +is any sequence type which satisfies the +.code seqp +function, otherwise to the string representation. .IP 172 A value of 172 or lower restores a behavior of the \*(TX pattern matching language when matching a variable followed by a directive, such as |