[前][次][番号順一覧][スレッド一覧]

ruby-changes:10174

From: nobu <ko1@a...>
Date: Wed, 21 Jan 2009 21:42:55 +0900 (JST)
Subject: [ruby-changes:10174] Ruby:r21718 (trunk): * io.c (rb_io_ungetbyte, rb_io_ungetc): allows nil to reset EOF

nobu	2009-01-21 21:42:39 +0900 (Wed, 21 Jan 2009)

  New Revision: 21718

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21718

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/ruby.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21717)
+++ ChangeLog	(revision 21718)
@@ -1,3 +1,11 @@
+Wed Jan 21 21:43:50 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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  <nobu@r...>
 
 	* io.c (rb_io_ungetbyte, rb_io_ungetc): clears EOF flag.
Index: io.c
===================================================================
--- io.c	(revision 21717)
+++ io.c	(revision 21718)
@@ -2860,6 +2860,7 @@
 
     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);
@@ -2869,7 +2870,6 @@
 	SafeStringValue(b);
     }
     io_ungetbyte(b, fptr);
-    io_unset_eof(fptr);
     return Qnil;
 }
 
@@ -2897,6 +2897,7 @@
 
     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);
@@ -2926,7 +2927,6 @@
     else {
         io_ungetbyte(c, fptr);
     }
-    io_unset_eof(fptr);
     return Qnil;
 }
 
Index: ruby.c
===================================================================
--- ruby.c	(revision 21717)
+++ ruby.c	(revision 21718)
@@ -1581,6 +1581,7 @@
 	    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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]