diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-21 06:18:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-21 06:18:15 -0800 |
commit | 386545bab0787be5ca4b24fb0f64e89ee49eb908 (patch) | |
tree | b14b6e0bd2a348de1195616623c6b9253eb1a1d6 /parser.c | |
parent | 4f26ccee4c18fe02868345ed50082cd0d4203a08 (diff) | |
download | txr-386545bab0787be5ca4b24fb0f64e89ee49eb908.tar.gz txr-386545bab0787be5ca4b24fb0f64e89ee49eb908.tar.bz2 txr-386545bab0787be5ca4b24fb0f64e89ee49eb908.zip |
listener: fix hang when stringifying output.
The issue is that when *listener-pprint-p* is set, then
the evaluation is printed using pprinl. The user may have
arranged for that to safely work when there are circular
objects in the print. But then the listener ignores
*listener-pprint-p* when saving the output object as a string
(which is done for the sake of the Ctrl-X Ctrl-P
paste-previous-output feature). The tostring function is used
which can blow up on an object containing circular structure,
even though the object was successfully printed.
The user is puzzled: why was the result of the evaluation
printed completely and perfectly, yet the image has hanged?
* parser.c (repl): Do not use tostring for converting the
evaluated output to a string. Choose between tostring and
tostringp based on the *listener-pprint-p* variable.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1328,10 +1328,11 @@ val repl(val bindings, val in_stream, val out_stream) in_stream, out_stream)); val pprin = cdr(pprint_var); val (*pfun)(val, val) = if3(pprin, pprinl, prinl); + val (*tsfun)(val) = if3(pprin, tostringp, tostring); reg_varl(var_sym, value); sethash(result_hash, var_counter, value); pfun(value, out_stream); - lino_set_result(ls, chk_strdup(c_str(tostring(value)))); + lino_set_result(ls, chk_strdup(c_str(tsfun(value)))); lino_hist_add(ls, line_w); if (cdr(greedy_eval)) { val error_p = nil; |