diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-07-23 14:47:21 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-07-23 14:47:21 +0200 |
commit | 0e4af9192f03fcfaa38454dbb3ffd8924bb26375 (patch) | |
tree | 5a20f37738d028db3e00990c3197a50209e0b31b /ext/mbstring/php_unicode.c | |
parent | 88f752a9471b9fdc3dcdbdc0c110faedae31feab (diff) | |
download | php-git-0e4af9192f03fcfaa38454dbb3ffd8924bb26375.tar.gz |
Partial fix for bug #69267
This pulls in 60a25c72ba389f53b0621ca250bc99f3b295d43f from the
OpenLDAP project.
Diffstat (limited to 'ext/mbstring/php_unicode.c')
-rw-r--r-- | ext/mbstring/php_unicode.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index 8b6a52156a..9771289cd0 100644 --- a/ext/mbstring/php_unicode.c +++ b/ext/mbstring/php_unicode.c @@ -122,6 +122,7 @@ MBSTRING_API int php_unicode_is_prop(unsigned long code, unsigned long mask1, static unsigned long case_lookup(unsigned long code, long l, long r, int field) { long m; + const unsigned int *tmp; /* * Do the binary search. @@ -132,13 +133,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; @@ -174,7 +175,7 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_ */ field = 2; l = _uccase_len[0]; - r = (l + _uccase_len[1]) - 3; + r = (l + _uccase_len[1]) - 1; if (enc == mbfl_no_encoding_8859_9) { return php_turkish_toupper(code, l, r, field); @@ -186,7 +187,7 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_ */ field = 1; l = _uccase_len[0] + _uccase_len[1]; - r = _uccase_size - 3; + r = _uccase_size - 1; } return case_lookup(code, l, r, field); } @@ -205,7 +206,7 @@ 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; if (enc == mbfl_no_encoding_8859_9) { return php_turkish_tolower(code, l, r, field); @@ -217,7 +218,7 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_ */ field = 2; l = _uccase_len[0] + _uccase_len[1]; - r = _uccase_size - 3; + r = _uccase_size - 1; } return case_lookup(code, l, r, field); } @@ -240,13 +241,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); |