ruby-changes:43228
From: duerst <ko1@a...>
Date: Tue, 7 Jun 2016 12:55:41 +0900 (JST)
Subject: [ruby-changes:43228] duerst:r55302 (trunk): * regenc.c (onigenc_not_support_case_map): Move to end of file;
duerst 2016-06-07 12:55:37 +0900 (Tue, 07 Jun 2016) New Revision: 55302 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55302 Log: * regenc.c (onigenc_not_support_case_map): Move to end of file; (onigenc_single_byte_ascii_only_case_map): Add new function. Modified files: trunk/ChangeLog trunk/regenc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 55301) +++ ChangeLog (revision 55302) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jun 7 12:55:34 2016 Martin Duerst <duerst@i...> + + * regenc.c (onigenc_not_support_case_map): Move to end of file; + (onigenc_single_byte_ascii_only_case_map): Add new function. + Tue Jun 7 09:26:37 2016 Martin Duerst <duerst@i...> * regenc.c (onigenc_not_support_case_map): Rewrite to work correctly Index: regenc.c =================================================================== --- regenc.c (revision 55301) +++ regenc.c (revision 55302) @@ -576,38 +576,6 @@ onigenc_not_support_get_ctype_code_range https://github.com/ruby/ruby/blob/trunk/regenc.c#L576 return ONIG_NO_SUPPORT_CONFIG; } -#ifdef ONIG_CASE_MAPPING -extern int -onigenc_not_support_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; - int codepoint_length; - - to_end -= 4; /* longest possible length of a single character */ - - while (*pp<end && to<=to_end) { - codepoint_length = ONIGENC_PRECISE_MBC_ENC_LEN(enc, *pp, end); - if (codepoint_length < 0) - return codepoint_length; /* encoding invalid */ - code = ONIGENC_MBC_TO_CODE(enc, *pp, end); - *pp += codepoint_length; - - if (code>='a' && code<='z' && (flags&ONIGENC_CASE_UPCASE)) - flags |= ONIGENC_CASE_MODIFIED, code += 'A'-'a'; - else if (code>='A' && code<='Z' && (flags&(ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) - flags |= ONIGENC_CASE_MODIFIED, code += 'a'-'A'; - to += ONIGENC_CODE_TO_MBC(enc, code, to); - if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */ - flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE); - } - *flagP = flags; - return (int)(to-to_start); -} -#endif /* ONIG_CASE_MAPPING */ - extern int onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end, OnigEncoding enc ARG_UNUSED) { @@ -989,3 +957,59 @@ onigenc_property_list_init(int (*f)(void https://github.com/ruby/ruby/blob/trunk/regenc.c#L957 THREAD_ATOMIC_END; return r; } + +#ifdef ONIG_CASE_MAPPING +extern int +onigenc_not_support_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; + int codepoint_length; + + to_end -= 4; /* longest possible length of a single character */ + + while (*pp<end && to<=to_end) { + codepoint_length = ONIGENC_PRECISE_MBC_ENC_LEN(enc, *pp, end); + if (codepoint_length < 0) + return codepoint_length; /* encoding invalid */ + code = ONIGENC_MBC_TO_CODE(enc, *pp, end); + *pp += codepoint_length; + + if (code>='a' && code<='z' && (flags&ONIGENC_CASE_UPCASE)) + flags |= ONIGENC_CASE_MODIFIED, code += 'A'-'a'; + else if (code>='A' && code<='Z' && (flags&(ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) + flags |= ONIGENC_CASE_MODIFIED, code += 'a'-'A'; + to += ONIGENC_CODE_TO_MBC(enc, code, to); + if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */ + flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE); + } + *flagP = flags; + return (int)(to-to_start); +} + +extern int +onigenc_single_byte_ascii_only_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; + + while (*pp<end && to<to_end) { + code = *(*pp)++; + + if (code>='a' && code<='z' && (flags&ONIGENC_CASE_UPCASE)) + flags |= ONIGENC_CASE_MODIFIED, code += 'A'-'a'; + else if (code>='A' && code<='Z' && (flags&(ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) + flags |= ONIGENC_CASE_MODIFIED, code += 'a'-'A'; + *to++ = code; + if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */ + flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE); + } + *flagP = flags; + return (int)(to-to_start); +} +#endif /* ONIG_CASE_MAPPING */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/