mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Remove flip-flop usages from build scripts
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bf7a32d220
commit
301fa452f7
3 changed files with 49 additions and 33 deletions
|
@ -41,6 +41,7 @@ end
|
||||||
|
|
||||||
def prelude(f, out)
|
def prelude(f, out)
|
||||||
@exprs = {}
|
@exprs = {}
|
||||||
|
lex_state_def = false
|
||||||
while line = f.gets
|
while line = f.gets
|
||||||
case line
|
case line
|
||||||
when /\A%%/
|
when /\A%%/
|
||||||
|
@ -50,18 +51,24 @@ def prelude(f, out)
|
||||||
out << line.sub(/<\w+>/, '<val>')
|
out << line.sub(/<\w+>/, '<val>')
|
||||||
when /\A%type/
|
when /\A%type/
|
||||||
out << line.sub(/<\w+>/, '<val>')
|
out << line.sub(/<\w+>/, '<val>')
|
||||||
else
|
when /^enum lex_state_(?:bits|e) \{/
|
||||||
if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line)
|
lex_state_def = true
|
||||||
case line
|
|
||||||
when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\//
|
|
||||||
@exprs[$1.chomp("_bit")] = $2.strip
|
|
||||||
when /^\s*(EXPR_\w+)\s+=\s+(.+)$/
|
|
||||||
name = $1
|
|
||||||
val = $2.chomp(",")
|
|
||||||
@exprs[name] = "equals to " + (val.start_with?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
out << line
|
out << line
|
||||||
|
when /^\}/
|
||||||
|
lex_state_def = false
|
||||||
|
out << line
|
||||||
|
else
|
||||||
|
out << line
|
||||||
|
end
|
||||||
|
if lex_state_def
|
||||||
|
case line
|
||||||
|
when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\//
|
||||||
|
@exprs[$1.chomp("_bit")] = $2.strip
|
||||||
|
when /^\s*(EXPR_\w+)\s+=\s+(.+)$/
|
||||||
|
name = $1
|
||||||
|
val = $2.chomp(",")
|
||||||
|
@exprs[name] = "equals to " + (val.start_with?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,20 +40,28 @@ encdirs.each do |encdir|
|
||||||
files[fn] = true
|
files[fn] = true
|
||||||
open(File.join(encdir,fn)) do |f|
|
open(File.join(encdir,fn)) do |f|
|
||||||
name = nil
|
name = nil
|
||||||
|
skip_ifndef_ruby = false
|
||||||
|
encoding_def = false
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
if (/^#ifndef RUBY/ =~ line)..(/^#endif/ =~ line)
|
case line
|
||||||
elsif (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
|
when /^#ifndef RUBY/
|
||||||
if $1
|
skip_ifndef_ruby = true
|
||||||
if name
|
when /^#endif/
|
||||||
lines << %[ENC_SET_BASE("#$1", "#{name}");]
|
skip_ifndef_ruby = false
|
||||||
else
|
end
|
||||||
name = $1
|
next if skip_ifndef_ruby
|
||||||
end
|
encoding_def = true if /^OnigEncodingDefine/ =~ line
|
||||||
check_duplication(defs, $1, fn, $.)
|
if encoding_def && /"(.*?)"/ =~ line
|
||||||
next if BUILTIN_ENCODINGS[name]
|
encoding_def = false
|
||||||
encodings << $1
|
if name
|
||||||
count += 1
|
lines << %[ENC_SET_BASE("#$1", "#{name}");]
|
||||||
|
else
|
||||||
|
name = $1
|
||||||
end
|
end
|
||||||
|
check_duplication(defs, $1, fn, $.)
|
||||||
|
next if BUILTIN_ENCODINGS[name]
|
||||||
|
encodings << $1
|
||||||
|
count += 1
|
||||||
else
|
else
|
||||||
case line
|
case line
|
||||||
when /^\s*rb_enc_register\(\s*"([^"]+)"/
|
when /^\s*rb_enc_register\(\s*"([^"]+)"/
|
||||||
|
|
|
@ -36,17 +36,18 @@ transdirs.each do |transdir|
|
||||||
files[fn] = true
|
files[fn] = true
|
||||||
path = File.join(transdir,fn)
|
path = File.join(transdir,fn)
|
||||||
open(path) do |f|
|
open(path) do |f|
|
||||||
|
transcoder_def = false
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
if (/^static const rb_transcoder/ =~ line)..(/"(.*?)"\s*,\s*"(.*?)"/ =~ line)
|
transcoder_def = true if /^static const rb_transcoder/ =~ line
|
||||||
if $1 && $2
|
if transcoder_def && /"(.*?)"\s*,\s*"(.*?)"/ =~ line
|
||||||
from_to = "%s to %s" % [$1, $2]
|
transcoder_def = false
|
||||||
if converters[from_to]
|
from_to = "%s to %s" % [$1, $2]
|
||||||
raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
|
if converters[from_to]
|
||||||
[path, $., from_to, *converters[from_to].values_at(3, 4)]
|
raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
|
||||||
else
|
[path, $., from_to, *converters[from_to].values_at(3, 4)]
|
||||||
converters[from_to] = [$1, $2, fn[0..-3], path, $.]
|
else
|
||||||
converter_list << from_to
|
converters[from_to] = [$1, $2, fn[0..-3], path, $.]
|
||||||
end
|
converter_list << from_to
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue