summaryrefslogtreecommitdiff
path: root/ext/etc/mkconstants.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/etc/mkconstants.rb')
-rw-r--r--ext/etc/mkconstants.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/etc/mkconstants.rb b/ext/etc/mkconstants.rb
index 18f34c9..69b472d 100644
--- a/ext/etc/mkconstants.rb
+++ b/ext/etc/mkconstants.rb
@@ -66,7 +66,15 @@ def each_name(pat)
}
end
-ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+erb_new = lambda do |src, safe, trim|
+ if RUBY_VERSION >= '2.6'
+ ERB.new(src, trim_mode: trim)
+ else
+ ERB.new(src, safe, trim)
+ end
+end
+
+erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% each_const {|name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
@@ -80,7 +88,7 @@ ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
% }
EOS
-ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% each_const {|name, default_value|
#if defined(<%=name%>)
% if comment = COMMENTS[name]
@@ -91,13 +99,13 @@ ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
% }
EOS
-header_result = ERB.new(<<'EOS', nil, '%').result(binding)
+header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
EOS
-result = ERB.new(<<'EOS', nil, '%').result(binding)
+result = erb_new.call(<<'EOS', nil, '%').result(binding)
/* autogenerated file */
#ifdef HAVE_LONG_LONG