summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/mkconstants.rb20
2 files changed, 13 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a8def61f71d..30d91a0dbe9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 2 14:33:12 2009 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/mkconstants.rb (gen_int_to_name): don't compare constants
+ in preprocessor because the constants may be enum.
+
Fri Jan 2 14:11:07 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/mkconstants.rb (gen_int_to_name): add lenp argument.
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 5b5b74105ea..32b99d2fe3f 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -104,19 +104,15 @@ def each_alias(pat)
end
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%>: if (<%=lenp_var%>) *<%=lenp_var%> = <%=n.bytesize%>; return <%=c_str n%>;
-#endif
-% }
-% }
- default:
- return NULL;
+% each_name(pat) {|n|
+#ifdef <%=n%>
+ if (<%=int_var%> == <%=n%>) {
+ if (<%=lenp_var%>) *<%=lenp_var%> = <%=n.bytesize%>;
+ return <%=c_str n%>;
}
+#endif
+% }
+ return NULL;
EOS
result << ERB.new(<<'EOS', nil, '%').result(binding)