diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -742,7 +742,6 @@ rb_io_eof(io) GetOpenFile(io, fptr); rb_io_check_readable(fptr); - if (feof(fptr->f)) return Qtrue; if (READ_DATA_PENDING(fptr->f)) return Qfalse; READ_CHECK(fptr->f); TRAP_BEG; @@ -1045,7 +1044,6 @@ remain_size(fptr) off_t siz = BUFSIZ; off_t pos; - if (feof(fptr->f)) return 0; if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode) #ifdef __BEOS__ && (st.st_dev > 3) @@ -1086,7 +1084,10 @@ read_all(fptr, siz, str) rb_str_unlocktmp(str); if (n == 0 && bytes == 0) { if (!fptr->f) break; - if (feof(fptr->f)) break; + if (feof(fptr->f)) { + clearerr(fptr->f); + break; + } if (!ferror(fptr->f)) break; rb_sys_fail(fptr->path); } @@ -1275,7 +1276,6 @@ io_read(argc, argv, io) GetOpenFile(io, fptr); rb_io_check_readable(fptr); - if (feof(fptr->f)) return Qnil; if (len == 0) return str; rb_str_locktmp(str); @@ -1288,6 +1288,7 @@ io_read(argc, argv, io) if (n == 0) { if (!fptr->f) return Qnil; if (feof(fptr->f)) { + clearerr(fptr->f); rb_str_resize(str, 0); return Qnil; } @@ -1365,6 +1366,7 @@ appendline(fptr, delim, strp) rb_sys_fail(fptr->path); continue; } + clearerr(fptr->f); #ifdef READ_DATA_PENDING_PTR return c; #endif @@ -1440,6 +1442,9 @@ swallow(fptr, term) return Qtrue; } } while (c != EOF); + if (!ferror(f)) { + clearerr(f); + } return Qfalse; } @@ -1806,6 +1811,7 @@ rb_io_each_byte(io) rb_sys_fail(fptr->path); continue; } + clearerr(f); break; } rb_yield(INT2FIX(c & 0xff)); @@ -1851,6 +1857,7 @@ rb_io_getc(io) rb_sys_fail(fptr->path); goto retry; } + clearerr(f); return Qnil; } return INT2FIX(c & 0xff); |