* enc/make_encdb.rb: fix duplication check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b3781c60c
commit
9a1d7e4d01
@ -1,3 +1,7 @@
|
|||||||
|
Sun Jan 20 05:12:44 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* enc/make_encdb.rb: fix duplication check.
|
||||||
|
|
||||||
Sun Jan 20 05:03:46 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
Sun Jan 20 05:03:46 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ascii.c: remove difinition of replica KOI8-U.
|
* ascii.c: remove difinition of replica KOI8-U.
|
||||||
|
@ -9,27 +9,29 @@
|
|||||||
# ENC_ALIAS("CP932", "Windows-31J")
|
# ENC_ALIAS("CP932", "Windows-31J")
|
||||||
#
|
#
|
||||||
|
|
||||||
def check_duplication(encs, name, fn, line)
|
def check_duplication(defs, name, fn, line)
|
||||||
if encs.include?(name)
|
if defs[name]
|
||||||
raise ArgumentError, "%s:%d: encoding %s is already registered" % [fn, line, name]
|
raise ArgumentError, "%s:%d: encoding %s is already registered(%s:%d)" %
|
||||||
|
[fn, line, name, *defs[name]]
|
||||||
|
else
|
||||||
|
defs[name.upcase] = [fn,line]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
lines = []
|
lines = []
|
||||||
encodings = []
|
encodings = []
|
||||||
|
defs = {}
|
||||||
encdir = ARGV[0]
|
encdir = ARGV[0]
|
||||||
outhdr = ARGV[1] || 'encdb.h'
|
outhdr = ARGV[1] || 'encdb.h'
|
||||||
Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort.each do |fn|
|
Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort.each do |fn|
|
||||||
open(File.join(encdir,fn)) do |f|
|
open(File.join(encdir,fn)) do |f|
|
||||||
orig = nil
|
orig = nil
|
||||||
name = nil
|
name = nil
|
||||||
encs = []
|
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
|
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
|
||||||
if $1
|
if $1
|
||||||
check_duplication(encs, $1, fn, $.)
|
check_duplication(defs, $1, fn, $.)
|
||||||
encs << $1.upcase
|
|
||||||
encodings << $1
|
encodings << $1
|
||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
@ -41,19 +43,18 @@ Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort.each do |fn|
|
|||||||
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
|
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
|
||||||
[fn, $., $2, $1] unless encs.include?($2.upcase)
|
[fn, $., $2, $1] unless defs[$2.upcase]
|
||||||
count += 1
|
count += 1
|
||||||
when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
'%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
|
'%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
|
||||||
[fn, $., $2, $1] unless encs.include?($2.upcase)
|
[fn, $., $2, $1] unless defs[$2.upcase]
|
||||||
when /^ENC_DUMMY\(\s*"([^"]+)"/
|
when /^ENC_DUMMY\(\s*"([^"]+)"/
|
||||||
count += 1
|
count += 1
|
||||||
else
|
else
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
check_duplication(encs, $1, fn, $.)
|
check_duplication(defs, $1, fn, $.)
|
||||||
encs << $1.upcase
|
|
||||||
lines << line.sub(/;.*/m, ";\n") if line
|
lines << line.sub(/;.*/m, ";\n") if line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user