summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-28 14:59:01 +0000
committermichal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-28 14:59:01 +0000
commit5c70716bdc3796ec62400b939dc2f5450def6b87 (patch)
tree16f0c5afc1f149f3b342fc78dee7b91312103eaa /variable.c
parentb961db7587376bf451775d3654c19a9da5d3a73d (diff)
variable.c: Get rid of fix len buffer in rb_class_path (ruby-core:381)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/variable.c b/variable.c
index bed89593d6..28b3f965ba 100644
--- a/variable.c
+++ b/variable.c
@@ -188,17 +188,22 @@ rb_class_path(klass)
if (path) return path;
else {
- char buf[256];
+ VALUE str;
char *s = "Class";
if (TYPE(klass) == T_MODULE) {
- if (rb_obj_class(klass) == rb_cModule)
+ if (rb_obj_class(klass) == rb_cModule) {
s = "Module";
- else
+ }
+ else {
s = rb_class2name(RBASIC(klass)->klass);
+ }
}
- sprintf(buf, "#<%s:0x%lx>", s, klass);
- return rb_str_new2(buf);
+ str = rb_str_new(0, 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1);
+ sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", s, klass);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+
+ return str;
}
}