ruby-changes:16900
From: nobu <ko1@a...>
Date: Sat, 7 Aug 2010 14:01:47 +0900 (JST)
Subject: [ruby-changes:16900] Ruby:r28896 (trunk): * ext/pathname/pathname.c (path_sub_ext): don't clobber shared string.
nobu 2010-08-07 13:59:27 +0900 (Sat, 07 Aug 2010) New Revision: 28896 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28896 Log: * ext/pathname/pathname.c (path_sub_ext): don't clobber shared string. [ruby-core:31640] Modified files: trunk/ChangeLog trunk/ext/pathname/pathname.c trunk/test/pathname/test_pathname.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28895) +++ ChangeLog (revision 28896) @@ -1,3 +1,8 @@ +Sat Aug 7 13:59:19 2010 Nobuyoshi Nakada <nobu@r...> + + * ext/pathname/pathname.c (path_sub_ext): don't clobber shared string. + [ruby-core:31640] + Sat Aug 7 13:33:25 2010 Nobuyoshi Nakada <nobu@r...> * vm_eval.c (vm_call0): fix for VM_METHOD_TYPE_NOTIMPLEMENTED. Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 28895) +++ ext/pathname/pathname.c (revision 28896) @@ -192,7 +192,7 @@ ext += extlen; } str2 = rb_str_dup(str); - rb_str_set_len(str2, ext-p); + rb_str_resize(str2, ext-p); rb_str_append(str2, repl); OBJ_INFECT(str2, str); return rb_class_new_instance(1, &str2, rb_obj_class(self)); Index: test/pathname/test_pathname.rb =================================================================== --- test/pathname/test_pathname.rb (revision 28895) +++ test/pathname/test_pathname.rb (revision 28896) @@ -19,7 +19,10 @@ def self.defassert(name, result, *args) define_assertion(name) { - assert_equal(result, self.send(name, *args), "#{name}(#{args.map {|a| a.inspect }.join(', ')})") + mesg = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" + assert_nothing_raised(mesg) { + assert_equal(result, self.send(name, *args), mesg) + } } end @@ -506,6 +509,7 @@ defassert(:pathsubext, 'lex.yy.o', 'lex.yy.c', '.o') defassert(:pathsubext, 'fooaa.o', 'fooaa', '.o') defassert(:pathsubext, 'd.e/aa.o', 'd.e/aa', '.o') + defassert(:pathsubext, 'long_enough.bug-3664', 'long_enough.not_to_be_embeded[ruby-core:31640]', '.bug-3664') def test_sub_matchdata result = Pathname("abc.gif").sub(/\..*/) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/