ruby-changes:8288
From: shugo <ko1@a...>
Date: Fri, 17 Oct 2008 11:51:00 +0900 (JST)
Subject: [ruby-changes:8288] Ruby:r19816 (trunk): * ext/socket/socket.c (init_sock): sockets should be binmode.
shugo 2008-10-17 11:50:43 +0900 (Fri, 17 Oct 2008) New Revision: 19816 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19816 Log: * ext/socket/socket.c (init_sock): sockets should be binmode. * test/socket/test_tcp.rb (test_encoding): ditto. Modified files: trunk/ChangeLog trunk/ext/socket/socket.c trunk/test/socket/test_tcp.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19815) +++ ChangeLog (revision 19816) @@ -1,3 +1,9 @@ +Fri Oct 17 11:48:18 2008 Shugo Maeda <shugo@r...> + + * ext/socket/socket.c (init_sock): sockets should be binmode. + + * test/socket/test_tcp.rb (test_encoding): ditto. + Fri Oct 17 10:26:13 2008 NAKAMURA Usaku <usa@r...> * tool/insns2vm.rb: remove -Kn option in shebang line because it's Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 19815) +++ ext/socket/socket.c (revision 19816) @@ -241,9 +241,7 @@ MakeOpenFile(sock, fp); fp->fd = fd; fp->mode = FMODE_READWRITE|FMODE_DUPLEX; -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__EMX__) - fp->mode |= FMODE_BINMODE; -#endif + rb_io_binmode(sock); if (do_not_reverse_lookup) { fp->mode |= FMODE_NOREVLOOKUP; } Index: test/socket/test_tcp.rb =================================================================== --- test/socket/test_tcp.rb (revision 19815) +++ test/socket/test_tcp.rb (revision 19816) @@ -21,4 +21,23 @@ th.kill th.join end + + def test_encoding + svr = TCPServer.new("localhost", 0) + th = Thread.new { + c = svr.accept + c.write "foo\r\n" + c.close + } + addr = svr.addr + sock = TCPSocket.open(addr[2], addr[1]) + assert_equal(true, sock.binmode?) + s = sock.gets + assert_equal("foo\r\n", s) + assert_equal(Encoding.find("ASCII-8BIT"), s.encoding) + ensure + th.kill + th.join + sock.close if sock + end end if defined?(TCPSocket) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/