summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-02 05:12:14 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-02 05:12:14 +0000
commit90a65796e78c99696a39a1fcda344bf4e3cb8856 (patch)
tree28b44ea597c661fe7b45a9079378a15a021de1dd /ext
parentd4b3e8ae70590a92ec5051edbaf9382923301497 (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/mkconstants.rb12
-rw-r--r--ext/socket/socket.c2
2 files changed, 7 insertions, 7 deletions
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 {