* io.c (rb_io_inspect): show the path also at a closed file.

[ruby-dev:21851]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-11-06 09:05:11 +00:00
parent 818d6a1e4f
commit 9fad82a6ba
2 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Thu Nov 6 18:05:07 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_set_string, strio_reopen): check

14
io.c
View File

@ -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);
}