ruby-changes:6917
From: nobu <ko1@a...>
Date: Fri, 8 Aug 2008 16:16:05 +0900 (JST)
Subject: [ruby-changes:6917] Ruby:r18435 (trunk): * common.mk (encdb.h): see both $(srcdir)/enc and enc.
nobu 2008-08-08 16:15:52 +0900 (Fri, 08 Aug 2008) New Revision: 18435 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18435 Log: * common.mk (encdb.h): see both $(srcdir)/enc and enc. * enc/make_encdb.rb: ditto. Modified files: trunk/ChangeLog trunk/enc/make_encdb.rb trunk/enc/trans/make_transdb.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18434) +++ ChangeLog (revision 18435) @@ -1,5 +1,9 @@ -Fri Aug 8 16:09:01 2008 Nobuyoshi Nakada <nobu@r...> +Fri Aug 8 16:15:50 2008 Nobuyoshi Nakada <nobu@r...> + * 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. * enc/trans/make_transdb.rb: converts only one transcoders for each Index: enc/trans/make_transdb.rb =================================================================== --- enc/trans/make_transdb.rb (revision 18434) +++ enc/trans/make_transdb.rb (revision 18435) @@ -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| Index: enc/make_encdb.rb =================================================================== --- enc/make_encdb.rb (revision 18434) +++ enc/make_encdb.rb (revision 18435) @@ -22,42 +22,48 @@ 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 +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 + 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, $.) - encodings << $1 - count += 1 + lines << line.sub(/;.*/m, "").chomp + ";\n" if line 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 - else - next - end - check_duplication(defs, $1, fn, $.) - lines << line.sub(/;.*/m, "").chomp + ";\n" if line end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/