summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-04 06:16:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-04 06:16:54 -0700
commit959f4259bde59d89f257fdfec0334b421f1dd8ce (patch)
treeda08423aa6cc3663f11b55c55317d31cfa5801e8 /lib.c
parentf33a3b23cbec3a636a67b070e3ed4245ed7fc155 (diff)
downloadtxr-959f4259bde59d89f257fdfec0334b421f1dd8ce.tar.gz
txr-959f4259bde59d89f257fdfec0334b421f1dd8ce.tar.bz2
txr-959f4259bde59d89f257fdfec0334b421f1dd8ce.zip
bugfix: tostringp not behaving right for floats.
The obj printer is ignoring the pretty flag when rendering floating-point numbers, and just formatting them using *print-flo-format*. To address this issue, we introduce an additional *pprint-flo-format* variable. * lib.c (obj_print_impl): In the FLNUM case, use either the value of *print-flo-format* or *pprint-flo-format* based on the value of the pretty flag. * stream.c (pprint_flo_format_s): New symbol variable. (stream_init): Initialize pprint_flo_format_s with interned symbol *pprint-flo-format* and register this as a special variable. * stream.c (pprint_flo_format_s): Declared. * txr.1: Documented *pprint-flo-format*. Also put in a note in the description of the various print functions that the equivalences based on ~s and ~a only apply to floats when the special variables have their original values.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 96b18000..a38ac973 100644
--- a/lib.c
+++ b/lib.c
@@ -10188,7 +10188,9 @@ dot:
break;
case FLNUM:
{
- val fmt = cdr(lookup_var(nil, print_flo_format_s));
+ val fmt = cdr(lookup_var(nil,
+ if3(pretty,
+ pprint_flo_format_s, print_flo_format_s)));
format(out, fmt, obj, nao);
}
break;