ruby-changes:43558
From: duerst <ko1@a...>
Date: Mon, 11 Jul 2016 17:49:43 +0900 (JST)
Subject: [ruby-changes:43558] duerst:r55631 (trunk): * enc/iso_8859_4.c, enc/iso_8859_10.c, enc/iso_8859_14.c,
duerst 2016-07-11 17:49:38 +0900 (Mon, 11 Jul 2016) New Revision: 55631 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55631 Log: * enc/iso_8859_4.c, enc/iso_8859_10.c, enc/iso_8859_14.c, enc/iso_8859_15.c, enc/iso_8859_16.c: Replace case-by-case code with lookup in ENC_ISO_8859_xx_TO_LOWER_CASE table. Modified files: trunk/ChangeLog trunk/enc/iso_8859_10.c trunk/enc/iso_8859_14.c trunk/enc/iso_8859_15.c trunk/enc/iso_8859_16.c trunk/enc/iso_8859_4.c Index: enc/iso_8859_4.c =================================================================== --- enc/iso_8859_4.c (revision 55630) +++ enc/iso_8859_4.c (revision 55631) @@ -250,14 +250,7 @@ case_map(OnigCaseFoldType* flagP, const https://github.com/ruby/ruby/blob/trunk/enc/iso_8859_4.c#L250 else if ((EncISO_8859_4_CtypeTable[code] & BIT_CTYPE_UPPER) && (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) { flags |= ONIGENC_CASE_MODIFIED; - if (code>=0xA0 && code<=0xBF) { - if (code==0xBD) - code += 0x02; - else - code += 0x10; - } - else - code += 0x20; + code = ENC_ISO_8859_4_TO_LOWER_CASE(code); } else if ((EncISO_8859_4_CtypeTable[code]&BIT_CTYPE_LOWER) && (flags&ONIGENC_CASE_UPCASE)) { Index: enc/iso_8859_10.c =================================================================== --- enc/iso_8859_10.c (revision 55630) +++ enc/iso_8859_10.c (revision 55631) @@ -252,10 +252,7 @@ case_map (OnigCaseFoldType* flagP, const https://github.com/ruby/ruby/blob/trunk/enc/iso_8859_10.c#L252 else if ((EncISO_8859_10_CtypeTable[code] & BIT_CTYPE_UPPER) && (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) { flags |= ONIGENC_CASE_MODIFIED; - if (code>=0xA0 && code<=0xBF) - code += 0x10; - else - code += 0x20; + code = ENC_ISO_8859_10_TO_LOWER_CASE(code); } else if ((EncISO_8859_10_CtypeTable[code]&BIT_CTYPE_LOWER) && (flags&ONIGENC_CASE_UPCASE)) { Index: enc/iso_8859_14.c =================================================================== --- enc/iso_8859_14.c (revision 55630) +++ enc/iso_8859_14.c (revision 55631) @@ -254,20 +254,7 @@ case_map (OnigCaseFoldType* flagP, const https://github.com/ruby/ruby/blob/trunk/enc/iso_8859_14.c#L254 else if ((EncISO_8859_14_CtypeTable[code] & BIT_CTYPE_UPPER) && (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) { flags |= ONIGENC_CASE_MODIFIED; - if (code == 0xA1 || code == 0xA4 || code == 0xB0 || code == 0xB2 || code == 0xB4 || code == 0xBD) - code += 0x1; - else if(code == 0xA6) - code += 0x5; - else if(code == 0xAF) - code += 0x50; - else if(code == 0xB7) - code += 0x2; - else if(code == 0xBB) - code += 0x4; - else if(code == 0xA8 || code == 0xAA || code == 0xAC) - code += 0x10; - else - code += 0x20; + code = ENC_ISO_8859_14_TO_LOWER_CASE(code); } else if ((EncISO_8859_14_CtypeTable[code]&BIT_CTYPE_LOWER) && (flags&ONIGENC_CASE_UPCASE)) { Index: enc/iso_8859_15.c =================================================================== --- enc/iso_8859_15.c (revision 55630) +++ enc/iso_8859_15.c (revision 55631) @@ -248,16 +248,7 @@ case_map (OnigCaseFoldType* flagP, const https://github.com/ruby/ruby/blob/trunk/enc/iso_8859_15.c#L248 else if ((EncISO_8859_15_CtypeTable[code] & BIT_CTYPE_UPPER) && (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) { flags |= ONIGENC_CASE_MODIFIED; - if (code==0xA6) - code += 2; - else if (code==0xB4) - code += 4; - else if (code==0xBC) - code += 1; - else if (code==0xBE) - code += 0x41; - else - code += 0x20; + code = ENC_ISO_8859_15_TO_LOWER_CASE(code); } else if ((EncISO_8859_15_CtypeTable[code]&BIT_CTYPE_LOWER) && (flags&ONIGENC_CASE_UPCASE)) { Index: enc/iso_8859_16.c =================================================================== --- enc/iso_8859_16.c (revision 55630) +++ enc/iso_8859_16.c (revision 55631) @@ -249,20 +249,7 @@ case_map (OnigCaseFoldType* flagP, const https://github.com/ruby/ruby/blob/trunk/enc/iso_8859_16.c#L249 else if ((EncISO_8859_16_CtypeTable[code] & BIT_CTYPE_UPPER) && (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) { flags |= ONIGENC_CASE_MODIFIED; - if (code==0xA1 || code==0xBC) - code++; - else if (code==0xA3 || code==0xAA || code==0xAF) - code += 0x10; - else if (code==0xA6 || code==0xAC) - code += 0x02; - else if (code==0xB2) - code += 0x07; - else if (code==0xB4) - code += 0x04; - else if (code==0xBE) - code += 0x41; - else - code += 0x20; + code = ENC_ISO_8859_16_TO_LOWER_CASE(code); } else if ((EncISO_8859_16_CtypeTable[code]&BIT_CTYPE_LOWER) && (flags&ONIGENC_CASE_UPCASE)) { Index: ChangeLog =================================================================== --- ChangeLog (revision 55630) +++ ChangeLog (revision 55631) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 11 17:49:25 2016 Martin Duerst <duerst@i...> + + * enc/iso_8859_4.c, enc/iso_8859_10.c, enc/iso_8859_14.c, + enc/iso_8859_15.c, enc/iso_8859_16.c: Replace case-by-case code with + lookup in ENC_ISO_8859_xx_TO_LOWER_CASE table. + Mon Jul 11 16:00:56 2016 Nobuyoshi Nakada <nobu@r...> * ext/stringio/stringio.c (strio_each, strio_readlines): convert -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/