summaryrefslogtreecommitdiff
path: root/enc/make_encdb.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-13 14:29:12 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-13 14:29:12 +0000
commit21671b558cfd8d90647f40a8594fd9e6db038768 (patch)
tree5204ff9fd0eb5569165d17423523fa36ca63c267 /enc/make_encdb.rb
parent62c596cb36af5471e65a4774dfe70047055f58b7 (diff)
* enc/make_encdb.h: sort encoding names by original name.
* encoding.c, enc/*.c: define replicas and aliases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/make_encdb.rb')
-rwxr-xr-xenc/make_encdb.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/enc/make_encdb.rb b/enc/make_encdb.rb
index fe596769dc..f260a2caa0 100755
--- a/enc/make_encdb.rb
+++ b/enc/make_encdb.rb
@@ -13,7 +13,7 @@ encodings = []
replicas = {}
aliases = {}
encdir = ARGV[0]
-Dir.open(encdir) {|d| d.grep(/.+\.c\z/)}.each do |fn|
+Dir.open(encdir) {|d| d.grep(/.+\.c\z/)}.sort.each do |fn|
open(File.join(encdir,fn)) do |f|
orig = nil
name = nil
@@ -26,19 +26,19 @@ Dir.open(encdir) {|d| d.grep(/.+\.c\z/)}.each do |fn|
encodings << $1 if $1
f.each_line do |line|
if /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
+ encodings << $1
replicas[$1] = $2
elsif /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
+ encodings << $1
aliases[$1] = $2
end
end
end
end
-p aliases
+
open('encdb.h', 'wb') do |f|
f.puts 'static const char *const enc_name_list[] = {'
encodings.each {|name| f.puts' "%s",' % name}
- replicas.each_key {|name| f.puts' "%s",' % name}
- aliases.each_key {|name| f.puts' "%s",' % name}
f.puts('};', '', 'static void', 'enc_init_db(void)', '{')
replicas.each_pair {|name, orig|
f.puts ' ENC_REPLICATE("%s", "%s");' % [name, orig]