ruby-changes:2587
From: ko1@a...
Date: 2 Dec 2007 11:53:55 +0900
Subject: [ruby-changes:2587] akr - Ruby:r14078 (trunk): s/unicode/Unicode/ in error messages.
akr 2007-12-02 11:53:46 +0900 (Sun, 02 Dec 2007) New Revision: 14078 Modified files: trunk/re.c trunk/test/ruby/test_m17n.rb Log: s/unicode/Unicode/ in error messages. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=14078&r2=14077 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=14078&r2=14077 Index: re.c =================================================================== --- re.c (revision 14077) +++ re.c (revision 14078) @@ -1446,11 +1446,11 @@ if (len == 0) break; if (6 < len) { /* max 10FFFF */ - strcpy(err, "invalid unicode range"); + strcpy(err, "invalid Unicode range"); return -1; } if (0x10ffff < code) { - strcpy(err, "invalid unicode range"); + strcpy(err, "invalid Unicode range"); return -1; } p += len; @@ -1462,7 +1462,7 @@ } if (has_unicode == 0) { - strcpy(err, "invalid unicode list"); + strcpy(err, "invalid Unicode list"); return -1; } @@ -1480,12 +1480,12 @@ unsigned long code; if (end < p+4) { - strcpy(err, "invalid unicode escape"); + strcpy(err, "invalid Unicode escape"); return -1; } code = ruby_scan_hex(p, 4, &len); if (len != 4) { - strcpy(err, "invalid unicode escape"); + strcpy(err, "invalid Unicode escape"); return -1; } if (append_utf8(code, buf, encp, err) != 0) @@ -1562,7 +1562,7 @@ if (unescape_unicode_list(&p, end, buf, encp, err) != 0) return -1; if (p == end || *p++ != '}') { - strcpy(err, "invalid unicode list"); + strcpy(err, "invalid Unicode list"); return -1; } break; Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 14077) +++ test/ruby/test_m17n.rb (revision 14078) @@ -15,7 +15,7 @@ assert_encoding("ASCII-8BIT", eval(a(%{"a"})).encoding) end - def test_string_euc_literal + def test_string_eucjp_literal assert_encoding("ASCII-8BIT", eval(e(%{""})).encoding) assert_encoding("ASCII-8BIT", eval(e(%{"a"})).encoding) assert_encoding("EUC-JP", eval(e(%{"\xa1\xa1"})).encoding) @@ -302,11 +302,79 @@ } end - def test_dynamic_euc_regexp - assert_encoding("EUC-JP", /#{}\xc0\xa1/e.encoding) - assert_raise(RegexpError) { eval('/\xa1#{}/e') } - assert_raise(RegexpError) { eval('/#{}\xa1/e') } - #assert_raise(SyntaxError) { eval('/\xa1#{}\xa1/e') } - #assert_raise(SyntaxError) { s = e('\xa1'); /#{s}#{s}/ } + def test_dynamic_ascii_regexp + assert_regexp_fixed_ascii8bit(/#{}/n) + assert_regexp_fixed_ascii8bit(/#{}\xc0\xa1/n) + assert_regexp_fixed_ascii8bit(/\xc0\xa1#{}/n) + #assert_raise(SyntaxError) { eval('/\xc0#{}\xa1/s') } + #assert_raise(SyntaxError) { s1, s2 = s('\xc0'), s('\xa1'); /#{s1}#{s2}/ } end + + def test_dynamic_eucjp_regexp + assert_regexp_fixed_eucjp(/#{}/e) + assert_regexp_fixed_eucjp(/#{}\xc0\xa1/e) + assert_regexp_fixed_eucjp(/\xc0\xa1#{}/e) + assert_raise(RegexpError) { eval('/\xc0#{}/e') } + assert_raise(RegexpError) { eval('/#{}\xc0/e') } + #assert_raise(SyntaxError) { eval('/\xc0#{}\xa1/e') } + #assert_raise(SyntaxError) { s1, s2 = e('\xc0'), e('\xa1'); /#{s1}#{s2}/ } + end + + def test_dynamic_sjis_regexp + assert_regexp_fixed_sjis(/#{}/s) + assert_regexp_fixed_sjis(/#{}\xc0\xa1/s) + assert_regexp_fixed_sjis(/\xc0\xa1#{}/s) + assert_raise(RegexpError) { eval('/\x81#{}/s') } + assert_raise(RegexpError) { eval('/#{}\x81/s') } + #assert_raise(SyntaxError) { eval('/\x81#{}\xa1/s') } + #assert_raise(SyntaxError) { s1, s2 = s('\x81'), s('\xa1'); /#{s1}#{s2}/ } + end + + def test_dynamic_utf8_regexp + assert_regexp_fixed_utf8(/#{}/u) + assert_regexp_fixed_utf8(/#{}\xc0\xa1/u) + assert_regexp_fixed_utf8(/\xc0\xa1#{}/u) + assert_raise(RegexpError) { eval('/\xc0#{}/u') } + assert_raise(RegexpError) { eval('/#{}\xc0/u') } + #assert_raise(SyntaxError) { eval('/\xc0#{}\xa1/u') } + #assert_raise(SyntaxError) { s1, s2 = u('\xc0'), u('\xa1'); /#{s1}#{s2}/ } + end + + def test_regexp_mixed_unicode + assert_raise(SyntaxError) { eval(a(%{/\xc0\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(e(%{/\xc0\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(s(%{/\xc0\xa0\\u{6666}/})) } + assert_nothing_raised { eval(u(%{/\xc0\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(a(%{/\\u{6666}\xc0\xa0/})) } + assert_raise(SyntaxError) { eval(e(%{/\\u{6666}\xc0\xa0/})) } + assert_raise(SyntaxError) { eval(s(%{/\\u{6666}\xc0\xa0/})) } + assert_nothing_raised { eval(u(%{/\\u{6666}\xc0\xa0/})) } + + assert_raise(SyntaxError) { eval(a(%{/\\xc0\\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(e(%{/\\xc0\\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(s(%{/\\xc0\\xa0\\u{6666}/})) } + assert_nothing_raised { eval(u(%{/\\xc0\\xa0\\u{6666}/})) } + assert_raise(SyntaxError) { eval(a(%{/\\u{6666}\\xc0\\xa0/})) } + assert_raise(SyntaxError) { eval(e(%{/\\u{6666}\\xc0\\xa0/})) } + assert_raise(SyntaxError) { eval(s(%{/\\u{6666}\\xc0\\xa0/})) } + assert_nothing_raised { eval(u(%{/\\u{6666}\\xc0\\xa0/})) } + + assert_raise(SyntaxError) { eval(a(%{/\xc0\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(e(%{/\xc0\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(s(%{/\xc0\xa0#{}\\u{6666}/})) } + assert_nothing_raised { eval(u(%{/\xc0\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(a(%{/\\u{6666}#{}\xc0\xa0/})) } + assert_raise(SyntaxError) { eval(e(%{/\\u{6666}#{}\xc0\xa0/})) } + assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\xc0\xa0/})) } + assert_nothing_raised { eval(u(%{/\\u{6666}#{}\xc0\xa0/})) } + + assert_raise(SyntaxError) { eval(a(%{/\\xc0\\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(e(%{/\\xc0\\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(s(%{/\\xc0\\xa0#{}\\u{6666}/})) } + assert_nothing_raised { eval(u(%{/\\xc0\\xa0#{}\\u{6666}/})) } + assert_raise(SyntaxError) { eval(a(%{/\\u{6666}#{}\\xc0\\xa0/})) } + assert_raise(SyntaxError) { eval(e(%{/\\u{6666}#{}\\xc0\\xa0/})) } + assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\\xc0\\xa0/})) } + assert_nothing_raised { eval(u(%{/\\u{6666}#{}\\xc0\\xa0/})) } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml