From: cas Date: Wed, 30 Aug 2000 18:30:40 +0000 (+0000) Subject: No comments X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=50f2f0808fe6b323bd9604be73d4d8c891464205;p=occt-wok.git No comments --- diff --git a/src/WOKTclLib/wutils.tcl b/src/WOKTclLib/wutils.tcl index 67676f9..90e4812 100755 --- a/src/WOKTclLib/wutils.tcl +++ b/src/WOKTclLib/wutils.tcl @@ -458,7 +458,7 @@ proc wokUtils:FILES:AppendListToFile { liste path } { } } # -# Replace s1 by s2 in f and write result in g +# Replace s1 by s2 in fin and write result in fout # return 1 if substitution was performed. # proc wokUtils:EASY:replace { fin fout s1 s2 } { @@ -483,6 +483,35 @@ proc wokUtils:EASY:replace { fin fout s1 s2 } { } } # +# Same as Replace but l is a list of couple {s1 s2} +# return 1 if at least one substitution has been done. +# This proc differs of the above one for lazyness purpose. +# +proc wokUtils:EASY:lreplace { fin fout ls1s2 } { + if { [catch { set in [ open $fin r ] } errin] == 0 } { + if { [catch { set out [ open $fout w ] } errout] == 0 } { + set strin [read $in [file size $fin]] + close $in + foreach [list s1 s2] $ls1s2 { + set done 0 + if { [set nbsub [regsub -all -- $s1 $strin $s2 strout]] != 0 } { + set done 1 + } + set strin $strout + } + puts $out $strout + close $out + return $done + } else { + puts stderr "Error: $errout" + return 0 + } + } else { + puts stderr "Error: $errin" + return 0 + } +} +# # Compares 2 full pathes for TEXT ASCII files. Returs 1 if identicals 0 ifnot # proc wokUtils:FILES:AreSame { f1 f2 } {