diff --git a/ChangeLog b/ChangeLog index 0278d0be3e..374232e0de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 26 17:43:20 2006 Minero Aoki + + * ext/strscan/strscan.c (strscan_do_scan): + StringScanner.new("").scan(//) should return "". [ruby-Bugs:4361] + Wed Jul 26 17:28:16 2006 Nobuyoshi Nakada * sprintf.c (rb_str_format): prepend ".." to %u for negative bignum, diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 1dd61e5963..dcb70a7747 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -391,9 +391,6 @@ strscan_set_pos(VALUE self, VALUE v) return INT2NUM(i); } -/* I should implement this function? */ -#define strscan_prepare_re(re) /* none */ - static VALUE strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly) { @@ -404,10 +401,6 @@ strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly) GET_SCANNER(self, p); CLEAR_MATCH_STATUS(p); - if (EOS_P(p)) { - return Qnil; - } - strscan_prepare_re(regex); if (headonly) { ret = onig_match(RREGEXP(regex)->ptr, (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)), diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index deb05d29a7..5b0fd53c75 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -242,6 +242,11 @@ class TestStringScanner < Test::Unit::TestCase s.string.replace '' # unspecified: assert_equal 2, s.pos assert_equal nil, s.scan(/test/) + + # [ruby-bugs:4361] + s = StringScanner.new("") + assert_equal "", s.scan(//) + assert_equal "", s.scan(//) end def test_skip @@ -259,6 +264,11 @@ class TestStringScanner < Test::Unit::TestCase s.scan(/te/) s.string.replace '' assert_equal nil, s.skip(/./) + + # [ruby-bugs:4361] + s = StringScanner.new("") + assert_equal 0, s.skip(//) + assert_equal 0, s.skip(//) end def test_getch