]> granicus.if.org Git - php/commitdiff
fix some cases with fast zpp
authorAnatol Belski <ab@php.net>
Sat, 16 Aug 2014 12:00:02 +0000 (14:00 +0200)
committerAnatol Belski <ab@php.net>
Sat, 16 Aug 2014 12:00:02 +0000 (14:00 +0200)
Zend/zend_API.c
ext/pcre/php_pcre.c
ext/reflection/php_reflection.c
ext/spl/spl_array.c
ext/spl/spl_engine.c
ext/standard/array.c
ext/standard/html.c
ext/standard/string.c
ext/standard/type.c
main/rfc1867.c

index 7ad1361210dd4cef3a98b346b391f93d0b16c504..4bd8760e6aa8094b352a7d917048ae33906992b5 100644 (file)
@@ -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') {
index bc878d0c31c73a175b5674dcf163e5fe8affd71e..3ff51978c93dbde2cb670c1bedddd34a7b1d0d9c 100644 (file)
@@ -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", &regex,
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ii", &regex,
                                                          &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/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|iz/", &regex, &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", &regex,
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ii", &regex,
                                                          &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", &regex,
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|i", &regex,
                                                          &input, &flags) == FAILURE) {
                return;
        }
index 639016179f89838e2f250e8c137f626525342bf2..f5eb473e0e6602115161a71b748ad9df78b091a0 100644 (file)
@@ -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) &&
index c7d9a951b8b1aefdfaf9e67968ecaa26ae569677..d81ad6275f6569921595f4833426dff965ddfedc 100644 (file)
@@ -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) {
index 0cd63dba78957d2c74393d05dae7d973f797d18b..b0d9a8a1eec0143ee37bd39c5514c23ace031451 100644 (file)
@@ -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:
index 881809a151e6701ad2f9975900ff9927ea961261..6b37baaff27d5b3ebb9442866f0829a84a59b1c8 100644 (file)
@@ -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
index e072abd3a483fa64eca45012fe6eb24c1846e527..cfc43313cf782bc5312dd758f68b11b4d79975c2 100644 (file)
@@ -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,
-                                                         &quote_style, &hint_charset, &hint_charset_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS", &str,
+                                                         &quote_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);
index ee6e1df25e222b7197145f18c9befb34d5a35fb5..f9403e98096f142786fb9ae79e0423e9b043976f 100644 (file)
@@ -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;
                }
        }
 
index 1aac60dfc2cb51a21ba9f852500eedf3fd022b60..57b3b61ce8d7e633995b7dd78fd617e8f3fb82e0 100644 (file)
@@ -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
index a56777dd79c5ac7589fb8d0650e12224c96b6a52..4c0f2adbf3091ac1f12f7402627b3f8aa705a896 100644 (file)
@@ -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;