summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/io.c b/io.c
index a0be6a9ef0..f76bf354f3 100644
--- a/io.c
+++ b/io.c
@@ -306,10 +306,6 @@ rb_io_eof(io)
rb_io_check_readable(fptr);
if (READ_DATA_PENDING(fptr->f)) return Qfalse;
-#if 0
- if (feof(fptr->f)) return Qtrue;
- return Qfalse;
-#else
READ_CHECK(fptr->f);
TRAP_BEG;
ch = getc(fptr->f);
@@ -320,7 +316,6 @@ rb_io_eof(io)
return Qfalse;
}
return Qtrue;
-#endif
}
static VALUE
@@ -811,6 +806,22 @@ rb_io_getc(io)
return INT2FIX(c & 0xff);
}
+int
+rb_getc(f)
+ FILE *f;
+{
+ int c;
+
+ if (!READ_DATA_PENDING(f)) {
+ rb_thread_wait_fd(fileno(f));
+ }
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+
+ return c;
+}
+
static VALUE
rb_io_readchar(io)
VALUE io;