ruby-changes:12940
From: nobu <ko1@a...>
Date: Thu, 27 Aug 2009 08:17:08 +0900 (JST)
Subject: [ruby-changes:12940] Ruby:r24679 (trunk): * ext/strscan/strscan.c (strscan_set_string): set string should not be
nobu 2009-08-27 08:16:40 +0900 (Thu, 27 Aug 2009) New Revision: 24679 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24679 Log: * 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]. Modified files: trunk/ChangeLog trunk/ext/strscan/strscan.c trunk/test/strscan/test_stringscanner.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24678) +++ ChangeLog (revision 24679) @@ -1,3 +1,10 @@ +Thu Aug 27 08:16:34 2009 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * Makefile.in (enc/unicode/name2ctype.kwd): Index: ext/strscan/strscan.c =================================================================== --- ext/strscan/strscan.c (revision 24678) +++ ext/strscan/strscan.c (revision 24679) @@ -321,8 +321,7 @@ 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; Index: test/strscan/test_stringscanner.rb =================================================================== --- test/strscan/test_stringscanner.rb (revision 24678) +++ test/strscan/test_stringscanner.rb (revision 24679) @@ -168,6 +168,26 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/