diff --git a/ChangeLog b/ChangeLog index 69db729abb..4e178c6a76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada + + * io.c (rb_io_check_initialized): new function to check uninitialized + object. [ruby-talk:118234] + + * file.c (rb_file_path), io.c (rb_io_closed): check if initialized. + Fri Oct 29 19:05:33 2004 NARUSE, Yui * ext/nkf: follow nkf2.0. diff --git a/file.c b/file.c index bf2e34fdb6..1238067bb0 100644 --- a/file.c +++ b/file.c @@ -138,6 +138,7 @@ rb_file_path(obj) OpenFile *fptr; 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); } diff --git a/io.c b/io.c index 414e70e413..3fa254a2fa 100644 --- a/io.c +++ b/io.c @@ -182,12 +182,19 @@ rb_io_taint_check(io) } void -rb_io_check_closed(fptr) +rb_io_check_initialized(fptr) OpenFile *fptr; { if (!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"); } @@ -941,7 +948,7 @@ rb_io_fread(ptr, len, f) ptr += c; if ((n -= c) <= 0) break; } - rb_thread_wait_fd(fileno(f)); + rb_thread_wait_fd(fileno(f)); TRAP_BEG; c = getc(f); TRAP_END; @@ -2028,6 +2035,7 @@ rb_io_closed(io) OpenFile *fptr; fptr = RFILE(io)->fptr; + rb_io_check_initialized(fptr); return (fptr->f || fptr->f2)?Qfalse:Qtrue; } diff --git a/rubyio.h b/rubyio.h index 0b77fa1794..f56cec4c40 100644 --- a/rubyio.h +++ b/rubyio.h @@ -69,6 +69,7 @@ void rb_io_check_writable _((OpenFile*)); 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)); int rb_io_wait_writable _((int));