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

ruby-changes:62898

From: aycabta <ko1@a...>
Date: Sat, 12 Sep 2020 08:38:49 +0900 (JST)
Subject: [ruby-changes:62898] 2e34b35a0f (master): [ruby/reline] Skip the nil obtained from getc

https://git.ruby-lang.org/ruby.git/commit/?id=2e34b35a0f

From 2e34b35a0ff7c326d1260a7f4dd3e4a9febe3d12 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Sat, 5 Sep 2020 21:13:47 +0900
Subject: [ruby/reline] Skip the nil obtained from getc

The nil means there is nothing in the buffer in some systems. Incidentally,
Errno::EIO is raised if the I/O is closed.

https://github.com/ruby/reline/commit/c698634e74

diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb
index d2c3289..8b6b10c 100644
--- a/lib/reline/ansi.rb
+++ b/lib/reline/ansi.rb
@@ -65,7 +65,9 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L65
     unless @@buf.empty?
       return @@buf.shift
     end
-    c = @@input.raw(intr: true, &:getbyte)
+    until c = @@input.raw(intr: true, &:getbyte)
+      sleep 0.1
+    end
     (c == 0x16 && @@input.raw(min: 0, tim: 0, &:getbyte)) || c
   rescue Errno::EIO
     # Maybe the I/O has been closed.
@@ -112,7 +114,9 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L114
       @@input.raw do |stdin|
         @@output << "\e[6n"
         @@output.flush
-        while (c = stdin.getc)
+        loop do
+          c = stdin.getc
+          next if c.nil?
           res << c
           m = res.match(/\e\[(?<row>\d+);(?<column>\d+)R/)
           break if m
-- 
cgit v0.10.2


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

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