mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
9646cb4e84
commit
82482f67e2
2 changed files with 29 additions and 16 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Feb 13 14:41:00 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tk/lib/tk.rb: en-bugged at last commit (Feb 11 23:24:22 2004)
|
||||||
|
|
||||||
Fri Feb 13 12:26:37 2004 Minero Aoki <aamine@loveruby.net>
|
Fri Feb 13 12:26:37 2004 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* test/fileutils/test_fileutils.rb: rescue SystemCallError instead
|
* test/fileutils/test_fileutils.rb: rescue SystemCallError instead
|
||||||
|
|
|
@ -104,8 +104,8 @@ module TkComm
|
||||||
when /^-?\d+\.?\d*(e[-+]?\d+)?$/
|
when /^-?\d+\.?\d*(e[-+]?\d+)?$/
|
||||||
val.to_f
|
val.to_f
|
||||||
when /[^\\] /
|
when /[^\\] /
|
||||||
val.split.collect{|elt|
|
tk_split_escstr(val).collect{|elt|
|
||||||
tk_tcl2ruby(elt)
|
tk_tcl2ruby(elt)
|
||||||
}
|
}
|
||||||
when /\\ /
|
when /\\ /
|
||||||
val.gsub(/\\ /, ' ')
|
val.gsub(/\\ /, ' ')
|
||||||
|
@ -114,18 +114,13 @@ module TkComm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def tk_split_list(str)
|
def tk_split_escstr(str)
|
||||||
return [] if str == ""
|
return [] if str == ""
|
||||||
list = []
|
list = []
|
||||||
token = nil
|
token = nil
|
||||||
escape = false
|
escape = false
|
||||||
brace = 0
|
brace = 0
|
||||||
str.split('').each {|c|
|
str.split('').each {|c|
|
||||||
if c == '\\' && !escape
|
|
||||||
escape = true
|
|
||||||
token = (token || "") << c
|
|
||||||
next
|
|
||||||
end
|
|
||||||
brace += 1 if c == '{' && !escape
|
brace += 1 if c == '{' && !escape
|
||||||
brace -= 1 if c == '}' && !escape
|
brace -= 1 if c == '}' && !escape
|
||||||
if brace == 0 && c == ' ' && !escape
|
if brace == 0 && c == ' ' && !escape
|
||||||
|
@ -134,16 +129,27 @@ module TkComm
|
||||||
else
|
else
|
||||||
token = (token || "") << c
|
token = (token || "") << c
|
||||||
end
|
end
|
||||||
escape = false
|
escape = (c == '\\' && !escape)
|
||||||
}
|
}
|
||||||
list << token.gsub(/^\{(.*)\}$/, '\1') if token
|
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
|
if list.size == 1
|
||||||
tk_tcl2ruby(list[0].gsub(/\\(\{|\})/, '\1'))
|
tk_tcl2ruby(list[0])
|
||||||
else
|
else
|
||||||
list.collect{|token| tk_split_list(token)}
|
list.collect{|token| tk_split_sublist(token)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tk_split_list(str)
|
||||||
|
return [] if str == ""
|
||||||
|
tk_split_escstr(str).collect{|token| tk_split_sublist(token)}
|
||||||
|
end
|
||||||
=begin
|
=begin
|
||||||
def tk_split_list(str)
|
def tk_split_list(str)
|
||||||
return [] if str == ""
|
return [] if str == ""
|
||||||
|
@ -194,6 +200,7 @@ module TkComm
|
||||||
str.split('').each {|c|
|
str.split('').each {|c|
|
||||||
if c == '\\' && !escape
|
if c == '\\' && !escape
|
||||||
escape = true
|
escape = true
|
||||||
|
token = (token || "") << c if brace > 0
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
brace += 1 if c == '{' && !escape
|
brace += 1 if c == '{' && !escape
|
||||||
|
@ -236,14 +243,15 @@ module TkComm
|
||||||
list.push ' '
|
list.push ' '
|
||||||
else
|
else
|
||||||
#list.push str[0..i-1]
|
#list.push str[0..i-1]
|
||||||
list.push(str[0..i-1].gsub(/\\(\{|})/, '\1'))
|
list.push(str[0..i-1].gsub(/\\(\{|\})/, '\1'))
|
||||||
end
|
end
|
||||||
list += tk_split_simplelist(str[i+1..-1])
|
list += tk_split_simplelist(str[i+1..-1])
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
=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)
|
def _symbolkey2str(keys)
|
||||||
h = {}
|
h = {}
|
||||||
|
@ -1619,8 +1627,8 @@ module Tk
|
||||||
@@enc_buf = '__rb_encoding_buffer__'
|
@@enc_buf = '__rb_encoding_buffer__'
|
||||||
|
|
||||||
def self.tk_escape(str)
|
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',
|
TkCore::INTERP.__eval(Kernel.format('global %s; set %s %s',
|
||||||
@@enc_buf, @@enc_buf, s))
|
@@enc_buf, @@enc_buf, s))
|
||||||
end
|
end
|
||||||
|
@ -1903,7 +1911,8 @@ class TkVariable
|
||||||
"ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
"ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
|
||||||
|
|
||||||
def TkVariable.callback(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]
|
if TkVar_CB_TBL[name1]
|
||||||
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
|
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue