Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: getopts.rb
#
[0] Fix | Delete
# getopts.rb -
[1] Fix | Delete
# $Release Version: $
[2] Fix | Delete
# $Revision: 11708 $
[3] Fix | Delete
# $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
[4] Fix | Delete
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
[5] Fix | Delete
#
[6] Fix | Delete
# --
[7] Fix | Delete
# this is obsolete; use getoptlong
[8] Fix | Delete
#
[9] Fix | Delete
# 2000-03-21
[10] Fix | Delete
# modified by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
[11] Fix | Delete
#
[12] Fix | Delete
# 2002-03-05
[13] Fix | Delete
# rewritten by Akinori MUSHA <knu@ruby-lang.org>
[14] Fix | Delete
#
[15] Fix | Delete
[16] Fix | Delete
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: getopts is deprecated after Ruby 1.8.1; use optparse instead" if caller[0] and $VERBOSE
[17] Fix | Delete
[18] Fix | Delete
$RCS_ID=%q$Header$
[19] Fix | Delete
[20] Fix | Delete
# getopts is obsolete. Use GetoptLong.
[21] Fix | Delete
[22] Fix | Delete
def getopts(single_options, *options)
[23] Fix | Delete
boolopts = {}
[24] Fix | Delete
valopts = {}
[25] Fix | Delete
[26] Fix | Delete
#
[27] Fix | Delete
# set defaults
[28] Fix | Delete
#
[29] Fix | Delete
single_options.scan(/.:?/) do |opt|
[30] Fix | Delete
if opt.size == 1
[31] Fix | Delete
boolopts[opt] = false
[32] Fix | Delete
else
[33] Fix | Delete
valopts[opt[0, 1]] = nil
[34] Fix | Delete
end
[35] Fix | Delete
end if single_options
[36] Fix | Delete
[37] Fix | Delete
options.each do |arg|
[38] Fix | Delete
opt, val = arg.split(':', 2)
[39] Fix | Delete
[40] Fix | Delete
if val
[41] Fix | Delete
valopts[opt] = val.empty? ? nil : val
[42] Fix | Delete
else
[43] Fix | Delete
boolopts[opt] = false
[44] Fix | Delete
end
[45] Fix | Delete
end
[46] Fix | Delete
[47] Fix | Delete
#
[48] Fix | Delete
# scan
[49] Fix | Delete
#
[50] Fix | Delete
c = 0
[51] Fix | Delete
argv = ARGV
[52] Fix | Delete
[53] Fix | Delete
while arg = argv.shift
[54] Fix | Delete
case arg
[55] Fix | Delete
when /\A--(.*)/
[56] Fix | Delete
if $1.empty? # xinit -- -bpp 24
[57] Fix | Delete
break
[58] Fix | Delete
end
[59] Fix | Delete
[60] Fix | Delete
opt, val = $1.split('=', 2)
[61] Fix | Delete
[62] Fix | Delete
if opt.size == 1
[63] Fix | Delete
argv.unshift arg
[64] Fix | Delete
return nil
[65] Fix | Delete
elsif valopts.key? opt # imclean --src +trash
[66] Fix | Delete
valopts[opt] = val || argv.shift or return nil
[67] Fix | Delete
elsif boolopts.key? opt # ruby --verbose
[68] Fix | Delete
boolopts[opt] = true
[69] Fix | Delete
else
[70] Fix | Delete
argv.unshift arg
[71] Fix | Delete
return nil
[72] Fix | Delete
end
[73] Fix | Delete
[74] Fix | Delete
c += 1
[75] Fix | Delete
when /\A-(.+)/
[76] Fix | Delete
opts = $1
[77] Fix | Delete
[78] Fix | Delete
until opts.empty?
[79] Fix | Delete
opt = opts.slice!(0, 1)
[80] Fix | Delete
[81] Fix | Delete
if valopts.key? opt
[82] Fix | Delete
val = opts
[83] Fix | Delete
[84] Fix | Delete
if val.empty? # ruby -e 'p $:'
[85] Fix | Delete
valopts[opt] = argv.shift or return nil
[86] Fix | Delete
else # cc -ohello ...
[87] Fix | Delete
valopts[opt] = val
[88] Fix | Delete
end
[89] Fix | Delete
[90] Fix | Delete
c += 1
[91] Fix | Delete
break
[92] Fix | Delete
elsif boolopts.key? opt
[93] Fix | Delete
boolopts[opt] = true # ruby -h
[94] Fix | Delete
c += 1
[95] Fix | Delete
else
[96] Fix | Delete
argv.unshift arg
[97] Fix | Delete
return nil
[98] Fix | Delete
end
[99] Fix | Delete
end
[100] Fix | Delete
else
[101] Fix | Delete
argv.unshift arg
[102] Fix | Delete
break
[103] Fix | Delete
end
[104] Fix | Delete
end
[105] Fix | Delete
[106] Fix | Delete
#
[107] Fix | Delete
# set
[108] Fix | Delete
#
[109] Fix | Delete
$OPT = {}
[110] Fix | Delete
[111] Fix | Delete
boolopts.each do |opt, val|
[112] Fix | Delete
$OPT[opt] = val
[113] Fix | Delete
[114] Fix | Delete
sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
[115] Fix | Delete
eval "$OPT_#{sopt} = val"
[116] Fix | Delete
end
[117] Fix | Delete
valopts.each do |opt, val|
[118] Fix | Delete
$OPT[opt] = val
[119] Fix | Delete
[120] Fix | Delete
sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
[121] Fix | Delete
eval "$OPT_#{sopt} = val"
[122] Fix | Delete
end
[123] Fix | Delete
[124] Fix | Delete
c
[125] Fix | Delete
end
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function