com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/iconv /iconv.c ext/mbstring/mbstring.c
ext/standard/html.c main/main.c
| From: | Anatol Belski | Date: | Mon, 31 Mar 2014 09:57:46 +0000 |
| Subject: | com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/iconv /iconv.c ext/mbstring/mbstring.c ext/standard/html.c main/main.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76616@lists.php.net to get a copy of this message | ||
Commit: 295cec706ee552a301f8b3865795aefd1d32a893
Author: Anatol Belski <ab@php.net> Mon, 31 Mar 2014 11:57:46 +0200
Parents: ef05ba641119466919afa187b9bf3e8d320d792a 5f54cecde99e55ed58206f6100df84c2cac264be
Branches: str_size_and_int64_56_backport
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=295cec706ee552a301f8b3865795aefd1d32a893
Log:
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6:
update lib versions
Remove unneeded string copy. Allow to set ''(empty string values)
internal/input/output_encoding for better compatibility. i.e. Runtime INI value changes. More
compliance to the RFC. Improve/add encoding handling tests. i.e. Rather than set encoding automagic
way, detect it.
Fix test
Conflicts:
ext/iconv/iconv.c
ext/standard/html.c
Changed paths:
MM ext/iconv/iconv.c
MM ext/mbstring/mbstring.c
MM ext/standard/html.c
MM main/main.c
Diff:
diff --cc ext/iconv/iconv..c
index d2f82e7,2df759f..ff7a0c2
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@@ -397,13 -418,13 +419,13 @@@ static int php_iconv_output_handler(voi
}
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
- int len;
+ php_int_t len;
- char *p = strstr(ICONVG(output_encoding), "//");
+ char *p = strstr(get_output_encoding(TSRMLS_C), "//");
if (p) {
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len
? mimetype_len : (php_size_t) strlen(mimetype), mimetype, (php_size_t)(p - ICONVG(output_encoding)),
ICONVG(output_encoding));
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len
? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - get_output_encoding(TSRMLS_C)),
get_output_encoding(TSRMLS_C));
++ len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len
? mimetype_len : (php_size_t) strlen(mimetype), mimetype, (php_size_t)(p -
get_output_encoding(TSRMLS_C)), get_output_encoding(TSRMLS_C));
} else {
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ?
mimetype_len : (php_size_t) strlen(mimetype), mimetype, ICONVG(output_encoding));
- len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ?
mimetype_len : (int) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C));
++ len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%s", mimetype_len ?
mimetype_len : (php_size_t) strlen(mimetype), mimetype, get_output_encoding(TSRMLS_C));
}
if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
SG(sapi_headers).send_default_content_type = 0;
@@@ -2002,10 -2022,10 +2024,10 @@@ static void _php_iconv_show_error(php_i
Returns the character count of str */
PHP_FUNCTION(iconv_strlen)
{
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
+ php_size_t charset_len = 0;
char *str;
- int str_len;
+ php_size_t str_len;
php_iconv_err_t err;
@@@ -2035,11 -2055,11 +2057,11 @@@
Returns specified part of a string */
PHP_FUNCTION(iconv_substr)
{
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
+ php_size_t charset_len = 0;
char *str;
- int str_len;
- long offset, length = 0;
+ php_size_t str_len;
+ php_int_t offset, length = 0;
php_iconv_err_t err;
@@@ -2075,13 -2095,13 +2097,13 @@@
Finds position of first occurrence of needle within part of haystack beginning with offset */
PHP_FUNCTION(iconv_strpos)
{
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
+ php_size_t charset_len = 0;
char *haystk;
- int haystk_len;
+ php_size_t haystk_len;
char *ndl;
- int ndl_len;
- long offset = 0;
+ php_size_t ndl_len;
+ php_int_t offset = 0;
php_iconv_err_t err;
@@@ -2123,12 -2143,12 +2145,12 @@@
Finds position of last occurrence of needle within part of haystack beginning with offset */
PHP_FUNCTION(iconv_strrpos)
{
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
+ php_size_t charset_len = 0;
char *haystk;
- int haystk_len;
+ php_size_t haystk_len;
char *ndl;
- int ndl_len;
+ php_size_t ndl_len;
php_iconv_err_t err;
@@@ -2174,9 -2194,9 +2196,9 @@@ PHP_FUNCTION(iconv_mime_encode
smart_str retval = {0};
php_iconv_err_t err;
- const char *in_charset = ICONVG(internal_encoding);
+ const char *in_charset = get_internal_encoding(TSRMLS_C);
const char *out_charset = in_charset;
- long line_len = 76;
+ php_int_t line_len = 76;
const char *lfchars = "\r\n";
php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64;
@@@ -2286,10 -2306,10 +2308,10 @@@
PHP_FUNCTION(iconv_mime_decode)
{
char *encoded_str;
- int encoded_str_len;
+ php_size_t encoded_str_len;
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
- long mode = 0;
+ php_size_t charset_len = 0;
+ php_int_t mode = 0;
smart_str retval = {0};
@@@ -2327,10 -2347,10 +2349,10 @@@
PHP_FUNCTION(iconv_mime_decode_headers)
{
const char *encoded_str;
- int encoded_str_len;
+ php_size_t encoded_str_len;
- char *charset = ICONVG(internal_encoding);
+ char *charset = get_internal_encoding(TSRMLS_C);
- int charset_len = 0;
- long mode = 0;
+ php_size_t charset_len = 0;
+ php_int_t mode = 0;
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
diff --cc ext/standard/html.c
index 3afd3c96,5bbe39c..f3353ad
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@@ -1445,10 -1444,10 +1444,10 @@@ encode_amp
*/
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
- char *str, *hint_charset = "";
+ char *str, *hint_charset = NULL;
- int str_len, hint_charset_len = 0;
+ php_size_t str_len, hint_charset_len = 0;
size_t new_len;
- long flags = ENT_COMPAT;
+ php_int_t flags = ENT_COMPAT;
char *replaced;
zend_bool double_encode = 1;
@@@ -1524,27 -1520,24 +1520,24 @@@ PHP_FUNCTION(htmlspecialchars_decode
Convert all HTML entities to their applicable characters */
PHP_FUNCTION(html_entity_decode)
{
- char *str, *hint_charset = "";
- php_size_t str_len, hint_charset_len = 0;
+ char *str, *hint_charset = NULL;
- int str_len, hint_charset_len;
++ php_size_t str_len, hint_charset_len;
size_t new_len = 0;
- long quote_style = ENT_COMPAT;
+ php_int_t quote_style = ENT_COMPAT;
char *replaced;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS", &str, &str_len,
"e_style, &hint_charset, &hint_charset_len) == FAILURE) {
return;
}
- if (hint_charset_len) {
- replaced = php_unescape_html_entities(str, str_len, &new_len, 1 /*all*/, quote_style,
hint_charset TSRMLS_CC);
- } else {
- get_charset(&hint_charset, &hint_charset_len TSRMLS_CC);
- replaced = php_unescape_html_entities(str, str_len, &new_len, 1 /*all*/, quote_style,
hint_charset TSRMLS_CC);
- efree(hint_charset);
+ if (!hint_charset) {
+ hint_charset = get_default_charset(TSRMLS_C);
}
+ replaced = php_unescape_html_entities(str, str_len, &new_len, 1 /*all*/, quote_style,
hint_charset TSRMLS_CC);
if (replaced) {
- RETURN_STRINGL(replaced, (int)new_len, 0);
+ RETURN_STRINGL(replaced, new_len, 0);
}
RETURN_FALSE;
}