1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

s/unicode/Unicode/ in error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-12-02 02:53:46 +00:00
parent 0893957bc6
commit 9bd11f24b3
2 changed files with 81 additions and 13 deletions

12
re.c
View file

@ -1446,11 +1446,11 @@ unescape_unicode_list(const char **pp, const char *end,
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 @@ unescape_unicode_list(const char **pp, const char *end,
}
if (has_unicode == 0) {
strcpy(err, "invalid unicode list");
strcpy(err, "invalid Unicode list");
return -1;
}
@ -1480,12 +1480,12 @@ unescape_unicode_bmp(const char **pp, const char *end,
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 @@ unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
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;

View file

@ -15,7 +15,7 @@ class TestM17N < Test::Unit::TestCase
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 @@ class TestM17N < Test::Unit::TestCase
}
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