diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-18 00:09:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-18 00:09:50 +0000 |
commit | 449873048fda87866e51fd61899814c06f0d6f82 (patch) | |
tree | 92397a667da83020f0ac8fea3a1378daa13db7aa /lib | |
parent | 017429c76c6b73061ff957f94871b6ef44d2d5c3 (diff) |
* lib/mkmf.rb (String#tr_cpp): make preprocessor identifiers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mkmf.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 5e981fba72..b90ee9a487 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -131,6 +131,9 @@ class String def quote /\s/ =~ self ? "\"#{self}\"" : self end + def tr_cpp + strip.upcase.tr_s("^A-Z0-9_", "_") + end end class Array def quote @@ -654,7 +657,7 @@ end def have_func(func, headers = nil, &b) checking_for checking_message("#{func}()", headers) do if try_func(func, $libs, headers, &b) - $defs.push(format("-DHAVE_%s", func.upcase)) + $defs.push(format("-DHAVE_%s", func.tr_cpp)) true else false @@ -673,7 +676,7 @@ end def have_var(var, headers = nil, &b) checking_for checking_message(var, headers) do if try_var(var, headers, &b) - $defs.push(format("-DHAVE_%s", var.upcase)) + $defs.push(format("-DHAVE_%s", var.tr_cpp)) true else false @@ -746,7 +749,7 @@ def have_struct_member(type, member, headers = nil, &b) int main() { return 0; } int s = (char *)&((#{type}*)0)->#{member} - (char *)0; SRC - $defs.push(format("-DHAVE_ST_%s", member.upcase)) + $defs.push(format("-DHAVE_ST_%s", member.tr_cpp)) true else false @@ -762,7 +765,7 @@ def try_type(type, headers = nil, opt = "", &b) typedef #{type} conftest_type; int conftestval[sizeof(conftest_type)?1:-1]; SRC - $defs.push(format("-DHAVE_TYPE_%s", type.strip.upcase.tr_s("^A-Z0-9_", "_"))) + $defs.push(format("-DHAVE_TYPE_%s", type.tr_cpp)) true else false @@ -817,7 +820,7 @@ def try_const(const, headers = nil, opt = "", &b) typedef #{type || 'int'} conftest_type; conftest_type conftestval = #{type ? '' : '(int)'}#{const}; SRC - $defs.push(format("-DHAVE_CONST_%s", const.strip.upcase.tr_s("^A-Z0-9_", "_"))) + $defs.push(format("-DHAVE_CONST_%s", const.tr_cpp)) true else false @@ -864,7 +867,7 @@ def check_sizeof(type, headers = nil, &b) end checking_for checking_message("size of #{type}", headers), fmt do if size = try_constant(expr, headers, &b) - $defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size)) + $defs.push(format("-DSIZEOF_%s=%d", type.tr_cpp, size)) size end end |