diff --git a/ChangeLog b/ChangeLog index 0572ef6b23..39b079f861 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 6 18:05:07 2003 Nobuyoshi Nakada + + * io.c (rb_io_inspect): show the path also at a closed file. + [ruby-dev:21851] + Thu Nov 6 11:42:07 2003 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_set_string, strio_reopen): check diff --git a/io.c b/io.c index 28504c9197..75c0227a1c 100644 --- a/io.c +++ b/io.c @@ -651,13 +651,19 @@ rb_io_inspect(obj) VALUE obj; { OpenFile *fptr; - char *buf, *cname; + char *buf, *cname, *st = ""; + long len; fptr = RFILE(rb_io_taint_check(obj))->fptr; - if (!fptr || !(fptr->f || fptr->f2) || !fptr->path) return rb_any_to_s(obj); + if (!fptr || !fptr->path) return rb_any_to_s(obj); cname = rb_obj_classname(obj); - buf = ALLOCA_N(char, strlen(cname) + strlen(fptr->path) + 5); - sprintf(buf, "#<%s:%s>", cname, fptr->path); + len = strlen(cname) + strlen(fptr->path) + 5; + if (!(fptr->f || fptr->f2)) { + st = " (closed)"; + len += 9; + } + buf = ALLOCA_N(char, len); + sprintf(buf, "#<%s:%s%s>", cname, fptr->path, st); return rb_str_new2(buf); }