summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index c530387df7..695ccc743e 100644
--- a/dir.c
+++ b/dir.c
@@ -486,8 +486,12 @@ dir_inspect(VALUE dir)
TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dirp);
if (!NIL_P(dirp->path)) {
- const char *c = rb_obj_classname(dir);
- return rb_sprintf("#<%s:%s>", c, RSTRING_PTR(dirp->path));
+ VALUE str = rb_str_new_cstr("#<");
+ rb_str_append(str, rb_class_name(CLASS_OF(dir)));
+ rb_str_cat2(str, ":");
+ rb_str_append(str, dirp->path);
+ rb_str_cat2(str, ">");
+ return str;
}
return rb_funcall(dir, rb_intern("to_s"), 0, 0);
}