From 5c70716bdc3796ec62400b939dc2f5450def6b87 Mon Sep 17 00:00:00 2001 From: michal Date: Wed, 28 Aug 2002 14:59:01 +0000 Subject: [PATCH] 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 --- ChangeLog | 6 ++++++ signal.c | 2 -- variable.c | 15 ++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73586e435a..2c2ba5a991 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Aug 28 23:59:15 2002 Michal Rokos + + * signal.c: remove #ifdef SIGINT for struct signals. + + * variable.c: get rid of fix length buffer in rb_class_path. + Wed Aug 28 23:34:32 2002 Nobuyoshi Nakada * io.c (appendline): data was lost when raw mode. diff --git a/signal.c b/signal.c index 6b2d50563f..a4331a9f15 100644 --- a/signal.c +++ b/signal.c @@ -36,9 +36,7 @@ static struct signals { #ifdef SIGHUP {"HUP", SIGHUP}, #endif -#ifdef SIGINT {"INT", SIGINT}, -#endif #ifdef SIGQUIT {"QUIT", SIGQUIT}, #endif 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; } }