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

ruby-changes:34652

From: usa <ko1@a...>
Date: Mon, 7 Jul 2014 12:17:37 +0900 (JST)
Subject: [ruby-changes:34652] usa:r46735 (ruby_2_0_0): merge revision(s) 46457, 46458: [Backport #9949]

usa	2014-07-07 12:17:25 +0900 (Mon, 07 Jul 2014)

  New Revision: 46735

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

  Log:
    merge revision(s) 46457,46458: [Backport #9949]
    
    * lib/net/ftp.rb (gets, readline): read lines without LF properly.
      [ruby-core:63205] [Bug #9949]
    
    * test/net/ftp/test_buffered_socket.rb: related test.

  Added files:
    branches/ruby_2_0_0/test/net/ftp/test_buffered_socket.rb
  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/lib/net/ftp.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46734)
+++ ruby_2_0_0/ChangeLog	(revision 46735)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Jul  7 12:16:54 2014  Shugo Maeda  <shugo@r...>
+
+	* lib/net/ftp.rb (gets, readline): read lines without LF properly.
+	  [ruby-core:63205] [Bug #9949]
+
+	* test/net/ftp/test_buffered_socket.rb: related test.
+
 Mon Jul  7 12:13:09 2014  Shugo Maeda  <shugo@r...>
 
 	* lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body
Index: ruby_2_0_0/lib/net/ftp.rb
===================================================================
--- ruby_2_0_0/lib/net/ftp.rb	(revision 46734)
+++ ruby_2_0_0/lib/net/ftp.rb	(revision 46735)
@@ -1102,13 +1102,16 @@ module Net https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/net/ftp.rb#L1102
       end
 
       def gets
-        return readuntil("\n")
-      rescue EOFError
-        return nil
+        line = readuntil("\n", true)
+        return line.empty? ? nil : line
       end
 
       def readline
-        return readuntil("\n")
+        line = gets
+        if line.nil?
+          raise EOFError, "end of file reached"
+        end
+        return line
       end
     end
     # :startdoc:
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46734)
+++ ruby_2_0_0/version.h	(revision 46735)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-07-07"
-#define RUBY_PATCHLEVEL 519
+#define RUBY_PATCHLEVEL 520
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_0_0/test/net/ftp/test_buffered_socket.rb
===================================================================
--- ruby_2_0_0/test/net/ftp/test_buffered_socket.rb	(revision 0)
+++ ruby_2_0_0/test/net/ftp/test_buffered_socket.rb	(revision 46735)
@@ -0,0 +1,40 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/net/ftp/test_buffered_socket.rb#L1
+require "net/ftp"
+require "test/unit"
+require "ostruct"
+require "stringio"
+
+class FTPTest < Test::Unit::TestCase
+  def test_gets_empty
+    sock = create_buffered_socket("")
+    assert_equal(nil, sock.gets)
+  end
+
+  def test_gets_one_line
+    sock = create_buffered_socket("foo\n")
+    assert_equal("foo\n", sock.gets)
+  end
+
+  def test_gets_one_line_without_term
+    sock = create_buffered_socket("foo")
+    assert_equal("foo", sock.gets)
+  end
+
+  def test_gets_two_lines
+    sock = create_buffered_socket("foo\nbar\n")
+    assert_equal("foo\n", sock.gets)
+    assert_equal("bar\n", sock.gets)
+  end
+
+  def test_gets_two_lines_without_term
+    sock = create_buffered_socket("foo\nbar")
+    assert_equal("foo\n", sock.gets)
+    assert_equal("bar", sock.gets)
+  end
+
+  private
+
+  def create_buffered_socket(s)
+    io = StringIO.new(s)
+    return Net::FTP::BufferedSocket.new(io)
+  end
+end

Property changes on: ruby_2_0_0/test/net/ftp/test_buffered_socket.rb
___________________________________________________________________
Added: svn:eol-style
   + LF


Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46457-46458


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

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