зеркало из https://github.com/github/ruby.git
* tool/transcode-tblgen.rb: show generating tables in verbose mode.
(transcode_generate_node): call ActionMap#generate_node with showing table name. * enc/trans/utf_16_32.erb.c: use transcode_generate_node. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3af2559d17
Коммит
e90dd02529
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Aug 6 07:45:26 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* tool/transcode-tblgen.rb: show generating tables in verbose mode.
|
||||||
|
(transcode_generate_node): call ActionMap#generate_node with showing
|
||||||
|
table name.
|
||||||
|
|
||||||
|
* enc/trans/utf_16_32.erb.c: use transcode_generate_node.
|
||||||
|
|
||||||
Wed Aug 6 06:55:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Aug 6 06:55:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* thread.c (thread_start_func_2): propagates fatal error and system
|
* thread.c (thread_start_func_2): propagates fatal error and system
|
||||||
|
|
|
@ -186,7 +186,7 @@ fun_so_to_utf_32le(const unsigned char* s, unsigned char* o)
|
||||||
map["{dc-df}{00-ff}"] = :invalid
|
map["{dc-df}{00-ff}"] = :invalid
|
||||||
map["{d8-db}{00-ff}{00-db,e0-ff}{00-ff}"] = :invalid
|
map["{d8-db}{00-ff}{00-db,e0-ff}{00-ff}"] = :invalid
|
||||||
code = ''
|
code = ''
|
||||||
ActionMap.parse(map).generate_node(code, "from_UTF_16BE", [])
|
transcode_generate_node(ActionMap.parse(map), code, "from_UTF_16BE", [])
|
||||||
code
|
code
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ rb_from_UTF_16BE = {
|
||||||
map["f4{90-bf}"] = :invalid
|
map["f4{90-bf}"] = :invalid
|
||||||
code = ''
|
code = ''
|
||||||
am = ActionMap.parse(map)
|
am = ActionMap.parse(map)
|
||||||
am.generate_node(code, "to_UTF_16BE", [0x00..0xff, 0x80..0xbf, 0x80..0xbf, 0x80..0xbf])
|
transcode_generate_node(am, code, "to_UTF_16BE", [0x00..0xff, 0x80..0xbf, 0x80..0xbf, 0x80..0xbf])
|
||||||
code
|
code
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ rb_to_UTF_16BE = {
|
||||||
map["{00-ff}{dc-df}"] = :invalid
|
map["{00-ff}{dc-df}"] = :invalid
|
||||||
map["{00-ff}{d8-db}{00-ff}{00-db,e0-ff}"] = :invalid
|
map["{00-ff}{d8-db}{00-ff}{00-db,e0-ff}"] = :invalid
|
||||||
code = ''
|
code = ''
|
||||||
ActionMap.parse(map).generate_node(code, "from_UTF_16LE", [])
|
transcode_generate_node(ActionMap.parse(map), code, "from_UTF_16LE", [])
|
||||||
code
|
code
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ rb_to_UTF_16LE = {
|
||||||
#map["{01-ff}"] = :invalid
|
#map["{01-ff}"] = :invalid
|
||||||
map["{01-ff}{00-ff}{00-ff}{00-ff}"] = :invalid
|
map["{01-ff}{00-ff}{00-ff}{00-ff}"] = :invalid
|
||||||
code = ''
|
code = ''
|
||||||
ActionMap.parse(map).generate_node(code, "from_UTF_32BE", [])
|
transcode_generate_node(ActionMap.parse(map), code, "from_UTF_32BE", [])
|
||||||
code
|
code
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ rb_to_UTF_32BE = {
|
||||||
map["{00-ff}{00-ff}{11-ff}00"] = :invalid
|
map["{00-ff}{00-ff}{11-ff}00"] = :invalid
|
||||||
map["{00-ff}{d8-df}0000"] = :invalid
|
map["{00-ff}{d8-df}0000"] = :invalid
|
||||||
code = ''
|
code = ''
|
||||||
ActionMap.parse(map).generate_node(code, "from_UTF_32LE", [])
|
transcode_generate_node(ActionMap.parse(map), code, "from_UTF_32LE", [])
|
||||||
code
|
code
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,7 @@ end
|
||||||
TRANSCODERS = []
|
TRANSCODERS = []
|
||||||
|
|
||||||
def transcode_tblgen(from, to, map)
|
def transcode_tblgen(from, to, map)
|
||||||
|
STDERR.puts "converter for #{from} to #{to}" if VERBOSE_MODE
|
||||||
id_from = from.tr('^0-9A-Za-z', '_')
|
id_from = from.tr('^0-9A-Za-z', '_')
|
||||||
id_to = to.tr('^0-9A-Za-z', '_')
|
id_to = to.tr('^0-9A-Za-z', '_')
|
||||||
if from == "UTF-8"
|
if from == "UTF-8"
|
||||||
|
@ -405,6 +406,11 @@ End
|
||||||
tree_code + "\n" + transcoder_code
|
tree_code + "\n" + transcoder_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def transcode_generate_node(am, code, name_hint=nil, ranges=[])
|
||||||
|
STDERR.puts "converter for #{name_hint}" if VERBOSE_MODE
|
||||||
|
am.generate_node(code, name_hint, ranges)
|
||||||
|
end
|
||||||
|
|
||||||
def transcode_register_code
|
def transcode_register_code
|
||||||
code = ''
|
code = ''
|
||||||
TRANSCODERS.each {|transcoder_name|
|
TRANSCODERS.each {|transcoder_name|
|
||||||
|
@ -499,6 +505,8 @@ op.def_option("--force", "force table generation") { force_mode = true }
|
||||||
op.def_option("--output=FILE", "specify output file") {|arg| output_filename = arg }
|
op.def_option("--output=FILE", "specify output file") {|arg| output_filename = arg }
|
||||||
op.parse!
|
op.parse!
|
||||||
|
|
||||||
|
VERBOSE_MODE = verbose_mode
|
||||||
|
|
||||||
arg = ARGV.shift
|
arg = ARGV.shift
|
||||||
dir = File.dirname(arg)
|
dir = File.dirname(arg)
|
||||||
$:.unshift dir unless $:.include? dir
|
$:.unshift dir unless $:.include? dir
|
||||||
|
@ -523,14 +531,14 @@ if !force_mode && output_filename && File.readable?(output_filename)
|
||||||
if old_signature == chk_signature
|
if old_signature == chk_signature
|
||||||
now = Time.now
|
now = Time.now
|
||||||
File.utime(now, now, output_filename)
|
File.utime(now, now, output_filename)
|
||||||
STDERR.puts "#{output_filename} is already up-to-date." if verbose_mode
|
STDERR.puts "already up-to-date: #{output_filename}" if VERBOSE_MODE
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if verbose_mode
|
if VERBOSE_MODE
|
||||||
if output_filename
|
if output_filename
|
||||||
STDERR.print "generate #{output_filename} ..."
|
STDERR.puts "generating #{output_filename} ..."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -559,7 +567,7 @@ if output_filename
|
||||||
new_filename = output_filename + ".new"
|
new_filename = output_filename + ".new"
|
||||||
File.open(new_filename, "w") {|f| f << result }
|
File.open(new_filename, "w") {|f| f << result }
|
||||||
File.rename(new_filename, output_filename)
|
File.rename(new_filename, output_filename)
|
||||||
STDERR.puts " done." if verbose_mode
|
STDERR.puts "done." if VERBOSE_MODE
|
||||||
else
|
else
|
||||||
print result
|
print result
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче