* enc/unicode.c: Fix flag error for switch from titlecase to lowercase.

* test/ruby/enc/test_case_mapping.rb: Tests for above error.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-05-24 23:01:39 +00:00
Родитель 85500b6634
Коммит ef6405f71c
3 изменённых файлов: 34 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Wed May 25 08:01:39 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/unicode.c: Fix flag error for switch from titlecase to lowercase.
* test/ruby/enc/test_case_mapping.rb: Tests for above error.
Wed May 25 01:13:55 2016 Kazuki Yamaguchi <k@rhe.jp>
* ext/openssl/ossl_pkey_ec.c (ec_key_new_from_group): Create a new

Просмотреть файл

@ -670,6 +670,8 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
OnigUChar *to_start = to;
OnigCaseFoldType flags = *flagP;
to_end -= CASE_MAPPING_SLACK;
/* copy flags ONIGENC_CASE_UPCASE and ONIGENC_CASE_DOWNCASE over to
* ONIGENC_CASE_UP_SPECIAL and ONIGENC_CASE_DOWN_SPECIAL */
flags |= (flags&(ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE))<<ONIGENC_CASE_SPECIAL_OFFSET;
while (*pp<end && to<=to_end) {
@ -780,7 +782,8 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
to += ONIGENC_CODE_TO_MBC(enc, code, to);
/* switch from titlecase to lowercase for capitalize */
if (flags & ONIGENC_CASE_TITLECASE)
flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_TITLECASE|ONIGENC_CASE_DOWNCASE);
flags ^= (ONIGENC_CASE_UPCASE |ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE|
ONIGENC_CASE_UP_SPECIAL|ONIGENC_CASE_DOWN_SPECIAL);
}
*flagP = flags;
return (int)(to-to_start);

Просмотреть файл

@ -9,7 +9,8 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
def check_upcase_properties(expected, start, *flags)
assert_equal expected, start.upcase(*flags)
temp = start.dup
assert_equal expected, temp.upcase!(*flags)
assert_equal expected, temp.upcase!(*flags) unless expected==temp
assert_equal nil, temp.upcase!(*flags) if expected==temp
assert_equal expected, expected.upcase(*flags)
temp = expected.dup
assert_nil temp.upcase!(*flags)
@ -18,7 +19,8 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
def check_downcase_properties(expected, start, *flags)
assert_equal expected, start.downcase(*flags)
temp = start.dup
assert_equal expected, temp.downcase!(*flags)
assert_equal expected, temp.downcase!(*flags) unless expected==temp
assert_equal nil, temp.downcase!(*flags) if expected==temp
assert_equal expected, expected.downcase(*flags)
temp = expected.dup
assert_nil temp.downcase!(*flags)
@ -27,7 +29,8 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
def check_capitalize_properties(expected, start, *flags)
assert_equal expected, start.capitalize(*flags)
temp = start.dup
assert_equal expected, temp.capitalize!(*flags)
assert_equal expected, temp.capitalize!(*flags) unless expected==temp
assert_equal nil, temp.capitalize!(*flags) if expected==temp
assert_equal expected, expected.capitalize(*flags)
temp = expected.dup
assert_nil temp.capitalize!(*flags)
@ -64,8 +67,26 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase
check_swapcase_properties 'résumé DÜRST ĭñŧėřŊÃŢIJŇŐŃæłĩżàťïōņ', 'RÉSUMÉ dürst ĬÑŦĖŘŋãţijňőńÆŁĨŻÀŤÏŌŅ', :lithuanian
end
def test_one_way_upcase
check_upcase_properties 'ΜΜΜΜΜ', 'µµµµµ', :lithuanian # MICRO SIGN -> Greek Mu
check_downcase_properties 'µµµµµ', 'µµµµµ', :lithuanian # MICRO SIGN -> Greek Mu
check_capitalize_properties 'Μµµµµ', 'µµµµµ', :lithuanian # MICRO SIGN -> Greek Mu
check_capitalize_properties 'Μµµµµ', 'µµµµµ', :turkic # MICRO SIGN -> Greek Mu
check_capitalize_properties 'H̱ẖẖẖẖ', 'ẖẖẖẖẖ', :lithuanian
check_capitalize_properties 'Βϐϐϐϐ', 'ϐϐϐϐϐ', :lithuanian
check_capitalize_properties 'Θϑϑϑϑ', 'ϑϑϑϑϑ', :lithuanian
check_capitalize_properties 'Φϕ', 'ϕϕ', :lithuanian
check_capitalize_properties 'Πϖ', 'ϖϖ', :lithuanian
check_capitalize_properties 'Κϰ', 'ϰϰ', :lithuanian
check_capitalize_properties 'Ρϱϱ', 'ϱϱϱ', :lithuanian
check_capitalize_properties 'Εϵ', 'ϵϵ', :lithuanian
check_capitalize_properties 'Ιͅͅͅͅ', 'ͅͅͅͅͅ', :lithuanian
check_capitalize_properties 'Sſſſſ', 'ſſſſſ', :lithuanian
end
def test_various
check_upcase_properties 'Μ', 'µ', :lithuanian # MICRO SIGN -> Greek Mu
check_downcase_properties 'µµµµµ', 'µµµµµ', :lithuanian # MICRO SIGN
check_capitalize_properties 'Ss', 'ß', :lithuanian
check_upcase_properties 'SS', 'ß', :lithuanian
end