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

ruby-changes:4766

From: ko1@a...
Date: Fri, 2 May 2008 00:10:43 +0900 (JST)
Subject: [ruby-changes:4766] jeg2 - Ruby:r16260 (ruby_1_8): Merged 16257 from trunk.

jeg2	2008-05-02 00:09:29 +0900 (Fri, 02 May 2008)

  New Revision: 16260

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/net/telnet.rb

  Log:
    Merged 16257 from trunk.
    
    * lib/net/telnet.rb:  This patch from Brian Candler adds a FailEOF mode which
      can be activated to have net/telnet raise EOFError exceptions when the 
      remote connection is closed.  The default behavior remains unchanged though.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16260&r2=16259&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/net/telnet.rb?r1=16260&r2=16259&diff_format=u

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 16259)
+++ ruby_1_8/ChangeLog	(revision 16260)
@@ -1,3 +1,11 @@
+Thu May  1 23:57:06 2008  James Edward Gray II  <jeg2@r...>
+
+  Merged 16257 from trunk.
+
+	* lib/net/telnet.rb:  This patch from Brian Candler adds a FailEOF mode which
+	  can be activated to have net/telnet raise EOFError exceptions when the 
+	  remote connection is closed.  The default behavior remains unchanged though.
+
 Thu May  1 23:43:21 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* range.c (range_step): check if step can be converted to an integer.
Index: ruby_1_8/lib/net/telnet.rb
===================================================================
--- ruby_1_8/lib/net/telnet.rb	(revision 16259)
+++ ruby_1_8/lib/net/telnet.rb	(revision 16260)
@@ -520,10 +520,15 @@
     #            value specified when this instance was created will be
     #            used, or, failing that, the default value of 0 seconds,
     #            which means not to wait for more input.
+    # FailEOF:: if true, when the remote end closes the connection then an
+    #           EOFError will be raised. Otherwise, defaults to the old
+    #           behaviour that the function will return whatever data
+    #           has been received already, or nil if nothing was received.
     #           
     def waitfor(options) # :yield: recvdata
       time_out = @options["Timeout"]
       waittime = @options["Waittime"]
+      fail_eof = @options["FailEOF"]
 
       if options.kind_of?(Hash)
         prompt   = if options.has_key?("Match")
@@ -535,6 +540,7 @@
                    end
         time_out = options["Timeout"]  if options.has_key?("Timeout")
         waittime = options["Waittime"] if options.has_key?("Waittime")
+        fail_eof = options["FailEOF"]  if options.has_key?("FailEOF")
       else
         prompt = options
       end
@@ -586,6 +592,7 @@
           line += buf
           yield buf if block_given?
         rescue EOFError # End of file reached
+          raise if fail_eof
           if line == ''
             line = nil
             yield nil if block_given?

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

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