diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-22 10:28:47 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-02-22 10:28:47 +0000 |
commit | 088d04d88e8948812038e1297d449ba12224066e (patch) | |
tree | 8fd2474ff94ff56ffd5f630c5d00c2fac1fa9a4f /io.c | |
parent | 9ce732561568d940e9ddf2cf6cf798b3dc65ccd7 (diff) |
* bignum.c (get2comp): need to specify to carry or not.
* io.c (rb_io_inspect): embed path info.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -491,6 +491,21 @@ rb_io_pid(io) } static VALUE +rb_io_inspect(obj) + VALUE obj; +{ + OpenFile *fptr; + char *buf, *cname; + + GetOpenFile(obj, fptr); + if (!fptr->path) return rb_any_to_s(obj); + cname = rb_class2name(CLASS_OF(obj)); + buf = ALLOCA_N(char, strlen(cname) + strlen(fptr->path) + 5); + sprintf(buf, "#<%s:%s>", cname, fptr->path); + return rb_str_new2(buf); +} + +static VALUE rb_io_to_io(io) VALUE io; { @@ -3691,6 +3706,7 @@ Init_IO() rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1); rb_define_method(rb_cIO, "fcntl", rb_io_fcntl, -1); rb_define_method(rb_cIO, "pid", rb_io_pid, 0); + rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0); rb_stdin = orig_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO); rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_stdin); |