[macruby-changes] [5078] MacRuby/trunk/lib
source_changes at macosforge.org
source_changes at macosforge.org
Thu Dec 23 09:09:44 PST 2010
Revision: 5078
http://trac.macosforge.org/projects/ruby/changeset/5078
Author: watson1978 at gmail.com
Date: 2010-12-23 09:09:39 -0800 (Thu, 23 Dec 2010)
Log Message:
-----------
stdlib: Deleted the whitespece of end of line, and fixed the petty typo.
Modified Paths:
--------------
MacRuby/trunk/lib/base64.rb
MacRuby/trunk/lib/benchmark.rb
MacRuby/trunk/lib/debug.rb
MacRuby/trunk/lib/delegate.rb
MacRuby/trunk/lib/objc_ext/ns_rect.rb
MacRuby/trunk/lib/objc_ext/ns_user_defaults.rb
MacRuby/trunk/lib/ostruct.rb
MacRuby/trunk/lib/racc/parser.rb
MacRuby/trunk/lib/rbconfig/datadir.rb
MacRuby/trunk/lib/rdoc.rb
MacRuby/trunk/lib/scanf.rb
MacRuby/trunk/lib/stringio.rb
MacRuby/trunk/lib/strscan.rb
MacRuby/trunk/lib/webrick/cgi.rb
MacRuby/trunk/lib/webrick/config.rb
MacRuby/trunk/lib/webrick/httpauth/authenticator.rb
MacRuby/trunk/lib/webrick/httpauth/digestauth.rb
MacRuby/trunk/lib/webrick/httpauth/userdb.rb
MacRuby/trunk/lib/webrick/httpproxy.rb
MacRuby/trunk/lib/webrick/httprequest.rb
MacRuby/trunk/lib/webrick/httpresponse.rb
MacRuby/trunk/lib/webrick/httpserver.rb
MacRuby/trunk/lib/webrick/httpservlet/cgihandler.rb
MacRuby/trunk/lib/webrick/httpservlet/erbhandler.rb
MacRuby/trunk/lib/webrick/httpservlet/filehandler.rb
MacRuby/trunk/lib/webrick/httpservlet/prochandler.rb
MacRuby/trunk/lib/webrick/httpstatus.rb
MacRuby/trunk/lib/webrick/httputils.rb
MacRuby/trunk/lib/webrick/log.rb
MacRuby/trunk/lib/webrick/server.rb
MacRuby/trunk/lib/webrick/ssl.rb
MacRuby/trunk/lib/webrick/utils.rb
MacRuby/trunk/lib/yaml/baseemitter.rb
MacRuby/trunk/lib/yaml/constants.rb
MacRuby/trunk/lib/yaml/dbm.rb
MacRuby/trunk/lib/yaml/encoding.rb
MacRuby/trunk/lib/yaml/error.rb
MacRuby/trunk/lib/yaml/rubytypes.rb
MacRuby/trunk/lib/yaml/stream.rb
MacRuby/trunk/lib/yaml/stringio.rb
MacRuby/trunk/lib/yaml/tag.rb
MacRuby/trunk/lib/yaml/types.rb
MacRuby/trunk/lib/yaml.rb
Modified: MacRuby/trunk/lib/base64.rb
===================================================================
--- MacRuby/trunk/lib/base64.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/base64.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,5 +1,5 @@
#
-# = base64.rb: methods for base64-encoding and -decoding stings
+# = base64.rb: methods for base64-encoding and -decoding strings
#
# The Base64 module provides for the encoding (#encode64, #strict_encode64,
@@ -8,12 +8,12 @@
#
# == Example
#
-# A simple encoding and decoding.
-#
+# A simple encoding and decoding.
+#
# require "base64"
#
# enc = Base64.encode64('Send reinforcements')
-# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
+# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
# plain = Base64.decode64(enc)
# # -> "Send reinforcements"
#
Modified: MacRuby/trunk/lib/benchmark.rb
===================================================================
--- MacRuby/trunk/lib/benchmark.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/benchmark.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,13 +1,13 @@
=begin
#
-# benchmark.rb - a performance benchmarking library
-#
+# benchmark.rb - a performance benchmarking library
+#
# $Id: benchmark.rb 15426 2008-02-10 15:29:00Z naruse $
-#
-# Created by Gotoken (gotoken at notwork.org).
#
+# Created by Gotoken (gotoken at notwork.org).
+#
# Documentation by Gotoken (original RD), Lyle Johnson (RDoc conversion), and
-# Gavin Sinclair (editing).
+# Gavin Sinclair (editing).
#
=end
@@ -26,15 +26,15 @@
# require 'benchmark'
#
# puts Benchmark.measure { "a"*1_000_000 }
-#
+#
# On my machine (FreeBSD 3.2 on P5, 100MHz) this generates:
-#
+#
# 1.166667 0.050000 1.216667 ( 0.571355)
-#
+#
# This report shows the user CPU time, system CPU time, the sum of
# the user and system CPU times, and the elapsed real time. The unit
# of time is seconds.
-#
+#
# * Do some experiments sequentially using the #bm method:
#
# require 'benchmark'
@@ -45,7 +45,7 @@
# x.report { n.times do ; a = "1"; end }
# x.report { 1.upto(n) do ; a = "1"; end }
# end
-#
+#
# The result:
#
# user system total real
@@ -63,15 +63,15 @@
# x.report("times:") { n.times do ; a = "1"; end }
# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# end
-#
+#
# The result:
-#
+#
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
-#
#
+#
# * The times for some benchmarks depend on the order in which items
# are run. These differences are due to the cost of memory
# allocation and garbage collection. To avoid these discrepancies,
@@ -79,21 +79,21 @@
# sort an array of floats:
#
# require 'benchmark'
-#
+#
# array = (1..1000000).map { rand }
-#
+#
# Benchmark.bmbm do |x|
# x.report("sort!") { array.dup.sort! }
# x.report("sort") { array.dup.sort }
# end
-#
+#
# The result:
-#
+#
# Rehearsal -----------------------------------------
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
# sort 13.048000 0.020000 13.068000 ( 13.857000)
# ------------------------------- total: 25.006000sec
-#
+#
# user system total real
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
# sort 12.007000 0.000000 12.007000 ( 12.791000)
@@ -111,9 +111,9 @@
# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# [tf+tt+tu, (tf+tt+tu)/3]
# end
-#
+#
# The result:
-#
+#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
@@ -144,10 +144,10 @@
# suitable for nearly all benchmarking requirements. See the examples in
# Benchmark, and the #bm and #bmbm methods.
#
- # Example:
+ # Example:
#
# require 'benchmark'
- # include Benchmark # we need the CAPTION and FMTSTR constants
+ # include Benchmark # we need the CAPTION and FMTSTR constants
#
# n = 50000
# Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
@@ -156,16 +156,16 @@
# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# [tf+tt+tu, (tf+tt+tu)/3]
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# upto: 1.533333 0.000000 1.533333 ( 0.722166)
# >total: 4.000000 0.033333 4.033333 ( 1.889282)
# >avg: 1.333333 0.011111 1.344444 ( 0.629761)
- #
+ #
def benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) # :yield: report
sync = STDOUT.sync
@@ -176,7 +176,7 @@
print caption
results = yield(Report.new(label_width, fmtstr))
Array === results and results.grep(Tms).each {|t|
- print((labels.shift || t.label || "").ljust(label_width),
+ print((labels.shift || t.label || "").ljust(label_width),
t.format(fmtstr))
}
STDOUT.sync = sync
@@ -185,7 +185,7 @@
# A simple interface to the #benchmark method, #bm is generates sequential reports
# with labels. The parameters have the same meaning as for #benchmark.
- #
+ #
# require 'benchmark'
#
# n = 50000
@@ -194,9 +194,9 @@
# x.report("times:") { n.times do ; a = "1"; end }
# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
@@ -223,21 +223,21 @@
# calculate the required label width.
#
# require 'benchmark'
- #
+ #
# array = (1..1000000).map { rand }
- #
+ #
# Benchmark.bmbm do |x|
# x.report("sort!") { array.dup.sort! }
# x.report("sort") { array.dup.sort }
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# Rehearsal -----------------------------------------
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
# sort 13.048000 0.020000 13.068000 ( 13.857000)
# ------------------------------- total: 25.006000sec
- #
+ #
# user system total real
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
# sort 12.007000 0.000000 12.007000 ( 12.791000)
@@ -266,7 +266,7 @@
ets = sum.format("total: %tsec")
printf("%s %s\n\n",
"-"*(width+CAPTION.length-ets.length-1), ets)
-
+
# take
print ' '*width, CAPTION
list = []
@@ -284,7 +284,7 @@
ary
end
- #
+ #
# Returns the time used to execute the given block as a
# Benchmark::Tms object.
#
@@ -292,10 +292,10 @@
t0, r0 = Benchmark.times, Time.now
yield
t1, r1 = Benchmark.times, Time.now
- Benchmark::Tms.new(t1.utime - t0.utime,
- t1.stime - t0.stime,
- t1.cutime - t0.cutime,
- t1.cstime - t0.cstime,
+ Benchmark::Tms.new(t1.utime - t0.utime,
+ t1.stime - t0.stime,
+ t1.cutime - t0.cutime,
+ t1.cstime - t0.cstime,
r1.to_f - r0.to_f,
label)
end
@@ -322,8 +322,8 @@
# Usually, one doesn't call this method directly, as new
# Job objects are created by the #bmbm method.
# _width_ is a initial value for the label offset used in formatting;
- # the #bmbm method passes its _width_ argument to this constructor.
- #
+ # the #bmbm method passes its _width_ argument to this constructor.
+ #
def initialize(width)
@width = width
@list = []
@@ -342,11 +342,11 @@
end
alias report item
-
+
# An array of 2-element arrays, consisting of label and block pairs.
attr_reader :list
-
- # Length of the widest label in the #list, plus one.
+
+ # Length of the widest label in the #list, plus one.
attr_reader :width
end
@@ -362,10 +362,10 @@
#
# Returns an initialized Report instance.
# Usually, one doesn't call this method directly, as new
- # Report objects are created by the #benchmark and #bm methods.
- # _width_ and _fmtstr_ are the label offset and
- # format string used by Tms#format.
- #
+ # Report objects are created by the #benchmark and #bm methods.
+ # _width_ and _fmtstr_ are the label offset and
+ # format string used by Tms#format.
+ #
def initialize(width = 0, fmtstr = nil)
@width, @fmtstr = width, fmtstr
end
@@ -397,50 +397,50 @@
# User CPU time
attr_reader :utime
-
+
# System CPU time
attr_reader :stime
-
+
# User CPU time of children
attr_reader :cutime
-
+
# System CPU time of children
attr_reader :cstime
-
+
# Elapsed real time
attr_reader :real
-
- # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
+
+ # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
attr_reader :total
-
+
# Label
attr_reader :label
#
# Returns an initialized Tms object which has
- # _u_ as the user CPU time, _s_ as the system CPU time,
+ # _u_ as the user CPU time, _s_ as the system CPU time,
# _cu_ as the children's user CPU time, _cs_ as the children's
# system CPU time, _real_ as the elapsed real time and _l_
- # as the label.
- #
+ # as the label.
+ #
def initialize(u = 0.0, s = 0.0, cu = 0.0, cs = 0.0, real = 0.0, l = nil)
@utime, @stime, @cutime, @cstime, @real, @label = u, s, cu, cs, real, l
@total = @utime + @stime + @cutime + @cstime
end
- #
+ #
# Returns a new Tms object whose times are the sum of the times for this
# Tms object, plus the time required to execute the code block (_blk_).
- #
+ #
def add(&blk) # :yield:
- self + Benchmark::measure(&blk)
+ self + Benchmark::measure(&blk)
end
- #
+ #
# An in-place version of #add.
- #
+ #
def add!(&blk)
- t = Benchmark::measure(&blk)
+ t = Benchmark::measure(&blk)
@utime = utime + t.utime
@stime = stime + t.stime
@cutime = cutime + t.cutime
@@ -449,32 +449,32 @@
self
end
- #
+ #
# Returns a new Tms object obtained by memberwise summation
# of the individual times for this Tms object with those of the other
# Tms object.
- # This method and #/() are useful for taking statistics.
- #
+ # This method and #/() are useful for taking statistics.
+ #
def +(other); memberwise(:+, other) end
-
+
#
# Returns a new Tms object obtained by memberwise subtraction
# of the individual times for the other Tms object from those of this
# Tms object.
#
def -(other); memberwise(:-, other) end
-
+
#
# Returns a new Tms object obtained by memberwise multiplication
# of the individual times for this Tms object by _x_.
#
def *(x); memberwise(:*, x) end
- #
+ #
# Returns a new Tms object obtained by memberwise division
# of the individual times for this Tms object by _x_.
- # This method and #+() are useful for taking statistics.
- #
+ # This method and #+() are useful for taking statistics.
+ #
def /(x); memberwise(:/, x) end
#
@@ -485,15 +485,15 @@
#
# <tt>%u</tt>:: Replaced by the user CPU time, as reported by Tms#utime.
# <tt>%y</tt>:: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
- # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
+ # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
# <tt>%Y</tt>:: Replaced by the children's system CPU time, as reported by Tms#cstime
# <tt>%t</tt>:: Replaced by the total CPU time, as reported by Tms#total
# <tt>%r</tt>:: Replaced by the elapsed real time, as reported by Tms#real
# <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
- #
+ #
# If _fmtstr_ is not given, FMTSTR is used as default value, detailing the
# user, system and real elapsed time.
- #
+ #
def format(arg0 = nil, *args)
fmtstr = (arg0 || FMTSTR).dup
fmtstr.gsub!(/(%[-+\.\d]*)n/){"#{$1}s" % label}
@@ -506,19 +506,19 @@
arg0 ? Kernel::format(fmtstr, *args) : fmtstr
end
- #
+ #
# Same as #format.
- #
+ #
def to_s
format
end
- #
+ #
# Returns a new 6-element array, consisting of the
# label, user CPU time, system CPU time, children's
# user CPU time, children's system CPU time and elapsed
# real time.
- #
+ #
def to_a
[@label, @utime, @stime, @cutime, @cstime, @real]
end
@@ -547,7 +547,7 @@
# The default caption string (heading above the output times).
CAPTION = Benchmark::Tms::CAPTION
- # The default format string used to display times. See also Benchmark::Tms#format.
+ # The default format string used to display times. See also Benchmark::Tms#format.
FMTSTR = Benchmark::Tms::FMTSTR
end
Modified: MacRuby/trunk/lib/debug.rb
===================================================================
--- MacRuby/trunk/lib/debug.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/debug.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -220,7 +220,7 @@
def debug_command(file, line, id, binding)
MUTEX.lock
unless defined?($debugger_restart) and $debugger_restart
- callcc{|c| $debugger_restart = c}
+ callcc{|c| $debugger_restart = c}
end
set_last_thread(Thread.current)
frame_pos = 0
@@ -299,7 +299,7 @@
stdout.print "Breakpoints:\n"
break_points.each do |b|
if b[0] and b[1] == 0
- stdout.printf " %d %s:%s\n", n, b[2], b[3]
+ stdout.printf " %d %s:%s\n", n, b[2], b[3]
end
n += 1
end
@@ -711,7 +711,7 @@
end
@frames.shift
- when 'raise'
+ when 'raise'
excn_handle(file, line, id, binding)
end
@@ -878,7 +878,7 @@
@stdout.print "Already stopped.\n"
else
thread_list(@thread_list[th])
- context(th).suspend
+ context(th).suspend
end
when /^resume\s+(\d+)/
Modified: MacRuby/trunk/lib/delegate.rb
===================================================================
--- MacRuby/trunk/lib/delegate.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/delegate.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -37,16 +37,16 @@
# def initialize
# @source = SimpleDelegator.new([])
# end
-#
+#
# def stats( records )
# @source.__setobj__(records)
-#
+#
# "Elements: #{@source.size}\n" +
# " Non-Nil: #{@source.compact.size}\n" +
# " Unique: #{@source.uniq.size}\n"
# end
# end
-#
+#
# s = Stats.new
# puts s.stats(%w{James Edward Gray II})
# puts
@@ -57,7 +57,7 @@
# Elements: 4
# Non-Nil: 4
# Unique: 4
-#
+#
# Elements: 8
# Non-Nil: 7
# Unique: 6
@@ -72,19 +72,19 @@
#
# class Tempfile < DelegateClass(File)
# # constant and class member data initialization...
-#
+#
# def initialize(basename, tmpdir=Dir::tmpdir)
# # build up file path/name in var tmpname...
-#
+#
# @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
-#
+#
# # ...
-#
+#
# super(@tmpfile)
-#
+#
# # below this point, all methods of File are supported...
# end
-#
+#
# # ...
# end
#
@@ -97,15 +97,15 @@
# super # pass obj to Delegator constructor, required
# @delegate_sd_obj = obj # store obj for future use
# end
-#
+#
# def __getobj__
# @delegate_sd_obj # return object we are delegating to, required
# end
-#
+#
# def __setobj__(obj)
# @delegate_sd_obj = obj # change delegation object, a feature we're providing
# end
-#
+#
# # ...
# end
@@ -142,18 +142,18 @@
end
end
- #
- # Checks for a method provided by this the delegate object by fowarding the
+ #
+ # Checks for a method provided by this the delegate object by fowarding the
# call through \_\_getobj\_\_.
- #
+ #
def respond_to?(m, include_private = false)
return true if super
return self.__getobj__.respond_to?(m, include_private)
end
- #
+ #
# Returns true if two objects are considered same.
- #
+ #
def ==(obj)
return true if obj.equal?(self)
self.__getobj__ == obj
Modified: MacRuby/trunk/lib/objc_ext/ns_rect.rb
===================================================================
--- MacRuby/trunk/lib/objc_ext/ns_rect.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/objc_ext/ns_rect.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -5,44 +5,44 @@
def x
origin.x
end
-
+
# Assigns the `x' coordinate on the rects origin instance.
def x=(x)
origin.x = coerce_float(x)
end
-
+
# Returns the `y' coordinate of the rects origin instance.
def y
origin.y
end
-
+
# Assigns the `y' coordinate on the rects origin instance.
def y=(y)
origin.y = coerce_float(y)
end
-
+
# Returns the `height' of the rects size instance.
def height
size.height
end
-
+
# Sets the `height' on the rects size instance.
def height=(height)
size.height = coerce_float(height)
end
-
+
# Returns the `width' of the rects size instance.
def width
size.width
end
-
+
# Sets the `width' on the rects size instance.
def width=(width)
size.width = coerce_float(width)
end
-
+
private
-
+
# Needed because atm NSCFNumber to Float conversion does not happen yet.
# In other words, Numeric should be build upon NSCFNumber.
def coerce_float(value)
@@ -52,4 +52,4 @@
end
end
-NSRect.send(:include, MacRuby::ObjcExt::NSRect)
\ No newline at end of file
+NSRect.send(:include, MacRuby::ObjcExt::NSRect)
Modified: MacRuby/trunk/lib/objc_ext/ns_user_defaults.rb
===================================================================
--- MacRuby/trunk/lib/objc_ext/ns_user_defaults.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/objc_ext/ns_user_defaults.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -4,11 +4,11 @@
def [](key)
valueForKey(key)
end
-
+
def []=(key, value)
setValue(value, forKey: key)
end
-
+
def delete(key)
removeObjectForKey(key)
end
@@ -16,4 +16,4 @@
end
end
-NSUserDefaults.send(:include, MacRuby::ObjcExt::NSUserDefaults)
\ No newline at end of file
+NSUserDefaults.send(:include, MacRuby::ObjcExt::NSUserDefaults)
Modified: MacRuby/trunk/lib/ostruct.rb
===================================================================
--- MacRuby/trunk/lib/ostruct.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/ostruct.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -12,13 +12,13 @@
# OpenStruct allows you to create data objects and set arbitrary attributes.
# For example:
#
-# require 'ostruct'
+# require 'ostruct'
#
# record = OpenStruct.new
# record.name = "John Smith"
# record.age = 70
# record.pension = 300
-#
+#
# puts record.name # -> "John Smith"
# puts record.address # -> nil
#
@@ -41,7 +41,7 @@
#
# p data # -> <OpenStruct country="Australia" population=20000000>
#
- # By default, the resulting OpenStruct object will have no attributes.
+ # By default, the resulting OpenStruct object will have no attributes.
#
def initialize(hash=nil)
@table = {}
@@ -53,7 +53,7 @@
end
end
- # Duplicate an OpenStruct object members.
+ # Duplicate an OpenStruct object members.
def initialize_copy(orig)
super
@table = @table.dup
Modified: MacRuby/trunk/lib/racc/parser.rb
===================================================================
--- MacRuby/trunk/lib/racc/parser.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/racc/parser.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -388,7 +388,7 @@
toks.each {|t| out.print ' ', racc_token2str(t) }
end
out.puts " --> #{racc_token2str(sim)}"
-
+
racc_print_stacks tstack, vstack
@racc_debug_out.puts
end
Modified: MacRuby/trunk/lib/rbconfig/datadir.rb
===================================================================
--- MacRuby/trunk/lib/rbconfig/datadir.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/rbconfig/datadir.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -10,7 +10,7 @@
# Only define datadir if it doesn't already exist.
unless Config.respond_to?(:datadir)
-
+
# Return the path to the data directory associated with the given
# package name. Normally this is just
# "#{Config::CONFIG['datadir']}/#{package_name}", but may be
Modified: MacRuby/trunk/lib/rdoc.rb
===================================================================
--- MacRuby/trunk/lib/rdoc.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/rdoc.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -69,7 +69,7 @@
# always will override those in +RDOCOPT+.
#
# Run
-#
+#
# % rdoc --help
#
# for full details on rdoc's options.
@@ -96,7 +96,7 @@
#
# =begin rdoc
# Documentation to be processed by RDoc.
-#
+#
# ...
# =end
#
@@ -112,7 +112,7 @@
# # FIXME: fails if the birthday falls on February 29th
# #++
# # The DOB is returned as a Time object.
-#
+#
# def get_dob(person)
# # ...
# end
@@ -138,7 +138,7 @@
#
# def fred # :yields: index, position
# # ...
-#
+#
# yield line, address
#
# which will get documented as
@@ -251,12 +251,12 @@
# module also will be omitted. By default, though, modules and
# classes within that class of module _will_ be documented. This is
# turned off by adding the +all+ modifier.
-#
+#
# module MyModule # :nodoc:
# class Input
# end
# end
-#
+#
# module OtherModule # :nodoc: all
# class Output
# end
@@ -290,7 +290,7 @@
# comment block may have one or more lines before the :section: directive.
# These will be removed, and any identical lines at the end of the block are
# also removed. This allows you to add visual cues such as:
-#
+#
# # ----------------------------------------
# # :section: My Section
# # This is the section that I wrote.
Modified: MacRuby/trunk/lib/scanf.rb
===================================================================
--- MacRuby/trunk/lib/scanf.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/scanf.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -63,7 +63,7 @@
conversions to the block every time the format string is matched
(including partial matches, but not including complete failures). The
actual return value of scanf when called with a block is an array
-containing the results of all the executions of the block.
+containing the results of all the executions of the block.
str = "123 abc 456 def 789 ghi"
str.scanf("%d%s") { |num,str| [ num * 2, str.upcase ] }
@@ -100,7 +100,7 @@
[u]
Same as d.
-[i]
+[i]
Matches an optionally signed integer. The integer is read in base
16 if it begins with `0x' or `0X', in base 8 if it begins with `0',
and in base 10 other- wise. Only characters that correspond to the
@@ -280,7 +280,7 @@
Thanks to Hal Fulton for hosting the Codefest.
-Thanks to Matz for suggestions about the class design.
+Thanks to Matz for suggestions about the class design.
Thanks to Gavin Sinclair for some feedback on the documentation.
@@ -332,7 +332,7 @@
@spec_string = str
h = '[A-Fa-f0-9]'
- @re_string, @handler =
+ @re_string, @handler =
case @spec_string
# %[[:...:]]
@@ -482,7 +482,7 @@
return width_left || cc_no_width
end
-
+
end
class FormatString
@@ -672,10 +672,10 @@
if b
block_scanf(fstr,&b)
else
- fs =
+ fs =
if fstr.is_a? Scanf::FormatString
- fstr
- else
+ fstr
+ else
Scanf::FormatString.new(fstr)
end
fs.match(self)
Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/stringio.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,31 +1,31 @@
# MacRuby implementation of stringio.
#
# This file is covered by the Ruby license. See COPYING for more details.
-#
+#
# Copyright (C) 2009-2010, Apple Inc. All rights reserved.
class StringIO
attr_reader :string, :pos
-
+
# strio.lineno -> integer
#
# Returns the current line number in *strio*. The stringio must be
# opened for reading. +lineno+ counts the number of times +gets+ is
# called, rather than the number of newlines encountered. The two
# values will differ if +gets+ is called with a separator other than
- # newline. See also the <code>$.</code> variable.
+ # newline. See also the <code>$.</code> variable.
#
#
# strio.lineno = integer -> integer
#
# Manually sets the current line number to the given value.
- # <code>$.</code> is updated only on the next read.
+ # <code>$.</code> is updated only on the next read.
#
attr_accessor :lineno
-
- include Enumerable
-
+
+ include Enumerable
+
# StringIO.open(string=""[, mode]) {|strio| ...}
#
# Equivalent to StringIO.new except that when it is called with a block, it
@@ -34,7 +34,7 @@
#
def self.open(*args)
obj = new(*args)
-
+
if block_given?
begin
yield obj
@@ -53,35 +53,35 @@
# Creates new StringIO instance from with _string_ and _mode_.
#
def initialize(string = String.new, mode = nil)
- @string = string.to_str
+ @string = string.to_str
@pos = 0
@lineno = 0
define_mode(mode)
-
- raise Errno::EACCES if (@writable && string.frozen?)
+
+ raise Errno::EACCES if (@writable && string.frozen?)
self
end
-
+
def initialize_copy(from)
from = from.to_strio
self.taint if from.tainted?
-
+
@string = from.instance_variable_get(:@string).dup
# mode
@append = from.instance_variable_get(:@append)
@readable = from.instance_variable_get(:@readable)
@writable = from.instance_variable_get(:@writable)
-
+
@pos = from.instance_variable_get(:@pos)
@lineno = from.instance_variable_get(:@lineno)
-
+
self
end
-
+
# strio.reopen(other_StrIO) -> strio
# strio.reopen(string, mode) -> strio
#
- # Reinitializes *strio* with the given <i>other_StrIO</i> or _string_
+ # Reinitializes *strio* with the given <i>other_StrIO</i> or _string_
# and _mode_ (see StringIO#new).
#
def reopen(str=nil, mode=nil)
@@ -90,16 +90,16 @@
elsif !str.kind_of?(String) && mode == nil
self.taint if str.tainted?
raise TypeError unless str.respond_to?(:to_strio)
- @string = str.to_strio.string
+ @string = str.to_strio.string
else
raise TypeError unless str.respond_to?(:to_str)
- @string = str.to_str
+ @string = str.to_str
end
-
+
define_mode(mode)
@pos = 0
@lineno = 0
-
+
self
end
@@ -111,8 +111,8 @@
@string = str.to_str
@pos = 0
@lineno = 0
- end
-
+ end
+
# strio.rewind -> 0
#
# Positions *strio* to the beginning of input, resetting
@@ -122,7 +122,7 @@
@pos = 0
@lineno = 0
end
-
+
# strio.read([length [, buffer]]) -> string, buffer, or nil
#
# See IO#read.
@@ -130,8 +130,8 @@
def read(length = nil, buffer = String.new)
raise IOError, "not opened for reading" unless @readable
raise TypeError unless buffer.respond_to?(:to_str)
- buffer = buffer.to_str
-
+ buffer = buffer.to_str
+
if length == 0
buffer.replace("")
elsif length == nil
@@ -144,15 +144,15 @@
return nil
end
raise TypeError unless length.respond_to?(:to_int)
- length = length.to_int
+ length = length.to_int
raise ArgumentError if length < 0
buffer.replace(string[pos, length])
@pos += buffer.length
end
-
+
buffer
end
-
+
# strio.sysread(integer[, outbuf]) -> string
#
# Similar to #read, but raises +EOFError+ at end of string instead of
@@ -161,9 +161,9 @@
val = read(length, buffer)
( buffer.clear && raise(IO::EOFError, "end of file reached")) if val == nil
val
- end
+ end
alias_method :readpartial, :sysread
-
+
# strio.readbyte -> fixnum
#
# See IO#readbyte.
@@ -172,17 +172,17 @@
raise(IO::EOFError, "end of file reached") if eof?
getbyte
end
-
+
# strio.seek(amount, whence=SEEK_SET) -> 0
#
# Seeks to a given offset _amount_ in the stream according to
# the value of _whence_ (see IO#seek).
#
- def seek(offset, whence = ::IO::SEEK_SET)
+ def seek(offset, whence = ::IO::SEEK_SET)
raise(IOError, "closed stream") if closed?
- raise TypeError unless offset.respond_to?(:to_int)
+ raise TypeError unless offset.respond_to?(:to_int)
offset = offset.to_int
-
+
case whence
when ::IO::SEEK_CUR
# Seeks to offset plus current position
@@ -195,13 +195,13 @@
else
raise Errno::EINVAL, "invalid whence"
end
-
+
raise Errno::EINVAL if (offset < 0)
- @pos = offset
-
+ @pos = offset
+
0
- end
-
+ end
+
# strio.pos = integer -> integer
#
# Seeks to the given position (in bytes) in *strio*.
@@ -210,25 +210,25 @@
raise Errno::EINVAL if pos < 0
@pos = pos
end
-
+
# strio.closed? -> true or false
#
# Returns +true+ if *strio* is completely closed, +false+ otherwise.
#
def closed?
!@readable && !@writable
- end
-
+ end
+
# strio.close -> nil
#
- # Closes strio. The *strio* is unavailable for any further data
+ # Closes strio. The *strio* is unavailable for any further data
# operations; an +IOError+ is raised if such an attempt is made.
#
def close
raise(IOError, "closed stream") if closed?
@readable = @writable = nil
end
-
+
# strio.closed_read? -> true or false
#
# Returns +true+ if *strio* is not readable, +false+ otherwise.
@@ -236,7 +236,7 @@
def closed_read?
!@readable
end
-
+
# strio.close_read -> nil
#
# Closes the read end of a StringIO. Will raise an +IOError+ if the
@@ -246,7 +246,7 @@
raise(IOError, "closing non-duplex IO for reading") unless @readable
@readable = nil
end
-
+
# strio.closed_write? -> true or false
#
# Returns +true+ if *strio* is not writable, +false+ otherwise.
@@ -254,47 +254,47 @@
def closed_write?
!@writable
end
-
+
# strio.eof -> true or false
# strio.eof? -> true or false
#
- # Returns true if *strio* is at end of file. The stringio must be
+ # Returns true if *strio* is at end of file. The stringio must be
# opened for reading or an +IOError+ will be raised.
#
def eof?
raise(IOError, "not opened for reading") unless @readable
pos >= @string.length
end
- alias_method :eof, :eof?
-
+ alias_method :eof, :eof?
+
def binmode
self
end
-
+
def fcntl
raise NotImplementedError, "StringIO#fcntl is not implemented"
end
-
+
def flush
self
end
-
+
def fsync
0
end
-
+
# strio.path -> nil
#
def path
nil
end
-
+
# strio.pid -> nil
- #
+ #
def pid
nil
end
-
+
# strio.sync -> true
#
# Returns +true+ always.
@@ -302,35 +302,35 @@
def sync
true
end
-
+
# strio.sync = boolean -> boolean
#
def sync=(value)
value
end
-
+
def tell
@pos
end
-
+
# strio.fileno -> nil
#
def fileno
nil
end
-
+
# strio.isatty -> nil
# strio.tty? -> nil
def isatty
false
end
alias_method :tty?, :isatty
-
+
def length
string.length
end
- alias_method :size, :length
-
+ alias_method :size, :length
+
# strio.getc -> string or nil
#
# Gets the next character from io.
@@ -341,30 +341,30 @@
@pos += 1
result
end
-
+
# strio.ungetc(string) -> nil
#
# Pushes back one character (passed as a parameter) onto *strio*
- # such that a subsequent buffered read will return it. Pushing back
+ # such that a subsequent buffered read will return it. Pushing back
# behind the beginning of the buffer string is not possible. Nothing
# will be done if such an attempt is made.
# In other case, there is no limitation for multiple pushbacks.
#
def ungetc(chars)
raise(IOError, "not opened for reading") unless @readable
- raise TypeError unless chars.respond_to?(:to_str)
+ raise TypeError unless chars.respond_to?(:to_str)
chars = chars.to_str
-
+
if pos == 0
- @string = chars + string
+ @string = chars + string
elsif pos > 0
@pos -= 1
- string[pos] = chars
- end
-
+ string[pos] = chars
+ end
+
nil
end
-
+
# strio.readchar -> fixnum
#
# See IO#readchar.
@@ -373,7 +373,7 @@
raise(IO::EOFError, "end of file reached") if eof?
getc
end
-
+
# strio.each_char {|char| block } -> strio
#
# See IO#each_char.
@@ -387,8 +387,8 @@
string.each_char
end
end
- alias_method :chars, :each_char
-
+ alias_method :chars, :each_char
+
# strio.getbyte -> fixnum or nil
#
# See IO#getbyte.
@@ -399,10 +399,10 @@
# instead we are dealing with chars
result = string.bytes.to_a[pos]
@pos += 1 unless eof?
- result
+ result
# getc
end
-
+
# strio.each_byte {|byte| block } -> strio
#
# See IO#each_byte.
@@ -417,9 +417,9 @@
string.each_byte
end
end
- alias_method :bytes, :each_byte
-
-
+ alias_method :bytes, :each_byte
+
+
# strio.each(sep=$/) {|line| block } -> strio
# strio.each(limit) {|line| block } -> strio
# strio.each(sep, limit) {|line| block } -> strio
@@ -440,10 +440,10 @@
else
to_enum(:each, sep)
end
- end
+ end
alias_method :each_line, :each
alias_method :lines, :each
-
+
# strio.gets(sep=$/) -> string or nil
# strio.gets(limit) -> string or nil
# strio.gets(sep, limit) -> string or nil
@@ -453,7 +453,7 @@
def gets(sep=$/)
$_ = getline(sep)
end
-
+
# strio.readline(sep=$/) -> string
# strio.readline(limit) -> string or nil
# strio.readline(sep, limit) -> string or nil
@@ -463,7 +463,7 @@
raise(IO::EOFError, 'end of file reached') if eof?
$_ = getline(sep)
end
-
+
# strio.readlines(sep=$/) -> array
# strio.readlines(limit) -> array
# strio.readlines(sep,limit) -> array
@@ -477,9 +477,9 @@
ary << line
end
ary
- end
-
-
+ end
+
+
# strio.write(string) -> integer
# strio.syswrite(string) -> integer
#
@@ -492,10 +492,10 @@
str = str.to_s
return 0 if str.empty?
- raise(IOError, "not opened for writing") unless @writable
-
+ raise(IOError, "not opened for writing") unless @writable
+
if @append || (pos >= string.length)
- # add padding in case it's needed
+ # add padding in case it's needed
str = str.rjust((pos + str.length) - string.length, "\000") if (pos > string.length)
enc1, enc2 = str.encoding, @string.encoding
if enc1 != enc2
@@ -508,11 +508,11 @@
@pos += str.length
@string.taint if str.tainted?
end
-
+
str.length
end
alias_method :syswrite, :write
-
+
# strio << obj -> strio
#
# See IO#<<.
@@ -522,12 +522,12 @@
self
end
-
+
def close_write
raise(IOError, "closing non-duplex IO for writing") unless @writable
@writable = nil
end
-
+
# strio.truncate(integer) -> 0
#
# Truncates the buffer string to at most _integer_ bytes. The *strio*
@@ -544,9 +544,9 @@
@string = string.ljust(length, "\000")
end
# send back what was passed, not our :to_int version
- len
+ len
end
-
+
# strio.puts(obj, ...) -> nil
#
# Writes the given objects to <em>strio</em> as with
@@ -575,7 +575,7 @@
begin
arg = arg.to_ary
recur = false
- arg.each do |a|
+ arg.each do |a|
if arg == a
recur = true
break
@@ -588,17 +588,17 @@
rescue
line = arg.to_s
end
- end
-
+ end
+
write(line)
write("\n") if !line.empty? && (line[-1] != ?\n)
end
end
-
+
nil
end
-
-
+
+
# strio.putc(obj) -> obj
#
# If <i>obj</i> is <code>Numeric</code>, write the character whose
@@ -611,7 +611,7 @@
if obj.is_a?(String)
char = obj[0]
else
- raise TypeError unless obj.respond_to?(:to_int)
+ raise TypeError unless obj.respond_to?(:to_int)
char = obj.to_int % 256
end
@@ -629,8 +629,8 @@
obj
end
-
-
+
+
# strio.print() => nil
# strio.print(obj, ...) => nil
#
@@ -654,8 +654,8 @@
args.map! { |x| (x == nil) ? "nil" : x }
write((args << $\).flatten.join)
nil
- end
-
+ end
+
# printf(strio, string [, obj ... ] ) => nil
#
# Equivalent to:
@@ -671,7 +671,7 @@
end
nil
- end
+ end
def external_encoding
@string ? @string.encoding : nil
@@ -682,23 +682,23 @@
end
protected
-
+
# meant to be overwritten by developers
def to_strio
self
end
-
+
def define_mode(mode=nil)
if mode == nil
# default modes
- string.frozen? ? set_mode_from_string("r") : set_mode_from_string("r+")
+ string.frozen? ? set_mode_from_string("r") : set_mode_from_string("r+")
elsif mode.is_a?(Integer)
set_mode_from_integer(mode)
else
mode = mode.to_str
set_mode_from_string(mode)
- end
- end
+ end
+ end
def set_mode_from_string(mode)
@readable = @writable = @append = false
@@ -728,10 +728,10 @@
@append = true
end
end
-
+
def set_mode_from_integer(mode)
@readable = @writable = @append = false
-
+
case mode & (IO::RDONLY | IO::WRONLY | IO::RDWR)
when IO::RDONLY
@readable = true
@@ -745,17 +745,17 @@
@writable = true
raise(Errno::EACCES) if string.frozen?
end
-
+
@append = true if (mode & IO::APPEND) != 0
raise(Errno::EACCES) if @append && string.frozen?
@string.replace("") if (mode & IO::TRUNC) != 0
end
-
+
def getline(sep = $/)
raise(IOError, "not opened for reading") unless @readable
return nil if eof?
sep = sep.to_str unless (sep == nil)
-
+
if sep == nil
line = string[pos .. -1]
@pos = string.size
@@ -765,7 +765,7 @@
line = string[pos .. stop]
while string[stop] == ?\n
stop += 1
- end
+ end
@pos = stop
else
line = string[pos .. -1]
@@ -784,6 +784,6 @@
@lineno += 1
line
- end
+ end
end
Modified: MacRuby/trunk/lib/strscan.rb
===================================================================
--- MacRuby/trunk/lib/strscan.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/strscan.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,7 +1,7 @@
# MacRuby implementation of strscan.
#
# This file is covered by the Ruby license. See COPYING for more details.
-#
+#
# Copyright (C) 2009-2010, Apple Inc. All rights reserved.
class ScanError < StandardError; end
@@ -11,14 +11,14 @@
#
# s = StringScanner.new('This is an example string')
# s.eos? # -> false
-#
+#
# p s.scan(/\w+/) # -> "This"
# p s.scan(/\w+/) # -> nil
# p s.scan(/\s+/) # -> " "
# p s.scan(/\s+/) # -> nil
# p s.scan(/\w+/) # -> "is"
# s.eos? # -> false
-#
+#
# p s.scan(/\s+/) # -> " "
# p s.scan(/\w+/) # -> "an"
# p s.scan(/\s+/) # -> " "
@@ -26,7 +26,7 @@
# p s.scan(/\s+/) # -> " "
# p s.scan(/\w+/) # -> "string"
# s.eos? # -> true
-#
+#
# p s.scan(/\s+/) # -> nil
# p s.scan(/\w+/) # -> nil
#
@@ -55,7 +55,7 @@
# the string without actually scanning. You can access the most recent match.
# You can modify the string being scanned, reset or terminate the scanner,
# find out or change the position of the scan pointer, skip ahead, and so on.
-#
+#
# === Advancing the Scan Pointer
#
# - #getch
@@ -86,7 +86,7 @@
# - #reset
# - #terminate
# - #pos=
-#
+#
# === Match Data
#
# - #matched
@@ -107,14 +107,14 @@
# There are aliases to several of the methods.
#
class StringScanner
-
+
# string <String>:: The string to scan
# pos <Integer>:: The position of the scan pointer. In the 'reset' position, this
# value is zero. In the 'terminated' position (i.e. the string is exhausted),
# this value is the length of the string.
- #
+ #
# In short, it's a 0-based index into the string.
- #
+ #
# s = StringScanner.new('test string')
# s.pos # -> 0
# s.scan_until /str/ # -> "test str"
@@ -125,13 +125,13 @@
# match <String>:: Matched string
#
attr_reader :string, :pos
-
+
# This method is defined for backward compatibility.
#
def self.must_C_version
self
- end
-
+ end
+
# StringScanner.new(string, dup = false)
#
# Creates a new StringScanner object to scan over the given +string+.
@@ -141,7 +141,7 @@
@string = string
@pos = 0
end
-
+
# Duplicates a StringScanner object when dup or clone are called on the
# object.
#
@@ -149,16 +149,16 @@
@string = orig.string
@pos = orig.pos
@match = orig.instance_variable_get("@match")
- end
-
+ end
+
# Reset the scan pointer (index 0) and clear matching data.
#
def reset
@previous_position = self.pos = 0
@match = nil
- self
+ self
end
-
+
# Set the scan pointer to the end of the string and clear matching data.
#
def terminate
@@ -166,7 +166,7 @@
self.pos = string.size
self
end
-
+
# Equivalent to #terminate.
# This method is obsolete; use #terminate instead.
#
@@ -174,15 +174,15 @@
warn "StringScanner#clear is obsolete; use #terminate instead" if $VERBOSE
terminate
end
-
+
# Changes the string being scanned to +str+ and resets the scanner.
# Returns +str+.
#
def string=(str)
reset
- @string = str
+ @string = str
end
-
+
# Appends +str+ to the string being scanned.
# This method does not affect scan pointer.
#
@@ -198,7 +198,7 @@
self
end
alias :<< :concat
-
+
# Modify the scan pointer.
#
# s = StringScanner.new('test string')
@@ -210,10 +210,10 @@
raise RangeError, "index out of range" if (n < 0 || (string && n > string.size))
@pos = n
end
-
+
alias :pointer :pos
alias :pointer= :pos=
-
+
# Scans one byte and returns it.
# This method is not multibyte sensitive.
# See also: #getch.
@@ -222,7 +222,7 @@
# s.get_byte # => "a"
# s.get_byte # => "b"
# s.get_byte # => nil
- #
+ #
# # encoding: EUC-JP
# s = StringScanner.new("\244\242")
# s.get_byte # => "244"
@@ -234,7 +234,7 @@
# TODO replace by a solution that will work with UTF-8
scan(/./mn)
end
-
+
# Equivalent to #get_byte.
# This method is obsolete; use #get_byte instead.
#
@@ -242,7 +242,7 @@
warn "StringScanner#getbyte is obsolete; use #get_byte instead" if $VERBOSE
get_byte
end
-
+
# Tries to match with +pattern+ at the current position. If there's a match,
# the scanner advances the "scan pointer" and returns the matched string.
# Otherwise, the scanner returns +nil+.
@@ -257,7 +257,7 @@
def scan(pattern)
_scan(pattern, true, true, true)
end
-
+
# Scans the string _until_ the +pattern+ is matched. Returns the substring up
# to and including the end of the match, advancing the scan pointer to that
# location. If there is no match, +nil+ is returned.
@@ -270,7 +270,7 @@
def scan_until(pattern)
_scan(pattern, true, true, false)
end
-
+
# Tests whether the given +pattern+ is matched from the current scan pointer.
# Returns the matched string if +return_string_p+ is true.
# Advances the scan pointer if +advance_pointer_p+ is true.
@@ -281,7 +281,7 @@
def scan_full(pattern, succptr, getstr)
_scan(pattern, succptr, getstr, true)
end
-
+
# Scans the string _until_ the +pattern+ is matched.
# Returns the matched string if +return_string_p+ is true, otherwise
# returns the number of bytes advanced.
@@ -291,7 +291,7 @@
def search_full(pattern, succptr, getstr)
_scan(pattern, succptr, getstr, false)
end
-
+
# Scans one character and returns it.
# This method is multibyte character sensitive.
#
@@ -303,7 +303,7 @@
def getch
scan(/./m)
end
-
+
# Returns +true+ if the scan pointer is at the end of the string.
#
# s = StringScanner.new('test string')
@@ -316,7 +316,7 @@
def eos?
self.pos >= self.string.size
end
-
+
# Equivalent to #eos?.
# This method is obsolete, use #eos? instead.
#
@@ -324,7 +324,7 @@
warn "StringScanner#empty? is obsolete; use #eos? instead" if $VERBOSE
eos?
end
-
+
# Returns true iff there is more data in the string. See #eos?.
# This method is obsolete; use #eos? instead.
#
@@ -335,20 +335,20 @@
def rest?
!eos?
end
-
+
# Returns the "rest" of the string (i.e. everything after the scan pointer).
# If there is no more data (eos? = true), it returns <tt>""</tt>.
#
def rest
string[pos..-1] || ""
end
-
+
# <tt>s.rest_size</tt> is equivalent to <tt>s.rest.size</tt>.
#
def rest_size
rest.size
end
-
+
# <tt>s.restsize</tt> is equivalent to <tt>s.rest_size</tt>.
# This method is obsolete; use #rest_size instead.
#
@@ -356,7 +356,7 @@
warn "StringScanner#restsize is obsolete; use #rest_size instead" if $VERBOSE
rest_size
end
-
+
# Returns a string that represents the StringScanner object, showing:
# - the current position
# - the size of the string
@@ -377,14 +377,14 @@
"#<StringScanner #{pos}/#{string.size} #{prev} @ #{rest.inspect}>"
else
"#<StringScanner #{pos}/#{string.size} @ #{rest.inspect}>"
- end
+ end
to_return.taint if self.string.tainted?
to_return
else
"#<StringScanner (uninitialized)>"
end
end
-
+
# Tests whether the given +pattern+ is matched from the current scan pointer.
# Returns the length of the match, or +nil+. The scan pointer is not advanced.
#
@@ -392,21 +392,21 @@
# p s.match?(/\w+/) # -> 4
# p s.match?(/\w+/) # -> 4
# p s.match?(/\s+/) # -> nil
- #
+ #
def match?(pattern)
_scan(pattern, false, false, true)
end
-
+
# Returns the last matched string.
- #
+ #
# s = StringScanner.new('test string')
# s.match?(/\w+/) # -> 4
# s.matched # -> "test"
- #
+ #
def matched
@match.to_s if matched?
end
-
+
# Returns +true+ iff the last match was successful.
#
# s = StringScanner.new('test string')
@@ -417,8 +417,8 @@
#
def matched?
!@match.nil?
- end
-
+ end
+
# Returns the last matched string.
#
# s = StringScanner.new('test string')
@@ -428,7 +428,7 @@
def matched_size
@match.to_s.size if matched?
end
-
+
# Equivalent to #matched_size.
# This method is obsolete; use #matched_size instead.
#
@@ -436,7 +436,7 @@
warn "StringScanner#matchedsize is obsolete; use #matched_size instead" if $VERBOSE
matched_size
end
-
+
# Attempts to skip over the given +pattern+ beginning with the scan pointer.
# If it matches, the scan pointer is advanced to the end of the match, and the
# length of the match is returned. Otherwise, +nil+ is returned.
@@ -453,7 +453,7 @@
def skip(pattern)
_scan(pattern, true, false, true)
end
-
+
# Advances the scan pointer until +pattern+ is matched and consumed. Returns
# the number of bytes advanced, or +nil+ if no match was found.
#
@@ -470,7 +470,7 @@
def skip_until(pattern)
_scan(pattern, true, false, false)
end
-
+
# This returns the value that #scan would return, without advancing the scan
# pointer. The match register is affected, though.
#
@@ -486,8 +486,8 @@
def check(pattern)
_scan(pattern, false, true, true)
end
-
+
# This returns the value that #scan_until would return, without advancing the
# scan pointer. The match register is affected, though.
#
@@ -501,7 +501,7 @@
def check_until(pattern)
_scan(pattern, false, true, false)
end
-
+
# Looks _ahead_ to see if the +pattern+ exists _anywhere_ in the string,
# without advancing the scan pointer. This predicates whether a #scan_until
# will return a value.
@@ -515,7 +515,7 @@
def exist?(pattern)
_scan(pattern, false, false, false)
end
-
+
# Extracts a string corresponding to <tt>string[pos,len]</tt>, without
# advancing the scan pointer.
#
@@ -528,7 +528,7 @@
raise ArgumentError if length < 0
length.zero? ? "" : string[pos, length]
end
-
+
# Equivalent to #peek.
# This method is obsolete; use #peek instead.
#
@@ -536,7 +536,7 @@
warn "StringScanner#peep is obsolete; use #peek instead" if $VERBOSE
peek(length)
end
-
+
# Set the scan pointer to the previous position. Only one previous position is
# remembered, and it changes with each scanning operation.
#
@@ -552,9 +552,9 @@
self.pos = @prev_pos
@prev_pos = nil
@match = nil
- self
+ self
end
-
+
# Returns +true+ iff the scan pointer is at the beginning of the line.
#
# s = StringScanner.new("test\ntest\n")
@@ -570,7 +570,7 @@
(pos == 0) || (string[pos-1] == "\n")
end
alias :beginning_of_line? :bol?
-
+
# Return the n-th subgroup in the most recent match.
#
# s = StringScanner.new("Fri Dec 12 1975 14:39")
@@ -586,19 +586,19 @@
raise TypeError, "Bad argument #{n.inspect}" unless n.respond_to? :to_int
@match.nil? ? nil : @match[n]
end
-
+
# Return the <i><b>pre</b>-match</i> (in the regular expression sense) of the last scan.
#
# s = StringScanner.new('test string')
# s.scan(/\w+/) # -> "test"
# s.scan(/\s+/) # -> " "
# s.pre_match # -> "test"
- # s.post_match # -> "string"
+ # s.post_match # -> "string"
#
def pre_match
string[0...(pos - @match.to_s.size)] if matched?
end
-
+
# Return the <i><b>post</b>-match</i> (in the regular expression sense) of the last scan.
#
# s = StringScanner.new('test string')
@@ -610,35 +610,35 @@
def post_match
@match.post_match if matched?
end
-
+
private
-
+
def _scan(pattern, succptr, getstr, headonly)
raise TypeError, "bad pattern argument: #{pattern.inspect}" unless
String === pattern or Regexp === pattern or pattern.respond_to? :to_str
-
+
@match = nil
rest = self.rest
-
+
return nil if rest_size < 0
-
+
if headonly
headonly_pattern = Regexp.new('^' + pattern.source, pattern.options)
@match = headonly_pattern.match rest
else
@match = pattern.match rest
end
-
+
return nil unless @match
-
+
m = rest[0, @match.end(0)]
-
+
if succptr
@prev_pos = pos
self.pos += m.size
end
-
+
getstr ? m : m.size
end
-
+
end
Modified: MacRuby/trunk/lib/webrick/cgi.rb
===================================================================
--- MacRuby/trunk/lib/webrick/cgi.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/cgi.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -77,7 +77,7 @@
res.set_error(ex)
rescue HTTPStatus::Status => ex
res.status = ex.code
- rescue Exception => ex
+ rescue Exception => ex
@logger.error(ex)
res.set_error(ex, true)
ensure
@@ -122,7 +122,7 @@
include Enumerable
private
-
+
def initialize(config, env, stdin, stdout)
@config = config
@env = env
@@ -130,7 +130,7 @@
@body_part = stdin
@out_port = stdout
@out_port.binmode
-
+
@server_addr = @env["SERVER_ADDR"] || "0.0.0.0"
@server_name = @env["SERVER_NAME"]
@server_port = @env["SERVER_PORT"]
@@ -164,7 +164,7 @@
httpv = @config[:HTTPVersion]
return "#{meth} #{url} HTTP/#{httpv}"
end
-
+
def setup_header
@env.each{|key, value|
case key
@@ -175,7 +175,7 @@
end
}
end
-
+
def add_header(hdrname, value)
unless value.empty?
@header_part << hdrname << ": " << value << CRLF
@@ -185,21 +185,21 @@
def input
@header_part.eof? ? @body_part : @header_part
end
-
+
public
-
+
def peeraddr
[nil, @remote_port, @remote_host, @remote_addr]
end
-
+
def addr
[nil, @server_port, @server_name, @server_addr]
end
-
+
def gets(eol=LF, size=nil)
input.gets(eol, size)
end
-
+
def read(size=nil)
input.read(size)
end
@@ -211,7 +211,7 @@
def eof?
input.eof?
end
-
+
def <<(data)
@out_port << data
end
@@ -256,5 +256,5 @@
end
end
end
- end
-end
+ end
+end
Modified: MacRuby/trunk/lib/webrick/config.rb
===================================================================
--- MacRuby/trunk/lib/webrick/config.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/config.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -22,7 +22,7 @@
General = {
:ServerName => Utils::getservername,
:BindAddress => nil, # "0.0.0.0" or "::" or nil
- :Port => nil, # users MUST specifiy this!!
+ :Port => nil, # users MUST specify this!!
:MaxClients => 100, # maximum number of the concurrent connections
:ServerType => nil, # default: WEBrick::SimpleServer
:Logger => nil, # default: WEBrick::Log.new
@@ -83,7 +83,7 @@
}
DigestAuth = {
- :Algorithm => 'MD5-sess', # or 'MD5'
+ :Algorithm => 'MD5-sess', # or 'MD5'
:Domain => nil, # an array includes domain names.
:Qop => [ 'auth' ], # 'auth' or 'auth-int' or both.
:UseOpaque => true,
Modified: MacRuby/trunk/lib/webrick/httpauth/authenticator.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpauth/authenticator.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpauth/authenticator.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -25,7 +25,7 @@
unless config[sym]
raise ArgumentError, "Argument #{sym.inspect} missing."
end
- }
+ }
@realm = config[:Realm]
@userdb = config[:UserDB]
@logger = config[:Logger] || Log::new($stderr)
@@ -40,8 +40,8 @@
def check_scheme(req)
unless credentials = req[@request_field]
error("no credentials in the request.")
- return nil
- end
+ return nil
+ end
unless match = /^#{@auth_scheme}\s+/i.match(credentials)
error("invalid scheme in %s.", credentials)
info("%s: %s", @request_field, credentials) if $DEBUG
@@ -60,7 +60,7 @@
if @logger.error?
log(:error, fmt, *args)
end
- end
+ end
def info(fmt, *args)
if @logger.info?
Modified: MacRuby/trunk/lib/webrick/httpauth/digestauth.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpauth/digestauth.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpauth/digestauth.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -118,16 +118,16 @@
}
if !check_uri(req, auth_req)
- raise HTTPStatus::BadRequest
+ raise HTTPStatus::BadRequest
end
- if auth_req['realm'] != @realm
+ if auth_req['realm'] != @realm
error('%s: realm unmatch. "%s" for "%s"',
auth_req['username'], auth_req['realm'], @realm)
return false
end
- auth_req['algorithm'] ||= 'MD5'
+ auth_req['algorithm'] ||= 'MD5'
if auth_req['algorithm'] != @algorithm &&
(@opera_hack && auth_req['algorithm'] != @algorithm.upcase)
error('%s: algorithm unmatch. "%s" for "%s"',
@@ -222,7 +222,7 @@
end
}.join(', ')
end
- info('%s: authentication scceeded.', auth_req['username'])
+ info('%s: authentication succeeded.', auth_req['username'])
req.user = auth_req['username']
return true
end
@@ -230,7 +230,7 @@
def split_param_value(string)
ret = {}
while string.bytesize != 0
- case string
+ case string
when /^\s*([\w\-\.\*\%\!]+)=\s*\"((\\.|[^\"])*)\"\s*,?/
key = $1
matched = $2
@@ -320,7 +320,7 @@
uri = auth_req['uri']
if uri != req.request_uri.to_s && uri != req.unparsed_uri &&
(@internet_explorer_hack && uri != req.path)
- error('%s: uri unmatch. "%s" for "%s"', auth_req['username'],
+ error('%s: uri unmatch. "%s" for "%s"', auth_req['username'],
auth_req['uri'], req.request_uri.to_s)
return false
end
Modified: MacRuby/trunk/lib/webrick/httpauth/userdb.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpauth/userdb.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpauth/userdb.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -18,7 +18,7 @@
def set_passwd(realm, user, pass)
self[user] = pass
- end
+ end
def get_passwd(realm, user, reload_db=false)
# reload_db is dummy
Modified: MacRuby/trunk/lib/webrick/httpproxy.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpproxy.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpproxy.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -64,7 +64,7 @@
def proxy_service(req, res)
# Proxy Authentication
- proxy_auth(req, res)
+ proxy_auth(req, res)
begin
self.send("do_#{req.request_method}", req, res)
@@ -81,7 +81,7 @@
handler.call(req, res)
end
end
-
+
def do_CONNECT(req, res)
# Proxy Authentication
proxy_auth(req, res)
@@ -264,7 +264,7 @@
http = Net::HTTP.new(uri.host, uri.port, upstream.host, upstream.port)
http.start do
if @config[:ProxyTimeout]
- ################################## these issues are
+ ################################## these issues are
http.open_timeout = 30 # secs # necessary (maybe bacause
http.read_timeout = 60 # secs # Ruby's bug, but why?)
##################################
Modified: MacRuby/trunk/lib/webrick/httprequest.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httprequest.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httprequest.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -304,7 +304,7 @@
end
elsif self['content-length'] || @remaining_size
@remaining_size ||= self['content-length'].to_i
- while @remaining_size > 0
+ while @remaining_size > 0
sz = [@buffer_size, @remaining_size].min
break unless buf = read_data(socket, sz)
@remaining_size -= buf.bytesize
Modified: MacRuby/trunk/lib/webrick/httpresponse.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpresponse.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpresponse.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -201,10 +201,10 @@
def set_error(ex, backtrace=false)
case ex
- when HTTPStatus::Status
+ when HTTPStatus::Status
@keep_alive = false if HTTPStatus::error?(ex.code)
self.status = ex.code
- else
+ else
@keep_alive = false
self.status = HTTPStatus::RC_INTERNAL_SERVER_ERROR
end
Modified: MacRuby/trunk/lib/webrick/httpserver.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpserver.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpserver.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -36,12 +36,12 @@
[ $stderr, AccessLog::REFERER_LOG_FORMAT ]
]
end
-
+
@virtual_hosts = Array.new
end
def run(sock)
- while true
+ while true
res = HTTPResponse.new(@config)
req = HTTPRequest.new(@config)
server = self
Modified: MacRuby/trunk/lib/webrick/httpservlet/cgihandler.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpservlet/cgihandler.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpservlet/cgihandler.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,11 +1,11 @@
-#
+#
# cgihandler.rb -- CGIHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: cgihandler.rb,v 1.27 2003/03/21 19:56:01 gotoyuzo Exp $
require 'rbconfig'
@@ -68,16 +68,16 @@
if errmsg.bytesize > 0
@logger.error("CGIHandler: #{@script_filename}:\n" + errmsg)
end
- end
+ end
cgi_err.close(true)
end
-
+
if status != 0
@logger.error("CGIHandler: #{@script_filename} exit with #{status}")
end
data = "" unless data
- raw_header, body = data.split(/^[\xd\xa]+/, 2)
+ raw_header, body = data.split(/^[\xd\xa]+/, 2)
raise HTTPStatus::InternalServerError,
"Premature end of script headers: #{@script_filename}" if body.nil?
Modified: MacRuby/trunk/lib/webrick/httpservlet/erbhandler.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpservlet/erbhandler.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpservlet/erbhandler.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,11 +1,11 @@
-#
+#
# erbhandler.rb -- ERBHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: erbhandler.rb,v 1.25 2003/02/24 19:25:31 gotoyuzo Exp $
require 'webrick/httpservlet/abstract.rb'
Modified: MacRuby/trunk/lib/webrick/httpservlet/filehandler.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpservlet/filehandler.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpservlet/filehandler.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -32,7 +32,7 @@
if not_modified?(req, res, mtime, res['etag'])
res.body = ''
raise HTTPStatus::NotModified
- elsif req['range']
+ elsif req['range']
make_partial_content(req, res, @local_path, st.size)
raise HTTPStatus::PartialContent
else
@@ -402,7 +402,7 @@
res.body << "<A HREF=\"?M=#{d1}\">Last modified</A> "
res.body << "<A HREF=\"?S=#{d1}\">Size</A>\n"
res.body << "<HR>\n"
-
+
list.unshift [ "..", File::mtime(local_path+"/.."), -1 ]
list.each{ |name, time, size|
if name == ".."
@@ -420,7 +420,7 @@
}
res.body << "</PRE><HR>"
- res.body << <<-_end_of_html_
+ res.body << <<-_end_of_html_
<ADDRESS>
#{HTMLUtils::escape(@config[:ServerSoftware])}<BR>
at #{req.host}:#{req.port}
Modified: MacRuby/trunk/lib/webrick/httpservlet/prochandler.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpservlet/prochandler.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpservlet/prochandler.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -1,11 +1,11 @@
-#
+#
# prochandler.rb -- ProcHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: prochandler.rb,v 1.7 2002/09/21 12:23:42 gotoyuzo Exp $
require 'webrick/httpservlet/abstract.rb'
@@ -16,7 +16,7 @@
class ProcHandler < AbstractServlet
def get_instance(server, *options)
self
- end
+ end
def initialize(proc)
@proc = proc
Modified: MacRuby/trunk/lib/webrick/httpstatus.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httpstatus.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httpstatus.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -19,7 +19,7 @@
class Error < Status; end
class ClientError < Error; end
class ServerError < Error; end
-
+
class EOFError < StandardError; end
StatusMessage = {
@@ -84,7 +84,7 @@
class #{err_name} < #{parent}
def self.code() RC_#{var_name} end
def self.reason_phrase() StatusMessage[code] end
- def code() self::class::code end
+ def code() self::class::code end
def reason_phrase() self::class::reason_phrase end
alias to_i code
end
Modified: MacRuby/trunk/lib/webrick/httputils.rb
===================================================================
--- MacRuby/trunk/lib/webrick/httputils.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/httputils.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -98,7 +98,7 @@
next if /^#/ =~ line
line.chomp!
mimetype, ext0 = line.split(/\s+/, 2)
- next unless ext0
+ next unless ext0
next if ext0.empty?
ext0.split(/\s+/).each{ |ext| hash[ext] = mimetype }
}
@@ -216,7 +216,7 @@
super("")
else
@raw_header = EmptyRawHeader
- @header = EmptyHeader
+ @header = EmptyHeader
super(args.shift)
unless args.empty?
@next_data = self.class.new(*args)
@@ -250,7 +250,7 @@
def append_data(data)
tmp = self
while tmp
- unless tmp.next_data
+ unless tmp.next_data
tmp.next_data = data
break
end
@@ -317,7 +317,7 @@
if form_data.has_key?(key)
form_data[key].append_data(data)
else
- form_data[key] = data
+ form_data[key] = data
end
end
data = FormData.new
Modified: MacRuby/trunk/lib/webrick/log.rb
===================================================================
--- MacRuby/trunk/lib/webrick/log.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/log.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -72,7 +72,7 @@
end
class Log < BasicLog
- attr_accessor :time_format
+ attr_accessor :time_format
def initialize(log_file=nil, level=nil)
super(log_file, level)
Modified: MacRuby/trunk/lib/webrick/server.rb
===================================================================
--- MacRuby/trunk/lib/webrick/server.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/server.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -157,7 +157,7 @@
begin
sock = svr.accept
sock.sync = true
- Utils::set_non_blocking(sock)
+ Utils::set_non_blocking(sock)
Utils::set_close_on_exec(sock)
rescue Errno::ECONNRESET, Errno::ECONNABORTED,
Errno::EPROTO, Errno::EINVAL => ex
Modified: MacRuby/trunk/lib/webrick/ssl.rb
===================================================================
--- MacRuby/trunk/lib/webrick/ssl.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/ssl.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -2,7 +2,7 @@
# ssl.rb -- SSL/TLS enhancement for GenericServer
#
# Copyright (c) 2003 GOTOU Yuuzou All rights reserved.
-#
+#
# $Id: ssl.rb 11708 2007-02-12 23:01:19Z shyouhei $
require 'webrick'
@@ -41,7 +41,7 @@
case p
when 0; $stderr.putc "." # BN_generate_prime
when 1; $stderr.putc "+" # BN_generate_prime
- when 2; $stderr.putc "*" # searching good prime,
+ when 2; $stderr.putc "*" # searching good prime,
# n = #of try,
# but also data from BN_generate_prime
when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
@@ -88,7 +88,7 @@
if @config[:SSLEnable]
unless ssl_context
@ssl_context = setup_ssl_context(@config)
- @logger.info("\n" + @config[:SSLCertificate].to_text)
+ @logger.info("\n" + @config[:SSLCertificate].to_text)
end
listeners.collect!{|svr|
ssvr = ::OpenSSL::SSL::SSLServer.new(svr, ssl_context)
Modified: MacRuby/trunk/lib/webrick/utils.rb
===================================================================
--- MacRuby/trunk/lib/webrick/utils.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/webrick/utils.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -86,13 +86,13 @@
RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789" +
- "abcdefghijklmnopqrstuvwxyz"
+ "abcdefghijklmnopqrstuvwxyz"
def random_string(len)
rand_max = RAND_CHARS.bytesize
- ret = ""
+ ret = ""
len.times{ ret << RAND_CHARS[rand(rand_max)] }
- ret
+ ret
end
module_function :random_string
Modified: MacRuby/trunk/lib/yaml/baseemitter.rb
===================================================================
--- MacRuby/trunk/lib/yaml/baseemitter.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/baseemitter.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -42,7 +42,7 @@
'|'
else
'>'
- end
+ end
indt = $&.to_i if block =~ /\d+/
if valx =~ /(\A\n*[ \t#]|^---\s+)/
indt = options(:Indent) unless indt.to_i > 0
@@ -64,8 +64,8 @@
valx = fold( YAML::escape( valx, esc_skip ) + "\"" ).chomp
self << '"' + indent_text( valx, indt, false )
else
- if block[0] == ?>
- valx = fold( valx )
+ if block[0] == ?>
+ valx = fold( valx )
end
#p [block, indt]
self << block + indent_text( valx, indt )
@@ -84,7 +84,7 @@
# Emit double-quoted string
#
def double( value )
- "\"#{YAML.escape( value )}\""
+ "\"#{YAML.escape( value )}\""
end
#
@@ -150,8 +150,8 @@
@seq_map = false
else
# FIXME
- # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
- # @headless = 1
+ # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
+ # @headless = 1
# end
defkey = @options.delete( :DefaultKey )
@@ -174,7 +174,7 @@
self << "\n"
indent!
end
- self << ": "
+ self << ": "
v[1].to_yaml( :Emitter => self )
}
end
@@ -187,7 +187,7 @@
# @seq_map = false
# else
self << "\n"
- indent!
+ indent!
# end
end
@@ -207,8 +207,8 @@
self << "[]"
else
# FIXME
- # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
- # @headless = 1
+ # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
+ # @headless = 1
# end
#
Modified: MacRuby/trunk/lib/yaml/constants.rb
===================================================================
--- MacRuby/trunk/lib/yaml/constants.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/constants.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -13,7 +13,7 @@
# Parser tokens
#
WORD_CHAR = 'A-Za-z0-9'
- PRINTABLE_CHAR = '-_A-Za-z0-9!?/()$\'". '
+ PRINTABLE_CHAR = '-_A-Za-z0-9!?/()$\'". '
NOT_PLAIN_CHAR = '\x7f\x0-\x1f\x80-\x9f'
ESCAPE_CHAR = '[\\x00-\\x09\\x0b-\\x1f]'
INDICATOR_CHAR = '*&!|\\\\^@%{}[]='
@@ -27,7 +27,7 @@
\x18 \x19 \x1a \e \x1c \x1d \x1e \x1f
}
UNESCAPES = {
- 'a' => "\x07", 'b' => "\x08", 't' => "\x09",
+ 'a' => "\x07", 'b' => "\x08", 't' => "\x09",
'n' => "\x0a", 'v' => "\x0b", 'f' => "\x0c",
'r' => "\x0d", 'e' => "\x1b", '\\' => '\\',
}
Modified: MacRuby/trunk/lib/yaml/dbm.rb
===================================================================
--- MacRuby/trunk/lib/yaml/dbm.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/dbm.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -35,14 +35,14 @@
def delete( key )
v = super( key )
if String === v
- v = YAML::load( v )
+ v = YAML::load( v )
end
v
end
def delete_if
del_keys = keys.dup
del_keys.delete_if { |k| yield( k, fetch( k ) ) == false }
- del_keys.each { |k| delete( k ) }
+ del_keys.each { |k| delete( k ) }
self
end
def reject
Modified: MacRuby/trunk/lib/yaml/encoding.rb
===================================================================
--- MacRuby/trunk/lib/yaml/encoding.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/encoding.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -23,9 +23,9 @@
if $3
["#$3".hex ].pack('U*')
elsif $2
- [$2].pack( "H2" )
+ [$2].pack( "H2" )
else
- UNESCAPES[$1]
+ UNESCAPES[$1]
end
}
end
Modified: MacRuby/trunk/lib/yaml/error.rb
===================================================================
--- MacRuby/trunk/lib/yaml/error.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/error.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -26,7 +26,7 @@
#
# YAML Error classes
#
-
+
class Error < StandardError; end
class ParseError < Error; end
class TypeError < StandardError; end
Modified: MacRuby/trunk/lib/yaml/rubytypes.rb
===================================================================
--- MacRuby/trunk/lib/yaml/rubytypes.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/rubytypes.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -21,15 +21,15 @@
end
#yaml_as "tag:ruby.yaml.org,2002:object"
-
+
def to_yaml_style
nil
end
-
+
def to_yaml_properties
self.instance_variables.sort
end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.map(taguri, to_yaml_style) do |map|
@@ -84,7 +84,7 @@
class NSString
yaml_as "tag:yaml.org,2002:str"
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar(taguri, self, to_yaml_style)
@@ -110,7 +110,7 @@
class NSArray
yaml_as "tag:yaml.org,2002:seq"
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.seq(taguri, to_yaml_style) do |seq|
@@ -122,10 +122,10 @@
class NSDictionary
yaml_as "tag:yaml.org,2002:map"
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
- out.map(taguri, to_yaml_style) do |map|
+ out.map(taguri, to_yaml_style) do |map|
each { |k,v| map.add(k,v) }
end
end
@@ -134,11 +134,11 @@
class Integer
yaml_as "tag:yaml.org,2002:int"
-
+
def Integer.yaml_new(val)
val.to_i
end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar("tag:yaml.org,2002:int", self.to_s, :plain)
@@ -148,11 +148,11 @@
class Float
yaml_as "tag:yaml.org,2002:float"
-
+
def Float.yaml_new(val)
val.to_f
end
-
+
def to_yaml(output = nil)
str = self.to_s
if str == "Infinity"
@@ -170,9 +170,9 @@
class Symbol
yaml_as "tag:ruby.yaml.org,2002:symbol"
-
+
def self.yaml_new(val); val[1..-1].to_sym; end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar(taguri, self.inspect, :plain)
@@ -182,11 +182,11 @@
class Range
yaml_as "tag:ruby.yaml.org,2002:range"
-
+
def Range.yaml_new(attrs)
Range.new(attrs['begin'], attrs['end'], attrs['excl'])
end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.map(taguri, to_yaml_style) do |map|
@@ -210,7 +210,7 @@
class Rational
yaml_as "tag:ruby.yaml.org,2002:object:Rational"
-
+
def Rational.yaml_new(attrs)
if attrs.is_a? String
Rational(attrs)
@@ -218,10 +218,10 @@
Rational(attrs['numerator'], attrs['denominator'])
end
end
-
- def to_yaml(output = nil)
+
+ def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
- out.map(taguri, to_yaml_style) do |map|
+ out.map(taguri, to_yaml_style) do |map|
map.add('denominator', denominator)
map.add('numerator', numerator)
end
@@ -248,11 +248,11 @@
end
end
-class NilClass
+class NilClass
yaml_as "tag:yaml.org,2002:null"
-
+
def self.yaml_new(val); nil; end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar(taguri, "", :plain)
@@ -262,9 +262,9 @@
class TrueClass
yaml_as "tag:yaml.org,2002:true"
-
+
def self.yaml_new(val); true; end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar(taguri, "true", :plain)
@@ -274,9 +274,9 @@
class FalseClass
yaml_as "tag:yaml.org,2002:false"
-
+
def self.yaml_new(val); false; end
-
+
def to_yaml(output = nil)
YAML::quick_emit(output) do |out|
out.scalar(taguri, "false", :plain)
@@ -321,7 +321,7 @@
utc_same_instant = self.dup.utc
utc_same_writing = Time.utc(year,month,day,hour,min,sec,usec)
difference_to_utc = utc_same_writing - utc_same_instant
- if (difference_to_utc < 0)
+ if (difference_to_utc < 0)
difference_sign = '-'
absolute_difference = -difference_to_utc
else
@@ -391,7 +391,7 @@
end
if not struct_type
struct_def = [ tag.split( ':', 4 ).last ]
- struct_type = Struct.new( *struct_def.concat( val.keys.collect { |k| k.intern } ) )
+ struct_type = Struct.new( *struct_def.concat( val.keys.collect { |k| k.intern } ) )
end
#
@@ -629,7 +629,7 @@
utc_same_instant = self.dup.utc
utc_same_writing = Time.utc(year,month,day,hour,min,sec,usec)
difference_to_utc = utc_same_writing - utc_same_instant
- if (difference_to_utc < 0)
+ if (difference_to_utc < 0)
difference_sign = '-'
absolute_difference = -difference_to_utc
else
Modified: MacRuby/trunk/lib/yaml/stream.rb
===================================================================
--- MacRuby/trunk/lib/yaml/stream.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/stream.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -11,7 +11,7 @@
@options = opts
@documents = []
end
-
+
def []( i )
@documents[ i ]
end
Modified: MacRuby/trunk/lib/yaml/stringio.rb
===================================================================
--- MacRuby/trunk/lib/yaml/stringio.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/stringio.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -13,7 +13,7 @@
end
def pos
@pos
- end
+ end
def eof
@eof
end
Modified: MacRuby/trunk/lib/yaml/tag.rb
===================================================================
--- MacRuby/trunk/lib/yaml/tag.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/tag.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -4,13 +4,13 @@
# = yaml/tag.rb: methods for associating a taguri to a class.
#
# Author:: why the lucky stiff
-#
+#
module YAML
# A dictionary of taguris which map to
# Ruby classes.
@@tagged_classes = {}
-
- #
+
+ #
# Associates a taguri _tag_ with a Ruby class _cls_. The taguri is used to give types
# to classes when loading YAML. Taguris are of the form:
#
@@ -19,7 +19,7 @@
# The +authorityName+ is a domain name or email address. The +date+ is the date the type
# was issued in YYYY or YYYY-MM or YYYY-MM-DD format. The +specific+ is a name for
# the type being added.
- #
+ #
# For example, built-in YAML types have 'yaml.org' as the +authorityName+ and '2002' as the
# +date+. The +specific+ is simply the name of the type:
#
Modified: MacRuby/trunk/lib/yaml/types.rb
===================================================================
--- MacRuby/trunk/lib/yaml/types.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml/types.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -58,7 +58,7 @@
#
# YAML Hash class to support comments and defaults
#
- class SpecialHash < ::Hash
+ class SpecialHash < ::Hash
attr_accessor :default
def inspect
self.default.to_s
@@ -112,7 +112,7 @@
if ( tmp = self.assoc( k ) ) and not set
tmp[1] = val
else
- self << [ k, val ]
+ self << [ k, val ]
end
val
end
@@ -163,7 +163,7 @@
self.assoc( k ).to_a
end
def []=( k, val )
- self << [ k, val ]
+ self << [ k, val ]
val
end
def has_key?( k )
Modified: MacRuby/trunk/lib/yaml.rb
===================================================================
--- MacRuby/trunk/lib/yaml.rb 2010-12-23 10:17:13 UTC (rev 5077)
+++ MacRuby/trunk/lib/yaml.rb 2010-12-23 17:09:39 UTC (rev 5078)
@@ -4,50 +4,50 @@
# = yaml.rb: top-level module with methods for loading and parsing YAML documents
#
# Author:: why the lucky stiff
-#
+#
require 'libyaml'
require 'yaml/rubytypes'
require 'yaml/yamlnode'
module YAML
-
+
def YAML.parser
LibYAML::Parser.new
end
-
+
def YAML.emitter
LibYAML::Emitter.new
end
-
+
def YAML.dump(obj, io=nil)
obj.to_yaml(io)
end
-
+
def YAML.dump_stream(*objs)
LibYAML::Emitter.new.stream do |stream|
- objs.each do |obj|
+ objs.each do |obj|
stream.document { |doc| obj.to_yaml(doc) }
end
end
end
-
+
def YAML.load(io)
parsr = LibYAML::Parser.new(io)
parsr.load
end
-
+
def YAML.load_file(path)
File.open(path) { |f| load(f) }
end
-
+
def YAML.load_documents(io)
yparser = LibYAML::Parser.new(io)
until (element = yparser.load).nil?
yield(element)
end
end
-
+
def YAML.each_document(io, &block)
YAML.load_documents(io, &block)
end
@@ -57,16 +57,16 @@
YAML.load_documents(io) { |e| elements << e}
elements
end
-
+
def YAML.parse(io)
return false if io==''
LibYAML::Parser.new(io).parse
end
-
+
def YAML.parse_file(path)
File.open(path) { |f| parse(f) }
end
-
+
def YAML.quick_emit(out, &block)
if out.is_a? LibYAML::Emitter
yield(out)
@@ -76,16 +76,16 @@
end
end
end
-
+
def YAML.tag_class(tag, klass)
LibYAML::DEFAULT_RESOLVER.add_type(tag, klass)
klass
end
-
+
def YAML.add_builtin_type(type_tag, &transfer)
LibYAML::DEFAULT_RESOLVER.add_type("tag:yaml.org,2002:#{type_tag}", transfer)
end
-
+
def YAML.add_domain_type(domain, type_tag, &transfer)
LibYAML::DEFAULT_RESOLVER.add_type("tag:#{domain}:#{type_tag}", transfer)
end
@@ -93,7 +93,7 @@
def YAML.add_ruby_type(type_tag, &transfer)
LibYAML::DEFAULT_RESOLVER.add_type("tag:ruby.yaml.org,2002:#{type_tag}", transfer)
end
-
+
def YAML.add_private_type(type_tag, &transfer)
LibYAML::DEFAULT_RESOLVER.add_type("x-private:#{type_tag}", transfer)
end
@@ -129,18 +129,18 @@
# serialization format. Together with the Unicode standard for characters, it
# provides all the information necessary to understand YAML Version 1.0
# and construct computer programs to process it.
-#
+#
# See http://yaml.org/ for more information. For a quick tutorial, please
# visit YAML In Five Minutes (http://yaml.kwiki.org/?YamlInFiveMinutes).
-#
+#
# == About This Library
-#
+#
# The YAML 1.0 specification outlines four stages of YAML loading and dumping.
# This library honors all four of those stages, although data is really only
# available to you in three stages.
-#
+#
# The four stages are: native, representation, serialization, and presentation.
-#
+#
# The native stage refers to data which has been loaded completely into Ruby's
# own types. (See +YAML::load+.)
#
@@ -148,14 +148,14 @@
# +YAML::BaseNode+ objects. In this stage, the document is available as a
# tree of node objects. You can perform YPath queries and transformations
# at this level. (See +YAML::parse+.)
-#
+#
# The serialization stage happens inside the parser. The YAML parser used in
# Ruby is called Syck. Serialized nodes are available in the extension as
# SyckNode structs.
-#
+#
# The presentation stage is the YAML document itself. This is accessible
# to you as a string. (See +YAML::dump+.)
-#
+#
# For more information about the various information models, see Chapter
# 3 of the YAML 1.0 Specification (http://yaml.org/spec/#id2491269).
#
@@ -207,7 +207,7 @@
#
# Converts _obj_ to YAML and writes the YAML result to _io_.
- #
+ #
# File.open( 'animals.yaml', 'w' ) do |out|
# YAML.dump( ['badger', 'elephant', 'tiger'], out )
# end
@@ -273,8 +273,8 @@
# Can also load from a string.
#
# YAML.parse( "--- :locked" )
- # #=> #<YAML::Syck::Node:0x82edddc
- # @type_id="tag:ruby.yaml.org,2002:sym",
+ # #=> #<YAML::Syck::Node:0x82edddc
+ # @type_id="tag:ruby.yaml.org,2002:sym",
# @value=":locked", @kind=:scalar>
#
def YAML.parse( io )
@@ -368,7 +368,7 @@
end
#
- # Loads all documents from the current _io_ stream,
+ # Loads all documents from the current _io_ stream,
# returning a +YAML::Stream+ object containing all
# loaded documents.
#
@@ -376,7 +376,7 @@
d = nil
parser.load_documents( io ) do |doc|
d = YAML::Stream.new if not d
- d.add( doc )
+ d.add( doc )
end
return d
end
@@ -393,7 +393,7 @@
def YAML.dump_stream( *objs )
d = YAML::Stream.new
objs.each do |doc|
- d.add( doc )
+ d.add( doc )
end
d.emit
end
@@ -483,7 +483,7 @@
# Allocate an Emitter if needed
#
def YAML.quick_emit( oid, opts = {}, &e )
- out =
+ out =
if opts.is_a? YAML::Emitter
opts
else
@@ -495,7 +495,7 @@
end
out.emit( oid, &e )
end
-
+
end
require 'yaml/rubytypes'
@@ -527,7 +527,7 @@
#
# _produces:_
#
- # --- !ruby/struct:S
+ # --- !ruby/struct:S
# name: dave
# state: TX
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101223/fcc7ec1f/attachment-0001.html>
More information about the macruby-changes
mailing list