diff --git a/template/fake.rb.in b/template/fake.rb.in index 9177fb10c5..67eb6dcec0 100644 --- a/template/fake.rb.in +++ b/template/fake.rb.in @@ -9,19 +9,23 @@ while /\A(\w+)=(.*)/ =~ ARGV[0] end if inc = arg['i'] src = inc == '-' ? STDIN.read : File.read(inc) - def src.value(name) - eval(self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1]. - gsub(/#/, '\\#'). - gsub(/((?:\G|[^\\])(?:\\\\)*)\n/, '\1')) - end - arg['versions'] = version = {} - File.read(File.join(arg['srcdir'], 'version.c')). - scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|STR)\(([^()]*)\)/m) do |n, v| - version[n] = src.value(v) - end - arg['RUBY_DESCRIPTION_WITH_MJIT'] = src.value('description_with_mjit') - arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit') +else + src = "" end +def src.value(name) + unless val = self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1] + return + end + eval(val.gsub(/#/, '\\#').gsub(/((?:\G|[^\\])(?:\\\\)*)\n/, '\1')) +end +version = Hash.new {|h, v| h[v] || src.value(v)} +arg['versions'] = version +File.read(File.join(arg['srcdir'], 'version.c')). + scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v| + version[n] = arg[v] || (s ? "" : 0) +end +arg['RUBY_DESCRIPTION_WITH_MJIT'] = arg['description_with_mjit'] || "" +arg['RUBY_DESCRIPTION_WITH_YJIT'] = arg['description_with_yjit'] || "" %>baseruby="<%=arg['BASERUBY']%>" _\ =begin