1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* enc/utf_16{be,le}.c (utf16{be,le}_mbc_to_code): simplified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-04-01 05:30:25 +00:00
parent 3a4c2bc034
commit 7e3e79d083
3 changed files with 8 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Thu Apr 1 14:30:16 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enc/utf_16{be,le}.c (utf16{be,le}_mbc_to_code): simplified.
Thu Apr 1 14:07:51 2010 NARUSE, Yui <naruse@ruby-lang.org>
* util.c (BSD__hdtoa): don't use C99 macros. (FP_NORMAL etc)

View file

@ -108,9 +108,8 @@ utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED,
OnigCodePoint code;
if (UTF16_IS_SURROGATE_FIRST(*p)) {
code = ((((p[0] - 0xd8) << 2) + ((p[1] & 0xc0) >> 6) + 1) << 16)
+ ((((p[1] & 0x3f) << 2) + (p[2] - 0xdc)) << 8)
+ p[3];
code = ((((p[0] << 8) + p[1]) & 0x03ff) << 10)
+ (((p[2] << 8) + p[3]) & 0x03ff) + 0x10000;
}
else {
code = p[0] * 256 + p[1];

View file

@ -102,9 +102,8 @@ utf16le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED,
UChar c1 = *(p+1);
if (UTF16_IS_SURROGATE_FIRST(c1)) {
code = ((((c1 - 0xd8) << 2) + ((c0 & 0xc0) >> 6) + 1) << 16)
+ ((((c0 & 0x3f) << 2) + (p[3] - 0xdc)) << 8)
+ p[2];
code = ((((c1 << 8) + c0) & 0x03ff) << 10)
+ (((p[3] << 8) + p[2]) & 0x03ff) + 0x10000;
}
else {
code = c1 * 256 + p[0];