diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-02 05:33:56 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-02 05:33:56 +0000 |
commit | 270f2034a71cecc3361920d5ff609bda41ecef8f (patch) | |
tree | 8a31ea0bb015203f3c720bd02b3978504bb92edd /ext/socket | |
parent | 90a65796e78c99696a39a1fcda344bf4e3cb8856 (diff) | |
download | ruby-270f2034a71cecc3361920d5ff609bda41ecef8f.tar.gz |
* ext/socket/mkconstants.rb (gen_int_to_name): don't compare constants
in preprocessor because the constants may be enum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/mkconstants.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 5b5b74105e..32b99d2fe3 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) |