diff options
author | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-16 08:24:58 +0000 |
---|---|---|
committer | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-16 08:24:58 +0000 |
commit | c12af76763a1bff53ed77bc4d236f441d8679880 (patch) | |
tree | 25e4f32d2f10ea1235bed8d9300faced113f0519 /enc/unicode.c | |
parent | d2076446ede4113260d94b29b8bd9334c6dd91ec (diff) |
* enc/unicode.c: Artificial mapping to test buffer expansion code.
* string.c: Fixed buffer expansion logic.
* test/ruby/enc/test_case_mapping.rb: Tests for above.
(with Kimihito Matsui)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode.c')
-rw-r--r-- | enc/unicode.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/enc/unicode.c b/enc/unicode.c index 365283e591..e877c99925 100644 --- a/enc/unicode.c +++ b/enc/unicode.c @@ -610,13 +610,14 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, be duplicated here (and in string.c), but we'll wait for this because we want this to become a primitive anyway. */ extern int -onigenc_unicode_case_map(OnigCaseFoldType* flags, +onigenc_unicode_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc) { OnigCodePoint code; OnigUChar *to_start = to; + OnigCaseFoldType flags = *flagP; to_end -= CASE_MAPPING_SLACK; /* hopelessly preliminary implementation, just dealing with ASCII, @@ -624,11 +625,25 @@ onigenc_unicode_case_map(OnigCaseFoldType* flags, while (*pp<end && to<=to_end) { code = ONIGENC_MBC_TO_CODE(enc, *pp, end); *pp += enclen(enc, *pp, end); - if (code>='A' && code<='Z') { + /* using :turcic to test buffer expansion */ + if (flags&ONIGENC_CASE_FOLD_TURKISH_AZERI && code==0x0049) { /* I */ + to += ONIGENC_CODE_TO_MBC(enc, 'T', to); + to += ONIGENC_CODE_TO_MBC(enc, 'U', to); + to += ONIGENC_CODE_TO_MBC(enc, 'R', to); + to += ONIGENC_CODE_TO_MBC(enc, 'K', to); + to += ONIGENC_CODE_TO_MBC(enc, 'I', to); + to += ONIGENC_CODE_TO_MBC(enc, 'S', to); + to += ONIGENC_CODE_TO_MBC(enc, 'H', to); + to += ONIGENC_CODE_TO_MBC(enc, '*', to); + code = 0x0131; + flags |= ONIGENC_CASE_MODIFIED; + } + else if (code>='A' && code<='Z') { code += 'a'-'A'; - *flags |= ONIGENC_CASE_MODIFIED; + flags |= ONIGENC_CASE_MODIFIED; } to += ONIGENC_CODE_TO_MBC(enc, code, to); } + *flagP = flags; return (int)(to-to_start); } |