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

ruby-changes:64523

From: aycabta <ko1@a...>
Date: Wed, 23 Dec 2020 22:15:42 +0900 (JST)
Subject: [ruby-changes:64523] 28e9344fa4 (master): [ruby/irb] Change StdioInputMethod#eof? to non-blocking

https://git.ruby-lang.org/ruby.git/commit/?id=28e9344fa4

From 28e9344fa49387ef84c71a72d1ba7e32b61cf4c7 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Wed, 23 Dec 2020 20:29:57 +0900
Subject: [ruby/irb] Change StdioInputMethod#eof? to non-blocking

This fixes --inf-ruby-mode.

https://github.com/ruby/irb/commit/0e4a818955

diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 6e87488..61540a1 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -83,7 +83,15 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L83
     #
     # See IO#eof? for more information.
     def eof?
-      @stdin.eof?
+      rs, = IO.select([@stdin], [], [], 0.00001)
+      if rs and rs[0]
+        c = @stdin.getc
+        result = c.nil? ? true : false
+        @stdin.ungetc(c) unless c.nil?
+        result
+      else # buffer is empty
+        false
+      end
     end
 
     # Whether this input method is still readable when there is no more data to
-- 
cgit v0.10.2


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

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