Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: parsearg.rb
#
[0] Fix | Delete
# parsearg.rb - parse arguments
[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
#
[8] Fix | Delete
#
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: parsearg is deprecated after Ruby 1.8.1; use optparse instead"
[12] Fix | Delete
[13] Fix | Delete
$RCS_ID=%q$Header$
[14] Fix | Delete
[15] Fix | Delete
require "getopts"
[16] Fix | Delete
[17] Fix | Delete
def printUsageAndExit()
[18] Fix | Delete
if $USAGE
[19] Fix | Delete
eval($USAGE)
[20] Fix | Delete
end
[21] Fix | Delete
exit()
[22] Fix | Delete
end
[23] Fix | Delete
[24] Fix | Delete
def setParenthesis(ex, opt, c)
[25] Fix | Delete
if opt != ""
[26] Fix | Delete
ex = sprintf("%s$OPT_%s%s", ex, opt, c)
[27] Fix | Delete
else
[28] Fix | Delete
ex = sprintf("%s%s", ex, c)
[29] Fix | Delete
end
[30] Fix | Delete
return ex
[31] Fix | Delete
end
[32] Fix | Delete
[33] Fix | Delete
def setOrAnd(ex, opt, c)
[34] Fix | Delete
if opt != ""
[35] Fix | Delete
ex = sprintf("%s$OPT_%s %s%s ", ex, opt, c, c)
[36] Fix | Delete
else
[37] Fix | Delete
ex = sprintf("%s %s%s ", ex, c, c)
[38] Fix | Delete
end
[39] Fix | Delete
return ex
[40] Fix | Delete
end
[41] Fix | Delete
[42] Fix | Delete
def setExpression(ex, opt, op)
[43] Fix | Delete
if !op
[44] Fix | Delete
ex = sprintf("%s$OPT_%s", ex, opt)
[45] Fix | Delete
return ex
[46] Fix | Delete
end
[47] Fix | Delete
case op.chr
[48] Fix | Delete
when "(", ")"
[49] Fix | Delete
ex = setParenthesis(ex, opt, op.chr)
[50] Fix | Delete
when "|", "&"
[51] Fix | Delete
ex = setOrAnd(ex, opt, op.chr)
[52] Fix | Delete
else
[53] Fix | Delete
return nil
[54] Fix | Delete
end
[55] Fix | Delete
return ex
[56] Fix | Delete
end
[57] Fix | Delete
[58] Fix | Delete
# parseArgs is obsolete. Use OptionParser instead.
[59] Fix | Delete
[60] Fix | Delete
def parseArgs(argc, nopt, single_opts, *opts)
[61] Fix | Delete
if (noOptions = getopts(single_opts, *opts)) == nil
[62] Fix | Delete
printUsageAndExit()
[63] Fix | Delete
end
[64] Fix | Delete
if nopt
[65] Fix | Delete
ex = nil
[66] Fix | Delete
pos = 0
[67] Fix | Delete
for o in nopt.split(/[()|&]/)
[68] Fix | Delete
pos += o.length
[69] Fix | Delete
ex = setExpression(ex, o, nopt[pos])
[70] Fix | Delete
pos += 1
[71] Fix | Delete
end
[72] Fix | Delete
begin
[73] Fix | Delete
if !eval(ex)
[74] Fix | Delete
printUsageAndExit()
[75] Fix | Delete
end
[76] Fix | Delete
rescue
[77] Fix | Delete
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
[78] Fix | Delete
exit!(-1)
[79] Fix | Delete
end
[80] Fix | Delete
end
[81] Fix | Delete
if ARGV.length < argc
[82] Fix | Delete
printUsageAndExit()
[83] Fix | Delete
end
[84] Fix | Delete
return noOptions
[85] Fix | Delete
end
[86] Fix | Delete
[87] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function