2003-07-18 15:51:42 -04:00
|
|
|
#! /usr/bin/ruby
|
|
|
|
require 'rbconfig'
|
|
|
|
|
2003-09-01 11:41:31 -04:00
|
|
|
# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
|
2003-07-18 15:51:42 -04:00
|
|
|
# Fri, 30 May 2003 00:09:00 GMT'
|
|
|
|
|
|
|
|
OS = Config::CONFIG["target"]
|
|
|
|
SHELL = Config::CONFIG['SHELL']
|
|
|
|
|
2003-09-01 11:41:31 -04:00
|
|
|
def charset_alias(config_charset, mapfile, target = OS)
|
2003-07-18 15:51:42 -04:00
|
|
|
map = {}
|
|
|
|
comments = []
|
2003-09-01 11:41:31 -04:00
|
|
|
IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
|
2003-07-18 15:51:42 -04:00
|
|
|
next comments << list if /^\#/ =~ list
|
|
|
|
next unless /^(\S+)\s+(\S+)$/ =~ list
|
|
|
|
sys, can = $1, $2
|
2003-12-07 06:39:29 -05:00
|
|
|
can.downcase!
|
2003-07-18 15:51:42 -04:00
|
|
|
map[can] = sys
|
|
|
|
end
|
2003-09-01 11:41:31 -04:00
|
|
|
case target
|
2003-07-18 15:51:42 -04:00
|
|
|
when /linux|-gnu/
|
|
|
|
map.delete('ascii')
|
2003-09-01 11:41:31 -04:00
|
|
|
when /cygwin/
|
|
|
|
# get rid of tilde/yen problem.
|
|
|
|
map['shift_jis'] = 'cp932'
|
2003-07-18 15:51:42 -04:00
|
|
|
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
|
|
|
|
|
2003-09-01 11:41:31 -04:00
|
|
|
(2..3) === ARGV.size or abort "usage: #$0 config.status map.rb [target]"
|
2003-07-18 15:51:42 -04:00
|
|
|
charset_alias(*ARGV)
|