зеркало из https://github.com/github/ruby.git
* lib/getopts.rb: Do not choke on characters that cannot be used
in a variable name. Replace them with `_'. Define a hash named $OPT for convenience. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aae36756dc
Коммит
db9126b073
|
@ -1,3 +1,9 @@
|
|||
Mon Nov 4 03:59:51 2002 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/getopts.rb: Do not choke on characters that cannot be used
|
||||
in a variable name. Replace them with `_'. Define a hash named
|
||||
$OPT for convenience.
|
||||
|
||||
Sat Nov 2 00:38:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (Init_Object): added Object#object_id, new name for
|
||||
|
|
|
@ -105,11 +105,19 @@ def getopts(single_options, *options)
|
|||
#
|
||||
# set
|
||||
#
|
||||
$OPT = {}
|
||||
|
||||
boolopts.each do |opt, val|
|
||||
eval "$OPT_#{opt} = val"
|
||||
$OPT[opt] = val
|
||||
|
||||
sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
|
||||
eval "$OPT_#{sopt} = val"
|
||||
end
|
||||
valopts.each do |opt, val|
|
||||
eval "$OPT_#{opt} = val"
|
||||
$OPT[opt] = val
|
||||
|
||||
sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
|
||||
eval "$OPT_#{sopt} = val"
|
||||
end
|
||||
|
||||
c
|
||||
|
|
Загрузка…
Ссылка в новой задаче