diff options
author | Anatol Belski <ab@php.net> | 2014-08-16 11:16:11 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-08-16 11:16:11 +0200 |
commit | 8ee2a4a9b5de682c0b37670e1f4f86242b1650ce (patch) | |
tree | 7768898294c125f79de082a986e962aa6cb23094 | |
parent | 735ec33b828bc4429c4ec8de7ba547925a4b44e3 (diff) | |
download | php-git-8ee2a4a9b5de682c0b37670e1f4f86242b1650ce.tar.gz |
first shot on merging the core fro the int64 branch
87 files changed, 2483 insertions, 2107 deletions
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index b232429d4d..82e272db5b 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -64,7 +64,7 @@ typedef int ts_rsrc_id; /* Define THREAD_T and MUTEX_T */ #ifdef TSRM_WIN32 -# define THREAD_T DWORD +# define THREAD_T UINT_PTR # define MUTEX_T CRITICAL_SECTION * #elif defined(GNUPTH) # define THREAD_T pth_t diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 945409eb1e..8a676cba15 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -130,7 +130,7 @@ int main() exit(1); } ], [ - AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits]) + AC_DEFINE([ZEND_DVAL_TO_IVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits]) AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) diff --git a/Zend/zend.c b/Zend/zend.c index 913462bec7..67ffea8b80 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -54,14 +54,14 @@ ZEND_API void (*zend_block_interruptions)(void); ZEND_API void (*zend_unblock_interruptions)(void); ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC); ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); -int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap); +int (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap); zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap); ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC); ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC); void (*zend_on_timeout)(int seconds TSRMLS_DC); -static void (*zend_message_dispatcher_p)(long message, const void *data TSRMLS_DC); +static void (*zend_message_dispatcher_p)(zend_int_t message, const void *data TSRMLS_DC); static int (*zend_get_configuration_directive_p)(const char *name, uint name_length, zval *contents); static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */ @@ -134,7 +134,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, { zval *tmp; zend_string *string_key; - ulong num_key; + zend_uint_t num_key; int i; for (i = 0; i < indent; i++) { @@ -193,7 +193,7 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */ { zval *tmp; zend_string *string_key; - ulong num_key; + zend_uint_t num_key; int i = 0; ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) { @@ -232,7 +232,7 @@ again: } break; case IS_RESOURCE: { - char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG]; + char buf[sizeof("Resource id #") + MAX_LENGTH_OF_ZEND_INT]; int len; len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(expr)); @@ -1158,7 +1158,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ va_end(usr_copy); #endif - ZVAL_LONG(¶ms[0], type); + ZVAL_INT(¶ms[0], type); if (error_filename) { ZVAL_STRING(¶ms[2], error_filename); @@ -1166,7 +1166,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */ ZVAL_NULL(¶ms[2]); } - ZVAL_LONG(¶ms[3], error_lineno); + ZVAL_INT(¶ms[3], error_lineno); symbol_table = zend_rebuild_symbol_table(TSRMLS_C); @@ -1293,7 +1293,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval *retval, int file_cou int i; zend_file_handle *file_handle; zend_op_array *op_array; - long orig_interactive = CG(interactive); + zend_int_t orig_interactive = CG(interactive); va_start(files, file_count); for (i = 0; i < file_count; i++) { diff --git a/Zend/zend.h b/Zend/zend.h index 0718edba12..3d539c33f9 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -273,14 +273,14 @@ char *alloca (); #define LONG_MIN (- LONG_MAX - 1) #endif -#if SIZEOF_LONG == 4 -#define MAX_LENGTH_OF_LONG 11 -static const char long_min_digits[] = "2147483648"; -#elif SIZEOF_LONG == 8 -#define MAX_LENGTH_OF_LONG 20 -static const char long_min_digits[] = "9223372036854775808"; +#if SIZEOF_ZEND_INT == 4 +#define MAX_LENGTH_OF_ZEND_INT 11 +static const char int_min_digits[] = "2147483648"; +#elif SIZEOF_ZEND_INT == 8 +#define MAX_LENGTH_OF_ZEND_INT 20 +static const char int_min_digits[] = "9223372036854775808"; #else -#error "Unknown SIZEOF_LONG" +#error "Unknown SIZEOF_ZEND_INT" #endif #define MAX_LENGTH_OF_DOUBLE 32 @@ -534,8 +534,8 @@ struct _zend_class_entry { #include "zend_stream.h" typedef struct _zend_utility_functions { void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0); - int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); - int (*write_function)(const char *str, uint str_length); + zend_size_t (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); + zend_size_t (*write_function)(const char *str, zend_size_t str_length); FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC); void (*message_handler)(long message, const void *data TSRMLS_DC); void (*block_interruptions)(void); @@ -544,7 +544,7 @@ typedef struct _zend_utility_functions { void (*ticks_function)(int ticks TSRMLS_DC); void (*on_timeout)(int seconds TSRMLS_DC); int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); - int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap); + zend_size_t (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap); zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap); char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC); char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC); @@ -655,8 +655,8 @@ extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC); extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0); extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC); extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); -extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap); -extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap); +extern int (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap); +extern zend_string *(*zend_vstrpprintf)(zend_size_t max_len, const char *format, va_list ap); extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC); extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC); @@ -685,7 +685,7 @@ END_EXTERN_C() #endif BEGIN_EXTERN_C() -ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC); +ZEND_API void zend_message_dispatcher(zend_int_t message, const void *data TSRMLS_DC); ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents); END_EXTERN_C() diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 9881740c06..91d2e40e7b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -166,7 +166,7 @@ ZEND_API char *zend_get_type_by_const(int type) /* {{{ */ case IS_FALSE: case IS_TRUE: return "boolean"; - case IS_LONG: + case IS_INT: return "integer"; case IS_DOUBLE: return "double"; @@ -228,7 +228,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (Z_OBJ_HANDLER_P(arg, cast_object)(arg, &obj, type TSRMLS_CC) == SUCCESS) { zval_ptr_dtor(arg); ZVAL_COPY_VALUE(arg, &obj); - *pl = Z_STRLEN_P(arg); + *pl = Z_STRSIZE_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -237,7 +237,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (Z_OBJ_HT_P(arg) == &std_object_handlers || !Z_OBJ_HANDLER_P(arg, cast_object)) { SEPARATE_ZVAL_NOREF(arg); if (zend_std_cast_object_tostring(arg, arg, type TSRMLS_CC) == SUCCESS) { - *pl = Z_STRLEN_P(arg); + *pl = Z_STRSIZE_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -252,7 +252,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (!zend_make_printable_zval(z, arg TSRMLS_CC)) { ZVAL_ZVAL(arg, z, 1, 1); } - *pl = Z_STRLEN_P(arg); + *pl = Z_STRSIZE_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -458,8 +458,69 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons case IS_FALSE: case IS_TRUE: case IS_LONG: - convert_to_long_ex(arg); - *p = Z_LVAL_P(arg); + convert_to_int_ex(arg); + *p = Z_IVAL_P(arg); + break; + + case IS_ARRAY: + case IS_OBJECT: + case IS_RESOURCE: + default: + return "long"; + } + } + break; + + case 'i': + case 'i': + { + zend_int_t *p = va_arg(*va, zend_int_t *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_P(arg) == IS_NULL); + } + + switch (Z_TYPE_P(arg)) { + case IS_STRING: + { + double d; + int type; + + if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), p, &d, -1)) == 0) { + return "long"; + } else if (type == IS_DOUBLE) { + if (c == 'L') { + if (d > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; + break; + } else if (d < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; + break; + } + } + + *p = zend_dval_to_ival(d); + } + } + break; + + case IS_DOUBLE: + if (c == 'L') { + if (Z_DVAL_P(arg) > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; + break; + } else if (Z_DVAL_P(arg) < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; + break; + } + } + case IS_NULL: + case IS_FALSE: + case IS_TRUE: + case IS_INT: + convert_to_int_ex(arg); + *p = Z_IVAL_P(arg); break; case IS_ARRAY: @@ -483,12 +544,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons switch (Z_TYPE_P(arg)) { case IS_STRING: { - long l; + zend_int_t l; int type; - if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &l, p, -1)) == 0) { + if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), &l, p, -1)) == 0) { return "double"; - } else if (type == IS_LONG) { + } else if (type == IS_INT) { *p = (double) l; } } @@ -497,7 +558,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons case IS_NULL: case IS_FALSE: case IS_TRUE: - case IS_LONG: + case IS_INT: case IS_DOUBLE: convert_to_double_ex(arg); *p = Z_DVAL_P(arg); @@ -526,14 +587,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: convert_to_string_ex(arg); case IS_STRING: *p = Z_STRVAL_P(arg); - *pl = Z_STRLEN_P(arg); + *pl = Z_STRSIZE_P(arg); if (c == 'p' && CHECK_ZVAL_NULL_PATH(arg)) { return "a valid path"; } @@ -567,7 +628,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: @@ -607,7 +668,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons switch (Z_TYPE_P(arg)) { case IS_NULL: case IS_STRING: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: @@ -1363,11 +1424,11 @@ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr) } /* }}} */ -ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, long n) /* {{{ */ +ZEND_API int add_assoc_int_ex(zval *arg, const char *key, uint key_len, zend_int_t n) /* {{{ */ { zval *ret, tmp; - ZVAL_LONG(&tmp, n); + ZVAL_INT(&tmp, n); ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); return ret ? SUCCESS : FAILURE; } @@ -1452,16 +1513,16 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *v } /* }}} */ -ZEND_API int add_index_long(zval *arg, ulong index, long n) /* {{{ */ +ZEND_API int add_index_int(zval *arg, zend_uint_t index, zend_int_t n) /* {{{ */ { zval tmp; - ZVAL_LONG(&tmp, n); + ZVAL_INT(&tmp, n); return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; } /* }}} */ -ZEND_API int add_index_null(zval *arg, ulong index) /* {{{ */ +ZEND_API int add_index_null(zval *arg, zend_uint_t index) /* {{{ */ { zval tmp; @@ -1470,7 +1531,7 @@ ZEND_API int add_index_null(zval *arg, ulong index) /* {{{ */ } /* }}} */ -ZEND_API int add_index_bool(zval *arg, ulong index, int b) /* {{{ */ +ZEND_API int add_index_bool(zval *arg, zend_uint_t index, int b) /* {{{ */ { zval tmp; @@ -1479,7 +1540,7 @@ ZEND_API int add_index_bool(zval *arg, ulong index, int b) /* {{{ */ } /* }}} */ -ZEND_API int add_index_resource(zval *arg, ulong index, zend_resource *r) /* {{{ */ +ZEND_API int add_index_resource(zval *arg, zend_uint_t index, zend_resource *r) /* {{{ */ { zval tmp; @@ -1488,7 +1549,7 @@ ZEND_API int add_index_resource(zval *arg, ulong index, zend_resource *r) /* {{{ } /* }}} */ -ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */ +ZEND_API int add_index_double(zval *arg, zend_uint_t index, double d) /* {{{ */ { zval tmp; @@ -1497,7 +1558,7 @@ ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */ } /* }}} */ -ZEND_API int add_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */ +ZEND_API int add_index_str(zval *arg, zend_uint_t index, zend_string *str) /* {{{ */ { zval tmp; @@ -1506,7 +1567,7 @@ ZEND_API int add_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */ } /* }}} */ -ZEND_API int add_index_string(zval *arg, ulong index, const char *str) /* {{{ */ +ZEND_API int add_index_string(zval *arg, zend_uint_t index, const char *str) /* {{{ */ { zval tmp; @@ -1515,7 +1576,7 @@ ZEND_API int add_index_string(zval *arg, ulong index, const char *str) /* {{{ */ } /* }}} */ -ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint length) /* {{{ */ +ZEND_API int add_index_stringl(zval *arg, zend_uint_t index, const char *str, uint length) /* {{{ */ { zval tmp; @@ -1524,17 +1585,17 @@ ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint len } /* }}} */ -ZEND_API int add_index_zval(zval *arg, ulong index, zval *value) /* {{{ */ +ZEND_API int add_index_zval(zval *arg, zend_uint_t index, zval *value) /* {{{ */ { return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; } /* }}} */ -ZEND_API int add_next_index_long(zval *arg, long n) /* {{{ */ +ZEND_API int add_next_index_int(zval *arg, zend_int_t n) /* {{{ */ { zval tmp; - ZVAL_LONG(&tmp, n); + ZVAL_INT(&tmp, n); return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE; } /* }}} */ @@ -1628,16 +1689,16 @@ ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len } /* }}} */ -ZEND_API zval *add_get_index_long(zval *arg, ulong index, long l) /* {{{ */ +ZEND_API zval *add_get_index_int(zval *arg, zend_uint_t index, zend_int_t l) /* {{{ */ { zval tmp; - ZVAL_LONG(&tmp, l); + ZVAL_INT(&tmp, l); return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); } /* }}} */ -ZEND_API zval *add_get_index_double(zval *arg, ulong index, double d) /* {{{ */ +ZEND_API zval *add_get_index_double(zval *arg, zend_uint_t index, double d) /* {{{ */ { zval tmp; @@ -1646,7 +1707,7 @@ ZEND_API zval *add_get_index_double(zval *arg, ulong index, double d) /* {{{ */ } /* }}} */ -ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str) /* {{{ */ +ZEND_API zval *add_get_index_str(zval *arg, zend_uint_t index, zend_string *str) /* {{{ */ { zval tmp; @@ -1655,7 +1716,7 @@ ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str) /* {{ } /* }}} */ -ZEND_API zval *add_get_index_string(zval *arg, ulong index, const char *str) /* {{{ */ +ZEND_API zval *add_get_index_string(zval *arg, zend_uint_t index, const char *str) /* {{{ */ { zval tmp; @@ -1664,7 +1725,7 @@ ZEND_API zval *add_get_index_string(zval *arg, ulong index, const char *str) /* } /* }}} */ -ZEND_API zval *add_get_index_stringl(zval *arg, ulong index, const char *str, uint length) /* {{{ */ +ZEND_API zval *add_get_index_stringl(zval *arg, zend_uint_t index, const char *str, uint length) /* {{{ */ { zval tmp; @@ -1694,11 +1755,11 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC) case IS_TRUE: result = zend_hash_index_update(ht, 1, value); break; - case IS_LONG: - result = zend_hash_index_update(ht, Z_LVAL_P(key), value); + case IS_INT: + result = zend_hash_index_update(ht, Z_IVAL_P(key), value); break; case IS_DOUBLE: - result = zend_hash_index_update(ht, zend_dval_to_lval(Z_DVAL_P(key)), value); + result = zend_hash_index_update(ht, zend_dval_to_ival(Z_DVAL_P(key)), value); break; default: zend_error(E_WARNING, "Illegal offset type"); @@ -1716,12 +1777,12 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC) } /* }}} */ -ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long n TSRMLS_DC) /* {{{ */ +ZEND_API int add_property_int_ex(zval *arg, const char *key, uint key_len, zend_int_t n TSRMLS_DC) /* {{{ */ { zval tmp; zval z_key; - ZVAL_LONG(&tmp, n); + ZVAL_INT(&tmp, n); ZVAL_STRINGL(&z_key, key, key_len); Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL TSRMLS_CC); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ @@ -1730,7 +1791,7 @@ ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long } /* }}} */ -ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC) /* {{{ */ +ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_int_t b TSRMLS_DC) /* {{{ */ { zval tmp; zval z_key; @@ -2941,7 +3002,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca /* Skip leading \ */ if (UNEXPECTED(Z_STRVAL_P(callable)[0] == '\\')) { - STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable) + 1, Z_STRLEN_P(callable) - 1, use_heap); + STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable) + 1, Z_STRSIZE_P(callable) - 1, use_heap); } else { lmname = Z_STR_P(callable); } @@ -2954,7 +3015,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca return 1; } else { if (lmname == Z_STR_P(callable)) { - STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable), Z_STRLEN_P(callable), use_heap); + STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable), Z_STRSIZE_P(callable), use_heap); } else { STR_FORGET_HASH_VAL(lmname); } @@ -2970,13 +3031,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } /* Split name into class/namespace and method/function names */ - if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL && + if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRSIZE_P(callable))) != NULL && colon > Z_STRVAL_P(callable) && *(colon-1) == ':' ) { colon--; clen = colon - Z_STRVAL_P(callable); - mlen = Z_STRLEN_P(callable) - clen - 2; + mlen = Z_STRSIZE_P(callable) - clen - 2; if (colon == Z_STRVAL_P(callable)) { if (error) zend_spprintf(error, 0, "invalid function name"); @@ -3007,7 +3068,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca mname = STR_INIT(Z_STRVAL_P(callable) + clen + 2, mlen, 0); } else if (ce_org) { /* Try to fetch find static method of given class. */ - mlen = Z_STRLEN_P(callable); + mlen = Z_STRSIZE_P(callable); mname = Z_STR_P(callable); STR_ADDREF(mname); ftable = &ce_org->function_table; @@ -3237,13 +3298,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (callable_name) { char *ptr; - *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0); + *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRSIZE_P(callable) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); ptr += fcc->calling_scope->name->len; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); + memcpy(ptr, Z_STRVAL_P(callable), Z_STRSIZE_P(callable) + 1); } } else if (callable_name) { *callable_name = STR_COPY(Z_STR_P(callable)); @@ -3294,13 +3355,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint char *ptr; - *callable_name = STR_ALLOC(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); + *callable_name = STR_ALLOC(Z_STRSIZE_P(obj) + Z_STRSIZE_P(method) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; - memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj)); - ptr += Z_STRLEN_P(obj); + memcpy(ptr, Z_STRVAL_P(obj), Z_STRSIZE_P(obj)); + ptr += Z_STRSIZE_P(obj); memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); + memcpy(ptr, Z_STRVAL_P(method), Z_STRSIZE_P(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { @@ -3324,13 +3385,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (callable_name) { char *ptr; - *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0); + *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRSIZE_P(method) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); ptr += fcc->calling_scope->name->len; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); + memcpy(ptr, Z_STRVAL_P(method), Z_STRSIZE_P(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { @@ -3702,7 +3763,7 @@ ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC) /* {{{ */ { zval property; @@ -3711,11 +3772,11 @@ ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_property_int(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC) /* {{{ */ { zval property; - ZVAL_LONG(&property, value); + ZVAL_INT(&property, value); return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC); } /* }}} */ @@ -3766,11 +3827,11 @@ ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char * } /* }}} */ -ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, long value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_class_constant_int(zend_class_entry *ce, const char *name, size_t name_length, zend_int_t value TSRMLS_DC) /* {{{ */ { zval constant; - ZVAL_LONG(&constant, value); + ZVAL_INT(&constant, value); return zend_declare_class_constant(ce, name, name_length, &constant TSRMLS_CC); } /* }}} */ @@ -3836,7 +3897,7 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c } /* }}} */ -ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */ +ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ { zval tmp; @@ -3845,11 +3906,11 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c } /* }}} */ -ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */ +ZEND_API void zend_update_property_int(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ { zval tmp; - ZVAL_LONG(&tmp, value); + ZVAL_INT(&tmp, value); zend_update_property(scope, object, name, name_length, &tmp TSRMLS_CC); } /* }}} */ @@ -3938,7 +3999,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ { zval tmp; @@ -3947,11 +4008,11 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_update_static_property_int(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ { zval tmp; - ZVAL_LONG(&tmp, value); + ZVAL_INT(&tmp, value); return zend_update_static_property(scope, name, name_length, &tmp TSRMLS_CC); } /* }}} */ @@ -4055,10 +4116,10 @@ static int same_zval(zval *zv1, zval *zv2) /* {{{ */ case IS_FALSE: case IS_TRUE: return 1; - case IS_LONG: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); + case IS_INT: + return Z_IVAL_P(zv1) == Z_IVAL_P(zv2); case IS_DOUBLE: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); + return Z_IVAL_P(zv1) == Z_IVAL_P(zv2); case IS_STRING: case IS_ARRAY: case IS_OBJECT: diff --git a/Zend/zend_API.h b/Zend/zend_API.h index b40afc162f..4478e60562 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -303,15 +303,15 @@ ZEND_API int zend_get_module_started(const char *module_name); ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC); ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC); -ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC); -ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC); +ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC); +ZEND_API int zend_declare_property_int(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC); ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, int value_len, int access_type TSRMLS_DC); ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC); ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC); -ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, long value TSRMLS_DC); +ZEND_API int zend_declare_class_constant_int(zend_class_entry *ce, const char *name, size_t name_length, zend_int_t value TSRMLS_DC); ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value TSRMLS_DC); ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value TSRMLS_DC); ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC); @@ -320,8 +320,8 @@ ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC); ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC); ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC); -ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC); -ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC); +ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC); +ZEND_API void zend_update_property_int(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC); ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC); ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC); ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC); @@ -329,8 +329,8 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC); ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC); -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC); -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC); +ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC); +ZEND_API int zend_update_static_property_int(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC); ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC); ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC); ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, int value_length TSRMLS_DC); @@ -374,7 +374,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC); /* no longer supported */ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS)); -ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, long n); +ZEND_API int add_assoc_int_ex(zval *arg, const char *key, uint key_len, zend_int_t n); ZEND_API int add_assoc_null_ex(zval *arg, const char *key, uint key_len); ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, uint key_len, int b); ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r); @@ -384,7 +384,7 @@ ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char *str, uint length); ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *value); -#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n) +#define add_assoc_int(__arg, __key, __n) add_assoc_int_ex(__arg, __key, strlen(__key), __n) #define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key)) #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b) #define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r) @@ -400,17 +400,17 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *v #define add_next_index_unset(__arg) add_next_index_null(__arg) #define add_property_unset(__arg, __key) add_property_null(__arg, __key) -ZEND_API int add_index_long(zval *arg, ulong idx, long n); -ZEND_API int add_index_null(zval *arg, ulong idx); -ZEND_API int add_index_bool(zval *arg, ulong idx, int b); -ZEND_API int add_index_resource(zval *arg, ulong idx, zend_resource *r); -ZEND_API int add_index_double(zval *arg, ulong idx, double d); -ZEND_API int add_index_str(zval *arg, ulong idx, zend_string *str); -ZEND_API int add_index_string(zval *arg, ulong idx, const char *str); -ZEND_API int add_index_stringl(zval *arg, ulong idx, const char *str, uint length); -ZEND_API int add_index_zval(zval *arg, ulong index, zval *value); - -ZEND_API int add_next_index_long(zval *arg, long n); +ZEND_API int add_index_int(zval *arg, zend_uint_t idx, zend_int_t n); +ZEND_API int add_index_null(zval *arg, zend_uint_t idx); +ZEND_API int add_index_bool(zval *arg, zend_uint_t idx, int b); +ZEND_API int add_index_resource(zval *arg, zend_uint_t idx, zend_resource *r); +ZEND_API int add_index_double(zval *arg, zend_uint_t idx, double d); +ZEND_API int add_index_str(zval *arg, zend_uint_t idx, zend_string *str); +ZEND_API int add_index_string(zval *arg, zend_uint_t idx, const char *str); +ZEND_API int add_index_stringl(zval *arg, zend_uint_t idx, const char *str, uint length); +ZEND_API int add_index_zval(zval *arg, zend_uint_t index, zval *value); + +ZEND_API int add_next_index_int(zval *arg, zend_int_t n); ZEND_API int add_next_index_null(zval *arg); ZEND_API int add_next_index_bool(zval *arg, int b); ZEND_API int add_next_index_resource(zval *arg, zend_resource *r); @@ -426,17 +426,17 @@ ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len #define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str) #define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length) -ZEND_API zval *add_get_index_long(zval *arg, ulong idx, long l); -ZEND_API zval *add_get_index_double(zval *arg, ulong idx, double d); -ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str); -ZEND_API zval *add_get_index_string(zval *arg, ulong idx, const char *str); -ZEND_API zval *add_get_index_stringl(zval *arg, ulong idx, const char *str, uint length); +ZEND_API zval *add_get_index_int(zval *arg, zend_uint_t idx, zend_int_t l); +ZEND_API zval *add_get_index_double(zval *arg, zend_uint_t idx, double d); +ZEND_API zval *add_get_index_str(zval *arg, zend_uint_t index, zend_string *str); +ZEND_API zval *add_get_index_string(zval *arg, zend_uint_t idx, const char *str); +ZEND_API zval *add_get_index_stringl(zval *arg, zend_uint_t idx, const char *str, uint length); ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC); -ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long l TSRMLS_DC); +ZEND_API int add_property_int_ex(zval *arg, const char *key, uint key_len, zend_int_t l TSRMLS_DC); ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRMLS_DC); -ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC); +ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_int_t b TSRMLS_DC); ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, zend_resource *r TSRMLS_DC); ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC); ZEND_API int add_property_str_ex(zval *arg, const char *key, uint key_len, zend_string *str TSRMLS_DC); @@ -444,7 +444,7 @@ ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, co ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, uint length TSRMLS_DC); ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval *value TSRMLS_DC); -#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n TSRMLS_CC) +#define add_property_int(__arg, __key, __n) add_property_int_ex(__arg, __key, strlen(__key), __n TSRMLS_CC) #define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) TSRMLS_CC) #define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b TSRMLS_CC) #define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r TSRMLS_CC) @@ -546,7 +546,7 @@ END_EXTERN_C() #define CHECK_ZVAL_STRING_REL(z) #endif -#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p))) +#define CHECK_ZVAL_NULL_PATH(p) (Z_STRSIZE_P(p) != strlen(Z_STRVAL_P(p))) #define CHECK_NULL_PATH(p, l) (strlen(p) != l) #define ZVAL_STRINGL(z, s, l) do { \ @@ -597,7 +597,7 @@ END_EXTERN_C() #define RETVAL_BOOL(b) ZVAL_BOOL(return_value, b) #define RETVAL_NULL() ZVAL_NULL(return_value) -#define RETVAL_LONG(l) ZVAL_LONG(return_value, l) +#define RETVAL_INT(l) ZVAL_INT(return_value, l) #define RETVAL_DOUBLE(d) ZVAL_DOUBLE(return_value, d) #define RETVAL_STR(s) ZVAL_STR(return_value, s) #define RETVAL_INT_STR(s) ZVAL_INT_STR(return_value, s) @@ -613,7 +613,7 @@ END_EXTERN_C() #define RETURN_BOOL(b) { RETVAL_BOOL(b); return; } #define RETURN_NULL() { RETVAL_NULL(); return;} -#define RETURN_LONG(l) { RETVAL_LONG(l); return; } +#define RETURN_INT(l) { RETVAL_INT(l); return; } #define RETURN_DOUBLE(d) { RETVAL_DOUBLE(d); return; } #define RETURN_STR(s) { RETVAL_STR(s); return; } #define RETURN_INT_STR(s) { RETVAL_INT_STR(s); return; } @@ -1072,33 +1072,33 @@ static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_boo return 1; } -static zend_always_inline int _z_param_long(zval *arg, long *dest, zend_bool *is_null, int check_null, int strict) +static zend_always_inline int _z_param_long(zval *arg, zend_int_t *dest, zend_bool *is_null, int check_null, int strict) { if (check_null) { *is_null = 0; } - if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { - if (strict && UNEXPECTED(Z_DVAL_P(arg) > LONG_MAX)) { - *dest = LONG_MAX; - } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < LONG_MIN)) { - *dest = LONG_MIN; + if (EXPECTED(Z_TYPE_P(arg) == IS_INT)) { + if (strict && UNEXPECTED(Z_DVAL_P(arg) > ZEND_INT_MAX)) { + *dest = ZEND_INT_MAX; + } else if (strict && UNEXPECTED(Z_DVAL_P(arg) < ZEND_INT_MIN)) { + *dest = ZEND_INT_MIN; } else { - *dest = Z_LVAL_P(arg); + *dest = Z_IVAL_P(arg); } } else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) { - *dest = zend_dval_to_lval(Z_DVAL_P(arg)); + *dest = zend_dval_to_ival(Z_DVAL_P(arg)); } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { double d; int type; - if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) { + if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_INT)) { if (EXPECTED(type != 0)) { - if (strict && UNEXPECTED(d > LONG_MAX)) { - *dest = LONG_MAX; - } else if (strict && UNEXPECTED(d < LONG_MIN)) { - *dest = LONG_MIN; + if (strict && UNEXPECTED(d > ZEND_INT_MAX)) { + *dest = ZEND_INT_MAX; + } else if (strict && UNEXPECTED(d < ZEND_INT_MIN)) { + *dest = ZEND_INT_MIN; } else { - *dest = zend_dval_to_lval(d); + *dest = zend_dval_to_ival(d); } } else { return 0; @@ -1124,10 +1124,10 @@ static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool } if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) { *dest = Z_DVAL_P(arg); - } else if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { - *dest = (double)Z_LVAL_P(arg); + } else if (EXPECTED(Z_TYPE_P(arg) == IS_INT)) { + *dest = (double)Z_IVAL_P(arg); } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { - long l; + zend_int_t l; int type; if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) { @@ -1172,7 +1172,7 @@ static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int ch return 1; } -static zend_always_inline int _z_param_string(zval *arg, char **dest, int *dest_len, int check_null TSRMLS_DC) +static zend_always_inline int _z_param_string(zval *arg, char **dest, zend_size_t *dest_len, int check_null TSRMLS_DC) { zend_string *str; diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index bb3e66c989..2bdf3dacfd 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -488,16 +488,16 @@ static unsigned int _zend_mm_cookie = 0; #define ZEND_MM_RESERVE_SIZE (8*1024) #ifdef _WIN64 -# define ZEND_MM_LONG_CONST(x) (x##i64) +# define ZEND_MM_INT_CONST(x) (x##i64) #else -# define ZEND_MM_LONG_CONST(x) (x##L) +# define ZEND_MM_INT_CONST(x) (x##L) #endif -#define ZEND_MM_TYPE_MASK ZEND_MM_LONG_CONST(0x3) +#define ZEND_MM_TYPE_MASK ZEND_MM_INT_CONST(0x3) -#define ZEND_MM_FREE_BLOCK ZEND_MM_LONG_CONST(0x0) -#define ZEND_MM_USED_BLOCK ZEND_MM_LONG_CONST(0x1) -#define ZEND_MM_GUARD_BLOCK ZEND_MM_LONG_CONST(0x3) +#define ZEND_MM_FREE_BLOCK ZEND_MM_INT_CONST(0x0) +#define ZEND_MM_USED_BLOCK ZEND_MM_INT_CONST(0x1) +#define ZEND_MM_GUARD_BLOCK ZEND_MM_INT_CONST(0x3) #define ZEND_MM_BLOCK(b, type, size) do { \ size_t _size = (size); \ @@ -742,7 +742,7 @@ static inline void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_blo *p = mm_block; mm_block->parent = p; mm_block->prev_free_block = mm_block->next_free_block = mm_block; - heap->large_free_bitmap |= (ZEND_MM_LONG_CONST(1) << index); + heap->large_free_bitmap |= (ZEND_MM_INT_CONST(1) << index); } else { size_t m; @@ -775,7 +775,7 @@ static inline void zend_mm_add_to_free_list(zend_mm_heap *heap, zend_mm_free_blo prev = ZEND_MM_SMALL_FREE_BUCKET(heap, index); if (prev->prev_free_block == prev) { - heap->free_bitmap |= (ZEND_MM_LONG_CONST(1) << index); + heap->free_bitmap |= (ZEND_MM_INT_CONST(1) << index); } next = prev->next_free_block; @@ -809,7 +809,7 @@ static inline void zend_mm_remove_from_free_list(zend_mm_heap *heap, zend_mm_fre ZEND_MM_CHECK_TREE(mm_block); *mm_block->parent = NULL; if (mm_block->parent == &heap->large_free_buckets[index]) { - heap->large_free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index); + heap->large_free_bitmap &= ~(ZEND_MM_INT_CONST(1) << index); } } else { while (*(cp = &(prev->child[prev->child[1] != NULL])) != NULL) { @@ -847,7 +847,7 @@ subst_block: size_t index = ZEND_MM_BUCKET_INDEX(ZEND_MM_FREE_BLOCK_SIZE(mm_block)); if (EXPECTED(heap->free_buckets[index*2] == heap->free_buckets[index*2+1])) { - heap->free_bitmap &= ~(ZEND_MM_LONG_CONST(1) << index); + heap->free_bitmap &= ~(ZEND_MM_INT_CONST(1) << index); } } } else if (UNEXPECTED(mm_block->parent == ZEND_MM_REST_BLOCK)) { @@ -1116,7 +1116,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, heap->real_size = 0; heap->overflow = 0; heap->real_peak = 0; - heap->limit = ZEND_MM_LONG_CONST(1)<<(ZEND_MM_NUM_BUCKETS-2); + heap->limit = ZEND_MM_INT_CONST(1)<<(ZEND_MM_NUM_BUCKETS-2); heap->size = 0; heap->peak = 0; heap->internal = internal; @@ -1231,9 +1231,9 @@ ZEND_API zend_mm_heap *zend_mm_startup(void) } #if ZEND_DEBUG -static long zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block *b) +static zend_int_t zend_mm_find_leaks(zend_mm_segment *segment, zend_mm_block *b) { - long leaks = 0; + zend_int_t leaks = 0; zend_mm_block *p, *q; p = ZEND_MM_NEXT_BLOCK(b); @@ -1291,7 +1291,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap TSRMLS_DC) } if (!ZEND_MM_IS_FREE_BLOCK(p)) { if (p->magic == MEM_BLOCK_VALID) { - long repeated; + zend_int_t repeated; zend_leak_info leak; ZEND_MM_SET_MAGIC(p, MEM_BLOCK_LEAK); @@ -1842,7 +1842,7 @@ static zend_mm_free_block *zend_mm_search_large_block(zend_mm_heap *heap, size_t best_size = ZEND_MM_FREE_BLOCK_SIZE(p); best_fit = p; } - if ((m & (ZEND_MM_LONG_CONST(1) << (ZEND_MM_NUM_BUCKETS-1))) == 0) { + if ((m & (ZEND_MM_INT_CONST(1) << (ZEND_MM_NUM_BUCKETS-1))) == 0) { if (p->child[1]) { rst = p->child[1]; } @@ -1984,9 +1984,9 @@ static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D #endif HANDLE_UNBLOCK_INTERRUPTIONS(); #if ZEND_DEBUG - zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %lu bytes)", heap->limit, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Allowed memory size of " ZEND_UINT_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_UINT_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %lu bytes)", heap->limit, size); + zend_mm_safe_error(heap, "Allowed memory size of " ZEND_UINT_FMT " bytes exhausted (tried to allocate " ZEND_UINT_FMT " bytes)", heap->limit, size); #endif } @@ -2297,9 +2297,9 @@ realloc_segment: #endif HANDLE_UNBLOCK_INTERRUPTIONS(); #if ZEND_DEBUG - zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %ld bytes)", heap->limit, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, "Allowed memory size of " ZEND_UINT_FMT " bytes exhausted at %s:%d (tried to allocate " ZEND_UINT_FMT " bytes)", heap->limit, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %ld bytes)", heap->limit, size); + zend_mm_safe_error(heap, "Allowed memory size of " ZEND_UINT_FMT " bytes exhausted (tried to allocate " ZEND_UINT_FMT " bytes)", heap->limit, size); #endif return NULL; } @@ -2630,7 +2630,7 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { - int length; + zend_size_t length; char *p; #ifdef ZEND_SIGNALS TSRMLS_FETCH(); @@ -2649,7 +2649,7 @@ ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) return p; } -ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +ZEND_API char *_estrndup(const char *s, zend_size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { char *p; #ifdef ZEND_SIGNALS @@ -2670,7 +2670,7 @@ ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_ } -ZEND_API char *zend_strndup(const char *s, uint length) +ZEND_API char *zend_strndup(const char *s, zend_size_t length) { char *p; #ifdef ZEND_SIGNALS diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 609db22dac..3c143419ae 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -26,20 +26,21 @@ #include "../TSRM/TSRM.h" #include "zend.h" +#include "zend_types.h" #ifndef ZEND_MM_ALIGNMENT -# define ZEND_MM_ALIGNMENT 8 -# define ZEND_MM_ALIGNMENT_LOG2 3 -#elif ZEND_MM_ALIGNMENT < 4 +# define ZEND_MM_ALIGNMENT Z_I(8) +# define ZEND_MM_ALIGNMENT_LOG2 Z_I(3) +#elif ZEND_MM_ALIGNMENT < Z_I(4) # undef ZEND_MM_ALIGNMENT # undef ZEND_MM_ALIGNMENT_LOG2 -# define ZEND_MM_ALIGNMENT 4 -# define ZEND_MM_ALIGNMENT_LOG2 2 +# define ZEND_MM_ALIGNMENT Z_I(4) +# define ZEND_MM_ALIGNMENT_LOG2 Z_I(2) #endif -#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1) +#define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-Z_I(1)) -#define ZEND_MM_ALIGNED_SIZE(size) (((size) + ZEND_MM_ALIGNMENT - 1) & ZEND_MM_ALIGNMENT_MASK) +#define ZEND_MM_ALIGNED_SIZE(size) (((size) + ZEND_MM_ALIGNMENT - Z_I(1)) & ZEND_MM_ALIGNMENT_MASK) typedef struct _zend_leak_info { void *addr; @@ -52,7 +53,7 @@ typedef struct _zend_leak_info { BEGIN_EXTERN_C() -ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_MALLOC; +ZEND_API char *zend_strndup(const char *s, zend_size_t length) ZEND_ATTRIBUTE_MALLOC; ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1); ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; @@ -63,7 +64,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN ZEND_API void *_safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void *_safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset); ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; -ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; +ZEND_API char *_estrndup(const char *s, zend_size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); /* Standard wrapper macros */ diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 810b9b1fe8..dd7574ba3c 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -114,8 +114,8 @@ static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr TS case IS_NULL: zend_symtable_update(Z_ARRVAL_P(result), STR_EMPTY_ALLOC(), expr); break; - case IS_LONG: - zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(offset), expr); + case IS_INT: + zend_hash_index_update(Z_ARRVAL_P(result), Z_IVAL_P(offset), expr); break; case IS_FALSE: zend_hash_index_update(Z_ARRVAL_P(result), 0, expr); @@ -124,7 +124,7 @@ static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr TS zend_hash_index_update(Z_ARRVAL_P(result), 1, expr); break; case IS_DOUBLE: - zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), expr); + zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_ival(Z_DVAL_P(offset)), expr); break; default: zend_error(E_ERROR, "Illegal offset type"); @@ -331,13 +331,13 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s } break; case ZEND_UNARY_PLUS: - ZVAL_LONG(&op1, 0); + ZVAL_INT(&op1, 0); zend_ast_evaluate(&op2, (&ast->u.child)[0], scope TSRMLS_CC); add_function(result, &op1, &op2 TSRMLS_CC); zval_dtor(&op2); break; case ZEND_UNARY_MINUS: - ZVAL_LONG(&op1, 0); + ZVAL_INT(&op1, 0); zend_ast_evaluate(&op2, (&ast->u.child)[0], scope TSRMLS_CC); sub_function(result, &op1, &op2 TSRMLS_CC); zval_dtor(&op2); diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 1e29ea4db1..519ff5b8d8 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -358,7 +358,7 @@ ZEND_FUNCTION(zend_version) Returns number of freed zvals */ ZEND_FUNCTION(gc_collect_cycles) { - RETURN_LONG(gc_collect_cycles(TSRMLS_C)); + RETURN_INT(gc_collect_cycles(TSRMLS_C)); } /* }}} */ @@ -397,10 +397,10 @@ ZEND_FUNCTION(func_num_args) zend_execute_data *ex = EG(current_execute_data)->prev_execute_data; if (ex->frame_kind == VM_FRAME_NESTED_FUNCTION || ex->frame_kind == VM_FRAME_TOP_FUNCTION) { - RETURN_LONG(ex->num_args); + RETURN_INT(ex->num_args); } else { zend_error(E_WARNING, "func_num_args(): Called from the global scope - no function context"); - RETURN_LONG(-1); + RETURN_INT(-1); } } /* }}} */ @@ -528,7 +528,7 @@ ZEND_FUNCTION(strlen) ZEND_PARSE_PARAMETERS_END(); #endif - RETVAL_LONG(s->len); + RETVAL_INT(s->len); } /* }}} */ @@ -537,14 +537,13 @@ ZEND_FUNCTION(strlen) Binary safe string comparison */ ZEND_FUNCTION(strcmp) { - char *s1, *s2; - int s1_len, s2_len; + zend_string *s1, *s2; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) { return; } - RETURN_LONG(zend_binary_strcmp(s1, s1_len, s2, s2_len)); + RETURN_INT(zend_binary_strcmp(s1->val, s1->len, s2->val, s2->len)); } /* }}} */ @@ -553,11 +552,10 @@ ZEND_FUNCTION(strcmp) Binary safe string comparison */ ZEND_FUNCTION(strncmp) { - char *s1, *s2; - int s1_len, s2_len; - long len; + zend_string *s1, *s2; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s2, &len) == FAILURE) { return; } @@ -566,7 +564,7 @@ ZEND_FUNCTION(strncmp) RETURN_FALSE; } - RETURN_LONG(zend_binary_strncmp(s1, s1_len, s2, s2_len, len)); + RETURN_INT(zend_binary_strncmp(s1->val, s1->len, s2->val, s2->len, len)); } /* }}} */ @@ -575,14 +573,13 @@ ZEND_FUNCTION(strncmp) Binary safe case-insensitive string comparison */ ZEND_FUNCTION(strcasecmp) { - char *s1, *s2; - int s1_len, s2_len; + zend_string *s1, *s2; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &s1, &s2) == FAILURE) { return; } - RETURN_LONG(zend_binary_strcasecmp(s1, s1_len, s2, s2_len)); + RETURN_INT(zend_binary_strcasecmp(s1->val, s1->len, s2->val, s2->len)); } /* }}} */ @@ -591,11 +588,10 @@ ZEND_FUNCTION(strcasecmp) Binary safe string comparison */ ZEND_FUNCTION(strncasecmp) { - char *s1, *s2; - int s1_len, s2_len; - long len; + zend_string *s1, *s2; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s2, &len) == FAILURE) { return; } @@ -604,7 +600,7 @@ ZEND_FUNCTION(strncasecmp) RETURN_FALSE; } - RETURN_LONG(zend_binary_strncasecmp(s1, s1_len, s2, s2_len, len)); + RETURN_INT(zend_binary_strncasecmp(s1->val, s1->len, s2->val, s2->len, len)); } /* }}} */ @@ -614,7 +610,7 @@ ZEND_FUNCTION(strncasecmp) ZEND_FUNCTION(each) { zval *array, *entry, tmp; - ulong num_key; + zend_uint_t num_key; HashTable *target_hash; zend_string *key; @@ -660,7 +656,7 @@ ZEND_FUNCTION(each) ZVAL_STR(&tmp, STR_COPY(key)); if (Z_REFCOUNTED(tmp)) Z_ADDREF(tmp); } else { - ZVAL_LONG(&tmp, num_key); + ZVAL_INT(&tmp, num_key); } zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp); zend_hash_str_add_new(Z_ARRVAL_P(return_value), "key", sizeof("key")-1, &tmp); @@ -688,7 +684,7 @@ ZEND_FUNCTION(error_reporting) STR_RELEASE(key); } - RETVAL_LONG(old_error_reporting); + RETVAL_INT(old_error_reporting); } /* }}} */ @@ -730,7 +726,7 @@ ZEND_FUNCTION(define) repeat: switch (Z_TYPE_P(val)) { - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_FALSE: @@ -1472,7 +1468,7 @@ ZEND_FUNCTION(class_alias) Cause an intentional memory leak, for testing/debugging purposes */ ZEND_FUNCTION(leak) { - long leakbytes=3; + zend_int_t leakbytes=3; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &leakbytes) == FAILURE) { return; @@ -1540,7 +1536,7 @@ ZEND_FUNCTION(get_included_files) Generates a user-level error/warning/notice message */ ZEND_FUNCTION(trigger_error) { - long error_type = E_USER_NOTICE; + zend_int_t error_type = E_USER_NOTICE; char *message; int message_len; @@ -1572,7 +1568,7 @@ ZEND_FUNCTION(set_error_handler) { zval *error_handler; zend_string *error_handler_name = NULL; - long error_type = E_ALL; + zend_int_t error_type = E_ALL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { return; @@ -1880,11 +1876,11 @@ ZEND_FUNCTION(create_function) } (*func->refcount)++; - function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0); + function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_ZEND_INT, 0); function_name->val[0] = '\0'; do { - function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1; + function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_ZEND_INT, "lambda_%d", ++EG(lambda_count)) + 1; } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL); static_variables = func->static_variables; func->static_variables = NULL; @@ -1911,7 +1907,7 @@ ZEND_FUNCTION(zend_test_func) #ifdef ZTS ZEND_FUNCTION(zend_thread_id) { - RETURN_LONG((long)tsrm_thread_id()); + RETURN_INT((long)tsrm_thread_id()); } #endif #endif @@ -2356,7 +2352,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int lineno = skip->opline->lineno; } add_assoc_string_ex(&stack_frame, "file", sizeof("file")-1, (char*)filename); - add_assoc_long_ex(&stack_frame, "line", sizeof("line")-1, lineno); + add_assoc_int_ex(&stack_frame, "line", sizeof("line")-1, lineno); /* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function * and debug_baktrace() might have been called by the error_handler. in this case we don't @@ -2375,7 +2371,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int } if (prev->func && ZEND_USER_CODE(prev->func->common.type)) { add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, STR_COPY(prev->func->op_array.filename)); - add_assoc_long_ex(&stack_frame, "line", sizeof("line")-1, prev->opline->lineno); + add_assoc_int_ex(&stack_frame, "line", sizeof("line")-1, prev->opline->lineno); break; } prev_call = prev; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ae26733a7b..5d14d4a1b6 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -171,7 +171,7 @@ static void build_runtime_defined_function_key(zval *result, const char *name, i static void init_compiler_declarables(TSRMLS_D) /* {{{ */ { - ZVAL_LONG(&CG(declarables).ticks, 0); + ZVAL_INT(&CG(declarables).ticks, 0); } /* }}} */ @@ -300,7 +300,7 @@ static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */ static int lookup_cv(zend_op_array *op_array, zend_string* name TSRMLS_DC) /* {{{ */{ int i = 0; - ulong hash_value = STR_HASH_VAL(name); + zend_uint_t hash_value = STR_HASH_VAL(name); while (i < op_array->last_var) { if (op_array->vars[i]->val == name->val || @@ -383,8 +383,8 @@ static int zend_add_func_name_literal(zend_op_array *op_array, zval *zv TSRMLS_D ret = zend_add_literal(op_array, zv TSRMLS_CC); } - lc_name = STR_ALLOC(Z_STRLEN_P(zv), 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv)); + lc_name = STR_ALLOC(Z_STRSIZE_P(zv), 0); + zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRSIZE_P(zv)); ZVAL_NEW_STR(&c, lc_name); zend_add_literal(CG(active_op_array), &c TSRMLS_CC); @@ -409,16 +409,16 @@ static int zend_add_ns_func_name_literal(zend_op_array *op_array, zval *zv TSRML ret = zend_add_literal(op_array, zv TSRMLS_CC); } - lc_name = STR_ALLOC(Z_STRLEN_P(zv), 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv)); + lc_name = STR_ALLOC(Z_STRSIZE_P(zv), 0); + zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRSIZE_P(zv)); ZVAL_NEW_STR(&c, lc_name); zend_add_literal(CG(active_op_array), &c TSRMLS_CC); - ns_separator = (const char*)zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv)); + ns_separator = (const char*)zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRSIZE_P(zv)); if (ns_separator != NULL) { ns_separator += 1; - lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv)); + lc_len = Z_STRSIZE_P(zv) - (ns_separator - Z_STRVAL_P(zv)); lc_name = STR_ALLOC(lc_len, 0); zend_str_tolower_copy(lc_name->val, ns_separator, lc_len); ZVAL_NEW_STR(&c, lc_name); @@ -445,11 +445,11 @@ static int zend_add_class_name_literal(zend_op_array *op_array, zval *zv TSRMLS_ } if (Z_STRVAL_P(zv)[0] == '\\') { - lc_name = STR_ALLOC(Z_STRLEN_P(zv) - 1, 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv) + 1, Z_STRLEN_P(zv) - 1); + lc_name = STR_ALLOC(Z_STRSIZE_P(zv) - 1, 0); + zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv) + 1, Z_STRSIZE_P(zv) - 1); } else { - lc_name = STR_ALLOC(Z_STRLEN_P(zv), 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv)); + lc_name = STR_ALLOC(Z_STRSIZE_P(zv), 0); + zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRSIZE_P(zv)); } ZVAL_NEW_STR(&c, lc_name); zend_add_literal(CG(active_op_array), &c TSRMLS_CC); @@ -480,10 +480,10 @@ static int zend_add_const_name_literal(zend_op_array *op_array, zval *zv, int un /* skip leading '\\' */ if (Z_STRVAL_P(zv)[0] == '\\') { - name_len = Z_STRLEN_P(zv) - 1; + name_len = Z_STRSIZE_P(zv) - 1; name = Z_STRVAL_P(zv) + 1; } else { - name_len = Z_STRLEN_P(zv); + name_len = Z_STRSIZE_P(zv); name = Z_STRVAL_P(zv); } ns_separator = zend_memrchr(name, '\\', name_len); @@ -543,15 +543,15 @@ static int zend_add_const_name_literal(zend_op_array *op_array, zval *zv, int un op.constant = zend_add_literal(CG(active_op_array), &_c TSRMLS_CC); \ } while (0) -#define LITERAL_LONG(op, val) do { \ +#define LITERAL_INT(op, val) do { \ zval _c; \ - ZVAL_LONG(&_c, val); \ + ZVAL_INT(&_c, val); \ op.constant = zend_add_literal(CG(active_op_array), &_c TSRMLS_CC); \ } while (0) -#define LITERAL_LONG_EX(op_array, op, val) do { \ +#define LITERAL_INT_EX(op_array, op, val) do { \ zval _c; \ - ZVAL_LONG(&_c, val); \ + ZVAL_INT(&_c, val); \ op.constant = zend_add_literal(op_array, &_c TSRMLS_CC); \ } while (0) @@ -657,7 +657,7 @@ void fetch_simple_variable_ex(znode *result, znode *varname, int bp, zend_uchar } if (!zend_is_auto_global(Z_STR(varname->u.constant) TSRMLS_CC) && - !(Z_STRLEN(varname->u.constant) == (sizeof("this")-1) && + !(Z_STRSIZE(varname->u.constant) == (sizeof("this")-1) && !memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this") - 1)) && (CG(active_op_array)->last == 0 || CG(active_op_array)->opcodes[CG(active_op_array)->last-1].opcode != ZEND_BEGIN_SILENCE)) { @@ -713,7 +713,7 @@ void zend_do_fetch_static_member(znode *result, znode *class_name TSRMLS_DC) /* zend_op opline; if (class_name->op_type == IS_CONST && - ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) { + ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant))) { zend_resolve_class_name(class_name TSRMLS_CC); class_node = *class_name; } else { @@ -811,11 +811,11 @@ void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC) /* {{{ SET_NODE(opline.op1, parent); SET_NODE(opline.op2, dim); if (opline.op2_type == IS_CONST && Z_TYPE(CONSTANT(opline.op2.constant)) == IS_STRING) { - ulong index; + zend_uint_t index; if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline.op2.constant)), index)) { zval_dtor(&CONSTANT(opline.op2.constant)); - ZVAL_LONG(&CONSTANT(opline.op2.constant), index); + ZVAL_INT(&CONSTANT(opline.op2.constant), index); } } @@ -859,17 +859,17 @@ void zend_do_abstract_method(const znode *function_name, znode *modifiers, const char *method_type; if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) { - Z_LVAL(modifiers->u.constant) |= ZEND_ACC_ABSTRACT; + Z_IVAL(modifiers->u.constant) |= ZEND_ACC_ABSTRACT; method_type = "Interface"; } else { method_type = "Abstract"; } - if (Z_LVAL(modifiers->u.constant) & ZEND_ACC_ABSTRACT) { - if(Z_LVAL(modifiers->u.constant) & ZEND_ACC_PRIVATE) { + if (Z_IVAL(modifiers->u.constant) & ZEND_ACC_ABSTRACT) { + if(Z_IVAL(modifiers->u.constant) & ZEND_ACC_PRIVATE) { zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot be declared private", method_type, CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant)); } - if (Z_LVAL(body->u.constant) == ZEND_ACC_ABSTRACT) { + if (Z_IVAL(body->u.constant) == ZEND_ACC_ABSTRACT) { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_RAISE_ABSTRACT_ERROR; @@ -880,7 +880,7 @@ void zend_do_abstract_method(const znode *function_name, znode *modifiers, const zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot contain body", method_type, CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant)); } } else { - if (Z_LVAL(body->u.constant) == ZEND_ACC_ABSTRACT) { + if (Z_IVAL(body->u.constant) == ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_COMPILE_ERROR, "Non-abstract method %s::%s() must contain body", CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant)); } } @@ -893,7 +893,7 @@ static zend_bool opline_is_fetch_this(const zend_op *opline TSRMLS_DC) /* {{{ */ && (Z_TYPE(CONSTANT(opline->op1.constant)) == IS_STRING) && ((opline->extended_value & ZEND_FETCH_STATIC_MEMBER) != ZEND_FETCH_STATIC_MEMBER) && (Z_STRHASH(CONSTANT(opline->op1.constant)) == THIS_HASHVAL) - && (Z_STRLEN(CONSTANT(opline->op1.constant)) == (sizeof("this")-1)) + && (Z_STRSIZE(CONSTANT(opline->op1.constant)) == (sizeof("this")-1)) && !memcmp(Z_STRVAL(CONSTANT(opline->op1.constant)), "this", sizeof("this") - 1)) { return 1; } else { @@ -1369,15 +1369,15 @@ void zend_do_add_string(znode *result, znode *op1, znode *op2 TSRMLS_DC) /* {{{ { zend_op *opline; - if (Z_STRLEN(op2->u.constant) > 1) { + if (Z_STRSIZE(op2->u.constant) > 1) { opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_ADD_STRING; - } else if (Z_STRLEN(op2->u.constant) == 1) { + } else if (Z_STRSIZE(op2->u.constant) == 1) { int ch = *Z_STRVAL(op2->u.constant); /* Free memory and use ZEND_ADD_CHAR in case of 1 character strings */ STR_FREE(Z_STR(op2->u.constant)); - ZVAL_LONG(&op2->u.constant, ch); + ZVAL_INT(&op2->u.constant, ch); opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_ADD_CHAR; } else { /* String can be empty after a variable at the end of a heredoc */ @@ -1480,26 +1480,26 @@ void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */ int zend_do_verify_access_types(const znode *current_access_type, const znode *new_modifier) /* {{{ */ { - if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK) - && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK)) { + if ((Z_IVAL(current_access_type->u.constant) & ZEND_ACC_PPP_MASK) + && (Z_IVAL(new_modifier->u.constant) & ZEND_ACC_PPP_MASK)) { zend_error_noreturn(E_COMPILE_ERROR, "Multiple access type modifiers are not allowed"); } - if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_ABSTRACT) - && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_ABSTRACT)) { + if ((Z_IVAL(current_access_type->u.constant) & ZEND_ACC_ABSTRACT) + && (Z_IVAL(new_modifier->u.constant) & ZEND_ACC_ABSTRACT)) { zend_error_noreturn(E_COMPILE_ERROR, "Multiple abstract modifiers are not allowed"); } - if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_STATIC) - && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_STATIC)) { + if ((Z_IVAL(current_access_type->u.constant) & ZEND_ACC_STATIC) + && (Z_IVAL(new_modifier->u.constant) & ZEND_ACC_STATIC)) { zend_error_noreturn(E_COMPILE_ERROR, "Multiple static modifiers are not allowed"); } - if ((Z_LVAL(current_access_type->u.constant) & ZEND_ACC_FINAL) - && (Z_LVAL(new_modifier->u.constant) & ZEND_ACC_FINAL)) { + if ((Z_IVAL(current_access_type->u.constant) & ZEND_ACC_FINAL) + && (Z_IVAL(new_modifier->u.constant) & ZEND_ACC_FINAL)) { zend_error_noreturn(E_COMPILE_ERROR, "Multiple final modifiers are not allowed"); } - if (((Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant)) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) { + if (((Z_IVAL(current_access_type->u.constant) | Z_IVAL(new_modifier->u.constant)) & (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) == (ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use the final modifier on an abstract class member"); } - return (Z_LVAL(current_access_type->u.constant) | Z_LVAL(new_modifier->u.constant)); + return (Z_IVAL(current_access_type->u.constant) | Z_IVAL(new_modifier->u.constant)); } /* }}} */ @@ -1515,12 +1515,12 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n if (is_method) { if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) { - if ((Z_LVAL(fn_flags_znode->u.constant) & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) { + if ((Z_IVAL(fn_flags_znode->u.constant) & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) { zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface method %s::%s() must be omitted", CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant)); } - Z_LVAL(fn_flags_znode->u.constant) |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */ + Z_IVAL(fn_flags_znode->u.constant) |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */ } - fn_flags = Z_LVAL(fn_flags_znode->u.constant); /* must be done *after* the above check */ + fn_flags = Z_IVAL(fn_flags_znode->u.constant); /* must be done *after* the above check */ } else { fn_flags = 0; } @@ -1689,8 +1689,8 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n ZVAL_DUP(&tmp.u.constant, &CG(current_namespace)); zend_do_build_namespace_name(&tmp, &tmp, function_name TSRMLS_CC); op_array.function_name = Z_STR(tmp.u.constant); - lcname = STR_ALLOC(Z_STRLEN(tmp.u.constant), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL(tmp.u.constant), Z_STRLEN(tmp.u.constant)); + lcname = STR_ALLOC(Z_STRSIZE(tmp.u.constant), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL(tmp.u.constant), Z_STRSIZE(tmp.u.constant)); } else { lcname = STR_ALLOC(name->len, 0); zend_str_tolower_copy(lcname->val, name->val, name->len); @@ -1700,10 +1700,10 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n if (CG(current_import_function) && (ns_name = zend_hash_find(CG(current_import_function), lcname)) != NULL) { - char *tmp = zend_str_tolower_dup(Z_STRVAL_P(ns_name), Z_STRLEN_P(ns_name)); + char *tmp = zend_str_tolower_dup(Z_STRVAL_P(ns_name), Z_STRSIZE_P(ns_name)); - if (Z_STRLEN_P(ns_name) != Z_STRLEN(function_name->u.constant) || - memcmp(tmp, lcname->val, Z_STRLEN(function_name->u.constant))) { + if (Z_STRSIZE_P(ns_name) != Z_STRSIZE(function_name->u.constant) || + memcmp(tmp, lcname->val, Z_STRSIZE(function_name->u.constant))) { zend_error(E_COMPILE_ERROR, "Cannot declare function %s because the name is already in use", Z_STRVAL(function_name->u.constant)); } efree(tmp); @@ -1847,7 +1847,7 @@ void zend_do_receive_param(zend_uchar op, znode *varname, znode *initialization, if (EX_VAR_TO_NUM(var.u.op.var) != CG(active_op_array)->num_args) { zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter %s", Z_STRVAL(varname->u.constant)); } else if (Z_STRHASH(varname->u.constant) == THIS_HASHVAL && - Z_STRLEN(varname->u.constant) == sizeof("this")-1 && + Z_STRSIZE(varname->u.constant) == sizeof("this")-1 && !memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this")-1)) { if (CG(active_op_array)->scope && (CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) == 0) { @@ -1886,8 +1886,8 @@ void zend_do_receive_param(zend_uchar op, znode *varname, znode *initialization, } CG(active_op_array)->arg_info = erealloc(CG(active_op_array)->arg_info, sizeof(zend_arg_info)*(CG(active_op_array)->num_args)); cur_arg_info = &CG(active_op_array)->arg_info[CG(active_op_array)->num_args-1]; - cur_arg_info->name = estrndup(Z_STRVAL(varname->u.constant), Z_STRLEN(varname->u.constant)); - cur_arg_info->name_len = Z_STRLEN(varname->u.constant); + cur_arg_info->name = estrndup(Z_STRVAL(varname->u.constant), Z_STRSIZE(varname->u.constant)); + cur_arg_info->name_len = Z_STRSIZE(varname->u.constant); cur_arg_info->type_hint = 0; cur_arg_info->pass_by_reference = pass_by_reference; cur_arg_info->allow_null = 1; @@ -1919,7 +1919,7 @@ void zend_do_receive_param(zend_uchar op, znode *varname, znode *initialization, } } else { cur_arg_info->type_hint = IS_OBJECT; - if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_type->u.constant), Z_STRLEN(class_type->u.constant))) { + if (ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_type->u.constant), Z_STRSIZE(class_type->u.constant))) { zend_resolve_class_name(class_type TSRMLS_CC); } Z_STR(class_type->u.constant) = zend_new_interned_string(Z_STR(class_type->u.constant) TSRMLS_CC); @@ -1928,12 +1928,12 @@ void zend_do_receive_param(zend_uchar op, znode *varname, znode *initialization, } // TODO: for now we have to copy it ??? #if 1 - cur_arg_info->class_name = estrndup(Z_STRVAL(class_type->u.constant), Z_STRLEN(class_type->u.constant)); - cur_arg_info->class_name_len = Z_STRLEN(class_type->u.constant); + cur_arg_info->class_name = estrndup(Z_STRVAL(class_type->u.constant), Z_STRSIZE(class_type->u.constant)); + cur_arg_info->class_name_len = Z_STRSIZE(class_type->u.constant); STR_RELEASE(Z_STR(class_type->u.constant)); #else cur_arg_info->class_name = Z_STRVAL(class_type->u.constant); - cur_arg_info->class_name_len = Z_STRLEN(class_type->u.constant); + cur_arg_info->class_name_len = Z_STRSIZE(class_type->u.constant); #endif if (op == ZEND_RECV_INIT) { if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")) || Z_TYPE(initialization->u.constant) == IS_CONSTANT_AST) { @@ -1958,7 +1958,7 @@ int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace zend_uint op_number; zend_function *function; zend_string *lcname; - char *is_compound = memchr(Z_STRVAL(function_name->u.constant), '\\', Z_STRLEN(function_name->u.constant)); + char *is_compound = memchr(Z_STRVAL(function_name->u.constant), '\\', Z_STRSIZE(function_name->u.constant)); zend_resolve_function_name(function_name, &check_namespace TSRMLS_CC); @@ -1972,8 +1972,8 @@ int zend_do_begin_function_call(znode *function_name, zend_bool check_namespace return 1; } - lcname = STR_ALLOC(Z_STRLEN(function_name->u.constant), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL(function_name->u.constant), Z_STRLEN(function_name->u.constant)); + lcname = STR_ALLOC(Z_STRSIZE(function_name->u.constant), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL(function_name->u.constant), Z_STRSIZE(function_name->u.constant)); if (((function = zend_hash_find_ptr(CG(function_table), lcname)) == NULL) || ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS) && (function->type == ZEND_INTERNAL_FUNCTION))) { @@ -2008,8 +2008,8 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */ last_op_number = get_next_op_number(CG(active_op_array))-1; last_op = &CG(active_op_array)->opcodes[last_op_number]; - if ((last_op->op2_type == IS_CONST) && (Z_TYPE(CONSTANT(last_op->op2.constant)) == IS_STRING) && (Z_STRLEN(CONSTANT(last_op->op2.constant)) == sizeof(ZEND_CLONE_FUNC_NAME)-1) - && !zend_binary_strcasecmp(Z_STRVAL(CONSTANT(last_op->op2.constant)), Z_STRLEN(CONSTANT(last_op->op2.constant)), ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)-1)) { + if ((last_op->op2_type == IS_CONST) && (Z_TYPE(CONSTANT(last_op->op2.constant)) == IS_STRING) && (Z_STRSIZE(CONSTANT(last_op->op2.constant)) == sizeof(ZEND_CLONE_FUNC_NAME)-1) + && !zend_binary_strcasecmp(Z_STRVAL(CONSTANT(last_op->op2.constant)), Z_STRSIZE(CONSTANT(last_op->op2.constant)), ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)-1)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot call __clone() method on objects - use 'clone $obj' instead"); } @@ -2028,7 +2028,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) /* {{{ */ } last_op->opcode = ZEND_INIT_METHOD_CALL; last_op->result_type = IS_UNUSED; - Z_LVAL(left_bracket->u.constant) = ZEND_INIT_FCALL_BY_NAME; + Z_IVAL(left_bracket->u.constant) = ZEND_INIT_FCALL_BY_NAME; } else { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_INIT_FCALL_BY_NAME; @@ -2098,12 +2098,12 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace int len; zval *ns; zend_string *lookup_name; - char *compound = memchr(Z_STRVAL(element_name->u.constant), '\\', Z_STRLEN(element_name->u.constant)); + char *compound = memchr(Z_STRVAL(element_name->u.constant), '\\', Z_STRSIZE(element_name->u.constant)); if (Z_STRVAL(element_name->u.constant)[0] == '\\') { /* name starts with \ so it is known and unambiguos, nothing to do here but shorten it */ - memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+1, Z_STRLEN(element_name->u.constant)); - --Z_STRLEN(element_name->u.constant); + memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+1, Z_STRSIZE(element_name->u.constant)); + --Z_STRSIZE(element_name->u.constant); return; } @@ -2112,7 +2112,7 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace } if (current_import_sub) { - len = Z_STRLEN(element_name->u.constant); + len = Z_STRSIZE(element_name->u.constant); if (case_sensitive) { lookup_name = STR_INIT(Z_STRVAL(element_name->u.constant), len, 0); } else { @@ -2141,8 +2141,8 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace tmp.op_type = IS_CONST; ZVAL_DUP(&tmp.u.constant, ns); len += 1; - Z_STRLEN(element_name->u.constant) -= len; - memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+len, Z_STRLEN(element_name->u.constant)+1); + Z_STRSIZE(element_name->u.constant) -= len; + memmove(Z_STRVAL(element_name->u.constant), Z_STRVAL(element_name->u.constant)+len, Z_STRSIZE(element_name->u.constant)+1); zend_do_build_namespace_name(&tmp, &tmp, element_name TSRMLS_CC); *element_name = tmp; STR_FREE(lookup_name); @@ -2154,11 +2154,11 @@ void zend_resolve_non_class_name(znode *element_name, zend_bool *check_namespace if (Z_TYPE(CG(current_namespace)) != IS_UNDEF) { tmp = *element_name; - Z_STR(tmp.u.constant) = STR_ALLOC(sizeof("\\")-1 + Z_STRLEN(element_name->u.constant) + Z_STRLEN(CG(current_namespace)), 0); + Z_STR(tmp.u.constant) = STR_ALLOC(sizeof("\\")-1 + Z_STRSIZE(element_name->u.constant) + Z_STRSIZE(CG(current_namespace)), 0); Z_TYPE_FLAGS(tmp.u.constant) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE; - memcpy(Z_STRVAL(tmp.u.constant), Z_STRVAL(CG(current_namespace)), Z_STRLEN(CG(current_namespace))); - memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN(CG(current_namespace))]), "\\", sizeof("\\")-1); - memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRLEN(CG(current_namespace)) + sizeof("\\")-1]), Z_STRVAL(element_name->u.constant), Z_STRLEN(element_name->u.constant)+1); + memcpy(Z_STRVAL(tmp.u.constant), Z_STRVAL(CG(current_namespace)), Z_STRSIZE(CG(current_namespace))); + memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRSIZE(CG(current_namespace))]), "\\", sizeof("\\")-1); + memcpy(&(Z_STRVAL(tmp.u.constant)[Z_STRSIZE(CG(current_namespace)) + sizeof("\\")-1]), Z_STRVAL(element_name->u.constant), Z_STRSIZE(element_name->u.constant)+1); STR_RELEASE(Z_STR(element_name->u.constant)); *element_name = tmp; } @@ -2183,7 +2183,7 @@ void zend_do_resolve_class_name(znode *result, znode *class_name, int is_static int lctype; znode constant_name; - lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); + lcname = zend_str_tolower_dup(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant)); lctype = zend_get_class_fetch_type(lcname, strlen(lcname)); switch (lctype) { case ZEND_FETCH_CLASS_SELF: @@ -2232,18 +2232,18 @@ void zend_resolve_class_name(znode *class_name TSRMLS_DC) /* {{{ */ znode tmp; int len; - compound = memchr(Z_STRVAL(class_name->u.constant), '\\', Z_STRLEN(class_name->u.constant)); + compound = memchr(Z_STRVAL(class_name->u.constant), '\\', Z_STRSIZE(class_name->u.constant)); if (compound) { /* This is a compound class name that contains namespace prefix */ if (Z_STRVAL(class_name->u.constant)[0] == '\\') { /* The STRING name has "\" prefix */ - memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+1, Z_STRLEN(class_name->u.constant)); + memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+1, Z_STRSIZE(class_name->u.constant)); Z_STR(class_name->u.constant) = STR_REALLOC( Z_STR(class_name->u.constant), - Z_STRLEN(class_name->u.constant) - 1, 0); + Z_STRSIZE(class_name->u.constant) - 1, 0); Z_TYPE_FLAGS(class_name->u.constant) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE; - if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) { + if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant))) { zend_error_noreturn(E_COMPILE_ERROR, "'\\%s' is an invalid class name", Z_STRVAL(class_name->u.constant)); } } else { @@ -2257,8 +2257,8 @@ void zend_resolve_class_name(znode *class_name TSRMLS_DC) /* {{{ */ tmp.op_type = IS_CONST; ZVAL_DUP(&tmp.u.constant, ns); len += 1; - Z_STRLEN(class_name->u.constant) -= len; - memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+len, Z_STRLEN(class_name->u.constant)+1); + Z_STRSIZE(class_name->u.constant) -= len; + memmove(Z_STRVAL(class_name->u.constant), Z_STRVAL(class_name->u.constant)+len, Z_STRSIZE(class_name->u.constant)+1); zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC); *class_name = tmp; STR_FREE(lcname); @@ -2276,8 +2276,8 @@ void zend_resolve_class_name(znode *class_name TSRMLS_DC) /* {{{ */ } } else if (CG(current_import) || Z_TYPE(CG(current_namespace)) != IS_UNDEF) { /* this is a plain name (without \) */ - lcname = STR_ALLOC(Z_STRLEN(class_name->u.constant), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); + lcname = STR_ALLOC(Z_STRSIZE(class_name->u.constant), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant)); if (CG(current_import) && (ns = zend_hash_find(CG(current_import), lcname)) != NULL) { @@ -2298,7 +2298,7 @@ void zend_resolve_class_name(znode *class_name TSRMLS_DC) /* {{{ */ void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC) /* {{{ */ { - long fetch_class_op_number; + zend_int_t fetch_class_op_number; zend_op *opline; fetch_class_op_number = get_next_op_number(CG(active_op_array)); @@ -2311,7 +2311,7 @@ void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC) /* {{{ */ if (class_name->op_type == IS_CONST) { int fetch_type; - fetch_type = zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); + fetch_type = zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant)); switch (fetch_type) { case ZEND_FETCH_CLASS_SELF: case ZEND_FETCH_CLASS_PARENT: @@ -2367,7 +2367,7 @@ void zend_do_label(znode *label TSRMLS_DC) /* {{{ */ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 TSRMLS_DC) /* {{{ */ { zend_label *dest; - long current, distance; + zend_int_t current, distance; zval *label; if (pass2) { @@ -2415,7 +2415,7 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int pass2 SET_UNUSED(opline->op2); } else { /* Set real break distance */ - ZVAL_LONG(label, distance); + ZVAL_INT(label, distance); } if (pass2) { @@ -2462,20 +2462,20 @@ void zend_do_build_full_name(znode *result, znode *prefix, znode *name, int is_c } if (is_class_member) { - int old_len = Z_STRLEN(result->u.constant); - length = sizeof("::")-1 + old_len + Z_STRLEN(name->u.constant); + int old_len = Z_STRSIZE(result->u.constant); + length = sizeof("::")-1 + old_len + Z_STRSIZE(name->u.constant); Z_STR(result->u.constant) = STR_REALLOC(Z_STR(result->u.constant), length, 0); Z_TYPE_FLAGS(result->u.constant) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE; memcpy(&Z_STRVAL(result->u.constant)[old_len], "::", sizeof("::")-1); - memcpy(&Z_STRVAL(result->u.constant)[old_len + sizeof("::")-1], Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)+1); + memcpy(&Z_STRVAL(result->u.constant)[old_len + sizeof("::")-1], Z_STRVAL(name->u.constant), Z_STRSIZE(name->u.constant)+1); STR_RELEASE(Z_STR(name->u.constant)); } else { - int old_len = Z_STRLEN(result->u.constant); - length = sizeof("\\")-1 + old_len + Z_STRLEN(name->u.constant); + int old_len = Z_STRSIZE(result->u.constant); + length = sizeof("\\")-1 + old_len + Z_STRSIZE(name->u.constant); Z_STR(result->u.constant) = STR_REALLOC(Z_STR(result->u.constant), length, 0); Z_TYPE_FLAGS(result->u.constant) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE; memcpy(&Z_STRVAL(result->u.constant)[old_len], "\\", sizeof("\\")-1); - memcpy(&Z_STRVAL(result->u.constant)[old_len + sizeof("\\")-1], Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)+1); + memcpy(&Z_STRVAL(result->u.constant)[old_len + sizeof("\\")-1], Z_STRVAL(name->u.constant), Z_STRSIZE(name->u.constant)+1); STR_RELEASE(Z_STR(name->u.constant)); } } @@ -2492,8 +2492,8 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na if (Z_TYPE(method_name->u.constant) != IS_STRING) { zend_error_noreturn(E_COMPILE_ERROR, "Method name must be a string"); } - lcname = zend_str_tolower_dup(Z_STRVAL(method_name->u.constant), Z_STRLEN(method_name->u.constant)); - if ((sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(method_name->u.constant) && + lcname = zend_str_tolower_dup(Z_STRVAL(method_name->u.constant), Z_STRSIZE(method_name->u.constant)); + if ((sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRSIZE(method_name->u.constant) && memcmp(lcname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) { zval_dtor(&method_name->u.constant); method_name->op_type = IS_UNUSED; @@ -2502,7 +2502,7 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na } if (class_name->op_type == IS_CONST && - ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) { + ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant))) { zend_resolve_class_name(class_name TSRMLS_CC); class_node = *class_name; op_number = get_next_op_number(CG(active_op_array)); @@ -2548,8 +2548,8 @@ static int zend_do_convert_call(zend_op *init_opline, zend_op *opline, long num_ *func_ptr = NULL; if (opline->op1_type == IS_CONST && Z_TYPE(CONSTANT(opline->op1.constant)) == IS_STRING) { function_name = &CONSTANT(opline->op1.constant); - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); if (((function = zend_hash_find_ptr(CG(function_table), lcname)) == NULL) || ((CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS) && (function->type == ZEND_INTERNAL_FUNCTION))) { @@ -2808,8 +2808,8 @@ static int zend_do_convert_defined(zend_op *init_opline, znode *result TSRMLS_DC if (opline->opcode != ZEND_SEND_VAL || opline->op1_type != IS_CONST || Z_TYPE(CONSTANT(opline->op1.constant)) != IS_STRING - || zend_memrchr(Z_STRVAL(CONSTANT(opline->op1.constant)), '\\', Z_STRLEN(CONSTANT(opline->op1.constant))) != NULL - || zend_memrchr(Z_STRVAL(CONSTANT(opline->op1.constant)), ':', Z_STRLEN(CONSTANT(opline->op1.constant))) != NULL) { + || zend_memrchr(Z_STRVAL(CONSTANT(opline->op1.constant)), '\\', Z_STRSIZE(CONSTANT(opline->op1.constant))) != NULL + || zend_memrchr(Z_STRVAL(CONSTANT(opline->op1.constant)), ':', Z_STRSIZE(CONSTANT(opline->op1.constant))) != NULL) { return 0; } @@ -2818,8 +2818,8 @@ static int zend_do_convert_defined(zend_op *init_opline, znode *result TSRMLS_DC opline->extended_value = 0; GET_CACHE_SLOT(opline->op1.constant); /* lowcase constant name */ - lc_name = STR_ALLOC(Z_STRLEN(CONSTANT(opline->op1.constant)), 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL(CONSTANT(opline->op1.constant)), Z_STRLEN(CONSTANT(opline->op1.constant))); + lc_name = STR_ALLOC(Z_STRSIZE(CONSTANT(opline->op1.constant)), 0); + zend_str_tolower_copy(lc_name->val, Z_STRVAL(CONSTANT(opline->op1.constant)), Z_STRSIZE(CONSTANT(opline->op1.constant))); ZVAL_NEW_STR(&c, lc_name); zend_add_literal(CG(active_op_array), &c TSRMLS_CC); opline->result.var = get_temporary_variable(CG(active_op_array)); @@ -2839,7 +2839,7 @@ void zend_do_end_function_call(znode *function_name, znode *result, int is_metho if (fcall->arg_num != 0) { zend_error(E_WARNING, "Clone method does not require arguments"); } - opline = &CG(active_op_array)->opcodes[Z_LVAL(function_name->u.constant)]; + opline = &CG(active_op_array)->opcodes[Z_IVAL(function_name->u.constant)]; } else { zend_uint call_flags = 0; @@ -2902,7 +2902,7 @@ void zend_do_end_function_call(znode *function_name, znode *result, int is_metho } else if (func->common.function_name->len == sizeof("is_long")-1 && memcmp(func->common.function_name->val, "is_long", sizeof("is_long")-1) == 0) { if (fcall->arg_num == 1) { - if (zend_do_convert_type_check(opline, result, IS_LONG TSRMLS_CC)) { + if (zend_do_convert_type_check(opline, result, IS_INT TSRMLS_CC)) { zend_stack_del_top(&CG(function_call_stack)); return; } @@ -3337,12 +3337,12 @@ void zend_do_finally(znode *finally_token TSRMLS_DC) /* {{{ */ void zend_do_begin_catch(znode *catch_token, znode *class_name, znode *catch_var, znode *first_catch TSRMLS_DC) /* {{{ */ { - long catch_op_number; + zend_int_t catch_op_number; zend_op *opline; znode catch_class; if (class_name->op_type == IS_CONST && - ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant))) { + ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant))) { zend_resolve_class_name(class_name TSRMLS_CC); catch_class = *class_name; } else { @@ -3825,7 +3825,7 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ ++idx; while (op < end) { if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) - && op->op1.num == (long)idx) + && op->op1.num == (zend_int_t)idx) { precv = op; } @@ -3836,9 +3836,9 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ zval *zv = precv->op2.zv; if (Z_TYPE_P(zv) == IS_CONSTANT) { - REALLOC_BUF_IF_EXCEED(buf, offset, length, Z_STRLEN_P(zv)); - memcpy(offset, Z_STRVAL_P(zv), Z_STRLEN_P(zv)); - offset += Z_STRLEN_P(zv); + REALLOC_BUF_IF_EXCEED(buf, offset, length, Z_STRSIZE_P(zv)); + memcpy(offset, Z_STRVAL_P(zv), Z_STRSIZE_P(zv)); + offset += Z_STRSIZE_P(zv); } else if (Z_TYPE_P(zv) == IS_FALSE) { memcpy(offset, "false", 5); offset += 5; @@ -3850,10 +3850,10 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{ offset += 4; } else if (Z_TYPE_P(zv) == IS_STRING) { *(offset++) = '\''; - REALLOC_BUF_IF_EXCEED(buf, offset, length, MIN(Z_STRLEN_P(zv), 10)); - memcpy(offset, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 10)); - offset += MIN(Z_STRLEN_P(zv), 10); - if (Z_STRLEN_P(zv) > 10) { + REALLOC_BUF_IF_EXCEED(buf, offset, length, MIN(Z_STRSIZE_P(zv), 10)); + memcpy(offset, Z_STRVAL_P(zv), MIN(Z_STRSIZE_P(zv), 10)); + offset += MIN(Z_STRSIZE_P(zv), 10); + if (Z_STRSIZE_P(zv) > 10) { *(offset++) = '.'; *(offset++) = '.'; *(offset++) = '.'; @@ -4837,12 +4837,12 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { not_compatible = (FAILURE == compare_function(&compare_result, &ce->default_static_members_table[coliding_prop->offset], &ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC)) - || (Z_LVAL(compare_result) != 0); + || (Z_IVAL(compare_result) != 0); } else { not_compatible = (FAILURE == compare_function(&compare_result, &ce->default_properties_table[coliding_prop->offset], &ce->traits[i]->default_properties_table[property_info->offset] TSRMLS_CC)) - || (Z_LVAL(compare_result) != 0); + || (Z_IVAL(compare_result) != 0); } } else { /* the flags are not identical, thus, we assume properties are not compatible */ @@ -5035,20 +5035,20 @@ void zend_add_trait_alias(znode *method_reference, znode *modifiers, znode *alia zend_class_entry *ce = CG(active_class_entry); zend_trait_alias *trait_alias; - if (Z_LVAL(modifiers->u.constant) == ZEND_ACC_STATIC) { + if (Z_IVAL(modifiers->u.constant) == ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use 'static' as method modifier"); return; - } else if (Z_LVAL(modifiers->u.constant) == ZEND_ACC_ABSTRACT) { + } else if (Z_IVAL(modifiers->u.constant) == ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use 'abstract' as method modifier"); return; - } else if (Z_LVAL(modifiers->u.constant) == ZEND_ACC_FINAL) { + } else if (Z_IVAL(modifiers->u.constant) == ZEND_ACC_FINAL) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use 'final' as method modifier"); return; } trait_alias = emalloc(sizeof(zend_trait_alias)); trait_alias->trait_method = (zend_trait_method_reference*)method_reference->u.op.ptr; - trait_alias->modifiers = Z_LVAL(modifiers->u.constant); + trait_alias->modifiers = Z_IVAL(modifiers->u.constant); if (alias) { trait_alias->alias = Z_STR(alias->u.constant); } else { @@ -5347,12 +5347,12 @@ void zend_do_brk_cont(zend_uchar op, znode *expr TSRMLS_DC) /* {{{ */ if (expr) { if (expr->op_type != IS_CONST) { zend_error_noreturn(E_COMPILE_ERROR, "'%s' operator with non-constant operand is no longer supported", op == ZEND_BRK ? "break" : "continue"); - } else if (Z_TYPE(expr->u.constant) != IS_LONG || Z_LVAL(expr->u.constant) < 1) { + } else if (Z_TYPE(expr->u.constant) != IS_INT || Z_IVAL(expr->u.constant) < 1) { zend_error_noreturn(E_COMPILE_ERROR, "'%s' operator accepts only positive numbers", op == ZEND_BRK ? "break" : "continue"); } SET_NODE(opline->op2, expr); } else { - LITERAL_LONG(opline->op2, 1); + LITERAL_INT(opline->op2, 1); opline->op2_type = IS_CONST; } } @@ -5505,8 +5505,8 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name return; } - lcname = STR_ALLOC(Z_STRLEN(class_name->u.constant), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); + lcname = STR_ALLOC(Z_STRSIZE(class_name->u.constant), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant)); if (!(strcmp(lcname->val, "self") && strcmp(lcname->val, "parent"))) { STR_FREE(lcname); @@ -5528,15 +5528,15 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC); *class_name = tmp; STR_FREE(lcname); - lcname = STR_ALLOC(Z_STRLEN(class_name->u.constant), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant)); + lcname = STR_ALLOC(Z_STRSIZE(class_name->u.constant), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRSIZE(class_name->u.constant)); } if (error) { - char *tmp = zend_str_tolower_dup(Z_STRVAL_P(ns_name), Z_STRLEN_P(ns_name)); + char *tmp = zend_str_tolower_dup(Z_STRVAL_P(ns_name), Z_STRSIZE_P(ns_name)); - if (Z_STRLEN_P(ns_name) != Z_STRLEN(class_name->u.constant) || - memcmp(tmp, lcname->val, Z_STRLEN(class_name->u.constant))) { + if (Z_STRSIZE_P(ns_name) != Z_STRSIZE(class_name->u.constant) || + memcmp(tmp, lcname->val, Z_STRSIZE(class_name->u.constant))) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare class %s because the name is already in use", Z_STRVAL(class_name->u.constant)); } efree(tmp); @@ -5686,7 +5686,7 @@ void zend_do_implements_interface(znode *interface_name TSRMLS_DC) /* {{{ */ CG(active_class_entry)->name->val); } - switch (zend_get_class_fetch_type(Z_STRVAL(interface_name->u.constant), Z_STRLEN(interface_name->u.constant))) { + switch (zend_get_class_fetch_type(Z_STRVAL(interface_name->u.constant), Z_STRSIZE(interface_name->u.constant))) { case ZEND_FETCH_CLASS_SELF: case ZEND_FETCH_CLASS_PARENT: case ZEND_FETCH_CLASS_STATIC: @@ -5718,7 +5718,7 @@ void zend_do_use_trait(znode *trait_name TSRMLS_DC) /* {{{ */ } - switch (zend_get_class_fetch_type(Z_STRVAL(trait_name->u.constant), Z_STRLEN(trait_name->u.constant))) { + switch (zend_get_class_fetch_type(Z_STRVAL(trait_name->u.constant), Z_STRSIZE(trait_name->u.constant))) { case ZEND_FETCH_CLASS_SELF: case ZEND_FETCH_CLASS_PARENT: case ZEND_FETCH_CLASS_STATIC: @@ -5953,7 +5953,7 @@ void zend_do_halt_compiler_register(TSRMLS_D) /* {{{ */ cfilename = zend_get_compiled_filename(TSRMLS_C); name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, cfilename->val, cfilename->len, 0); - zend_register_long_constant(name->val, name->len, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC); + zend_register_int_constant(name->val, name->len, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC); STR_FREE(name); if (CG(in_namespace)) { @@ -6012,9 +6012,9 @@ static zend_constant* zend_get_ct_const(const zval *const_name, int all_internal char *lookup_name; if (Z_STRVAL_P(const_name)[0] == '\\') { - if ((c = zend_hash_str_find_ptr(EG(zend_constants), Z_STRVAL_P(const_name)+1, Z_STRLEN_P(const_name)-1)) == NULL) { - lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name)+1, Z_STRLEN_P(const_name)-1); - if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name)-1)) != NULL) { + if ((c = zend_hash_str_find_ptr(EG(zend_constants), Z_STRVAL_P(const_name)+1, Z_STRSIZE_P(const_name)-1)) == NULL) { + lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name)+1, Z_STRSIZE_P(const_name)-1); + if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, Z_STRSIZE_P(const_name)-1)) != NULL) { if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) { efree(lookup_name); return c; @@ -6024,8 +6024,8 @@ static zend_constant* zend_get_ct_const(const zval *const_name, int all_internal return NULL; } } else if ((c = zend_hash_find_ptr(EG(zend_constants), Z_STR_P(const_name))) == NULL) { - lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRLEN_P(const_name)); - if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name))) != NULL) { + lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRSIZE_P(const_name)); + if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, Z_STRSIZE_P(const_name))) != NULL) { if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) { efree(lookup_name); return c; @@ -6068,13 +6068,13 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con zend_op *opline; int type; char *compound; - ulong fetch_type = 0; + zend_uint_t fetch_type = 0; if (constant_container) { switch (mode) { case ZEND_CT: /* this is a class constant */ - type = zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant)); + type = zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRSIZE(constant_container->u.constant)); if (ZEND_FETCH_CLASS_STATIC == type) { zend_error(E_ERROR, "\"static::\" is not allowed in compile-time constants"); @@ -6091,7 +6091,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con break; case ZEND_RT: if (constant_container->op_type == IS_CONST && - ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRLEN(constant_container->u.constant))) { + ZEND_FETCH_CLASS_DEFAULT == zend_get_class_fetch_type(Z_STRVAL(constant_container->u.constant), Z_STRSIZE(constant_container->u.constant))) { zend_resolve_class_name(constant_container TSRMLS_CC); } else { zend_do_fetch_class(&tmp, constant_container TSRMLS_CC); @@ -6122,7 +6122,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con /* only one that did not contain \ from the start can be converted to string if unknown */ switch (mode) { case ZEND_CT: - compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant)); + compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRSIZE(constant_name->u.constant)); /* this is a namespace constant, or an unprefixed constant */ if (zend_constant_ct_subst(result, &constant_name->u.constant, 0 TSRMLS_CC)) { @@ -6143,7 +6143,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con Z_CONST_FLAGS(result->u.constant) = fetch_type; break; case ZEND_RT: - compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant)); + compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRSIZE(constant_name->u.constant)); zend_resolve_const_name(constant_name, &check_namespace TSRMLS_CC); @@ -6232,12 +6232,12 @@ void zend_do_init_array(znode *result, znode *expr, znode *offset, zend_bool is_ if (offset) { SET_NODE(opline->op2, offset); if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) { - ulong index; + zend_uint_t index; opline->extended_value |= ZEND_ARRAY_NOT_PACKED; if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline->op2.constant)), index)) { zval_dtor(&CONSTANT(opline->op2.constant)); - ZVAL_LONG(&CONSTANT(opline->op2.constant), index); + ZVAL_INT(&CONSTANT(opline->op2.constant), index); } } } else { @@ -6262,12 +6262,12 @@ void zend_do_add_array_element(znode *result, znode *expr, znode *offset, zend_b if (offset) { SET_NODE(opline->op2, offset); if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) { - ulong index; + zend_uint_t index; init_opline->extended_value |= ZEND_ARRAY_NOT_PACKED; if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline->op2.constant)), index)) { zval_dtor(&CONSTANT(opline->op2.constant)); - ZVAL_LONG(&CONSTANT(opline->op2.constant), index); + ZVAL_INT(&CONSTANT(opline->op2.constant), index); } } } else { @@ -6334,8 +6334,8 @@ void zend_do_end_array(znode *result, const znode *array_node TSRMLS_DC) /* {{{ while (i > 0 && constant_array) { if (opline->op2_type == IS_CONST) { switch (Z_TYPE(CONSTANT(opline->op2.constant))) { - case IS_LONG: - num = Z_LVAL(CONSTANT(opline->op2.constant)); + case IS_INT: + num = Z_IVAL(CONSTANT(opline->op2.constant)); num_index: zend_hash_index_update(Z_ARRVAL(array), num, &CONSTANT(opline->op1.constant)); if (Z_REFCOUNTED(CONSTANT(opline->op1.constant))) Z_ADDREF(CONSTANT(opline->op1.constant)); @@ -6347,7 +6347,7 @@ str_index: if (Z_REFCOUNTED(CONSTANT(opline->op1.constant))) Z_ADDREF(CONSTANT(opline->op1.constant)); break; case IS_DOUBLE: - num = zend_dval_to_lval(Z_DVAL(CONSTANT(opline->op2.constant))); + num = zend_dval_to_ival(Z_DVAL(CONSTANT(opline->op2.constant))); goto num_index; case IS_FALSE: num = 0; @@ -6483,7 +6483,7 @@ void zend_do_list_end(znode *result, znode *expr TSRMLS_DC) /* {{{ */ opline->result.var = get_temporary_variable(CG(active_op_array)); SET_NODE(opline->op1, &last_container); opline->op2_type = IS_CONST; - LITERAL_LONG(opline->op2, *((int *) dimension->data)); + LITERAL_INT(opline->op2, *((int *) dimension->data)); GET_NODE(&last_container, opline->result); dimension = dimension->next; } @@ -6600,7 +6600,7 @@ void zend_do_fetch_lexical_variable(znode *varname, zend_bool is_ref TSRMLS_DC) { znode value; - if (Z_STRLEN(varname->u.constant) == sizeof("this") - 1 && + if (Z_STRSIZE(varname->u.constant) == sizeof("this") - 1 && memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this") - 1) == 0) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as lexical variable"); return; @@ -6629,7 +6629,7 @@ void zend_do_fetch_global_variable(znode *varname, const znode *static_assignmen if (varname->op_type == IS_CONST && !zend_is_auto_global(Z_STR(varname->u.constant) TSRMLS_CC) && - !(Z_STRLEN(varname->u.constant) == (sizeof("this")-1) && + !(Z_STRSIZE(varname->u.constant) == (sizeof("this")-1) && !memcmp(Z_STRVAL(varname->u.constant), "this", sizeof("this") - 1))) { opline->opcode = ZEND_BIND_GLOBAL; SET_NODE(opline->op2, varname); @@ -6693,7 +6693,7 @@ void zend_do_indirect_references(znode *result, const znode *num_references, zno int i; zend_do_end_variable_parse(variable, BP_VAR_R, 0 TSRMLS_CC); - for (i=1; i<Z_LVAL(num_references->u.constant); i++) { + for (i=1; i<Z_IVAL(num_references->u.constant); i++) { fetch_simple_variable_ex(result, variable, 0, ZEND_FETCH_R TSRMLS_CC); *variable = *result; } @@ -6997,10 +6997,10 @@ void zend_do_declare_begin(TSRMLS_D) /* {{{ */ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC) /* {{{ */ { - if (!zend_binary_strcasecmp(Z_STRVAL(var->u.constant), Z_STRLEN(var->u.constant), "ticks", sizeof("ticks")-1)) { - convert_to_long(&val->u.constant); + if (!zend_binary_strcasecmp(Z_STRVAL(var->u.constant), Z_STRSIZE(var->u.constant), "ticks", sizeof("ticks")-1)) { + convert_to_int(&val->u.constant); CG(declarables).ticks = val->u.constant; - } else if (!zend_binary_strcasecmp(Z_STRVAL(var->u.constant), Z_STRLEN(var->u.constant), "encoding", sizeof("encoding")-1)) { + } else if (!zend_binary_strcasecmp(Z_STRVAL(var->u.constant), Z_STRSIZE(var->u.constant), "encoding", sizeof("encoding")-1)) { if (Z_TYPE(val->u.constant) == IS_CONSTANT) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use constants as encoding"); } @@ -7062,7 +7062,7 @@ void zend_do_declare_end(const znode *declare_token TSRMLS_DC) /* {{{ */ { zend_declarables *declarables = zend_stack_top(&CG(declare_stack)); /* We should restore if there was more than (current - start) - (ticks?1:0) opcodes */ - if ((get_next_op_number(CG(active_op_array)) - declare_token->u.op.opline_num) - ((Z_LVAL(CG(declarables).ticks))?1:0)) { + if ((get_next_op_number(CG(active_op_array)) - declare_token->u.op.opline_num) - ((Z_IVAL(CG(declarables).ticks))?1:0)) { CG(declarables) = *declarables; } } @@ -7284,7 +7284,7 @@ void zend_do_ticks(TSRMLS_D) /* {{{ */ opline->opcode = ZEND_TICKS; SET_UNUSED(opline->op1); SET_UNUSED(opline->op2); - opline->extended_value = Z_LVAL(CG(declarables).ticks); + opline->extended_value = Z_IVAL(CG(declarables).ticks); } /* }}} */ @@ -7344,7 +7344,7 @@ int zendlex(znode *zendlval TSRMLS_DC) /* {{{ */ } again: - Z_TYPE_INFO(zendlval->u.constant) = IS_LONG; + Z_TYPE_INFO(zendlval->u.constant) = IS_INT; retval = lex_scan(&zendlval->u.constant TSRMLS_CC); switch (retval) { case T_COMMENT: @@ -7472,7 +7472,7 @@ void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRM if (prefix) { *result = *prefix; if (Z_TYPE(result->u.constant) == IS_STRING && - Z_STRLEN(result->u.constant) == 0) { + Z_STRSIZE(result->u.constant) == 0) { /* namespace\ */ if (Z_TYPE(CG(current_namespace)) != IS_UNDEF) { znode tmp; @@ -7532,10 +7532,10 @@ void zend_do_begin_namespace(znode *name, zend_bool with_bracket TSRMLS_DC) /* { } if (name) { - lcname = zend_str_tolower_dup(Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)); - if (((Z_STRLEN(name->u.constant) == sizeof("self")-1) && + lcname = zend_str_tolower_dup(Z_STRVAL(name->u.constant), Z_STRSIZE(name->u.constant)); + if (((Z_STRSIZE(name->u.constant) == sizeof("self")-1) && !memcmp(lcname, "self", sizeof("self")-1)) || - ((Z_STRLEN(name->u.constant) == sizeof("parent")-1) && + ((Z_STRSIZE(name->u.constant) == sizeof("parent")-1) && !memcmp(lcname, "parent", sizeof("parent")-1))) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use '%s' as namespace name", Z_STRVAL(name->u.constant)); } @@ -7598,7 +7598,7 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{ /* The form "use A\B" is eqivalent to "use A\B as B". So we extract the last part of compound name to use as a new_name */ name = &tmp; - p = zend_memrchr(Z_STRVAL(ns), '\\', Z_STRLEN(ns)); + p = zend_memrchr(Z_STRVAL(ns), '\\', Z_STRSIZE(ns)); if (p) { ZVAL_STRING(name, p+1); } else { @@ -7607,28 +7607,28 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{ } } - lcname = STR_ALLOC(Z_STRLEN_P(name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(name), Z_STRLEN_P(name)); + lcname = STR_ALLOC(Z_STRSIZE_P(name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(name), Z_STRSIZE_P(name)); - if (((Z_STRLEN_P(name) == sizeof("self")-1) && + if (((Z_STRSIZE_P(name) == sizeof("self")-1) && !memcmp(lcname->val, "self", sizeof("self")-1)) || - ((Z_STRLEN_P(name) == sizeof("parent")-1) && + ((Z_STRSIZE_P(name) == sizeof("parent")-1) && !memcmp(lcname->val, "parent", sizeof("parent")-1))) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as %s because '%s' is a special class name", Z_STRVAL(ns), Z_STRVAL_P(name), Z_STRVAL_P(name)); } if (Z_TYPE(CG(current_namespace)) != IS_UNDEF) { /* Prefix import name with current namespace name to avoid conflicts with classes */ - zend_string *c_ns_name = STR_ALLOC(Z_STRLEN(CG(current_namespace)) + 1 + Z_STRLEN_P(name), 0); + zend_string *c_ns_name = STR_ALLOC(Z_STRSIZE(CG(current_namespace)) + 1 + Z_STRSIZE_P(name), 0); - zend_str_tolower_copy(c_ns_name->val, Z_STRVAL(CG(current_namespace)), Z_STRLEN(CG(current_namespace))); - c_ns_name->val[Z_STRLEN(CG(current_namespace))] = '\\'; - memcpy(c_ns_name->val+Z_STRLEN(CG(current_namespace))+1, lcname->val, Z_STRLEN_P(name)+1); + zend_str_tolower_copy(c_ns_name->val, Z_STRVAL(CG(current_namespace)), Z_STRSIZE(CG(current_namespace))); + c_ns_name->val[Z_STRSIZE(CG(current_namespace))] = '\\'; + memcpy(c_ns_name->val+Z_STRSIZE(CG(current_namespace))+1, lcname->val, Z_STRSIZE_P(name)+1); if (zend_hash_exists(CG(class_table), c_ns_name)) { - char *tmp2 = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRLEN(ns)); + char *tmp2 = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRSIZE(ns)); - if (Z_STRLEN(ns) != Z_STRLEN(CG(current_namespace)) + 1 + Z_STRLEN_P(name) || - memcmp(tmp2, c_ns_name->val, Z_STRLEN(ns))) { + if (Z_STRSIZE(ns) != Z_STRSIZE(CG(current_namespace)) + 1 + Z_STRSIZE_P(name) || + memcmp(tmp2, c_ns_name->val, Z_STRSIZE(ns))) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL(ns), Z_STRVAL_P(name)); } efree(tmp2); @@ -7637,10 +7637,10 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{ } else if ((ce = zend_hash_find_ptr(CG(class_table), lcname)) != NULL && ce->type == ZEND_USER_CLASS && ce->info.user.filename == CG(compiled_filename)) { - char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRLEN(ns)); + char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRSIZE(ns)); - if (Z_STRLEN(ns) != Z_STRLEN_P(name) || - memcmp(c_tmp, lcname->val, Z_STRLEN(ns))) { + if (Z_STRSIZE(ns) != Z_STRSIZE_P(name) || + memcmp(c_tmp, lcname->val, Z_STRSIZE(ns))) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL(ns), Z_STRVAL_P(name)); } efree(c_tmp); @@ -7675,7 +7675,7 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int i /* The form "use A\B" is eqivalent to "use A\B as B". So we extract the last part of compound name to use as a new_name */ name = &tmp; - p = zend_memrchr(Z_STRVAL(ns), '\\', Z_STRLEN(ns)); + p = zend_memrchr(Z_STRVAL(ns), '\\', Z_STRSIZE(ns)); if (p) { ZVAL_STRING(name, p+1); } else { @@ -7687,22 +7687,22 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int i if (case_sensitive) { lookup_name = STR_COPY(Z_STR_P(name)); } else { - lookup_name = STR_ALLOC(Z_STRLEN_P(name), 0); - zend_str_tolower_copy(lookup_name->val, Z_STRVAL_P(name), Z_STRLEN_P(name)); + lookup_name = STR_ALLOC(Z_STRSIZE_P(name), 0); + zend_str_tolower_copy(lookup_name->val, Z_STRVAL_P(name), Z_STRSIZE_P(name)); } if (Z_TYPE(CG(current_namespace)) != IS_UNDEF) { /* Prefix import name with current namespace name to avoid conflicts with functions/consts */ - zend_string *c_ns_name = STR_ALLOC(Z_STRLEN(CG(current_namespace)) + 1 + Z_STRLEN_P(name), 0); + zend_string *c_ns_name = STR_ALLOC(Z_STRSIZE(CG(current_namespace)) + 1 + Z_STRSIZE_P(name), 0); - zend_str_tolower_copy(c_ns_name->val, Z_STRVAL(CG(current_namespace)), Z_STRLEN(CG(current_namespace))); - c_ns_name->val[Z_STRLEN(CG(current_namespace))] = '\\'; - memcpy(c_ns_name->val+Z_STRLEN(CG(current_namespace))+1, lookup_name, Z_STRLEN_P(name)+1); + zend_str_tolower_copy(c_ns_name->val, Z_STRVAL(CG(current_namespace)), Z_STRSIZE(CG(current_namespace))); + c_ns_name->val[Z_STRSIZE(CG(current_namespace))] = '\\'; + memcpy(c_ns_name->val+Z_STRSIZE(CG(current_namespace))+1, lookup_name, Z_STRSIZE_P(name)+1); if (zend_hash_exists(lookup_table, c_ns_name)) { - char *tmp2 = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRLEN(ns)); + char *tmp2 = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRSIZE(ns)); - if (Z_STRLEN(ns) != Z_STRLEN(CG(current_namespace)) + 1 + Z_STRLEN_P(name) || - memcmp(tmp2, c_ns_name->val, Z_STRLEN(ns))) { + if (Z_STRSIZE(ns) != Z_STRSIZE(CG(current_namespace)) + 1 + Z_STRSIZE_P(name) || + memcmp(tmp2, c_ns_name->val, Z_STRSIZE(ns))) { zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in use", is_function ? "function" : "const", Z_STRVAL(ns), Z_STRVAL_P(name)); } efree(tmp2); @@ -7712,10 +7712,10 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int i zend_function *function; if ((function = zend_hash_find_ptr(lookup_table, lookup_name)) != NULL && function->type == ZEND_USER_FUNCTION && strcmp(function->op_array.filename->val, CG(compiled_filename)->val) == 0) { - char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRLEN(ns)); + char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRSIZE(ns)); - if (Z_STRLEN(ns) != Z_STRLEN_P(name) || - memcmp(c_tmp, lookup_name->val, Z_STRLEN(ns))) { + if (Z_STRSIZE(ns) != Z_STRSIZE_P(name) || + memcmp(c_tmp, lookup_name->val, Z_STRSIZE(ns))) { zend_error(E_COMPILE_ERROR, "Cannot use function %s as %s because the name is already in use", Z_STRVAL(ns), Z_STRVAL_P(name)); } efree(c_tmp); @@ -7724,10 +7724,10 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int i zend_string *filename; if ((filename = zend_hash_find_ptr(lookup_table, lookup_name)) != NULL && strcmp(filename->val, CG(compiled_filename)->val) == 0) { - char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRLEN(ns)); + char *c_tmp = zend_str_tolower_dup(Z_STRVAL(ns), Z_STRSIZE(ns)); - if (Z_STRLEN(ns) != Z_STRLEN_P(name) || - memcmp(c_tmp, lookup_name->val, Z_STRLEN(ns))) { + if (Z_STRSIZE(ns) != Z_STRSIZE_P(name) || + memcmp(c_tmp, lookup_name->val, Z_STRSIZE(ns))) { zend_error(E_COMPILE_ERROR, "Cannot use const %s as %s because the name is already in use", Z_STRVAL(ns), Z_STRVAL_P(name)); } efree(c_tmp); @@ -7781,8 +7781,8 @@ void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */ znode tmp; tmp.op_type = IS_CONST; - ZVAL_NEW_STR(&tmp.u.constant, STR_ALLOC(Z_STRLEN(CG(current_namespace)), 0)); - zend_str_tolower_copy(Z_STRVAL(tmp.u.constant), Z_STRVAL(CG(current_namespace)), Z_STRLEN(CG(current_namespace))); + ZVAL_NEW_STR(&tmp.u.constant, STR_ALLOC(Z_STRSIZE(CG(current_namespace)), 0)); + zend_str_tolower_copy(Z_STRVAL(tmp.u.constant), Z_STRVAL(CG(current_namespace)), Z_STRSIZE(CG(current_namespace))); zend_do_build_namespace_name(&tmp, &tmp, name TSRMLS_CC); *name = tmp; } @@ -7791,10 +7791,10 @@ void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */ if (CG(current_import_const) && (ns_name = zend_hash_find(CG(current_import_const), Z_STR(name->u.constant))) != NULL) { - char *tmp = estrndup(Z_STRVAL_P(ns_name), Z_STRLEN_P(ns_name)); + char *tmp = estrndup(Z_STRVAL_P(ns_name), Z_STRSIZE_P(ns_name)); - if (Z_STRLEN_P(ns_name) != Z_STRLEN(name->u.constant) || - memcmp(tmp, Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant))) { + if (Z_STRSIZE_P(ns_name) != Z_STRSIZE(name->u.constant) || + memcmp(tmp, Z_STRVAL(name->u.constant), Z_STRSIZE(name->u.constant))) { zend_error(E_COMPILE_ERROR, "Cannot declare const %s because the name is already in use", Z_STRVAL(name->u.constant)); } efree(tmp); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index fa333545f4..1e089478ab 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -40,7 +40,7 @@ #define INC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count++); } #define DEC_BPC(op_array) if (op_array->fn_flags & ZEND_ACC_INTERACTIVE) { (CG(context).backpatch_count--); } #define HANDLE_INTERACTIVE() if (CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE) { execute_new_code(TSRMLS_C); } -#define DO_TICKS() if (Z_LVAL(CG(declarables).ticks)) { zend_do_ticks(TSRMLS_C); } +#define DO_TICKS() if (Z_IVAL(CG(declarables).ticks)) { zend_do_ticks(TSRMLS_C); } #define RESET_DOC_COMMENT() \ { \ @@ -67,7 +67,7 @@ typedef union _znode_op { zend_uint constant; zend_uint var; zend_uint num; - zend_ulong hash; + zend_uint_t hash; zend_uint opline_num; /* Needs to be signed */ zend_op *jmp_addr; zval *zv; @@ -100,7 +100,7 @@ struct _zend_op { znode_op op1; znode_op op2; znode_op result; - ulong extended_value; + zend_uint_t extended_value; uint lineno; zend_uchar opcode; zend_uchar op1_type; @@ -128,10 +128,14 @@ typedef struct _zend_try_catch_element { zend_uint finally_end; } zend_try_catch_element; -#if SIZEOF_LONG == 8 -#define THIS_HASHVAL 6385726429UL +#if SIZEOF_ZEND_INT == 8 +# ifdef _WIN32 +# define THIS_HASHVAL 210728972157Ui64 +# else +# define THIS_HASHVAL 210728972157ULL +# endif #else -#define THIS_HASHVAL 2090759133UL +#define THIS_HASHVAL 275574653UL #endif /* method flags (types) */ @@ -210,7 +214,7 @@ char *zend_visibility_string(zend_uint fn_flags); typedef struct _zend_property_info { zend_uint flags; zend_string *name; - ulong h; + zend_uint_t h; int offset; zend_string *doc_comment; zend_class_entry *ce; diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 64ea7060fa..693c65676d 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -113,26 +113,26 @@ int zend_startup_constants(TSRMLS_D) void zend_register_standard_constants(TSRMLS_D) { - REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT | CONST_CS); - - REGISTER_MAIN_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS); - - REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_PROVIDE_OBJECT", DEBUG_BACKTRACE_PROVIDE_OBJECT, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT | CONST_CS); + + REGISTER_MAIN_INT_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS); + + REGISTER_MAIN_INT_CONSTANT("DEBUG_BACKTRACE_PROVIDE_OBJECT", DEBUG_BACKTRACE_PROVIDE_OBJECT, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT | CONST_CS); /* true/false constants */ { REGISTER_MAIN_BOOL_CONSTANT("TRUE", 1, CONST_PERSISTENT | CONST_CT_SUBST); @@ -183,11 +183,11 @@ ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_ zend_register_constant(&c TSRMLS_CC); } -ZEND_API void zend_register_long_constant(const char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC) +ZEND_API void zend_register_int_constant(const char *name, uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC) { zend_constant c; - ZVAL_LONG(&c.value, lval); + ZVAL_INT(&c.value, lval); c.flags = flags; c.name = STR_INIT(name, name_len, flags & CONST_PERSISTENT); c.module_number = module_number; @@ -465,12 +465,12 @@ zend_constant *zend_quick_get_constant(const zval *key, ulong flags TSRMLS_DC) (c->flags & CONST_CS) != 0) { key--; - c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key) TSRMLS_CC); + c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRSIZE_P(key) TSRMLS_CC); } } } else { key--; - c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRLEN_P(key) TSRMLS_CC); + c = zend_get_special_constant(Z_STRVAL_P(key), Z_STRSIZE_P(key) TSRMLS_CC); } } } diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 09a5dac63d..11a12cbfa7 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -39,21 +39,21 @@ typedef struct _zend_constant { #define REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), module_number TSRMLS_CC) #define REGISTER_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number TSRMLS_CC) -#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number TSRMLS_CC) +#define REGISTER_INT_CONSTANT(name, lval, flags) zend_register_int_constant((name), sizeof(name)-1, (lval), (flags), module_number TSRMLS_CC) #define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number TSRMLS_CC) #define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number TSRMLS_CC) #define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number TSRMLS_CC) #define REGISTER_NS_NULL_CONSTANT(ns, name, flags) zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (flags), module_number TSRMLS_CC) #define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags) zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (bval), (flags), module_number TSRMLS_CC) -#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (lval), (flags), module_number TSRMLS_CC) +#define REGISTER_NS_INT_CONSTANT(ns, name, lval, flags) zend_register_int_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (lval), (flags), module_number TSRMLS_CC) #define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (dval), (flags), module_number TSRMLS_CC) #define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (flags), module_number TSRMLS_CC) #define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (len), (flags), module_number TSRMLS_CC) #define REGISTER_MAIN_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0 TSRMLS_CC) -#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0 TSRMLS_CC) +#define REGISTER_MAIN_INT_CONSTANT(name, lval, flags) zend_register_int_constant((name), sizeof(name)-1, (lval), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0 TSRMLS_CC) #define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0 TSRMLS_CC) @@ -70,7 +70,7 @@ ZEND_API zval *zend_get_constant_str(const char *name, uint name_len TSRMLS_DC); ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, ulong flags TSRMLS_DC); ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_bool bval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_null_constant(const char *name, uint name_len, int flags, int module_number TSRMLS_DC); -ZEND_API void zend_register_long_constant(const char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC); +ZEND_API void zend_register_int_constant(const char *name, uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_double_constant(const char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_string_constant(const char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_stringl_constant(const char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 754927b577..401a85f870 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -163,7 +163,7 @@ static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, Z_SET_REFCOUNT(trace, 0); zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); - zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); + zend_update_property_int(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); zend_update_property(default_exception_ce, &obj, "trace", sizeof("trace")-1, &trace TSRMLS_CC); return object; @@ -211,7 +211,7 @@ ZEND_METHOD(exception, __construct) } if (code) { - zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); + zend_update_property_int(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); } if (previous) { @@ -240,21 +240,21 @@ ZEND_METHOD(error_exception, __construct) } if (code) { - zend_update_property_long(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); + zend_update_property_int(default_exception_ce, object, "code", sizeof("code")-1, code TSRMLS_CC); } if (previous) { zend_update_property(default_exception_ce, object, "previous", sizeof("previous")-1, previous TSRMLS_CC); } - zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC); + zend_update_property_int(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC); if (argc >= 4) { zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC); if (argc < 5) { lineno = 0; /* invalidate lineno */ } - zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); + zend_update_property_int(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); } } /* }}} */ @@ -354,7 +354,7 @@ ZEND_METHOD(error_exception, getSeverity) zend_error(E_WARNING, "Value for %s is no string", key); \ TRACE_APPEND_STR("[unknown]"); \ } else { \ - TRACE_APPEND_STRL(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp)); \ + TRACE_APPEND_STRL(Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp)); \ } \ } \ } while (0) @@ -386,12 +386,12 @@ static void _build_trace_args(zval *arg, zend_string **str_ptr TSRMLS_DC) /* {{{ case IS_STRING: { int l_added; TRACE_APPEND_CHR('\''); - if (Z_STRLEN_P(arg) > 15) { + if (Z_STRSIZE_P(arg) > 15) { TRACE_APPEND_STRL(Z_STRVAL_P(arg), 15); TRACE_APPEND_STR("...', "); l_added = 15 + 6 + 1; /* +1 because of while (--l_added) */ } else { - l_added = Z_STRLEN_P(arg); + l_added = Z_STRSIZE_P(arg); TRACE_APPEND_STRL(Z_STRVAL_P(arg), l_added); TRACE_APPEND_STR("', "); l_added += 3 + 1; @@ -460,16 +460,16 @@ static void _build_trace_args(zval *arg, zend_string **str_ptr TSRMLS_DC) /* {{{ break; case IS_RESOURCE: { long lval = Z_RES_HANDLE_P(arg); - char s_tmp[MAX_LENGTH_OF_LONG + 1]; + char s_tmp[MAX_LENGTH_OF_ZEND_INT + 1]; int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */ TRACE_APPEND_STR("Resource id #"); TRACE_APPEND_STRL(s_tmp, l_tmp); TRACE_APPEND_STR(", "); break; } - case IS_LONG: { - long lval = Z_LVAL_P(arg); - char s_tmp[MAX_LENGTH_OF_LONG + 1]; + case IS_INT: { + long lval = Z_IVAL_P(arg); + char s_tmp[MAX_LENGTH_OF_ZEND_INT + 1]; int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */ TRACE_APPEND_STRL(s_tmp, l_tmp); TRACE_APPEND_STR(", "); @@ -524,7 +524,7 @@ static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr, } ht = Z_ARRVAL_P(frame); - s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1); + s_tmp = emalloc(1 + MAX_LENGTH_OF_ZEND_INT + 1 + 1); len = sprintf(s_tmp, "#%d ", (*num)++); TRACE_APPEND_STRL(s_tmp, len); efree(s_tmp); @@ -536,8 +536,8 @@ static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr, } else{ tmp = zend_hash_str_find(ht, "line", sizeof("line")-1); if (tmp) { - if (Z_TYPE_P(tmp) == IS_LONG) { - line = Z_LVAL_P(tmp); + if (Z_TYPE_P(tmp) == IS_INT) { + line = Z_IVAL_P(tmp); } else { zend_error(E_WARNING, "Line is no long"); line = 0; @@ -545,7 +545,7 @@ static void _build_trace_string(zval *frame, ulong index, zend_string **str_ptr, } else { line = 0; } - s_tmp = emalloc(Z_STRLEN_P(file) + MAX_LENGTH_OF_LONG + 4 + 1); + s_tmp = emalloc(Z_STRSIZE_P(file) + MAX_LENGTH_OF_ZEND_INT + 4 + 1); len = sprintf(s_tmp, "%s(%ld): ", Z_STRVAL_P(file), line); TRACE_APPEND_STRL(s_tmp, len); efree(s_tmp); @@ -587,7 +587,7 @@ ZEND_METHOD(exception, getTraceAsString) ulong index; zend_string *str, *key; int num = 0, len; - char s_tmp[MAX_LENGTH_OF_LONG + 7 + 1 + 1]; + char s_tmp[MAX_LENGTH_OF_ZEND_INT + 7 + 1 + 1]; DEFAULT_0_PARAMS; @@ -667,7 +667,7 @@ ZEND_METHOD(exception, __toString) convert_to_string(&message); convert_to_string(&file); - convert_to_long(&line); + convert_to_int(&line); fci.size = sizeof(fci); fci.function_table = &Z_OBJCE_P(exception)->function_table; @@ -686,15 +686,15 @@ ZEND_METHOD(exception, __toString) ZVAL_UNDEF(&trace); } - if (Z_STRLEN(message) > 0) { + if (Z_STRSIZE(message) > 0) { str = zend_strpprintf(0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s%s%s", - Z_OBJCE_P(exception)->name->val, Z_STRVAL(message), Z_STRVAL(file), Z_LVAL(line), - (Z_TYPE(trace) == IS_STRING && Z_STRLEN(trace)) ? Z_STRVAL(trace) : "#0 {main}\n", + Z_OBJCE_P(exception)->name->val, Z_STRVAL(message), Z_STRVAL(file), Z_IVAL(line), + (Z_TYPE(trace) == IS_STRING && Z_STRSIZE(trace)) ? Z_STRVAL(trace) : "#0 {main}\n", prev_str->len ? "\n\nNext " : "", prev_str->val); } else { str = zend_strpprintf(0, "exception '%s' in %s:%ld\nStack trace:\n%s%s%s", - Z_OBJCE_P(exception)->name->val, Z_STRVAL(file), Z_LVAL(line), - (Z_TYPE(trace) == IS_STRING && Z_STRLEN(trace)) ? Z_STRVAL(trace) : "#0 {main}\n", + Z_OBJCE_P(exception)->name->val, Z_STRVAL(file), Z_IVAL(line), + (Z_TYPE(trace) == IS_STRING && Z_STRSIZE(trace)) ? Z_STRVAL(trace) : "#0 {main}\n", prev_str->len ? "\n\nNext " : "", prev_str->val); } STR_RELEASE(prev_str); @@ -775,7 +775,7 @@ void zend_register_default_exception(TSRMLS_D) /* {{{ */ zend_declare_property_string(default_exception_ce, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(default_exception_ce, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC); - zend_declare_property_long(default_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_int(default_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, "line", sizeof("line")-1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(default_exception_ce, "trace", sizeof("trace")-1, ZEND_ACC_PRIVATE TSRMLS_CC); @@ -784,7 +784,7 @@ void zend_register_default_exception(TSRMLS_D) /* {{{ */ INIT_CLASS_ENTRY(ce, "ErrorException", error_exception_functions); error_exception_ce = zend_register_internal_class_ex(&ce, default_exception_ce TSRMLS_CC); error_exception_ce->create_object = zend_error_exception_new; - zend_declare_property_long(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_int(error_exception_ce, "severity", sizeof("severity")-1, E_ERROR, ZEND_ACC_PROTECTED TSRMLS_CC); } /* }}} */ @@ -819,7 +819,7 @@ ZEND_API zend_object *zend_throw_exception(zend_class_entry *exception_ce, const zend_update_property_string(default_exception_ce, &ex, "message", sizeof("message")-1, message TSRMLS_CC); } if (code) { - zend_update_property_long(default_exception_ce, &ex, "code", sizeof("code")-1, code TSRMLS_CC); + zend_update_property_int(default_exception_ce, &ex, "code", sizeof("code")-1, code TSRMLS_CC); } zend_throw_exception_internal(&ex TSRMLS_CC); @@ -847,7 +847,7 @@ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, zval ex; zend_object *obj = zend_throw_exception(exception_ce, message, code TSRMLS_CC); ZVAL_OBJ(&ex, obj); - zend_update_property_long(default_exception_ce, &ex, "severity", sizeof("severity")-1, severity TSRMLS_CC); + zend_update_property_int(default_exception_ce, &ex, "severity", sizeof("severity")-1, severity TSRMLS_CC); return obj; } /* }}} */ @@ -895,13 +895,13 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* { line = zend_read_property(default_exception_ce, &zv, "line", sizeof("line")-1, 1 TSRMLS_CC); convert_to_string(file); - file = (Z_STRLEN_P(file) > 0) ? file : NULL; - line = (Z_TYPE_P(line) == IS_LONG) ? line : NULL; + file = (Z_STRSIZE_P(file) > 0) ? file : NULL; + line = (Z_TYPE_P(line) == IS_INT) ? line : NULL; } else { file = NULL; line = NULL; } - zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE(zv)->name->val, ce_exception->name->val); + zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_IVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE(zv)->name->val, ce_exception->name->val); } str = zend_read_property(default_exception_ce, &exception, "string", sizeof("string")-1, 1 TSRMLS_CC); @@ -910,9 +910,9 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity TSRMLS_DC) /* { convert_to_string(str); convert_to_string(file); - convert_to_long(line); + convert_to_int(line); - zend_error_va(severity, (Z_STRLEN_P(file) > 0) ? Z_STRVAL_P(file) : NULL, Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str)); + zend_error_va(severity, (Z_STRSIZE_P(file) > 0) ? Z_STRVAL_P(file) : NULL, Z_IVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str)); } else { zend_error(severity, "Uncaught exception '%s'", ce_exception->name->val); } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index f3e97d71d0..6bf0cdf984 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -516,7 +516,7 @@ static inline zval* make_real_object(zval *object_ptr TSRMLS_DC) if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { if (Z_TYPE_P(object) == IS_NULL || Z_TYPE_P(object) == IS_FALSE - || (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) { + || (Z_TYPE_P(object) == IS_STRING && Z_STRSIZE_P(object) == 0)) { zval_ptr_dtor_nogc(object); object_init(object); zend_error(E_WARNING, "Creating default object from empty value"); @@ -525,7 +525,7 @@ static inline zval* make_real_object(zval *object_ptr TSRMLS_DC) return object; } -ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC) +ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, zend_uint_t fetch_type, char **class_name, zend_class_entry **pce TSRMLS_DC) { zend_string *key; ALLOCA_FLAG(use_heap); @@ -574,7 +574,7 @@ ZEND_API void zend_verify_arg_error(int error_type, const zend_function *zf, zen } } -static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg, ulong fetch_type TSRMLS_DC) +static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg, zend_uint_t fetch_type TSRMLS_DC) { zend_arg_info *cur_arg_info; char *need_msg; @@ -623,7 +623,7 @@ static void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg } } -static inline int zend_verify_missing_arg_type(zend_function *zf, zend_uint arg_num, ulong fetch_type TSRMLS_DC) +static inline int zend_verify_missing_arg_type(zend_function *zf, zend_uint arg_num, zend_uint_t fetch_type TSRMLS_DC) { zend_arg_info *cur_arg_info; char *need_msg; @@ -695,7 +695,7 @@ static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *p } if (Z_TYPE_P(object) == IS_NULL || Z_TYPE_P(object) == IS_FALSE || - (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) { + (Z_TYPE_P(object) == IS_STRING && Z_STRSIZE_P(object) == 0)) { zend_object *obj; zval_ptr_dtor(object); @@ -781,14 +781,14 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu } old_str = Z_STR_P(str); - if (offset >= Z_STRLEN_P(str)) { - int old_len = Z_STRLEN_P(str); + if (offset >= Z_STRSIZE_P(str)) { + int old_len = Z_STRSIZE_P(str); Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), offset + 1, 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len); Z_STRVAL_P(str)[offset+1] = 0; } else if (IS_INTERNED(Z_STR_P(str))) { - Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0); + Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRSIZE_P(str), 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; } @@ -1015,23 +1015,23 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht { zval *retval; zend_string *offset_key; - ulong hval; + zend_uint_t hval; - if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { - hval = Z_LVAL_P(dim); + if (EXPECTED(Z_TYPE_P(dim) == IS_INT)) { + hval = Z_IVAL_P(dim); num_index: retval = zend_hash_index_find(ht, hval); if (retval == NULL) { switch (type) { case BP_VAR_R: - zend_error(E_NOTICE,"Undefined offset: %ld", hval); + zend_error(E_NOTICE,"Undefined offset: " ZEND_UINT_FMT, hval); /* break missing intentionally */ case BP_VAR_UNSET: case BP_VAR_IS: retval = &EG(uninitialized_zval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined offset: %ld", hval); + zend_error(E_NOTICE,"Undefined offset: " ZEND_UINT_FMT, hval); /* break missing intentionally */ case BP_VAR_W: retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); @@ -1092,7 +1092,7 @@ str_index: offset_key = STR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_ival(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); @@ -1139,9 +1139,9 @@ fetch_from_array: ZVAL_INDIRECT(result, retval); } } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { - long offset; + zend_int_t offset; - if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRLEN_P(container) == 0)) { + if (type != BP_VAR_UNSET && UNEXPECTED(Z_STRSIZE_P(container) == 0)) { zval_dtor(container); convert_to_array: ZVAL_NEW_ARR(container); @@ -1156,10 +1156,10 @@ convert_to_array: SEPARATE_STRING(container); } - if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(dim) != IS_INT)) { switch(Z_TYPE_P(dim)) { case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_INT == is_numeric_string(Z_STRVAL_P(dim), Z_STRSIZE_P(dim), NULL, NULL, -1)) { break; } if (type != BP_VAR_UNSET) { @@ -1179,7 +1179,7 @@ convert_to_array: offset = zval_get_long(dim); } else { - offset = Z_LVAL_P(dim); + offset = Z_IVAL_P(dim); } if (!IS_INTERNED(Z_STR_P(container))) STR_ADDREF(Z_STR_P(container)); @@ -1279,13 +1279,13 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC); ZVAL_COPY(result, retval); } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { - long offset; + zend_int_t offset; - if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(dim) != IS_INT)) { switch(Z_TYPE_P(dim)) { - /* case IS_LONG: */ + /* case IS_INT: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_INT == is_numeric_string(Z_STRVAL_P(dim), Z_STRSIZE_P(dim), NULL, NULL, -1)) { break; } if (type != BP_VAR_IS) { @@ -1307,10 +1307,10 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z offset = zval_get_long(dim); } else { - offset = Z_LVAL_P(dim); + offset = Z_IVAL_P(dim); } - if (UNEXPECTED(offset < 0) || UNEXPECTED(Z_STRLEN_P(container) <= offset)) { + if (UNEXPECTED(offset < 0) || UNEXPECTED(Z_STRSIZE_P(container) <= offset)) { if (type != BP_VAR_IS) { zend_error(E_NOTICE, "Uninitialized string offset: %ld", offset); } @@ -1375,7 +1375,7 @@ static void zend_fetch_property_address(zval *result, zval *container_ptr, zval if (type != BP_VAR_UNSET && ((Z_TYPE_P(container) == IS_NULL || Z_TYPE_P(container) == IS_FALSE || - (Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0)))) { + (Z_TYPE_P(container) == IS_STRING && Z_STRSIZE_P(container)==0)))) { zval_ptr_dtor_nogc(container); object_init(container); } else { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index cb7ca70ef3..2f7e107cef 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -87,8 +87,8 @@ again: case IS_TRUE: result = 1; break; - case IS_LONG: - result = (Z_LVAL_P(op)?1:0); + case IS_INT: + result = (Z_IVAL_P(op)?1:0); break; case IS_RESOURCE: result = (Z_RES_HANDLE_P(op)?1:0); @@ -97,8 +97,8 @@ again: result = (Z_DVAL_P(op) ? 1 : 0); break; case IS_STRING: - if (Z_STRLEN_P(op) == 0 - || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) { + if (Z_STRSIZE_P(op) == 0 + || (Z_STRSIZE_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) { result = 0; } else { result = 1; @@ -279,7 +279,7 @@ ZEND_API const char *zend_get_executed_filename(TSRMLS_D); ZEND_API uint zend_get_executed_lineno(TSRMLS_D); ZEND_API zend_bool zend_is_executing(TSRMLS_D); -ZEND_API void zend_set_timeout(long seconds, int reset_signals); +ZEND_API void zend_set_timeout(zend_int_t seconds, int reset_signals); ZEND_API void zend_unset_timeout(TSRMLS_D); ZEND_API void zend_timeout(int dummy); ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type TSRMLS_DC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 8af877215c..1b33903723 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -531,11 +531,11 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas if (!const_value) { char *actual = Z_STRVAL_P(p); - if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) { + if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRSIZE_P(p)))) { int len; zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p)); - len = Z_STRLEN_P(p) - ((colon - Z_STRVAL_P(p)) + 1); + len = Z_STRSIZE_P(p) - ((colon - Z_STRVAL_P(p)) + 1); if (inline_change) { zend_string *tmp = STR_INIT(colon + 1, len, 0); STR_RELEASE(Z_STR_P(p)); @@ -547,7 +547,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas } else { zend_string *save = Z_STR_P(p); char *slash; - int actual_len = Z_STRLEN_P(p); + int actual_len = Z_STRSIZE_P(p); if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) && (slash = (char *)zend_memrchr(actual, '\\', actual_len))) { actual = slash + 1; actual_len -= (actual - Z_STRVAL_P(p)); @@ -559,8 +559,8 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas } if (actual[0] == '\\') { if (inline_change) { - memmove(Z_STRVAL_P(p), Z_STRVAL_P(p)+1, Z_STRLEN_P(p)); - --Z_STRLEN_P(p); + memmove(Z_STRVAL_P(p), Z_STRVAL_P(p)+1, Z_STRSIZE_P(p)); + --Z_STRSIZE_P(p); } else { ++actual; } @@ -1069,8 +1069,8 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s ZVAL_NEW_STR(&pv, STR_ALLOC(str_len + sizeof("return ;")-1, 1)); memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1); memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len); - Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';'; - Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; + Z_STRVAL(pv)[Z_STRSIZE(pv) - 1] = ';'; + Z_STRVAL(pv)[Z_STRSIZE(pv)] = '\0'; } else { ZVAL_STRINGL(&pv, str, str_len); } @@ -1183,7 +1183,7 @@ void execute_new_code(TSRMLS_D) /* {{{ */ } switch (opline->opcode) { case ZEND_GOTO: - if (Z_TYPE_P(opline->op2.zv) != IS_LONG) { + if (Z_TYPE_P(opline->op2.zv) != IS_INT) { zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC); } /* break omitted intentionally */ @@ -1360,7 +1360,7 @@ void zend_shutdown_timeout_thread(void) /* {{{ */ #define SIGPROF 27 #endif -void zend_set_timeout(long seconds, int reset_signals) /* {{{ */ +void zend_set_timeout(zend_int_t seconds, int reset_signals) /* {{{ */ { TSRMLS_FETCH(); diff --git a/Zend/zend_generators.h b/Zend/zend_generators.h index 5d1264cc4f..ba6fe1b8ca 100644 --- a/Zend/zend_generators.h +++ b/Zend/zend_generators.h @@ -43,7 +43,7 @@ typedef struct _zend_generator { /* Variable to put sent value into */ zval *send_target; /* Largest used integer key for auto-incrementing keys */ - long largest_used_integer_key; + zend_int_t largest_used_integer_key; /* ZEND_GENERATOR_* flags */ zend_uchar flags; diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 082e733844..81ddfb9396 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -112,7 +112,7 @@ struct _zend_compiler_globals { zend_llist open_files; - long catch_begin; + zend_int_t catch_begin; struct _zend_ini_parser_param *ini_parser_param; @@ -188,7 +188,7 @@ struct _zend_executor_globals { zval This; - long precision; + zend_int_t precision; int ticks_count; @@ -220,7 +220,7 @@ struct _zend_executor_globals { zend_class_entry *exception_class; /* timeout support */ - int timeout_seconds; + zend_int_t timeout_seconds; int lambda_count; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 78b38f7ea2..7d926493be 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -183,7 +183,7 @@ ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProt static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zend_string *key) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -205,7 +205,7 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zen return NULL; } -static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, int len, ulong h) +static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, int len, zend_uint_t h) { uint nIndex; uint idx; @@ -227,7 +227,7 @@ static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, return NULL; } -static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, ulong h) +static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, zend_uint_t h) { uint nIndex; uint idx; @@ -248,7 +248,7 @@ static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *h static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_string *key, zval *pData, int flag ZEND_FILE_LINE_DC) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -375,7 +375,7 @@ ZEND_API zval *_zend_hash_str_add_new(HashTable *ht, const char *str, int len, z return ret; } -ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, ulong h) +ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, zend_uint_t h) { zval dummy; @@ -402,7 +402,7 @@ ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *str, i return zend_hash_str_add(ht, str, len, &dummy); } -static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC) +static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTable *ht, zend_uint_t h, zval *pData, int flag ZEND_FILE_LINE_DC) { uint nIndex; uint idx; @@ -430,8 +430,8 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab ht->pDestructor(&p->val); } ZVAL_COPY_VALUE(&p->val, pData); - if ((long)h >= (long)ht->nNextFreeElement) { - ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX; + if ((zend_int_t)h >= (zend_int_t)ht->nNextFreeElement) { + ht->nNextFreeElement = h < ZEND_INT_MAX ? h + 1 : ZEND_INT_MAX; } return &p->val; } else { /* we have to keep the order :( */ @@ -460,8 +460,8 @@ static zend_always_inline zval *_zend_hash_index_update_or_next_insert_i(HashTab if (ht->nInternalPointer == INVALID_IDX) { ht->nInternalPointer = h; } - if ((long)h >= (long)ht->nNextFreeElement) { - ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX; + if ((zend_int_t)h >= (zend_int_t)ht->nNextFreeElement) { + ht->nNextFreeElement = h < ZEND_INT_MAX ? h + 1 : ZEND_INT_MAX; } p->h = h; p->key = NULL; @@ -490,7 +490,7 @@ convert_to_hash: } ZVAL_COPY_VALUE(&p->val, pData); HANDLE_UNBLOCK_INTERRUPTIONS(); - if ((long)h >= (long)ht->nNextFreeElement) { + if ((zend_int_t)h >= (zend_int_t)ht->nNextFreeElement) { ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX; } return &p->val; @@ -505,8 +505,8 @@ convert_to_hash: if (ht->nInternalPointer == INVALID_IDX) { ht->nInternalPointer = idx; } - if ((long)h >= (long)ht->nNextFreeElement) { - ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX; + if ((zend_int_t)h >= (zend_int_t)ht->nNextFreeElement) { + ht->nNextFreeElement = h < ZEND_INT_MAX ? h + 1 : ZEND_INT_MAX; } p = ht->arData + idx; p->h = h; @@ -520,22 +520,22 @@ convert_to_hash: return &p->val; } -ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, zval *pData, int flag ZEND_FILE_LINE_DC) { return _zend_hash_index_update_or_next_insert_i(ht, h, pData, flag ZEND_FILE_LINE_RELAY_CC); } -ZEND_API zval *_zend_hash_index_add(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC) { return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD ZEND_FILE_LINE_RELAY_CC); } -ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC) { return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_ADD | HASH_ADD_NEW ZEND_FILE_LINE_RELAY_CC); } -ZEND_API zval *_zend_hash_index_update(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC) { return _zend_hash_index_update_or_next_insert_i(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_RELAY_CC); } @@ -669,7 +669,7 @@ static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint idx, Bucket ZEND_API int zend_hash_del(HashTable *ht, zend_string *key) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -708,7 +708,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key) ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -760,7 +760,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key) ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, int len) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -811,7 +811,7 @@ ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, int len) ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, int len) { - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; @@ -843,7 +843,7 @@ ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, int len) return FAILURE; } -ZEND_API int zend_hash_index_del(HashTable *ht, ulong h) +ZEND_API int zend_hash_index_del(HashTable *ht, zend_uint_t h) { uint nIndex; uint idx; @@ -1383,7 +1383,7 @@ ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key) ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *str, int len) { - ulong h; + zend_uint_t h; Bucket *p; IS_CONSISTENT(ht); @@ -1413,7 +1413,7 @@ ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key) ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len) { - ulong h; + zend_uint_t h; Bucket *p; IS_CONSISTENT(ht); @@ -1427,7 +1427,7 @@ ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len) return p ? 1 : 0; } -ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h) +ZEND_API zval *zend_hash_index_find(const HashTable *ht, zend_uint_t h) { Bucket *p; @@ -1448,7 +1448,7 @@ ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h) } -ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h) +ZEND_API int zend_hash_index_exists(const HashTable *ht, zend_uint_t h) { Bucket *p; @@ -1602,7 +1602,7 @@ ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) /* This function should be made binary safe */ -ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, ulong *num_index, zend_bool duplicate, HashPosition *pos) +ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_uint_t *num_index, zend_bool duplicate, HashPosition *pos) { uint idx = *pos; Bucket *p; @@ -1619,7 +1619,7 @@ ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str return HASH_KEY_IS_STRING; } else { *num_index = p->h; - return HASH_KEY_IS_LONG; + return HASH_KEY_IS_INT; } } return HASH_KEY_NON_EXISTENT; @@ -1639,7 +1639,7 @@ ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, ZVAL_STR(key, p->key); STR_ADDREF(p->key); } else { - ZVAL_LONG(key, p->h); + ZVAL_INT(key, p->h); } } } @@ -1655,7 +1655,7 @@ ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos) if (p->key) { return HASH_KEY_IS_STRING; } else { - return HASH_KEY_IS_LONG; + return HASH_KEY_IS_INT; } } return HASH_KEY_NON_EXISTENT; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index d7b419225e..f9c7f02efe 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -26,7 +26,7 @@ #include "zend.h" #define HASH_KEY_IS_STRING 1 -#define HASH_KEY_IS_LONG 2 +#define HASH_KEY_IS_INT 2 #define HASH_KEY_NON_EXISTENT 3 #define HASH_KEY_NON_EXISTANT HASH_KEY_NON_EXISTENT /* Keeping old define (with typo) for backward compatibility */ @@ -45,7 +45,7 @@ #define HASH_MASK_CONSISTENCY 0x60 typedef struct _zend_hash_key { - ulong h; + zend_uint_t h; zend_string *key; } zend_hash_key; @@ -98,10 +98,10 @@ ZEND_API zval *_zend_hash_str_add_new(HashTable *ht, const char *key, int len, z #define zend_hash_str_add_new(ht, key, len, pData) \ _zend_hash_str_add_new(ht, key, len, pData ZEND_FILE_LINE_CC) -ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC); -ZEND_API zval *_zend_hash_index_add(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC); -ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC); -ZEND_API zval *_zend_hash_index_update(HashTable *ht, ulong h, zval *pData ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, zend_uint_t h, zval *pData, int flag ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_hash_index_add(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_hash_index_add_new(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_hash_index_update(HashTable *ht, zend_uint_t h, zval *pData ZEND_FILE_LINE_DC); ZEND_API zval *_zend_hash_next_index_insert(HashTable *ht, zval *pData ZEND_FILE_LINE_DC); ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_FILE_LINE_DC); @@ -116,7 +116,7 @@ ZEND_API zval *_zend_hash_next_index_insert_new(HashTable *ht, zval *pData ZEND_ #define zend_hash_next_index_insert_new(ht, pData) \ _zend_hash_next_index_insert_new(ht, pData ZEND_FILE_LINE_CC) -ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, ulong h); +ZEND_API zval *zend_hash_index_add_empty_element(HashTable *ht, zend_uint_t h); ZEND_API zval *zend_hash_add_empty_element(HashTable *ht, zend_string *key); ZEND_API zval *zend_hash_str_add_empty_element(HashTable *ht, const char *key, int len); @@ -148,24 +148,24 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key); ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key); ZEND_API int zend_hash_str_del(HashTable *ht, const char *key, int len); ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *key, int len); -ZEND_API int zend_hash_index_del(HashTable *ht, ulong h); +ZEND_API int zend_hash_index_del(HashTable *ht, zend_uint_t h); /* Data retreival */ ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key); ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *key, int len); -ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h); +ZEND_API zval *zend_hash_index_find(const HashTable *ht, zend_uint_t h); /* Misc */ ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key); ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len); -ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h); +ZEND_API int zend_hash_index_exists(const HashTable *ht, zend_uint_t h); /* traversing */ #define zend_hash_has_more_elements_ex(ht, pos) \ (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS) ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); -ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, ulong *num_index, zend_bool duplicate, HashPosition *pos); +ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_uint_t *num_index, zend_bool duplicate, HashPosition *pos); ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos); ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos); @@ -175,7 +175,7 @@ ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos typedef struct _HashPointer { HashPosition pos; HashTable *ht; - ulong h; + zend_uint_t h; } HashPointer; ZEND_API int zend_hash_get_pointer(const HashTable *ht, HashPointer *ptr); @@ -235,7 +235,7 @@ END_EXTERN_C() #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) -static inline int _zend_handle_numeric_str(const char *key, int length, ulong *idx) +static inline int _zend_handle_numeric_str(const char *key, zend_size_t length, zend_uint_t *idx) { register const char *tmp = key; const char *end; @@ -257,9 +257,9 @@ static inline int _zend_handle_numeric_str(const char *key, int length, ulong *i if ((*end != '\0') /* not a null terminated string */ || (*tmp == '0' && length > 1) /* numbers with leading zeros */ - || (end - tmp > MAX_LENGTH_OF_LONG - 1) /* number too long */ - || (SIZEOF_LONG == 4 && - end - tmp == MAX_LENGTH_OF_LONG - 1 && + || (end - tmp > MAX_LENGTH_OF_ZEND_INT - 1) /* number too long */ + || (SIZEOF_ZEND_INT == 4 && + end - tmp == MAX_LENGTH_OF_ZEND_INT - 1 && *tmp > '2')) { /* overflow */ return 0; } @@ -268,11 +268,11 @@ static inline int _zend_handle_numeric_str(const char *key, int length, ulong *i ++tmp; if (tmp == end) { if (*key == '-') { - if (*idx-1 > LONG_MAX) { /* overflow */ + if (*idx-1 > ZEND_INT_MAX) { /* overflow */ return 0; } *idx = 0 - *idx; - } else if (*idx > LONG_MAX) { /* overflow */ + } else if (*idx > ZEND_INT_MAX) { /* overflow */ return 0; } return 1; @@ -322,7 +322,7 @@ static inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_update(ht, idx, pData); @@ -334,7 +334,7 @@ static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval * static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_update(ht, idx, pData); @@ -346,7 +346,7 @@ static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zv static inline int zend_symtable_del(HashTable *ht, zend_string *key) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_del(ht, idx); @@ -358,7 +358,7 @@ static inline int zend_symtable_del(HashTable *ht, zend_string *key) static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_del(ht, idx); @@ -370,7 +370,7 @@ static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key) static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_find(ht, idx); @@ -382,7 +382,7 @@ static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key) static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_find(ht, idx); @@ -394,7 +394,7 @@ static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key static inline int zend_symtable_exists(HashTable *ht, zend_string *key) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC(key, idx)) { return zend_hash_index_exists(ht, idx); @@ -406,7 +406,7 @@ static inline int zend_symtable_exists(HashTable *ht, zend_string *key) static inline zval *zend_symtable_str_update(HashTable *ht, const char *str, int len, zval *pData) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_update(ht, idx, pData); @@ -418,7 +418,7 @@ static inline zval *zend_symtable_str_update(HashTable *ht, const char *str, int static inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, int len, zval *pData) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_update(ht, idx, pData); @@ -430,7 +430,7 @@ static inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, static inline int zend_symtable_str_del(HashTable *ht, const char *str, int len) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_del(ht, idx); @@ -442,7 +442,7 @@ static inline int zend_symtable_str_del(HashTable *ht, const char *str, int len) static inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, int len) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_del(ht, idx); @@ -454,7 +454,7 @@ static inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, int static inline zval *zend_symtable_str_find(HashTable *ht, const char *str, int len) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_find(ht, idx); @@ -466,7 +466,7 @@ static inline zval *zend_symtable_str_find(HashTable *ht, const char *str, int l static inline int zend_symtable_str_exists(HashTable *ht, const char *str, int len) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_exists(ht, idx); @@ -564,7 +564,7 @@ static inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, int return zend_hash_str_update_ptr(ht, str, len, p); } -static inline void *zend_hash_index_update_ptr(HashTable *ht, ulong h, void *pData) +static inline void *zend_hash_index_update_ptr(HashTable *ht, zend_uint_t h, void *pData) { zval tmp, *zv; @@ -582,7 +582,7 @@ static inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData) return zv ? Z_PTR_P(zv) : NULL; } -static inline void *zend_hash_index_update_mem(HashTable *ht, ulong h, void *pData, size_t size) +static inline void *zend_hash_index_update_mem(HashTable *ht, zend_uint_t h, void *pData, size_t size) { void *p; @@ -620,7 +620,7 @@ static inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, return zv ? Z_PTR_P(zv) : NULL; } -static inline void *zend_hash_index_find_ptr(const HashTable *ht, ulong h) +static inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_uint_t h) { zval *zv; @@ -630,7 +630,7 @@ static inline void *zend_hash_index_find_ptr(const HashTable *ht, ulong h) static inline void *zend_symtable_str_find_ptr(HashTable *ht, const char *str, int len) { - ulong idx; + zend_uint_t idx; if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) { return zend_hash_index_find_ptr(ht, idx); diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index c3a02d53a3..52585005b9 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -208,9 +208,9 @@ ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int modu hashed_ini_entry->module_number = module_number; if ((zend_get_configuration_directive(p->name, p->name_length, &default_value)) == SUCCESS) { if (!hashed_ini_entry->on_modify - || hashed_ini_entry->on_modify(hashed_ini_entry, Z_STRVAL(default_value), Z_STRLEN(default_value), hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC) == SUCCESS) { + || hashed_ini_entry->on_modify(hashed_ini_entry, Z_STRVAL(default_value), Z_STRSIZE(default_value), hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC) == SUCCESS) { hashed_ini_entry->value = Z_STRVAL(default_value); - hashed_ini_entry->value_length = Z_STRLEN(default_value); + hashed_ini_entry->value_length = Z_STRSIZE(default_value); config_directive_success = 1; } } @@ -352,7 +352,7 @@ ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*di * Data retrieval */ -ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */ +ZEND_API zend_int_t zend_ini_int(char *name, uint name_length, int orig) /* {{{ */ { zend_ini_entry *ini_entry; TSRMLS_FETCH(); @@ -360,9 +360,9 @@ ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */ ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length); if (ini_entry) { if (orig && ini_entry->modified) { - return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0); + return (ini_entry->orig_value ? ZEND_STRTOI(ini_entry->orig_value, NULL, 0) : 0); } else { - return (ini_entry->value ? strtol(ini_entry->value, NULL, 0) : 0); + return (ini_entry->value ? ZEND_STRTOI(ini_entry->value, NULL, 0) : 0); } } @@ -587,7 +587,7 @@ ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */ { - long *p; + zend_int_t *p; #ifndef ZTS char *base = (char *) mh_arg2; #else @@ -596,7 +596,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */ base = (char *) ts_resource(*((int *) mh_arg2)); #endif - p = (long *) (base+(size_t) mh_arg1); + p = (zend_int_t *) (base+(size_t) mh_arg1); *p = zend_atol(new_value, new_value_length); return SUCCESS; @@ -605,7 +605,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */ { - long *p, tmp; + zend_int_t *p, tmp; #ifndef ZTS char *base = (char *) mh_arg2; #else @@ -619,7 +619,7 @@ ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */ return FAILURE; } - p = (long *) (base+(size_t) mh_arg1); + p = (zend_int_t *) (base+(size_t) mh_arg1); *p = tmp; return SUCCESS; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 0a0c1137e1..4ed2b99387 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -69,7 +69,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, char *new_value, uint ne ZEND_API int zend_restore_ini_entry(zend_string *name, int stage); ZEND_API void display_ini_entries(zend_module_entry *module); -ZEND_API long zend_ini_long(char *name, uint name_length, int orig); +ZEND_API zend_int_t zend_ini_int(char *name, uint name_length, int orig); ZEND_API double zend_ini_double(char *name, uint name_length, int orig); ZEND_API char *zend_ini_string(char *name, uint name_length, int orig); ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists); @@ -124,12 +124,12 @@ END_EXTERN_C() ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb) #endif -#define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0) +#define INI_INT(name) zend_ini_int((name), sizeof(name)-1, 0) #define INI_FLT(name) zend_ini_double((name), sizeof(name)-1, 0) #define INI_STR(name) zend_ini_string_ex((name), sizeof(name)-1, 0, NULL) #define INI_BOOL(name) ((zend_bool) INI_INT(name)) -#define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name)-1, 1) +#define INI_ORIG_INT(name) zend_ini_int((name), sizeof(name)-1, 1) #define INI_ORIG_FLT(name) zend_ini_double((name), sizeof(name)-1, 1) #define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name)-1, 1) #define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name)) diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index eaf451a3a1..7981cff3d4 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -50,7 +50,7 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2) int i_result; int i_op1, i_op2; int str_len; - char str_result[MAX_LENGTH_OF_LONG]; + char str_result[MAX_LENGTH_OF_ZEND_INT]; i_op1 = atoi(Z_STRVAL_P(op1)); STR_FREE(Z_STR_P(op1)); @@ -99,11 +99,11 @@ static void zend_ini_init_string(zval *result) */ static void zend_ini_add_string(zval *result, zval *op1, zval *op2) { - int op1_len = Z_STRLEN_P(op1); - int length = op1_len + Z_STRLEN_P(op2); + int op1_len = Z_STRSIZE_P(op1); + int length = op1_len + Z_STRSIZE_P(op2); ZVAL_NEW_STR(result, STR_REALLOC(Z_STR_P(op1), length, 1)); - memcpy(Z_STRVAL_P(result)+op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); + memcpy(Z_STRVAL_P(result)+op1_len, Z_STRVAL_P(op2), Z_STRSIZE_P(op2)); Z_STRVAL_P(result)[length] = 0; } /* }}} */ @@ -115,7 +115,7 @@ static void zend_ini_get_constant(zval *result, zval *name TSRMLS_DC) zval *c, tmp; /* If name contains ':' it is not a constant. Bug #26893. */ - if (!memchr(Z_STRVAL_P(name), ':', Z_STRLEN_P(name)) + if (!memchr(Z_STRVAL_P(name), ':', Z_STRSIZE_P(name)) && (c = zend_get_constant(Z_STR_P(name) TSRMLS_CC)) != 0) { if (Z_TYPE_P(c) != IS_STRING) { ZVAL_COPY_VALUE(&tmp, c); @@ -126,7 +126,7 @@ static void zend_ini_get_constant(zval *result, zval *name TSRMLS_DC) convert_to_string(&tmp); c = &tmp; } - ZVAL_PSTRINGL(result, Z_STRVAL_P(c), Z_STRLEN_P(c)); + ZVAL_PSTRINGL(result, Z_STRVAL_P(c), Z_STRSIZE_P(c)); if (c == &tmp) { zval_dtor(&tmp); } @@ -145,10 +145,10 @@ static void zend_ini_get_var(zval *result, zval *name TSRMLS_DC) char *envvar; /* Fetch configuration option value */ - if (zend_get_configuration_directive(Z_STRVAL_P(name), Z_STRLEN_P(name), &curval) == SUCCESS) { - ZVAL_PSTRINGL(result, Z_STRVAL(curval), Z_STRLEN(curval)); + if (zend_get_configuration_directive(Z_STRVAL_P(name), Z_STRSIZE_P(name), &curval) == SUCCESS) { + ZVAL_PSTRINGL(result, Z_STRVAL(curval), Z_STRSIZE(curval)); /* ..or if not found, try ENV */ - } else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRLEN_P(name) TSRMLS_CC)) != NULL || + } else if ((envvar = zend_getenv(Z_STRVAL_P(name), Z_STRSIZE_P(name) TSRMLS_CC)) != NULL || (envvar = getenv(Z_STRVAL_P(name))) != NULL) { ZVAL_PSTRING(result, envvar); } else { diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index b71f1ccb3c..981ab50100 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -269,7 +269,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty /* convert escape sequences */ s = t = Z_STRVAL_P(lval); - end = s + Z_STRLEN_P(lval); + end = s + Z_STRSIZE_P(lval); while (s < end) { if (*s == '\\') { @@ -288,7 +288,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty case '\\': case '$': *t++ = *s; - Z_STRLEN_P(lval)--; + Z_STRSIZE_P(lval)--; break; default: *t++ = '\\'; diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index bbc48d1fc1..0bd303f54a 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -267,7 +267,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty /* convert escape sequences */ s = t = Z_STRVAL_P(lval); - end = s + Z_STRLEN_P(lval); + end = s + Z_STRSIZE_P(lval); while (s < end) { if (*s == '\\') { @@ -286,7 +286,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty case '\\': case '$': *t++ = *s; - Z_STRLEN_P(lval)--; + Z_STRSIZE_P(lval)--; break; default: *t++ = '\\'; diff --git a/Zend/zend_int.h b/Zend/zend_int.h new file mode 100644 index 0000000000..de48718365 --- /dev/null +++ b/Zend/zend_int.h @@ -0,0 +1,145 @@ +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.00 of the Zend license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.zend.com/license/2_00.txt. | + | If you did not receive a copy of the Zend license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@zend.com so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Anatol Belski <ab@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + + +#ifndef ZEND_INT_H +#define ZEND_INT_H + +#ifndef ZEND_WIN32 +/* this probably needs more on non windows, like for C++ and C99*/ +# include <stdint.h> +# include <inttypes.h> +#endif + +/* This is the heart of the whole int64 enablement in zval. Based on this + macros the zend_size_t datatype is handled, see zend_types.h */ +#if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) +# define ZEND_ENABLE_INT64 1 +#endif + +/* Integer types or the old bad long. */ +#ifdef ZEND_ENABLE_INT64 +# ifdef ZEND_WIN32 +# ifdef _WIN64 +typedef __int64 zend_int_t; +typedef unsigned __int64 zend_uint_t; +typedef __int64 zend_off_t; +# define ZEND_INT_MAX _I64_MAX +# define ZEND_INT_MIN _I64_MIN +# define ZEND_UINT_MAX _UI64_MAX +# define Z_I(i) i##i64 +# define Z_UI(i) i##Ui64 +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# else +# if defined(__X86_64__) || defined(__LP64__) || defined(_LP64) +typedef int64_t zend_int_t; +typedef uint64_t zend_uint_t; +typedef off_t zend_off_t; +# define ZEND_INT_MAX INT64_MAX +# define ZEND_INT_MIN INT64_MIN +# define ZEND_UINT_MAX UINT64_MAX +# define Z_I(i) i##LL +# define Z_UI(i) i##ULL +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# endif +# define SIZEOF_ZEND_INT 8 +#else +typedef long zend_int_t; +typedef unsigned long zend_uint_t; +typedef long zend_off_t; +# define ZEND_INT_MAX LONG_MAX +# define ZEND_INT_MIN LONG_MIN +# define ZEND_UINT_MAX ULONG_MAX +# define Z_I(i) i##L +# define Z_UI(i) i##UL +# define SIZEOF_ZEND_INT SIZEOF_LONG +#endif + + +/* conversion macros */ +#define ZEND_ITOA_BUF_LEN 65 + +#ifdef ZEND_ENABLE_INT64 +# ifdef PHP_WIN32 +# define ZEND_ITOA(i, s, len) _i64toa_s((i), (s), (len), 10) +# define ZEND_ATOI(i, s) i = _atoi64((s)) +# define ZEND_STRTOI(s0, s1, base) _strtoi64((s0), (s1), (base)) +# define ZEND_STRTOUI(s0, s1, base) _strtoui64((s0), (s1), (base)) +# define ZEND_INT_FMT "%I64d" +# define ZEND_UINT_FMT "%I64u" +# define ZEND_INT_FMT_SPEC "I64d" +# define ZEND_UINT_FMT_SPEC "I64u" +# define ZEND_STRTOI_PTR _strtoi64 +# define ZEND_STRTOUI_PTR _strtoui64 +# define ZEND_ABS _abs64 +# else +# define ZEND_ITOA(i, s, len) \ + do { \ + int st = snprintf((s), (len), "%lld", (i)); \ + (s)[st] = '\0'; \ + } while (0) +# define ZEND_ATOI(i, s) (i) = atoll((s)) +# define ZEND_STRTOI(s0, s1, base) strtoll((s0), (s1), (base)) +# define ZEND_STRTOUI(s0, s1, base) strtoull((s0), (s1), (base)) +# define ZEND_INT_FMT "%" PRId64 +# define ZEND_UINT_FMT "%" PRIu64 +# define ZEND_INT_FMT_SPEC PRId64 +# define ZEND_UINT_FMT_SPEC PRIu64 +# define ZEND_STRTOI_PTR strtoll +# define ZEND_STRTOUI_PTR strtoull +# define ZEND_ABS llabs +# endif +#else +# define ZEND_STRTOI(s0, s1, base) strtol((s0), (s1), (base)) +# define ZEND_STRTOUI(s0, s1, base) strtoul((s0), (s1), (base)) +# ifdef PHP_WIN32 +# define ZEND_ITOA(i, s, len) _ltoa_s((i), (s), (len), 10) +# define ZEND_ATOI(i, s) i = atol((s)) +# else +# define ZEND_ITOA(i, s, len) \ + do { \ + int st = snprintf((s), (len), "%ld", (i)); \ + (s)[st] = '\0'; \ + } while (0) +# define ZEND_ATOI(i, s) (i) = atol((s)) +# endif +# define ZEND_INT_FMT "%ld" +# define ZEND_UINT_FMT "%lu" +# define ZEND_INT_FMT_SPEC "ld" +# define ZEND_UINT_FMT_SPEC "lu" +# define ZEND_STRTOI_PTR strtol +# define ZEND_STRTOUI_PTR strtoul +# define ZEND_ABS abs +#endif + + +#endif /* ZEND_INT_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index d5420dae76..8d1b2e3652 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -195,7 +195,7 @@ ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter TSRMLS_ static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) { *int_key = _iter->index; - return HASH_KEY_IS_LONG; + return HASH_KEY_IS_INT; } #endif /* }}} */ @@ -216,7 +216,7 @@ ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *ke zend_error(E_WARNING, "Nothing returned from %s::key()", iter->ce->name->val); } - ZVAL_LONG(key, 0); + ZVAL_INT(key, 0); } } /* }}} */ @@ -424,8 +424,8 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint zval_ptr_dtor(&retval); return FAILURE; case IS_STRING: - *buffer = (unsigned char*)estrndup(Z_STRVAL(retval), Z_STRLEN(retval)); - *buf_len = Z_STRLEN(retval); + *buffer = (unsigned char*)estrndup(Z_STRVAL(retval), Z_STRSIZE(retval)); + *buf_len = Z_STRSIZE(retval); result = SUCCESS; break; default: /* failure */ diff --git a/Zend/zend_iterators.h b/Zend/zend_iterators.h index 09346aee90..468223d47c 100644 --- a/Zend/zend_iterators.h +++ b/Zend/zend_iterators.h @@ -58,7 +58,7 @@ struct _zend_object_iterator { zend_object std; zval data; zend_object_iterator_funcs *funcs; - ulong index; /* private to fe_reset/fe_fetch opcodes */ + zend_uint_t index; /* private to fe_reset/fe_fetch opcodes */ }; typedef struct _zend_class_iterator_funcs { diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 38b1bcc2b4..0d40b73e4d 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -578,7 +578,7 @@ optional_class_type: function_call_parameter_list: - '(' ')' { Z_LVAL($$.u.constant) = 0; } + '(' ')' { Z_IVAL($$.u.constant) = 0; } | '(' non_empty_function_call_parameter_list ')' { $$ = $2; } | '(' yield_expr ')' { zend_do_pass_param(&$2, ZEND_SEND_VAL TSRMLS_CC); } ; @@ -625,7 +625,7 @@ class_statement_list: class_statement: - variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';' + variable_modifiers { CG(access_type) = Z_IVAL($1.u.constant); } class_variable_declaration ';' | class_constant_declaration ';' | trait_use_statement | method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } @@ -686,37 +686,37 @@ trait_alias: ; trait_modifiers: - /* empty */ { Z_LVAL($$.u.constant) = 0x0; } /* No change of methods visibility */ + /* empty */ { Z_IVAL($$.u.constant) = 0x0; } /* No change of methods visibility */ | member_modifier { $$ = $1; } /* REM: Keep in mind, there are not only visibility modifiers */ ; method_body: - ';' /* abstract method */ { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; } - | '{' inner_statement_list '}' { Z_LVAL($$.u.constant) = 0; } + ';' /* abstract method */ { Z_IVAL($$.u.constant) = ZEND_ACC_ABSTRACT; } + | '{' inner_statement_list '}' { Z_IVAL($$.u.constant) = 0; } ; variable_modifiers: non_empty_member_modifiers { $$ = $1; } - | T_VAR { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; } + | T_VAR { Z_IVAL($$.u.constant) = ZEND_ACC_PUBLIC; } ; method_modifiers: - /* empty */ { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; } - | non_empty_member_modifiers { $$ = $1; if (!(Z_LVAL($$.u.constant) & ZEND_ACC_PPP_MASK)) { Z_LVAL($$.u.constant) |= ZEND_ACC_PUBLIC; } } + /* empty */ { Z_IVAL($$.u.constant) = ZEND_ACC_PUBLIC; } + | non_empty_member_modifiers { $$ = $1; if (!(Z_IVAL($$.u.constant) & ZEND_ACC_PPP_MASK)) { Z_IVAL($$.u.constant) |= ZEND_ACC_PUBLIC; } } ; non_empty_member_modifiers: member_modifier { $$ = $1; } - | non_empty_member_modifiers member_modifier { Z_LVAL($$.u.constant) = zend_do_verify_access_types(&$1, &$2); } + | non_empty_member_modifiers member_modifier { Z_IVAL($$.u.constant) = zend_do_verify_access_types(&$1, &$2); } ; member_modifier: - T_PUBLIC { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; } - | T_PROTECTED { Z_LVAL($$.u.constant) = ZEND_ACC_PROTECTED; } - | T_PRIVATE { Z_LVAL($$.u.constant) = ZEND_ACC_PRIVATE; } - | T_STATIC { Z_LVAL($$.u.constant) = ZEND_ACC_STATIC; } - | T_ABSTRACT { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; } - | T_FINAL { Z_LVAL($$.u.constant) = ZEND_ACC_FINAL; } + T_PUBLIC { Z_IVAL($$.u.constant) = ZEND_ACC_PUBLIC; } + | T_PROTECTED { Z_IVAL($$.u.constant) = ZEND_ACC_PROTECTED; } + | T_PRIVATE { Z_IVAL($$.u.constant) = ZEND_ACC_PRIVATE; } + | T_STATIC { Z_IVAL($$.u.constant) = ZEND_ACC_STATIC; } + | T_ABSTRACT { Z_IVAL($$.u.constant) = ZEND_ACC_ABSTRACT; } + | T_FINAL { Z_IVAL($$.u.constant) = ZEND_ACC_FINAL; } ; class_variable_declaration: @@ -812,8 +812,8 @@ expr_without_variable: | expr '%' expr { zend_do_binary_op(ZEND_MOD, &$$, &$1, &$3 TSRMLS_CC); } | expr T_SL expr { zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 TSRMLS_CC); } | expr T_SR expr { zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 TSRMLS_CC); } - | '+' expr %prec T_INC { ZVAL_LONG(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; zend_do_binary_op(ZEND_ADD, &$$, &$1, &$2 TSRMLS_CC); } } - | '-' expr %prec T_INC { ZVAL_LONG(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; zend_do_binary_op(ZEND_SUB, &$$, &$1, &$2 TSRMLS_CC); } } + | '+' expr %prec T_INC { ZVAL_INT(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; zend_do_binary_op(ZEND_ADD, &$$, &$1, &$2 TSRMLS_CC); } } + | '-' expr %prec T_INC { ZVAL_INT(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; zend_do_binary_op(ZEND_SUB, &$$, &$1, &$2 TSRMLS_CC); } } | '!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 TSRMLS_CC); } | '~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 TSRMLS_CC); } | expr T_IS_IDENTICAL expr { zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); } @@ -834,7 +834,7 @@ expr_without_variable: | expr '?' ':' { zend_do_jmp_set(&$1, &$2, &$3 TSRMLS_CC); } expr { zend_do_jmp_set_else(&$$, &$5, &$2, &$3 TSRMLS_CC); } | internal_functions_in_yacc { $$ = $1; } - | T_INT_CAST expr { zend_do_cast(&$$, &$2, IS_LONG TSRMLS_CC); } + | T_INT_CAST expr { zend_do_cast(&$$, &$2, IS_INT TSRMLS_CC); } | T_DOUBLE_CAST expr { zend_do_cast(&$$, &$2, IS_DOUBLE TSRMLS_CC); } | T_STRING_CAST expr { zend_do_cast(&$$, &$2, IS_STRING TSRMLS_CC); } | T_ARRAY_CAST expr { zend_do_cast(&$$, &$2, IS_ARRAY TSRMLS_CC); } @@ -915,13 +915,13 @@ class_name: T_STATIC { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1);} | namespace_name { $$ = $1; } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); } - | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); $$ = $2; } + | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRSIZE($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); $$ = $2; } ; fully_qualified_class_name: namespace_name { $$ = $1; } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); } - | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); $$ = $2; } + | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRSIZE($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); $$ = $2; } ; @@ -964,7 +964,7 @@ backticks_expr: ctor_arguments: - /* empty */ { Z_LVAL($$.u.constant) = 0; } + /* empty */ { Z_IVAL($$.u.constant) = 0; } | function_call_parameter_list { $$ = $1; } ; @@ -997,7 +997,7 @@ static_scalar_value: | static_class_name_scalar { $$.u.ast = zend_ast_create_constant(&$1.u.constant); } | namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_CT, 0 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); } - | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_CT, 0 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); } + | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRSIZE($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_CT, 0 TSRMLS_CC); $$.u.ast = zend_ast_create_constant(&$$.u.constant); } | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; } | '[' static_array_pair_list ']' { $$ = $2; } | static_class_constant { $$.u.ast = zend_ast_create_constant(&$1.u.constant); } @@ -1045,7 +1045,7 @@ general_constant: class_constant { $$ = $1; } | namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); } | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_RT, 0 TSRMLS_CC); } - | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); } + | T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRSIZE($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRSIZE($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); } ; scalar: @@ -1203,8 +1203,8 @@ variable_name: ; simple_indirect_reference: - '$' { Z_LVAL($$.u.constant) = 1; } - | simple_indirect_reference '$' { Z_LVAL($$.u.constant)++; } + '$' { Z_IVAL($$.u.constant) = 1; } + | simple_indirect_reference '$' { Z_IVAL($$.u.constant)++; } ; assignment_list: diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c index 8858e8be9e..f69b512d52 100644 --- a/Zend/zend_language_scanner.c +++ b/Zend/zend_language_scanner.c @@ -565,7 +565,7 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR zend_bool original_in_compilation = CG(in_compilation); retval_znode.op_type = IS_CONST; - ZVAL_LONG(&retval_znode.u.constant, 1); + ZVAL_INT(&retval_znode.u.constant, 1); zend_save_lexical_state(&original_lex_state TSRMLS_CC); @@ -631,7 +631,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) retval = zend_compile_file(&file_handle, type TSRMLS_CC); if (retval && file_handle.handle.stream.handle) { if (!file_handle.opened_path) { - file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename)); + file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRSIZE_P(filename)); } zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)); @@ -655,7 +655,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D zend_string *new_compiled_filename; /* enforce ZEND_MMAP_AHEAD trailing NULLs for flex... */ - old_len = Z_STRLEN_P(str); + old_len = Z_STRSIZE_P(str); Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; memset(Z_STRVAL_P(str) + old_len, 0, ZEND_MMAP_AHEAD + 1); @@ -727,7 +727,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) int compiler_result; zend_bool original_in_compilation = CG(in_compilation); - if (Z_STRLEN_P(source_string)==0) { + if (Z_STRSIZE_P(source_string)==0) { efree(op_array); return NULL; } @@ -894,7 +894,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo /* convert escape sequences */ s = t = Z_STRVAL_P(zendlval); - end = s+Z_STRLEN_P(zendlval); + end = s+Z_STRSIZE_P(zendlval); while (s<end) { if (*s=='\\') { s++; @@ -906,23 +906,23 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo switch(*s) { case 'n': *t++ = '\n'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'r': *t++ = '\r'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 't': *t++ = '\t'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'f': *t++ = '\f'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'v': *t++ = '\v'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'e': #ifdef PHP_WIN32 @@ -930,7 +930,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo #else *t++ = '\e'; #endif - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case '"': case '`': @@ -942,22 +942,22 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo case '\\': case '$': *t++ = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'x': case 'X': if (ZEND_IS_HEX(*(s+1))) { char hex_buf[3] = { 0, 0, 0 }; - Z_STRLEN_P(zendlval)--; /* for the 'x' */ + Z_STRSIZE_P(zendlval)--; /* for the 'x' */ hex_buf[0] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_HEX(*(s+1))) { hex_buf[1] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; } - *t++ = (char) strtol(hex_buf, NULL, 16); + *t++ = (char) ZEND_STRTOI(hex_buf, NULL, 16); } else { *t++ = '\\'; *t++ = *s; @@ -969,16 +969,16 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo char octal_buf[4] = { 0, 0, 0, 0 }; octal_buf[0] = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_OCT(*(s+1))) { octal_buf[1] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_OCT(*(s+1))) { octal_buf[2] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; } } - *t++ = (char) strtol(octal_buf, NULL, 8); + *t++ = (char) ZEND_STRTOI(octal_buf, NULL, 8); } else { *t++ = '\\'; *t++ = *s; @@ -1000,7 +1000,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo unsigned char *str; // TODO: avoid realocation ??? s = Z_STRVAL_P(zendlval); - SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); + SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRSIZE_P(zendlval) TSRMLS_CC); zval_ptr_dtor(zendlval); ZVAL_STRINGL(zendlval, str, sz); efree(str); @@ -1645,7 +1645,7 @@ yy61: yyleng = YYCURSOR - SCNG(yy_text); #line 2153 "Zend/zend_language_scanner.l" { - Z_LVAL_P(zendlval) = (long) '{'; + Z_IVAL_P(zendlval) = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; @@ -1873,7 +1873,7 @@ yy83: yyleng = YYCURSOR - SCNG(yy_text); #line 2153 "Zend/zend_language_scanner.l" { - Z_LVAL_P(zendlval) = (long) '{'; + Z_IVAL_P(zendlval) = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; @@ -2132,7 +2132,7 @@ yy107: yyleng = YYCURSOR - SCNG(yy_text); #line 2153 "Zend/zend_language_scanner.l" { - Z_LVAL_P(zendlval) = (long) '{'; + Z_IVAL_P(zendlval) = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; @@ -2952,11 +2952,11 @@ yy173: yyleng = YYCURSOR - SCNG(yy_text); #line 1537 "Zend/zend_language_scanner.l" { - if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ - ZVAL_LONG(zendlval, strtol(yytext, NULL, 0)); + if (yyleng < MAX_LENGTH_OF_ZEND_INT - 1) { /* Won't overflow */ + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 0)); } else { errno = 0; - ZVAL_LONG(zendlval, strtol(yytext, NULL, 0)); + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 0)); if (errno == ERANGE) { /* Overflow */ if (yytext[0] == '0') { /* octal overflow */ ZVAL_DOUBLE(zendlval, zend_oct_strtod(yytext, NULL)); @@ -3067,7 +3067,7 @@ yy179: /* convert escape sequences */ s = t = Z_STRVAL_P(zendlval); - end = s+Z_STRLEN_P(zendlval); + end = s+Z_STRSIZE_P(zendlval); while (s<end) { if (*s=='\\') { s++; @@ -3076,7 +3076,7 @@ yy179: case '\\': case '\'': *t++ = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; default: *t++ = '\\'; @@ -3099,7 +3099,7 @@ yy179: char *str = NULL; s = Z_STRVAL_P(zendlval); // TODO: avoid reallocation ??? - SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); + SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRSIZE_P(zendlval) TSRMLS_CC); ZVAL_STRINGL(zendlval, str, sz); efree(s); } @@ -3314,11 +3314,11 @@ yy200: --len; } - if (len < SIZEOF_LONG * 8) { + if (len < SIZEOF_ZEND_INT * 8) { if (len == 0) { - ZVAL_LONG(zendlval, 0); + ZVAL_INT(zendlval, 0); } else { - ZVAL_LONG(zendlval, strtol(bin, NULL, 2)); + ZVAL_INT(zendlval, ZEND_STRTOI(bin, NULL, 2)); } return T_LNUMBER; } else { @@ -3349,11 +3349,11 @@ yy203: len--; } - if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) { + if (len < SIZEOF_ZEND_INT * 2 || (len == SIZEOF_ZEND_INT * 2 && *hex <= '7')) { if (len == 0) { - ZVAL_LONG(zendlval, 0); + ZVAL_INT(zendlval, 0); } else { - ZVAL_LONG(zendlval, strtol(hex, NULL, 16)); + ZVAL_INT(zendlval, ZEND_STRTOI(hex, NULL, 16)); } return T_LNUMBER; } else { @@ -4248,7 +4248,7 @@ yy328: yyleng = YYCURSOR - SCNG(yy_text); #line 1666 "Zend/zend_language_scanner.l" { - ZVAL_LONG(zendlval, CG(zend_lineno)); + ZVAL_INT(zendlval, CG(zend_lineno)); return T_LINE; } #line 4255 "Zend/zend_language_scanner.c" @@ -7672,8 +7672,8 @@ yy839: yyleng = YYCURSOR - SCNG(yy_text); #line 1578 "Zend/zend_language_scanner.l" { /* Offset could be treated as a long */ - if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { - ZVAL_LONG(zendlval, strtol(yytext, NULL, 10)); + if (yyleng < MAX_LENGTH_OF_ZEND_INT - 1 || (yyleng == MAX_LENGTH_OF_ZEND_INT - 1 && strcmp(yytext, int_min_digits) < 0)) { + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 10)); } else { ZVAL_STRINGL(zendlval, yytext, yyleng); } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index b5100860c1..36aeee65d6 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -563,7 +563,7 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR zend_bool original_in_compilation = CG(in_compilation); retval_znode.op_type = IS_CONST; - ZVAL_LONG(&retval_znode.u.constant, 1); + ZVAL_INT(&retval_znode.u.constant, 1); zend_save_lexical_state(&original_lex_state TSRMLS_CC); @@ -629,7 +629,7 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) retval = zend_compile_file(&file_handle, type TSRMLS_CC); if (retval && file_handle.handle.stream.handle) { if (!file_handle.opened_path) { - file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRLEN_P(filename)); + file_handle.opened_path = opened_path = estrndup(Z_STRVAL_P(filename), Z_STRSIZE_P(filename)); } zend_hash_str_add_empty_element(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)); @@ -653,7 +653,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D zend_string *new_compiled_filename; /* enforce ZEND_MMAP_AHEAD trailing NULLs for flex... */ - old_len = Z_STRLEN_P(str); + old_len = Z_STRSIZE_P(str); Z_STR_P(str) = STR_REALLOC(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; memset(Z_STRVAL_P(str) + old_len, 0, ZEND_MMAP_AHEAD + 1); @@ -725,7 +725,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) int compiler_result; zend_bool original_in_compilation = CG(in_compilation); - if (Z_STRLEN_P(source_string)==0) { + if (Z_STRSIZE_P(source_string)==0) { efree(op_array); return NULL; } @@ -892,7 +892,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo /* convert escape sequences */ s = t = Z_STRVAL_P(zendlval); - end = s+Z_STRLEN_P(zendlval); + end = s+Z_STRSIZE_P(zendlval); while (s<end) { if (*s=='\\') { s++; @@ -904,23 +904,23 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo switch(*s) { case 'n': *t++ = '\n'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'r': *t++ = '\r'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 't': *t++ = '\t'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'f': *t++ = '\f'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'v': *t++ = '\v'; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'e': #ifdef PHP_WIN32 @@ -928,7 +928,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo #else *t++ = '\e'; #endif - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case '"': case '`': @@ -940,22 +940,22 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo case '\\': case '$': *t++ = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; case 'x': case 'X': if (ZEND_IS_HEX(*(s+1))) { char hex_buf[3] = { 0, 0, 0 }; - Z_STRLEN_P(zendlval)--; /* for the 'x' */ + Z_STRSIZE_P(zendlval)--; /* for the 'x' */ hex_buf[0] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_HEX(*(s+1))) { hex_buf[1] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; } - *t++ = (char) strtol(hex_buf, NULL, 16); + *t++ = (char) ZEND_STRTOI(hex_buf, NULL, 16); } else { *t++ = '\\'; *t++ = *s; @@ -967,16 +967,16 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo char octal_buf[4] = { 0, 0, 0, 0 }; octal_buf[0] = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_OCT(*(s+1))) { octal_buf[1] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; if (ZEND_IS_OCT(*(s+1))) { octal_buf[2] = *(++s); - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; } } - *t++ = (char) strtol(octal_buf, NULL, 8); + *t++ = (char) ZEND_STRTOI(octal_buf, NULL, 8); } else { *t++ = '\\'; *t++ = *s; @@ -998,7 +998,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo unsigned char *str; // TODO: avoid realocation ??? s = Z_STRVAL_P(zendlval); - SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); + SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRSIZE_P(zendlval) TSRMLS_CC); zval_ptr_dtor(zendlval); ZVAL_STRINGL(zendlval, str, sz); efree(str); @@ -1521,11 +1521,11 @@ NEWLINE ("\r"|"\n"|"\r\n") --len; } - if (len < SIZEOF_LONG * 8) { + if (len < SIZEOF_ZEND_INT * 8) { if (len == 0) { - ZVAL_LONG(zendlval, 0); + ZVAL_INT(zendlval, 0); } else { - ZVAL_LONG(zendlval, strtol(bin, NULL, 2)); + ZVAL_INT(zendlval, ZEND_STRTOI(bin, NULL, 2)); } return T_LNUMBER; } else { @@ -1535,11 +1535,11 @@ NEWLINE ("\r"|"\n"|"\r\n") } <ST_IN_SCRIPTING>{LNUM} { - if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ - ZVAL_LONG(zendlval, strtol(yytext, NULL, 0)); + if (yyleng < MAX_LENGTH_OF_ZEND_INT - 1) { /* Won't overflow */ + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 0)); } else { errno = 0; - ZVAL_LONG(zendlval, strtol(yytext, NULL, 0)); + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 0)); if (errno == ERANGE) { /* Overflow */ if (yytext[0] == '0') { /* octal overflow */ ZVAL_DOUBLE(zendlval, zend_oct_strtod(yytext, NULL)); @@ -1562,11 +1562,11 @@ NEWLINE ("\r"|"\n"|"\r\n") len--; } - if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) { + if (len < SIZEOF_ZEND_INT * 2 || (len == SIZEOF_ZEND_INT * 2 && *hex <= '7')) { if (len == 0) { - ZVAL_LONG(zendlval, 0); + ZVAL_INT(zendlval, 0); } else { - ZVAL_LONG(zendlval, strtol(hex, NULL, 16)); + ZVAL_INT(zendlval, ZEND_STRTOI(hex, NULL, 16)); } return T_LNUMBER; } else { @@ -1576,8 +1576,8 @@ NEWLINE ("\r"|"\n"|"\r\n") } <ST_VAR_OFFSET>[0]|([1-9][0-9]*) { /* Offset could be treated as a long */ - if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { - ZVAL_LONG(zendlval, strtol(yytext, NULL, 10)); + if (yyleng < MAX_LENGTH_OF_ZEND_INT - 1 || (yyleng == MAX_LENGTH_OF_ZEND_INT - 1 && strcmp(yytext, int_min_digits) < 0)) { + ZVAL_INT(zendlval, ZEND_STRTOI(yytext, NULL, 10)); } else { ZVAL_STRINGL(zendlval, yytext, yyleng); } @@ -1664,7 +1664,7 @@ NEWLINE ("\r"|"\n"|"\r\n") } <ST_IN_SCRIPTING>"__LINE__" { - ZVAL_LONG(zendlval, CG(zend_lineno)); + ZVAL_INT(zendlval, CG(zend_lineno)); return T_LINE; } @@ -2000,7 +2000,7 @@ inline_html: /* convert escape sequences */ s = t = Z_STRVAL_P(zendlval); - end = s+Z_STRLEN_P(zendlval); + end = s+Z_STRSIZE_P(zendlval); while (s<end) { if (*s=='\\') { s++; @@ -2009,7 +2009,7 @@ inline_html: case '\\': case '\'': *t++ = *s; - Z_STRLEN_P(zendlval)--; + Z_STRSIZE_P(zendlval)--; break; default: *t++ = '\\'; @@ -2032,7 +2032,7 @@ inline_html: char *str = NULL; s = Z_STRVAL_P(zendlval); // TODO: avoid reallocation ??? - SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval) TSRMLS_CC); + SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRSIZE_P(zendlval) TSRMLS_CC); ZVAL_STRINGL(zendlval, str, sz); efree(s); } @@ -2151,7 +2151,7 @@ inline_html: <ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" { - Z_LVAL_P(zendlval) = (long) '{'; + Z_IVAL_P(zendlval) = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index 74dc7d1452..587346c267 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -21,8 +21,8 @@ #if defined(__i386__) && defined(__GNUC__) -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - long __tmpvar; \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ + zend_int_t __tmpvar; \ __asm__ ("imul %3,%0\n" \ "adc $0,%1" \ : "=r"(__tmpvar),"=r"(usedval) \ @@ -33,8 +33,8 @@ #elif defined(__x86_64__) && defined(__GNUC__) -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - long __tmpvar; \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ + zend_int_t __tmpvar; \ __asm__ ("imul %3,%0\n" \ "adc $0,%1" \ : "=r"(__tmpvar),"=r"(usedval) \ @@ -45,8 +45,8 @@ #elif defined(__arm__) && defined(__GNUC__) -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - long __tmpvar; \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ + zend_int_t __tmpvar; \ __asm__("smull %0, %1, %2, %3\n" \ "sub %1, %1, %0, asr #31" \ : "=r"(__tmpvar), "=r"(usedval) \ @@ -57,8 +57,8 @@ #elif defined(__aarch64__) && defined(__GNUC__) -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ - long __tmpvar; \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ + zend_int_t __tmpvar; \ __asm__("mul %0, %2, %3\n" \ "smulh %1, %2, %3\n" \ "sub %1, %1, %0, asr #63\n" \ @@ -68,11 +68,24 @@ else (lval) = __tmpvar; \ } while (0) +#elif defined(ZEND_WIN32) + +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ + zend_int_t __lres = (a) * (b); \ + long double __dres = (long double)(a) * (long double)(b); \ + long double __delta = (long double) __lres - __dres; \ + if ( ((usedval) = (( __dres + __delta ) != __dres))) { \ + (dval) = __dres; \ + } else { \ + (lval) = __lres; \ + } \ +} while (0) + #elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64) -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ zend_long64 __result = (zend_long64) (a) * (zend_long64) (b); \ - if (__result > LONG_MAX || __result < LONG_MIN) { \ + if (__result > ZEND_INT_MAX || __result < ZEND_INT_MIN) { \ (dval) = (double) __result; \ (usedval) = 1; \ } else { \ @@ -83,7 +96,7 @@ #else -#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ +#define ZEND_SIGNED_MULTIPLY_INT(a, b, lval, dval, usedval) do { \ long __lres = (a) * (b); \ long double __dres = (long double)(a) * (long double)(b); \ long double __delta = (long double) __lres - __dres; \ diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index d7d8bf0a52..a0ff59b292 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -423,7 +423,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf } /* }}} */ -static long *zend_get_property_guard(zend_object *zobj, zend_property_info *property_info, zval *member) /* {{{ */ +static zend_int_t *zend_get_property_guard(zend_object *zobj, zend_property_info *property_info, zval *member) /* {{{ */ { zend_property_info info; zval stub, *guard; @@ -448,15 +448,15 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop if (str) { STR_RELEASE(str); } - return &Z_LVAL_P(guard); + return &Z_IVAL_P(guard); } - ZVAL_LONG(&stub, 0); + ZVAL_INT(&stub, 0); guard = zend_hash_add_new(zobj->guards, property_info->name, &stub); if (str) { STR_RELEASE(str); } - return &Z_LVAL_P(guard); + return &Z_IVAL_P(guard); } /* }}} */ @@ -501,7 +501,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ /* magic get */ if (zobj->ce->__get) { - long *guard = zend_get_property_guard(zobj, property_info, member); + zend_int_t *guard = zend_get_property_guard(zobj, property_info, member); if (!((*guard) & IN_GET)) { zval tmp_object; @@ -526,7 +526,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ zval_ptr_dtor(&tmp_object); } else { if (Z_STRVAL_P(member)[0] == '\0') { - if (Z_STRLEN_P(member) == 0) { + if (Z_STRSIZE_P(member) == 0) { zend_error(E_ERROR, "Cannot access empty property"); } else { zend_error(E_ERROR, "Cannot access property started with '\\0'"); @@ -635,7 +635,7 @@ found: /* magic set */ if (zobj->ce->__set) { - long *guard = zend_get_property_guard(zobj, property_info, member); + zend_int_t *guard = zend_get_property_guard(zobj, property_info, member); if (!((*guard) & IN_SET)) { zval tmp_object; @@ -651,7 +651,7 @@ found: goto write_std_property; } else { if (Z_STRVAL_P(member)[0] == '\0') { - if (Z_STRLEN_P(member) == 0) { + if (Z_STRSIZE_P(member) == 0) { zend_error(E_ERROR, "Cannot access empty property"); } else { zend_error(E_ERROR, "Cannot access property started with '\\0'"); @@ -778,7 +778,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, zval tmp_member; zval *retval, tmp; zend_property_info *property_info; - long *guard; + zend_int_t *guard; zobj = Z_OBJ_P(object); @@ -875,7 +875,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo /* magic unset */ if (zobj->ce->__unset) { - long *guard = zend_get_property_guard(zobj, property_info, member); + zend_int_t *guard = zend_get_property_guard(zobj, property_info, member); if (!((*guard) & IN_UNSET)) { zval tmp_object; @@ -887,7 +887,7 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo zval_ptr_dtor(&tmp_object); } else { if (Z_STRVAL_P(member)[0] == '\0') { - if (Z_STRLEN_P(member) == 0) { + if (Z_STRSIZE_P(member) == 0) { zend_error(E_ERROR, "Cannot access empty property"); } else { zend_error(E_ERROR, "Cannot access property started with '\\0'"); @@ -1404,10 +1404,10 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ Z_OBJ_UNPROTECT_RECURSION(o2); return 1; } - if (Z_LVAL(result) != 0) { + if (Z_IVAL(result) != 0) { Z_OBJ_UNPROTECT_RECURSION(o1); Z_OBJ_UNPROTECT_RECURSION(o2); - return Z_LVAL(result); + return Z_IVAL(result); } } else { Z_OBJ_UNPROTECT_RECURSION(o1); @@ -1485,7 +1485,7 @@ found: result = 0; if ((has_set_exists != 2) && zobj->ce->__isset) { - long *guard = zend_get_property_guard(zobj, property_info, member); + zend_int_t *guard = zend_get_property_guard(zobj, property_info, member); if (!((*guard) & IN_ISSET)) { zval rv; @@ -1586,13 +1586,13 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty case _IS_BOOL: ZVAL_BOOL(writeobj, 1); return SUCCESS; - case IS_LONG: + case IS_INT: ce = Z_OBJCE_P(readobj); zend_error(E_NOTICE, "Object of class %s could not be converted to int", ce->name->val); if (readobj == writeobj) { zval_dtor(readobj); } - ZVAL_LONG(writeobj, 1); + ZVAL_INT(writeobj, 1); return SUCCESS; case IS_DOUBLE: ce = Z_OBJCE_P(readobj); diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index ac3d962071..a11269c925 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -106,7 +106,7 @@ typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_D /* updates *count to hold the number of elements present and returns SUCCESS. * Returns FAILURE if the object does not have any sense of overloaded dimensions */ -typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC); +typedef int (*zend_object_count_elements_t)(zval *object, zend_int_t *count TSRMLS_DC); typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC); diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 8309599521..1c0b06fa8c 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -648,7 +648,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) int nest_levels, array_offset; zend_brk_cont_element *jmp_to; - nest_levels = Z_LVAL(op_array->literals[opline->op2.constant]); + nest_levels = Z_IVAL(op_array->literals[opline->op2.constant]); if ((array_offset = opline->op1.opline_num) != -1) { do { jmp_to = &op_array->brk_cont_array[array_offset]; @@ -661,7 +661,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) } } case ZEND_GOTO: - if (Z_TYPE(op_array->literals[opline->op2.constant]) != IS_LONG) { + if (Z_TYPE(op_array->literals[opline->op2.constant]) != IS_INT) { zend_uint num = opline->op2.constant; opline->op2.zv = &op_array->literals[opline->op2.constant]; zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC); @@ -734,7 +734,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) opline->extended_value = (zend_uint)(zend_intptr_t)EX_VAR_NUM_2(NULL, op_array->last_var + opline->extended_value); break; case ZEND_GOTO: - if (Z_TYPE_P(opline->op2.zv) != IS_LONG) { + if (Z_TYPE_P(opline->op2.zv) != IS_INT) { zend_resolve_goto_label(op_array, opline, 1 TSRMLS_CC); } /* break omitted intentionally */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 921d71b685..ecc5762624 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -86,7 +86,7 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ if (!str_len) { str_len = strlen(str); } - retval = strtol(str, NULL, 0); + retval = ZEND_STRTOI(str, NULL, 0); if (str_len>0) { switch (str[str_len-1]) { case 'g': @@ -107,14 +107,14 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ } /* }}} */ -ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */ +ZEND_API zend_int_t zend_atol(const char *str, int str_len) /* {{{ */ { - long retval; + zend_int_t retval; if (!str_len) { str_len = strlen(str); } - retval = strtol(str, NULL, 0); + retval = ZEND_STRTOI(str, NULL, 0); if (str_len>0) { switch (str[str_len-1]) { case 'g': @@ -198,28 +198,28 @@ try_again: zend_string *str; str = Z_STR_P(op); - if ((Z_TYPE_INFO_P(op)=is_numeric_string(str->val, str->len, &Z_LVAL_P(op), &Z_DVAL_P(op), 1)) == 0) { - ZVAL_LONG(op, 0); + if ((Z_TYPE_INFO_P(op)=is_numeric_string(str->val, str->len, &Z_IVAL_P(op), &Z_DVAL_P(op), 1)) == 0) { + ZVAL_INT(op, 0); } STR_RELEASE(str); break; } case IS_NULL: case IS_FALSE: - ZVAL_LONG(op, 0); + ZVAL_INT(op, 0); break; case IS_TRUE: - ZVAL_LONG(op, 1); + ZVAL_INT(op, 1); break; case IS_RESOURCE: { - long l = Z_RES_HANDLE_P(op); + zend_int_t l = Z_RES_HANDLE_P(op); zval_ptr_dtor(op); - ZVAL_LONG(op, l); + ZVAL_INT(op, l); } break; case IS_OBJECT: - convert_to_long_base(op, 10); + convert_to_int_base(op, 10); break; } } @@ -228,36 +228,36 @@ try_again: /* {{{ zendi_convert_scalar_to_number */ #define zendi_convert_scalar_to_number(op, holder, result) \ if (op==result) { \ - if (Z_TYPE_P(op) != IS_LONG) { \ + if (Z_TYPE_P(op) != IS_INT) { \ convert_scalar_to_number(op TSRMLS_CC); \ } \ } else { \ switch (Z_TYPE_P(op)) { \ case IS_STRING: \ { \ - if ((Z_TYPE_INFO(holder)=is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &Z_LVAL(holder), &Z_DVAL(holder), 1)) == 0) { \ - ZVAL_LONG(&(holder), 0); \ + if ((Z_TYPE_INFO(holder)=is_numeric_string(Z_STRVAL_P(op), Z_STRSIZE_P(op), &Z_IVAL(holder), &Z_DVAL(holder), 1)) == 0) { \ + ZVAL_INT(&(holder), 0); \ } \ (op) = &(holder); \ break; \ } \ case IS_NULL: \ case IS_FALSE: \ - ZVAL_LONG(&(holder), 0); \ + ZVAL_INT(&(holder), 0); \ (op) = &(holder); \ break; \ case IS_TRUE: \ - ZVAL_LONG(&(holder), 1); \ + ZVAL_INT(&(holder), 1); \ (op) = &(holder); \ break; \ case IS_RESOURCE: \ - ZVAL_LONG(&(holder), Z_RES_HANDLE_P(op)); \ + ZVAL_INT(&(holder), Z_RES_HANDLE_P(op)); \ (op) = &(holder); \ break; \ case IS_OBJECT: \ ZVAL_DUP(&(holder), op); \ - convert_to_long_base(&(holder), 10); \ - if (Z_TYPE(holder) == IS_LONG) { \ + convert_to_int_base(&(holder), 10); \ + if (Z_TYPE(holder) == IS_INT) { \ (op) = &(holder); \ } \ break; \ @@ -266,38 +266,38 @@ try_again: /* }}} */ -/* {{{ zendi_convert_to_long */ -#define zendi_convert_to_long(op, holder, result) \ +/* {{{ zendi_convert_to_int */ +#define zendi_convert_to_int(op, holder, result) \ if (op == result) { \ - convert_to_long(op); \ - } else if (Z_TYPE_P(op) != IS_LONG) { \ + convert_to_int(op); \ + } else if (Z_TYPE_P(op) != IS_INT) { \ switch (Z_TYPE_P(op)) { \ case IS_NULL: \ case IS_FALSE: \ - ZVAL_LONG(&(holder), 0); \ + ZVAL_INT(&(holder), 0); \ break; \ case IS_TRUE: \ - ZVAL_LONG(&(holder), 1); \ + ZVAL_INT(&(holder), 1); \ break; \ case IS_DOUBLE: \ - ZVAL_LONG(&holder, zend_dval_to_lval(Z_DVAL_P(op)));\ + ZVAL_INT(&holder, zend_dval_to_ival(Z_DVAL_P(op)));\ break; \ case IS_STRING: \ - ZVAL_LONG(&holder, strtol(Z_STRVAL_P(op), NULL, 10));\ + ZVAL_INT(&holder, ZEND_STRTOI(Z_STRVAL_P(op), NULL, 10));\ break; \ case IS_ARRAY: \ - ZVAL_LONG(&holder, zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); \ + ZVAL_INT(&holder, zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); \ break; \ case IS_OBJECT: \ ZVAL_DUP(&(holder), (op)); \ - convert_to_long_base(&(holder), 10); \ + convert_to_int_base(&(holder), 10); \ break; \ case IS_RESOURCE: \ - ZVAL_LONG(&holder, Z_RES_HANDLE_P(op)); \ + ZVAL_INT(&holder, Z_RES_HANDLE_P(op)); \ break; \ default: \ zend_error(E_WARNING, "Cannot convert to ordinal value"); \ - ZVAL_LONG(&holder, 0); \ + ZVAL_INT(&holder, 0); \ break; \ } \ (op) = &(holder); \ @@ -318,15 +318,15 @@ try_again: case IS_RESOURCE: \ ZVAL_BOOL(&holder, Z_RES_HANDLE_P(op) ? 1 : 0); \ break; \ - case IS_LONG: \ - ZVAL_BOOL(&holder, Z_LVAL_P(op) ? 1 : 0); \ + case IS_INT: \ + ZVAL_BOOL(&holder, Z_IVAL_P(op) ? 1 : 0); \ break; \ case IS_DOUBLE: \ ZVAL_BOOL(&holder, Z_DVAL_P(op) ? 1 : 0); \ break; \ case IS_STRING: \ - if (Z_STRLEN_P(op) == 0 \ - || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) { \ + if (Z_STRSIZE_P(op) == 0 \ + || (Z_STRSIZE_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) { \ ZVAL_BOOL(&holder, 0); \ } else { \ ZVAL_BOOL(&holder, 1); \ @@ -368,66 +368,66 @@ try_again: /* }}} */ -ZEND_API void convert_to_long(zval *op) /* {{{ */ +ZEND_API void convert_to_int(zval *op) /* {{{ */ { - if (Z_TYPE_P(op) != IS_LONG) { - convert_to_long_base(op, 10); + if (Z_TYPE_P(op) != IS_INT) { + convert_to_int_base(op, 10); } } /* }}} */ -ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ +ZEND_API void convert_to_int_base(zval *op, int base) /* {{{ */ { - long tmp; + zend_int_t tmp; switch (Z_TYPE_P(op)) { case IS_NULL: case IS_FALSE: - ZVAL_LONG(op, 0); + ZVAL_INT(op, 0); break; case IS_TRUE: - ZVAL_LONG(op, 1); + ZVAL_INT(op, 1); break; case IS_RESOURCE: { - long l = Z_RES_HANDLE_P(op); + zend_int_t l = Z_RES_HANDLE_P(op); zval_ptr_dtor(op); - ZVAL_LONG(op, l); + ZVAL_INT(op, l); } /* break missing intentionally */ - Z_TYPE_INFO_P(op) = IS_LONG; + Z_TYPE_INFO_P(op) = IS_INT; break; - case IS_LONG: + case IS_INT: break; case IS_DOUBLE: - ZVAL_LONG(op, zend_dval_to_lval(Z_DVAL_P(op))); + ZVAL_INT(op, zend_dval_to_ival(Z_DVAL_P(op))); break; case IS_STRING: { zend_string *str = Z_STR_P(op); - ZVAL_LONG(op, strtol(str->val, NULL, base)); + ZVAL_INT(op, strtol(str->val, NULL, base)); STR_RELEASE(str); } break; case IS_ARRAY: tmp = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); zval_dtor(op); - ZVAL_LONG(op, tmp); + ZVAL_INT(op, tmp); break; case IS_OBJECT: { zval dst; TSRMLS_FETCH(); - convert_object_to_type(op, &dst, IS_LONG, convert_to_long); + convert_object_to_type(op, &dst, IS_INT, convert_to_int); zval_dtor(op); - if (Z_TYPE(dst) == IS_LONG) { + if (Z_TYPE(dst) == IS_INT) { ZVAL_COPY_VALUE(op, &dst); } else { zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name->val); - ZVAL_LONG(op, 1); + ZVAL_INT(op, 1); } return; } @@ -454,8 +454,8 @@ ZEND_API void convert_to_double(zval *op) /* {{{ */ ZVAL_DOUBLE(op, d); } break; - case IS_LONG: - ZVAL_DOUBLE(op, (double) Z_LVAL_P(op)); + case IS_INT: + ZVAL_DOUBLE(op, (double) Z_IVAL_P(op)); break; case IS_DOUBLE: break; @@ -527,14 +527,14 @@ ZEND_API void convert_to_boolean(zval *op) /* {{{ */ ZVAL_BOOL(op, 0); break; case IS_RESOURCE: { - long l = (Z_RES_HANDLE_P(op) ? 1 : 0); + zend_int_t l = (Z_RES_HANDLE_P(op) ? 1 : 0); zval_ptr_dtor(op); ZVAL_BOOL(op, l); } break; - case IS_LONG: - ZVAL_BOOL(op, Z_LVAL_P(op) ? 1 : 0); + case IS_INT: + ZVAL_BOOL(op, Z_IVAL_P(op) ? 1 : 0); break; case IS_DOUBLE: ZVAL_BOOL(op, Z_DVAL_P(op) ? 1 : 0); @@ -598,13 +598,13 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ case IS_STRING: break; case IS_RESOURCE: { - char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG]; + char buf[sizeof("Resource id #") + MAX_LENGTH_OF_ZEND_INT]; int len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(op)); ZVAL_NEW_STR(op, STR_INIT(buf, len, 0)); break; } - case IS_LONG: { - ZVAL_NEW_STR(op, zend_long_to_str(Z_LVAL_P(op))); + case IS_INT: { + ZVAL_NEW_STR(op, zend_long_to_str(Z_IVAL_P(op))); break; } case IS_DOUBLE: { @@ -736,7 +736,7 @@ ZEND_API void convert_to_object(zval *op) /* {{{ */ } /* }}} */ -ZEND_API void multi_convert_to_long_ex(int argc, ...) /* {{{ */ +ZEND_API void multi_convert_to_int_ex(int argc, ...) /* {{{ */ { zval *arg; va_list ap; @@ -745,7 +745,7 @@ ZEND_API void multi_convert_to_long_ex(int argc, ...) /* {{{ */ while (argc--) { arg = va_arg(ap, zval *); - convert_to_long_ex(arg); + convert_to_int_ex(arg); } va_end(ap); @@ -784,7 +784,7 @@ ZEND_API void multi_convert_to_string_ex(int argc, ...) /* {{{ */ } /* }}} */ -ZEND_API long _zval_get_long_func(zval *op TSRMLS_DC) /* {{{ */ +ZEND_API zend_int_t _zval_get_long_func(zval *op TSRMLS_DC) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -795,20 +795,20 @@ try_again: return 1; case IS_RESOURCE: return Z_RES_HANDLE_P(op); - case IS_LONG: - return Z_LVAL_P(op); + case IS_INT: + return Z_IVAL_P(op); case IS_DOUBLE: - return zend_dval_to_lval(Z_DVAL_P(op)); + return zend_dval_to_ival(Z_DVAL_P(op)); case IS_STRING: - return strtol(Z_STRVAL_P(op), NULL, 10); + return ZEND_STRTOI(Z_STRVAL_P(op), NULL, 10); case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? 1 : 0; case IS_OBJECT: { zval dst; - convert_object_to_type(op, &dst, IS_LONG, convert_to_long); - if (Z_TYPE(dst) == IS_LONG) { - return Z_LVAL(dst); + convert_object_to_type(op, &dst, IS_INT, convert_to_int); + if (Z_TYPE(dst) == IS_INT) { + return Z_IVAL(dst); } else { zend_error(E_NOTICE, "Object of class %s could not be converted to int", Z_OBJCE_P(op)->name->val); return 1; @@ -834,8 +834,8 @@ try_again: return 1.0; case IS_RESOURCE: return (double) Z_RES_HANDLE_P(op); - case IS_LONG: - return (double) Z_LVAL_P(op); + case IS_INT: + return (double) Z_IVAL_P(op); case IS_DOUBLE: return Z_DVAL_P(op); case IS_STRING: @@ -876,14 +876,14 @@ try_again: case IS_TRUE: return STR_INIT("1", 1, 0); case IS_RESOURCE: { - char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG]; + char buf[sizeof("Resource id #") + MAX_LENGTH_OF_ZEND_INT]; int len; len = snprintf(buf, sizeof(buf), "Resource id #%ld", Z_RES_HANDLE_P(op)); return STR_INIT(buf, len, 0); } - case IS_LONG: { - return zend_long_to_str(Z_LVAL_P(op)); + case IS_INT: { + return zend_long_to_str(Z_IVAL_P(op)); } case IS_DOUBLE: { return zend_strpprintf(0, "%.*G", (int) EG(precision), Z_DVAL_P(op)); @@ -925,26 +925,26 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): { - long lval = Z_LVAL_P(op1) + Z_LVAL_P(op2); + case TYPE_PAIR(IS_INT, IS_INT): { + zend_int_t lval = Z_IVAL_P(op1) + Z_IVAL_P(op2); /* check for overflow by comparing sign bits */ - if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK) - && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) { + if ((Z_IVAL_P(op1) & LONG_SIGN_MASK) == (Z_IVAL_P(op2) & LONG_SIGN_MASK) + && (Z_IVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) { - ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2)); + ZVAL_DOUBLE(result, (double) Z_IVAL_P(op1) + (double) Z_IVAL_P(op2)); } else { - ZVAL_LONG(result, lval); + ZVAL_INT(result, lval); } return SUCCESS; } - case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2)); + case TYPE_PAIR(IS_INT, IS_DOUBLE): + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) + Z_DVAL_P(op2)); return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2))); + case TYPE_PAIR(IS_DOUBLE, IS_INT): + ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_IVAL_P(op2))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): @@ -989,26 +989,26 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): { - long lval = Z_LVAL_P(op1) - Z_LVAL_P(op2); + case TYPE_PAIR(IS_INT, IS_INT): { + zend_int_t lval = Z_IVAL_P(op1) - Z_IVAL_P(op2); /* check for overflow by comparing sign bits */ - if ((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK) - && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) { + if ((Z_IVAL_P(op1) & LONG_SIGN_MASK) != (Z_IVAL_P(op2) & LONG_SIGN_MASK) + && (Z_IVAL_P(op1) & LONG_SIGN_MASK) != (lval & LONG_SIGN_MASK)) { - ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2)); + ZVAL_DOUBLE(result, (double) Z_IVAL_P(op1) - (double) Z_IVAL_P(op2)); } else { - ZVAL_LONG(result, lval); + ZVAL_INT(result, lval); } return SUCCESS; } - case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2)); + case TYPE_PAIR(IS_INT, IS_DOUBLE): + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) - Z_DVAL_P(op2)); return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2))); + case TYPE_PAIR(IS_DOUBLE, IS_INT): + ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_IVAL_P(op2))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): @@ -1042,20 +1042,20 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): { - long overflow; + case TYPE_PAIR(IS_INT, IS_INT): { + zend_int_t overflow; - ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1),Z_LVAL_P(op2), Z_LVAL_P(result),Z_DVAL_P(result),overflow); - Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG; + ZEND_SIGNED_MULTIPLY_INT(Z_IVAL_P(op1),Z_IVAL_P(op2), Z_IVAL_P(result),Z_DVAL_P(result),overflow); + Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_INT; return SUCCESS; } - case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2)); + case TYPE_PAIR(IS_INT, IS_DOUBLE): + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) * Z_DVAL_P(op2)); return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2))); + case TYPE_PAIR(IS_DOUBLE, IS_INT): + ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_IVAL_P(op2))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): @@ -1089,32 +1089,32 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): - if (Z_LVAL_P(op2) >= 0) { - long l1 = 1, l2 = Z_LVAL_P(op1), i = Z_LVAL_P(op2); + case TYPE_PAIR(IS_INT, IS_INT): + if (Z_IVAL_P(op2) >= 0) { + zend_int_t l1 = 1, l2 = Z_IVAL_P(op1), i = Z_IVAL_P(op2); if (i == 0) { - ZVAL_LONG(result, 1L); + ZVAL_INT(result, 1L); return SUCCESS; } else if (l2 == 0) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; } while (i >= 1) { - long overflow; + zend_int_t overflow; double dval = 0.0; if (i % 2) { --i; - ZEND_SIGNED_MULTIPLY_LONG(l1, l2, l1, dval, overflow); + ZEND_SIGNED_MULTIPLY_INT(l1, l2, l1, dval, overflow); if (overflow) { ZVAL_DOUBLE(result, dval * pow(l2, i)); return SUCCESS; } } else { i /= 2; - ZEND_SIGNED_MULTIPLY_LONG(l2, l2, l2, dval, overflow); + ZEND_SIGNED_MULTIPLY_INT(l2, l2, l2, dval, overflow); if (overflow) { ZVAL_DOUBLE(result, (double)l1 * pow(dval, i)); return SUCCESS; @@ -1122,18 +1122,18 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * } } /* i == 0 */ - ZVAL_LONG(result, l1); + ZVAL_INT(result, l1); } else { - ZVAL_DOUBLE(result, pow((double)Z_LVAL_P(op1), (double)Z_LVAL_P(op2))); + ZVAL_DOUBLE(result, pow((double)Z_IVAL_P(op1), (double)Z_IVAL_P(op2))); } return SUCCESS; - case TYPE_PAIR(IS_LONG, IS_DOUBLE): - ZVAL_DOUBLE(result, pow((double)Z_LVAL_P(op1), Z_DVAL_P(op2))); + case TYPE_PAIR(IS_INT, IS_DOUBLE): + ZVAL_DOUBLE(result, pow((double)Z_IVAL_P(op1), Z_DVAL_P(op2))); return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - ZVAL_DOUBLE(result, pow(Z_DVAL_P(op1), (double)Z_LVAL_P(op2))); + case TYPE_PAIR(IS_DOUBLE, IS_INT): + ZVAL_DOUBLE(result, pow(Z_DVAL_P(op1), (double)Z_IVAL_P(op2))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): @@ -1149,13 +1149,13 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_POW); if (Z_TYPE_P(op1) == IS_ARRAY) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; } else { zendi_convert_scalar_to_number(op1, op1_copy, result); } if (Z_TYPE_P(op2) == IS_ARRAY) { - ZVAL_LONG(result, 1L); + ZVAL_INT(result, 1L); return SUCCESS; } else { zendi_convert_scalar_to_number(op2, op2_copy, result); @@ -1177,39 +1177,39 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): - if (Z_LVAL_P(op2) == 0) { + case TYPE_PAIR(IS_INT, IS_INT): + if (Z_IVAL_P(op2) == 0) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ - } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) { + } else if (Z_IVAL_P(op2) == -1 && Z_IVAL_P(op1) == ZEND_INT_MIN) { /* Prevent overflow error/crash */ - ZVAL_DOUBLE(result, (double) LONG_MIN / -1); + ZVAL_DOUBLE(result, (double) ZEND_INT_MIN / -1); return SUCCESS; } - if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */ - ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2)); + if (Z_IVAL_P(op1) % Z_IVAL_P(op2) == 0) { /* integer */ + ZVAL_INT(result, Z_IVAL_P(op1) / Z_IVAL_P(op2)); } else { - ZVAL_DOUBLE(result, ((double) Z_LVAL_P(op1)) / Z_LVAL_P(op2)); + ZVAL_DOUBLE(result, ((double) Z_IVAL_P(op1)) / Z_IVAL_P(op2)); } return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - if (Z_LVAL_P(op2) == 0) { + case TYPE_PAIR(IS_DOUBLE, IS_INT): + if (Z_IVAL_P(op2) == 0) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ } - ZVAL_DOUBLE(result, Z_DVAL_P(op1) / (double)Z_LVAL_P(op2)); + ZVAL_DOUBLE(result, Z_DVAL_P(op1) / (double)Z_IVAL_P(op2)); return SUCCESS; - case TYPE_PAIR(IS_LONG, IS_DOUBLE): + case TYPE_PAIR(IS_INT, IS_DOUBLE): if (Z_DVAL_P(op2) == 0) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ } - ZVAL_DOUBLE(result, (double)Z_LVAL_P(op1) / Z_DVAL_P(op2)); + ZVAL_DOUBLE(result, (double)Z_IVAL_P(op1) / Z_DVAL_P(op2)); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): @@ -1244,31 +1244,31 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MOD); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - if (Z_LVAL_P(op2) == 0) { + if (Z_IVAL_P(op2) == 0) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* modulus by zero */ } - if (Z_LVAL_P(op2) == -1) { + if (Z_IVAL_P(op2) == -1) { /* Prevent overflow error/crash if op1==LONG_MIN */ - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; } - ZVAL_LONG(result, op1_lval % Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval % Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1276,7 +1276,7 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if ((Z_TYPE_P(op1) != IS_FALSE && Z_TYPE_P(op1) != IS_TRUE) || (Z_TYPE_P(op2) != IS_FALSE && Z_TYPE_P(op2) != IS_TRUE)) { @@ -1317,18 +1317,18 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ { switch (Z_TYPE_P(op1)) { - case IS_LONG: - ZVAL_LONG(result, ~Z_LVAL_P(op1)); + case IS_INT: + ZVAL_INT(result, ~Z_IVAL_P(op1)); return SUCCESS; case IS_DOUBLE: - ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1))); + ZVAL_INT(result, ~zend_dval_to_ival(Z_DVAL_P(op1))); return SUCCESS; case IS_STRING: { - int i; + zend_size_t i; zval op1_copy = *op1; - ZVAL_NEW_STR(result, STR_ALLOC(Z_STRLEN(op1_copy), 0)); - for (i = 0; i < Z_STRLEN(op1_copy); i++) { + ZVAL_NEW_STR(result, STR_ALLOC(Z_STRSIZE(op1_copy), 0)); + for (i = 0; i < Z_STRSIZE(op1_copy); i++) { Z_STRVAL_P(result)[i] = ~Z_STRVAL(op1_copy)[i]; } Z_STRVAL_P(result)[i] = 0; @@ -1346,14 +1346,14 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; zend_string *str; - int i; + zend_size_t i; - if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) >= Z_STRSIZE_P(op2)) { longer = op1; shorter = op2; } else { @@ -1361,11 +1361,11 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / shorter = op1; } - str = STR_ALLOC(Z_STRLEN_P(longer), 0); - for (i = 0; i < Z_STRLEN_P(shorter); i++) { + str = STR_ALLOC(Z_STRSIZE_P(longer), 0); + for (i = 0; i < Z_STRSIZE_P(shorter); i++) { str->val[i] = Z_STRVAL_P(longer)[i] | Z_STRVAL_P(shorter)[i]; } - memcpy(str->val + i, Z_STRVAL_P(longer) + i, Z_STRLEN_P(longer) - i + 1); + memcpy(str->val + i, Z_STRVAL_P(longer) + i, Z_STRSIZE_P(longer) - i + 1); if (result==op1) { STR_RELEASE(Z_STR_P(result)); } @@ -1373,17 +1373,17 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / return SUCCESS; } - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_OR); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - ZVAL_LONG(result, op1_lval | Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval | Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1391,14 +1391,14 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; zend_string *str; - int i; + zend_size_t i; - if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) >= Z_STRSIZE_P(op2)) { longer = op1; shorter = op2; } else { @@ -1406,8 +1406,8 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) shorter = op1; } - str = STR_ALLOC(Z_STRLEN_P(shorter), 0); - for (i = 0; i < Z_STRLEN_P(shorter); i++) { + str = STR_ALLOC(Z_STRSIZE_P(shorter), 0); + for (i = 0; i < Z_STRSIZE_P(shorter); i++) { str->val[i] = Z_STRVAL_P(shorter)[i] & Z_STRVAL_P(longer)[i]; } str->val[i] = 0; @@ -1418,17 +1418,17 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) return SUCCESS; } - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_AND); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - ZVAL_LONG(result, op1_lval & Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval & Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1436,14 +1436,14 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; zend_string *str; - int i; + zend_size_t i; - if (Z_STRLEN_P(op1) >= Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) >= Z_STRSIZE_P(op2)) { longer = op1; shorter = op2; } else { @@ -1451,8 +1451,8 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) shorter = op1; } - str = STR_ALLOC(Z_STRLEN_P(shorter), 0); - for (i = 0; i < Z_STRLEN_P(shorter); i++) { + str = STR_ALLOC(Z_STRSIZE_P(shorter), 0); + for (i = 0; i < Z_STRSIZE_P(shorter); i++) { str->val[i] = Z_STRVAL_P(shorter)[i] ^ Z_STRVAL_P(longer)[i]; } str->val[i] = 0; @@ -1463,17 +1463,17 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) return SUCCESS; } - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_BW_XOR); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - ZVAL_LONG(result, op1_lval ^ Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval ^ Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1481,19 +1481,19 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SL); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - ZVAL_LONG(result, op1_lval << Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval << Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1501,19 +1501,19 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; - if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { + if (Z_TYPE_P(op1) != IS_INT || Z_TYPE_P(op2) != IS_INT) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SR); - zendi_convert_to_long(op1, op1_copy, result); - op1_lval = Z_LVAL_P(op1); - zendi_convert_to_long(op2, op2_copy, result); + zendi_convert_to_int(op1, op1_copy, result); + op1_lval = Z_IVAL_P(op1); + zendi_convert_to_int(op2, op2_copy, result); } else { - op1_lval = Z_LVAL_P(op1); + op1_lval = Z_IVAL_P(op1); } - ZVAL_LONG(result, op1_lval >> Z_LVAL_P(op2)); + ZVAL_INT(result, op1_lval >> Z_IVAL_P(op2)); return SUCCESS; } /* }}} */ @@ -1521,10 +1521,10 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* must support result==op1 */ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */ { - int length = Z_STRLEN_P(op1) + 1; + zend_size_t length = Z_STRSIZE_P(op1) + 1; zend_string *buf = STR_REALLOC(Z_STR_P(op1), length, 0); - buf->val[length - 1] = (char) Z_LVAL_P(op2); + buf->val[length - 1] = (char) Z_IVAL_P(op2); buf->val[length] = 0; ZVAL_NEW_STR(result, buf); return SUCCESS; @@ -1534,11 +1534,11 @@ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2) /* must support result==op1 */ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */ { - int op1_len = Z_STRLEN_P(op1); - int length = op1_len + Z_STRLEN_P(op2); + zend_size_t op1_len = Z_STRSIZE_P(op1); + zend_size_t length = op1_len + Z_STRSIZE_P(op2); zend_string *buf = STR_REALLOC(Z_STR_P(op1), length, 0); - memcpy(buf->val + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); + memcpy(buf->val + op1_len, Z_STRVAL_P(op2), Z_STRSIZE_P(op2)); buf->val[length] = 0; ZVAL_NEW_STR(result, buf); return SUCCESS; @@ -1576,11 +1576,11 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{ } if (result==op1 && !IS_INTERNED(Z_STR_P(op1))) { /* special case, perform operations on result */ - uint op1_len = Z_STRLEN_P(op1); - uint op2_len = Z_STRLEN_P(op2); - uint res_len = op1_len + op2_len; + zend_size_t op1_len = Z_STRSIZE_P(op1); + zend_size_t op2_len = Z_STRSIZE_P(op2); + zend_size_t res_len = op1_len + op2_len; - if (Z_STRLEN_P(result) < 0 || (int) (op1_len + op2_len) < 0) { + if (Z_STRSIZE_P(result) < 0 || (zend_size_t) (op1_len + op2_len) < 0) { ZVAL_EMPTY_STRING(result); zend_error(E_ERROR, "String size overflow"); } @@ -1590,11 +1590,11 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{ memcpy(Z_STRVAL_P(result) + op1_len, Z_STRVAL_P(op2), op2_len); Z_STRVAL_P(result)[res_len]=0; } else { - int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); + zend_size_t length = Z_STRSIZE_P(op1) + Z_STRSIZE_P(op2); zend_string *buf = STR_ALLOC(length, 0); - memcpy(buf->val, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); - memcpy(buf->val + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); + memcpy(buf->val, Z_STRVAL_P(op1), Z_STRSIZE_P(op1)); + memcpy(buf->val + Z_STRSIZE_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op2)); buf->val[length] = 0; ZVAL_NEW_STR(result, buf); } @@ -1614,9 +1614,9 @@ ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend zend_string *str2 = zval_get_string(op2); if (case_insensitive) { - ZVAL_LONG(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len)); + ZVAL_INT(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len)); } else { - ZVAL_LONG(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len)); + ZVAL_INT(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len)); } STR_RELEASE(str1); @@ -1630,15 +1630,15 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) && EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { if (Z_STR_P(op1) == Z_STR_P(op2)) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); } else { - ZVAL_LONG(result, zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2))); + ZVAL_INT(result, zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op2))); } } else { zend_string *str1 = zval_get_string(op1); zend_string *str2 = zval_get_string(op2); - ZVAL_LONG(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len)); + ZVAL_INT(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len)); STR_RELEASE(str1); STR_RELEASE(str2); @@ -1652,15 +1652,15 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR if (EXPECTED(Z_TYPE_P(op1) == IS_STRING) && EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { if (Z_STR_P(op1) == Z_STR_P(op2)) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); } else { - ZVAL_LONG(result, zend_binary_strcasecmp_l(Z_STRVAL_P(op1), Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2))); + ZVAL_INT(result, zend_binary_strcasecmp_l(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op2))); } } else { zend_string *str1 = zval_get_string(op1); zend_string *str2 = zval_get_string(op2); - ZVAL_LONG(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len)); + ZVAL_INT(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len)); STR_RELEASE(str1); STR_RELEASE(str2); @@ -1675,7 +1675,7 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T zend_string *str1 = zval_get_string(op1); zend_string *str2 = zval_get_string(op2); - ZVAL_LONG(result, strcoll(str1->val, str2->val)); + ZVAL_INT(result, strcoll(str1->val, str2->val)); STR_RELEASE(str1); STR_RELEASE(str2); @@ -1691,7 +1691,7 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_ d1 = zval_get_double(op1); d2 = zval_get_double(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(d1 - d2)); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(d1 - d2)); return SUCCESS; } @@ -1718,26 +1718,26 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { while (1) { switch (TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2))) { - case TYPE_PAIR(IS_LONG, IS_LONG): - ZVAL_LONG(result, Z_LVAL_P(op1)>Z_LVAL_P(op2)?1:(Z_LVAL_P(op1)<Z_LVAL_P(op2)?-1:0)); + case TYPE_PAIR(IS_INT, IS_INT): + ZVAL_INT(result, Z_IVAL_P(op1)>Z_IVAL_P(op2)?1:(Z_IVAL_P(op1)<Z_IVAL_P(op2)?-1:0)); return SUCCESS; - case TYPE_PAIR(IS_DOUBLE, IS_LONG): - Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_LVAL_P(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); + case TYPE_PAIR(IS_DOUBLE, IS_INT): + Z_DVAL_P(result) = Z_DVAL_P(op1) - (double)Z_IVAL_P(op2); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; - case TYPE_PAIR(IS_LONG, IS_DOUBLE): - Z_DVAL_P(result) = (double)Z_LVAL_P(op1) - Z_DVAL_P(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); + case TYPE_PAIR(IS_INT, IS_DOUBLE): + Z_DVAL_P(result) = (double)Z_IVAL_P(op1) - Z_DVAL_P(op2); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); return SUCCESS; case TYPE_PAIR(IS_DOUBLE, IS_DOUBLE): if (Z_DVAL_P(op1) == Z_DVAL_P(op2)) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); } else { Z_DVAL_P(result) = Z_DVAL_P(op1) - Z_DVAL_P(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); } return SUCCESS; @@ -1750,39 +1750,39 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { case TYPE_PAIR(IS_FALSE, IS_NULL): case TYPE_PAIR(IS_FALSE, IS_FALSE): case TYPE_PAIR(IS_TRUE, IS_TRUE): - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; case TYPE_PAIR(IS_NULL, IS_TRUE): - ZVAL_LONG(result, -1); + ZVAL_INT(result, -1); return SUCCESS; case TYPE_PAIR(IS_TRUE, IS_NULL): - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); return SUCCESS; case TYPE_PAIR(IS_STRING, IS_STRING): if (Z_STR_P(op1) == Z_STR_P(op2)) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; } zendi_smart_strcmp(result, op1, op2); return SUCCESS; case TYPE_PAIR(IS_NULL, IS_STRING): - ZVAL_LONG(result, Z_STRLEN_P(op2) == 0 ? 0 : -1); + ZVAL_INT(result, Z_STRSIZE_P(op2) == 0 ? 0 : -1); return SUCCESS; case TYPE_PAIR(IS_STRING, IS_NULL): - ZVAL_LONG(result, Z_STRLEN_P(op1) == 0 ? 0 : 1); + ZVAL_INT(result, Z_STRSIZE_P(op1) == 0 ? 0 : 1); return SUCCESS; case TYPE_PAIR(IS_OBJECT, IS_NULL): - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); return SUCCESS; case TYPE_PAIR(IS_NULL, IS_OBJECT): - ZVAL_LONG(result, -1); + ZVAL_INT(result, -1); return SUCCESS; default: @@ -1803,11 +1803,11 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { if (Z_TYPE_P(op1) == IS_OBJECT && Z_TYPE_P(op2) == IS_OBJECT) { if (Z_OBJ_P(op1) == Z_OBJ_P(op2)) { /* object handles are identical, apparently this is the same object */ - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return SUCCESS; } if (Z_OBJ_HANDLER_P(op1, compare_objects) == Z_OBJ_HANDLER_P(op2, compare_objects)) { - ZVAL_LONG(result, Z_OBJ_HANDLER_P(op1, compare_objects)(op1, op2 TSRMLS_CC)); + ZVAL_INT(result, Z_OBJ_HANDLER_P(op1, compare_objects)(op1, op2 TSRMLS_CC)); return SUCCESS; } } @@ -1821,7 +1821,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { } else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) { ZVAL_UNDEF(&tmp_free); if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, ((Z_TYPE_P(op2) == IS_FALSE || Z_TYPE_P(op2) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op2)) TSRMLS_CC) == FAILURE) { - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); zend_free_obj_get_result(&tmp_free TSRMLS_CC); return SUCCESS; } @@ -1840,7 +1840,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { } else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) { ZVAL_UNDEF(&tmp_free); if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, ((Z_TYPE_P(op1) == IS_FALSE || Z_TYPE_P(op1) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op1)) TSRMLS_CC) == FAILURE) { - ZVAL_LONG(result, -1); + ZVAL_INT(result, -1); zend_free_obj_get_result(&tmp_free TSRMLS_CC); return SUCCESS; } @@ -1848,26 +1848,26 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { zend_free_obj_get_result(&tmp_free TSRMLS_CC); return ret; } else if (Z_TYPE_P(op1) == IS_OBJECT) { - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); return SUCCESS; } } if (!converted) { if (Z_TYPE_P(op1) == IS_NULL || Z_TYPE_P(op1) == IS_FALSE) { zendi_convert_to_boolean(op2, op2_copy, result); - ZVAL_LONG(result, (Z_TYPE_P(op2) == IS_TRUE) ? -1 : 0); + ZVAL_INT(result, (Z_TYPE_P(op2) == IS_TRUE) ? -1 : 0); return SUCCESS; } else if (Z_TYPE_P(op2) == IS_NULL || Z_TYPE_P(op2) == IS_FALSE) { zendi_convert_to_boolean(op1, op1_copy, result); - ZVAL_LONG(result, (Z_TYPE_P(op1) == IS_TRUE) ? 1 : 0); + ZVAL_INT(result, (Z_TYPE_P(op1) == IS_TRUE) ? 1 : 0); return SUCCESS; } else if (Z_TYPE_P(op1) == IS_TRUE) { zendi_convert_to_boolean(op2, op2_copy, result); - ZVAL_LONG(result, (Z_TYPE_P(op2) == IS_TRUE) ? 0 : 1); + ZVAL_INT(result, (Z_TYPE_P(op2) == IS_TRUE) ? 0 : 1); return SUCCESS; } else if (Z_TYPE_P(op2) == IS_TRUE) { zendi_convert_to_boolean(op1, op1_copy, result); - ZVAL_LONG(result, (Z_TYPE_P(op1) == IS_TRUE) ? 0 : -1); + ZVAL_INT(result, (Z_TYPE_P(op1) == IS_TRUE) ? 0 : -1); return SUCCESS; } else { zendi_convert_scalar_to_number(op1, op1_copy, result); @@ -1875,19 +1875,19 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* { converted = 1; } } else if (Z_TYPE_P(op1)==IS_ARRAY) { - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); return SUCCESS; } else if (Z_TYPE_P(op2)==IS_ARRAY) { - ZVAL_LONG(result, -1); + ZVAL_INT(result, -1); return SUCCESS; } else if (Z_TYPE_P(op1)==IS_OBJECT) { - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); return SUCCESS; } else if (Z_TYPE_P(op2)==IS_OBJECT) { - ZVAL_LONG(result, -1); + ZVAL_INT(result, -1); return SUCCESS; } else { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return FAILURE; } } @@ -1925,8 +1925,8 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) case IS_TRUE: ZVAL_BOOL(result, 1); break; - case IS_LONG: - ZVAL_BOOL(result, Z_LVAL_P(op1) == Z_LVAL_P(op2)); + case IS_INT: + ZVAL_BOOL(result, Z_IVAL_P(op1) == Z_IVAL_P(op2)); break; case IS_RESOURCE: ZVAL_BOOL(result, Z_RES_P(op1) == Z_RES_P(op2)); @@ -1938,8 +1938,8 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) if (Z_STR_P(op1) == Z_STR_P(op2)) { ZVAL_BOOL(result, 1); } else { - ZVAL_BOOL(result, (Z_STRLEN_P(op1) == Z_STRLEN_P(op2)) - && (!memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)))); + ZVAL_BOOL(result, (Z_STRSIZE_P(op1) == Z_STRSIZE_P(op2)) + && (!memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op1)))); } break; case IS_ARRAY: @@ -1976,7 +1976,7 @@ ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { return FAILURE; } - ZVAL_BOOL(result, (Z_LVAL_P(result) == 0)); + ZVAL_BOOL(result, (Z_IVAL_P(result) == 0)); return SUCCESS; } /* }}} */ @@ -1986,7 +1986,7 @@ ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { return FAILURE; } - ZVAL_BOOL(result, (Z_LVAL_P(result) != 0)); + ZVAL_BOOL(result, (Z_IVAL_P(result) != 0)); return SUCCESS; } /* }}} */ @@ -1996,7 +1996,7 @@ ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { return FAILURE; } - ZVAL_BOOL(result, (Z_LVAL_P(result) < 0)); + ZVAL_BOOL(result, (Z_IVAL_P(result) < 0)); return SUCCESS; } /* }}} */ @@ -2006,7 +2006,7 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) { return FAILURE; } - ZVAL_BOOL(result, (Z_LVAL_P(result) <= 0)); + ZVAL_BOOL(result, (Z_IVAL_P(result) <= 0)); return SUCCESS; } /* }}} */ @@ -2046,13 +2046,13 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons static void increment_string(zval *str) /* {{{ */ { int carry=0; - int pos=Z_STRLEN_P(str)-1; + zend_size_t pos=Z_STRSIZE_P(str)-1; char *s; zend_string *t; int last=0; /* Shut up the compiler warning */ int ch; - if (Z_STRLEN_P(str) == 0) { + if (Z_STRSIZE_P(str) == 0) { STR_RELEASE(Z_STR_P(str)); Z_STR_P(str) = STR_INIT("1", sizeof("1")-1, 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; @@ -2060,11 +2060,11 @@ static void increment_string(zval *str) /* {{{ */ } if (IS_INTERNED(Z_STR_P(str))) { - Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0); + Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRSIZE_P(str), 0); Z_TYPE_INFO_P(str) = IS_STRING_EX; } else if (Z_REFCOUNT_P(str) > 1) { Z_DELREF_P(str); - Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRLEN_P(str), 0); + Z_STR_P(str) = STR_INIT(Z_STRVAL_P(str), Z_STRSIZE_P(str), 0); } else { STR_FORGET_HASH_VAL(Z_STR_P(str)); } @@ -2110,9 +2110,9 @@ static void increment_string(zval *str) /* {{{ */ } if (carry) { - t = STR_ALLOC(Z_STRLEN_P(str)+1, 0); - memcpy(t->val + 1, Z_STRVAL_P(str), Z_STRLEN_P(str)); - t->val[Z_STRLEN_P(str) + 1] = '\0'; + t = STR_ALLOC(Z_STRSIZE_P(str)+1, 0); + memcpy(t->val + 1, Z_STRVAL_P(str), Z_STRSIZE_P(str)); + t->val[Z_STRSIZE_P(str) + 1] = '\0'; switch (last) { case NUMERIC: t->val[0] = '1'; @@ -2134,34 +2134,34 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { - case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MAX) { + case IS_INT: + if (Z_IVAL_P(op1) == ZEND_INT_MAX) { /* switch to double */ - double d = (double)Z_LVAL_P(op1); + double d = (double)Z_IVAL_P(op1); ZVAL_DOUBLE(op1, d+1); } else { - Z_LVAL_P(op1)++; + Z_IVAL_P(op1)++; } break; case IS_DOUBLE: Z_DVAL_P(op1) = Z_DVAL_P(op1) + 1; break; case IS_NULL: - ZVAL_LONG(op1, 1); + ZVAL_INT(op1, 1); break; case IS_STRING: { - long lval; + zend_int_t lval; double dval; - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) { - case IS_LONG: + switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { + case IS_INT: STR_RELEASE(Z_STR_P(op1)); - if (lval == LONG_MAX) { + if (lval == ZEND_INT_MAX) { /* switch to double */ double d = (double)lval; ZVAL_DOUBLE(op1, d+1); } else { - ZVAL_LONG(op1, lval+1); + ZVAL_INT(op1, lval+1); } break; case IS_DOUBLE: @@ -2181,7 +2181,7 @@ try_again: int res; TSRMLS_FETCH(); - ZVAL_LONG(&op2, 1); + ZVAL_INT(&op2, 1); res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_ADD, op1, op1, &op2 TSRMLS_CC); zval_ptr_dtor(&op2); @@ -2200,36 +2200,36 @@ try_again: ZEND_API int decrement_function(zval *op1) /* {{{ */ { - long lval; + zend_int_t lval; double dval; try_again: switch (Z_TYPE_P(op1)) { - case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MIN) { - double d = (double)Z_LVAL_P(op1); + case IS_INT: + if (Z_IVAL_P(op1) == ZEND_INT_MIN) { + double d = (double)Z_IVAL_P(op1); ZVAL_DOUBLE(op1, d-1); } else { - Z_LVAL_P(op1)--; + Z_IVAL_P(op1)--; } break; case IS_DOUBLE: Z_DVAL_P(op1) = Z_DVAL_P(op1) - 1; break; case IS_STRING: /* Like perl we only support string increment */ - if (Z_STRLEN_P(op1) == 0) { /* consider as 0 */ + if (Z_STRSIZE_P(op1) == 0) { /* consider as 0 */ STR_RELEASE(Z_STR_P(op1)); - ZVAL_LONG(op1, -1); + ZVAL_INT(op1, -1); break; } - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) { - case IS_LONG: + switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { + case IS_INT: STR_RELEASE(Z_STR_P(op1)); - if (lval == LONG_MIN) { + if (lval == ZEND_INT_MIN) { double d = (double)lval; ZVAL_DOUBLE(op1, d-1); } else { - ZVAL_LONG(op1, lval-1); + ZVAL_INT(op1, lval-1); } break; case IS_DOUBLE: @@ -2244,7 +2244,7 @@ try_again: int res; TSRMLS_FETCH(); - ZVAL_LONG(&op2, 1); + ZVAL_INT(&op2, 1); res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_SUB, op1, op1, &op2 TSRMLS_CC); zval_ptr_dtor(&op2); @@ -2277,7 +2277,7 @@ ZEND_API void zend_update_current_locale(void) /* {{{ */ /* }}} */ #endif -ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length) /* {{{ */ +ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, zend_size_t length) /* {{{ */ { register unsigned char *str = (unsigned char*)source; register unsigned char *result = (unsigned char*)dest; @@ -2292,13 +2292,13 @@ ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned in } /* }}} */ -ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length) /* {{{ */ +ZEND_API char *zend_str_tolower_dup(const char *source, zend_size_t length) /* {{{ */ { return zend_str_tolower_copy((char *)emalloc(length+1), source, length); } /* }}} */ -ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */ +ZEND_API void zend_str_tolower(char *str, zend_size_t length) /* {{{ */ { register unsigned char *p = (unsigned char*)str; register unsigned char *end = p + length; @@ -2310,7 +2310,7 @@ ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */ } /* }}} */ -ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */ +ZEND_API int zend_binary_strcmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2) /* {{{ */ { int retval; @@ -2319,14 +2319,20 @@ ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint } retval = memcmp(s1, s2, MIN(len1, len2)); if (!retval) { - return (len1 - len2); - } else { - return retval; + if (len1 > len2) { + retval = 1; + } else if (len1 < len2) { + retval = -1; + } else { + retval = 0; + } } + + return retval; } /* }}} */ -ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ +ZEND_API int zend_binary_strncmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length) /* {{{ */ { int retval; @@ -2335,16 +2341,22 @@ ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint } retval = memcmp(s1, s2, MIN(length, MIN(len1, len2))); if (!retval) { - return (MIN(length, len1) - MIN(length, len2)); - } else { - return retval; + if (MIN(length, len1) > MIN(length, len2)) { + retval = 1; + } else if (MIN(length, len1) < MIN(length, len2)) { + retval = -1; + } else { + retval = 0; + } } + + return retval; } /* }}} */ -ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */ +ZEND_API int zend_binary_strcasecmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2) /* {{{ */ { - int len; + zend_size_t len; int c1, c2; if (s1 == s2) { @@ -2360,13 +2372,19 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u } } - return len1 - len2; + if (len1 > len2) { + return 1; + } else if (len1 < len2) { + return -1; + } else { + return 0; + } } /* }}} */ -ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ +ZEND_API int zend_binary_strncasecmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length) /* {{{ */ { - int len; + zend_size_t len; int c1, c2; if (s1 == s2) { @@ -2381,13 +2399,19 @@ ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, } } - return MIN(length, len1) - MIN(length, len2); + if (MIN(length, len1) > MIN(length, len2)) { + return 1; + } else if (MIN(length, len1) < MIN(length, len2)) { + return -1; + } else { + return 0; + } } /* }}} */ -ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */ +ZEND_API int zend_binary_strcasecmp_l(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2) /* {{{ */ { - int len; + zend_size_t len; int c1, c2; if (s1 == s2) { @@ -2403,13 +2427,19 @@ ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, } } - return len1 - len2; + if (len1 > len2) { + return 1; + } else if (len1 < len2) { + return -1; + } else { + return 0; + } } /* }}} */ -ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */ +ZEND_API int zend_binary_strncasecmp_l(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length) /* {{{ */ { - int len; + zend_size_t len; int c1, c2; if (s1 == s2) { @@ -2424,31 +2454,37 @@ ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2 } } - return MIN(length, len1) - MIN(length, len2); + if (MIN(length, len1) > MIN(length, len2)) { + return 1; + } else if (MIN(length, len1) < MIN(length, len2)) { + return -1; + } else { + return 0; + } } /* }}} */ ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2) /* {{{ */ { - return zend_binary_strcmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2)); + return zend_binary_strcmp(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), Z_STRVAL_P(s2), Z_STRSIZE_P(s2)); } /* }}} */ ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3) /* {{{ */ { - return zend_binary_strncmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3)); + return zend_binary_strncmp(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), Z_STRVAL_P(s2), Z_STRSIZE_P(s2), Z_IVAL_P(s3)); } /* }}} */ ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2) /* {{{ */ { - return zend_binary_strcasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2)); + return zend_binary_strcasecmp_l(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), Z_STRVAL_P(s2), Z_STRSIZE_P(s2)); } /* }}} */ ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3) /* {{{ */ { - return zend_binary_strncasecmp_l(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3)); + return zend_binary_strncasecmp_l(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), Z_STRVAL_P(s2), Z_STRSIZE_P(s2), Z_IVAL_P(s3)); } /* }}} */ @@ -2456,12 +2492,12 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ { int ret1, ret2; int oflow1, oflow2; - long lval1 = 0, lval2 = 0; + zend_int_t lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; - if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRLEN_P(s1), &lval1, &dval1, 0, &oflow1)) && - (ret2=is_numeric_string_ex(Z_STRVAL_P(s2), Z_STRLEN_P(s2), &lval2, &dval2, 0, &oflow2))) { -#if ULONG_MAX == 0xFFFFFFFF + if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), &lval1, &dval1, 0, &oflow1)) && + (ret2=is_numeric_string_ex(Z_STRVAL_P(s2), Z_STRSIZE_P(s2), &lval2, &dval2, 0, &oflow2))) { +#if ZEND_UINT_MAX == 0xFFFFFFFF if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) || (oflow1 == -1 && dval1 < -9007199254740991.))) { @@ -2476,13 +2512,13 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ if (ret1!=IS_DOUBLE) { if (oflow2) { /* 2nd operand is integer > LONG_MAX (oflow2==1) or < LONG_MIN (-1) */ - ZVAL_LONG(result, -1 * oflow2); + ZVAL_INT(result, -1 * oflow2); return; } dval1 = (double) lval1; } else if (ret2!=IS_DOUBLE) { if (oflow1) { - ZVAL_LONG(result, oflow1); + ZVAL_INT(result, oflow1); return; } dval2 = (double) lval2; @@ -2492,14 +2528,14 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ goto string_cmp; } Z_DVAL_P(result) = dval1 - dval2; - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(Z_DVAL_P(result))); } else { /* they both have to be long's */ - ZVAL_LONG(result, lval1 > lval2 ? 1 : (lval1 < lval2 ? -1 : 0)); + ZVAL_INT(result, lval1 > lval2 ? 1 : (lval1 < lval2 ? -1 : 0)); } } else { string_cmp: - Z_LVAL_P(result) = zend_binary_strcmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2)); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_LVAL_P(result))); + Z_IVAL_P(result) = zend_binary_strcmp(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), Z_STRVAL_P(s2), Z_STRSIZE_P(s2)); + ZVAL_INT(result, ZEND_NORMALIZE_BOOL(Z_IVAL_P(result))); } } /* }}} */ @@ -2511,7 +2547,7 @@ static int hash_zval_compare_function(zval *z1, zval *z2 TSRMLS_DC) /* {{{ */ if (compare_function(&result, z1, z2 TSRMLS_CC)==FAILURE) { return 1; } - return Z_LVAL(result); + return Z_IVAL(result); } /* }}} */ @@ -2523,7 +2559,7 @@ ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_ ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */ { - ZVAL_LONG(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC)); + ZVAL_INT(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC)); } /* }}} */ @@ -2536,14 +2572,14 @@ ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC) /* ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ { if (Z_OBJ_P(o1) == Z_OBJ_P(o2)) { - ZVAL_LONG(result, 0); + ZVAL_INT(result, 0); return; } if (Z_OBJ_HT_P(o1)->compare_objects == NULL) { - ZVAL_LONG(result, 1); + ZVAL_INT(result, 1); } else { - ZVAL_LONG(result, Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC)); + ZVAL_INT(result, Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC)); } } /* }}} */ @@ -2558,16 +2594,16 @@ ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */ } /* }}} */ -ZEND_API zend_string *zend_long_to_str(long num) /* {{{ */ +ZEND_API zend_string *zend_long_to_str(zend_int_t num) /* {{{ */ { - char buf[MAX_LENGTH_OF_LONG + 1]; + char buf[MAX_LENGTH_OF_ZEND_INT + 1]; char *res; - _zend_print_signed_to_buf(buf + sizeof(buf) - 1, num, unsigned long, res); + _zend_print_signed_to_buf(buf + sizeof(buf) - 1, num, zend_uint_t, res); return STR_INIT(res, buf + sizeof(buf) - 1 - res, 0); } /* }}} */ -ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval) { +ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, zend_int_t *lval, double *dval) { return is_numeric_string_ex(str->val, str->len, lval, dval, -1, NULL); } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 1ab9518b9a..92550f956f 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -41,7 +41,7 @@ #include "ext/bcmath/libbcmath/src/bcmath.h" #endif -#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1)) +#define LONG_SIGN_MASK (((zend_int_t)1) << (8*sizeof(zend_int_t)-1)) BEGIN_EXTERN_C() ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); @@ -71,12 +71,12 @@ ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, c ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC); END_EXTERN_C() -#if ZEND_DVAL_TO_LVAL_CAST_OK -# define zend_dval_to_lval(d) ((long) (d)) -#elif SIZEOF_LONG == 4 -static zend_always_inline long zend_dval_to_lval(double d) +#if ZEND_DVAL_TO_IVAL_CAST_OK +# define zend_dval_to_ival(d) ((zend_int_t) (d)) +#elif SIZEOF_ZEND_INT == 4 +static zend_always_inline zend_int_t zend_dval_to_ival(double d) { - if (d > LONG_MAX || d < LONG_MIN) { + if (d > ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_32 = pow(2., 32.), dmod; @@ -86,15 +86,15 @@ static zend_always_inline long zend_dval_to_lval(double d) * to simulate rounding towards 0 of the negative number */ dmod = ceil(dmod) + two_pow_32; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #else -static zend_always_inline long zend_dval_to_lval(double d) +static zend_always_inline zend_int_t zend_dval_to_ival(double d) { - /* >= as (double)LONG_MAX is outside signed range */ - if (d >= LONG_MAX || d < LONG_MIN) { + /* >= as (double)ZEND_INT_MAX is outside signed range */ + if (d >= ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_64 = pow(2., 64.), dmod; @@ -104,9 +104,9 @@ static zend_always_inline long zend_dval_to_lval(double d) * fractional part, hence dmod does not have one either */ dmod += two_pow_64; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #endif /* }}} */ @@ -119,7 +119,7 @@ static zend_always_inline long zend_dval_to_lval(double d) * of allow_errors determines whether it's required to be entirely numeric, or * just its prefix. Leading whitespace is allowed. * - * The function returns 0 if the string did not contain a valid number; IS_LONG + * The function returns 0 if the string did not contain a valid number; IS_INT * if it contained a number that fits within the range of a long; or IS_DOUBLE * if the number was out of long range or contained a decimal point/exponent. * The number's value is returned into the respective pointer, *lval or *dval, @@ -127,9 +127,9 @@ static zend_always_inline long zend_dval_to_lval(double d) * * This variant also gives information if a string that represents an integer * could not be represented as such due to overflow. It writes 1 to oflow_info - * if the integer is larger than LONG_MAX and -1 if it's smaller than LONG_MIN. + * if the integer is larger than ZEND_INT_MAX and -1 if it's smaller than ZEND_INT_MIN. */ -static inline zend_uchar is_numeric_string_ex(const char *str, int length, long *lval, double *dval, int allow_errors, int *oflow_info) +static inline zend_uchar is_numeric_string_ex(const char *str, zend_size_t length, zend_int_t *lval, double *dval, int allow_errors, int *oflow_info) { const char *ptr; int base = 10, digits = 0, dp_or_e = 0; @@ -172,7 +172,7 @@ static inline zend_uchar is_numeric_string_ex(const char *str, int length, long /* Count the number of digits. If a decimal point/exponent is found, * it's a double. Otherwise, if there's a dval or no need to check for * a full match, stop when there are too many digits for a long */ - for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors == 1)); digits++, ptr++) { + for (type = IS_INT; !(digits >= MAX_LENGTH_OF_ZEND_INT && (dval || allow_errors == 1)); digits++, ptr++) { check_digits: if (ZEND_IS_DIGIT(*ptr) || (base == 16 && ZEND_IS_XDIGIT(*ptr))) { continue; @@ -195,14 +195,14 @@ check_digits: } if (base == 10) { - if (digits >= MAX_LENGTH_OF_LONG) { + if (digits >= MAX_LENGTH_OF_ZEND_INT) { if (oflow_info != NULL) { *oflow_info = *str == '-' ? -1 : 1; } dp_or_e = -1; goto process_double; } - } else if (!(digits < SIZEOF_LONG * 2 || (digits == SIZEOF_LONG * 2 && ptr[-digits] <= '7'))) { + } else if (!(digits < SIZEOF_ZEND_INT * 2 || (digits == SIZEOF_ZEND_INT * 2 && ptr[-digits] <= '7'))) { if (dval) { local_dval = zend_hex_strtod(str, &ptr); } @@ -236,9 +236,9 @@ process_double: } } - if (type == IS_LONG) { - if (digits == MAX_LENGTH_OF_LONG - 1) { - int cmp = strcmp(&ptr[-digits], long_min_digits); + if (type == IS_INT) { + if (digits == MAX_LENGTH_OF_ZEND_INT - 1) { + int cmp = strcmp(&ptr[-digits], int_min_digits); if (!(cmp < 0 || (cmp == 0 && *str == '-'))) { if (dval) { @@ -253,10 +253,10 @@ process_double: } if (lval) { - *lval = strtol(str, NULL, base); + *lval = ZEND_STRTOI(str, NULL, base); } - return IS_LONG; + return IS_INT; } else { if (dval) { *dval = local_dval; @@ -266,23 +266,27 @@ process_double: } } -static inline zend_uchar is_numeric_string(const char *str, int length, long *lval, double *dval, int allow_errors) { +static inline zend_uchar is_numeric_string(const char *str, zend_size_t length, zend_int_t *lval, double *dval, int allow_errors) { return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); } -ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, long *lval, double *dval); +ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, zend_int_t *lval, double *dval); static inline const char * -zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end) +zend_memnstr(const char *haystack, const char *needle, zend_size_t needle_len, char *end) { const char *p = haystack; const char ne = needle[needle_len-1]; + ptrdiff_t off_p; + zend_size_t off_s; if (needle_len == 1) { return (char *)memchr(p, *needle, (end-p)); } - if (needle_len > end-haystack) { + off_p = end - haystack; + off_s = (off_p > 0) ? (zend_size_t)off_p : 0; + if (needle_len > off_s) { return NULL; } @@ -305,7 +309,7 @@ zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end return NULL; } -static inline const void *zend_memrchr(const void *s, int c, size_t n) +static inline const void *zend_memrchr(const void *s, int c, zend_size_t n) { register const unsigned char *e; @@ -329,23 +333,23 @@ ZEND_API int decrement_function(zval *op2); ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC); ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC); ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC); -ZEND_API void convert_to_long(zval *op); +ZEND_API void convert_to_int(zval *op); ZEND_API void convert_to_double(zval *op); -ZEND_API void convert_to_long_base(zval *op, int base); +ZEND_API void convert_to_int_base(zval *op, int base); ZEND_API void convert_to_null(zval *op); ZEND_API void convert_to_boolean(zval *op); ZEND_API void convert_to_array(zval *op); ZEND_API void convert_to_object(zval *op); -ZEND_API void multi_convert_to_long_ex(int argc, ...); +ZEND_API void multi_convert_to_int_ex(int argc, ...); ZEND_API void multi_convert_to_double_ex(int argc, ...); ZEND_API void multi_convert_to_string_ex(int argc, ...); -ZEND_API long _zval_get_long_func(zval *op TSRMLS_DC); +ZEND_API zend_int_t _zval_get_long_func(zval *op TSRMLS_DC); ZEND_API double _zval_get_double_func(zval *op TSRMLS_DC); ZEND_API zend_string *_zval_get_string_func(zval *op TSRMLS_DC); -static zend_always_inline long _zval_get_long(zval *op TSRMLS_DC) { - return Z_TYPE_P(op) == IS_LONG ? Z_LVAL_P(op) : _zval_get_long_func(op TSRMLS_CC); +static zend_always_inline zend_int_t _zval_get_long(zval *op TSRMLS_DC) { + return Z_TYPE_P(op) == IS_INT ? Z_IVAL_P(op) : _zval_get_long_func(op TSRMLS_CC); } static zend_always_inline double _zval_get_double(zval *op TSRMLS_DC) { return Z_TYPE_P(op) == IS_DOUBLE ? Z_DVAL_P(op) : _zval_get_double_func(op TSRMLS_CC); @@ -375,20 +379,20 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); #endif -ZEND_API void zend_str_tolower(char *str, unsigned int length); -ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length); -ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length); +ZEND_API void zend_str_tolower(char *str, zend_size_t length); +ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, zend_size_t length); +ZEND_API char *zend_str_tolower_dup(const char *source, zend_size_t length); ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2); ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3); ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2); ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3); -ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2); -ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length); -ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2); -ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length); -ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2); -ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length); +ZEND_API int zend_binary_strcmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2); +ZEND_API int zend_binary_strncmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length); +ZEND_API int zend_binary_strcasecmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2); +ZEND_API int zend_binary_strncasecmp(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length); +ZEND_API int zend_binary_strcasecmp_l(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2); +ZEND_API int zend_binary_strncasecmp_l(const char *s1, zend_size_t len1, const char *s2, zend_size_t len2, zend_size_t length); ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2); ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC); @@ -396,7 +400,7 @@ ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC); ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC); ZEND_API int zend_atoi(const char *str, int str_len); -ZEND_API long zend_atol(const char *str, int str_len); +ZEND_API zend_int_t zend_atol(const char *str, int str_len); ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC); END_EXTERN_C() @@ -413,8 +417,8 @@ END_EXTERN_C() case IS_NULL: \ convert_to_null(pzv); \ break; \ - case IS_LONG: \ - convert_to_long(pzv); \ + case IS_INT: \ + convert_to_int(pzv); \ break; \ case IS_DOUBLE: \ convert_to_double(pzv); \ @@ -444,7 +448,7 @@ END_EXTERN_C() } #define convert_to_boolean_ex(pzv) convert_to_ex_master(pzv, boolean, _IS_BOOL) -#define convert_to_long_ex(pzv) convert_to_ex_master(pzv, long, IS_LONG) +#define convert_to_int_ex(pzv) convert_to_ex_master(pzv, int, IS_INT) #define convert_to_double_ex(pzv) convert_to_ex_master(pzv, double, IS_DOUBLE) #define convert_to_string_ex(pzv) convert_to_ex_master(pzv, string, IS_STRING) #define convert_to_array_ex(pzv) convert_to_ex_master(pzv, array, IS_ARRAY) @@ -452,7 +456,7 @@ END_EXTERN_C() #define convert_to_null_ex(pzv) convert_to_ex_master(pzv, null, IS_NULL) #define convert_scalar_to_number_ex(pzv) \ - if (Z_TYPE_P(pzv)!=IS_LONG && Z_TYPE_P(pzv)!=IS_DOUBLE) { \ + if (Z_TYPE_P(pzv)!=IS_INT && Z_TYPE_P(pzv)!=IS_DOUBLE) { \ SEPARATE_ZVAL_IF_NOT_REF(pzv); \ convert_scalar_to_number(pzv TSRMLS_CC); \ } @@ -476,7 +480,7 @@ ZEND_API void zend_update_current_locale(void); static zend_always_inline int fast_increment_function(zval *op1) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { #if defined(__GNUC__) && defined(__i386__) __asm__( "incl (%0)\n\t" @@ -504,11 +508,11 @@ static zend_always_inline int fast_increment_function(zval *op1) "n"(ZVAL_OFFSETOF_TYPE) : "cc"); #else - if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) { + if (UNEXPECTED(Z_IVAL_P(op1) == ZEND_INT_MAX)) { /* switch to double */ - ZVAL_DOUBLE(op1, (double)LONG_MAX + 1.0); + ZVAL_DOUBLE(op1, (double)ZEND_INT_MAX + 1.0); } else { - Z_LVAL_P(op1)++; + Z_IVAL_P(op1)++; } #endif return SUCCESS; @@ -518,7 +522,7 @@ static zend_always_inline int fast_increment_function(zval *op1) static zend_always_inline int fast_decrement_function(zval *op1) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { #if defined(__GNUC__) && defined(__i386__) __asm__( "decl (%0)\n\t" @@ -546,11 +550,11 @@ static zend_always_inline int fast_decrement_function(zval *op1) "n"(ZVAL_OFFSETOF_TYPE) : "cc"); #else - if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MIN)) { + if (UNEXPECTED(Z_IVAL_P(op1) == ZEND_INT_MIN)) { /* switch to double */ - ZVAL_DOUBLE(op1, (double)LONG_MIN - 1.0); + ZVAL_DOUBLE(op1, (double)ZEND_INT_MIN - 1.0); } else { - Z_LVAL_P(op1)--; + Z_IVAL_P(op1)--; } #endif return SUCCESS; @@ -560,8 +564,8 @@ static zend_always_inline int fast_decrement_function(zval *op1) static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { #if defined(__GNUC__) && defined(__i386__) __asm__( "movl (%1), %%eax\n\t" @@ -581,7 +585,7 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o : "r"(&result->value), "r"(&op1->value), "r"(&op2->value), - "n"(IS_LONG), + "n"(IS_INT), "n"(IS_DOUBLE), "n"(ZVAL_OFFSETOF_TYPE) : "eax","cc"); @@ -604,7 +608,7 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o : "r"(&result->value), "r"(&op1->value), "r"(&op2->value), - "n"(IS_LONG), + "n"(IS_INT), "n"(IS_DOUBLE), "n"(ZVAL_OFFSETOF_TYPE) : "rax","cc"); @@ -615,24 +619,24 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o * have read the values of op1 and op2. */ - if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK) - && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != ((Z_LVAL_P(op1) + Z_LVAL_P(op2)) & LONG_SIGN_MASK))) { - ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2)); + if (UNEXPECTED((Z_IVAL_P(op1) & LONG_SIGN_MASK) == (Z_IVAL_P(op2) & LONG_SIGN_MASK) + && (Z_IVAL_P(op1) & LONG_SIGN_MASK) != ((Z_IVAL_P(op1) + Z_IVAL_P(op2)) & LONG_SIGN_MASK))) { + ZVAL_DOUBLE(result, (double) Z_IVAL_P(op1) + (double) Z_IVAL_P(op2)); } else { - ZVAL_LONG(result, Z_LVAL_P(op1) + Z_LVAL_P(op2)); + ZVAL_INT(result, Z_IVAL_P(op1) + Z_IVAL_P(op2)); } #endif return SUCCESS; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2)); + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) + Z_DVAL_P(op2)); return SUCCESS; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2)); return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_IVAL_P(op2))); return SUCCESS; } } @@ -641,8 +645,8 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { #if defined(__GNUC__) && defined(__i386__) __asm__( "movl (%1), %%eax\n\t" @@ -666,7 +670,7 @@ static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *o : "r"(&result->value), "r"(&op1->value), "r"(&op2->value), - "n"(IS_LONG), + "n"(IS_INT), "n"(IS_DOUBLE), "n"(ZVAL_OFFSETOF_TYPE) : "eax","cc"); @@ -693,29 +697,29 @@ static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *o : "r"(&result->value), "r"(&op1->value), "r"(&op2->value), - "n"(IS_LONG), + "n"(IS_INT), "n"(IS_DOUBLE), "n"(ZVAL_OFFSETOF_TYPE) : "rax","cc"); #else - ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2)); + ZVAL_INT(result, Z_IVAL_P(op1) - Z_IVAL_P(op2)); - if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK) - && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) { - ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2)); + if (UNEXPECTED((Z_IVAL_P(op1) & LONG_SIGN_MASK) != (Z_IVAL_P(op2) & LONG_SIGN_MASK) + && (Z_IVAL_P(op1) & LONG_SIGN_MASK) != (Z_IVAL_P(result) & LONG_SIGN_MASK))) { + ZVAL_DOUBLE(result, (double) Z_IVAL_P(op1) - (double) Z_IVAL_P(op2)); } #endif return SUCCESS; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2)); + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) - Z_DVAL_P(op2)); return SUCCESS; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_DOUBLE(result, Z_DVAL_P(op1) - Z_DVAL_P(op2)); return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_IVAL_P(op2))); return SUCCESS; } } @@ -724,23 +728,23 @@ static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - long overflow; + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + zend_int_t overflow; - ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow); - Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG; + ZEND_SIGNED_MULTIPLY_INT(Z_IVAL_P(op1), Z_IVAL_P(op2), Z_IVAL_P(result), Z_DVAL_P(result), overflow); + Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_INT; return SUCCESS; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2)); + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) * Z_DVAL_P(op2)); return SUCCESS; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_DOUBLE(result, Z_DVAL_P(op1) * Z_DVAL_P(op2)); return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_IVAL_P(op2))); return SUCCESS; } } @@ -750,20 +754,20 @@ static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { #if 0 - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT) && 0) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + if (UNEXPECTED(Z_IVAL_P(op2) == 0)) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; - } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN)) { + } else if (UNEXPECTED(Z_IVAL_P(op2) == -1 && Z_IVAL_P(op1) == ZEND_INT_MIN)) { /* Prevent overflow error/crash */ - ZVAL_DOUBLE(result, (double) LONG_MIN / -1); - } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) { + ZVAL_DOUBLE(result, (double) ZEND_INT_MIN / -1); + } else if (EXPECTED(Z_IVAL_P(op1) % Z_IVAL_P(op2) == 0)) { /* integer */ - ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2)); + ZVAL_INT(result, Z_IVAL_P(op1) / Z_IVAL_P(op2)); } else { - ZVAL_DOUBLE(result, ((double) Z_LVAL_P(op1)) / ((double)Z_LVAL_P(op2))); + ZVAL_DOUBLE(result, ((double) Z_IVAL_P(op1)) / ((double)Z_IVAL_P(op2))); } return SUCCESS; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { @@ -772,7 +776,7 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o ZVAL_BOOL(result, 0); return FAILURE; } - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) / Z_DVAL_P(op2)); + ZVAL_DOUBLE(result, ((double)Z_IVAL_P(op1)) / Z_DVAL_P(op2)); return SUCCESS; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE) && 0) { @@ -784,13 +788,13 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o } ZVAL_DOUBLE(result, Z_DVAL_P(op1) / Z_DVAL_P(op2)); return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + if (UNEXPECTED(Z_IVAL_P(op2) == 0)) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; } - ZVAL_DOUBLE(result, Z_DVAL_P(op1) / ((double)Z_LVAL_P(op2))); + ZVAL_DOUBLE(result, Z_DVAL_P(op1) / ((double)Z_IVAL_P(op2))); return SUCCESS; } } @@ -800,18 +804,18 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + if (UNEXPECTED(Z_IVAL_P(op2) == 0)) { zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; - } else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) { - /* Prevent overflow error/crash if op1==LONG_MIN */ - ZVAL_LONG(result, 0); + } else if (UNEXPECTED(Z_IVAL_P(op2) == -1)) { + /* Prevent overflow error/crash if op1==ZEND_INT_MIN */ + ZVAL_INT(result, 0); return SUCCESS; } - ZVAL_LONG(result, Z_LVAL_P(op1) % Z_LVAL_P(op2)); + ZVAL_INT(result, Z_IVAL_P(op1) % Z_IVAL_P(op2)); return SUCCESS; } } @@ -820,54 +824,54 @@ static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_equal_check_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - return Z_LVAL_P(op1) == Z_LVAL_P(op2); + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + return Z_IVAL_P(op1) == Z_IVAL_P(op2); } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - return ((double)Z_LVAL_P(op1)) == Z_DVAL_P(op2); + return ((double)Z_IVAL_P(op1)) == Z_DVAL_P(op2); } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { return Z_DVAL_P(op1) == Z_DVAL_P(op2); - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - return Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + return Z_DVAL_P(op1) == ((double)Z_IVAL_P(op2)); } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { if (Z_STR_P(op1) == Z_STR_P(op2)) { return 1; } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') { - if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) != Z_STRSIZE_P(op2)) { return 0; } else { - return memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0; + return memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op1)) == 0; } } else { zendi_smart_strcmp(result, op1, op2); - return Z_LVAL_P(result) == 0; + return Z_IVAL_P(result) == 0; } } } compare_function(result, op1, op2 TSRMLS_CC); - return Z_LVAL_P(result) == 0; + return Z_IVAL_P(result) == 0; } static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_LVAL_P(op1) == Z_LVAL_P(op2)); + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_IVAL_P(op1) == Z_IVAL_P(op2)); return; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_BOOL(result, (double)Z_LVAL_P(op1) == Z_DVAL_P(op2)); + ZVAL_BOOL(result, (double)Z_IVAL_P(op1) == Z_DVAL_P(op2)); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_BOOL(result, Z_DVAL_P(op1) == Z_DVAL_P(op2)); return; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_DVAL_P(op1) == ((double)Z_IVAL_P(op2))); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -876,40 +880,40 @@ static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval ZVAL_TRUE(result); return; } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') { - if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) != Z_STRSIZE_P(op2)) { ZVAL_FALSE(result); return; } else { - ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0); + ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op1)) == 0); return; } } else { zendi_smart_strcmp(result, op1, op2); - ZVAL_BOOL(result, Z_LVAL_P(result) == 0); + ZVAL_BOOL(result, Z_IVAL_P(result) == 0); return; } } } compare_function(result, op1, op2 TSRMLS_CC); - ZVAL_BOOL(result, Z_LVAL_P(result) == 0); + ZVAL_BOOL(result, Z_IVAL_P(result) == 0); } static zend_always_inline void fast_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_LVAL_P(op1) != Z_LVAL_P(op2)); + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_IVAL_P(op1) != Z_IVAL_P(op2)); return; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_BOOL(result, (double)Z_LVAL_P(op1) != Z_DVAL_P(op2)); + ZVAL_BOOL(result, (double)Z_IVAL_P(op1) != Z_DVAL_P(op2)); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_BOOL(result, Z_DVAL_P(op1) != Z_DVAL_P(op2)); return; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_DVAL_P(op1) != ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_DVAL_P(op1) != ((double)Z_IVAL_P(op2))); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { @@ -918,68 +922,68 @@ static zend_always_inline void fast_not_equal_function(zval *result, zval *op1, ZVAL_FALSE(result); return; } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') { - if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) { + if (Z_STRSIZE_P(op1) != Z_STRSIZE_P(op2)) { ZVAL_TRUE(result); return; } else { - ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) != 0); + ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRSIZE_P(op1)) != 0); return; } } else { zendi_smart_strcmp(result, op1, op2); - ZVAL_BOOL(result, Z_LVAL_P(result) != 0); + ZVAL_BOOL(result, Z_IVAL_P(result) != 0); return; } } } compare_function(result, op1, op2 TSRMLS_CC); - ZVAL_BOOL(result, Z_LVAL_P(result) != 0); + ZVAL_BOOL(result, Z_IVAL_P(result) != 0); } static zend_always_inline void fast_is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_LVAL_P(op1) < Z_LVAL_P(op2)); + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_IVAL_P(op1) < Z_IVAL_P(op2)); return; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_BOOL(result, (double)Z_LVAL_P(op1) < Z_DVAL_P(op2)); + ZVAL_BOOL(result, (double)Z_IVAL_P(op1) < Z_DVAL_P(op2)); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_BOOL(result, Z_DVAL_P(op1) < Z_DVAL_P(op2)); return; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_DVAL_P(op1) < ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_DVAL_P(op1) < ((double)Z_IVAL_P(op2))); return; } } compare_function(result, op1, op2 TSRMLS_CC); - ZVAL_BOOL(result, Z_LVAL_P(result) < 0); + ZVAL_BOOL(result, Z_IVAL_P(result) < 0); } static zend_always_inline void fast_is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_LVAL_P(op1) <= Z_LVAL_P(op2)); + if (EXPECTED(Z_TYPE_P(op1) == IS_INT)) { + if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_IVAL_P(op1) <= Z_IVAL_P(op2)); return; } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - ZVAL_BOOL(result, (double)Z_LVAL_P(op1) <= Z_DVAL_P(op2)); + ZVAL_BOOL(result, (double)Z_IVAL_P(op1) <= Z_DVAL_P(op2)); return; } } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) { if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { ZVAL_BOOL(result, Z_DVAL_P(op1) <= Z_DVAL_P(op2)); return; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - ZVAL_BOOL(result, Z_DVAL_P(op1) <= ((double)Z_LVAL_P(op2))); + } else if (EXPECTED(Z_TYPE_P(op2) == IS_INT)) { + ZVAL_BOOL(result, Z_DVAL_P(op1) <= ((double)Z_IVAL_P(op2))); return; } } compare_function(result, op1, op2 TSRMLS_CC); - ZVAL_BOOL(result, Z_LVAL_P(result) <= 0); + ZVAL_BOOL(result, Z_IVAL_P(result) <= 0); } static zend_always_inline void fast_is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) @@ -1041,7 +1045,7 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval } \ } while (0) -ZEND_API zend_string *zend_long_to_str(long num); +ZEND_API zend_string *zend_long_to_str(zend_int_t num); #endif diff --git a/Zend/zend_qsort.c b/Zend/zend_qsort.c index ea577e1c07..16d513e93c 100644 --- a/Zend/zend_qsort.c +++ b/Zend/zend_qsort.c @@ -74,7 +74,7 @@ ZEND_API void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_ end = end_stack[loop]; while (begin < end) { - offset = (end - begin) >> 1; + offset = (end - begin) >> Z_I(1); _zend_qsort_swap(begin, begin + (offset - (offset % siz)), siz); seg1 = begin + siz; diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c index 6d306b337e..b144432db9 100644 --- a/Zend/zend_stream.c +++ b/Zend/zend_stream.c @@ -24,9 +24,8 @@ #include "zend.h" #include "zend_compile.h" +#include "zend_stream.h" -#include <sys/types.h> -#include <sys/stat.h> #if HAVE_MMAP # if HAVE_UNISTD_H # include <unistd.h> @@ -64,8 +63,8 @@ static void zend_stream_stdio_closer(void *handle TSRMLS_DC) /* {{{ */ static size_t zend_stream_stdio_fsizer(void *handle TSRMLS_DC) /* {{{ */ { - struct stat buf; - if (handle && fstat(fileno((FILE*)handle), &buf) == 0) { + zend_stat_t buf; + if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) { #ifdef S_ISREG if (!S_ISREG(buf.st_mode)) { return 0; @@ -237,7 +236,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t /* *buf[size] is zeroed automatically by the kernel */ *buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0); if (*buf != MAP_FAILED) { - long offset = ftell(file_handle->handle.fp); + zend_int_t offset = ftell(file_handle->handle.fp); file_handle->handle.stream.mmap.map = *buf; if (offset != -1) { diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h index 5306b496f9..10fa8d8a60 100644 --- a/Zend/zend_stream.h +++ b/Zend/zend_stream.h @@ -24,6 +24,9 @@ #ifndef ZEND_STREAM_H #define ZEND_STREAM_H +#include <sys/types.h> +#include <sys/stat.h> + /* Lightweight stream implementation for the ZE scanners. * These functions are private to the engine. * */ @@ -78,4 +81,20 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC); ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); END_EXTERN_C() +#ifdef _WIN64 +# define zend_fseek _fseeki64 +# define zend_ftell _ftelli64 +# define zend_lseek _lseeki64 +# define zend_fstat _fstat64 +# define zend_stat _stat64 +typedef struct __stat64 zend_stat_t; +#else +# define zend_fseek fseek +# define zend_ftell ftell +# define zend_lseek lseek +# define zend_fstat fstat +# define zend_stat stat +typedef struct stat zend_stat_t; +#endif + #endif diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 2a415454ce..5a4f4e1fc5 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -29,7 +29,7 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC); static void zend_interned_strings_snapshot_int(TSRMLS_D); static void zend_interned_strings_restore_int(TSRMLS_D); -ZEND_API zend_ulong zend_hash_func(const char *str, uint len) +ZEND_API zend_uint_t zend_hash_func(const char *str, zend_size_t len) { return zend_inline_hash_func(str, len); } @@ -85,7 +85,7 @@ void zend_interned_strings_dtor(TSRMLS_D) static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) { #ifndef ZTS - ulong h; + zend_uint_t h; uint nIndex; uint idx; Bucket *p; diff --git a/Zend/zend_string.h b/Zend/zend_string.h index ef0116b938..f30ae29941 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -29,7 +29,7 @@ ZEND_API extern zend_string *(*zend_new_interned_string)(zend_string *str TSRMLS ZEND_API extern void (*zend_interned_strings_snapshot)(TSRMLS_D); ZEND_API extern void (*zend_interned_strings_restore)(TSRMLS_D); -ZEND_API zend_ulong zend_hash_func(const char *str, uint len); +ZEND_API zend_uint_t zend_hash_func(const char *str, zend_size_t len); void zend_interned_strings_init(TSRMLS_D); void zend_interned_strings_dtor(TSRMLS_D); @@ -70,7 +70,7 @@ END_EXTERN_C() #define STR_ALLOCA_FREE(str, use_heap) free_alloca(str, use_heap) -static zend_always_inline zend_ulong zend_str_hash_val(zend_string *s) +static zend_always_inline zend_uint_t zend_str_hash_val(zend_string *s) { if (!s->h) { s->h = zend_hash_func(s->val, s->len); @@ -107,7 +107,7 @@ static zend_always_inline zend_uint zend_str_delref(zend_string *s) return 1; } -static zend_always_inline zend_string *zend_str_alloc(int len, int persistent) +static zend_always_inline zend_string *zend_str_alloc(zend_size_t len, int persistent) { zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + len + 1), persistent); @@ -143,7 +143,7 @@ static zend_always_inline zend_string *zend_str_safe_alloc(size_t n, size_t m, s return ret; } -static zend_always_inline zend_string *zend_str_init(const char *str, int len, int persistent) +static zend_always_inline zend_string *zend_str_init(const char *str, zend_size_t len, int persistent) { zend_string *ret = STR_ALLOC(len, persistent); @@ -169,7 +169,7 @@ static zend_always_inline zend_string *zend_str_dup(zend_string *s, int persiste } } -static zend_always_inline zend_string *zend_str_realloc(zend_string *s, int len, int persistent) +static zend_always_inline zend_string *zend_str_realloc(zend_string *s, zend_size_t len, int persistent) { zend_string *ret; @@ -257,9 +257,9 @@ static zend_always_inline void zend_str_release(zend_string *s) * -- Ralf S. Engelschall <rse@engelschall.com> */ -static inline ulong zend_inline_hash_func(const char *str, uint len) +static inline zend_uint_t zend_inline_hash_func(const char *str, zend_size_t len) { - register ulong hash = 5381; + register zend_uint_t hash = Z_UI(5381); /* variant with the hash unrolled eight times */ for (; len >= 8; len -= 8) { diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index f6523574ae..9d55933e0a 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -110,7 +110,7 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv return retval; } -ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC) +ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_uint_t h, zval *pData, int flag ZEND_FILE_LINE_DC) { zval *retval; @@ -187,7 +187,7 @@ ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, ulong h) +ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_uint_t h) { int retval; @@ -209,7 +209,7 @@ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, ulong h) +ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_uint_t h) { zval *retval; @@ -231,7 +231,7 @@ ZEND_API int zend_ts_hash_exists(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h) +ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, zend_uint_t h) { int retval; diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index fcf8c3cda1..ceb7cbf1fe 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -55,7 +55,7 @@ ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zv #define zend_ts_hash_add(ht, key, pData) \ _zend_ts_hash_add_or_update(ht, key, pData, HASH_ADD ZEND_FILE_LINE_CC) -ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, zval *pData, int flag ZEND_FILE_LINE_DC); +ZEND_API zval *_zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, zend_uint_t h, zval *pData, int flag ZEND_FILE_LINE_DC); #define zend_ts_hash_index_update(ht, h, pData) \ _zend_ts_hash_index_update_or_next_insert(ht, h, pData, HASH_UPDATE ZEND_FILE_LINE_CC) #define zend_ts_hash_next_index_insert(ht, pData) \ @@ -73,15 +73,15 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun /* Deletes */ ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key); -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, ulong h); +ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_uint_t h); /* Data retreival */ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key); -ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, ulong); +ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_uint_t); /* Misc */ ZEND_API int zend_ts_hash_exists(TsHashTable *ht, zend_string *key); -ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h); +ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, zend_uint_t h); /* Copying, merging and sorting */ ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 232fcbadc1..f5d7a6ea7d 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -22,6 +22,8 @@ #ifndef ZEND_TYPES_H #define ZEND_TYPES_H +#include "zend_int.h" + #ifdef WORDS_BIGENDIAN # define ZEND_ENDIAN_LOHI(lo, hi) hi; lo; # define ZEND_ENDIAN_LOHI_3(lo, mi, hi) hi; mi; lo; @@ -44,6 +46,21 @@ typedef unsigned int zend_uint; typedef unsigned long zend_ulong; typedef unsigned short zend_ushort; +#ifdef ZEND_ENABLE_INT64 +# ifdef ZEND_WIN32 +# define ZEND_SIZE_MAX _UI64_MAX +# else +# define ZEND_SIZE_MAX SIZE_MAX +# endif +#else +# if defined(ZEND_WIN32) +# define ZEND_SIZE_MAX _UI32_MAX +# else +# define ZEND_SIZE_MAX SIZE_MAX +# endif +#endif +typedef size_t zend_size_t; + #define HAVE_ZEND_LONG64 #ifdef ZEND_WIN32 typedef __int64 zend_long64; @@ -87,7 +104,7 @@ typedef void (*dtor_func_t)(zval *pDest); typedef void (*copy_ctor_func_t)(zval *pElement); typedef union _zend_value { - long lval; /* long value */ + zend_int_t lval; /* long value */ double dval; /* double value */ zend_refcounted *counted; zend_string *str; @@ -137,13 +154,13 @@ struct _zend_refcounted { struct _zend_string { zend_refcounted gc; - zend_ulong h; /* hash value */ - int len; + zend_uint_t h; /* hash value */ + zend_size_t len; char val[1]; }; typedef struct _Bucket { - zend_ulong h; /* hash value (or numeric index) */ + zend_uint_t h; /* hash value (or numeric index) */ zend_string *key; /* string key or NULL for numerics */ zval val; } Bucket; @@ -153,7 +170,7 @@ typedef struct _HashTable { zend_uint nTableMask; zend_uint nNumUsed; zend_uint nNumOfElements; - long nNextFreeElement; + zend_int_t nNextFreeElement; Bucket *arData; zend_uint *arHash; dtor_func_t pDestructor; @@ -186,7 +203,7 @@ struct _zend_object { struct _zend_resource { zend_refcounted gc; - long handle; // TODO: may be removed ??? + zend_int_t handle; // TODO: may be removed ??? int type; void *ptr; }; @@ -206,7 +223,7 @@ struct _zend_ast_ref { #define IS_NULL 1 #define IS_FALSE 2 #define IS_TRUE 3 -#define IS_LONG 4 +#define IS_INT 4 #define IS_DOUBLE 5 #define IS_STRING 6 #define IS_ARRAY 7 @@ -381,8 +398,8 @@ static inline zend_uchar zval_get_type(const zval* pz) { #define Z_ISNULL(zval) (Z_TYPE(zval) == IS_NULL) #define Z_ISNULL_P(zval_p) Z_ISNULL(*(zval_p)) -#define Z_LVAL(zval) (zval).value.lval -#define Z_LVAL_P(zval_p) Z_LVAL(*(zval_p)) +#define Z_IVAL(zval) (zval).value.lval +#define Z_IVAL_P(zval_p) Z_IVAL(*(zval_p)) #define Z_DVAL(zval) (zval).value.dval #define Z_DVAL_P(zval_p) Z_DVAL(*(zval_p)) @@ -393,8 +410,8 @@ static inline zend_uchar zval_get_type(const zval* pz) { #define Z_STRVAL(zval) Z_STR(zval)->val #define Z_STRVAL_P(zval_p) Z_STRVAL(*(zval_p)) -#define Z_STRLEN(zval) Z_STR(zval)->len -#define Z_STRLEN_P(zval_p) Z_STRLEN(*(zval_p)) +#define Z_STRSIZE(zval) Z_STR(zval)->len +#define Z_STRSIZE_P(zval_p) Z_STRSIZE(*(zval_p)) #define Z_STRHASH(zval) Z_STR(zval)->h #define Z_STRHASH_P(zval_p) Z_STRHASH(*(zval_p)) @@ -483,10 +500,10 @@ static inline zend_uchar zval_get_type(const zval* pz) { (b) ? IS_TRUE : IS_FALSE; \ } while (0) -#define ZVAL_LONG(z, l) { \ +#define ZVAL_INT(z, l) { \ zval *__z = (z); \ - Z_LVAL_P(__z) = l; \ - Z_TYPE_INFO_P(__z) = IS_LONG; \ + Z_IVAL_P(__z) = l; \ + Z_TYPE_INFO_P(__z) = IS_INT; \ } #define ZVAL_DOUBLE(z, d) { \ diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 9f76d9f812..1c10a1451f 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -165,7 +165,7 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC) free(ref); break; } - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: @@ -196,7 +196,7 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC) free(ref); break; } - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index ab3d0d7c49..1b12f6f0b9 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -291,7 +291,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ } /* }}} */ -CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */ +CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */ { WIN32_FILE_ATTRIBUTE_DATA data; __int64 t; @@ -299,7 +299,7 @@ CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{ ALLOCA_FLAG(use_heap_large); if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) { - return stat(path, buf); + return zend_stat(path, buf); } if (path_len >= 1 && path[1] == ':') { @@ -407,7 +407,7 @@ CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{ static int php_is_dir_ok(const cwd_state *state) /* {{{ */ { - struct stat buf; + zend_stat_t buf; if (php_sys_stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode)) return (0); @@ -418,7 +418,7 @@ static int php_is_dir_ok(const cwd_state *state) /* {{{ */ static int php_is_file_ok(const cwd_state *state) /* {{{ */ { - struct stat buf; + zend_stat_t buf; if (php_sys_stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode)) return (0); @@ -582,9 +582,9 @@ CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */ /* }}} */ #ifdef PHP_WIN32 -static inline unsigned long realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */ +static inline zend_uint_t realpath_cache_key(const char *path, int path_len TSRMLS_DC) /* {{{ */ { - register unsigned long h; + register zend_uint_t h; char *bucket_key_start = tsrm_win32_get_path_sid_key(path TSRMLS_CC); char *bucket_key = (char *)bucket_key_start; const char *e = bucket_key + strlen(bucket_key); @@ -602,9 +602,9 @@ static inline unsigned long realpath_cache_key(const char *path, int path_len TS } /* }}} */ #else -static inline unsigned long realpath_cache_key(const char *path, int path_len) /* {{{ */ +static inline zend_uint_t realpath_cache_key(const char *path, int path_len) /* {{{ */ { - register unsigned long h; + register zend_uint_t h; const char *e = path + path_len; for (h = 2166136261U; path < e;) { @@ -637,11 +637,11 @@ CWD_API void realpath_cache_clean(TSRMLS_D) /* {{{ */ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ */ { #ifdef PHP_WIN32 - unsigned long key = realpath_cache_key(path, path_len TSRMLS_CC); + zend_uint_t key = realpath_cache_key(path, path_len TSRMLS_CC); #else - unsigned long key = realpath_cache_key(path, path_len); + zend_uint_t key = realpath_cache_key(path, path_len); #endif - unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); + zend_uint_t n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n]; while (*bucket != NULL) { @@ -668,7 +668,7 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ static inline void realpath_cache_add(const char *path, int path_len, const char *realpath, int realpath_len, int is_dir, time_t t TSRMLS_DC) /* {{{ */ { - long size = sizeof(realpath_cache_bucket) + path_len + 1; + zend_int_t size = sizeof(realpath_cache_bucket) + path_len + 1; int same = 1; if (realpath_len != path_len || @@ -679,7 +679,7 @@ static inline void realpath_cache_add(const char *path, int path_len, const char if (CWDG(realpath_cache_size) + size <= CWDG(realpath_cache_size_limit)) { realpath_cache_bucket *bucket = malloc(size); - unsigned long n; + zend_uint_t n; if (bucket == NULL) { return; @@ -719,12 +719,12 @@ static inline void realpath_cache_add(const char *path, int path_len, const char static inline realpath_cache_bucket* realpath_cache_find(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ { #ifdef PHP_WIN32 - unsigned long key = realpath_cache_key(path, path_len TSRMLS_CC); + zend_uint_t key = realpath_cache_key(path, path_len TSRMLS_CC); #else - unsigned long key = realpath_cache_key(path, path_len); + zend_uint_t key = realpath_cache_key(path, path_len); #endif - unsigned long n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); + zend_uint_t n = key % (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); realpath_cache_bucket **bucket = &CWDG(realpath_cache)[n]; while (*bucket != NULL) { @@ -784,7 +784,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i HANDLE hFind; ALLOCA_FLAG(use_heap_large) #else - struct stat st; + zend_stat_t st; #endif realpath_cache_bucket *bucket; char *tmp; @@ -1739,7 +1739,7 @@ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) / } /* }}} */ -CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */ +CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */ { cwd_state new_state; int retval; @@ -1757,7 +1757,7 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */ } /* }}} */ -CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */ +CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC) /* {{{ */ { cwd_state new_state; int retval; diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h index b0df0ad310..383b65db32 100644 --- a/Zend/zend_virtual_cwd.h +++ b/Zend/zend_virtual_cwd.h @@ -130,7 +130,7 @@ typedef unsigned short mode_t; #endif #ifdef TSRM_WIN32 -CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat); +CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat); # define php_sys_stat(path, buf) php_sys_stat_ex(path, buf, 0) # define php_sys_lstat(path, buf) php_sys_stat_ex(path, buf, 1) CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len); @@ -164,8 +164,8 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC); CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...); CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC); CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC); -CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC); -CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC); +CWD_API int virtual_stat(const char *path, zend_stat_t *buf TSRMLS_DC); +CWD_API int virtual_lstat(const char *path, zend_stat_t *buf TSRMLS_DC); CWD_API int virtual_unlink(const char *path TSRMLS_DC); CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC); CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC); @@ -211,7 +211,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC); #define REALPATH_CACHE_SIZE 0 /* disabled while php.ini isn't loaded */ typedef struct _realpath_cache_bucket { - unsigned long key; + zend_uint_t key; char *path; int path_len; char *realpath; @@ -229,9 +229,9 @@ typedef struct _realpath_cache_bucket { typedef struct _virtual_cwd_globals { cwd_state cwd; - long realpath_cache_size; - long realpath_cache_size_limit; - long realpath_cache_ttl; + zend_int_t realpath_cache_size; + zend_int_t realpath_cache_size_limit; + zend_int_t realpath_cache_ttl; realpath_cache_bucket *realpath_cache[1024]; } virtual_cwd_globals; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 7749197a74..974a46ffce 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -867,7 +867,7 @@ ZEND_VM_HANDLER(34, ZEND_PRE_INC, VAR|CV, ANY) SAVE_OPLINE(); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_increment_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -922,7 +922,7 @@ ZEND_VM_HANDLER(35, ZEND_PRE_DEC, VAR|CV, ANY) SAVE_OPLINE(); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_decrement_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -977,7 +977,7 @@ ZEND_VM_HANDLER(36, ZEND_POST_INC, VAR|CV, ANY) SAVE_OPLINE(); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_increment_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -1031,7 +1031,7 @@ ZEND_VM_HANDLER(37, ZEND_POST_DEC, VAR|CV, ANY) SAVE_OPLINE(); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_decrement_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -1096,7 +1096,7 @@ ZEND_VM_HANDLER(41, ZEND_PRINT, CONST|TMP|VAR|CV, ANY) { USE_OPLINE - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ECHO); } @@ -2412,11 +2412,11 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { if (Z_STRVAL_P(function_name)[0] == '\\') { - lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name) - 1, 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRSIZE_P(function_name) - 1); } else { - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); @@ -3633,7 +3633,7 @@ ZEND_VM_HANDLER(50, ZEND_BRK, ANY, CONST) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->op1.opline_num, &EX(func)->op_array, execute_data TSRMLS_CC); ZEND_VM_JMP(EX(func)->op_array.opcodes + el->brk); } @@ -3644,7 +3644,7 @@ ZEND_VM_HANDLER(51, ZEND_CONT, ANY, CONST) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->op1.opline_num, &EX(func)->op_array, execute_data TSRMLS_CC); ZEND_VM_JMP(EX(func)->op_array.opcodes + el->cont); } @@ -3656,7 +3656,7 @@ ZEND_VM_HANDLER(100, ZEND_GOTO, ANY, CONST) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->extended_value, &EX(func)->op_array, execute_data TSRMLS_CC); brk_opline = EX(func)->op_array.opcodes + el->brk; @@ -3818,7 +3818,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv)); } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { - char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); + char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRSIZE_P(opline->op2.zv)); if(!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { @@ -3826,7 +3826,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) } /* non-qualified constant - allow text substitution */ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRSIZE_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -3889,7 +3889,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value); } ZVAL_DUP(EX_VAR(opline->result.var), value); - } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { + } else if (Z_STRSIZE_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ ZVAL_STR(EX_VAR(opline->result.var), ce->name); STR_ADDREF(ce->name); @@ -3941,15 +3941,15 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS zend_free_op free_op2; zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); zend_string *str; - ulong hval; + zend_uint_t hval; ZEND_VM_C_LABEL(add_again): switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); ZEND_VM_C_GOTO(num_index); - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); ZEND_VM_C_LABEL(num_index): zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -4052,8 +4052,8 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY) case _IS_BOOL: ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC)); break; - case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + case IS_INT: + ZVAL_INT(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -4149,7 +4149,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) inc_filename = &tmp_inc_filename; } - if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) { + if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRSIZE_P(inc_filename)) { if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC); } else { @@ -4162,7 +4162,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) zend_file_handle file_handle; char *resolved_path; - resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename) TSRMLS_CC); + resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRSIZE_P(inc_filename) TSRMLS_CC); if (resolved_path) { failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, strlen(resolved_path)); } else { @@ -4332,7 +4332,7 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV) zend_free_op free_op1, free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET); @@ -4348,11 +4348,11 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV) ZEND_VM_C_LABEL(offset_again): switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); ZEND_VM_C_LABEL(num_index_dim): zend_hash_index_del(ht, hval); break; @@ -4605,12 +4605,12 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) zend_object *zobj = Z_OBJ_P(array_ptr); while (zend_hash_has_more_elements(fe_ht) == SUCCESS) { zend_string *str_key; - ulong int_key; + zend_uint_t int_key; zend_uchar key_type; key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); if (key_type != HASH_KEY_NON_EXISTENT && - (key_type == HASH_KEY_IS_LONG || + (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) { break; } @@ -4669,7 +4669,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) zend_object *zobj = Z_OBJ_P(array); int key_type; zend_string *str_key; - zend_ulong int_key; + zend_uint_t int_key; fe_ht = Z_OBJPROP_P(array); zend_hash_set_pointer(fe_ht, (HashPointer*)EX_VAR((opline+1)->op1.var)); @@ -4690,15 +4690,15 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); zend_hash_move_forward(fe_ht); - if (key_type == HASH_KEY_IS_LONG || + if (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS) { break; } } if (key) { - if (key_type == HASH_KEY_IS_LONG) { - ZVAL_LONG(key, int_key); + if (key_type == HASH_KEY_IS_INT) { + ZVAL_INT(key, int_key); } else { const char *class_name, *prop_name; int prop_name_len; @@ -4764,7 +4764,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) HANDLE_EXCEPTION(); } } else { - ZVAL_LONG(key, iter->index); + ZVAL_INT(key, iter->index); } } break; @@ -4869,7 +4869,7 @@ ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV zend_free_op free_op1, free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -4891,14 +4891,14 @@ ZEND_VM_C_LABEL(isset_again): } ZEND_VM_C_LABEL(str_index_prop): value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); ZEND_VM_C_LABEL(num_index_prop): value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); ZEND_VM_C_GOTO(num_index_prop); case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -4943,20 +4943,20 @@ ZEND_VM_C_LABEL(num_index_prop): zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -5020,8 +5020,8 @@ ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMP|VAR|UNUSED|CV, ANY) zend_free_op free_op1; zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -5037,9 +5037,9 @@ ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY) USE_OPLINE SAVE_OPLINE(); - ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting)); + ZVAL_INT(EX_VAR(opline->result.var), EG(error_reporting)); if (Z_TYPE(EX(old_error_reporting)) == IS_UNDEF) { - ZVAL_LONG(&EX(old_error_reporting), EG(error_reporting)); + ZVAL_INT(&EX(old_error_reporting), EG(error_reporting)); } if (EG(error_reporting)) { @@ -5085,12 +5085,12 @@ ZEND_VM_HANDLER(142, ZEND_RAISE_ABSTRACT_ERROR, ANY, ANY) ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY) { USE_OPLINE - char buf[MAX_LENGTH_OF_LONG + 1]; + char buf[MAX_LENGTH_OF_ZEND_INT + 1]; char *res; SAVE_OPLINE(); - if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) { - EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var)); + if (!EG(error_reporting) && Z_IVAL_P(EX_VAR(opline->op1.var)) != 0) { + EG(error_reporting) = Z_IVAL_P(EX_VAR(opline->op1.var)); _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res); if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) { if (EXPECTED(EG(error_reporting_ini_entry)->modified && @@ -5460,14 +5460,14 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) } /* restore previous error_reporting value */ - if (!EG(error_reporting) && Z_TYPE(EX(old_error_reporting)) != IS_UNDEF && Z_LVAL(EX(old_error_reporting)) != 0) { + if (!EG(error_reporting) && Z_TYPE(EX(old_error_reporting)) != IS_UNDEF && Z_IVAL(EX(old_error_reporting)) != 0) { zval restored_error_reporting; zend_string *key; - ZVAL_LONG(&restored_error_reporting, Z_LVAL(EX(old_error_reporting))); + ZVAL_INT(&restored_error_reporting, Z_IVAL(EX(old_error_reporting))); convert_to_string(&restored_error_reporting); key = STR_INIT("error_reporting", sizeof("error_reporting")-1, 0); - zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC); + zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRSIZE(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC); STR_FREE(key); zval_dtor(&restored_error_reporting); } @@ -5721,15 +5721,15 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSE ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -5868,15 +5868,15 @@ ZEND_VM_HANDLER(121, ZEND_STRLEN, CONST|TMP|VAR|CV, ANY) SAVE_OPLINE(); value = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { - ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); + ZVAL_INT(EX_VAR(opline->result.var), Z_STRSIZE_P(value)); } else { if (Z_TYPE_P(value) < IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 0); + ZVAL_INT(EX_VAR(opline->result.var), 0); } else if (Z_TYPE_P(value) == IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); } else if (Z_TYPE_P(value) <= IS_DOUBLE) { zend_string *str = zval_get_string(value); - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else if (Z_TYPE_P(value) == IS_OBJECT) { zend_string *str; @@ -5884,7 +5884,7 @@ ZEND_VM_HANDLER(121, ZEND_STRLEN, CONST|TMP|VAR|CV, ANY) if (parse_arg_object_to_str(value, &str, IS_STRING TSRMLS_CC) == FAILURE) { ZEND_VM_C_GOTO(strlen_error); } - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else { ZEND_VM_C_LABEL(strlen_error): @@ -5907,7 +5907,7 @@ ZEND_VM_HANDLER(123, ZEND_TYPE_CHECK, CONST|TMP|VAR|CV, ANY) value = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R); switch (opline->extended_value) { case IS_NULL: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_ARRAY: diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index c2e59c1441..93309b5da1 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1110,9 +1110,9 @@ static int ZEND_FASTCALL ZEND_BEGIN_SILENCE_SPEC_HANDLER(ZEND_OPCODE_HANDLER_AR USE_OPLINE SAVE_OPLINE(); - ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting)); + ZVAL_INT(EX_VAR(opline->result.var), EG(error_reporting)); if (Z_TYPE(EX(old_error_reporting)) == IS_UNDEF) { - ZVAL_LONG(&EX(old_error_reporting), EG(error_reporting)); + ZVAL_INT(&EX(old_error_reporting), EG(error_reporting)); } if (EG(error_reporting)) { @@ -1367,14 +1367,14 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER } /* restore previous error_reporting value */ - if (!EG(error_reporting) && Z_TYPE(EX(old_error_reporting)) != IS_UNDEF && Z_LVAL(EX(old_error_reporting)) != 0) { + if (!EG(error_reporting) && Z_TYPE(EX(old_error_reporting)) != IS_UNDEF && Z_IVAL(EX(old_error_reporting)) != 0) { zval restored_error_reporting; zend_string *key; - ZVAL_LONG(&restored_error_reporting, Z_LVAL(EX(old_error_reporting))); + ZVAL_INT(&restored_error_reporting, Z_IVAL(EX(old_error_reporting))); convert_to_string(&restored_error_reporting); key = STR_INIT("error_reporting", sizeof("error_reporting")-1, 0); - zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC); + zend_alter_ini_entry_ex(key, Z_STRVAL(restored_error_reporting), Z_STRSIZE(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME, 1 TSRMLS_CC); STR_FREE(key); zval_dtor(&restored_error_reporting); } @@ -1583,11 +1583,11 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { if (Z_STRVAL_P(function_name)[0] == '\\') { - lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name) - 1, 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRSIZE_P(function_name) - 1); } else { - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); @@ -1769,7 +1769,7 @@ static int ZEND_FASTCALL ZEND_BRK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->op1.opline_num, &EX(func)->op_array, execute_data TSRMLS_CC); ZEND_VM_JMP(EX(func)->op_array.opcodes + el->brk); } @@ -1780,7 +1780,7 @@ static int ZEND_FASTCALL ZEND_CONT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->op1.opline_num, &EX(func)->op_array, execute_data TSRMLS_CC); ZEND_VM_JMP(EX(func)->op_array.opcodes + el->cont); } @@ -1792,7 +1792,7 @@ static int ZEND_FASTCALL ZEND_GOTO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_brk_cont_element *el; SAVE_OPLINE(); - el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value, + el = zend_brk_cont(Z_IVAL_P(opline->op2.zv), opline->extended_value, &EX(func)->op_array, execute_data TSRMLS_CC); brk_opline = EX(func)->op_array.opcodes + el->brk; @@ -1912,11 +1912,11 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { if (Z_STRVAL_P(function_name)[0] == '\\') { - lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name) - 1, 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRSIZE_P(function_name) - 1); } else { - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); @@ -2086,11 +2086,11 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { if (Z_STRVAL_P(function_name)[0] == '\\') { - lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name) - 1, 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRSIZE_P(function_name) - 1); } else { - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); @@ -2298,11 +2298,11 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA ZVAL_DEREF(function_name); if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { if (Z_STRVAL_P(function_name)[0] == '\\') { - lcname = STR_ALLOC(Z_STRLEN_P(function_name) - 1, 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRLEN_P(function_name) - 1); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name) - 1, 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name) + 1, Z_STRSIZE_P(function_name) - 1); } else { - lcname = STR_ALLOC(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + lcname = STR_ALLOC(Z_STRSIZE_P(function_name), 0); + zend_str_tolower_copy(lcname->val, Z_STRVAL_P(function_name), Z_STRSIZE_P(function_name)); } if (UNEXPECTED((func = zend_hash_find(EG(function_table), lcname)) == NULL)) { zend_error_noreturn(E_ERROR, "Call to undefined function %s()", Z_STRVAL_P(function_name)); @@ -2441,7 +2441,7 @@ static int ZEND_FASTCALL ZEND_PRINT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS { USE_OPLINE - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); return ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -2868,8 +2868,8 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) case _IS_BOOL: ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC)); break; - case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + case IS_INT: + ZVAL_INT(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -2963,7 +2963,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA inc_filename = &tmp_inc_filename; } - if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) { + if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRSIZE_P(inc_filename)) { if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC); } else { @@ -2976,7 +2976,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA zend_file_handle file_handle; char *resolved_path; - resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename) TSRMLS_CC); + resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRSIZE_P(inc_filename) TSRMLS_CC); if (resolved_path) { failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, strlen(resolved_path)); } else { @@ -3219,12 +3219,12 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A zend_object *zobj = Z_OBJ_P(array_ptr); while (zend_hash_has_more_elements(fe_ht) == SUCCESS) { zend_string *str_key; - ulong int_key; + zend_uint_t int_key; zend_uchar key_type; key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); if (key_type != HASH_KEY_NON_EXISTENT && - (key_type == HASH_KEY_IS_LONG || + (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) { break; } @@ -3259,8 +3259,8 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *ptr = opline->op1.zv; - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -3370,15 +3370,15 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); value = opline->op1.zv; if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { - ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); + ZVAL_INT(EX_VAR(opline->result.var), Z_STRSIZE_P(value)); } else { if (Z_TYPE_P(value) < IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 0); + ZVAL_INT(EX_VAR(opline->result.var), 0); } else if (Z_TYPE_P(value) == IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); } else if (Z_TYPE_P(value) <= IS_DOUBLE) { zend_string *str = zval_get_string(value); - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else if (Z_TYPE_P(value) == IS_OBJECT) { zend_string *str; @@ -3386,7 +3386,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG if (parse_arg_object_to_str(value, &str, IS_STRING TSRMLS_CC) == FAILURE) { goto strlen_error; } - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else { strlen_error: @@ -3409,7 +3409,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER value = opline->op1.zv; switch (opline->extended_value) { case IS_NULL: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_ARRAY: @@ -4122,7 +4122,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv)); } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { - char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); + char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRSIZE_P(opline->op2.zv)); if(!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { @@ -4130,7 +4130,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO } /* non-qualified constant - allow text substitution */ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRSIZE_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -4193,7 +4193,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value); } ZVAL_DUP(EX_VAR(opline->result.var), value); - } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { + } else if (Z_STRSIZE_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ ZVAL_STR(EX_VAR(opline->result.var), ce->name); STR_ADDREF(ce->name); @@ -4245,15 +4245,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_O zval *offset = opline->op2.zv; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -4609,15 +4609,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLE ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -5160,15 +5160,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPC zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -5339,15 +5339,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -6043,15 +6043,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPC zend_free_op free_op2; zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -6374,15 +6374,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -6728,15 +6728,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_ zval *offset = NULL; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -7084,15 +7084,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDL ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -7671,15 +7671,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCO zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -7850,15 +7850,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_A ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -7942,7 +7942,7 @@ static int ZEND_FASTCALL ZEND_PRINT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); return ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -8384,8 +8384,8 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) case _IS_BOOL: ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC)); break; - case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + case IS_INT: + ZVAL_INT(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -8480,7 +8480,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND inc_filename = &tmp_inc_filename; } - if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) { + if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRSIZE_P(inc_filename)) { if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC); } else { @@ -8493,7 +8493,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND zend_file_handle file_handle; char *resolved_path; - resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename) TSRMLS_CC); + resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRSIZE_P(inc_filename) TSRMLS_CC); if (resolved_path) { failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, strlen(resolved_path)); } else { @@ -8736,12 +8736,12 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_object *zobj = Z_OBJ_P(array_ptr); while (zend_hash_has_more_elements(fe_ht) == SUCCESS) { zend_string *str_key; - ulong int_key; + zend_uint_t int_key; zend_uchar key_type; key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); if (key_type != HASH_KEY_NON_EXISTENT && - (key_type == HASH_KEY_IS_LONG || + (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) { break; } @@ -8776,8 +8776,8 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; zval *ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -8791,12 +8791,12 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) static int ZEND_FASTCALL ZEND_END_SILENCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - char buf[MAX_LENGTH_OF_LONG + 1]; + char buf[MAX_LENGTH_OF_ZEND_INT + 1]; char *res; SAVE_OPLINE(); - if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) { - EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var)); + if (!EG(error_reporting) && Z_IVAL_P(EX_VAR(opline->op1.var)) != 0) { + EG(error_reporting) = Z_IVAL_P(EX_VAR(opline->op1.var)); _zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res); if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) { if (EXPECTED(EG(error_reporting_ini_entry)->modified && @@ -8936,15 +8936,15 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { - ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); + ZVAL_INT(EX_VAR(opline->result.var), Z_STRSIZE_P(value)); } else { if (Z_TYPE_P(value) < IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 0); + ZVAL_INT(EX_VAR(opline->result.var), 0); } else if (Z_TYPE_P(value) == IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); } else if (Z_TYPE_P(value) <= IS_DOUBLE) { zend_string *str = zval_get_string(value); - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else if (Z_TYPE_P(value) == IS_OBJECT) { zend_string *str; @@ -8952,7 +8952,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (parse_arg_object_to_str(value, &str, IS_STRING TSRMLS_CC) == FAILURE) { goto strlen_error; } - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else { strlen_error: @@ -8975,7 +8975,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_A value = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); switch (opline->extended_value) { case IS_NULL: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_ARRAY: @@ -9645,15 +9645,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPC zval *offset = opline->op2.zv; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -9976,15 +9976,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -10484,15 +10484,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCOD zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -10663,15 +10663,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -11324,15 +11324,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCOD zend_free_op free_op2; zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -11655,15 +11655,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -11893,15 +11893,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OP zval *offset = NULL; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -12224,15 +12224,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -12714,15 +12714,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -12893,15 +12893,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -12974,7 +12974,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_increment_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -13029,7 +13029,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_decrement_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -13084,7 +13084,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_increment_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -13138,7 +13138,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG SAVE_OPLINE(); var_ptr = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_decrement_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -13203,7 +13203,7 @@ static int ZEND_FASTCALL ZEND_PRINT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); return ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -13823,8 +13823,8 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) case _IS_BOOL: ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC)); break; - case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + case IS_INT: + ZVAL_INT(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -13920,7 +13920,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND inc_filename = &tmp_inc_filename; } - if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) { + if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRSIZE_P(inc_filename)) { if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC); } else { @@ -13933,7 +13933,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND zend_file_handle file_handle; char *resolved_path; - resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename) TSRMLS_CC); + resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRSIZE_P(inc_filename) TSRMLS_CC); if (resolved_path) { failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, strlen(resolved_path)); } else { @@ -14176,12 +14176,12 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_object *zobj = Z_OBJ_P(array_ptr); while (zend_hash_has_more_elements(fe_ht) == SUCCESS) { zend_string *str_key; - ulong int_key; + zend_uint_t int_key; zend_uchar key_type; key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); if (key_type != HASH_KEY_NON_EXISTENT && - (key_type == HASH_KEY_IS_LONG || + (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) { break; } @@ -14240,7 +14240,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG zend_object *zobj = Z_OBJ_P(array); int key_type; zend_string *str_key; - zend_ulong int_key; + zend_uint_t int_key; fe_ht = Z_OBJPROP_P(array); zend_hash_set_pointer(fe_ht, (HashPointer*)EX_VAR((opline+1)->op1.var)); @@ -14261,15 +14261,15 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); zend_hash_move_forward(fe_ht); - if (key_type == HASH_KEY_IS_LONG || + if (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS) { break; } } if (key) { - if (key_type == HASH_KEY_IS_LONG) { - ZVAL_LONG(key, int_key); + if (key_type == HASH_KEY_IS_INT) { + ZVAL_INT(key, int_key); } else { const char *class_name, *prop_name; int prop_name_len; @@ -14335,7 +14335,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG HANDLE_EXCEPTION(); } } else { - ZVAL_LONG(key, iter->index); + ZVAL_INT(key, iter->index); } } break; @@ -14364,8 +14364,8 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zend_free_op free_op1; zval *ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -14498,15 +14498,15 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { - ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); + ZVAL_INT(EX_VAR(opline->result.var), Z_STRSIZE_P(value)); } else { if (Z_TYPE_P(value) < IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 0); + ZVAL_INT(EX_VAR(opline->result.var), 0); } else if (Z_TYPE_P(value) == IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); } else if (Z_TYPE_P(value) <= IS_DOUBLE) { zend_string *str = zval_get_string(value); - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else if (Z_TYPE_P(value) == IS_OBJECT) { zend_string *str; @@ -14514,7 +14514,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (parse_arg_object_to_str(value, &str, IS_STRING TSRMLS_CC) == FAILURE) { goto strlen_error; } - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else { strlen_error: @@ -14537,7 +14537,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_A value = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); switch (opline->extended_value) { case IS_NULL: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_ARRAY: @@ -16180,7 +16180,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv)); } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { - char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); + char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRSIZE_P(opline->op2.zv)); if(!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { @@ -16188,7 +16188,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE } /* non-qualified constant - allow text substitution */ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRSIZE_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -16251,7 +16251,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value); } ZVAL_DUP(EX_VAR(opline->result.var), value); - } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { + } else if (Z_STRSIZE_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ ZVAL_STR(EX_VAR(opline->result.var), ce->name); STR_ADDREF(ce->name); @@ -16303,15 +16303,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPC zval *offset = opline->op2.zv; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -16461,7 +16461,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND zend_free_op free_op1; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -16477,11 +16477,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -16669,7 +16669,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CONST_HANDLER(ZEND zend_free_op free_op1; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -16691,14 +16691,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -16743,20 +16743,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -16908,15 +16908,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -18442,15 +18442,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCOD zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -18528,7 +18528,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE zend_free_op free_op1, free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -18544,11 +18544,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -18656,7 +18656,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_TMP_HANDLER(ZEND_O zend_free_op free_op1, free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -18678,14 +18678,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -18730,20 +18730,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -18897,15 +18897,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -20648,15 +20648,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCOD zend_free_op free_op2; zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -20806,7 +20806,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE zend_free_op free_op1, free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -20822,11 +20822,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -21014,7 +21014,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_VAR_HANDLER(ZEND_O zend_free_op free_op1, free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -21036,14 +21036,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -21088,20 +21088,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -21255,15 +21255,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -22108,15 +22108,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OP zval *offset = NULL; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -22458,15 +22458,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -24031,15 +24031,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -24117,7 +24117,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER zend_free_op free_op1; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -24133,11 +24133,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -24245,7 +24245,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_VAR_CV_HANDLER(ZEND_OP zend_free_op free_op1; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -24267,14 +24267,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -24319,20 +24319,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -24484,15 +24484,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -24603,8 +24603,8 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS zval *ptr = NULL; - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -25457,7 +25457,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC c = CACHED_PTR(Z_CACHE_SLOT_P(opline->op2.zv)); } else if ((c = zend_quick_get_constant(opline->op2.zv + 1, opline->extended_value TSRMLS_CC)) == NULL) { if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { - char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); + char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRSIZE_P(opline->op2.zv)); if(!actual) { actual = Z_STRVAL_P(opline->op2.zv); } else { @@ -25465,7 +25465,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC } /* non-qualified constant - allow text substitution */ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRSIZE_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -25528,7 +25528,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(opline->op2.zv), ce, value); } ZVAL_DUP(EX_VAR(opline->result.var), value); - } else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { + } else if (Z_STRSIZE_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) { /* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */ ZVAL_STR(EX_VAR(opline->result.var), ce->name); STR_ADDREF(ce->name); @@ -25578,7 +25578,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); @@ -25594,11 +25594,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -25706,7 +25706,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CONST_HANDLER(Z zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -25728,14 +25728,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -25780,20 +25780,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_UNUSED == IS_CV || IS_UNUSED == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -25944,15 +25944,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDL ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -26858,7 +26858,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN zend_free_op free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); @@ -26874,11 +26874,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -26986,7 +26986,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_TMP_HANDLER(ZEN zend_free_op free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -27008,14 +27008,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -27060,20 +27060,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_UNUSED == IS_CV || IS_UNUSED == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -27226,15 +27226,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -28140,7 +28140,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN zend_free_op free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); @@ -28156,11 +28156,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -28268,7 +28268,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_VAR_HANDLER(ZEN zend_free_op free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -28290,14 +28290,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -28342,20 +28342,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_UNUSED == IS_CV || IS_UNUSED == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -28508,15 +28508,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -29024,15 +29024,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HAND ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -29931,7 +29931,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(TSRMLS_C); @@ -29947,11 +29947,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -30059,7 +30059,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_UNUSED_CV_HANDLER(ZEND zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -30081,14 +30081,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -30133,20 +30133,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_UNUSED == IS_CV || IS_UNUSED == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -30297,15 +30297,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -30368,7 +30368,7 @@ static int ZEND_FASTCALL ZEND_PRE_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_increment_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -30422,7 +30422,7 @@ static int ZEND_FASTCALL ZEND_PRE_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { fast_decrement_function(var_ptr); if (RETURN_VALUE_USED(opline)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); @@ -30476,7 +30476,7 @@ static int ZEND_FASTCALL ZEND_POST_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_increment_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -30529,7 +30529,7 @@ static int ZEND_FASTCALL ZEND_POST_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS SAVE_OPLINE(); var_ptr = _get_zval_ptr_cv_BP_VAR_RW(execute_data, opline->op1.var TSRMLS_CC); - if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) { + if (EXPECTED(Z_TYPE_P(var_ptr) == IS_INT)) { ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr); fast_decrement_function(var_ptr); ZEND_VM_NEXT_OPCODE(); @@ -30592,7 +30592,7 @@ static int ZEND_FASTCALL ZEND_PRINT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); return ZEND_ECHO_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } @@ -31183,8 +31183,8 @@ static int ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) case _IS_BOOL: ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC)); break; - case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + case IS_INT: + ZVAL_INT(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -31278,7 +31278,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL inc_filename = &tmp_inc_filename; } - if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) { + if (opline->extended_value != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRSIZE_P(inc_filename)) { if (opline->extended_value == ZEND_INCLUDE_ONCE || opline->extended_value == ZEND_INCLUDE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC); } else { @@ -31291,7 +31291,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL zend_file_handle file_handle; char *resolved_path; - resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename) TSRMLS_CC); + resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), Z_STRSIZE_P(inc_filename) TSRMLS_CC); if (resolved_path) { failure_retval = zend_hash_str_exists(&EG(included_files), resolved_path, strlen(resolved_path)); } else { @@ -31534,12 +31534,12 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS zend_object *zobj = Z_OBJ_P(array_ptr); while (zend_hash_has_more_elements(fe_ht) == SUCCESS) { zend_string *str_key; - ulong int_key; + zend_uint_t int_key; zend_uchar key_type; key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0); if (key_type != HASH_KEY_NON_EXISTENT && - (key_type == HASH_KEY_IS_LONG || + (key_type == HASH_KEY_IS_INT || zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) { break; } @@ -31574,8 +31574,8 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); + if (Z_TYPE_P(ptr) == IS_INT) { + EG(exit_status) = Z_IVAL_P(ptr); } else { zend_print_variable(ptr TSRMLS_CC); } @@ -31706,15 +31706,15 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) SAVE_OPLINE(); value = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); if (EXPECTED(Z_TYPE_P(value) == IS_STRING)) { - ZVAL_LONG(EX_VAR(opline->result.var), Z_STRLEN_P(value)); + ZVAL_INT(EX_VAR(opline->result.var), Z_STRSIZE_P(value)); } else { if (Z_TYPE_P(value) < IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 0); + ZVAL_INT(EX_VAR(opline->result.var), 0); } else if (Z_TYPE_P(value) == IS_TRUE) { - ZVAL_LONG(EX_VAR(opline->result.var), 1); + ZVAL_INT(EX_VAR(opline->result.var), 1); } else if (Z_TYPE_P(value) <= IS_DOUBLE) { zend_string *str = zval_get_string(value); - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else if (Z_TYPE_P(value) == IS_OBJECT) { zend_string *str; @@ -31722,7 +31722,7 @@ static int ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) if (parse_arg_object_to_str(value, &str, IS_STRING TSRMLS_CC) == FAILURE) { goto strlen_error; } - ZVAL_LONG(EX_VAR(opline->result.var), str->len); + ZVAL_INT(EX_VAR(opline->result.var), str->len); STR_RELEASE(str); } else { strlen_error: @@ -31745,7 +31745,7 @@ static int ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_AR value = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); switch (opline->extended_value) { case IS_NULL: - case IS_LONG: + case IS_INT: case IS_DOUBLE: case IS_STRING: case IS_ARRAY: @@ -33296,15 +33296,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCO zval *offset = opline->op2.zv; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -33454,7 +33454,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); @@ -33470,11 +33470,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -33662,7 +33662,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_CONST_HANDLER(ZEND_ zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -33684,14 +33684,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -33736,20 +33736,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_CV == IS_CV || IS_CV == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -33900,15 +33900,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_A ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -35346,15 +35346,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE zend_free_op free_op2; zval *offset = _get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -35432,7 +35432,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER zend_free_op free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); @@ -35448,11 +35448,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -35560,7 +35560,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_TMP_HANDLER(ZEND_OP zend_free_op free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -35582,14 +35582,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -35634,20 +35634,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_CV == IS_CV || IS_CV == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -35800,15 +35800,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -37432,15 +37432,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE zend_free_op free_op2; zval *offset = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -37590,7 +37590,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER zend_free_op free_op2; zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); @@ -37606,11 +37606,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -37798,7 +37798,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_VAR_HANDLER(ZEND_OP zend_free_op free_op2; zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -37820,14 +37820,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -37872,20 +37872,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_CV == IS_CV || IS_CV == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -38038,15 +38038,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -38774,15 +38774,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPC zval *offset = NULL; zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -39105,15 +39105,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { @@ -40559,15 +40559,15 @@ static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_ zval *offset = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var TSRMLS_CC); zend_string *str; - ulong hval; + zend_uint_t hval; add_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index: zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr); break; @@ -40645,7 +40645,7 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ zval *container; zval *offset; - ulong hval; + zend_uint_t hval; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(execute_data, opline->op1.var TSRMLS_CC); @@ -40661,11 +40661,11 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ offset_again: switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); zend_hash_index_del(ht, hval); break; - case IS_LONG: - hval = Z_LVAL_P(offset); + case IS_INT: + hval = Z_IVAL_P(offset); num_index_dim: zend_hash_index_del(ht, hval); break; @@ -40773,7 +40773,7 @@ static int ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_CV_HANDLER(ZEND_OPC zval *container; int result; - ulong hval; + zend_uint_t hval; zval *offset; SAVE_OPLINE(); @@ -40795,14 +40795,14 @@ isset_again: } str_index_prop: value = zend_hash_find_ind(ht, str); - } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { - hval = Z_LVAL_P(offset); + } else if (EXPECTED(Z_TYPE_P(offset) == IS_INT)) { + hval = Z_IVAL_P(offset); num_index_prop: value = zend_hash_index_find(ht, hval); } else { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_ival(Z_DVAL_P(offset)); goto num_index_prop; case IS_NULL: str = STR_EMPTY_ALLOC(); @@ -40847,20 +40847,20 @@ num_index_prop: zval tmp; result = 0; - if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { + if (UNEXPECTED(Z_TYPE_P(offset) != IS_INT)) { if (IS_CV == IS_CV || IS_CV == IS_VAR) { ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ - && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { + && IS_INT == is_numeric_string(Z_STRVAL_P(offset), Z_STRSIZE_P(offset), NULL, NULL, 0))) { ZVAL_DUP(&tmp, offset); - convert_to_long(&tmp); + convert_to_int(&tmp); offset = &tmp; } } - if (Z_TYPE_P(offset) == IS_LONG) { - if (offset->value.lval >= 0 && offset->value.lval < Z_STRLEN_P(container)) { + if (Z_TYPE_P(offset) == IS_INT) { + if (offset->value.lval >= 0 && offset->value.lval < Z_STRSIZE_P(container)) { if ((opline->extended_value & ZEND_ISSET) || Z_STRVAL_P(container)[offset->value.lval] != '0') { result = 1; @@ -41011,15 +41011,15 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS ZVAL_COPY_VALUE(&generator->key, key); } - if (Z_TYPE(generator->key) == IS_LONG - && Z_LVAL(generator->key) > generator->largest_used_integer_key + if (Z_TYPE(generator->key) == IS_INT + && Z_IVAL(generator->key) > generator->largest_used_integer_key ) { - generator->largest_used_integer_key = Z_LVAL(generator->key); + generator->largest_used_integer_key = Z_IVAL(generator->key); } } else { /* If no key was specified we use auto-increment keys */ generator->largest_used_integer_key++; - ZVAL_LONG(&generator->key, generator->largest_used_integer_key); + ZVAL_INT(&generator->key, generator->largest_used_integer_key); } if (RETURN_VALUE_USED(opline)) { diff --git a/main/SAPI.c b/main/SAPI.c index f2a0b26779..9d8a19dc6d 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -290,7 +290,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data) } if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds %ld bytes", SG(post_max_size)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_INT_FMT " bytes", SG(post_max_size)); break; } @@ -1004,7 +1004,7 @@ SAPI_API int sapi_flush(TSRMLS_D) } } -SAPI_API struct stat *sapi_get_stat(TSRMLS_D) +SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D) { if (sapi_module.get_stat) { return sapi_module.get_stat(TSRMLS_C); diff --git a/main/SAPI.h b/main/SAPI.h index ac3db56bad..4e67a481c5 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -31,6 +31,7 @@ #include "win32/php_stdint.h" #endif #include <sys/stat.h> +#include "php.h" #define SAPI_OPTION_NO_CHDIR 1 #define SAPI_POST_BLOCK_SIZE 0x4000 @@ -81,7 +82,7 @@ typedef struct { const char *request_method; char *query_string; char *cookie_data; - long content_length; + zend_int_t content_length; char *path_translated; char *request_uri; @@ -124,11 +125,11 @@ typedef struct _sapi_globals_struct { int64_t read_post_bytes; unsigned char post_read; unsigned char headers_sent; - struct stat global_stat; + zend_stat_t global_stat; char *default_mimetype; char *default_charset; HashTable *rfc1867_uploaded_files; - long post_max_size; + zend_int_t post_max_size; int options; zend_bool sapi_started; double global_request_time; @@ -169,7 +170,7 @@ END_EXTERN_C() typedef struct { char *line; /* If you allocated this, you need to free it yourself */ uint line_len; - long response_code; /* long due to zend_parse_parameters compatibility */ + zend_int_t response_code; /* long due to zend_parse_parameters compatibility */ } sapi_header_line; typedef enum { /* Parameter: */ @@ -200,7 +201,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC), unsigned int (*input_filter_init)(TSRMLS_D) TSRMLS_DC); SAPI_API int sapi_flush(TSRMLS_D); -SAPI_API struct stat *sapi_get_stat(TSRMLS_D); +SAPI_API zend_stat_t *sapi_get_stat(TSRMLS_D); SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC); SAPI_API char *sapi_get_default_content_type(TSRMLS_D); @@ -227,9 +228,9 @@ struct _sapi_module_struct { int (*activate)(TSRMLS_D); int (*deactivate)(TSRMLS_D); - int (*ub_write)(const char *str, unsigned int str_length TSRMLS_DC); + php_size_t (*ub_write)(const char *str, php_size_t str_length TSRMLS_DC); void (*flush)(void *server_context TSRMLS_DC); - struct stat *(*get_stat)(TSRMLS_D); + zend_stat_t *(*get_stat)(TSRMLS_D); char *(*getenv)(char *name, size_t name_len TSRMLS_DC); void (*sapi_error)(int type, const char *error_msg, ...); @@ -238,7 +239,7 @@ struct _sapi_module_struct { int (*send_headers)(sapi_headers_struct *sapi_headers TSRMLS_DC); void (*send_header)(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC); - int (*read_post)(char *buffer, uint count_bytes TSRMLS_DC); + php_size_t (*read_post)(char *buffer, php_size_t count_bytes TSRMLS_DC); char *(*read_cookies)(TSRMLS_D); void (*register_server_variables)(zval *track_vars_array TSRMLS_DC); @@ -265,7 +266,7 @@ struct _sapi_module_struct { int (*get_target_uid)(uid_t * TSRMLS_DC); int (*get_target_gid)(gid_t * TSRMLS_DC); - unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC); + unsigned int (*input_filter)(int arg, char *var, char **val, php_size_t val_len, php_size_t *new_val_len TSRMLS_DC); void (*ini_defaults)(HashTable *configuration_hash); int phpinfo_as_text; @@ -299,7 +300,7 @@ struct _sapi_post_entry { #define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg TSRMLS_DC) #define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray TSRMLS_DC) -#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) +#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, php_size_t val_len, php_size_t *new_val_len TSRMLS_DC) BEGIN_EXTERN_C() SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data); diff --git a/main/main.c b/main/main.c index 1fd314b582..6b3f261a45 100644 --- a/main/main.c +++ b/main/main.c @@ -160,7 +160,9 @@ static php_win32_disable_functions(TSRMLS_D) */ static PHP_INI_MH(OnSetPrecision) { - int i = atoi(new_value); + php_int_t i; + + ZEND_ATOI(i, new_value); if (i >= 0) { EG(precision) = i; return SUCCESS; @@ -279,7 +281,7 @@ static void php_binary_init(TSRMLS_D) if ((envpath = getenv("PATH")) != NULL) { char *search_dir, search_path[MAXPATHLEN]; char *last = NULL; - struct stat s; + php_stat_t s; path = estrdup(envpath); search_dir = php_strtok_r(path, ":", &last); @@ -316,11 +318,11 @@ static PHP_INI_MH(OnUpdateTimeout) { if (stage==PHP_INI_STAGE_STARTUP) { /* Don't set a timeout on startup, only per-request */ - EG(timeout_seconds) = atoi(new_value); + ZEND_ATOI(EG(timeout_seconds), new_value); return SUCCESS; } zend_unset_timeout(TSRMLS_C); - EG(timeout_seconds) = atoi(new_value); + ZEND_ATOI(EG(timeout_seconds), new_value); zend_set_timeout(EG(timeout_seconds), 0); return SUCCESS; } @@ -347,7 +349,7 @@ static int php_get_display_errors_mode(char *value, int value_length) } else if (value_length == 6 && !strcasecmp(value, "stdout")) { mode = PHP_DISPLAY_ERRORS_STDOUT; } else { - mode = atoi(value); + ZEND_ATOI(mode, value); if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT; } @@ -707,7 +709,7 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC) /* {{{ php_write wrapper for modules to use PHPWRITE */ -PHPAPI int php_write(void *buf, uint size TSRMLS_DC) +PHPAPI php_size_t php_write(void *buf, php_size_t size TSRMLS_DC) { return PHPWRITE(buf, size); } @@ -715,12 +717,12 @@ PHPAPI int php_write(void *buf, uint size TSRMLS_DC) /* {{{ php_printf */ -PHPAPI int php_printf(const char *format, ...) +PHPAPI php_size_t php_printf(const char *format, ...) { va_list args; - int ret; + php_size_t ret; char *buffer; - int size; + php_size_t size; TSRMLS_FETCH(); va_start(args, format); @@ -1263,7 +1265,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ */ PHPAPI char *php_get_current_user(TSRMLS_D) { - struct stat *pstat; + php_stat_t *pstat; if (SG(request_info).current_user) { return SG(request_info).current_user; @@ -1326,7 +1328,7 @@ PHPAPI char *php_get_current_user(TSRMLS_D) Sets the maximum time a script can run */ PHP_FUNCTION(set_time_limit) { - long new_timeout; + php_int_t new_timeout; char *new_timeout_str; int new_timeout_strlen; zend_string *key; @@ -1335,7 +1337,7 @@ PHP_FUNCTION(set_time_limit) return; } - new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, "%ld", new_timeout); + new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_INT_FMT, new_timeout); key = STR_INIT("max_execution_time", sizeof("max_execution_time")-1, 0); if (zend_alter_ini_entry_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == SUCCESS) { @@ -1921,7 +1923,7 @@ PHPAPI void php_com_initialize(TSRMLS_D) /* {{{ php_output_wrapper */ -static int php_output_wrapper(const char *str, uint str_length) +static php_size_t php_output_wrapper(const char *str, php_size_t str_length) { TSRMLS_FETCH(); return php_output_write(str, str_length TSRMLS_CC); @@ -2178,17 +2180,17 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod /* Register constants */ REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_MAJOR_VERSION", PHP_MAJOR_VERSION, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_MINOR_VERSION", PHP_MINOR_VERSION, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_MAJOR_VERSION", PHP_MAJOR_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_MINOR_VERSION", PHP_MINOR_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, sizeof(PHP_EXTRA_VERSION) - 1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT | CONST_CS); #ifdef ZTS - REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_ZTS", 1, CONST_PERSISTENT | CONST_CS); #else - REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 0, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_ZTS", 0, CONST_PERSISTENT | CONST_CS); #endif - REGISTER_MAIN_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS); @@ -2208,23 +2210,23 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR, sizeof(PHP_CONFIG_FILE_SCAN_DIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", LONG_MIN, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_INT_MAX", PHP_INT_MAX, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_INT_MIN", PHP_INT_MIN, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_INT, CONST_PERSISTENT | CONST_CS); #ifdef PHP_WIN32 - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MINOR", EG(windows_version_info).dwMinorVersion, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_BUILD", EG(windows_version_info).dwBuildNumber, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_PLATFORM", EG(windows_version_info).dwPlatformId, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MAJOR", EG(windows_version_info).wServicePackMajor, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MINOR", EG(windows_version_info).wServicePackMinor, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_SUITEMASK", EG(windows_version_info).wSuiteMask, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_PRODUCTTYPE", EG(windows_version_info).wProductType, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_NT_DOMAIN_CONTROLLER", VER_NT_DOMAIN_CONTROLLER, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_NT_SERVER", VER_NT_SERVER, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_NT_WORKSTATION", VER_NT_WORKSTATION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_MINOR", EG(windows_version_info).dwMinorVersion, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_BUILD", EG(windows_version_info).dwBuildNumber, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_PLATFORM", EG(windows_version_info).dwPlatformId, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_SP_MAJOR", EG(windows_version_info).wServicePackMajor, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_SP_MINOR", EG(windows_version_info).wServicePackMinor, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_SUITEMASK", EG(windows_version_info).wSuiteMask, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_VERSION_PRODUCTTYPE", EG(windows_version_info).wProductType, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_NT_DOMAIN_CONTROLLER", VER_NT_DOMAIN_CONTROLLER, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_NT_SERVER", VER_NT_SERVER, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_INT_CONSTANT("PHP_WINDOWS_NT_WORKSTATION", VER_NT_WORKSTATION, CONST_PERSISTENT | CONST_CS); #endif php_binary_init(TSRMLS_C); @@ -2372,9 +2374,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod const char **p = directives[i].directives; while(*p) { - long value; + php_int_t value; - if (cfg_get_long((char*)*p, &value) == SUCCESS && value) { + if (cfg_get_int((char*)*p, &value) == SUCCESS && value) { zend_error(directives[i].error_level, directives[i].phrase, *p); } diff --git a/main/network.c b/main/network.c index 74855064d7..14db63a21b 100644 --- a/main/network.c +++ b/main/network.c @@ -507,7 +507,7 @@ bound: } /* }}} */ -PHPAPI int php_network_parse_network_address_with_port(const char *addr, long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC) +PHPAPI int php_network_parse_network_address_with_port(const char *addr, php_int_t addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC) { char *colon; char *tmp; @@ -1108,7 +1108,7 @@ PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short p int socktype, struct timeval *timeout, const char *persistent_id STREAMS_DC TSRMLS_DC) { char *res; - long reslen; + php_int_t reslen; php_stream *stream; reslen = spprintf(&res, 0, "tcp://%s:%d", host, port); diff --git a/main/output.c b/main/output.c index 41b2c65cdf..f2cd4d4fbe 100644 --- a/main/output.c +++ b/main/output.c @@ -199,20 +199,20 @@ PHPAPI void php_output_deactivate(TSRMLS_D) /* {{{ void php_output_register_constants() */ PHPAPI void php_output_register_constants(TSRMLS_D) { - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_WRITE", PHP_OUTPUT_HANDLER_WRITE, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FLUSH", PHP_OUTPUT_HANDLER_FLUSH, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CLEAN", PHP_OUTPUT_HANDLER_CLEAN, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FINAL", PHP_OUTPUT_HANDLER_FINAL, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CONT", PHP_OUTPUT_HANDLER_WRITE, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_FINAL, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_WRITE", PHP_OUTPUT_HANDLER_WRITE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_FLUSH", PHP_OUTPUT_HANDLER_FLUSH, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_CLEAN", PHP_OUTPUT_HANDLER_CLEAN, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_FINAL", PHP_OUTPUT_HANDLER_FINAL, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_CONT", PHP_OUTPUT_HANDLER_WRITE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_END", PHP_OUTPUT_HANDLER_FINAL, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_CLEANABLE", PHP_OUTPUT_HANDLER_CLEANABLE, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_FLUSHABLE", PHP_OUTPUT_HANDLER_FLUSHABLE, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_REMOVABLE", PHP_OUTPUT_HANDLER_REMOVABLE, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STDFLAGS", PHP_OUTPUT_HANDLER_STDFLAGS, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_STARTED", PHP_OUTPUT_HANDLER_STARTED, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("PHP_OUTPUT_HANDLER_DISABLED", PHP_OUTPUT_HANDLER_DISABLED, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_CLEANABLE", PHP_OUTPUT_HANDLER_CLEANABLE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_FLUSHABLE", PHP_OUTPUT_HANDLER_FLUSHABLE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_REMOVABLE", PHP_OUTPUT_HANDLER_REMOVABLE, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_STDFLAGS", PHP_OUTPUT_HANDLER_STDFLAGS, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_STARTED", PHP_OUTPUT_HANDLER_STARTED, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("PHP_OUTPUT_HANDLER_DISABLED", PHP_OUTPUT_HANDLER_DISABLED, CONST_CS | CONST_PERSISTENT); } /* }}} */ @@ -404,7 +404,7 @@ PHPAPI int php_output_get_contents(zval *p TSRMLS_DC) PHPAPI int php_output_get_length(zval *p TSRMLS_DC) { if (OG(active)) { - ZVAL_LONG(p, OG(active)->buffer.used); + ZVAL_INT(p, OG(active)->buffer.used); return SUCCESS; } else { ZVAL_NULL(p); @@ -501,8 +501,8 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, handler = php_output_handler_create_internal(ZEND_STRL(php_output_default_handler_name), php_output_handler_default_func, chunk_size, flags TSRMLS_CC); break; case IS_STRING: - if (Z_STRLEN_P(output_handler) && (alias = php_output_handler_alias(Z_STRVAL_P(output_handler), Z_STRLEN_P(output_handler) TSRMLS_CC))) { - handler = alias(Z_STRVAL_P(output_handler), Z_STRLEN_P(output_handler), chunk_size, flags TSRMLS_CC); + if (Z_STRSIZE_P(output_handler) && (alias = php_output_handler_alias(Z_STRVAL_P(output_handler), Z_STRSIZE_P(output_handler) TSRMLS_CC))) { + handler = alias(Z_STRVAL_P(output_handler), Z_STRSIZE_P(output_handler), chunk_size, flags TSRMLS_CC); break; } default: @@ -973,7 +973,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl zval retval, ob_data, ob_mode; ZVAL_STRINGL(&ob_data, handler->buffer.data, handler->buffer.used); - ZVAL_LONG(&ob_mode, (long) context->op); + ZVAL_INT(&ob_mode, (long) context->op); zend_fcall_info_argn(&handler->func.user->fci TSRMLS_CC, 2, &ob_data, &ob_mode); #define PHP_OUTPUT_USER_SUCCESS(retval) ((Z_TYPE(retval) != IS_UNDEF) && !(Z_TYPE(retval) == IS_FALSE)) @@ -982,9 +982,9 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl status = PHP_OUTPUT_HANDLER_NO_DATA; if (Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { convert_to_string_ex(&retval); - if (Z_STRLEN(retval)) { - context->out.data = estrndup(Z_STRVAL(retval), Z_STRLEN(retval)); - context->out.used = Z_STRLEN(retval); + if (Z_STRSIZE(retval)) { + context->out.data = estrndup(Z_STRVAL(retval), Z_STRSIZE(retval)); + context->out.used = Z_STRSIZE(retval); context->out.free = 1; status = PHP_OUTPUT_HANDLER_SUCCESS; } @@ -1197,12 +1197,12 @@ static inline zval *php_output_handler_status(php_output_handler *handler, zval array_init(entry); add_assoc_str(entry, "name", STR_COPY(handler->name)); - add_assoc_long(entry, "type", (long) (handler->flags & 0xf)); - add_assoc_long(entry, "flags", (long) handler->flags); - add_assoc_long(entry, "level", (long) handler->level); - add_assoc_long(entry, "chunk_size", (long) handler->size); - add_assoc_long(entry, "buffer_size", (long) handler->buffer.size); - add_assoc_long(entry, "buffer_used", (long) handler->buffer.used); + add_assoc_int(entry, "type", (php_int_t) (handler->flags & 0xf)); + add_assoc_int(entry, "flags", (php_int_t) handler->flags); + add_assoc_int(entry, "level", (php_int_t) handler->level); + add_assoc_int(entry, "chunk_size", (php_int_t) handler->size); + add_assoc_int(entry, "buffer_size", (php_int_t) handler->buffer.size); + add_assoc_int(entry, "buffer_used", (php_int_t) handler->buffer.used); return entry; } @@ -1316,8 +1316,8 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co PHP_FUNCTION(ob_start) { zval *output_handler = NULL; - long chunk_size = 0; - long flags = PHP_OUTPUT_HANDLER_STDFLAGS; + php_int_t chunk_size = 0; + php_int_t flags = PHP_OUTPUT_HANDLER_STDFLAGS; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags) == FAILURE) { return; @@ -1475,7 +1475,7 @@ PHP_FUNCTION(ob_get_level) return; } - RETURN_LONG(php_output_get_level(TSRMLS_C)); + RETURN_INT(php_output_get_level(TSRMLS_C)); } /* }}} */ @@ -1539,7 +1539,7 @@ PHP_FUNCTION(ob_get_status) Turn implicit flush on/off and is equivalent to calling flush() after every output call */ PHP_FUNCTION(ob_implicit_flush) { - long flag = 1; + php_int_t flag = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { return; diff --git a/main/php.h b/main/php.h index f9cfd2d7f2..68e94869e0 100644 --- a/main/php.h +++ b/main/php.h @@ -66,6 +66,14 @@ # define PHP_EOL "\n" #endif +#define php_size_t zend_size_t +#define php_int_t zend_int_t +#define php_uint_t zend_uint_t +#define PHP_INT_MAX ZEND_INT_MAX +#define PHP_INT_MIN ZEND_INT_MIN +#define PHP_UINT_MAX ZEND_UINT_MAX +#define PHP_SIZE_MAX ZEND_SIZE_MAX + #ifdef NETWARE /* For php_get_uname() function */ #define PHP_UNAME "NetWare" @@ -280,8 +288,8 @@ ssize_t pread(int, void *, size_t, off64_t); BEGIN_EXTERN_C() void phperror(char *error); -PHPAPI int php_write(void *buf, uint size TSRMLS_DC); -PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, +PHPAPI php_size_t php_write(void *buf, php_size_t size TSRMLS_DC); +PHPAPI php_size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2); PHPAPI int php_get_module_initialized(void); PHPAPI void php_log_err(char *log_message TSRMLS_DC); diff --git a/main/php_globals.h b/main/php_globals.h index 9baabf757c..defb220c76 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -56,7 +56,7 @@ typedef struct _arg_separators { struct _php_core_globals { zend_bool implicit_flush; - long output_buffering; + zend_int_t output_buffering; zend_bool sql_safe_mode; zend_bool enable_dl; @@ -64,16 +64,16 @@ struct _php_core_globals { char *output_handler; char *unserialize_callback_func; - long serialize_precision; + zend_int_t serialize_precision; - long memory_limit; - long max_input_time; + zend_int_t memory_limit; + zend_int_t max_input_time; zend_bool track_errors; zend_bool display_errors; zend_bool display_startup_errors; zend_bool log_errors; - long log_errors_max_len; + zend_int_t log_errors_max_len; zend_bool ignore_repeated_errors; zend_bool ignore_repeated_source; zend_bool report_memleaks; @@ -88,7 +88,7 @@ struct _php_core_globals { char *sys_temp_dir; char *upload_tmp_dir; - long upload_max_filesize; + zend_int_t upload_max_filesize; char *error_append_string; char *error_prepend_string; @@ -126,7 +126,7 @@ struct _php_core_globals { zend_bool html_errors; zend_bool xmlrpc_errors; - long xmlrpc_error_number; + zend_int_t xmlrpc_error_number; zend_bool activated_auto_globals[8]; @@ -149,12 +149,12 @@ struct _php_core_globals { #ifdef PHP_WIN32 zend_bool com_initialized; #endif - long max_input_nesting_level; - long max_input_vars; + zend_int_t max_input_nesting_level; + zend_int_t max_input_vars; zend_bool in_user_include; char *user_ini_filename; - long user_ini_cache_ttl; + zend_int_t user_ini_cache_ttl; char *request_order; diff --git a/main/php_ini.c b/main/php_ini.c index cdd4a61fb5..54944483d2 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -233,10 +233,10 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* PHP and Zend extensions are not added into configuration hash! */ if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); zend_llist_add_element(&extension_lists.functions, &extension_name); } else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); zend_llist_add_element(&extension_lists.engine, &extension_name); /* All other entries are added into either configuration_hash or active ini section array */ @@ -267,7 +267,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } /* arg3 is possible option offset name */ - if (arg3 && Z_STRLEN_P(arg3) > 0) { + if (arg3 && Z_STRSIZE_P(arg3) > 0) { entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2); } else { entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2); @@ -287,7 +287,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("PATH") - 1; - key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1; + key_len = Z_STRSIZE_P(arg1) - sizeof("PATH") + 1; is_special_section = 1; has_per_dir_config = 1; @@ -298,7 +298,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } else if (!strncasecmp(Z_STRVAL_P(arg1), "HOST", sizeof("HOST") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("HOST") - 1; - key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1; + key_len = Z_STRSIZE_P(arg1) - sizeof("HOST") + 1; is_special_section = 1; has_per_host_config = 1; zend_str_tolower(key, key_len); /* host names are case-insensitive. */ @@ -545,7 +545,7 @@ int php_init_config(TSRMLS_D) /* Check if php_ini_file_name is a file and can be opened */ if (php_ini_file_name && php_ini_file_name[0]) { - struct stat statbuf; + php_stat_t statbuf; if (!VCWD_STAT(php_ini_file_name, &statbuf)) { if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) { @@ -598,7 +598,7 @@ int php_init_config(TSRMLS_D) if (php_ini_opened_path) { efree(php_ini_opened_path); } - php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp)); + php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRSIZE(tmp)); } } @@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D) if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { struct dirent **namelist; int ndir, i; - struct stat sb; + php_stat_t sb; char ini_file[MAXPATHLEN]; char *p; zend_file_handle fh2; @@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D) */ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC) { - struct stat sb; + php_stat_t sb; char ini_file[MAXPATHLEN]; zend_file_handle fh; @@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int { zend_string *str; zval *data; - ulong num_index; + zend_uint_t num_index; /* Walk through config hash and alter matching ini entries using the values found in the hash */ for (zend_hash_internal_pointer_reset(source_hash); @@ -786,7 +786,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int zend_hash_move_forward(source_hash) ) { data = zend_hash_get_current_data(source_hash); - zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); + zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRSIZE_P(data), modify_type, stage, 0 TSRMLS_CC); } } /* }}} */ @@ -873,9 +873,9 @@ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) } /* }}} */ -/* {{{ cfg_get_long +/* {{{ cfg_get_int */ -PHPAPI int cfg_get_long(const char *varname, long *result) +PHPAPI int cfg_get_int(const char *varname, zend_int_t *result) { zval *tmp, var; @@ -884,8 +884,8 @@ PHPAPI int cfg_get_long(const char *varname, long *result) return FAILURE; } ZVAL_DUP(&var, tmp); - convert_to_long(&var); - *result = Z_LVAL(var); + convert_to_int(&var); + *result = Z_IVAL(var); return SUCCESS; } /* }}} */ diff --git a/main/php_ini.h b/main/php_ini.h index 4159e7591f..491ad1cbd8 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -29,7 +29,7 @@ int php_init_config(TSRMLS_D); int php_shutdown_config(void); void php_ini_register_extensions(TSRMLS_D); PHPAPI zval *cfg_get_entry(const char *name, uint name_length); -PHPAPI int cfg_get_long(const char *varname, long *result); +PHPAPI int cfg_get_int(const char *varname, zend_int_t *result); PHPAPI int cfg_get_double(const char *varname, double *result); PHPAPI int cfg_get_string(const char *varname, char **result); PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC); @@ -83,7 +83,7 @@ END_EXTERN_C() #define php_alter_ini_entry zend_alter_ini_entry -#define php_ini_long zend_ini_long +#define php_ini_long zend_ini_int #define php_ini_double zend_ini_double #define php_ini_string zend_ini_string diff --git a/main/php_network.h b/main/php_network.h index 3a0062c437..cc6e1c54e7 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -306,7 +306,7 @@ PHPAPI void php_network_populate_name_from_sockaddr( TSRMLS_DC); PHPAPI int php_network_parse_network_address_with_port(const char *addr, - long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC); + php_int_t addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC); END_EXTERN_C() #define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC TSRMLS_CC) diff --git a/main/php_streams.h b/main/php_streams.h index 38215a67b0..229f8f49e0 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -103,8 +103,18 @@ typedef struct _php_stream_filter php_stream_filter; #include "streams/php_stream_context.h" #include "streams/php_stream_filter_api.h" +#ifdef _WIN64 +# define php_fstat _fstat64 +# define php_stat_fn _stat64 +typedef struct __stat64 php_stat_t; +#else +# define php_fstat fstat +# define php_stat_fn stat +typedef struct stat php_stat_t; +#endif + typedef struct _php_stream_statbuf { - struct stat sb; /* regular info */ + zend_stat_t sb; /* regular info */ /* extended info to go here some day: content-type etc. etc. */ } php_stream_statbuf; @@ -123,7 +133,7 @@ typedef struct _php_stream_ops { const char *label; /* label for this ops structure */ /* these are optional */ - int (*seek)(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC); + int (*seek)(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC); int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC); int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC); int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); @@ -209,11 +219,11 @@ struct _php_stream { int flags; /* PHP_STREAM_FLAG_XXX */ /* buffer */ - off_t position; /* of underlying stream */ + zend_off_t position; /* of underlying stream */ unsigned char *readbuf; size_t readbuflen; - off_t readpos; - off_t writepos; + zend_off_t readpos; + zend_off_t writepos; /* how much data to read when filling buffer */ size_t chunk_size; @@ -279,11 +289,11 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC); #define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC) #define php_stream_pclose(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE_PERSISTENT TSRMLS_CC) -PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC); +PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC); #define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET TSRMLS_CC) #define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence) TSRMLS_CC) -PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC); +PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC); #define php_stream_tell(stream) _php_stream_tell((stream) TSRMLS_CC) PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC); diff --git a/main/php_variables.c b/main/php_variables.c index 3bb6d65aa5..94ec65f7de 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -141,7 +141,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars /* do not output the error message to the screen, this helps us to to avoid "information disclosure" */ if (!PG(display_errors)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded " ZEND_INT_FMT ". To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level)); } free_alloca(var_orig, use_heap); return; @@ -246,7 +246,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR char *ksep, *vsep; size_t klen, vlen; /* FIXME: string-size_t */ - unsigned int new_vlen; + php_size_t new_vlen; if (var->ptr >= var->end) { return 0; @@ -442,13 +442,13 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data) } if (++count > PG(max_input_vars)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_INT_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars)); break; } if (val) { /* have a value */ - int val_len; - unsigned int new_val_len; + php_size_t val_len; + php_size_t new_val_len; *val++ = '\0'; php_url_decode(var, strlen(var)); @@ -459,8 +459,8 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data) } efree(val); } else { - int val_len; - unsigned int new_val_len; + php_size_t val_len; + php_size_t new_val_len; php_url_decode(var, strlen(var)); val_len = 0; @@ -562,9 +562,9 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) /* prepare argc */ if (SG(request_info).argc) { - ZVAL_LONG(&argc, SG(request_info).argc); + ZVAL_INT(&argc, SG(request_info).argc); } else { - ZVAL_LONG(&argc, count); + ZVAL_INT(&argc, count); } if (SG(request_info).argc) { @@ -608,7 +608,7 @@ static inline void php_register_server_variables(TSRMLS_D) zval request_time_float, request_time_long; ZVAL_DOUBLE(&request_time_float, sapi_get_request_time(TSRMLS_C)); php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, &PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); - ZVAL_LONG(&request_time_long, zend_dval_to_lval(Z_DVAL(request_time_float))); + ZVAL_INT(&request_time_long, zend_dval_to_ival(Z_DVAL(request_time_float))); php_register_variable_ex("REQUEST_TIME", &request_time_long, &PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); } @@ -621,7 +621,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) { zval *src_entry, *dest_entry; zend_string *string_key; - ulong num_key; + php_uint_t num_key; int globals_check = (dest == (&EG(symbol_table).ht)); ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) { diff --git a/main/rfc1867.c b/main/rfc1867.c index 3347a69ac8..a56777dd79 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -78,14 +78,14 @@ static void safe_php_register_variable(char *var, char *strval, int val_len, zva void php_rfc1867_register_constants(TSRMLS_D) /* {{{ */ { - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_OK", UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_INI_SIZE", UPLOAD_ERROR_A, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_FORM_SIZE", UPLOAD_ERROR_B, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_PARTIAL", UPLOAD_ERROR_C, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_FILE", UPLOAD_ERROR_D, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_TMP_DIR", UPLOAD_ERROR_E, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_CANT_WRITE", UPLOAD_ERROR_F, CONST_CS | CONST_PERSISTENT); - REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_EXTENSION", UPLOAD_ERROR_X, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_OK", UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_INI_SIZE", UPLOAD_ERROR_A, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_FORM_SIZE", UPLOAD_ERROR_B, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_PARTIAL", UPLOAD_ERROR_C, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_NO_FILE", UPLOAD_ERROR_D, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_NO_TMP_DIR", UPLOAD_ERROR_E, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_CANT_WRITE", UPLOAD_ERROR_F, CONST_CS | CONST_PERSISTENT); + REGISTER_MAIN_INT_CONSTANT("UPLOAD_ERR_EXTENSION", UPLOAD_ERROR_X, CONST_CS | CONST_PERSISTENT); } /* }}} */ @@ -701,7 +701,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ php_rfc1867_getword_t getword; php_rfc1867_getword_conf_t getword_conf; php_rfc1867_basename_t _basename; - long count = 0; + php_int_t count = 0; if (php_rfc1867_encoding_translation(TSRMLS_C) && internal_encoding) { getword = php_rfc1867_getword; @@ -714,7 +714,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ } if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) { - sapi_module.sapi_error(E_WARNING, "POST Content-Length of %ld bytes exceeds the limit of %ld bytes", SG(request_info).content_length, SG(post_max_size)); + sapi_module.sapi_error(E_WARNING, "POST Content-Length of " ZEND_INT_FMT " bytes exceeds the limit of " ZEND_INT_FMT " bytes", SG(request_info).content_length, SG(post_max_size)); return; } @@ -787,7 +787,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ char buff[FILLUNIT]; char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL; size_t blen = 0, wlen = 0; - off_t offset; + zend_off_t offset; zend_llist_clean(&header); @@ -850,9 +850,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ /* Normal form variable, safe to read all data into memory */ if (!filename && param) { - unsigned int value_len; + php_size_t value_len; char *value = multipart_buffer_read_body(mbuff, &value_len TSRMLS_CC); - unsigned int new_val_len; /* Dummy variable */ + php_size_t new_val_len; /* Dummy variable */ if (!value) { value = estrdup(""); @@ -889,7 +889,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ safe_php_register_variable(param, value, new_val_len, array_ptr, 0 TSRMLS_CC); } else { if (count == PG(max_input_vars) + 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded " ZEND_INT_FMT ". To increase the limit change max_input_vars in php.ini.", PG(max_input_vars)); } if (php_rfc1867_callback != NULL) { @@ -1034,14 +1034,14 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ } } - if (PG(upload_max_filesize) > 0 && (long)(total_bytes+blen) > PG(upload_max_filesize)) { + if (PG(upload_max_filesize) > 0 && (php_int_t)(total_bytes+blen) > PG(upload_max_filesize)) { #if DEBUG_FILE_UPLOAD - sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename); + sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of " ZEND_INT_FMT " bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename); #endif cancel_upload = UPLOAD_ERROR_A; - } else if (max_file_size && ((long)(total_bytes+blen) > max_file_size)) { + } else if (max_file_size && ((php_int_t)(total_bytes+blen) > max_file_size)) { #if DEBUG_FILE_UPLOAD - sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename); + sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of " ZEND_INT_FMT " bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename); #endif cancel_upload = UPLOAD_ERROR_B; } else if (blen > 0) { @@ -1224,13 +1224,13 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ int size_overflow = 0; char file_size_buf[65]; - ZVAL_LONG(&error_type, cancel_upload); + ZVAL_INT(&error_type, cancel_upload); /* Add $foo[error] */ if (cancel_upload) { - ZVAL_LONG(&file_size, 0); + ZVAL_INT(&file_size, 0); } else { - if (total_bytes > LONG_MAX) { + if (total_bytes > ZEND_INT_MAX) { #ifdef PHP_WIN32 if (_i64toa_s(total_bytes, file_size_buf, 65, 10)) { file_size_buf[0] = '0'; @@ -1245,7 +1245,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ size_overflow = 1; } else { - ZVAL_LONG(&file_size, total_bytes); + ZVAL_INT(&file_size, total_bytes); } } diff --git a/main/rfc1867.h b/main/rfc1867.h index 1d47165851..b76e3598f5 100644 --- a/main/rfc1867.h +++ b/main/rfc1867.h @@ -51,7 +51,7 @@ typedef struct _multipart_event_file_start { typedef struct _multipart_event_file_data { size_t post_bytes_processed; - off_t offset; + zend_off_t offset; char *data; size_t length; size_t *newlength; diff --git a/main/snprintf.c b/main/snprintf.c index 914cac7133..7a55034341 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -312,7 +312,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c */ /* char * ap_php_conv_10() {{{ */ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned, - register bool_int * is_negative, char *buf_end, register int *len) + register bool_int * is_negative, char *buf_end, register php_size_t *len) { register char *p = buf_end; register u_wide_int magnitude; @@ -370,7 +370,7 @@ char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned, */ /* PHPAPI char * php_conv_fp() {{{ */ PHPAPI char * php_conv_fp(register char format, register double num, - boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len) + boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, php_size_t *len) { register char *s = buf; register char *p, *p_orig; @@ -438,7 +438,7 @@ PHPAPI char * php_conv_fp(register char format, register double num, if (format != 'F') { char temp[EXPONENT_LENGTH]; /* for exponent conversion */ - int t_len; + php_size_t t_len; bool_int exponent_is_negative; *s++ = format; /* either e or E */ @@ -474,7 +474,7 @@ PHPAPI char * php_conv_fp(register char format, register double num, * which is a pointer to the END of the buffer + 1 (i.e. if the buffer * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) */ -char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register int *len) /* {{{ */ +char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, char *buf_end, register php_size_t *len) /* {{{ */ { register int mask = (1 << nbits) - 1; register char *p = buf_end; @@ -584,10 +584,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / char *sp; char *bep; int cc = 0; - int i; + php_size_t i; char *s = NULL; - int s_len, free_zcopy; + php_size_t s_len; + int free_zcopy; zval *zvp, zcopy; int min_width = 0; @@ -758,6 +759,10 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / modifier = LM_SIZE_T; #endif break; + case 'p': + fmt++; + modifier = LM_PHP_INT_T; + break; case 'h': fmt++; if (*fmt == 'h') { @@ -788,7 +793,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / if (free_zcopy) { zvp = &zcopy; } - s_len = Z_STRLEN_P(zvp); + s_len = Z_STRSIZE_P(zvp); s = Z_STRVAL_P(zvp); if (adjust_precision && precision < s_len) { s_len = precision; @@ -823,6 +828,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / i_num = (wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + i_num = (wide_int) va_arg(ap, php_uint_t); + break; } /* * The rest also applies to other integer formats, so fall @@ -865,6 +873,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / i_num = (wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + i_num = (wide_int) va_arg(ap, php_int_t); + break; } } s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative, @@ -911,6 +922,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + ui_num = (u_wide_int) va_arg(ap, php_uint_t); + break; } s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); FIX_PRECISION(adjust_precision, precision, s, s_len); @@ -950,6 +964,9 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + ui_num = (u_wide_int) va_arg(ap, php_uint_t); + break; } s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); FIX_PRECISION(adjust_precision, precision, s, s_len); diff --git a/main/snprintf.h b/main/snprintf.h index 10f0e24fa5..ae179cf6f5 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -87,7 +87,7 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...); PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf); PHPAPI char * php_conv_fp(register char format, register double num, - boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, int *len); + boolean_e add_dp, int precision, char dec_point, bool_int * is_negative, char *buf, php_size_t *len); END_EXTERN_C() @@ -137,7 +137,8 @@ typedef enum { #endif LM_SIZE_T, LM_LONG, - LM_LONG_DOUBLE + LM_LONG_DOUBLE, + LM_PHP_INT_T } length_modifier_e; #ifdef PHP_WIN32 @@ -153,10 +154,10 @@ typedef WIDE_INT wide_int; typedef unsigned WIDE_INT u_wide_int; extern char * ap_php_conv_10(register wide_int num, register bool_int is_unsigned, - register bool_int * is_negative, char *buf_end, register int *len); + register bool_int * is_negative, char *buf_end, register php_size_t *len); extern char * ap_php_conv_p2(register u_wide_int num, register int nbits, - char format, char *buf_end, register int *len); + char format, char *buf_end, register php_size_t *len); /* The maximum precision that's allowed for float conversion. Does not include * decimal separator, exponent, sign, terminator. Currently does not affect diff --git a/main/spprintf.c b/main/spprintf.c index 079089c0fc..5c0310fd9d 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -198,7 +198,8 @@ static size_t strnlen(const char *s, size_t maxlen) { static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt, va_list ap) /* {{{ */ { char *s = NULL; - int s_len, free_zcopy; + php_size_t s_len; + int free_zcopy; zval *zvp, zcopy; int min_width = 0; @@ -366,6 +367,16 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt modifier = LM_SIZE_T; #endif break; + case 'p': { + char __next = *(fmt+1); + if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) { + fmt++; + modifier = LM_PHP_INT_T; + } else { + modifier = LM_STD; + } + } + break; case 'h': fmt++; if (*fmt == 'h') { @@ -396,7 +407,7 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt if (free_zcopy) { zvp = &zcopy; } - s_len = Z_STRLEN_P(zvp); + s_len = Z_STRSIZE_P(zvp); s = Z_STRVAL_P(zvp); if (adjust_precision && precision < s_len) { s_len = precision; @@ -431,6 +442,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt i_num = (wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + i_num = (wide_int) va_arg(ap, php_uint_t); + break; } /* * The rest also applies to other integer formats, so fall @@ -473,6 +487,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt i_num = (wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + i_num = (wide_int) va_arg(ap, php_int_t); + break; } } s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative, @@ -518,6 +535,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + ui_num = (u_wide_int) va_arg(ap, php_uint_t); + break; } s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); @@ -558,6 +578,9 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt ui_num = (u_wide_int) va_arg(ap, ptrdiff_t); break; #endif + case LM_PHP_INT_T: + ui_num = (u_wide_int) va_arg(ap, php_uint_t); + break; } s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len); @@ -796,10 +819,10 @@ skip_output: /* * This is the general purpose conversion function. */ -PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */ +PHPAPI php_size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */ { smart_string buf = {0}; - int result; + php_size_t result; xbuf_format_converter(&buf, 1, format, ap); @@ -821,9 +844,9 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap } /* }}} */ -PHPAPI int spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */ +PHPAPI php_size_t spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */ { - int cc; + php_size_t cc; va_list ap; va_start(ap, format); diff --git a/main/spprintf.h b/main/spprintf.h index ae26a3b9ec..612bcbf5db 100644 --- a/main/spprintf.h +++ b/main/spprintf.h @@ -37,9 +37,9 @@ There is also snprintf: See difference explained in snprintf.h #include "snprintf.h" BEGIN_EXTERN_C() -PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); +PHPAPI php_size_t spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); -PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0); +PHPAPI php_size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0); PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap); diff --git a/main/streams/cast.c b/main/streams/cast.c index 78073c6187..4780d46eea 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -76,7 +76,7 @@ static int stream_cookie_writer(void *cookie, const char *buffer, int size) return php_stream_write((php_stream *)cookie, (char *)buffer, size); } -static PHP_FPOS_T stream_cookie_seeker(void *cookie, off_t position, int whence) +static PHP_FPOS_T stream_cookie_seeker(void *cookie, zend_off_t position, int whence) { TSRMLS_FETCH(); @@ -114,7 +114,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence) { TSRMLS_FETCH(); - *position = php_stream_seek((php_stream *)cookie, (off_t)*position, whence); + *position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence); if (*position == -1) { return -1; @@ -122,7 +122,7 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence) return 0; } # else -static int stream_cookie_seeker(void *cookie, off_t position, int whence) +static int stream_cookie_seeker(void *cookie, zend_off_t position, int whence) { TSRMLS_FETCH(); @@ -206,7 +206,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show if (ret && castas != PHP_STREAM_AS_FD_FOR_SELECT) { php_stream_flush(stream); if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) { - off_t dummy; + zend_off_t dummy; stream->ops->seek(stream, stream->position, SEEK_SET, &dummy TSRMLS_CC); stream->readpos = stream->writepos = 0; @@ -246,7 +246,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show } if (*ret != NULL) { - off_t pos; + zend_off_t pos; stream->fclose_stdiocast = PHP_STREAM_FCLOSE_FOPENCOOKIE; @@ -254,7 +254,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show * the stdio layer to believe it's real location. */ pos = php_stream_tell(stream); if (pos > 0) { - fseek(*ret, pos, SEEK_SET); + zend_fseek(*ret, pos, SEEK_SET); } goto exit_success; @@ -334,7 +334,7 @@ exit_success: * will be accessing the stream. Emit a warning so that the end-user will * know that they should try something else */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld bytes of buffered data lost during stream conversion!", (long)(stream->writepos - stream->readpos)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, ZEND_INT_FMT " bytes of buffered data lost during stream conversion!", (php_int_t)(stream->writepos - stream->readpos)); } if (castas == PHP_STREAM_AS_STDIO && ret) { diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 5a48584f4e..ceb60d5b07 100644 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -180,7 +180,7 @@ static int php_glob_stream_close(php_stream *stream, int close_handle TSRMLS_DC) } /* {{{ */ -static int php_glob_stream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) /* {{{ */ +static int php_glob_stream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) /* {{{ */ { glob_s_t *pglob = (glob_s_t *)stream->abstract; diff --git a/main/streams/memory.c b/main/streams/memory.c index 5da0c8decd..71e9005fa7 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -127,7 +127,7 @@ static int php_stream_memory_flush(php_stream *stream TSRMLS_DC) /* {{{ */ -static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) +static int php_stream_memory_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) { php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract; assert(ms != NULL); @@ -442,7 +442,7 @@ static int php_stream_temp_flush(php_stream *stream TSRMLS_DC) /* {{{ */ -static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) +static int php_stream_temp_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) { php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract; int ret; @@ -468,7 +468,7 @@ static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRML php_stream *file; size_t memsize; char *membuf; - off_t pos; + zend_off_t pos; assert(ts != NULL); @@ -584,7 +584,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char { php_stream *stream; php_stream_temp_data *ts; - off_t newoffs; + zend_off_t newoffs; if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) { if (length) { @@ -618,7 +618,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con php_stream_temp_data *ts; char *comma, *semi, *sep, *key; size_t mlen, dlen, plen, vlen; - off_t newoffs; + zend_off_t newoffs; zval meta; int base64 = 0, ilen; zend_string *base64_comma = NULL; diff --git a/main/streams/mmap.c b/main/streams/mmap.c index 050e95f285..a99c8994aa 100644 --- a/main/streams/mmap.c +++ b/main/streams/mmap.c @@ -51,7 +51,7 @@ PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC) return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0; } -PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC) +PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC) { int ret = 1; diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h index b3570be48c..5d200d729a 100644 --- a/main/streams/php_stream_mmap.h +++ b/main/streams/php_stream_mmap.h @@ -74,7 +74,7 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC); #define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC) -PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC); +PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden TSRMLS_DC); #define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC) END_EXTERN_C() diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 87312b9ef8..d9f058e3cc 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -53,6 +53,12 @@ extern int php_get_uid_by_name(const char *name, uid_t *uid TSRMLS_DC); extern int php_get_gid_by_name(const char *name, gid_t *gid TSRMLS_DC); #endif +#if defined(PHP_WIN32) +# define PLAIN_WRAP_BUF_SIZE(st) (((st) > UINT_MAX) ? UINT_MAX : (unsigned int)(st)) +#else +# define PLAIN_WRAP_BUF_SIZE(st) (st) +#endif + /* parse standard "fopen" modes into open() flags */ PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags) { @@ -132,7 +138,7 @@ typedef struct { HANDLE file_mapping; #endif - struct stat sb; + php_stat_t sb; } php_stdio_stream_data; #define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd @@ -143,7 +149,7 @@ static int do_fstat(php_stdio_stream_data *d, int force) int r; PHP_STDIOP_GET_FD(fd, d); - r = fstat(fd, &d->sb); + r = php_fstat(fd, &d->sb); d->cached_fstat = r == 0; return r; @@ -246,9 +252,9 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha if (self->is_pipe) { stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { - stream->position = lseek(self->fd, 0, SEEK_CUR); + stream->position = zend_lseek(self->fd, 0, SEEK_CUR); #ifdef ESPIPE - if (stream->position == (off_t)-1 && errno == ESPIPE) { + if (stream->position == (zend_off_t)-1 && errno == ESPIPE) { stream->position = 0; stream->flags |= PHP_STREAM_FLAG_NO_SEEK; self->is_pipe = 1; @@ -285,7 +291,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE if (self->is_pipe) { stream->flags |= PHP_STREAM_FLAG_NO_SEEK; } else { - stream->position = ftell(file); + stream->position = zend_ftell(file); } } @@ -342,13 +348,13 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS assert(data != NULL); if (data->fd >= 0) { - ret = read(data->fd, buf, count); + ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count)); if (ret == (size_t)-1 && errno == EINTR) { /* Read was interrupted, retry once, If read still fails, giveup with feof==0 so script can retry if desired */ - ret = read(data->fd, buf, count); + ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count)); } stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR && errno != EBADF)); @@ -356,7 +362,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS } else { #if HAVE_FLUSHIO if (!data->is_pipe && data->last_op == 'w') - fseek(data->file, 0, SEEK_CUR); + zend_fseek(data->file, 0, SEEK_CUR); data->last_op = 'r'; #endif @@ -445,7 +451,7 @@ static int php_stdiop_flush(php_stream *stream TSRMLS_DC) return 0; } -static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) +static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset TSRMLS_DC) { php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract; int ret; @@ -458,18 +464,18 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t * } if (data->fd >= 0) { - off_t result; + zend_off_t result; - result = lseek(data->fd, offset, whence); - if (result == (off_t)-1) + result = zend_lseek(data->fd, offset, whence); + if (result == (zend_off_t)-1) return -1; *newoffset = result; return 0; } else { - ret = fseek(data->file, offset, whence); - *newoffset = ftell(data->file); + ret = zend_fseek(data->file, offset, whence); + *newoffset = zend_ftell(data->file); return ret; } } @@ -831,7 +837,7 @@ static int php_plain_files_dirstream_close(php_stream *stream, int close_handle return closedir((DIR *)stream->abstract); } -static int php_plain_files_dirstream_rewind(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) +static int php_plain_files_dirstream_rewind(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) { rewinddir((DIR *)stream->abstract); return 0; @@ -1096,7 +1102,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f #ifndef PHP_WIN32 # ifdef EXDEV if (errno == EXDEV) { - struct stat sb; + php_stat_t sb; if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) { if (VCWD_STAT(url_from, &sb) == 0) { # if !defined(TSRM_WIN32) && !defined(NETWARE) @@ -1159,7 +1165,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i } else { /* we look for directory separator from the end of string, thus hopefuly reducing our work load */ char *e; - struct stat sb; + php_stat_t sb; int dir_len = strlen(dir); int offset = 0; char buf[MAXPATHLEN]; diff --git a/main/streams/streams.c b/main/streams/streams.c index 89537bdaeb..1a6c4d24a0 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -675,7 +675,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D } else { /* is there enough data in the buffer ? */ - if (stream->writepos - stream->readpos < (off_t)size) { + if (stream->writepos - stream->readpos < (zend_off_t)size) { size_t justread = 0; /* reduce buffer memory consumption if possible, to avoid a realloc */ @@ -1269,12 +1269,12 @@ PHPAPI size_t _php_stream_printf(php_stream *stream TSRMLS_DC, const char *fmt, return count; } -PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC) +PHPAPI zend_off_t _php_stream_tell(php_stream *stream TSRMLS_DC) { return stream->position; } -PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC) +PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence TSRMLS_DC) { if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) { /* flush to commit data written to the fopencookie FILE* */ @@ -2136,7 +2136,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod } if (stream && stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && strchr(mode, 'a') && stream->position == 0) { - off_t newpos = 0; + zend_off_t newpos = 0; /* if opened for append, we need to revise our idea of the initial file position */ if (0 == stream->ops->seek(stream, 0, SEEK_CUR, &newpos TSRMLS_CC)) { diff --git a/main/streams/transports.c b/main/streams/transports.c index 7792e24fef..7f1d13faaa 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -163,8 +163,8 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in if (PHP_STREAM_CONTEXT(stream) && (zbacklog = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "backlog")) != NULL) { zval *ztmp = zbacklog; - convert_to_long_ex(ztmp); - backlog = Z_LVAL_P(ztmp); + convert_to_int_ex(ztmp); + backlog = Z_IVAL_P(ztmp); if (ztmp != zbacklog) { zval_ptr_dtor(ztmp); } diff --git a/main/streams/userspace.c b/main/streams/userspace.c index c41826155c..82ff445c4f 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -86,35 +86,35 @@ PHP_MINIT_FUNCTION(user_streams) if (le_protocols == FAILURE) return FAILURE; - REGISTER_LONG_CONSTANT("STREAM_USE_PATH", USE_PATH, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_IGNORE_URL", IGNORE_URL, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_REPORT_ERRORS", REPORT_ERRORS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_MUST_SEEK", STREAM_MUST_SEEK, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_URL_STAT_LINK", PHP_STREAM_URL_STAT_LINK, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_URL_STAT_QUIET", PHP_STREAM_URL_STAT_QUIET, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_MKDIR_RECURSIVE", PHP_STREAM_MKDIR_RECURSIVE, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_IS_URL", PHP_STREAM_IS_URL, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_OPTION_BLOCKING", PHP_STREAM_OPTION_BLOCKING, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_OPTION_READ_TIMEOUT", PHP_STREAM_OPTION_READ_TIMEOUT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_OPTION_READ_BUFFER", PHP_STREAM_OPTION_READ_BUFFER, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_OPTION_WRITE_BUFFER", PHP_STREAM_OPTION_WRITE_BUFFER, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_BUFFER_NONE", PHP_STREAM_BUFFER_NONE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_BUFFER_LINE", PHP_STREAM_BUFFER_LINE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_BUFFER_FULL", PHP_STREAM_BUFFER_FULL, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_CAST_AS_STREAM", PHP_STREAM_AS_STDIO, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_CAST_FOR_SELECT", PHP_STREAM_AS_FD_FOR_SELECT, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("STREAM_META_TOUCH", PHP_STREAM_META_TOUCH, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_META_OWNER", PHP_STREAM_META_OWNER, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_META_OWNER_NAME", PHP_STREAM_META_OWNER_NAME, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_META_GROUP", PHP_STREAM_META_GROUP, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_META_GROUP_NAME", PHP_STREAM_META_GROUP_NAME, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_META_ACCESS", PHP_STREAM_META_ACCESS, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_USE_PATH", USE_PATH, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_IGNORE_URL", IGNORE_URL, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_REPORT_ERRORS", REPORT_ERRORS, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_MUST_SEEK", STREAM_MUST_SEEK, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_URL_STAT_LINK", PHP_STREAM_URL_STAT_LINK, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_URL_STAT_QUIET", PHP_STREAM_URL_STAT_QUIET, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_MKDIR_RECURSIVE", PHP_STREAM_MKDIR_RECURSIVE, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_IS_URL", PHP_STREAM_IS_URL, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_OPTION_BLOCKING", PHP_STREAM_OPTION_BLOCKING, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_OPTION_READ_TIMEOUT", PHP_STREAM_OPTION_READ_TIMEOUT, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_OPTION_READ_BUFFER", PHP_STREAM_OPTION_READ_BUFFER, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_OPTION_WRITE_BUFFER", PHP_STREAM_OPTION_WRITE_BUFFER, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_BUFFER_NONE", PHP_STREAM_BUFFER_NONE, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_BUFFER_LINE", PHP_STREAM_BUFFER_LINE, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_BUFFER_FULL", PHP_STREAM_BUFFER_FULL, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_CAST_AS_STREAM", PHP_STREAM_AS_STDIO, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_CAST_FOR_SELECT", PHP_STREAM_AS_FD_FOR_SELECT, CONST_CS|CONST_PERSISTENT); + + REGISTER_INT_CONSTANT("STREAM_META_TOUCH", PHP_STREAM_META_TOUCH, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_META_OWNER", PHP_STREAM_META_OWNER, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_META_OWNER_NAME", PHP_STREAM_META_OWNER_NAME, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_META_GROUP", PHP_STREAM_META_GROUP, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_META_GROUP_NAME", PHP_STREAM_META_GROUP_NAME, CONST_CS|CONST_PERSISTENT); + REGISTER_INT_CONSTANT("STREAM_META_ACCESS", PHP_STREAM_META_ACCESS, CONST_CS|CONST_PERSISTENT); return SUCCESS; } @@ -367,7 +367,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * /* call it's stream_open method - set up params first */ ZVAL_STRING(&args[0], filename); ZVAL_STRING(&args[1], mode); - ZVAL_LONG(&args[2], options); + ZVAL_INT(&args[2], options); ZVAL_NEW_REF(&args[3], &EG(uninitialized_zval)); ZVAL_STRING(&zfuncname, USERSTREAM_OPEN); @@ -385,7 +385,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * /* if the opened path is set, copy it out */ if (Z_ISREF(args[3]) && Z_TYPE_P(Z_REFVAL(args[3])) == IS_STRING && opened_path) { - *opened_path = estrndup(Z_STRVAL_P(Z_REFVAL(args[3])), Z_STRLEN_P(Z_REFVAL(args[3]))); + *opened_path = estrndup(Z_STRVAL_P(Z_REFVAL(args[3])), Z_STRSIZE_P(Z_REFVAL(args[3]))); } /* set wrapper data to be a reference to our object */ @@ -443,7 +443,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char /* call it's dir_open method - set up params first */ ZVAL_STRING(&args[0], filename); - ZVAL_LONG(&args[1], options); + ZVAL_INT(&args[1], options); ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN); @@ -490,7 +490,7 @@ PHP_FUNCTION(stream_wrapper_register) zend_string *protocol, *classname; struct php_user_stream_wrapper * uwrap; zend_resource *rsrc; - long flags = 0; + php_int_t flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &protocol, &classname, &flags) == FAILURE) { RETURN_FALSE; @@ -608,8 +608,8 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t didwrite = 0; if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { - convert_to_long(&retval); - didwrite = Z_LVAL(retval); + convert_to_int(&retval); + didwrite = Z_IVAL(retval); } else if (call_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!", us->wrapper->classname); @@ -617,9 +617,9 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t /* don't allow strange buffer overruns due to bogus return */ if (didwrite > count) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote %ld bytes more data than requested (%ld written, %ld max)", + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote " ZEND_INT_FMT " bytes more data than requested (" ZEND_INT_FMT " written, " ZEND_INT_FMT " max)", us->wrapper->classname, - (long)(didwrite - count), (long)didwrite, (long)count); + (php_int_t)(didwrite - count), (php_int_t)didwrite, (php_int_t)count); didwrite = count; } @@ -641,7 +641,7 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count ZVAL_STRINGL(&func_name, USERSTREAM_READ, sizeof(USERSTREAM_READ)-1); - ZVAL_LONG(&args[0], count); + ZVAL_INT(&args[0], count); call_result = call_user_function_ex(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, @@ -652,10 +652,10 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) { convert_to_string(&retval); - didread = Z_STRLEN(retval); + didread = Z_STRSIZE(retval); if (didread > count) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read %ld bytes more data than requested (%ld read, %ld max) - excess data will be lost", - us->wrapper->classname, (long)(didread - count), (long)didread, (long)count); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_INT_FMT " bytes more data than requested (" ZEND_INT_FMT " read, " ZEND_INT_FMT " max) - excess data will be lost", + us->wrapper->classname, (php_int_t)(didread - count), (php_int_t)didread, (php_int_t)count); didread = count; } if (didread > 0) @@ -763,8 +763,8 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o ZVAL_STRINGL(&func_name, USERSTREAM_SEEK, sizeof(USERSTREAM_SEEK)-1); - ZVAL_LONG(&args[0], offset); - ZVAL_LONG(&args[1], whence); + ZVAL_INT(&args[0], offset); + ZVAL_INT(&args[1], whence); call_result = call_user_function_ex(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, @@ -807,8 +807,8 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o &retval, 0, NULL, 0, NULL TSRMLS_CC); - if (call_result == SUCCESS && Z_TYPE(retval) == IS_LONG) { - *newoffs = Z_LVAL(retval); + if (call_result == SUCCESS && Z_TYPE(retval) == IS_INT) { + *newoffs = Z_IVAL(retval); ret = 0; } else if (call_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", us->wrapper->classname); @@ -831,8 +831,8 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb TSRMLS_DC) #define STAT_PROP_ENTRY_EX(name, name2) \ if (NULL != (elem = zend_hash_str_find(Z_ARRVAL_P(array), #name, sizeof(#name)-1))) { \ SEPARATE_ZVAL(elem); \ - convert_to_long(elem); \ - ssb->sb.st_##name2 = Z_LVAL_P(elem); \ + convert_to_int(elem); \ + ssb->sb.st_##name2 = Z_IVAL_P(elem); \ } #define STAT_PROP_ENTRY(name) STAT_PROP_ENTRY_EX(name,name) @@ -927,20 +927,20 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value break; case PHP_STREAM_OPTION_LOCKING: - ZVAL_LONG(&args[0], 0); + ZVAL_INT(&args[0], 0); if (value & LOCK_NB) { - Z_LVAL_P(&args[0]) |= PHP_LOCK_NB; + Z_IVAL_P(&args[0]) |= PHP_LOCK_NB; } switch(value & ~LOCK_NB) { case LOCK_SH: - Z_LVAL_P(&args[0]) |= PHP_LOCK_SH; + Z_IVAL_P(&args[0]) |= PHP_LOCK_SH; break; case LOCK_EX: - Z_LVAL_P(&args[0]) |= PHP_LOCK_EX; + Z_IVAL_P(&args[0]) |= PHP_LOCK_EX; break; case LOCK_UN: - Z_LVAL_P(&args[0]) |= PHP_LOCK_UN; + Z_IVAL_P(&args[0]) |= PHP_LOCK_UN; break; } @@ -987,7 +987,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value case PHP_STREAM_TRUNCATE_SET_SIZE: { ptrdiff_t new_size = *(ptrdiff_t*) ptrparam; if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) { - ZVAL_LONG(&args[0], (long)new_size); + ZVAL_INT(&args[0], (long)new_size); call_result = call_user_function_ex(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, @@ -1025,28 +1025,28 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value ZVAL_STRINGL(&func_name, USERSTREAM_SET_OPTION, sizeof(USERSTREAM_SET_OPTION)-1); - ZVAL_LONG(&args[0], option); + ZVAL_INT(&args[0], option); ZVAL_NULL(&args[1]); ZVAL_NULL(&args[2]); switch(option) { case PHP_STREAM_OPTION_READ_BUFFER: case PHP_STREAM_OPTION_WRITE_BUFFER: - ZVAL_LONG(&args[1], value); + ZVAL_INT(&args[1], value); if (ptrparam) { - ZVAL_LONG(&args[2], *(long *)ptrparam); + ZVAL_INT(&args[2], *(long *)ptrparam); } else { - ZVAL_LONG(&args[2], BUFSIZ); + ZVAL_INT(&args[2], BUFSIZ); } break; case PHP_STREAM_OPTION_READ_TIMEOUT: { struct timeval tv = *(struct timeval*)ptrparam; - ZVAL_LONG(&args[1], tv.tv_sec); - ZVAL_LONG(&args[2], tv.tv_usec); + ZVAL_INT(&args[1], tv.tv_sec); + ZVAL_INT(&args[2], tv.tv_usec); break; } case PHP_STREAM_OPTION_BLOCKING: - ZVAL_LONG(&args[1], value); + ZVAL_INT(&args[1], value); break; default: break; @@ -1189,8 +1189,8 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int /* call the mkdir method */ ZVAL_STRING(&args[0], url); - ZVAL_LONG(&args[1], mode); - ZVAL_LONG(&args[2], options); + ZVAL_INT(&args[1], mode); + ZVAL_INT(&args[2], options); ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR); @@ -1237,7 +1237,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, /* call the rmdir method */ ZVAL_STRING(&args[0], url); - ZVAL_LONG(&args[1], options); + ZVAL_INT(&args[1], options); ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR); @@ -1280,14 +1280,14 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i array_init(&args[2]); if(value) { struct utimbuf *newtime = (struct utimbuf *)value; - add_index_long(&args[2], 0, newtime->modtime); - add_index_long(&args[2], 1, newtime->actime); + add_index_int(&args[2], 0, newtime->modtime); + add_index_int(&args[2], 1, newtime->actime); } break; case PHP_STREAM_META_GROUP: case PHP_STREAM_META_OWNER: case PHP_STREAM_META_ACCESS: - ZVAL_LONG(&args[2], *(long *)value); + ZVAL_INT(&args[2], *(long *)value); break; case PHP_STREAM_META_GROUP_NAME: case PHP_STREAM_META_OWNER_NAME: @@ -1308,7 +1308,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i /* call the mkdir method */ ZVAL_STRING(&args[0], url); - ZVAL_LONG(&args[1], option); + ZVAL_INT(&args[1], option); ZVAL_STRING(&zfuncname, USERSTREAM_METADATA); @@ -1356,7 +1356,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i /* call it's stat_url method - set up params first */ ZVAL_STRING(&args[0], url); - ZVAL_LONG(&args[1], flags); + ZVAL_INT(&args[1], flags); ZVAL_STRING(&zfuncname, USERSTREAM_STATURL); @@ -1414,7 +1414,7 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou if (call_result == SUCCESS && Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { convert_to_string(&retval); - PHP_STRLCPY(ent->d_name, Z_STRVAL(retval), sizeof(ent->d_name), Z_STRLEN(retval)); + PHP_STRLCPY(ent->d_name, Z_STRVAL(retval), sizeof(ent->d_name), Z_STRSIZE(retval)); didread = sizeof(php_stream_dirent); } else if (call_result == FAILURE) { @@ -1489,10 +1489,10 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr T switch(castas) { case PHP_STREAM_AS_FD_FOR_SELECT: - ZVAL_LONG(&args[0], PHP_STREAM_AS_FD_FOR_SELECT); + ZVAL_INT(&args[0], PHP_STREAM_AS_FD_FOR_SELECT); break; default: - ZVAL_LONG(&args[0], PHP_STREAM_AS_STDIO); + ZVAL_INT(&args[0], PHP_STREAM_AS_STDIO); break; } diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index dad78beb13..d2aaef0bc3 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -39,6 +39,13 @@ # define MSG_PEEK 0 #endif +#ifdef PHP_WIN32 +/* send/recv family on windows expects int */ +# define XP_SOCK_BUF_SIZE(sz) (((sz) > INT_MAX) ? INT_MAX : (int)(sz)) +#else +# define XP_SOCK_BUF_SIZE(sz) (sz) +#endif + php_stream_ops php_stream_generic_socket_ops; PHPAPI php_stream_ops php_stream_socket_ops; php_stream_ops php_stream_udp_socket_ops; @@ -67,7 +74,7 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count ptimeout = &sock->timeout; retry: - didwrite = send(sock->socket, buf, count, (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0); + didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0); if (didwrite <= 0) { long err = php_socket_errno(); @@ -95,8 +102,8 @@ retry: } while (err == EINTR); } estr = php_socket_strerror(err, NULL, 0); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of %ld bytes failed with errno=%ld %s", - (long)count, err, estr); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "send of " ZEND_INT_FMT " bytes failed with errno=%ld %s", + (php_int_t)count, err, estr); efree(estr); } @@ -144,7 +151,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) { php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; - int nr_bytes = 0; + ssize_t nr_bytes = 0; if (!sock || sock->socket == -1) { return 0; @@ -156,7 +163,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS return 0; } - nr_bytes = recv(sock->socket, buf, count, (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0); + nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0); stream->eof = (nr_bytes == 0 || (nr_bytes == -1 && php_socket_errno() != EWOULDBLOCK)); @@ -230,7 +237,7 @@ static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC #if ZEND_WIN32 return 0; #else - return fstat(sock->socket, &ssb->sb); + return php_fstat(sock->socket, &ssb->sb); #endif } @@ -240,7 +247,8 @@ static inline int sock_sendto(php_netstream_data_t *sock, const char *buf, size_ { int ret; if (addr) { - ret = sendto(sock->socket, buf, buflen, flags, addr, addrlen); + ret = sendto(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, addr, XP_SOCK_BUF_SIZE(addrlen)); + return (ret == SOCK_CONN_ERR) ? -1 : ret; } return ((ret = send(sock->socket, buf, buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret; @@ -257,12 +265,12 @@ static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t bu int want_addr = textaddr || addr; if (want_addr) { - ret = recvfrom(sock->socket, buf, buflen, flags, (struct sockaddr*)&sa, &sl); + ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl); ret = (ret == SOCK_CONN_ERR) ? -1 : ret; php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl, textaddr, addr, addrlen TSRMLS_CC); } else { - ret = recv(sock->socket, buf, buflen, flags); + ret = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags); ret = (ret == SOCK_CONN_ERR) ? -1 : ret; } @@ -694,7 +702,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_ efree(host); return -1; } - bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text TSRMLS_CC); + bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRSIZE_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text TSRMLS_CC); } #ifdef SO_BROADCAST diff --git a/win32/glob.c b/win32/glob.c index 8111daba1c..95160f9963 100644 --- a/win32/glob.c +++ b/win32/glob.c @@ -146,10 +146,10 @@ typedef char Char; static int compare(const void *, const void *); static int g_Ctoc(const Char *, char *, u_int); -static int g_lstat(Char *, struct stat *, glob_t *); +static int g_lstat(Char *, php_stat_t *, glob_t *); static DIR *g_opendir(Char *, glob_t *); static Char *g_strchr(Char *, int); -static int g_stat(Char *, struct stat *, glob_t *); +static int g_stat(Char *, php_stat_t *, glob_t *); static int glob0(const Char *, glob_t *); static int glob1(Char *, Char *, glob_t *, size_t *); static int glob2(Char *, Char *, Char *, Char *, Char *, Char *, @@ -559,7 +559,7 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern, glob_t *pglob; size_t *limitp; { - struct stat sb; + php_stat_t sb; Char *p, *q; int anymeta; @@ -856,7 +856,7 @@ g_opendir(str, pglob) static int g_lstat(fn, sb, pglob) register Char *fn; - struct stat *sb; + php_stat_t *sb; glob_t *pglob; { char buf[MAXPATHLEN]; @@ -871,7 +871,7 @@ g_lstat(fn, sb, pglob) static int g_stat(fn, sb, pglob) register Char *fn; - struct stat *sb; + php_stat_t *sb; glob_t *pglob; { char buf[MAXPATHLEN]; diff --git a/win32/glob.h b/win32/glob.h index 3f7a57a0b3..a03fda9199 100644 --- a/win32/glob.h +++ b/win32/glob.h @@ -47,7 +47,7 @@ # include <sys/cdefs.h> #endif -struct stat; +php_stat_t; typedef struct { int gl_pathc; /* Count of total paths so far. */ int gl_matchc; /* Count of paths matching pattern. */ @@ -65,8 +65,8 @@ typedef struct { void (*gl_closedir)(void *); struct dirent *(*gl_readdir)(void *); void *(*gl_opendir)(const char *); - int (*gl_lstat)(const char *, struct stat *); - int (*gl_stat)(const char *, struct stat *); + int (*gl_lstat)(const char *, php_stat_t *); + int (*gl_stat)(const char *, php_stat_t *); } glob_t; /* Flags */ diff --git a/win32/php_stdint.h b/win32/php_stdint.h index 0d63615c6b..4e9b869483 100644 --- a/win32/php_stdint.h +++ b/win32/php_stdint.h @@ -130,6 +130,7 @@ typedef uint64_t uintmax_t; #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types +#if _MSC_VER >= 1700 && !defined(_INTSAFE_H_INCLUDED_) #define INT8_MIN ((int8_t)_I8_MIN) #define INT8_MAX _I8_MAX #define INT16_MIN ((int16_t)_I16_MIN) @@ -142,6 +143,7 @@ typedef uint64_t uintmax_t; #define UINT16_MAX _UI16_MAX #define UINT32_MAX _UI32_MAX #define UINT64_MAX _UI64_MAX +#endif // 7.18.2.2 Limits of minimum-width integer types #define INT_LEAST8_MIN INT8_MIN diff --git a/win32/registry.c b/win32/registry.c index ade09aa486..75854910e0 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -240,18 +240,18 @@ void UpdateIniFromRegistry(char *path TSRMLS_DC) if (pht != NULL) { HashTable *ht = pht; zend_string *index; - ulong num; + php_uint_t num; zval *data; ZEND_HASH_FOREACH_KEY_VAL(ht, num, index, data) { - zend_alter_ini_entry(index, Z_STRVAL_P(data), Z_STRLEN_P(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); + zend_alter_ini_entry(index, Z_STRVAL_P(data), Z_STRSIZE_P(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); } ZEND_HASH_FOREACH_END(); /* for (zend_hash_internal_pointer_reset_ex(ht, &pos); zend_hash_get_current_data_ex(ht, (void**)&data, &pos) == SUCCESS && zend_hash_get_current_key_ex(ht, &index, &index_len, &num, 0, &pos) == HASH_KEY_IS_STRING; zend_hash_move_forward_ex(ht, &pos)) { - zend_alter_ini_entry(index, index_len, Z_STRVAL_PP(data), Z_STRLEN_PP(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); + zend_alter_ini_entry(index, index_len, Z_STRVAL_PP(data), Z_STRSIZE_PP(data), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); } break; */ diff --git a/win32/sendmail.c b/win32/sendmail.c index c191e0f3aa..85a2e5b4c5 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -360,6 +360,9 @@ PHPAPI char *GetSMErrorText(int index) } } +PHPAPI zend_string *php_str_to_str(char *haystack, int length, char *needle, + int needle_len, char *str, int str_len); + /********************************************************************* // Name: SendText diff --git a/win32/winutil.c b/win32/winutil.c index 22e2d45304..9984d3addc 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -22,7 +22,7 @@ #include "php.h" #include <wincrypt.h> -PHPAPI char *php_win32_error_to_msg(int error) +PHPAPI char *php_win32_error_to_msg(HRESULT error) { char *buf = NULL; diff --git a/win32/winutil.h b/win32/winutil.h index 773063e5f6..e0193d33f3 100644 --- a/win32/winutil.h +++ b/win32/winutil.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -PHPAPI char *php_win32_error_to_msg(int error); +PHPAPI char *php_win32_error_to_msg(HRESULT error); #define php_win_err() php_win32_error_to_msg(GetLastError()) int php_win32_check_trailing_space(const char * path, const int path_len); |