From 5d4de25fc34a84eccc1ae92ca0ed09fffba679b1 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sun, 29 Nov 2009 00:55:47 +0000 Subject: [PATCH] Use string map rather than regsub for the printable procedure. Signed-off-by: Pat Thoyts --- bin/sockspy.tcl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 } ##+########################################################################## # -- 2.23.0