summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-28 20:55:53 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-28 20:55:53 -0800
commitffada96ffdf3dae7c1932deebd6f512ede5f2aa5 (patch)
tree08b9fa969e686e01d1456a7e1bdb7407cf9094b5 /lib.c
parentd6eca506a08d569d4c821c724242fc556638342c (diff)
downloadtxr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.tar.gz
txr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.tar.bz2
txr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.zip
New variables for floating-point printing control.
* lib.c (obj_print_impl): Instead of hard-coded "~s", obtain the format string for floats from the *print-flo-format* special variable, whose default value is "~s". * stream.c (print_flo_digits_s, print_flo_format_s): New symbol variables. (formatv): Use *print-flo-digits* value for default precision for ~f and ~e, rather than hard-coded 3. (stream_init): Initialize print_flo_digits_s and print_flo_format_s, and register special variables under those symbols. * stream.h (print_flo_digits_s, print_flo_format_s): Declared. * txr.1: Documented new specials.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index d0cee7e6..d1f765a9 100644
--- a/lib.c
+++ b/lib.c
@@ -8406,7 +8406,10 @@ finish:
case NUM:
case BGNUM:
case FLNUM:
- format(out, lit("~s"), obj, nao);
+ {
+ val fmt = cdr(lookup_var(nil, print_flo_format_s));
+ format(out, fmt, obj, nao);
+ }
break;
case SYM:
if (!pretty) {