From a298f32e615c5b5292a5c3b01c618b4ff7b64bc8 Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 28 Jan 2009 09:20:46 +0000 Subject: merges r21715 and r21718 from trunk into ruby_1_9_1. * io.c (rb_io_ungetbyte, rb_io_ungetc): clears EOF flag. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ io.c | 5 ++++- ruby.c | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 86a0832b6..d87ce2882 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Jan 21 21:43:50 2009 Nobuyoshi Nakada + + * io.c (rb_io_ungetbyte, rb_io_ungetc): allows nil to reset EOF + flag with ungetting nothing. + + * ruby.c (load_file_internal): rests EOF flag to make possible to + load from stdin after reading data. + +Wed Jan 21 15:32:15 2009 Nobuyoshi Nakada + + * io.c (rb_io_ungetbyte, rb_io_ungetc): clears EOF flag. + Wed Jan 21 13:58:17 2009 Nobuyoshi Nakada * include/ruby/io.h (FMODE_EOF): EOF flag on TTY. diff --git a/io.c b/io.c index d9abd6328..858472074 100644 --- a/io.c +++ b/io.c @@ -354,7 +354,8 @@ flush_before_seek(rb_io_t *fptr) } #define io_set_eof(fptr) (void)(((fptr)->mode & FMODE_TTY) && ((fptr)->mode |= FMODE_EOF)) -#define io_seek(fptr, ofs, whence) (fptr->mode &= ~FMODE_EOF, lseek(flush_before_seek(fptr)->fd, ofs, whence)) +#define io_unset_eof(fptr) (fptr->mode &= ~FMODE_EOF) +#define io_seek(fptr, ofs, whence) (io_unset_eof(fptr), lseek(flush_before_seek(fptr)->fd, ofs, whence)) #define io_tell(fptr) lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR) #ifndef SEEK_CUR @@ -2845,6 +2846,7 @@ rb_io_ungetbyte(VALUE io, VALUE b) GetOpenFile(io, fptr); rb_io_check_readable(fptr); + io_unset_eof(fptr); if (NIL_P(b)) return Qnil; if (FIXNUM_P(b)) { char cc = FIX2INT(b); @@ -2881,6 +2883,7 @@ rb_io_ungetc(VALUE io, VALUE c) GetOpenFile(io, fptr); rb_io_check_readable(fptr); + io_unset_eof(fptr); if (NIL_P(c)) return Qnil; if (FIXNUM_P(c)) { int cc = FIX2INT(c); diff --git a/ruby.c b/ruby.c index e97475775..9364d4b62 100644 --- a/ruby.c +++ b/ruby.c @@ -1552,6 +1552,7 @@ load_file_internal(VALUE arg) rb_io_ungetbyte(f, c); } require_libraries(opt); /* Why here? unnatural */ + rb_io_ungetbyte(f, Qnil); } if (opt->src.enc.index >= 0) { enc = rb_enc_from_index(opt->src.enc.index); -- cgit