summaryrefslogtreecommitdiff
path: root/support/tcltexed/lib/backslash.tcl
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/tcltexed/lib/backslash.tcl
Initial commit
Diffstat (limited to 'support/tcltexed/lib/backslash.tcl')
-rw-r--r--support/tcltexed/lib/backslash.tcl67
1 files changed, 67 insertions, 0 deletions
diff --git a/support/tcltexed/lib/backslash.tcl b/support/tcltexed/lib/backslash.tcl
new file mode 100644
index 0000000000..032db6ade3
--- /dev/null
+++ b/support/tcltexed/lib/backslash.tcl
@@ -0,0 +1,67 @@
+# Copyright (C) 1999 - Martin Strauss - under terms of GPL
+####################################################################
+# Setzt backslash's fuer eine Stringuebergabe ein
+proc backslash {s} {
+ set begin_s ""
+ set end_s $s
+ set pos 0
+ while {$pos != 10000} {
+ set key ""
+ set pos "10000"
+ set kpos [string first "\"" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\""
+ }}
+ set kpos [string first "\\" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\\"
+ }}
+ set kpos [string first "\n" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\n"
+ }}
+ set kpos [string first "\t" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\t"
+ }}
+ set kpos [string first "\[" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\["
+ }}
+
+ set kpos [string first "\]" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\]"
+ }}
+ set kpos [string first "\{" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\{"
+ }}
+
+ set kpos [string first "\}" $end_s]
+ if {$pos > $kpos} then {
+ if {$kpos != -1} then {
+ set pos $kpos
+ set key "\\\}"
+ }}
+
+ if {$pos != 10000} then {
+ set begin_s $begin_s[string range $end_s 0 [expr $pos - 1]]$key
+ set end_s "[string range $end_s [expr $pos + 1] end]"
+ } else {return "$begin_s$end_s"}
+}}
+