summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-29 12:28:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-29 12:28:32 +0000
commit99be646a7f22dbc7be24b871cb950bf65414f9d5 (patch)
tree9dbdd9a7fccf3c6553f142c51ad80d3a601cf27f
parent383723abc852fc7d7987e498b55c6e78697dbdaf (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--file.c1
-rw-r--r--io.c12
-rw-r--r--rubyio.h1
4 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 34246707c3..3e5416db12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_start_0): forget to free some memory chunks.
diff --git a/file.c b/file.c
index c9aa494143..066745ca6a 100644
--- a/file.c
+++ b/file.c
@@ -113,6 +113,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 87cd6a8b5e..2de3de7f44 100644
--- a/io.c
+++ b/io.c
@@ -183,12 +183,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)
if (len > n) {
clearerr(f);
}
- rb_thread_wait_fd(fileno(f));
+ rb_thread_wait_fd(fileno(f));
}
if (len == n) return 0;
}
@@ -1889,6 +1896,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 7130be7666..44f679494e 100644
--- a/rubyio.h
+++ b/rubyio.h
@@ -67,6 +67,7 @@ void rb_io_check_writable _((OpenFile*));
void rb_io_check_readable _((OpenFile*));
void 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));