From 1169de3e61975fe00fbf4768318eb095f22c63ec Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 16 Aug 2014 14:00:02 +0200 Subject: [PATCH] fix some cases with fast zpp --- Zend/zend_API.c | 2 +- ext/pcre/php_pcre.c | 22 +++++++-------- ext/reflection/php_reflection.c | 10 +++---- ext/spl/spl_array.c | 4 +-- ext/spl/spl_engine.c | 2 +- ext/standard/array.c | 4 +-- ext/standard/html.c | 28 +++++++++---------- ext/standard/string.c | 48 ++++++++++++++++----------------- ext/standard/type.c | 4 +-- main/rfc1867.c | 6 ++--- 10 files changed, 64 insertions(+), 66 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 7ad1361210..4bd8760e6a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -426,7 +426,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons double d; int type; - if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), p, &d, -1)) == 0) { + if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), (zend_int_t *)p, &d, -1)) == 0) { return "long"; } else if (type == IS_DOUBLE) { if (c == 'L') { diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index bc878d0c31..3ff51978c9 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -544,11 +544,11 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * zend_string *subject; /* String to match against */ pcre_cache_entry *pce; /* Compiled regular expression */ zval *subpats = NULL; /* Array for subpatterns */ - long flags = 0; /* Match control flags */ - long start_offset = 0; /* Where the new search starts */ + php_int_t flags = 0; /* Match control flags */ + php_int_t start_offset = 0; /* Where the new search starts */ #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ll", ®ex, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ii", ®ex, &subject, &subpats, &flags, &start_offset) == FAILURE) { RETURN_FALSE; } @@ -1434,7 +1434,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl *subject_entry, *zcount = NULL; int limit_val = -1; - long limit = -1; + php_int_t limit = -1; zend_string *result; zend_string *string_key; ulong num_key; @@ -1443,7 +1443,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl #ifndef FAST_ZPP /* Get function parameters and do error-checking. */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz/", ®ex, &replace, &subject, &limit, &zcount) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|iz/", ®ex, &replace, &subject, &limit, &zcount) == FAILURE) { return; } #else @@ -1553,14 +1553,14 @@ static PHP_FUNCTION(preg_filter) static PHP_FUNCTION(preg_split) { zend_string *regex; /* Regular expression */ - zend_string *subject; /* String to match against */ - long limit_val = -1;/* Integer value of limit */ - long flags = 0; /* Match control flags */ + zend_string *subject; /* String to match against */ + php_int_t limit_val = -1;/* Integer value of limit */ + php_int_t flags = 0; /* Match control flags */ pcre_cache_entry *pce; /* Compiled regular expression */ /* Get function parameters and do error checking */ #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ll", ®ex, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ii", ®ex, &subject, &subject_len, &limit_val, &flags) == FAILURE) { RETURN_FALSE; } @@ -1862,12 +1862,12 @@ static PHP_FUNCTION(preg_grep) { zend_string *regex; /* Regular expression */ zval *input; /* Input array */ - long flags = 0; /* Match control flags */ + php_int_t flags = 0; /* Match control flags */ pcre_cache_entry *pce; /* Compiled regular expression */ /* Get arguments and do error checking */ #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|l", ®ex, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|i", ®ex, &input, &flags) == FAILURE) { return; } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 639016179f..f5eb473e0e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -444,7 +444,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in HashPosition pos; zval *value; zend_string *key; - ulong num_index; + php_uint_t num_index; zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos); @@ -574,7 +574,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in while ((prop = zend_hash_get_current_data_ptr_ex(properties, &pos)) != NULL) { zend_string *prop_name; - ulong index; + php_uint_t index; if (zend_hash_get_current_key_ex(properties, &prop_name, &index, 0, &pos) == HASH_KEY_IS_STRING) { if (prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */ @@ -611,7 +611,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { zend_string *key; - ulong num_index; + php_uint_t num_index; uint len = mptr->common.function_name->len; /* Do not display old-style inherited constructors */ @@ -783,7 +783,7 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i static void _function_closure_string(string *str, zend_function *fptr, char* indent TSRMLS_DC) { zend_uint i, count; - ulong num_index; + php_uint_t num_index; zend_string *key; HashTable *static_variables; HashPosition pos; @@ -3352,7 +3352,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value zend_property_info *prop_info; zval *prop, prop_copy; zend_string *key; - ulong num_index; + php_uint_t num_index; ZEND_HASH_FOREACH_KEY_PTR(&ce->properties_info, num_index, key, prop_info) { if (((prop_info->flags & ZEND_ACC_SHADOW) && diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index c7d9a951b8..d81ad6275f 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -66,7 +66,7 @@ typedef struct _spl_array_object { zval array; zval retval; HashPosition pos; - ulong pos_h; + php_uint_t pos_h; int ar_flags; int is_self; zend_function *fptr_offset_get; @@ -969,7 +969,7 @@ static int spl_array_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */ { zend_string *string_key; - ulong num_key; + php_uint_t num_key; zval *data; if (Z_TYPE(intern->array) == IS_OBJECT) { diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index 0cd63dba78..b0d9a8a1ee 100644 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -42,7 +42,7 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) PHPAPI long spl_offset_convert_to_int(zval *offset TSRMLS_DC) /* {{{ */ { - ulong idx; + php_uint_t idx; switch (Z_TYPE_P(offset)) { case IS_STRING: diff --git a/ext/standard/array.c b/ext/standard/array.c index 881809a151..6b37baaff2 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -288,12 +288,12 @@ PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ PHP_FUNCTION(count) { zval *array; - long mode = COUNT_NORMAL; + php_int_t mode = COUNT_NORMAL; php_int_t cnt; zval *element; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &array, &mode) == FAILURE) { return; } #else diff --git a/ext/standard/html.c b/ext/standard/html.c index e072abd3a4..cfc43313cf 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1442,22 +1442,21 @@ encode_amp: */ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all) { - char *str, *hint_charset = NULL; - int str_len, hint_charset_len = 0; - long flags = ENT_COMPAT; + zend_string *str, *hint_charset = NULL; + php_int_t flags = ENT_COMPAT; zend_string *replaced; zend_bool double_encode = 1; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!b", &str, &str_len, &flags, &hint_charset, &hint_charset_len, &double_encode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS!b", &str, &flags, &hint_charset, &double_encode) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STRING(str, str_len) + Z_PARAM_STR(str) Z_PARAM_OPTIONAL Z_PARAM_LONG(flags) - Z_PARAM_STRING_EX(hint_charset, hint_charset_len, 1, 0) + Z_PARAM_STR_EX(hint_charset, 1, 0) Z_PARAM_BOOL(double_encode); ZEND_PARSE_PARAMETERS_END(); #endif @@ -1465,7 +1464,7 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all) if (!hint_charset) { hint_charset = get_default_charset(TSRMLS_C); } - replaced = php_escape_html_entities_ex((unsigned char*)str, str_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC); + replaced = php_escape_html_entities_ex((unsigned char*)str->val, str->len, all, (int) flags, (hint_charset ? hint_charset->val : NULL), double_encode TSRMLS_CC); RETVAL_STR(replaced); } /* }}} */ @@ -1525,30 +1524,29 @@ PHP_FUNCTION(htmlspecialchars_decode) Convert all HTML entities to their applicable characters */ PHP_FUNCTION(html_entity_decode) { - char *str, *hint_charset = NULL; - int str_len, hint_charset_len = 0; + zend_string *str, *hint_charset = NULL; size_t new_len = 0; - long quote_style = ENT_COMPAT; + php_int_t quote_style = ENT_COMPAT; zend_string *replaced; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len, - "e_style, &hint_charset, &hint_charset_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS", &str, + "e_style, &hint_charset) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STRING(str, str_len) + Z_PARAM_STR(str) Z_PARAM_OPTIONAL Z_PARAM_LONG(quote_style) - Z_PARAM_STRING(hint_charset, hint_charset_len) + Z_PARAM_STR(hint_charset) ZEND_PARSE_PARAMETERS_END(); #endif if (!hint_charset) { hint_charset = get_default_charset(TSRMLS_C); } - replaced = php_unescape_html_entities((unsigned char*)str, str_len, 1 /*all*/, quote_style, hint_charset TSRMLS_CC); + replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, hint_charset->val TSRMLS_CC); if (replaced) { RETURN_STR(replaced); diff --git a/ext/standard/string.c b/ext/standard/string.c index ee6e1df25e..f9403e9809 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1798,26 +1798,25 @@ PHP_FUNCTION(strstr) PHP_FUNCTION(strpos) { zval *needle; - char *haystack; + zend_string *haystack; char *found = NULL; char needle_char[2]; - long offset = 0; - int haystack_len; + php_int_t offset = 0; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &needle, &offset) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STRING(haystack, haystack_len) + Z_PARAM_STR(haystack) Z_PARAM_ZVAL(needle) Z_PARAM_OPTIONAL Z_PARAM_LONG(offset) ZEND_PARSE_PARAMETERS_END(); #endif - if (offset < 0 || offset > haystack_len) { + if (offset < 0 || offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string"); RETURN_FALSE; } @@ -1828,24 +1827,24 @@ PHP_FUNCTION(strpos) RETURN_FALSE; } - found = (char*)php_memnstr(haystack + offset, + found = (char*)php_memnstr(haystack->val + offset, Z_STRVAL_P(needle), Z_STRSIZE_P(needle), - haystack + haystack_len); + haystack->val + haystack->len); } else { if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) { RETURN_FALSE; } needle_char[1] = 0; - found = (char*)php_memnstr(haystack + offset, + found = (char*)php_memnstr(haystack->val + offset, needle_char, 1, - haystack + haystack_len); + haystack->val + haystack->len); } if (found) { - RETURN_INT(found - haystack); + RETURN_INT(found - haystack->val); } else { RETURN_FALSE; } @@ -1920,18 +1919,19 @@ PHP_FUNCTION(stripos) PHP_FUNCTION(strrpos) { zval *zneedle; - char *needle, *haystack; - int needle_len, haystack_len; - long offset = 0; + char *needle; + zend_string *haystack; + php_size_t needle_len; + php_int_t offset = 0; char *p, *e, ord_needle[2]; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &zneedle, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &zneedle, &offset) == FAILURE) { RETURN_FALSE; } #else ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STRING(haystack, haystack_len) + Z_PARAM_STR(haystack) Z_PARAM_ZVAL(zneedle) Z_PARAM_OPTIONAL Z_PARAM_LONG(offset) @@ -1950,28 +1950,28 @@ PHP_FUNCTION(strrpos) needle_len = 1; } - if ((haystack_len == 0) || (needle_len == 0)) { + if ((haystack->len == 0) || (needle_len == 0)) { RETURN_FALSE; } if (offset >= 0) { - if (offset > haystack_len) { + if (offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack + offset; - e = haystack + haystack_len - needle_len; + p = haystack->val + offset; + e = haystack->val + haystack->len - needle_len; } else { - if (offset < -INT_MAX || -offset > haystack_len) { + if (offset < -INT_MAX || -offset > haystack->len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack; + p = haystack->val; if (needle_len > -offset) { - e = haystack + haystack_len - needle_len; + e = haystack->val + haystack->len - needle_len; } else { - e = haystack + haystack_len + offset; + e = haystack->val + haystack->len + offset; } } diff --git a/ext/standard/type.c b/ext/standard/type.c index 1aac60dfc2..57b3b61ce8 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -138,13 +138,13 @@ PHP_FUNCTION(settype) PHP_FUNCTION(intval) { zval *num; - long base = 10; + php_int_t base = 10; if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 2) { WRONG_PARAM_COUNT; } #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &num, &base) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &num, &base) == FAILURE) { return; } #else diff --git a/main/rfc1867.c b/main/rfc1867.c index a56777dd79..4c0f2adbf3 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -611,9 +611,9 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne } /* read until a boundary condition */ -static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, int *end TSRMLS_DC) +static int multipart_buffer_read(multipart_buffer *self, char *buf, php_size_t bytes, int *end TSRMLS_DC) { - int len, max; + php_size_t len, max; char *bound; /* fill buffer if needed */ @@ -657,7 +657,7 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, i XXX: this is horrible memory-usage-wise, but we only expect to do this on small pieces of form data. */ -static char *multipart_buffer_read_body(multipart_buffer *self, unsigned int *len TSRMLS_DC) +static char *multipart_buffer_read_body(multipart_buffer *self, php_size_t *len TSRMLS_DC) { char buf[FILLUNIT], *out=NULL; int total_bytes=0, read_bytes=0; -- 2.40.0