From 386545bab0787be5ca4b24fb0f64e89ee49eb908 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 21 Feb 2019 06:18:15 -0800 Subject: 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. --- parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index 0f5d5c99..99c6d728 100644 --- a/parser.c +++ b/parser.c @@ -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; -- cgit v1.2.3