summaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-15 08:53:17 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-15 08:53:17 (GMT)
commit301fa452f7a9cdea922103e9c50d85a2d5652d0d (patch)
treeb503ea3e71639ed59dacf26a134710cb4ca757ea /template
parentbf7a32d22079cc44eb19794e41d82b886d5d17b3 (diff)
Remove flip-flop usages from build scripts
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template')
-rw-r--r--template/encdb.h.tmpl32
-rw-r--r--template/transdb.h.tmpl21
2 files changed, 31 insertions, 22 deletions
diff --git a/template/encdb.h.tmpl b/template/encdb.h.tmpl
index 9de29be..06afb5d 100644
--- a/template/encdb.h.tmpl
+++ b/template/encdb.h.tmpl
@@ -40,20 +40,28 @@ 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|
- 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*"([^"]+)"/
diff --git a/template/transdb.h.tmpl b/template/transdb.h.tmpl
index d0cf101..16565dd 100644
--- a/template/transdb.h.tmpl
+++ b/template/transdb.h.tmpl
@@ -36,17 +36,18 @@ transdirs.each do |transdir|
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