5 # http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
6 # Fri, 30 May 2003 00:09:00 GMT'
15 def charset_alias(config_charset, mapfile = nil)
18 open(config_charset) do |input|
19 input.find {|line| /^case "\$os" in/ =~ line} or return
22 when /^\s*([-\w\*]+(?:\s*\|\s*[-\w\*]+)*)(?=\))/
23 (s = " when ") << $&.split('|').collect {|targ|
25 tail = targ.chomp!("*") ? '' : '\z'
26 head = targ.slice!(/\A\*/) ? '' : '\A'
27 targ.gsub!(/\*/, '.*')
28 "/#{head}#{targ}#{tail}/"
32 when /^\s*echo "(?:\$\w+\.)?([-\w*]+)\s+([-\w]+)"/
35 unless found[can] or (/\Aen_(?!US\z)/ =~ sys && /\ACP437\z/i =~ can)
37 src << " charset_map['#{can}'] = '#{sys}'.freeze"
44 src << " end" << "end"
46 open(mapfile, "wb") {|f| f.puts *src}
52 (1..2) === ARGV.size or abort "usage: #{$0} config_charset [mapfile]"