com php-src: Merge branch 'PHP-5.6' into PHP-7.0: ext/intl/grap heme/grapheme_string.c

From: Date: Sun, 27 Nov 2016 23:36:29 +0000
Subject: com php-src: Merge branch 'PHP-5.6' into PHP-7.0: ext/intl/grap heme/grapheme_string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96084@lists.php.net to get a copy of this message
Commit: f1a9851c3e4aa5606d209b44742dc7156b49f7b7 Author: Stanislav Malyshev <stas@php.net> Sun, 27 Nov 2016 15:36:29 -0800 Parents: 1cb58ead7032a4fe11cda07181997705c37610f1 8856b3a63c6b3eefe83aecaa9e18afb640173708 Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f1a9851c3e4aa5606d209b44742dc7156b49f7b7 Log: Merge branch 'PHP-5.6' into PHP-7.0 * PHP-5.6: Fix #68447: grapheme_extract take an extra trailing character Bugs: https://bugs.php.net/68447 Changed paths: MM ext/intl/grapheme/grapheme_string.c Diff: diff --cc ext/intl/grapheme/grapheme_string.c index 5687e3e,d298bab..f695004 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@@ -868,44 -885,35 +855,35 @@@ PHP_FUNCTION(grapheme_extract if ( NULL != next ) { ZVAL_LONG(next, start+nsize); } - RETURN_STRINGL(((char *)pstr), nsize, 1); + RETURN_STRINGL(pstr, nsize); } - /* convert the strings to UTF-16. */ - ustr = NULL; - ustr_len = 0; status = U_ZERO_ERROR; - intl_convert_utf8_to_utf16(&ustr, &ustr_len, pstr, str_len, &status ); + utext_openUTF8(&ut, pstr, str_len, &status); if ( U_FAILURE( status ) ) { /* Set global error code. */ - intl_error_set_code( NULL, status TSRMLS_CC ); + intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 ); - - if ( NULL != ustr ) - efree( ustr ); - intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 TSRMLS_CC ); ++ intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 ); RETURN_FALSE; } bi = NULL; status = U_ZERO_ERROR; - bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status TSRMLS_CC ); + bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status ); - ubrk_setText(bi, ustr, ustr_len, &status); - + ubrk_setUText(bi, &ut, &status); /* if the caller put us in the middle of a grapheme, we can't detect it in all cases since we can't back up. So, we will not do anything. */ /* now we need to find the end of the chunk the user wants us to return */ - - ret_pos = (*grapheme_extract_iters[extract_type])(bi, size, pstr, str_len); + /* it's ok to convert str_len to in32_t since if it were too big intl_convert_utf8_to_utf16 above would fail */ + ret_pos = (*grapheme_extract_iters[extract_type])(bi, size, (unsigned char *)pstr, (int32_t)str_len); - if (ustr) { - efree(ustr); - } + utext_close(&ut); ubrk_close(bi); if ( NULL != next ) {

« previous php.cvs (#96084) next »