* lib: revert r31635-r31638 and untabify with expand(1).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-05-19 00:07:25 +00:00
parent 1fae66fca2
commit d371e3583e
59 changed files with 1971 additions and 1967 deletions

View File

@ -1,3 +1,7 @@
Thu May 19 09:07:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib: revert r31635-r31638 and untabify with expand(1).
Thu May 19 07:47:26 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
* test/openssl/test_pkey_rsa.rb: Add tests for sign/verify.

View File

@ -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},

View File

@ -717,18 +717,18 @@ EOHELP
end
@last_file = file
end
end
end
trap("INT") { DEBUGGER__.interrupt }
@last_thread = Thread::main
@max_thread = 1
@thread_list = {Thread::main => 1}
@break_points = []
@display = []
@waiting = []
@stdout = STDOUT
trap("INT") { DEBUGGER__.interrupt }
@last_thread = Thread::main
@max_thread = 1
@thread_list = {Thread::main => 1}
@break_points = []
@display = []
@waiting = []
@stdout = STDOUT
class << DEBUGGER__
class << DEBUGGER__
def stdout
@stdout
end
@ -894,14 +894,14 @@ class << DEBUGGER__
end
end
end
end
end
stdout.printf "Debug.rb\n"
stdout.printf "Emacs support available.\n\n"
RubyVM::InstructionSequence.compile_option = {
stdout.printf "Debug.rb\n"
stdout.printf "Emacs support available.\n\n"
RubyVM::InstructionSequence.compile_option = {
trace_instruction: true
}
set_trace_func proc { |event, file, line, id, binding, klass, *rest|
}
set_trace_func proc { |event, file, line, id, binding, klass, *rest|
DEBUGGER__.context.trace_func event, file, line, id, binding, klass
}
}
end

View File

@ -72,7 +72,7 @@ module IRB
ensure
irb_at_exit
end
# print "\n"
# print "\n"
end
def IRB.irb_at_exit

View File

@ -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)

View File

@ -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}

View File

@ -2965,38 +2965,38 @@ 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%"\\]+)|\

View File

@ -760,5 +760,5 @@ module Net
end
end # class Telnet
end # module Net
end # module Net

View File

@ -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 @@ def prime?(value, generator = Prime::Generator23.new)
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 @@ def prime_division(value, generator= Prime::Generator23.new)
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 PseudoPrimeGenerator
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 EratosthenesGenerator < PseudoPrimeGenerator
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 TrialDivisionGenerator<PseudoPrimeGenerator
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 Generator23<PseudoPrimeGenerator
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 TrialDivision
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 EratosthenesSieve
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 @@ module OldCompatibility
yield succ
end
end
end
end
end

View File

@ -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

View File

@ -17,7 +17,7 @@ module RSS
class ImageItem < ImageItemBase
DublinCoreModel.install_dublin_core(self)
end
EOC
EOC
end
class ImageItemBase < Base

View File

@ -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 @@ module RSS
rv << value if /\\A\\s*\\z/ !~ value
end
rv.join("\n")
EOC
EOC
end
end
@ -264,7 +264,7 @@ module RSS
else
''
end
EOC
EOC
end
end
@ -295,7 +295,7 @@ module RSS
else
''
end
EOC
EOC
end
end
@ -310,7 +310,7 @@ module RSS
#{yield(name, elem_name)}
end
private :#{method_name}
EOC
EOC
end
def inherit_convert_attr_reader(*attrs)
@ -330,7 +330,7 @@ module RSS
nil
end
end
EOC
EOC
end
end
@ -351,7 +351,7 @@ module RSS
"\#{base}\#{value}"
end
end
EOC
EOC
end
end
@ -362,7 +362,7 @@ module RSS
def #{attr}
convert(@#{attr})
end
EOC
EOC
end
end
@ -448,7 +448,7 @@ module RSS
end
end
EOC
EOC
end
def integer_writer(name, disp_name=name)
@ -468,7 +468,7 @@ module RSS
end
end
end
EOC
EOC
end
def positive_integer_writer(name, disp_name=name)
@ -490,7 +490,7 @@ module RSS
end
end
end
EOC
EOC
end
def boolean_writer(name, disp_name=name)
@ -510,7 +510,7 @@ module RSS
end
end
end
EOC
EOC
end
def text_type_writer(name, disp_name=name)
@ -522,7 +522,7 @@ module RSS
end
@#{name} = new_value
end
EOC
EOC
end
def content_writer(name, disp_name=name)
@ -536,7 +536,7 @@ module RSS
@#{name}.content = new_value
end
end
EOC
EOC
end
def yes_clean_other_writer(name, disp_name=name)
@ -603,7 +603,7 @@ module RSS
end
end
alias_method(:set_#{accessor_name}, :#{accessor_name}=)
EOC
EOC
end
end

View File

@ -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

View File

@ -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 @@ def ==(other)
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 @@ def classify # :yields: o
}
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 @@ def divide(&func)
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 @@ def inspect
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 @@ def pretty_print(pp) # :nodoc:
}
}
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)

View File

@ -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

View File

@ -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)

View File

@ -19,7 +19,7 @@ require "shell/builtin-command"
class Shell
class CommandProcessor
# include Error
# include Error
#
# initialize of Shell and related classes.

View File

@ -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