[macruby-changes] [4917] MacRuby/trunk/lib/strscan.rb

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 19 07:55:19 PST 2010


Revision: 4917
          http://trac.macosforge.org/projects/ruby/changeset/4917
Author:   watson1978 at gmail.com
Date:     2010-11-19 07:55:17 -0800 (Fri, 19 Nov 2010)
Log Message:
-----------
fixed the bug of StringScanner#rest. there was the case that this method returned nil.

Test Script:
{{{
require 'strscan'
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

s = StringScanner.new('test')
assert_equal("te", s.scan(/te/))

s.string.replace ''
assert_equal(2,   s.pos)
assert_equal(0,   s.rest_size)
assert_equal("",  s.rest)

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/lib/strscan.rb

Modified: MacRuby/trunk/lib/strscan.rb
===================================================================
--- MacRuby/trunk/lib/strscan.rb	2010-11-17 08:39:20 UTC (rev 4916)
+++ MacRuby/trunk/lib/strscan.rb	2010-11-19 15:55:17 UTC (rev 4917)
@@ -340,7 +340,7 @@
   # If there is no more data (eos? = true), it returns <tt>""</tt>.
   #
   def rest
-    string[pos..-1]
+    string[pos..-1] || ""
   end
   
   # <tt>s.rest_size</tt> is equivalent to <tt>s.rest.size</tt>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101119/12a64ee4/attachment.html>


More information about the macruby-changes mailing list