Attachment "regsub.diff" to
ticket [667558ffff]
added by
davidw
2003-01-14 13:58:46.
Index: library/auto.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/auto.tcl,v
retrieving revision 1.12
diff -u -r1.12 auto.tcl
--- library/auto.tcl 28 Oct 2002 16:34:25 -0000 1.12
+++ library/auto.tcl 14 Jan 2003 01:39:06 -0000
@@ -337,8 +337,8 @@
# in case there were any $ in the proc name. This will cause a problem
# if somebody actually tries to have a \0 in their proc name. Too bad
# for them.
- regsub -all {\$} $contents "\0" contents
-
+ set contents [string map [list \$ \0] $contents]
+
set index ""
set contextStack ""
set imports ""
@@ -418,8 +418,7 @@
if {[string equal $ns ""]} {
set fakeName "[namespace current]::_%@fake_$tail"
} else {
- set fakeName "_%@fake_$name"
- regsub -all {::} $fakeName "_" fakeName
+ set fakeName [string map {:: _} "_%@fake_$name"]
set fakeName "[namespace current]::$fakeName"
}
proc $fakeName $arglist $body
@@ -484,11 +483,10 @@
} elseif {![string match ::* $name]} {
set name "::$name"
}
-
+
# Earlier, mkindex replaced all $'s with \0. Now, we have to reverse
# that replacement.
- regsub -all "\0" $name "\$" name
- return $name
+ return [string map [list \0 \$] $name]
}
# Register all of the procedures for the auto_mkindex parser that
Index: library/history.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/history.tcl,v
retrieving revision 1.5
diff -u -r1.5 history.tcl
--- library/history.tcl 17 May 2001 08:18:56 -0000 1.5
+++ library/history.tcl 14 Jan 2003 01:39:06 -0000
@@ -256,8 +256,7 @@
if {![info exists history($i)]} {
continue
}
- set cmd [string trimright $history($i) \ \n]
- regsub -all \n $cmd "\n\t" cmd
+ set cmd [string map {\n \n\t} [string trimright $history($i) \ \n]]
append result $newline[format "%6d %s" $i $cmd]
set newline \n
}
Index: library/http/http.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/http/http.tcl,v
retrieving revision 1.43
diff -u -r1.43 http.tcl
--- library/http/http.tcl 3 Oct 2002 13:34:32 -0000 1.43
+++ library/http/http.tcl 14 Jan 2003 01:39:08 -0000
@@ -119,7 +119,7 @@
}
return $result
}
- regsub -all -- - $options {} options
+ set options [string map {- ""} $options]
set pat ^-([join $options |])$
if {[llength $args] == 1} {
set flag [lindex $args 0]
@@ -260,7 +260,7 @@
-progress -query -queryblocksize -querychannel -queryprogress\
-validate -timeout -type}
set usage [join $options ", "]
- regsub -all -- - $options {} options
+ set options [string map {- ""} $options]
set pat ^-([join $options |])$
foreach {flag value} $args {
if {[regexp $pat $flag]} {
@@ -414,7 +414,7 @@
}
puts $s "User-Agent: $http(-useragent)"
foreach {key value} $state(-headers) {
- regsub -all \[\n\r\] $value {} value
+ set value [string map {\n "" \r ""} $value]
set key [string trim $key]
if {[string equal $key "Content-Length"]} {
set contDone 1
Index: library/tcltest/tcltest.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/tcltest/tcltest.tcl,v
retrieving revision 1.75
diff -u -r1.75 tcltest.tcl
--- library/tcltest/tcltest.tcl 22 Sep 2002 18:19:26 -0000 1.75
+++ library/tcltest/tcltest.tcl 14 Jan 2003 01:39:15 -0000
@@ -1836,11 +1836,9 @@
}
# Replace symbolic valies supplied for -returnCodes
- regsub -nocase normal $returnCodes 0 returnCodes
- regsub -nocase error $returnCodes 1 returnCodes
- regsub -nocase return $returnCodes 2 returnCodes
- regsub -nocase break $returnCodes 3 returnCodes
- regsub -nocase continue $returnCodes 4 returnCodes
+ foreach {strcode numcode} {normal 0 error 1 return 2 break 3 continue 4} {
+ set returnCodes [string map -nocase [list $strcode $numcode] $returnCodes]
+ }
} else {
# This is parsing for the old test command format; it is here
# for backward compatibility.
@@ -2806,7 +2804,6 @@
proc tcltest::normalizeMsg {msg} {
regsub "\n$" [string tolower $msg] "" msg
- regsub -all "\n\n" $msg "\n" msg
- regsub -all "\n\}" $msg "\}" msg
- return $msg
+ set msg [string map [list "\n\n" "\n"] $msg]
+ return [string map [list "\n}" "\}"] $msg]
}