* ext/strscan/strscan.c (strscan_set_string): set string should not be

dupped or frozen, because freezing it causes #concat method failure,
  and unnecessary to dup without freezing.  a patch from Aaron
  Patterson at [ruby-core:25145].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-08-26 23:16:40 +00:00
Родитель 6cd8f907cf
Коммит 2ef382231f
3 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Thu Aug 27 08:16:34 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/strscan/strscan.c (strscan_set_string): set string should not be
dupped or frozen, because freezing it causes #concat method failure,
and unnecessary to dup without freezing. a patch from Aaron
Patterson at [ruby-core:25145].
Thu Aug 27 02:06:11 2009 NARUSE, Yui <naruse@ruby-lang.org>
* Makefile.in (enc/unicode/name2ctype.kwd):

Просмотреть файл

@ -321,8 +321,7 @@ strscan_set_string(VALUE self, VALUE str)
Data_Get_Struct(self, struct strscanner, p);
StringValue(str);
p->str = rb_str_dup(str);
rb_obj_freeze(p->str);
p->str = str;
p->curr = 0;
CLEAR_MATCH_STATUS(p);
return str;

Просмотреть файл

@ -168,6 +168,26 @@ class TestStringScanner < Test::Unit::TestCase
assert_equal 0, s.pos
end
def test_string_set_is_equal
name = 'tenderlove'
s = StringScanner.new(name)
assert_equal name.object_id, s.string.object_id
s.string = name
assert_equal name.object_id, s.string.object_id
end
def test_string_append
s = StringScanner.new('tender')
s << 'love'
assert_equal 'tenderlove', s.string
s.string = 'tender'
s << 'love'
assert_equal 'tenderlove', s.string
end
def test_pos
s = StringScanner.new('test string')
assert_equal 0, s.pos