summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/socket/mkconstants.rb20
-rw-r--r--ext/socket/socket.c7
3 files changed, 21 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 224f4111a54..cd80d51d8a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jan 2 17:45:19 2009 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/mkconstants.rb: rename family_to_str to intern_family.
+ it returns ID now.
+
+ * ext/socket/socket.c (ipaddr): use intern_family.
+
Fri Jan 2 17:20:31 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb: use ID in the values of
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 83efde1cd47..9dce82495b4 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -144,18 +144,18 @@ ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pa
EOS
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
-static VALUE
+static ID
<%=func_name%>(int val)
{
st_data_t name;
if (st_lookup(<%=hash_var%>, (st_data_t)val, &name))
- return rb_id2str((ID)name);
- return Qnil;
+ return (ID)name;
+ return 0;
}
EOS
-STRINGIZER_DEFS = []
-def def_stringizer(func_name, pat, prefix_optional=nil)
+INTERN_DEFS = []
+def def_intern(func_name, pat, prefix_optional=nil)
prefix_pat = nil
if prefix_optional
if Regexp === prefix_optional
@@ -168,14 +168,14 @@ def def_stringizer(func_name, pat, prefix_optional=nil)
decl = "static st_table *#{hash_var};"
gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat)
func = gen_int_to_name_func(func_name, hash_var)
- STRINGIZER_DEFS << [decl, gen_hash, func]
+ INTERN_DEFS << [decl, gen_hash, func]
end
-def_stringizer('family_to_str', /\AAF_/)
+def_intern('intern_family', /\AAF_/)
result << ERB.new(<<'EOS', nil, '%').result(binding)
-<%= STRINGIZER_DEFS.map {|decl, gen_hash, func| decl }.join("\n") %>
+<%= INTERN_DEFS.map {|decl, gen_hash, func| decl }.join("\n") %>
static void
init_constants(VALUE mConst)
@@ -195,7 +195,7 @@ init_constants(VALUE mConst)
#endif
% end
% }
-<%= STRINGIZER_DEFS.map {|decl, gen_hash, func| gen_hash }.join("\n") %>
+<%= INTERN_DEFS.map {|decl, gen_hash, func| gen_hash }.join("\n") %>
}
static int
@@ -246,7 +246,7 @@ udp_optname_to_int(char *str, int len, int *valp)
<%= gen_name_to_int("str", "len", "valp", /\AUDP_/, "UDP_") %>
}
-<%= STRINGIZER_DEFS.map {|decl, gen_hash, func| func }.join("\n") %>
+<%= INTERN_DEFS.map {|decl, gen_hash, func| func }.join("\n") %>
EOS
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 76cb4ae0454..236356e828c 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1061,10 +1061,11 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
VALUE ary;
int error;
char hbuf[1024], pbuf[1024];
+ ID id;
- family = family_to_str(sockaddr->sa_family);
- if (!NIL_P(family)) {
- family = rb_str_dup(family);
+ id = intern_family(sockaddr->sa_family);
+ if (id) {
+ family = rb_str_dup(rb_id2str(id));
}
else {
sprintf(pbuf, "unknown:%d", sockaddr->sa_family);