diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-09 15:07:34 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-09 15:07:34 +0000 |
commit | 5869de449fe535321a1f43d3ca59c22cdf610e9e (patch) | |
tree | 5d45215c48d8c4ea579d2c333e092e43759e1dc1 | |
parent | d124dcf4eb245ced006ff4a3817322d8ecdbaea9 (diff) | |
download | ruby-5869de449fe535321a1f43d3ca59c22cdf610e9e.tar.gz |
* ext/pty/lib/expect.rb: preserve buffer read, instead of discard.
based on a patch from Luiz Angelo Daros de Luca in
[ruby-core:23464].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/pty/lib/expect.rb | 9 |
2 files changed, 13 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Sat Apr 10 00:01:51 2010 Yusuke Endoh <mame@tsg.ne.jp> + + * ext/pty/lib/expect.rb: preserve buffer read, instead of discard. + based on a patch from Luiz Angelo Daros de Luca in + [ruby-core:23464]. + Fri Apr 9 23:58:58 2010 Yusuke Endoh <mame@tsg.ne.jp> * ext/pty/lib/expect.rb: raise an error when argument is unexpected diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb index 52396d90bd..54cf709ee2 100644 --- a/ext/pty/lib/expect.rb +++ b/ext/pty/lib/expect.rb @@ -17,12 +17,17 @@ class IO else raise TypeError, "unsupported pattern class: #{pattern.class}" end + @unusedBuf ||= '' while true - if !IO.select([self],nil,nil,timeout) or eof? then + if not @unusedBuf.empty? + c = @unusedBuf.slice!(0).chr + elsif !IO.select([self],nil,nil,timeout) or eof? then result = nil + @unusedBuf = buf break + else + c = getc.chr end - c = getc.chr buf << c if $expect_verbose STDOUT.print c |