mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style Patch by Steve Klabnik [Ruby 1.9 - Bug #4730] Patch by Jason Dew [Ruby 1.9 - Feature #4718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34276148c4
commit
7bbf2f3085
67 changed files with 3823 additions and 3814 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu May 19 06:16:41 2011 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib: Convert tabs to spaces for ruby files per
|
||||
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style
|
||||
Patch by Steve Klabnik [Ruby 1.9 - Bug #4730]
|
||||
Patch by Jason Dew [Ruby 1.9 - Feature #4718]
|
||||
|
||||
Thu May 19 06:06:07 2011 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/cgi/util.rb: Improve documentation. Patch by Clinton Nixon.
|
||||
|
|
|
@ -548,9 +548,9 @@ if __FILE__ == $0
|
|||
x.report("for:") {for _ in 1..n; _ = "1"; end} # Benchmark.measure
|
||||
x.report("times:") {n.times do ; _ = "1"; end}
|
||||
x.report("upto:") {1.upto(n) do ; _ = "1"; end}
|
||||
end
|
||||
end
|
||||
|
||||
benchmark do
|
||||
benchmark do
|
||||
[
|
||||
measure{for _ in 1..n; _ = "1"; end}, # Benchmark.measure
|
||||
measure{n.times do ; _ = "1"; end},
|
||||
|
|
|
@ -21,9 +21,9 @@ end
|
|||
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
|
||||
|
||||
class DEBUGGER__
|
||||
MUTEX = Mutex.new
|
||||
MUTEX = Mutex.new
|
||||
|
||||
class Context
|
||||
class Context
|
||||
DEBUG_LAST_CMD = []
|
||||
|
||||
begin
|
||||
|
@ -548,7 +548,7 @@ Commands
|
|||
p expression evaluate expression and print its value
|
||||
h[elp] print this help
|
||||
<everything else> evaluate
|
||||
EOHELP
|
||||
EOHELP
|
||||
end
|
||||
|
||||
def display_expressions(binding)
|
||||
|
|
|
@ -72,7 +72,7 @@ module IRB
|
|||
ensure
|
||||
irb_at_exit
|
||||
end
|
||||
# print "\n"
|
||||
# print "\n"
|
||||
end
|
||||
|
||||
def IRB.irb_at_exit
|
||||
|
|
|
@ -478,7 +478,7 @@ class Logger
|
|||
@logdev.close if @logdev
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
# Severity label for logging. (max 5 char)
|
||||
SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)
|
||||
|
|
38
lib/mkmf.rb
38
lib/mkmf.rb
|
@ -337,12 +337,12 @@ def log_src(src)
|
|||
Logging::message <<"EOM"
|
||||
checked program was:
|
||||
/* begin */
|
||||
EOM
|
||||
EOM
|
||||
src.each_with_index {|line, no| Logging::message fmt, no+1, line}
|
||||
Logging::message <<"EOM"
|
||||
/* end */
|
||||
|
||||
EOM
|
||||
EOM
|
||||
end
|
||||
|
||||
def create_tmpsrc(src)
|
||||
|
@ -547,7 +547,7 @@ end
|
|||
def try_static_assert(expr, headers = nil, opt = "", &b)
|
||||
headers = cpp_include(headers)
|
||||
try_compile(<<SRC, opt, &b)
|
||||
#{headers}
|
||||
#{headers}
|
||||
/*top*/
|
||||
int conftest_const[(#{expr}) ? 1 : -1];
|
||||
SRC
|
||||
|
@ -616,15 +616,15 @@ def try_func(func, libs, headers = nil, &b)
|
|||
decltype = proc {|x| "void ((*#{x})())"}
|
||||
end
|
||||
try_link(<<"SRC", libs, &b) or
|
||||
#{headers}
|
||||
#{headers}
|
||||
/*top*/
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int t() { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return 0; }
|
||||
SRC
|
||||
call && try_link(<<"SRC", libs, &b)
|
||||
#{headers}
|
||||
#{headers}
|
||||
/*top*/
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int t() { #{func}(); return 0; }
|
||||
SRC
|
||||
end
|
||||
|
@ -633,9 +633,9 @@ end
|
|||
def try_var(var, headers = nil, &b)
|
||||
headers = cpp_include(headers)
|
||||
try_compile(<<"SRC", &b)
|
||||
#{headers}
|
||||
#{headers}
|
||||
/*top*/
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
|
||||
SRC
|
||||
end
|
||||
|
@ -999,9 +999,9 @@ end
|
|||
def have_struct_member(type, member, headers = nil, &b)
|
||||
checking_for checking_message("#{type}.#{member}", headers) do
|
||||
if try_compile(<<"SRC", &b)
|
||||
#{cpp_include(headers)}
|
||||
#{cpp_include(headers)}
|
||||
/*top*/
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
|
||||
SRC
|
||||
$defs.push(format("-DHAVE_%s_%s", type.tr_cpp, member.tr_cpp))
|
||||
|
@ -1019,7 +1019,7 @@ end
|
|||
#
|
||||
def try_type(type, headers = nil, opt = "", &b)
|
||||
if try_compile(<<"SRC", opt, &b)
|
||||
#{cpp_include(headers)}
|
||||
#{cpp_include(headers)}
|
||||
/*top*/
|
||||
typedef #{type} conftest_type;
|
||||
int conftestval[sizeof(conftest_type)?1:-1];
|
||||
|
@ -1077,7 +1077,7 @@ end
|
|||
def try_const(const, headers = nil, opt = "", &b)
|
||||
const, type = *const
|
||||
if try_compile(<<"SRC", opt, &b)
|
||||
#{cpp_include(headers)}
|
||||
#{cpp_include(headers)}
|
||||
/*top*/
|
||||
typedef #{type || 'int'} conftest_type;
|
||||
conftest_type conftestval = #{type ? '' : '(int)'}#{const};
|
||||
|
@ -1239,10 +1239,10 @@ end
|
|||
# pointer.
|
||||
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
|
||||
try_compile(<<"SRC", &b) # pointer
|
||||
#{cpp_include(headers)}
|
||||
#{cpp_include(headers)}
|
||||
/*top*/
|
||||
volatile #{type} conftestval;
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int t() {return (int)(1-*(conftestval#{member ? ".#{member}" : ""}));}
|
||||
SRC
|
||||
end
|
||||
|
@ -1251,10 +1251,10 @@ end
|
|||
# pointer.
|
||||
def scalar_type?(type, member = nil, headers = nil, &b)
|
||||
try_compile(<<"SRC", &b) # pointer
|
||||
#{cpp_include(headers)}
|
||||
#{cpp_include(headers)}
|
||||
/*top*/
|
||||
volatile #{type} conftestval;
|
||||
#{MAIN_DOES_NOTHING}
|
||||
#{MAIN_DOES_NOTHING}
|
||||
int t() {return (int)(1-(conftestval#{member ? ".#{member}" : ""}));}
|
||||
SRC
|
||||
end
|
||||
|
@ -1266,7 +1266,7 @@ def have_typeof?
|
|||
$typeof = %w[__typeof__ typeof].find do |t|
|
||||
try_compile(<<SRC)
|
||||
int rbcv_foo;
|
||||
#{t}(rbcv_foo) rbcv_bar;
|
||||
#{t}(rbcv_foo) rbcv_bar;
|
||||
SRC
|
||||
end
|
||||
end
|
||||
|
@ -1644,7 +1644,7 @@ ECHO1 = $(V:1=@:)
|
|||
ECHO = $(ECHO1:0=@echo)
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
#{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
|
||||
#{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
|
||||
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}.quote}
|
||||
topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote}
|
||||
hdrdir = #{mkintpath(CONFIG["hdrdir"]).quote}
|
||||
|
|
134
lib/net/imap.rb
134
lib/net/imap.rb
|
@ -2032,41 +2032,41 @@ module Net
|
|||
T_TEXT = :TEXT
|
||||
|
||||
BEG_REGEXP = /\G(?:\
|
||||
(?# 1: SPACE )( +)|\
|
||||
(?# 2: NIL )(NIL)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
|
||||
(?# 3: NUMBER )(\d+)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
|
||||
(?# 4: ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+]+)|\
|
||||
(?# 5: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
|
||||
(?# 6: LPAR )(\()|\
|
||||
(?# 7: RPAR )(\))|\
|
||||
(?# 8: BSLASH )(\\)|\
|
||||
(?# 9: STAR )(\*)|\
|
||||
(?# 10: LBRA )(\[)|\
|
||||
(?# 11: RBRA )(\])|\
|
||||
(?# 12: LITERAL )\{(\d+)\}\r\n|\
|
||||
(?# 13: PLUS )(\+)|\
|
||||
(?# 14: PERCENT )(%)|\
|
||||
(?# 15: CRLF )(\r\n)|\
|
||||
(?# 16: EOF )(\z))/ni
|
||||
(?# 1: SPACE )( +)|\
|
||||
(?# 2: NIL )(NIL)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
|
||||
(?# 3: NUMBER )(\d+)(?=[\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+])|\
|
||||
(?# 4: ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*#{'"'}\\\[\]+]+)|\
|
||||
(?# 5: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
|
||||
(?# 6: LPAR )(\()|\
|
||||
(?# 7: RPAR )(\))|\
|
||||
(?# 8: BSLASH )(\\)|\
|
||||
(?# 9: STAR )(\*)|\
|
||||
(?# 10: LBRA )(\[)|\
|
||||
(?# 11: RBRA )(\])|\
|
||||
(?# 12: LITERAL )\{(\d+)\}\r\n|\
|
||||
(?# 13: PLUS )(\+)|\
|
||||
(?# 14: PERCENT )(%)|\
|
||||
(?# 15: CRLF )(\r\n)|\
|
||||
(?# 16: EOF )(\z))/ni
|
||||
|
||||
DATA_REGEXP = /\G(?:\
|
||||
(?# 1: SPACE )( )|\
|
||||
(?# 2: NIL )(NIL)|\
|
||||
(?# 3: NUMBER )(\d+)|\
|
||||
(?# 4: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
|
||||
(?# 5: LITERAL )\{(\d+)\}\r\n|\
|
||||
(?# 6: LPAR )(\()|\
|
||||
(?# 7: RPAR )(\)))/ni
|
||||
(?# 1: SPACE )( )|\
|
||||
(?# 2: NIL )(NIL)|\
|
||||
(?# 3: NUMBER )(\d+)|\
|
||||
(?# 4: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
|
||||
(?# 5: LITERAL )\{(\d+)\}\r\n|\
|
||||
(?# 6: LPAR )(\()|\
|
||||
(?# 7: RPAR )(\)))/ni
|
||||
|
||||
TEXT_REGEXP = /\G(?:\
|
||||
(?# 1: TEXT )([^\x00\r\n]*))/ni
|
||||
(?# 1: TEXT )([^\x00\r\n]*))/ni
|
||||
|
||||
RTEXT_REGEXP = /\G(?:\
|
||||
(?# 1: LBRA )(\[)|\
|
||||
(?# 2: TEXT )([^\x00\r\n]*))/ni
|
||||
(?# 1: LBRA )(\[)|\
|
||||
(?# 2: TEXT )([^\x00\r\n]*))/ni
|
||||
|
||||
CTEXT_REGEXP = /\G(?:\
|
||||
(?# 1: TEXT )([^\x00\r\n\]]*))/ni
|
||||
(?# 1: TEXT )([^\x00\r\n\]]*))/ni
|
||||
|
||||
Token = Struct.new(:symbol, :value)
|
||||
|
||||
|
@ -2932,11 +2932,11 @@ module Net
|
|||
end
|
||||
|
||||
ADDRESS_REGEXP = /\G\
|
||||
(?# 1: NAME )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 2: ROUTE )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 3: MAILBOX )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 4: HOST )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)")\
|
||||
\)/ni
|
||||
(?# 1: NAME )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 2: ROUTE )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 3: MAILBOX )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
|
||||
(?# 4: HOST )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)")\
|
||||
\)/ni
|
||||
|
||||
def address
|
||||
match(T_LPAR)
|
||||
|
@ -2965,42 +2965,42 @@ module Net
|
|||
return Address.new(name, route, mailbox, host)
|
||||
end
|
||||
|
||||
# def flag_list
|
||||
# result = []
|
||||
# match(T_LPAR)
|
||||
# while true
|
||||
# token = lookahead
|
||||
# case token.symbol
|
||||
# when T_RPAR
|
||||
# shift_token
|
||||
# break
|
||||
# when T_SPACE
|
||||
# shift_token
|
||||
# end
|
||||
# result.push(flag)
|
||||
# end
|
||||
# return result
|
||||
# end
|
||||
# def flag_list
|
||||
# result = []
|
||||
# match(T_LPAR)
|
||||
# while true
|
||||
# token = lookahead
|
||||
# case token.symbol
|
||||
# when T_RPAR
|
||||
# shift_token
|
||||
# break
|
||||
# when T_SPACE
|
||||
# shift_token
|
||||
# end
|
||||
# result.push(flag)
|
||||
# end
|
||||
# return result
|
||||
# end
|
||||
|
||||
# def flag
|
||||
# token = lookahead
|
||||
# if token.symbol == T_BSLASH
|
||||
# shift_token
|
||||
# token = lookahead
|
||||
# if token.symbol == T_STAR
|
||||
# shift_token
|
||||
# return token.value.intern
|
||||
# else
|
||||
# return atom.intern
|
||||
# end
|
||||
# else
|
||||
# return atom
|
||||
# end
|
||||
# end
|
||||
# def flag
|
||||
# token = lookahead
|
||||
# if token.symbol == T_BSLASH
|
||||
# shift_token
|
||||
# token = lookahead
|
||||
# if token.symbol == T_STAR
|
||||
# shift_token
|
||||
# return token.value.intern
|
||||
# else
|
||||
# return atom.intern
|
||||
# end
|
||||
# else
|
||||
# return atom
|
||||
# end
|
||||
# end
|
||||
|
||||
FLAG_REGEXP = /\
|
||||
(?# FLAG )\\([^\x80-\xff(){ \x00-\x1f\x7f%"\\]+)|\
|
||||
(?# ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\]+)/n
|
||||
(?# FLAG )\\([^\x80-\xff(){ \x00-\x1f\x7f%"\\]+)|\
|
||||
(?# ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\]+)/n
|
||||
|
||||
def flag_list
|
||||
if @str.index(/\(([^)]*)\)/ni, @pos)
|
||||
|
@ -3514,7 +3514,7 @@ usage: #{$0} [options] <host>
|
|||
--auth=AUTH specifies auth type
|
||||
--starttls use starttls
|
||||
--ssl use ssl
|
||||
EOF
|
||||
EOF
|
||||
end
|
||||
|
||||
begin
|
||||
|
@ -3649,7 +3649,7 @@ summary display summary
|
|||
fetch [msgno] display message
|
||||
logout logout
|
||||
help, ? display help message
|
||||
EOF
|
||||
EOF
|
||||
else
|
||||
print "unknown command: ", cmd, "\n"
|
||||
end
|
||||
|
|
|
@ -760,5 +760,5 @@ module Net
|
|||
end
|
||||
|
||||
end # class Telnet
|
||||
end # module Net
|
||||
end # module Net
|
||||
|
||||
|
|
216
lib/prime.rb
216
lib/prime.rb
|
@ -100,50 +100,50 @@ class Prime
|
|||
def method_added(method) # :nodoc:
|
||||
(class<< self;self;end).def_delegator :instance, method
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Iterates the given block over all prime numbers.
|
||||
#
|
||||
# == Parameters
|
||||
# +ubound+::
|
||||
# Optional. An arbitrary positive number.
|
||||
# The upper bound of enumeration. The method enumerates
|
||||
# prime numbers infinitely if +ubound+ is nil.
|
||||
# +generator+::
|
||||
# Optional. An implementation of pseudo-prime generator.
|
||||
#
|
||||
# == Return value
|
||||
# An evaluated value of the given block at the last time.
|
||||
# Or an enumerator which is compatible to an +Enumerator+
|
||||
# if no block given.
|
||||
#
|
||||
# == Description
|
||||
# Calls +block+ once for each prime number, passing the prime as
|
||||
# a parameter.
|
||||
#
|
||||
# +ubound+::
|
||||
# Upper bound of prime numbers. The iterator stops after
|
||||
# yields all prime numbers p <= +ubound+.
|
||||
#
|
||||
# == Note
|
||||
# +Prime+.+new+ returns a object extended by +Prime+::+OldCompatibility+
|
||||
# in order to compatibility to Ruby 1.8, and +Prime+#each is overwritten
|
||||
# by +Prime+::+OldCompatibility+#+each+.
|
||||
#
|
||||
# +Prime+.+new+ is now obsolete. Use +Prime+.+instance+.+each+ or simply
|
||||
# +Prime+.+each+.
|
||||
def each(ubound = nil, generator = EratosthenesGenerator.new, &block)
|
||||
# Iterates the given block over all prime numbers.
|
||||
#
|
||||
# == Parameters
|
||||
# +ubound+::
|
||||
# Optional. An arbitrary positive number.
|
||||
# The upper bound of enumeration. The method enumerates
|
||||
# prime numbers infinitely if +ubound+ is nil.
|
||||
# +generator+::
|
||||
# Optional. An implementation of pseudo-prime generator.
|
||||
#
|
||||
# == Return value
|
||||
# An evaluated value of the given block at the last time.
|
||||
# Or an enumerator which is compatible to an +Enumerator+
|
||||
# if no block given.
|
||||
#
|
||||
# == Description
|
||||
# Calls +block+ once for each prime number, passing the prime as
|
||||
# a parameter.
|
||||
#
|
||||
# +ubound+::
|
||||
# Upper bound of prime numbers. The iterator stops after
|
||||
# yields all prime numbers p <= +ubound+.
|
||||
#
|
||||
# == Note
|
||||
# +Prime+.+new+ returns a object extended by +Prime+::+OldCompatibility+
|
||||
# in order to compatibility to Ruby 1.8, and +Prime+#each is overwritten
|
||||
# by +Prime+::+OldCompatibility+#+each+.
|
||||
#
|
||||
# +Prime+.+new+ is now obsolete. Use +Prime+.+instance+.+each+ or simply
|
||||
# +Prime+.+each+.
|
||||
def each(ubound = nil, generator = EratosthenesGenerator.new, &block)
|
||||
generator.upper_bound = ubound
|
||||
generator.each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns true if +value+ is prime, false for a composite.
|
||||
#
|
||||
# == Parameters
|
||||
# +value+:: an arbitrary integer to be checked.
|
||||
# +generator+:: optional. A pseudo-prime generator.
|
||||
def prime?(value, generator = Prime::Generator23.new)
|
||||
# Returns true if +value+ is prime, false for a composite.
|
||||
#
|
||||
# == Parameters
|
||||
# +value+:: an arbitrary integer to be checked.
|
||||
# +generator+:: optional. A pseudo-prime generator.
|
||||
def prime?(value, generator = Prime::Generator23.new)
|
||||
value = -value if value < 0
|
||||
return false if value < 2
|
||||
for num in generator
|
||||
|
@ -151,48 +151,48 @@ class Prime
|
|||
return true if q < num
|
||||
return false if r == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Re-composes a prime factorization and returns the product.
|
||||
#
|
||||
# == Parameters
|
||||
# +pd+:: Array of pairs of integers. The each internal
|
||||
# pair consists of a prime number -- a prime factor --
|
||||
# and a natural number -- an exponent.
|
||||
#
|
||||
# == Example
|
||||
# For [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]], it returns
|
||||
# p_1**e_1 * p_2**e_2 * .... * p_n**e_n.
|
||||
#
|
||||
# Prime.int_from_prime_division([[2,2], [3,1]]) #=> 12
|
||||
def int_from_prime_division(pd)
|
||||
# Re-composes a prime factorization and returns the product.
|
||||
#
|
||||
# == Parameters
|
||||
# +pd+:: Array of pairs of integers. The each internal
|
||||
# pair consists of a prime number -- a prime factor --
|
||||
# and a natural number -- an exponent.
|
||||
#
|
||||
# == Example
|
||||
# For [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]], it returns
|
||||
# p_1**e_1 * p_2**e_2 * .... * p_n**e_n.
|
||||
#
|
||||
# Prime.int_from_prime_division([[2,2], [3,1]]) #=> 12
|
||||
def int_from_prime_division(pd)
|
||||
pd.inject(1){|value, (prime, index)|
|
||||
value *= prime**index
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the factorization of +value+.
|
||||
#
|
||||
# == Parameters
|
||||
# +value+:: An arbitrary integer.
|
||||
# +generator+:: Optional. A pseudo-prime generator.
|
||||
# +generator+.succ must return the next
|
||||
# pseudo-prime number in the ascendent
|
||||
# order. It must generate all prime numbers,
|
||||
# but may generate non prime numbers.
|
||||
#
|
||||
# === Exceptions
|
||||
# +ZeroDivisionError+:: when +value+ is zero.
|
||||
#
|
||||
# == Example
|
||||
# For an arbitrary integer
|
||||
# n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n,
|
||||
# prime_division(n) returns
|
||||
# [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]].
|
||||
#
|
||||
# Prime.prime_division(12) #=> [[2,2], [3,1]]
|
||||
#
|
||||
def prime_division(value, generator= Prime::Generator23.new)
|
||||
# Returns the factorization of +value+.
|
||||
#
|
||||
# == Parameters
|
||||
# +value+:: An arbitrary integer.
|
||||
# +generator+:: Optional. A pseudo-prime generator.
|
||||
# +generator+.succ must return the next
|
||||
# pseudo-prime number in the ascendent
|
||||
# order. It must generate all prime numbers,
|
||||
# but may generate non prime numbers.
|
||||
#
|
||||
# === Exceptions
|
||||
# +ZeroDivisionError+:: when +value+ is zero.
|
||||
#
|
||||
# == Example
|
||||
# For an arbitrary integer
|
||||
# n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n,
|
||||
# prime_division(n) returns
|
||||
# [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]].
|
||||
#
|
||||
# Prime.prime_division(12) #=> [[2,2], [3,1]]
|
||||
#
|
||||
def prime_division(value, generator= Prime::Generator23.new)
|
||||
raise ZeroDivisionError if value == 0
|
||||
if value < 0
|
||||
value = -value
|
||||
|
@ -216,12 +216,12 @@ class Prime
|
|||
pv.push [value, 1]
|
||||
end
|
||||
return pv
|
||||
end
|
||||
end
|
||||
|
||||
# An abstract class for enumerating pseudo-prime numbers.
|
||||
#
|
||||
# Concrete subclasses should override succ, next, rewind.
|
||||
class PseudoPrimeGenerator
|
||||
# An abstract class for enumerating pseudo-prime numbers.
|
||||
#
|
||||
# Concrete subclasses should override succ, next, rewind.
|
||||
class PseudoPrimeGenerator
|
||||
include Enumerable
|
||||
|
||||
def initialize(ubound = nil)
|
||||
|
@ -282,12 +282,12 @@ class Prime
|
|||
yield prime, obj
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# An implementation of +PseudoPrimeGenerator+.
|
||||
#
|
||||
# Uses +EratosthenesSieve+.
|
||||
class EratosthenesGenerator < PseudoPrimeGenerator
|
||||
# An implementation of +PseudoPrimeGenerator+.
|
||||
#
|
||||
# Uses +EratosthenesSieve+.
|
||||
class EratosthenesGenerator < PseudoPrimeGenerator
|
||||
def initialize
|
||||
@last_prime = nil
|
||||
super
|
||||
|
@ -300,11 +300,11 @@ class Prime
|
|||
initialize
|
||||
end
|
||||
alias next succ
|
||||
end
|
||||
end
|
||||
|
||||
# An implementation of +PseudoPrimeGenerator+ which uses
|
||||
# a prime table generated by trial division.
|
||||
class TrialDivisionGenerator<PseudoPrimeGenerator
|
||||
# An implementation of +PseudoPrimeGenerator+ which uses
|
||||
# a prime table generated by trial division.
|
||||
class TrialDivisionGenerator<PseudoPrimeGenerator
|
||||
def initialize
|
||||
@index = -1
|
||||
super
|
||||
|
@ -317,15 +317,15 @@ class Prime
|
|||
initialize
|
||||
end
|
||||
alias next succ
|
||||
end
|
||||
end
|
||||
|
||||
# Generates all integer which are greater than 2 and
|
||||
# are not divided by 2 nor 3.
|
||||
#
|
||||
# This is a pseudo-prime generator, suitable on
|
||||
# checking primality of a integer by brute force
|
||||
# method.
|
||||
class Generator23<PseudoPrimeGenerator
|
||||
# Generates all integer which are greater than 2 and
|
||||
# are not divided by 2 nor 3.
|
||||
#
|
||||
# This is a pseudo-prime generator, suitable on
|
||||
# checking primality of a integer by brute force
|
||||
# method.
|
||||
class Generator23<PseudoPrimeGenerator
|
||||
def initialize
|
||||
@prime = 1
|
||||
@step = nil
|
||||
|
@ -351,13 +351,13 @@ class Prime
|
|||
def rewind
|
||||
initialize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# Internal use. An implementation of prime table by trial division method.
|
||||
class TrialDivision
|
||||
# Internal use. An implementation of prime table by trial division method.
|
||||
class TrialDivision
|
||||
include Singleton
|
||||
|
||||
def initialize # :nodoc:
|
||||
|
@ -402,10 +402,10 @@ class Prime
|
|||
end
|
||||
return @primes[index]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Internal use. An implementation of eratosthenes's sieve
|
||||
class EratosthenesSieve
|
||||
# Internal use. An implementation of eratosthenes's sieve
|
||||
class EratosthenesSieve
|
||||
include Singleton
|
||||
|
||||
BITS_PER_ENTRY = 16 # each entry is a set of 16-bits in a Fixnum
|
||||
|
@ -471,10 +471,10 @@ class Prime
|
|||
end
|
||||
@tables << new_table.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Provides a +Prime+ object with compatibility to Ruby 1.8 when instantiated via +Prime+.+new+.
|
||||
module OldCompatibility
|
||||
# Provides a +Prime+ object with compatibility to Ruby 1.8 when instantiated via +Prime+.+new+.
|
||||
module OldCompatibility
|
||||
# Returns the next prime number and forwards internal pointer.
|
||||
def succ
|
||||
@generator.succ
|
||||
|
@ -491,5 +491,5 @@ class Prime
|
|||
yield succ
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require 'rexml/xmltokens'
|
||||
|
||||
# [ :element, parent, name, attributes, children* ]
|
||||
# a = Node.new
|
||||
# a << "B" # => <a>B</a>
|
||||
# a.b # => <a>B<b/></a>
|
||||
# a.b[1] # => <a>B<b/><b/><a>
|
||||
# a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
|
||||
# a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
|
||||
# a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
|
||||
# a = Node.new
|
||||
# a << "B" # => <a>B</a>
|
||||
# a.b # => <a>B<b/></a>
|
||||
# a.b[1] # => <a>B<b/><b/><a>
|
||||
# a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
|
||||
# a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
|
||||
# a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
|
||||
module REXML
|
||||
module Light
|
||||
# Represents a tagged XML element. Elements are characterized by
|
||||
|
|
|
@ -17,7 +17,7 @@ module RSS
|
|||
class ImageItem < ImageItemBase
|
||||
DublinCoreModel.install_dublin_core(self)
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
class ImageItemBase < Base
|
||||
|
|
|
@ -209,7 +209,7 @@ module RSS
|
|||
else
|
||||
''
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
alias_method(:install_have_attribute_element, :install_have_child_element)
|
||||
|
@ -230,7 +230,7 @@ EOC
|
|||
rv << value if /\\A\\s*\\z/ !~ value
|
||||
end
|
||||
rv.join("\n")
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -264,7 +264,7 @@ EOC
|
|||
else
|
||||
''
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -295,7 +295,7 @@ EOC
|
|||
else
|
||||
''
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -310,7 +310,7 @@ EOC
|
|||
#{yield(name, elem_name)}
|
||||
end
|
||||
private :#{method_name}
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def inherit_convert_attr_reader(*attrs)
|
||||
|
@ -330,7 +330,7 @@ EOC
|
|||
nil
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -351,7 +351,7 @@ EOC
|
|||
"\#{base}\#{value}"
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -362,7 +362,7 @@ EOC
|
|||
def #{attr}
|
||||
convert(@#{attr})
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -448,7 +448,7 @@ EOC
|
|||
end
|
||||
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def integer_writer(name, disp_name=name)
|
||||
|
@ -468,7 +468,7 @@ EOC
|
|||
end
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def positive_integer_writer(name, disp_name=name)
|
||||
|
@ -490,7 +490,7 @@ EOC
|
|||
end
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def boolean_writer(name, disp_name=name)
|
||||
|
@ -510,7 +510,7 @@ EOC
|
|||
end
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def text_type_writer(name, disp_name=name)
|
||||
|
@ -522,7 +522,7 @@ EOC
|
|||
end
|
||||
@#{name} = new_value
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def content_writer(name, disp_name=name)
|
||||
|
@ -536,7 +536,7 @@ EOC
|
|||
@#{name}.content = new_value
|
||||
end
|
||||
end
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
|
||||
def yes_clean_other_writer(name, disp_name=name)
|
||||
|
@ -603,7 +603,7 @@ EOC
|
|||
end
|
||||
end
|
||||
alias_method(:set_#{accessor_name}, :#{accessor_name}=)
|
||||
EOC
|
||||
EOC
|
||||
end
|
||||
end
|
||||
|
||||
|
|
58
lib/scanf.rb
58
lib/scanf.rb
|
@ -578,33 +578,33 @@ end
|
|||
|
||||
class IO
|
||||
|
||||
# The trick here is doing a match where you grab one *line*
|
||||
# of input at a time. The linebreak may or may not occur
|
||||
# at the boundary where the string matches a format specifier.
|
||||
# And if it does, some rule about whitespace may or may not
|
||||
# be in effect...
|
||||
#
|
||||
# That's why this is much more elaborate than the string
|
||||
# version.
|
||||
#
|
||||
# For each line:
|
||||
# Match succeeds (non-emptily)
|
||||
# and the last attempted spec/string sub-match succeeded:
|
||||
#
|
||||
# could the last spec keep matching?
|
||||
# yes: save interim results and continue (next line)
|
||||
#
|
||||
# The last attempted spec/string did not match:
|
||||
#
|
||||
# are we on the next-to-last spec in the string?
|
||||
# yes:
|
||||
# is fmt_string.string_left all spaces?
|
||||
# yes: does current spec care about input space?
|
||||
# yes: fatal failure
|
||||
# no: save interim results and continue
|
||||
# no: continue [this state could be analyzed further]
|
||||
#
|
||||
#
|
||||
# The trick here is doing a match where you grab one *line*
|
||||
# of input at a time. The linebreak may or may not occur
|
||||
# at the boundary where the string matches a format specifier.
|
||||
# And if it does, some rule about whitespace may or may not
|
||||
# be in effect...
|
||||
#
|
||||
# That's why this is much more elaborate than the string
|
||||
# version.
|
||||
#
|
||||
# For each line:
|
||||
# Match succeeds (non-emptily)
|
||||
# and the last attempted spec/string sub-match succeeded:
|
||||
#
|
||||
# could the last spec keep matching?
|
||||
# yes: save interim results and continue (next line)
|
||||
#
|
||||
# The last attempted spec/string did not match:
|
||||
#
|
||||
# are we on the next-to-last spec in the string?
|
||||
# yes:
|
||||
# is fmt_string.string_left all spaces?
|
||||
# yes: does current spec care about input space?
|
||||
# yes: fatal failure
|
||||
# no: save interim results and continue
|
||||
# no: continue [this state could be analyzed further]
|
||||
#
|
||||
#
|
||||
|
||||
def scanf(str,&b)
|
||||
return block_scanf(str,&b) if b
|
||||
|
@ -671,8 +671,8 @@ class IO
|
|||
|
||||
def block_scanf(str)
|
||||
final = []
|
||||
# Sub-ideal, since another FS gets created in scanf.
|
||||
# But used here to determine the number of specifiers.
|
||||
# Sub-ideal, since another FS gets created in scanf.
|
||||
# But used here to determine the number of specifiers.
|
||||
fstr = Scanf::FormatString.new(str)
|
||||
last_spec = fstr.last_spec
|
||||
begin
|
||||
|
|
106
lib/set.rb
106
lib/set.rb
|
@ -351,11 +351,11 @@ class Set
|
|||
n = Set.new(enum)
|
||||
each { |o| if n.include?(o) then n.delete(o) else n.add(o) end }
|
||||
n
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if two sets are equal. The equality of each couple
|
||||
# of elements is defined according to Object#eql?.
|
||||
def ==(other)
|
||||
# Returns true if two sets are equal. The equality of each couple
|
||||
# of elements is defined according to Object#eql?.
|
||||
def ==(other)
|
||||
if self.equal?(other)
|
||||
true
|
||||
elsif other.instance_of?(self.class)
|
||||
|
@ -365,31 +365,31 @@ class Set
|
|||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def hash # :nodoc:
|
||||
def hash # :nodoc:
|
||||
@hash.hash
|
||||
end
|
||||
end
|
||||
|
||||
def eql?(o) # :nodoc:
|
||||
def eql?(o) # :nodoc:
|
||||
return false unless o.is_a?(Set)
|
||||
@hash.eql?(o.instance_eval{@hash})
|
||||
end
|
||||
end
|
||||
|
||||
# Classifies the set by the return value of the given block and
|
||||
# returns a hash of {value => set of elements} pairs. The block is
|
||||
# called once for each element of the set, passing the element as
|
||||
# parameter.
|
||||
#
|
||||
# e.g.:
|
||||
#
|
||||
# require 'set'
|
||||
# files = Set.new(Dir.glob("*.rb"))
|
||||
# hash = files.classify { |f| File.mtime(f).year }
|
||||
# p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>,
|
||||
# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
|
||||
# # 2002=>#<Set: {"f.rb"}>}
|
||||
def classify # :yields: o
|
||||
# Classifies the set by the return value of the given block and
|
||||
# returns a hash of {value => set of elements} pairs. The block is
|
||||
# called once for each element of the set, passing the element as
|
||||
# parameter.
|
||||
#
|
||||
# e.g.:
|
||||
#
|
||||
# require 'set'
|
||||
# files = Set.new(Dir.glob("*.rb"))
|
||||
# hash = files.classify { |f| File.mtime(f).year }
|
||||
# p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>,
|
||||
# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
|
||||
# # 2002=>#<Set: {"f.rb"}>}
|
||||
def classify # :yields: o
|
||||
block_given? or return enum_for(__method__)
|
||||
|
||||
h = {}
|
||||
|
@ -400,25 +400,25 @@ class Set
|
|||
}
|
||||
|
||||
h
|
||||
end
|
||||
end
|
||||
|
||||
# Divides the set into a set of subsets according to the commonality
|
||||
# defined by the given block.
|
||||
#
|
||||
# If the arity of the block is 2, elements o1 and o2 are in common
|
||||
# if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are
|
||||
# in common if block.call(o1) == block.call(o2).
|
||||
#
|
||||
# e.g.:
|
||||
#
|
||||
# require 'set'
|
||||
# numbers = Set[1, 3, 4, 6, 9, 10, 11]
|
||||
# set = numbers.divide { |i,j| (i - j).abs == 1 }
|
||||
# p set # => #<Set: {#<Set: {1}>,
|
||||
# # #<Set: {11, 9, 10}>,
|
||||
# # #<Set: {3, 4}>,
|
||||
# # #<Set: {6}>}>
|
||||
def divide(&func)
|
||||
# Divides the set into a set of subsets according to the commonality
|
||||
# defined by the given block.
|
||||
#
|
||||
# If the arity of the block is 2, elements o1 and o2 are in common
|
||||
# if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are
|
||||
# in common if block.call(o1) == block.call(o2).
|
||||
#
|
||||
# e.g.:
|
||||
#
|
||||
# require 'set'
|
||||
# numbers = Set[1, 3, 4, 6, 9, 10, 11]
|
||||
# set = numbers.divide { |i,j| (i - j).abs == 1 }
|
||||
# p set # => #<Set: {#<Set: {1}>,
|
||||
# # #<Set: {11, 9, 10}>,
|
||||
# # #<Set: {3, 4}>,
|
||||
# # #<Set: {6}>}>
|
||||
def divide(&func)
|
||||
func or return enum_for(__method__)
|
||||
|
||||
if func.arity == 2
|
||||
|
@ -446,13 +446,13 @@ class Set
|
|||
else
|
||||
Set.new(classify(&func).values)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
InspectKey = :__inspect_key__ # :nodoc:
|
||||
InspectKey = :__inspect_key__ # :nodoc:
|
||||
|
||||
# Returns a string containing a human-readable representation of the
|
||||
# set. ("#<Set: {element1, element2, ...}>")
|
||||
def inspect
|
||||
# Returns a string containing a human-readable representation of the
|
||||
# set. ("#<Set: {element1, element2, ...}>")
|
||||
def inspect
|
||||
ids = (Thread.current[InspectKey] ||= [])
|
||||
|
||||
if ids.include?(object_id)
|
||||
|
@ -465,9 +465,9 @@ class Set
|
|||
ensure
|
||||
ids.pop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pretty_print(pp) # :nodoc:
|
||||
def pretty_print(pp) # :nodoc:
|
||||
pp.text sprintf('#<%s: {', self.class.name)
|
||||
pp.nest(1) {
|
||||
pp.seplist(self) { |o|
|
||||
|
@ -475,11 +475,11 @@ class Set
|
|||
}
|
||||
}
|
||||
pp.text "}>"
|
||||
end
|
||||
end
|
||||
|
||||
def pretty_print_cycle(pp) # :nodoc:
|
||||
def pretty_print_cycle(pp) # :nodoc:
|
||||
pp.text sprintf('#<%s: {%s}>', self.class.name, empty? ? '' : '...')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -1168,8 +1168,8 @@ class TC_Set < Test::Unit::TestCase
|
|||
set2 = Set["a", "b", set1]
|
||||
set1 = set1.add(set1.clone)
|
||||
|
||||
# assert_equal(set1, set2)
|
||||
# assert_equal(set2, set1)
|
||||
# assert_equal(set1, set2)
|
||||
# assert_equal(set2, set1)
|
||||
assert_equal(set2, set2.clone)
|
||||
assert_equal(set1.clone, set1)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Shell
|
|||
include Error
|
||||
extend Exception2MessageMapper
|
||||
|
||||
# @cascade = true
|
||||
# @cascade = true
|
||||
# debug: true -> normal debug
|
||||
# debug: 1 -> eval definition debug
|
||||
# debug: 2 -> detail inspect debug
|
||||
|
@ -41,7 +41,7 @@ class Shell
|
|||
|
||||
attr_accessor :cascade, :debug, :verbose
|
||||
|
||||
# alias cascade? cascade
|
||||
# alias cascade? cascade
|
||||
alias debug? debug
|
||||
alias verbose? verbose
|
||||
@verbose = true
|
||||
|
@ -286,7 +286,7 @@ class Shell
|
|||
yield mes if iterator?
|
||||
if _head
|
||||
_head = false
|
||||
# "shell" " + mes
|
||||
# "shell" " + mes
|
||||
prefix + mes
|
||||
else
|
||||
" "* prefix.size + mes
|
||||
|
|
|
@ -83,19 +83,19 @@ class Shell
|
|||
end
|
||||
end
|
||||
|
||||
# class Sort < Cat
|
||||
# def initialize(sh, *filenames)
|
||||
# super
|
||||
# end
|
||||
#
|
||||
# def each(rs = nil)
|
||||
# ary = []
|
||||
# super{|l| ary.push l}
|
||||
# for l in ary.sort!
|
||||
# yield l
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# class Sort < Cat
|
||||
# def initialize(sh, *filenames)
|
||||
# super
|
||||
# end
|
||||
#
|
||||
# def each(rs = nil)
|
||||
# ary = []
|
||||
# super{|l| ary.push l}
|
||||
# for l in ary.sort!
|
||||
# yield l
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
class AppendIO < BuiltInCommand
|
||||
def initialize(sh, io, filter)
|
||||
|
|
|
@ -19,7 +19,7 @@ require "shell/builtin-command"
|
|||
|
||||
class Shell
|
||||
class CommandProcessor
|
||||
# include Error
|
||||
# include Error
|
||||
|
||||
#
|
||||
# initialize of Shell and related classes.
|
||||
|
|
|
@ -157,19 +157,19 @@ class Shell
|
|||
@waiting_jobs.delete command
|
||||
else
|
||||
command = @waiting_jobs.shift
|
||||
# command.notify "job(%id) pre-start.", @shell.debug?
|
||||
# command.notify "job(%id) pre-start.", @shell.debug?
|
||||
|
||||
return unless command
|
||||
end
|
||||
@active_jobs.push command
|
||||
command.start
|
||||
# command.notify "job(%id) post-start.", @shell.debug?
|
||||
# command.notify "job(%id) post-start.", @shell.debug?
|
||||
|
||||
# start all jobs that input from the job
|
||||
for job in @waiting_jobs.dup
|
||||
start_job(job) if job.input == command
|
||||
end
|
||||
# command.notify "job(%id) post2-start.", @shell.debug?
|
||||
# command.notify "job(%id) post2-start.", @shell.debug?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -254,7 +254,7 @@ class Shell
|
|||
|
||||
pid = fork {
|
||||
Thread.list.each do |th|
|
||||
# th.kill unless [Thread.main, Thread.current].include?(th)
|
||||
# th.kill unless [Thread.main, Thread.current].include?(th)
|
||||
th.kill unless Thread.current == th
|
||||
end
|
||||
|
||||
|
@ -296,11 +296,11 @@ class Shell
|
|||
redo
|
||||
end
|
||||
|
||||
# command.notify "job(%id) pre-pre-finish.", @shell.debug?
|
||||
# command.notify "job(%id) pre-pre-finish.", @shell.debug?
|
||||
@job_monitor.synchronize do
|
||||
# command.notify "job(%id) pre-finish.", @shell.debug?
|
||||
# command.notify "job(%id) pre-finish.", @shell.debug?
|
||||
terminate_job(command)
|
||||
# command.notify "job(%id) pre-finish2.", @shell.debug?
|
||||
# command.notify "job(%id) pre-finish2.", @shell.debug?
|
||||
@job_condition.signal
|
||||
command.notify "job(%id) finish.", @shell.debug?
|
||||
end
|
||||
|
|
|
@ -1323,9 +1323,11 @@ module URI
|
|||
if rel.userinfo != oth.userinfo ||
|
||||
rel.host.to_s.downcase != oth.host.to_s.downcase ||
|
||||
rel.port != oth.port
|
||||
|
||||
if self.userinfo.nil? && self.host.nil?
|
||||
return self, self.dup
|
||||
end
|
||||
|
||||
rel.set_port(nil) if rel.port == oth.default_port
|
||||
return rel, rel
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue