More debugging output helpers
@@ -93,13 +93,42 @@ proc readfile { filename } {
# Debugging helper
proc show { args } {
foreach v $args {
+ show_token $v
+
upvar $v t
+ if { ! [ info exists v ] } {
+ error "show: variable does not exist: $v"
+ }
+ # Make copy for possible modification:
+ set s $t
+ if { [ string length $s ] == 0 } { set s "''" }
+ puts "$v: $s"
+ }
+}
+
+proc showln { args } {
+ foreach v $args {
+ show_token $v
+ # Actual variable
+ upvar $v t
if { ! [ info exists v ] } {
error "show: variable does not exist: $v"
}
+ # Make copy for possible modification:
+ set s $t
+ if { [ string length $s ] == 0 } { set s "''" }
+ puts -nonewline "$v=$s "
+ }
+ puts ""
+}
- puts "$v: $t"
+proc show_token { v } {
+ # Token
+ if { [ string first "@" $v ] == 0 } {
+ set s [ string range $v 1 end ]
+ puts -nonewline "$s "
+ return -code continue
}
}
@@ -146,6 +175,17 @@ proc puts* { args } {
puts [ join $args "" ]
}
+proc puts** { args } {
+ foreach a $args {
+ if { [ string length $a ] == 0 } {
+ puts -nonewline "'' "
+ } else {
+ puts -nonewline "$a "
+ }
+ }
+ puts ""
+}
+
proc putsn { args } {
puts [ join $args "\n" ]
}
