summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-27 14:31:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-27 14:31:19 +0000
commita67f1a9534322914367d6eb17eb01badd87e7f79 (patch)
tree23bef858db62ea6eba371eb345716415bf3ffb3c /io.c
parentd9edd4ca87bff687dc9548de6517792443746ddd (diff)
* include/ruby/io.h, io.c: reverted r21709.
* ruby.c (load_file_internal): nothing to read if EOF reached while reading shebang. [ruby-core:30910] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/io.c b/io.c
index 48634d306b..05b2d45832 100644
--- a/io.c
+++ b/io.c
@@ -398,9 +398,7 @@ flush_before_seek(rb_io_t *fptr)
return fptr;
}
-#define io_set_eof(fptr) (void)(((fptr)->mode & FMODE_TTY) && ((fptr)->mode |= FMODE_EOF))
-#define io_unset_eof(fptr) (fptr->mode &= ~FMODE_EOF)
-#define io_seek(fptr, ofs, whence) (errno = 0, io_unset_eof(fptr), lseek(flush_before_seek(fptr)->fd, ofs, whence))
+#define io_seek(fptr, ofs, whence) (errno = 0, lseek(flush_before_seek(fptr)->fd, ofs, whence))
#define io_tell(fptr) lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)
#ifndef SEEK_CUR
@@ -1203,9 +1201,6 @@ io_fillbuf(rb_io_t *fptr)
{
ssize_t r;
- if (fptr->mode & FMODE_EOF) {
- return -1;
- }
if (fptr->rbuf == NULL) {
fptr->rbuf_off = 0;
fptr->rbuf_len = 0;
@@ -1224,10 +1219,8 @@ io_fillbuf(rb_io_t *fptr)
}
fptr->rbuf_off = 0;
fptr->rbuf_len = (int)r; /* r should be <= rbuf_capa */
- if (r == 0) {
- io_set_eof(fptr);
+ if (r == 0)
return -1; /* EOF */
- }
}
return 0;
}
@@ -1533,10 +1526,7 @@ io_fread(VALUE str, long offset, rb_io_t *fptr)
while (n > 0) {
again:
c = rb_read_internal(fptr->fd, RSTRING_PTR(str)+offset, n);
- if (c == 0) {
- io_set_eof(fptr);
- break;
- }
+ if (c == 0) break;
if (c < 0) {
if (rb_io_wait_readable(fptr->fd))
goto again;
@@ -1870,9 +1860,6 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
rb_mod_sys_fail(rb_mWaitReadable, "read would block");
rb_sys_fail_path(fptr->pathv);
}
- else if (n == 0) {
- io_set_eof(fptr);
- }
}
rb_str_resize(str, n);
@@ -3154,7 +3141,6 @@ rb_io_ungetbyte(VALUE io, VALUE b)
GetOpenFile(io, fptr);
rb_io_check_byte_readable(fptr);
- io_unset_eof(fptr);
if (NIL_P(b)) return Qnil;
if (FIXNUM_P(b)) {
char cc = FIX2INT(b);
@@ -3191,7 +3177,6 @@ rb_io_ungetc(VALUE io, VALUE c)
GetOpenFile(io, fptr);
rb_io_check_char_readable(fptr);
- io_unset_eof(fptr);
if (NIL_P(c)) return Qnil;
if (FIXNUM_P(c)) {
int cc = FIX2INT(c);