* include/ruby/oniguruma.h: Additional flag for characters that are titlecase.

* enc/unicode/case-folding.rb, casefold.h: Using above flag in data.
* enc/unicode.c: Marking capitalized character as unmodified if it is
  already titlecase.
* test/ruby/enc/test_case_mapping.rb: Tests for above functionality.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-03-22 12:08:30 +00:00
parent bf99f85941
commit 2f455ceca4
6 changed files with 63 additions and 36 deletions

View file

@ -158,6 +158,7 @@ code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
#define ST ONIGENC_CASE_TITLECASE
#define SU ONIGENC_CASE_UP_SPECIAL
#define SL ONIGENC_CASE_DOWN_SPECIAL
#define IT ONIGENC_CASE_IS_TITLECASE
#define I(n) OnigSpecialIndexEncode(n)
#define L(n) SpecialsLengthEncode(n)
@ -169,6 +170,7 @@ code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
#undef ST
#undef SU
#undef SL
#undef IT
#undef I
#undef L
@ -718,8 +720,11 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
OnigCodePoint *SpecialsStart = CaseMappingSpecials + OnigSpecialIndexDecode(folded->n);
if (OnigCaseFoldFlags(folded->n)&ONIGENC_CASE_TITLECASE) {
if (flags&ONIGENC_CASE_TITLECASE)
if (flags&ONIGENC_CASE_TITLECASE) {
if (OnigCaseFoldFlags(folded->n)&ONIGENC_CASE_IS_TITLECASE)
flags ^= ONIGENC_CASE_MODIFIED;
goto SpecialsCopy;
}
else
SpecialsStart += SpecialsLengthExtract(*SpecialsStart);
}