summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-13 05:46:49 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-13 05:46:49 +0000
commit82482f67e25e8239d17a0ee9d209dca3c6fbb2f9 (patch)
treeff2c6d32e8172db8f68f250d03f85898dfca77ab /ext
parent9646cb4e840cebb12c1986a8bc3fc5715f62d8c0 (diff)
* ext/tk/lib/tk.rb: en-bugged at last commit (Feb 11 23:24:22 2004)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/lib/tk.rb41
1 files changed, 25 insertions, 16 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index f41763614f..f098772a28 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -104,8 +104,8 @@ module TkComm
when /^-?\d+\.?\d*(e[-+]?\d+)?$/
val.to_f
when /[^\\] /
- val.split.collect{|elt|
- tk_tcl2ruby(elt)
+ tk_split_escstr(val).collect{|elt|
+ tk_tcl2ruby(elt)
}
when /\\ /
val.gsub(/\\ /, ' ')
@@ -114,18 +114,13 @@ module TkComm
end
end
- def tk_split_list(str)
+ def tk_split_escstr(str)
return [] if str == ""
list = []
token = nil
escape = false
brace = 0
str.split('').each {|c|
- if c == '\\' && !escape
- escape = true
- token = (token || "") << c
- next
- end
brace += 1 if c == '{' && !escape
brace -= 1 if c == '}' && !escape
if brace == 0 && c == ' ' && !escape
@@ -134,16 +129,27 @@ module TkComm
else
token = (token || "") << c
end
- escape = false
+ escape = (c == '\\' && !escape)
}
list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ list
+ end
+ def tk_split_sublist(str)
+ return [] if str == ""
+ return [tk_split_sublist(str[1..-2])] if str =~ /^\{.*\}$/
+ list = tk_split_escstr(str)
if list.size == 1
- tk_tcl2ruby(list[0].gsub(/\\(\{|\})/, '\1'))
+ tk_tcl2ruby(list[0])
else
- list.collect{|token| tk_split_list(token)}
+ list.collect{|token| tk_split_sublist(token)}
end
end
+
+ def tk_split_list(str)
+ return [] if str == ""
+ tk_split_escstr(str).collect{|token| tk_split_sublist(token)}
+ end
=begin
def tk_split_list(str)
return [] if str == ""
@@ -194,6 +200,7 @@ module TkComm
str.split('').each {|c|
if c == '\\' && !escape
escape = true
+ token = (token || "") << c if brace > 0
next
end
brace += 1 if c == '{' && !escape
@@ -236,14 +243,15 @@ module TkComm
list.push ' '
else
#list.push str[0..i-1]
- list.push(str[0..i-1].gsub(/\\(\{|})/, '\1'))
+ list.push(str[0..i-1].gsub(/\\(\{|\})/, '\1'))
end
list += tk_split_simplelist(str[i+1..-1])
list
end
=end
- private :tk_tcl2ruby, :tk_split_list, :tk_split_simplelist
+ private :tk_tcl2ruby, :tk_split_escstr,
+ :tk_split_sublist, :tk_split_list, :tk_split_simplelist
def _symbolkey2str(keys)
h = {}
@@ -1619,8 +1627,8 @@ module Tk
@@enc_buf = '__rb_encoding_buffer__'
def self.tk_escape(str)
- #s = '"' + str.gsub(/[\[\]$"]/, '\\\\\&') + '"'
- s = '"' + str.gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ s = '"' + str.gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ #s = '"' + str.gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
TkCore::INTERP.__eval(Kernel.format('global %s; set %s %s',
@@enc_buf, @@enc_buf, s))
end
@@ -1903,7 +1911,8 @@ class TkVariable
"ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
def TkVariable.callback(args)
- name1,name2,op = tk_split_list(args)
+ #name1,name2,op = tk_split_list(args)
+ name1,name2,op = tk_split_simplelist(args)
if TkVar_CB_TBL[name1]
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
else