From e30e834bf8ca6f1539ef43fa22e93252d4aa24cf Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 15 May 2023 14:34:07 +1000 Subject: [PATCH] repl - avoid unnecessary string rep conversion to aid analysis using tcl::unsupported::representation --- src/punk86.vfs/lib/app-punk/repl.tcl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/punk86.vfs/lib/app-punk/repl.tcl b/src/punk86.vfs/lib/app-punk/repl.tcl index fea741a5..03df7474 100644 --- a/src/punk86.vfs/lib/app-punk/repl.tcl +++ b/src/punk86.vfs/lib/app-punk/repl.tcl @@ -1040,7 +1040,18 @@ proc repl::repl_handler {inputchan prompt_config} { } } else { - rputs $resultprompt[string map [list \n "\n$resultprompt"] $result] + #----------------------------------------------------------- + # avoid repl forcing string rep of simple results. This is just to aid analysis using tcl::unsupported::representation + set rparts [split $result {}] + if {[lsearch $rparts \n] < 0} { + #type of $result unaffected + rputs "$resultprompt $result" + } else { + #$result will be a string due to use of string map + rputs $resultprompt[string map [list \n "\n$resultprompt"] $result] + } + #----------------------------------------------------------- + #rputs $resultprompt[string map [list \n "\n$resultprompt"] $result] } doprompt "P% " } else { @@ -1090,10 +1101,10 @@ proc repl::repl_handler {inputchan prompt_config} { rputs stderr "${c}repl interrupted$n" #set command [list error "repl interrupted"] set command "" - doprompt ">_" + doprompt ">_ " } else { - doprompt "> " + doprompt "> " } } fileevent $inputchan readable [list [namespace current]::repl_handler $inputchan $prompt_config]