mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (str_alloc): should allocate a String object, even when
asked to allocate a Symbol object. [ruby-dev:29529] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3d1b573946
commit
82f7f29c59
2 changed files with 8 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Sep 8 16:53:30 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (str_alloc): should allocate a String object, even when
|
||||||
|
asked to allocate a Symbol object. [ruby-dev:29529]
|
||||||
|
|
||||||
Fri Sep 8 16:36:27 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
Fri Sep 8 16:36:27 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/extmk.rb (extmake): follow Array#to_s.
|
* ext/extmk.rb (extmake): follow Array#to_s.
|
||||||
|
|
4
string.c
4
string.c
|
@ -119,6 +119,9 @@ str_alloc(VALUE klass)
|
||||||
NEWOBJ(str, struct RString);
|
NEWOBJ(str, struct RString);
|
||||||
OBJSETUP(str, klass, T_STRING);
|
OBJSETUP(str, klass, T_STRING);
|
||||||
|
|
||||||
|
if (klass == rb_cSymbol) {
|
||||||
|
RBASIC(str)->klass = rb_cString;
|
||||||
|
}
|
||||||
str->as.heap.ptr = 0;
|
str->as.heap.ptr = 0;
|
||||||
str->as.heap.len = 0;
|
str->as.heap.len = 0;
|
||||||
str->as.heap.aux.capa = 0;
|
str->as.heap.aux.capa = 0;
|
||||||
|
@ -135,7 +138,6 @@ str_new(VALUE klass, const char *ptr, long len)
|
||||||
rb_raise(rb_eArgError, "negative string size (or size too big)");
|
rb_raise(rb_eArgError, "negative string size (or size too big)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (klass == rb_cSymbol) klass = rb_cString;
|
|
||||||
str = str_alloc(klass);
|
str = str_alloc(klass);
|
||||||
if (len > RSTRING_EMBED_LEN_MAX) {
|
if (len > RSTRING_EMBED_LEN_MAX) {
|
||||||
RSTRING(str)->as.heap.aux.capa = len;
|
RSTRING(str)->as.heap.aux.capa = len;
|
||||||
|
|
Loading…
Reference in a new issue