diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-13 09:55:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-13 09:55:21 +0000 |
commit | 2298eb5f12ee4d8c192bc02e5dc957504a9ac30d (patch) | |
tree | 2c67feda7ef0154051ec14bba9ce6a8103e6b28b /ext/iconv/charset_alias.rb | |
parent | 6a3f682ff79266b0b38b8890f2fa61014089f6a3 (diff) | |
download | ruby-2298eb5f12ee4d8c192bc02e5dc957504a9ac30d.tar.gz |
* ext/iconv/charset_alias.rb: preserve original order.
* ext/iconv/extconf.rb: remove wrapper file at clean.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/iconv/charset_alias.rb')
-rw-r--r-- | ext/iconv/charset_alias.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb index 7947fd8127..be2c1412e7 100644 --- a/ext/iconv/charset_alias.rb +++ b/ext/iconv/charset_alias.rb @@ -7,8 +7,21 @@ require 'rbconfig' OS = Config::CONFIG["target"] SHELL = Config::CONFIG['SHELL'] +class Hash::Ordered < Hash + def [](key) + val = super and val.last + end + def []=(key, val) + ary = fetch(key) {return super(key, [self.size, key, val])} and + ary.last = val + end + def each + values.sort.each {|i, key, val| yield key, val} + end +end + def charset_alias(config_charset, mapfile, target = OS) - map = {} + map = Hash::Ordered.new comments = [] IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list| next comments << list if /^\#/ =~ list @@ -29,7 +42,7 @@ def charset_alias(config_charset, mapfile, target = OS) f.puts f.puts(comments) f.puts("class Iconv") - map.keys.sort.each {|can| f.puts(" charset_map['#{can}'.freeze] = '#{map[can]}'.freeze")} + map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")} f.puts("end") end end |