From: Pat Thoyts Date: Sun, 29 Nov 2009 00:55:47 +0000 (+0000) Subject: Use string map rather than regsub for the printable procedure. X-Git-Tag: v2.6~4 X-Git-Url: http://privyetmir.co.uk/gitweb?a=commitdiff_plain;h=5d4de25fc34a84eccc1ae92ca0ed09fffba679b1;p=sockspy Use string map rather than regsub for the printable procedure. Signed-off-by: Pat Thoyts --- diff --git a/bin/sockspy.tcl b/bin/sockspy.tcl index 75de035..83ca11c 100644 --- a/bin/sockspy.tcl +++ b/bin/sockspy.tcl @@ -423,11 +423,19 @@ proc saveOutput {} { # printable -- Replaces all unprintable characters into dots. # proc printable {s {spaces 0}} { - regsub -all {[^\x09\x20-\x7e]} $s "." n + variable printable + if {![info exists printable]} { + for {set n 0} {$n < 256} {incr n} { + if {($n < 32 || $n >= 0x7e) && $n != 9} { + lappend printable [format %c $n] "." + } + } + } + set s [string map $printable $s] if {$spaces} { - regsub -all { } $n "_" n + set s [string map {" " "_"} $s] } - return $n; + return $s } ##+########################################################################## #