From 5f13d888cf0aece7c1bb13b72773f66a4b9cebff Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 4 Aug 2010 11:08:28 +0000 Subject: * string.c (rb_str_resize): reverted r28851. rb_str_resize cannot work before the length is set. [ruby-core:31615] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ----- ext/-test-/bug-3652/bug.c | 16 ---------------- ext/-test-/bug-3652/extconf.rb | 1 - string.c | 2 +- test/-ext-/test_bug-3652.rb | 12 ------------ 5 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 ext/-test-/bug-3652/bug.c delete mode 100644 ext/-test-/bug-3652/extconf.rb delete mode 100644 test/-ext-/test_bug-3652.rb diff --git a/ChangeLog b/ChangeLog index 94ad482142..c69bb03994 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,11 +3,6 @@ Wed Aug 4 19:37:00 2010 Nobuyoshi Nakada * string.c (rb_str_set_len): rb_str_modify cannot work before the length is set, which is a precondition for rb_str_modify. -Wed Aug 4 16:09:43 2010 Nobuyoshi Nakada - - * string.c (rb_str_resize): should copy the content properly. a - patch from Jeremy Evans at [ruby-core:31615]. - Wed Aug 4 15:47:21 2010 NAKAMURA Usaku * lib/mkmf.rb (create_makefile): no need to create the directory diff --git a/ext/-test-/bug-3652/bug.c b/ext/-test-/bug-3652/bug.c deleted file mode 100644 index 290ac2ddee..0000000000 --- a/ext/-test-/bug-3652/bug.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -static VALUE -bug_str_resize(VALUE self, VALUE init, VALUE repl) -{ - long initlen = NUM2LONG(init); - VALUE s = rb_str_buf_new(initlen); - return rb_str_resize(s, strlcpy(RSTRING_PTR(s), StringValueCStr(repl), (size_t)initlen)); -} - -void -Init_bug(void) -{ - VALUE mBug = rb_define_module("Bug"); - rb_define_module_function(mBug, "str_resize", bug_str_resize, 2); -} diff --git a/ext/-test-/bug-3652/extconf.rb b/ext/-test-/bug-3652/extconf.rb deleted file mode 100644 index 44f57b41c8..0000000000 --- a/ext/-test-/bug-3652/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/bug-3652/bug") diff --git a/string.c b/string.c index decc9d7f04..9fe344a20f 100644 --- a/string.c +++ b/string.c @@ -1723,7 +1723,7 @@ rb_str_resize(VALUE str, long len) else if (len <= RSTRING_EMBED_LEN_MAX) { char *ptr = RSTRING(str)->as.heap.ptr; STR_SET_EMBED(str); - if (len > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, len); + if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen); RSTRING(str)->as.ary[len] = '\0'; STR_SET_EMBED_LEN(str, len); if (independent) xfree(ptr); diff --git a/test/-ext-/test_bug-3652.rb b/test/-ext-/test_bug-3652.rb deleted file mode 100644 index 0e4d658081..0000000000 --- a/test/-ext-/test_bug-3652.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test/unit' -require '-test-/bug-3652/bug' - -class Test_BUG_3652 < Test::Unit::TestCase - def test_block_call_id - bug3652 = '[ruby-core:31615]' - s = "123456789012345678901234" - assert_equal(s, Bug.str_resize(127, s), bug3652) - s = "123456789" - assert_equal(s, Bug.str_resize(127, s), bug3652) - end -end -- cgit v1.2.3