ruby-changes:51459
From: mame <ko1@a...>
Date: Fri, 15 Jun 2018 17:53:25 +0900 (JST)
Subject: [ruby-changes:51459] mame:r63669 (trunk): Remove flip-flop usages from build scripts
mame 2018-06-15 17:53:17 +0900 (Fri, 15 Jun 2018) New Revision: 63669 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63669 Log: Remove flip-flop usages from build scripts Modified files: trunk/ext/ripper/tools/preproc.rb trunk/template/encdb.h.tmpl trunk/template/transdb.h.tmpl Index: template/transdb.h.tmpl =================================================================== --- template/transdb.h.tmpl (revision 63668) +++ template/transdb.h.tmpl (revision 63669) @@ -36,17 +36,18 @@ transdirs.each do |transdir| https://github.com/ruby/ruby/blob/trunk/template/transdb.h.tmpl#L36 files[fn] = true path = File.join(transdir,fn) open(path) do |f| + transcoder_def = false f.each_line do |line| - 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, $., from_to, *converters[from_to].values_at(3, 4)] - else - converters[from_to] = [$1, $2, fn[0..-3], path, $.] - converter_list << from_to - end + 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, $., from_to, *converters[from_to].values_at(3, 4)] + else + converters[from_to] = [$1, $2, fn[0..-3], path, $.] + converter_list << from_to end end end Index: template/encdb.h.tmpl =================================================================== --- template/encdb.h.tmpl (revision 63668) +++ template/encdb.h.tmpl (revision 63669) @@ -40,20 +40,28 @@ encdirs.each do |encdir| https://github.com/ruby/ruby/blob/trunk/template/encdb.h.tmpl#L40 files[fn] = true open(File.join(encdir,fn)) do |f| name = nil + skip_ifndef_ruby = false + encoding_def = false f.each_line do |line| - 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, $.) - next if BUILTIN_ENCODINGS[name] - encodings << $1 - count += 1 + 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 end + check_duplication(defs, $1, fn, $.) + next if BUILTIN_ENCODINGS[name] + encodings << $1 + count += 1 else case line when /^\s*rb_enc_register\(\s*"([^"]+)"/ Index: ext/ripper/tools/preproc.rb =================================================================== --- ext/ripper/tools/preproc.rb (revision 63668) +++ ext/ripper/tools/preproc.rb (revision 63669) @@ -41,6 +41,7 @@ end https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/preproc.rb#L41 def prelude(f, out) @exprs = {} + lex_state_def = false while line = f.gets case line when /\A%%/ @@ -50,19 +51,25 @@ def prelude(f, out) https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/preproc.rb#L51 out << line.sub(/<\w+>/, '<val>') when /\A%type/ out << line.sub(/<\w+>/, '<val>') + when /^enum lex_state_(?:bits|e) \{/ + lex_state_def = true + out << line + when /^\}/ + lex_state_def = false + out << line else - 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 + 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/