summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-12-23 20:29:57 +0900
committeraycabta <aycabta@gmail.com>2020-12-23 22:08:30 +0900
commit28e9344fa49387ef84c71a72d1ba7e32b61cf4c7 (patch)
treeb930c0f9ca336f97407cd176bc37ae9e34ed3a83 /lib
parent129ecb43e54b3249734c69787f813d49ce995567 (diff)
[ruby/irb] Change StdioInputMethod#eof? to non-blocking
This fixes --inf-ruby-mode. https://github.com/ruby/irb/commit/0e4a818955
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/input-method.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 6e87488753..61540a106f 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -83,7 +83,15 @@ module IRB
#
# 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