diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-07-23 15:36:25 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-07-23 15:36:25 +0200 |
commit | 7077c719db0b07dc0306390455a51e95eb5e904d (patch) | |
tree | f558f79191315923795d076a94a65e481a9ae768 /ext/mbstring/php_unicode.c | |
parent | 698132d6f981b118642a85e964a10f4721f903e4 (diff) | |
parent | 077e61fad3c5fbdbe8df4371b88f64bcc4a6bccd (diff) | |
download | php-git-7077c719db0b07dc0306390455a51e95eb5e904d.tar.gz |
Merge branch 'PHP-7.2'
Diffstat (limited to 'ext/mbstring/php_unicode.c')
-rw-r--r-- | ext/mbstring/php_unicode.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index 208c10319e..2baa4690c9 100644 --- a/ext/mbstring/php_unicode.c +++ b/ext/mbstring/php_unicode.c @@ -116,6 +116,7 @@ MBSTRING_API int php_unicode_is_prop(unsigned long code, ...) static unsigned long case_lookup(unsigned long code, long l, long r, int field) { long m; + const unsigned int *tmp; /* * Do the binary search. @@ -126,13 +127,13 @@ static unsigned long case_lookup(unsigned long code, long l, long r, int field) * the beginning of a case mapping triple. */ m = (l + r) >> 1; - m -= (m % 3); - if (code > _uccase_map[m]) - l = m + 3; - else if (code < _uccase_map[m]) - r = m - 3; - else if (code == _uccase_map[m]) - return _uccase_map[m + field]; + tmp = &_uccase_map[m*3]; + if (code > *tmp) + l = m + 1; + else if (code < *tmp) + r = m - 1; + else if (code == *tmp) + return tmp[field]; } return code; @@ -161,16 +162,16 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_ /* * The character is lower case. */ - field = 2; + field = 1; l = _uccase_len[0]; - r = (l + _uccase_len[1]) - 3; + r = (l + _uccase_len[1]) - 1; } else { /* * The character is title case. */ field = 1; l = _uccase_len[0] + _uccase_len[1]; - r = _uccase_size - 3; + r = _uccase_size - 1; } return case_lookup(code, l, r, field); } @@ -200,14 +201,14 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_ */ field = 1; l = 0; - r = _uccase_len[0] - 3; + r = _uccase_len[0] - 1; } else { /* * The character is title case. */ field = 2; l = _uccase_len[0] + _uccase_len[1]; - r = _uccase_size - 3; + r = _uccase_size - 1; } return case_lookup(code, l, r, field); } @@ -230,13 +231,13 @@ MBSTRING_API unsigned long php_unicode_totitle(unsigned long code, enum mbfl_no_ * The character is upper case. */ l = 0; - r = _uccase_len[0] - 3; + r = _uccase_len[0] - 1; } else { /* * The character is lower case. */ l = _uccase_len[0]; - r = (l + _uccase_len[1]) - 3; + r = (l + _uccase_len[1]) - 1; } return case_lookup(code, l, r, field); |