ruby-changes:12295
From: nobu <ko1@a...>
Date: Wed, 8 Jul 2009 16:47:34 +0900 (JST)
Subject: [ruby-changes:12295] Ruby:r23989 (trunk): * file.c (rb_file_s_basename): returns new string instead of
nobu 2009-07-08 16:47:09 +0900 (Wed, 08 Jul 2009) New Revision: 23989 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23989 Log: * file.c (rb_file_s_basename): returns new string instead of shared string from FilePathStringValue(). [ruby-core:24199] Modified files: trunk/ChangeLog trunk/file.c trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 23988) +++ ChangeLog (revision 23989) @@ -1,3 +1,8 @@ +Wed Jul 8 16:47:03 2009 Nobuyoshi Nakada <nobu@r...> + + * file.c (rb_file_s_basename): returns new string instead of + shared string from FilePathStringValue(). [ruby-core:24199] + 2009-07-07 Eric Hodel <drbrain@s...> * ext/.document: Update with extensions that appear to have Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 23988) +++ test/ruby/test_file_exhaustive.rb (revision 23989) @@ -392,8 +392,10 @@ def test_basename assert_equal(File.basename(@file).sub(/\.test$/, ""), File.basename(@file, ".test")) - assert_equal("", File.basename("")) - assert_equal("foo", File.basename("foo")) + assert_equal("", s = File.basename("")) + assert(!s.frozen?, '[ruby-core:24199]') + assert_equal("foo", s = File.basename("foo")) + assert(!s.frozen?, '[ruby-core:24199]') assert_equal("foo", File.basename("foo", ".ext")) assert_equal("foo", File.basename("foo.ext", ".ext")) assert_equal("foo", File.basename("foo.ext", ".*")) Index: file.c =================================================================== --- file.c (revision 23988) +++ file.c (revision 23989) @@ -3104,7 +3104,7 @@ } FilePathStringValue(fname); if (RSTRING_LEN(fname) == 0 || !*(name = RSTRING_PTR(fname))) - return fname; + return rb_str_new_shared(fname); name = skipprefix(name); #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC root = name; @@ -3146,7 +3146,7 @@ if (NIL_P(fext) || !(f = rmext(p, n, StringValueCStr(fext)))) { f = n; } - if (f == RSTRING_LEN(fname)) return fname; + if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname); } basename = rb_str_new(p, f); rb_enc_copy(basename, fname); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/