mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* ext/iconv/charset_alias.rb: parse config.charset_alias file directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3b4216d2b5
commit
b440480b7f
3 changed files with 41 additions and 13 deletions
|
@ -1,8 +1,10 @@
|
||||||
Sat Oct 8 18:56:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Oct 8 19:15:02 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (rb_parser_malloc, rb_parser_free): manage parser stack on
|
* parse.y (rb_parser_malloc, rb_parser_free): manage parser stack on
|
||||||
heap. [ruby-list:41199]
|
heap. [ruby-list:41199]
|
||||||
|
|
||||||
|
* ext/iconv/charset_alias.rb: parse config.charset_alias file directly.
|
||||||
|
|
||||||
Fri Oct 7 09:54:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Oct 7 09:54:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* lib/cgi.rb (CGI::Cookie::parse): Cookies from Nokia devices may
|
* lib/cgi.rb (CGI::Cookie::parse): Cookies from Nokia devices may
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#! /usr/bin/ruby
|
#! /usr/bin/ruby
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
|
# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
|
||||||
# Fri, 30 May 2003 00:09:00 GMT'
|
# Fri, 30 May 2003 00:09:00 GMT'
|
||||||
|
|
||||||
OS = Config::CONFIG["target"]
|
OS = Config::CONFIG["target_os"]
|
||||||
SHELL = Config::CONFIG['SHELL']
|
SHELL = Config::CONFIG['SHELL']
|
||||||
|
|
||||||
class Hash::Ordered < Hash
|
class Hash::Ordered < Hash
|
||||||
|
@ -24,12 +25,26 @@ end
|
||||||
def charset_alias(config_charset, mapfile, target = OS)
|
def charset_alias(config_charset, mapfile, target = OS)
|
||||||
map = Hash::Ordered.new
|
map = Hash::Ordered.new
|
||||||
comments = []
|
comments = []
|
||||||
IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
|
match = false
|
||||||
next comments << list if /^\#/ =~ list
|
open(config_charset) do |input|
|
||||||
next unless /^(\S+)\s+(\S+)$/ =~ list
|
input.find {|line| /^case "\$os" in/ =~ line} or return
|
||||||
sys, can = $1, $2
|
input.find {|line|
|
||||||
can.downcase!
|
/^\s*([-\w\*]+(?:\s*\|\s*[-\w\*]+)*)(?=\))/ =~ line and
|
||||||
map[can] = sys
|
$&.split('|').any? {|pattern| File.fnmatch?(pattern.strip, target)}
|
||||||
|
} or return
|
||||||
|
input.find do |line|
|
||||||
|
case line
|
||||||
|
when /^\s*echo "(?:\$\w+\.)?([-\w*]+)\s+([-\w]+)"/
|
||||||
|
sys, can = $1, $2
|
||||||
|
can.downcase!
|
||||||
|
map[can] = sys
|
||||||
|
false
|
||||||
|
when /^\s*;;/
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
case target
|
case target
|
||||||
when /linux|-gnu/
|
when /linux|-gnu/
|
||||||
|
@ -38,7 +53,7 @@ def charset_alias(config_charset, mapfile, target = OS)
|
||||||
# get rid of tilde/yen problem.
|
# get rid of tilde/yen problem.
|
||||||
map['shift_jis'] = 'cp932'
|
map['shift_jis'] = 'cp932'
|
||||||
end
|
end
|
||||||
open(mapfile, "w") do |f|
|
writer = proc do |f|
|
||||||
f.puts("require 'iconv.so'")
|
f.puts("require 'iconv.so'")
|
||||||
f.puts
|
f.puts
|
||||||
f.puts(comments)
|
f.puts(comments)
|
||||||
|
@ -46,7 +61,18 @@ def charset_alias(config_charset, mapfile, target = OS)
|
||||||
map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")}
|
map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")}
|
||||||
f.puts("end")
|
f.puts("end")
|
||||||
end
|
end
|
||||||
|
if mapfile
|
||||||
|
open(mapfile, "w", &writer)
|
||||||
|
else
|
||||||
|
writer[STDOUT]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
(2..3) === ARGV.size or abort "usage: #$0 config.status map.rb [target]"
|
target = OS
|
||||||
charset_alias(*ARGV)
|
opt = nil
|
||||||
|
ARGV.options do |opt|
|
||||||
|
opt.banner << " config.status map.rb"
|
||||||
|
opt.on("--target OS") {|t| target = t}
|
||||||
|
opt.parse! and (1..2) === ARGV.size
|
||||||
|
end or abort opt.to_s
|
||||||
|
charset_alias(ARGV[0], ARGV[1], target)
|
||||||
|
|
|
@ -32,7 +32,7 @@ if have_func("iconv", "iconv.h") or
|
||||||
require 'uri'
|
require 'uri'
|
||||||
scheme = URI.parse(conf).scheme
|
scheme = URI.parse(conf).scheme
|
||||||
else
|
else
|
||||||
conf = prefix + "config.charset"
|
conf = "$(srcdir)/config.charset"
|
||||||
end
|
end
|
||||||
$cleanfiles << wrapper
|
$cleanfiles << wrapper
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ if have_func("iconv", "iconv.h") or
|
||||||
open("Makefile", "a") do |mf|
|
open("Makefile", "a") do |mf|
|
||||||
mf.print("\nall: #{wrapper}\n\n#{wrapper}: #{prefix}charset_alias.rb")
|
mf.print("\nall: #{wrapper}\n\n#{wrapper}: #{prefix}charset_alias.rb")
|
||||||
mf.print(" ", conf) unless scheme
|
mf.print(" ", conf) unless scheme
|
||||||
mf.print("\n\t$(RUBY) ", prefix, "charset_alias.rb ", conf, " $@\n")
|
mf.print("\n\t$(RUBY) $(srcdir)/charset_alias.rb #{conf} $@\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue