* ext/tk/lib/tk.rb (TkComm#array2tk_list): accept enc-mode argument to
decide whether convert encoding of each element or not. * ext/tk/lib/tk/variable.rb (TkVariable#value=): fail to convert the encoding of array elements when assign an array to an TkVariable object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1d580ecda2
commit
5ddcd35cf1
@ -1,3 +1,12 @@
|
|||||||
|
Mon Apr 4 23:17:52 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tk/lib/tk.rb (TkComm#array2tk_list): accept enc-mode argument to
|
||||||
|
decide whether convert encoding of each element or not.
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/variable.rb (TkVariable#value=): fail to convert the
|
||||||
|
encoding of array elements when assign an array to an TkVariable
|
||||||
|
object.
|
||||||
|
|
||||||
Mon Apr 4 10:26:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
Mon Apr 4 10:26:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
* ext/tk/lib/tk/dialog.rb: fixed typo.
|
* ext/tk/lib/tk/dialog.rb: fixed typo.
|
||||||
|
@ -287,19 +287,19 @@ if USE_TCLs_LIST_FUNCTIONS
|
|||||||
TkCore::INTERP._split_tklist(str)
|
TkCore::INTERP._split_tklist(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def array2tk_list(ary)
|
def array2tk_list(ary, enc=nil)
|
||||||
return "" if ary.size == 0
|
return "" if ary.size == 0
|
||||||
|
|
||||||
dst = ary.collect{|e|
|
dst = ary.collect{|e|
|
||||||
if e.kind_of? Array
|
if e.kind_of? Array
|
||||||
array2tk_list(e)
|
array2tk_list(e, enc)
|
||||||
elsif e.kind_of? Hash
|
elsif e.kind_of? Hash
|
||||||
tmp_ary = []
|
tmp_ary = []
|
||||||
#e.each{|k,v| tmp_ary << k << v }
|
#e.each{|k,v| tmp_ary << k << v }
|
||||||
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
||||||
array2tk_list(tmp_ary)
|
array2tk_list(tmp_ary, enc)
|
||||||
else
|
else
|
||||||
_get_eval_string(e)
|
_get_eval_string(e, enc)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
TkCore::INTERP._merge_tklist(*dst)
|
TkCore::INTERP._merge_tklist(*dst)
|
||||||
@ -422,16 +422,16 @@ else
|
|||||||
list
|
list
|
||||||
end
|
end
|
||||||
|
|
||||||
def array2tk_list(ary)
|
def array2tk_list(ary, enc=nil)
|
||||||
ary.collect{|e|
|
ary.collect{|e|
|
||||||
if e.kind_of? Array
|
if e.kind_of? Array
|
||||||
"{#{array2tk_list(e)}}"
|
"{#{array2tk_list(e, enc)}}"
|
||||||
elsif e.kind_of? Hash
|
elsif e.kind_of? Hash
|
||||||
# "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
|
# "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
|
||||||
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
|
||||||
array2tk_list(tmp_ary)
|
array2tk_list(tmp_ary, enc)
|
||||||
else
|
else
|
||||||
s = _get_eval_string(e)
|
s = _get_eval_string(e, enc)
|
||||||
(s.index(/\s/) || s.size == 0)? "{#{s}}": s
|
(s.index(/\s/) || s.size == 0)? "{#{s}}": s
|
||||||
end
|
end
|
||||||
}.join(" ")
|
}.join(" ")
|
||||||
@ -3120,7 +3120,7 @@ module TkConfigMethod
|
|||||||
when /^(#{__strval_optkeys.join('|')})$/
|
when /^(#{__strval_optkeys.join('|')})$/
|
||||||
conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
|
conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
|
||||||
else
|
else
|
||||||
conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__confinfo_cmd << "-#{slot}"))))
|
conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
|
||||||
end
|
end
|
||||||
conf[__configinfo_struct[:key]] =
|
conf[__configinfo_struct[:key]] =
|
||||||
conf[__configinfo_struct[:key]][1..-1]
|
conf[__configinfo_struct[:key]][1..-1]
|
||||||
|
@ -468,7 +468,7 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||||||
_get_eval_string(v, true))
|
_get_eval_string(v, true))
|
||||||
}
|
}
|
||||||
self.value
|
self.value
|
||||||
elsif val.kind_of?(Array)
|
# elsif val.kind_of?(Array)
|
||||||
=begin
|
=begin
|
||||||
INTERP._set_global_var(@id, '')
|
INTERP._set_global_var(@id, '')
|
||||||
val.each{|v|
|
val.each{|v|
|
||||||
@ -481,7 +481,7 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
|
|||||||
}
|
}
|
||||||
self.value
|
self.value
|
||||||
=end
|
=end
|
||||||
_fromUTF8(INTERP._set_global_var(@id, array2tk_list(val)))
|
# _fromUTF8(INTERP._set_global_var(@id, array2tk_list(val, true)))
|
||||||
else
|
else
|
||||||
#_fromUTF8(INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val))))
|
#_fromUTF8(INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val))))
|
||||||
_fromUTF8(INTERP._set_global_var(@id, _get_eval_string(val, true)))
|
_fromUTF8(INTERP._set_global_var(@id, _get_eval_string(val, true)))
|
||||||
@ -576,7 +576,7 @@ else
|
|||||||
#INTERP._invoke_without_enc('unset', @id+'(0)')
|
#INTERP._invoke_without_enc('unset', @id+'(0)')
|
||||||
elsif val.kind_of?(Array)
|
elsif val.kind_of?(Array)
|
||||||
a = []
|
a = []
|
||||||
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
|
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e, true))}
|
||||||
#s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
#s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||||
s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
|
s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
|
||||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||||
@ -588,7 +588,7 @@ else
|
|||||||
elsif val.kind_of?(Hash)
|
elsif val.kind_of?(Hash)
|
||||||
#s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
#s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
||||||
# .gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
# .gsub(/[\[\]$"]/, '\\\\\&') + '"'
|
||||||
s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
|
s = '"' + val.to_a.collect{|e| array2tk_list(e, true)}.join(" ")\
|
||||||
.gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
|
.gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
|
||||||
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
|
||||||
@id, @id, @id, s))
|
@id, @id, @id, s))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user