Revert "Remove flip-flop usages from build scripts"

This reverts commit 301fa452f7.
This commit is contained in:
Nobuyoshi Nakada 2024-03-17 18:28:28 +09:00
Родитель 28a2105a55
Коммит 9e470ebdcd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
3 изменённых файлов: 32 добавлений и 48 удалений

Просмотреть файл

@ -53,7 +53,6 @@ end
def prelude(f, out)
@exprs = {}
lex_state_def = false
while line = f.gets
case line
when /\A%%/
@ -62,24 +61,18 @@ def prelude(f, out)
when /\A%token/, /\A%type/, /\A} <node(?>_\w+)?>/
# types in %union which have corresponding set_yylval_* macro.
out << line
when /^enum lex_state_(?:bits|e) \{/
lex_state_def = true
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}+")
if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line)
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
end
end
end

Просмотреть файл

@ -40,28 +40,20 @@ encdirs.each do |encdir|
files[fn] = true
open(File.join(encdir,fn)) do |f|
name = nil
skip_ifndef_ruby = false
encoding_def = false
f.each_line do |line|
case line
when /^#ifndef RUBY/
skip_ifndef_ruby = true
when /^#endif/
skip_ifndef_ruby = false
end
next if skip_ifndef_ruby
encoding_def = true if /^OnigEncodingDefine/ =~ line
if encoding_def && /"(.*?)"/ =~ line
encoding_def = false
if name
lines << %[ENC_SET_BASE("#$1", "#{name}");]
else
name = $1
if (/^#ifndef RUBY/ =~ line)..(/^#endif/ =~ line)
elsif (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
if $1
if name
lines << %[ENC_SET_BASE("#$1", "#{name}");]
else
name = $1
end
check_duplication(defs, $1, fn, f.lineno)
next if BUILTIN_ENCODINGS[name]
encodings << $1
count += 1
end
check_duplication(defs, $1, fn, f.lineno)
next if BUILTIN_ENCODINGS[name]
encodings << $1
count += 1
else
case line
when /^\s*rb_enc_register\(\s*"([^"]+)"/

Просмотреть файл

@ -36,18 +36,17 @@ transdirs.each do |transdir|
files[fn] = true
path = File.join(transdir,fn)
open(path) do |f|
transcoder_def = false
f.each_line do |line|
transcoder_def = true if /^static const rb_transcoder/ =~ line
if transcoder_def && /"(.*?)"\s*,\s*"(.*?)"/ =~ line
transcoder_def = false
from_to = "%s to %s" % [$1, $2]
if converters[from_to]
raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
[path, f.lineno, from_to, *converters[from_to].values_at(3, 4)]
else
converters[from_to] = [$1, $2, fn[0..-3], path, f.lineno]
converter_list << from_to
if (/^static const rb_transcoder/ =~ line)..(/"(.*?)"\s*,\s*"(.*?)"/ =~ line)
if $1 && $2
from_to = "%s to %s" % [$1, $2]
if converters[from_to]
raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
[path, f.lineno, from_to, *converters[from_to].values_at(3, 4)]
else
converters[from_to] = [$1, $2, fn[0..-3], path, f.lineno]
converter_list << from_to
end
end
end
end