Skip to content

Commit 4020ef8

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Add a __wakeup() method to SplFixedArray, thereby fixing serialising an Update NEWS small optimization fix bug #61860: use USearch for searches, it does the right thing
2 parents 70ae67b + e46beab commit 4020ef8

File tree

5 files changed

+114
-338
lines changed

5 files changed

+114
-338
lines changed

NEWS

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ PHP NEWS
2525
that other formats. (Remi)
2626

2727
- Intl:
28-
. Fixed bug #62759: Buggy grapheme_substr() on edge case. (Stas)
28+
. Fixed bug #62759 (Buggy grapheme_substr() on edge case). (Stas)
29+
. Fixed bug #61860 (Offsets may be wrong for grapheme_stri* functions).
30+
(Stas)
2931

3032
- PDO:
3133
. Allowed PDO_OCI to compile with Oracle Database 12c client libraries.

ext/intl/grapheme/grapheme_string.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PHP_FUNCTION(grapheme_strpos)
113113
unsigned char *found;
114114
long loffset = 0;
115115
int32_t offset = 0;
116-
int ret_pos, uchar_pos;
116+
int ret_pos;
117117

118118
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) {
119119

@@ -160,10 +160,10 @@ PHP_FUNCTION(grapheme_strpos)
160160
}
161161

162162
/* do utf16 part of the strpos */
163-
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, &uchar_pos, 0 /* fIgnoreCase */ TSRMLS_CC );
163+
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 0 /* fIgnoreCase */, 0 /* last */ TSRMLS_CC );
164164

165165
if ( ret_pos >= 0 ) {
166-
RETURN_LONG(ret_pos + offset);
166+
RETURN_LONG(ret_pos);
167167
} else {
168168
RETURN_FALSE;
169169
}
@@ -180,7 +180,7 @@ PHP_FUNCTION(grapheme_stripos)
180180
unsigned char *found;
181181
long loffset = 0;
182182
int32_t offset = 0;
183-
int ret_pos, uchar_pos;
183+
int ret_pos;
184184
int is_ascii;
185185

186186
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) {
@@ -235,10 +235,10 @@ PHP_FUNCTION(grapheme_stripos)
235235
}
236236

237237
/* do utf16 part of the strpos */
238-
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, &uchar_pos, 1 /* fIgnoreCase */ TSRMLS_CC );
238+
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 1 /* fIgnoreCase */, 0 /*last */ TSRMLS_CC );
239239

240240
if ( ret_pos >= 0 ) {
241-
RETURN_LONG(ret_pos + offset);
241+
RETURN_LONG(ret_pos);
242242
} else {
243243
RETURN_FALSE;
244244
}
@@ -304,7 +304,7 @@ PHP_FUNCTION(grapheme_strrpos)
304304
/* else we need to continue via utf16 */
305305
}
306306

307-
ret_pos = grapheme_strrpos_utf16(haystack, haystack_len, needle, needle_len, offset, 0 /* f_ignore_case */ TSRMLS_CC);
307+
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 0 /* f_ignore_case */, 1/* last */ TSRMLS_CC);
308308

309309
if ( ret_pos >= 0 ) {
310310
RETURN_LONG(ret_pos);
@@ -382,7 +382,7 @@ PHP_FUNCTION(grapheme_strripos)
382382
/* else we need to continue via utf16 */
383383
}
384384

385-
ret_pos = grapheme_strrpos_utf16(haystack, haystack_len, needle, needle_len, offset, 1 /* f_ignore_case */ TSRMLS_CC);
385+
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 1 /* f_ignore_case */, 1 /*last */ TSRMLS_CC);
386386

387387
if ( ret_pos >= 0 ) {
388388
RETURN_LONG(ret_pos);
@@ -659,7 +659,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
659659
}
660660

661661
/* need to work in utf16 */
662-
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, 0, &uchar_pos, f_ignore_case TSRMLS_CC );
662+
ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, 0, &uchar_pos, f_ignore_case, 0 /*last */ TSRMLS_CC );
663663

664664
if ( ret_pos < 0 ) {
665665
RETURN_FALSE;

0 commit comments

Comments
 (0)