Skip to content

Commit 1169de3

Browse files
committed
fix some cases with fast zpp
1 parent b7e7a89 commit 1169de3

File tree

10 files changed

+64
-66
lines changed

10 files changed

+64
-66
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
426426
double d;
427427
int type;
428428

429-
if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), p, &d, -1)) == 0) {
429+
if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), (zend_int_t *)p, &d, -1)) == 0) {
430430
return "long";
431431
} else if (type == IS_DOUBLE) {
432432
if (c == 'L') {

ext/pcre/php_pcre.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
544544
zend_string *subject; /* String to match against */
545545
pcre_cache_entry *pce; /* Compiled regular expression */
546546
zval *subpats = NULL; /* Array for subpatterns */
547-
long flags = 0; /* Match control flags */
548-
long start_offset = 0; /* Where the new search starts */
547+
php_int_t flags = 0; /* Match control flags */
548+
php_int_t start_offset = 0; /* Where the new search starts */
549549

550550
#ifndef FAST_ZPP
551-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ll", &regex,
551+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|z/ii", &regex,
552552
&subject, &subpats, &flags, &start_offset) == FAILURE) {
553553
RETURN_FALSE;
554554
}
@@ -1434,7 +1434,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
14341434
*subject_entry,
14351435
*zcount = NULL;
14361436
int limit_val = -1;
1437-
long limit = -1;
1437+
php_int_t limit = -1;
14381438
zend_string *result;
14391439
zend_string *string_key;
14401440
ulong num_key;
@@ -1443,7 +1443,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
14431443

14441444
#ifndef FAST_ZPP
14451445
/* Get function parameters and do error-checking. */
1446-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
1446+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|iz/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
14471447
return;
14481448
}
14491449
#else
@@ -1553,14 +1553,14 @@ static PHP_FUNCTION(preg_filter)
15531553
static PHP_FUNCTION(preg_split)
15541554
{
15551555
zend_string *regex; /* Regular expression */
1556-
zend_string *subject; /* String to match against */
1557-
long limit_val = -1;/* Integer value of limit */
1558-
long flags = 0; /* Match control flags */
1556+
zend_string *subject; /* String to match against */
1557+
php_int_t limit_val = -1;/* Integer value of limit */
1558+
php_int_t flags = 0; /* Match control flags */
15591559
pcre_cache_entry *pce; /* Compiled regular expression */
15601560

15611561
/* Get function parameters and do error checking */
15621562
#ifndef FAST_ZPP
1563-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ll", &regex,
1563+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|ii", &regex,
15641564
&subject, &subject_len, &limit_val, &flags) == FAILURE) {
15651565
RETURN_FALSE;
15661566
}
@@ -1862,12 +1862,12 @@ static PHP_FUNCTION(preg_grep)
18621862
{
18631863
zend_string *regex; /* Regular expression */
18641864
zval *input; /* Input array */
1865-
long flags = 0; /* Match control flags */
1865+
php_int_t flags = 0; /* Match control flags */
18661866
pcre_cache_entry *pce; /* Compiled regular expression */
18671867

18681868
/* Get arguments and do error checking */
18691869
#ifndef FAST_ZPP
1870-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|l", &regex,
1870+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sa|i", &regex,
18711871
&input, &flags) == FAILURE) {
18721872
return;
18731873
}

ext/reflection/php_reflection.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
444444
HashPosition pos;
445445
zval *value;
446446
zend_string *key;
447-
ulong num_index;
447+
php_uint_t num_index;
448448

449449
zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos);
450450

@@ -574,7 +574,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
574574

575575
while ((prop = zend_hash_get_current_data_ptr_ex(properties, &pos)) != NULL) {
576576
zend_string *prop_name;
577-
ulong index;
577+
php_uint_t index;
578578

579579
if (zend_hash_get_current_key_ex(properties, &prop_name, &index, 0, &pos) == HASH_KEY_IS_STRING) {
580580
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
611611
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
612612
{
613613
zend_string *key;
614-
ulong num_index;
614+
php_uint_t num_index;
615615
uint len = mptr->common.function_name->len;
616616

617617
/* Do not display old-style inherited constructors */
@@ -783,7 +783,7 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i
783783
static void _function_closure_string(string *str, zend_function *fptr, char* indent TSRMLS_DC)
784784
{
785785
zend_uint i, count;
786-
ulong num_index;
786+
php_uint_t num_index;
787787
zend_string *key;
788788
HashTable *static_variables;
789789
HashPosition pos;
@@ -3352,7 +3352,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
33523352
zend_property_info *prop_info;
33533353
zval *prop, prop_copy;
33543354
zend_string *key;
3355-
ulong num_index;
3355+
php_uint_t num_index;
33563356

33573357
ZEND_HASH_FOREACH_KEY_PTR(&ce->properties_info, num_index, key, prop_info) {
33583358
if (((prop_info->flags & ZEND_ACC_SHADOW) &&

ext/spl/spl_array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef struct _spl_array_object {
6666
zval array;
6767
zval retval;
6868
HashPosition pos;
69-
ulong pos_h;
69+
php_uint_t pos_h;
7070
int ar_flags;
7171
int is_self;
7272
zend_function *fptr_offset_get;
@@ -969,7 +969,7 @@ static int spl_array_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
969969
static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
970970
{
971971
zend_string *string_key;
972-
ulong num_key;
972+
php_uint_t num_key;
973973
zval *data;
974974

975975
if (Z_TYPE(intern->array) == IS_OBJECT) {

ext/spl/spl_engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
4242

4343
PHPAPI long spl_offset_convert_to_int(zval *offset TSRMLS_DC) /* {{{ */
4444
{
45-
ulong idx;
45+
php_uint_t idx;
4646

4747
switch (Z_TYPE_P(offset)) {
4848
case IS_STRING:

ext/standard/array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
288288
PHP_FUNCTION(count)
289289
{
290290
zval *array;
291-
long mode = COUNT_NORMAL;
291+
php_int_t mode = COUNT_NORMAL;
292292
php_int_t cnt;
293293
zval *element;
294294

295295
#ifndef FAST_ZPP
296-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) {
296+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &array, &mode) == FAILURE) {
297297
return;
298298
}
299299
#else

ext/standard/html.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,30 +1442,29 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
14421442
*/
14431443
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
14441444
{
1445-
char *str, *hint_charset = NULL;
1446-
int str_len, hint_charset_len = 0;
1447-
long flags = ENT_COMPAT;
1445+
zend_string *str, *hint_charset = NULL;
1446+
php_int_t flags = ENT_COMPAT;
14481447
zend_string *replaced;
14491448
zend_bool double_encode = 1;
14501449

14511450
#ifndef FAST_ZPP
1452-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!b", &str, &str_len, &flags, &hint_charset, &hint_charset_len, &double_encode) == FAILURE) {
1451+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS!b", &str, &flags, &hint_charset, &double_encode) == FAILURE) {
14531452
return;
14541453
}
14551454
#else
14561455
ZEND_PARSE_PARAMETERS_START(1, 4)
1457-
Z_PARAM_STRING(str, str_len)
1456+
Z_PARAM_STR(str)
14581457
Z_PARAM_OPTIONAL
14591458
Z_PARAM_LONG(flags)
1460-
Z_PARAM_STRING_EX(hint_charset, hint_charset_len, 1, 0)
1459+
Z_PARAM_STR_EX(hint_charset, 1, 0)
14611460
Z_PARAM_BOOL(double_encode);
14621461
ZEND_PARSE_PARAMETERS_END();
14631462
#endif
14641463

14651464
if (!hint_charset) {
14661465
hint_charset = get_default_charset(TSRMLS_C);
14671466
}
1468-
replaced = php_escape_html_entities_ex((unsigned char*)str, str_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC);
1467+
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);
14691468
RETVAL_STR(replaced);
14701469
}
14711470
/* }}} */
@@ -1525,30 +1524,29 @@ PHP_FUNCTION(htmlspecialchars_decode)
15251524
Convert all HTML entities to their applicable characters */
15261525
PHP_FUNCTION(html_entity_decode)
15271526
{
1528-
char *str, *hint_charset = NULL;
1529-
int str_len, hint_charset_len = 0;
1527+
zend_string *str, *hint_charset = NULL;
15301528
size_t new_len = 0;
1531-
long quote_style = ENT_COMPAT;
1529+
php_int_t quote_style = ENT_COMPAT;
15321530
zend_string *replaced;
15331531

15341532
#ifndef FAST_ZPP
1535-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
1536-
&quote_style, &hint_charset, &hint_charset_len) == FAILURE) {
1533+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|iS", &str,
1534+
&quote_style, &hint_charset) == FAILURE) {
15371535
return;
15381536
}
15391537
#else
15401538
ZEND_PARSE_PARAMETERS_START(1, 3)
1541-
Z_PARAM_STRING(str, str_len)
1539+
Z_PARAM_STR(str)
15421540
Z_PARAM_OPTIONAL
15431541
Z_PARAM_LONG(quote_style)
1544-
Z_PARAM_STRING(hint_charset, hint_charset_len)
1542+
Z_PARAM_STR(hint_charset)
15451543
ZEND_PARSE_PARAMETERS_END();
15461544
#endif
15471545

15481546
if (!hint_charset) {
15491547
hint_charset = get_default_charset(TSRMLS_C);
15501548
}
1551-
replaced = php_unescape_html_entities((unsigned char*)str, str_len, 1 /*all*/, quote_style, hint_charset TSRMLS_CC);
1549+
replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, hint_charset->val TSRMLS_CC);
15521550

15531551
if (replaced) {
15541552
RETURN_STR(replaced);

ext/standard/string.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,26 +1798,25 @@ PHP_FUNCTION(strstr)
17981798
PHP_FUNCTION(strpos)
17991799
{
18001800
zval *needle;
1801-
char *haystack;
1801+
zend_string *haystack;
18021802
char *found = NULL;
18031803
char needle_char[2];
1804-
long offset = 0;
1805-
int haystack_len;
1804+
php_int_t offset = 0;
18061805

18071806
#ifndef FAST_ZPP
1808-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) {
1807+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &needle, &offset) == FAILURE) {
18091808
return;
18101809
}
18111810
#else
18121811
ZEND_PARSE_PARAMETERS_START(2, 3)
1813-
Z_PARAM_STRING(haystack, haystack_len)
1812+
Z_PARAM_STR(haystack)
18141813
Z_PARAM_ZVAL(needle)
18151814
Z_PARAM_OPTIONAL
18161815
Z_PARAM_LONG(offset)
18171816
ZEND_PARSE_PARAMETERS_END();
18181817
#endif
18191818

1820-
if (offset < 0 || offset > haystack_len) {
1819+
if (offset < 0 || offset > haystack->len) {
18211820
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
18221821
RETURN_FALSE;
18231822
}
@@ -1828,24 +1827,24 @@ PHP_FUNCTION(strpos)
18281827
RETURN_FALSE;
18291828
}
18301829

1831-
found = (char*)php_memnstr(haystack + offset,
1830+
found = (char*)php_memnstr(haystack->val + offset,
18321831
Z_STRVAL_P(needle),
18331832
Z_STRSIZE_P(needle),
1834-
haystack + haystack_len);
1833+
haystack->val + haystack->len);
18351834
} else {
18361835
if (php_needle_char(needle, needle_char TSRMLS_CC) != SUCCESS) {
18371836
RETURN_FALSE;
18381837
}
18391838
needle_char[1] = 0;
18401839

1841-
found = (char*)php_memnstr(haystack + offset,
1840+
found = (char*)php_memnstr(haystack->val + offset,
18421841
needle_char,
18431842
1,
1844-
haystack + haystack_len);
1843+
haystack->val + haystack->len);
18451844
}
18461845

18471846
if (found) {
1848-
RETURN_INT(found - haystack);
1847+
RETURN_INT(found - haystack->val);
18491848
} else {
18501849
RETURN_FALSE;
18511850
}
@@ -1920,18 +1919,19 @@ PHP_FUNCTION(stripos)
19201919
PHP_FUNCTION(strrpos)
19211920
{
19221921
zval *zneedle;
1923-
char *needle, *haystack;
1924-
int needle_len, haystack_len;
1925-
long offset = 0;
1922+
char *needle;
1923+
zend_string *haystack;
1924+
php_size_t needle_len;
1925+
php_int_t offset = 0;
19261926
char *p, *e, ord_needle[2];
19271927

19281928
#ifndef FAST_ZPP
1929-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &haystack, &haystack_len, &zneedle, &offset) == FAILURE) {
1929+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &zneedle, &offset) == FAILURE) {
19301930
RETURN_FALSE;
19311931
}
19321932
#else
19331933
ZEND_PARSE_PARAMETERS_START(2, 3)
1934-
Z_PARAM_STRING(haystack, haystack_len)
1934+
Z_PARAM_STR(haystack)
19351935
Z_PARAM_ZVAL(zneedle)
19361936
Z_PARAM_OPTIONAL
19371937
Z_PARAM_LONG(offset)
@@ -1950,28 +1950,28 @@ PHP_FUNCTION(strrpos)
19501950
needle_len = 1;
19511951
}
19521952

1953-
if ((haystack_len == 0) || (needle_len == 0)) {
1953+
if ((haystack->len == 0) || (needle_len == 0)) {
19541954
RETURN_FALSE;
19551955
}
19561956

19571957
if (offset >= 0) {
1958-
if (offset > haystack_len) {
1958+
if (offset > haystack->len) {
19591959
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
19601960
RETURN_FALSE;
19611961
}
1962-
p = haystack + offset;
1963-
e = haystack + haystack_len - needle_len;
1962+
p = haystack->val + offset;
1963+
e = haystack->val + haystack->len - needle_len;
19641964
} else {
1965-
if (offset < -INT_MAX || -offset > haystack_len) {
1965+
if (offset < -INT_MAX || -offset > haystack->len) {
19661966
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
19671967
RETURN_FALSE;
19681968
}
19691969

1970-
p = haystack;
1970+
p = haystack->val;
19711971
if (needle_len > -offset) {
1972-
e = haystack + haystack_len - needle_len;
1972+
e = haystack->val + haystack->len - needle_len;
19731973
} else {
1974-
e = haystack + haystack_len + offset;
1974+
e = haystack->val + haystack->len + offset;
19751975
}
19761976
}
19771977

ext/standard/type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ PHP_FUNCTION(settype)
138138
PHP_FUNCTION(intval)
139139
{
140140
zval *num;
141-
long base = 10;
141+
php_int_t base = 10;
142142

143143
if (ZEND_NUM_ARGS() != 1 && ZEND_NUM_ARGS() != 2) {
144144
WRONG_PARAM_COUNT;
145145
}
146146
#ifndef FAST_ZPP
147-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &num, &base) == FAILURE) {
147+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &num, &base) == FAILURE) {
148148
return;
149149
}
150150
#else

main/rfc1867.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ static void *php_ap_memstr(char *haystack, int haystacklen, char *needle, int ne
611611
}
612612

613613
/* read until a boundary condition */
614-
static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, int *end TSRMLS_DC)
614+
static int multipart_buffer_read(multipart_buffer *self, char *buf, php_size_t bytes, int *end TSRMLS_DC)
615615
{
616-
int len, max;
616+
php_size_t len, max;
617617
char *bound;
618618

619619
/* fill buffer if needed */
@@ -657,7 +657,7 @@ static int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes, i
657657
XXX: this is horrible memory-usage-wise, but we only expect
658658
to do this on small pieces of form data.
659659
*/
660-
static char *multipart_buffer_read_body(multipart_buffer *self, unsigned int *len TSRMLS_DC)
660+
static char *multipart_buffer_read_body(multipart_buffer *self, php_size_t *len TSRMLS_DC)
661661
{
662662
char buf[FILLUNIT], *out=NULL;
663663
int total_bytes=0, read_bytes=0;

0 commit comments

Comments
 (0)