зеркало из https://github.com/github/ruby.git
* 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:
Родитель
818d6a1e4f
Коммит
9fad82a6ba
|
@ -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
14
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);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче