diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | enc/unicode.c | 5 | ||||
-rw-r--r-- | test/ruby/enc/test_case_mapping.rb | 27 |
3 files changed, 34 insertions, 4 deletions
@@ -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 diff --git a/enc/unicode.c b/enc/unicode.c index 8f978bc9a7..22d1dda809 100644 --- a/enc/unicode.c +++ b/enc/unicode.c @@ -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); diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb index 5fb7339eeb..2ef3360314 100644 --- a/test/ruby/enc/test_case_mapping.rb +++ b/test/ruby/enc/test_case_mapping.rb @@ -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 |