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

ruby-changes:15385

From: mame <ko1@a...>
Date: Sat, 10 Apr 2010 00:10:01 +0900 (JST)
Subject: [ruby-changes:15385] Ruby:r27277 (trunk): * ext/pty/lib/expect.rb: preserve buffer read, instead of discard.

mame	2010-04-10 00:07:34 +0900 (Sat, 10 Apr 2010)

  New Revision: 27277

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

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

  Modified files:
    trunk/ChangeLog
    trunk/ext/pty/lib/expect.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27276)
+++ ChangeLog	(revision 27277)
@@ -1,3 +1,9 @@
+Sat Apr 10 00:01:51 2010  Yusuke Endoh  <mame@t...>
+
+	* 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@t...>
 
 	* ext/pty/lib/expect.rb: raise an error when argument is unexpected
Index: ext/pty/lib/expect.rb
===================================================================
--- ext/pty/lib/expect.rb	(revision 27276)
+++ ext/pty/lib/expect.rb	(revision 27277)
@@ -17,12 +17,17 @@
     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

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

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