ruby-changes:10495
From: akr <ko1@a...>
Date: Thu, 5 Feb 2009 01:20:16 +0900 (JST)
Subject: [ruby-changes:10495] Ruby:r22047 (trunk): * ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional.
akr 2009-02-05 01:20:05 +0900 (Thu, 05 Feb 2009) New Revision: 22047 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22047 Log: * ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional. * ext/socket/unixsocket.c (unix_s_socketpair): follow the above change. * ext/socket/rubysocket.h (sock_s_socketpair): ditto. Modified files: trunk/ChangeLog trunk/ext/socket/rubysocket.h trunk/ext/socket/socket.c trunk/ext/socket/unixsocket.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22046) +++ ChangeLog (revision 22047) @@ -1,3 +1,12 @@ +Thu Feb 5 01:18:25 2009 Tanaka Akira <akr@f...> + + * ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional. + + * ext/socket/unixsocket.c (unix_s_socketpair): follow the above + change. + + * ext/socket/rubysocket.h (sock_s_socketpair): ditto. + Thu Feb 5 00:09:39 2009 Tanaka Akira <akr@f...> * ext/socket/raddrinfo.c (addrinfo_ipv6_to_ipv4): new method. Index: ext/socket/rubysocket.h =================================================================== --- ext/socket/rubysocket.h (revision 22046) +++ ext/socket/rubysocket.h (revision 22047) @@ -212,7 +212,7 @@ int ruby_socket(int domain, int type, int proto); VALUE init_sock(VALUE sock, int fd); -VALUE sock_s_socketpair(VALUE klass, VALUE domain, VALUE type, VALUE protocol); +VALUE sock_s_socketpair(int argc, VALUE *argv, VALUE klass); VALUE init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type); VALUE init_unixsock(VALUE sock, VALUE path, int server); Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 22046) +++ ext/socket/socket.c (revision 22047) @@ -97,13 +97,18 @@ * */ VALUE -sock_s_socketpair(VALUE klass, VALUE domain, VALUE type, VALUE protocol) +sock_s_socketpair(int argc, VALUE *argv, VALUE klass) { #if defined HAVE_SOCKETPAIR + VALUE domain, type, protocol; int d, t, p, sp[2]; int ret; VALUE s1, s2, r; + rb_scan_args(argc, argv, "21", &domain, &type, &protocol); + if (NIL_P(protocol)) + protocol = INT2FIX(0); + setup_domain_and_type(domain, &d, type, &t); p = NUM2INT(protocol); ret = socketpair(d, t, p, sp); @@ -1760,8 +1765,8 @@ rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1); rb_define_method(rb_cSocket, "recvfrom_nonblock", sock_recvfrom_nonblock, -1); - rb_define_singleton_method(rb_cSocket, "socketpair", sock_s_socketpair, 3); - rb_define_singleton_method(rb_cSocket, "pair", sock_s_socketpair, 3); + rb_define_singleton_method(rb_cSocket, "socketpair", sock_s_socketpair, -1); + rb_define_singleton_method(rb_cSocket, "pair", sock_s_socketpair, -1); rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0); rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1); rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1); Index: ext/socket/unixsocket.c =================================================================== --- ext/socket/unixsocket.c (revision 22046) +++ ext/socket/unixsocket.c (revision 22047) @@ -463,6 +463,7 @@ { VALUE domain, type, protocol; domain = INT2FIX(PF_UNIX); + VALUE args[3]; rb_scan_args(argc, argv, "02", &type, &protocol); if (argc == 0) @@ -470,7 +471,11 @@ if (argc <= 1) protocol = INT2FIX(0); - return sock_s_socketpair(klass, domain, type, protocol); + args[0] = domain; + args[1] = type; + args[2] = protocol; + + return sock_s_socketpair(3, args, klass); } #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/