зеркало из https://github.com/github/ruby.git
* lib/optparse.rb (ParseError.filter_backtrace): removes internal
backtrace. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
65fcdd10b7
Коммит
05124e6a55
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Oct 10 00:21:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/optparse.rb (ParseError.filter_backtrace): removes internal
|
||||||
|
backtrace.
|
||||||
|
|
||||||
Fri Oct 10 00:11:16 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
Fri Oct 10 00:11:16 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* transcode.c (rb_econv_add_coverter): remove unnecessary NULL check.
|
* transcode.c (rb_econv_add_coverter): remove unnecessary NULL check.
|
||||||
|
|
|
@ -301,7 +301,8 @@ class OptionParser
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.incompatible_argument_styles(arg, t)
|
def self.incompatible_argument_styles(arg, t)
|
||||||
raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}"
|
raise(ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}",
|
||||||
|
ParseError.filter_backtrace(caller(2)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.pattern
|
def self.pattern
|
||||||
|
@ -529,7 +530,8 @@ class OptionParser
|
||||||
#
|
#
|
||||||
def accept(t, pat = /.*/nm, &block)
|
def accept(t, pat = /.*/nm, &block)
|
||||||
if pat
|
if pat
|
||||||
pat.respond_to?(:match) or raise TypeError, "has no `match'"
|
pat.respond_to?(:match) or
|
||||||
|
raise TypeError, "has no `match'", ParseError.filter_backtrace(caller(2))
|
||||||
else
|
else
|
||||||
pat = t if t.respond_to?(:match)
|
pat = t if t.respond_to?(:match)
|
||||||
end
|
end
|
||||||
|
@ -987,12 +989,8 @@ class OptionParser
|
||||||
#
|
#
|
||||||
def notwice(obj, prv, msg)
|
def notwice(obj, prv, msg)
|
||||||
unless !prv or prv == obj
|
unless !prv or prv == obj
|
||||||
begin
|
raise(ArgumentError, "argument #{msg} given twice: #{obj}",
|
||||||
raise ArgumentError, "argument #{msg} given twice: #{obj}"
|
ParseError.filter_backtrace(caller(2)))
|
||||||
rescue
|
|
||||||
$@[0, 2] = nil
|
|
||||||
raise
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
@ -1097,7 +1095,7 @@ class OptionParser
|
||||||
end
|
end
|
||||||
o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
|
o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
|
||||||
when Module
|
when Module
|
||||||
raise ArgumentError, "unsupported argument type: #{o}"
|
raise ArgumentError, "unsupported argument type: #{o}", ParseError.filter_backtrace(caller(4))
|
||||||
when *ArgumentStyle.keys
|
when *ArgumentStyle.keys
|
||||||
style = notwice(ArgumentStyle[o], style, 'style')
|
style = notwice(ArgumentStyle[o], style, 'style')
|
||||||
when /^--no-([^\[\]=\s]*)(.+)?/
|
when /^--no-([^\[\]=\s]*)(.+)?/
|
||||||
|
@ -1162,7 +1160,9 @@ class OptionParser
|
||||||
s = (style || default_style).new(pattern || default_pattern,
|
s = (style || default_style).new(pattern || default_pattern,
|
||||||
conv, sdesc, ldesc, arg, desc, block)
|
conv, sdesc, ldesc, arg, desc, block)
|
||||||
elsif !block
|
elsif !block
|
||||||
raise ArgumentError, "no switch given" if style or pattern
|
if style or pattern
|
||||||
|
raise ArgumentError, "no switch given", ParseError.filter_backtrace(caller)
|
||||||
|
end
|
||||||
s = desc
|
s = desc
|
||||||
else
|
else
|
||||||
short << pattern
|
short << pattern
|
||||||
|
@ -1605,11 +1605,15 @@ class OptionParser
|
||||||
argv
|
argv
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_backtrace(array)
|
def self.filter_backtrace(array)
|
||||||
unless $DEBUG
|
unless $DEBUG
|
||||||
array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
|
array.delete_if(&%r"\A#{Regexp.quote(__FILE__)}:"o.method(:=~))
|
||||||
end
|
end
|
||||||
super(array)
|
array
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_backtrace(array)
|
||||||
|
super(self.class.filter_backtrace(array))
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_option(opt, eq)
|
def set_option(opt, eq)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче