diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-18 19:51:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-18 19:51:42 +0000 |
commit | 3b1e7ac7855a2d5cb4a075d652835cf52ea123a6 (patch) | |
tree | 1bdd8507d591b06e13eb5c9da6a74d4adb83855b /ext/iconv/charset_alias.rb | |
parent | c88efe5fa2ba6e6b565630e3049c8307ed540c9f (diff) | |
download | ruby-3b1e7ac7855a2d5cb4a075d652835cf52ea123a6.tar.gz |
* ext/iconv/charset_alias.rb, ext/iconv/extconf.rb: make wrapper
script which maps charset names. [ruby-dev:20625]
* ext/iconv/iconv.c (charset_map): charset name map.
* ext/iconv/iconv.c (iconv_dfree): no exception while
finalization.
* ext/iconv/iconv.c (iconv_s_conv): new method Iconv.conv.
[ruby-dev:20588]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/iconv/charset_alias.rb')
-rw-r--r-- | ext/iconv/charset_alias.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb new file mode 100644 index 0000000000..20a7f6406a --- /dev/null +++ b/ext/iconv/charset_alias.rb @@ -0,0 +1,36 @@ +#! /usr/bin/ruby +require 'rbconfig' + +# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset' +# Fri, 30 May 2003 00:09:00 GMT' + +OS = Config::CONFIG["target"] +SHELL = Config::CONFIG['SHELL'] + +def charset_alias(config_charset, mapfile) + map = {} + comments = [] + IO.foreach("|#{SHELL} #{config_charset} #{OS}") do |list| + next comments << list if /^\#/ =~ list + next unless /^(\S+)\s+(\S+)$/ =~ list + sys, can = $1, $2 + next if sys == can + next if can.downcase! and sys == can + map[can] = sys + end + case OS + when /linux|-gnu/ + map.delete('ascii') + end + open(mapfile, "w") 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")} + f.puts("end") + end +end + +ARGV.size == 2 or abort "usage: #$0 config.status map.rb" +charset_alias(*ARGV) |