ruby-changes:15036
From: akr <ko1@a...>
Date: Sun, 14 Mar 2010 02:55:05 +0900 (JST)
Subject: [ruby-changes:15036] Ruby:r26912 (trunk): * tool/transcode-tblgen.rb: reject ambiguous mapping.
akr 2010-03-14 02:54:43 +0900 (Sun, 14 Mar 2010) New Revision: 26912 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26912 Log: * tool/transcode-tblgen.rb: reject ambiguous mapping. * enc/trans/single_byte.trans: remove ambiguous maping such as \xD6 -> U+05F2 and \xD6\xC7 -> U+FB1F in Windows-1255 Modified files: trunk/ChangeLog trunk/enc/trans/single_byte.trans trunk/tool/transcode-tblgen.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26911) +++ ChangeLog (revision 26912) @@ -1,3 +1,10 @@ +Sun Mar 14 02:40:38 2010 Tanaka Akira <akr@f...> + + * tool/transcode-tblgen.rb: reject ambiguous mapping. + + * enc/trans/single_byte.trans: remove ambiguous maping such as + \xD6 -> U+05F2 and \xD6\xC7 -> U+FB1F in Windows-1255 + Sat Mar 13 23:48:27 2010 Yukihiro Matsumoto <matz@r...> * file.c (file_expand_path): should not just copy the encoding Index: enc/trans/single_byte.trans =================================================================== --- enc/trans/single_byte.trans (revision 26911) +++ enc/trans/single_byte.trans (revision 26912) @@ -24,7 +24,7 @@ tbl_to_ucs = control1_if_needed + eval(name.gsub(/-/, '_') + "_TO_UCS_TBL") set_valid_byte_pattern(name, '1byte') code = '' - code << transcode_tblgen(name, "UTF-8", [["{00-7f}", :nomap], *tbl_to_ucs]) + code << transcode_tblgen(name, "UTF-8", [["{00-7f}", :nomap], *tbl_to_ucs.reject {|a, b| a.length != 2 }]) code << "\n" code << transcode_tblgen("UTF-8", name, [["{00-7f}", :nomap], *tbl_to_ucs.map {|a,b| [b,a] }]) code Index: tool/transcode-tblgen.rb =================================================================== --- tool/transcode-tblgen.rb (revision 26911) +++ tool/transcode-tblgen.rb (revision 26912) @@ -133,6 +133,12 @@ } end + def has_nonempty? + @pat.any? {|seq| + !seq.empty? + } + end + def first_bytes result = {} @pat.each {|seq| @@ -228,6 +234,18 @@ @map.keys.map {|k| k.max_length }.max end + def check_conflict + has_empty = false + has_nonempty = false + @map.each {|ss, action| + has_empty = true if ss.emptyable? + has_nonempty = true if ss.has_nonempty? + } + if has_empty && has_nonempty + raise "conflict between empty and nonempty sequence" + end + end + def empty_action @map.each {|ss, action| return action if ss.emptyable? @@ -440,6 +458,7 @@ table = Array.new(0x100, :invalid) each_firstbyte(valid_encoding) {|byte, rest, rest_valid_encoding| + rest.check_conflict if a = rest.empty_action table[byte] = a else -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/