diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 17:20:24 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 17:20:24 +0000 |
commit | 57bb055c9334b2778b7a1b7469ce9be70f50bd4b (patch) | |
tree | 8de47768f6f3a41a8ca804569ef417a5255e8047 /io.c | |
parent | 574b3297480dac8256ff3faaf02bdf61ab5e4623 (diff) | |
download | ruby-57bb055c9334b2778b7a1b7469ce9be70f50bd4b.tar.gz |
* io.c (io_unread): adhoc workaround for non-binary mode of some DOSish
platforms. this is not perfect and safety, but works with most cases.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -284,7 +284,19 @@ io_unread(rb_io_t *fptr) if (fptr->rbuf_len == 0 || fptr->mode & FMODE_DUPLEX) return; /* xxx: target position may be negative if buffer is filled by ungetc */ +#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__) + if (!(fptr->mode & FMODE_BINMODE)) { + int len = fptr->rbuf_len; + while (fptr->rbuf_len-- > 0) { + if (fptr->rbuf[fptr->rbuf_len] == '\n') + ++len; + } + r = lseek(fptr->fd, -len, SEEK_CUR); + } + else +#else r = lseek(fptr->fd, -fptr->rbuf_len, SEEK_CUR); +#endif if (r < 0) { if (errno == ESPIPE) fptr->mode |= FMODE_DUPLEX; |