nobu.nokada
10/29/2004 10:27:00 AM
Hi,
At Fri, 29 Oct 2004 19:05:43 +0900,
ts wrote in [ruby-talk:118237]:
> >>>>> "l" == leon breedt <bitserf@gmail.com> writes:
>
> l> $stderr.puts self.path
>
> same with IO#closed?
Yes.
Index: file.c
===================================================================
RCS file: /cvs/ruby/src/ruby/file.c,v
retrieving revision 1.189
diff -U2 -p -d -r1.189 file.c
--- file.c 23 Oct 2004 15:40:58 -0000 1.189
+++ file.c 29 Oct 2004 10:15:05 -0000
@@ -139,4 +139,5 @@ rb_file_path(obj)
fptr = RFILE(rb_io_taint_check(obj))->fptr;
+ rb_io_check_initialized(fptr);
if (!fptr->path) return Qnil;
return rb_tainted_str_new2(fptr->path);
Index: io.c
===================================================================
RCS file: /cvs/ruby/src/ruby/io.c,v
retrieving revision 1.311
diff -U2 -p -d -r1.311 io.c
--- io.c 29 Oct 2004 01:06:36 -0000 1.311
+++ io.c 29 Oct 2004 10:15:59 -0000
@@ -183,5 +183,5 @@ rb_io_taint_check(io)
void
-rb_io_check_closed(fptr)
+rb_io_check_initialized(fptr)
OpenFile *fptr;
{
@@ -189,4 +189,11 @@ rb_io_check_closed(fptr)
rb_raise(rb_eIOError, "uninitialized stream");
}
+}
+
+void
+rb_io_check_closed(fptr)
+ OpenFile *fptr;
+{
+ rb_io_check_initialized(fptr);
if (!fptr->f && !fptr->f2) {
rb_raise(rb_eIOError, "closed stream");
@@ -2029,4 +2036,5 @@ rb_io_closed(io)
fptr = RFILE(io)->fptr;
+ rb_io_check_initialized(fptr);
return (fptr->f || fptr->f2)?Qfalse:Qtrue;
}
Index: rubyio.h
===================================================================
RCS file: /cvs/ruby/src/ruby/rubyio.h,v
retrieving revision 1.28
diff -U2 -p -d -r1.28 rubyio.h
--- rubyio.h 18 Oct 2004 02:29:43 -0000 1.28
+++ rubyio.h 29 Oct 2004 10:14:41 -0000
@@ -70,4 +70,5 @@ void rb_io_check_readable _((OpenFile*))
int rb_io_fptr_finalize _((OpenFile*));
void rb_io_synchronized _((OpenFile*));
+void rb_io_check_initialized _((OpenFile*));
void rb_io_check_closed _((OpenFile*));
int rb_io_wait_readable _((int));
--
Nobu Nakada