diff --git a/ChangeLog b/ChangeLog index d1d03204fb..a8def61f71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 2 14:11:07 2009 Tanaka Akira + + * 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 * signal.c (rb_signal_buff_size): defined for check whether signal diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 82718b400e..5b5b74105e 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -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 diff --git a/ext/socket/socket.c b/ext/socket/socket.c index b50747a5e1..0f6f9e8a03 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -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 {