--- io.c.orig 2009-11-25 08:45:13.000000000 +0000 +++ io.c @@ -488,7 +488,16 @@ io_fwrite(str, fptr) r = write(fileno(f), RSTRING(str)->ptr+offset, l); TRAP_END; #if BSD_STDIO - fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET); + { + int saved_errno; + off_t pos; + + saved_errno = errno; + pos = lseek(fileno(f), (off_t)0, SEEK_CUR); + if (pos != -1) + fseeko(f, pos, SEEK_SET); + errno = saved_errno; + } #endif if (r == n) return len; if (0 <= r) { @@ -1297,8 +1306,13 @@ io_getpartial(int argc, VALUE *argv, VAL goto again; rb_sys_fail(fptr->path); } - if (fptr->f) /* update pos in FILE structure [ruby-core:21561] */ + if (fptr->f) { /* update pos in FILE structure [ruby-core:21561] */ fflush(fptr->f); +#if defined(__SOFF) && defined(__NetBSD__) + fptr->f->_flags &= ~__SOFF; + (void)io_tell(fptr); +#endif + } } rb_str_resize(str, n);