mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (family_arg): accept symbols as well.
(socktype_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
31fa80dadd
commit
c6bbf28a9f
4 changed files with 23 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jan 2 00:58:40 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/socket.c (family_arg): accept symbols as well.
|
||||
(socktype_arg): ditto.
|
||||
|
||||
Fri Jan 2 00:49:44 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_getaddrinfo): use socktype_arg.
|
||||
|
|
|
@ -249,9 +249,13 @@ family_arg(VALUE domain)
|
|||
char *ptr;
|
||||
int ret;
|
||||
|
||||
tmp = rb_check_string_type(domain);
|
||||
if (!NIL_P(tmp)) {
|
||||
if (SYMBOL_P(domain)) {
|
||||
domain = rb_sym_to_s(domain);
|
||||
goto str;
|
||||
}
|
||||
else if (!NIL_P(tmp = rb_check_string_type(domain))) {
|
||||
domain = tmp;
|
||||
str:
|
||||
rb_check_safe_obj(domain);
|
||||
ptr = RSTRING_PTR(domain);
|
||||
if (family_to_int(ptr, RSTRING_LEN(domain), &ret) == -1)
|
||||
|
@ -271,9 +275,13 @@ socktype_arg(VALUE type)
|
|||
char *ptr;
|
||||
int ret;
|
||||
|
||||
tmp = rb_check_string_type(type);
|
||||
if (!NIL_P(tmp)) {
|
||||
if (SYMBOL_P(type)) {
|
||||
type = rb_sym_to_s(type);
|
||||
goto str;
|
||||
}
|
||||
else if (!NIL_P(tmp = rb_check_string_type(type))) {
|
||||
type = tmp;
|
||||
str:
|
||||
rb_check_safe_obj(type);
|
||||
ptr = RSTRING_PTR(type);
|
||||
if (socktype_to_int(ptr, RSTRING_LEN(type), &ret) == -1)
|
||||
|
|
|
@ -109,6 +109,11 @@ class TestSocket < Test::Unit::TestCase
|
|||
assert_nothing_raised { Socket.unpack_sockaddr_in(addr) }
|
||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
|
||||
}
|
||||
Socket.open(:AF_INET, :SOCK_STREAM, 0) {|s|
|
||||
addr = s.getsockname
|
||||
assert_nothing_raised { Socket.unpack_sockaddr_in(addr) }
|
||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
|
||||
}
|
||||
end
|
||||
|
||||
def test_getaddrinfo
|
||||
|
|
|
@ -10,6 +10,7 @@ class TestUDPSocket < Test::Unit::TestCase
|
|||
assert_nothing_raised { UDPSocket.open {} }
|
||||
assert_nothing_raised { UDPSocket.open(Socket::AF_INET) {} }
|
||||
assert_nothing_raised { UDPSocket.open("AF_INET") {} }
|
||||
assert_nothing_raised { UDPSocket.open(:AF_INET) {} }
|
||||
if defined? Socket::AF_INET6
|
||||
assert_nothing_raised { UDPSocket.open(Socket::AF_INET6) {} }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue