aboutsummaryrefslogtreecommitdiffstats
path: root/enc/unicode.c
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-16 01:24:03 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-16 01:24:03 +0000
commitbe897c2507a9d7710f218ccf377e6ea67d6d47bf (patch)
tree1ced89fb677d813b33a1b30db54d141934c88299 /enc/unicode.c
parent2fd11c760ca2f903092c461566bd522636ea45cc (diff)
downloadruby-be897c2507a9d7710f218ccf377e6ea67d6d47bf.tar.gz
* string.c, enc/unicode.c: New code path as a preparation for Unicode-wide
case mapping. The code path is currently guarded by the :lithuanian option to avoid accidental problems in daily use. * test/ruby/enc/test_case_mapping.rb: Test for above. * string.c: function 'check_case_options': fixed logical errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode.c')
-rw-r--r--enc/unicode.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/enc/unicode.c b/enc/unicode.c
index 9c0b326d0b..2f45f2f88c 100644
--- a/enc/unicode.c
+++ b/enc/unicode.c
@@ -603,3 +603,32 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
return n;
}
+
+/* length in bytes for three characters in UTF-32; e.g. needed for ffi (U+FB03) */
+#define CASE_MAPPING_SLACK 12
+/* The following declaration should be moved to an include file rather than
+ 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,
+ const OnigUChar** pp, const OnigUChar* end,
+ OnigUChar* to, OnigUChar* to_end,
+ const struct OnigEncodingTypeST* enc)
+{
+ OnigCodePoint code;
+ OnigUChar *to_start = to;
+ to_end -= CASE_MAPPING_SLACK;
+
+ /* hopelessly preliminary implementation, just dealing with ASCII,
+ * and just for downcase */
+ while (*pp<end && to<=to_end) {
+ code = ONIGENC_MBC_TO_CODE(enc, *pp, end);
+ *pp += enclen(enc, *pp, end);
+ if (code>='A' && code<='Z') {
+ code += 'a'-'A';
+ *flags |= ONIGENC_CASE_MODIFIED;
+ }
+ to += ONIGENC_CODE_TO_MBC(enc, code, to);
+ }
+ return to-to_start;
+}