diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-05-12 07:28:16 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-05-12 07:28:16 +0000 |
commit | 84eca25a328b2ae05b68b5cf4dd9b8bad2ab4647 (patch) | |
tree | a9f7ebb1a8fd54deb6f0b162e356b28de9c4d23b /io.c | |
parent | bdbbf18c4a93547fbd648f405ec4f19f943124f8 (diff) | |
download | ruby-84eca25a328b2ae05b68b5cf4dd9b8bad2ab4647.tar.gz |
* io.c (rb_io_eof, remain_size, read_all, io_read, appendline)
(swallow, rb_io_each_byte, rb_io_getc): don't rely EOF flag.
[ruby-talk:141527]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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); |