1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/socket/mkconstants.rb (gen_int_to_name): add lenp argument.

* ext/socket/socket.c (ipaddr): follow argument change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-01-02 05:12:14 +00:00
parent d4b3e8ae70
commit 90a65796e7
3 changed files with 13 additions and 7 deletions

View file

@ -1,3 +1,9 @@
Fri Jan 2 14:11:07 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb (gen_int_to_name): add lenp argument.
* ext/socket/socket.c (ipaddr): follow argument change.
Fri Jan 2 06:43:58 2009 NARUSE, Yui <naruse@ruby-lang.org>
* signal.c (rb_signal_buff_size): defined for check whether signal

View file

@ -103,14 +103,14 @@ def each_alias(pat)
yield names
end
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name(int_var, pat)")
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name(int_var, lenp_var, pat)")
switch (<%=int_var%>) {
% each_alias(pat) {|names|
% names.each_with_index {|n, i|
% cond = ["defined(#{n})"]
% (0...i).each {|j| cond << "(!defined(#{names[j]}) || #{n} != #{names[j]})" }
#if <%=cond.join(" && ")%>
case <%=n%>: return <%=c_str n%>;
case <%=n%>: if (<%=lenp_var%>) *<%=lenp_var%> = <%=n.bytesize%>; return <%=c_str n%>;
#endif
% }
% }
@ -190,9 +190,9 @@ udp_optname_to_int(char *str, int len, int *valp)
}
static char *
family_to_str(int val)
family_to_str(int val, int *lenp)
{
<%= gen_int_to_name("val", /\AAF_/) %>
<%= gen_int_to_name("val", "lenp", /\AAF_/) %>
}
EOS
@ -214,6 +214,8 @@ SOCK_RDM
SOCK_SEQPACKET
SOCK_PACKET
AF_UNSPEC
PF_UNSPEC
AF_INET
PF_INET
AF_INET6
@ -226,8 +228,6 @@ AF_IPX
PF_IPX
AF_APPLETALK
PF_APPLETALK
AF_UNSPEC
PF_UNSPEC
AF_LOCAL
PF_LOCAL
AF_IMPLINK

View file

@ -1063,7 +1063,7 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
char hbuf[1024], pbuf[1024];
char *name;
name = family_to_str(sockaddr->sa_family);
name = family_to_str(sockaddr->sa_family, NULL);
if (name)
family = rb_str_new2(name);
else {