1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* common.mk (encdb.h): see both $(srcdir)/enc and enc.

* enc/make_encdb.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-08-08 07:15:52 +00:00
parent 2f37e03736
commit b917553e68
3 changed files with 47 additions and 37 deletions

View file

@ -1,4 +1,8 @@
Fri Aug 8 16:09:01 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Aug 8 16:15:50 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (encdb.h): see both $(srcdir)/enc and enc.
* enc/make_encdb.rb: ditto.
* enc/trans/make_transdb.rb: fix for the case no transdirs are given.

View file

@ -22,42 +22,48 @@ count = 0
lines = []
encodings = []
defs = {}
encdir = ARGV[0]
outhdr = ARGV[1] || 'encdb.h'
Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort_by {|e|
e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten
}.each do |fn|
open(File.join(encdir,fn)) do |f|
orig = nil
name = nil
f.each_line do |line|
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
if $1
check_duplication(defs, $1, fn, $.)
encodings << $1
count += 1
end
else
case line
when /^\s*rb_enc_register\(\s*"([^"]+)"/
count += 1
line = nil
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
raise ArgumentError,
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
[fn, $., $2, $1] unless defs[$2.upcase]
count += 1
when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
raise ArgumentError,
'%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
[fn, $., $2, $1] unless defs[$2.upcase]
when /^ENC_DUMMY\(\s*"([^"]+)"/
count += 1
encdirs = ARGV.dup
outhdr = encdirs.shift || 'encdb.h'
encdirs << 'enc' if encdirs.empty?
files = {}
encdirs.each do |encdir|
Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort_by {|e|
e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten
}.each do |fn|
next if files[fn]
files[fn] = true
open(File.join(encdir,fn)) do |f|
orig = nil
name = nil
f.each_line do |line|
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
if $1
check_duplication(defs, $1, fn, $.)
encodings << $1
count += 1
end
else
next
case line
when /^\s*rb_enc_register\(\s*"([^"]+)"/
count += 1
line = nil
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
raise ArgumentError,
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
[fn, $., $2, $1] unless defs[$2.upcase]
count += 1
when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
raise ArgumentError,
'%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
[fn, $., $2, $1] unless defs[$2.upcase]
when /^ENC_DUMMY\(\s*"([^"]+)"/
count += 1
else
next
end
check_duplication(defs, $1, fn, $.)
lines << line.sub(/;.*/m, "").chomp + ";\n" if line
end
check_duplication(defs, $1, fn, $.)
lines << line.sub(/;.*/m, "").chomp + ";\n" if line
end
end
end

View file

@ -8,8 +8,8 @@
count = 0
converters = {}
outhdr = ARGV[0] || 'transdb.h'
transdirs = ARGV[1..-1]
transdirs = ARGV.dup
outhdr = transdirs.shift || 'transdb.h'
transdirs << 'enc/trans' if transdirs.empty?
files = {}
transdirs.each do |transdir|