diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-13 14:33:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-10-13 14:33:30 +0000 |
commit | c84f1057b412af5ec1aed050e3f9505ceb03bad3 (patch) | |
tree | d2974b5b17a60ef0dc9c39bbbfcde843300d64b0 /ext/iconv | |
parent | 9401edfe229e14635be9d480473f63b4cbf0a580 (diff) |
* ext/iconv/charset_alias.rb (charset_alias): create wrapper libray
even if no target matched.
* ext/iconv/extconf.rb: create wrapper library under RUBYARCHDIR
directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/iconv')
-rw-r--r-- | ext/iconv/charset_alias.rb | 43 | ||||
-rw-r--r-- | ext/iconv/extconf.rb | 8 |
2 files changed, 40 insertions, 11 deletions
diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb index e5210b4e4f..aed4644290 100644 --- a/ext/iconv/charset_alias.rb +++ b/ext/iconv/charset_alias.rb @@ -15,23 +15,25 @@ class Hash::Ordered < Hash end def []=(key, val) ary = fetch(key) {return super(key, [self.size, key, val])} and - ary.last = val + ary << val end - def each - values.sort.each {|i, key, val| yield key, val} + def sort + values.sort.collect {|i, *rest| rest} + end + def each(&block) + sort.each(&block) end end def charset_alias(config_charset, mapfile, target = OS) map = Hash::Ordered.new comments = [] - match = false open(config_charset) do |input| - input.find {|line| /^case "\$os" in/ =~ line} or return + input.find {|line| /^case "\$os" in/ =~ line} or break input.find {|line| /^\s*([-\w\*]+(?:\s*\|\s*[-\w\*]+)*)(?=\))/ =~ line and $&.split('|').any? {|pattern| File.fnmatch?(pattern.strip, target)} - } or return + } or break input.find do |line| case line when /^\s*echo "(?:\$\w+\.)?([-\w*]+)\s+([-\w]+)"/ @@ -48,17 +50,40 @@ def charset_alias(config_charset, mapfile, target = OS) end case target when /linux|-gnu/ - map.delete('ascii') - when /cygwin/ + # map.delete('ascii') + when /cygwin|os2-emx/ # get rid of tilde/yen problem. map['shift_jis'] = 'cp932' end + st = Hash.new(0) + map = map.sort.collect do |can, *sys| + if sys.grep(/^en_us(?=.|$)/i) {break true} == true + noen = %r"^(?!en_us)\w+_\w+#{Regexp.new($')}$"i #" + sys.reject! {|s| noen =~ s} + end + sys = sys.first + st[sys] += 1 + [can, sys] + end + st.delete_if {|sys, i| i == 1}.empty? + st.keys.each {|sys| st[sys] = nil} + st.default = nil writer = proc do |f| f.puts("require 'iconv.so'") f.puts f.puts(comments) f.puts("class Iconv") - map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")} + i = 0 + map.each do |can, sys| + if s = st[sys] + sys = s + elsif st.key?(sys) + sys = (st[sys] = "sys#{i+=1}") + " = '#{sys}'.freeze" + else + sys = "'#{sys}'.freeze" + end + f.puts(" charset_map['#{can}'] = #{sys}") + end f.puts("end") end if mapfile diff --git a/ext/iconv/extconf.rb b/ext/iconv/extconf.rb index 2d6f8538d7..359771e8a9 100644 --- a/ext/iconv/extconf.rb +++ b/ext/iconv/extconf.rb @@ -26,8 +26,12 @@ if have_func("iconv", "iconv.h") or if conf prefix = '$(srcdir)' prefix = $nmake ? "{#{prefix}}" : "#{prefix}/" - wrapper = "./iconv.rb" - $INSTALLFILES = [[wrapper, "$(RUBYARCHDIR)"]] + if $extout + wrapper = "$(RUBYARCHDIR)/iconv.rb" + else + wrapper = "./iconv.rb" + $INSTALLFILES = [[wrapper, "$(RUBYARCHDIR)"]] + end if String === conf require 'uri' scheme = URI.parse(conf).scheme |