diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index b6b66fc5074..04c7e3a40ee 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -418,7 +418,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ * HashTable *debug_info, *prop_handlers = obj->prop_handler, *std_props; - HashPosition pos; + zend_string *string_key; dom_prop_handler *entry; zval object_value; @@ -435,19 +435,10 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ * ZVAL_STRING(&object_value, "(object value omitted)"); - for (zend_hash_internal_pointer_reset_ex(prop_handlers, &pos); - (entry = zend_hash_get_current_data_ptr_ex(prop_handlers, &pos)) != NULL; - zend_hash_move_forward_ex(prop_handlers, &pos)) { + ZEND_HASH_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) { zval value; - zend_string *string_key; - zend_ulong num_key; - if (entry->read_func(obj, &value) == FAILURE) { - continue; - } - - if (zend_hash_get_current_key_ex(prop_handlers, &string_key, - &num_key, &pos) != HASH_KEY_IS_STRING) { + if (entry->read_func(obj, &value) == FAILURE || !string_key) { continue; } @@ -457,7 +448,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ * } zend_hash_add(debug_info, string_key, &value); - } + } ZEND_HASH_FOREACH_END(); zval_dtor(&object_value); diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index e7a3ed7648e..1fb6574695a 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -520,14 +520,12 @@ PHP_FUNCTION(dom_xpath_register_php_functions) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "a", &array_value) == SUCCESS) { intern = Z_XPATHOBJ_P(id); - zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value)); - while ((entry = zend_hash_get_current_data(Z_ARRVAL_P(array_value)))) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) { zend_string *str = zval_get_string(entry); ZVAL_LONG(&new_string,1); zend_hash_update(intern->registered_phpfunctions, str, &new_string); - zend_hash_move_forward(Z_ARRVAL_P(array_value)); zend_string_release(str); - } + } ZEND_HASH_FOREACH_END(); intern->registerPhpFunctions = 2; RETURN_TRUE; diff --git a/ext/mysqlnd/mysqlnd_plugin.c b/ext/mysqlnd/mysqlnd_plugin.c index 243dae41d71..d0709282f19 100644 --- a/ext/mysqlnd/mysqlnd_plugin.c +++ b/ext/mysqlnd/mysqlnd_plugin.c @@ -168,10 +168,6 @@ PHPAPI void * _mysqlnd_plugin_find(const char * const name) /* {{{ _mysqlnd_plugin_apply_with_argument */ PHPAPI void _mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void * argument) { - /* Note: We want to be thread-safe (read-only), so we can use neither - * zend_hash_apply_with_argument nor zend_hash_internal_pointer_reset and - * friends - */ zval *val; int result; diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index d29e3b13b72..11e245d7d17 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.7.5 */ +/* Generated by re2c 0.13.5 */ #line 1 "ext/pdo/pdo_sql_parser.re" /* +----------------------------------------------------------------------+ @@ -70,10 +70,9 @@ static int scan(Scanner *s) } yy2: YYCURSOR = YYMARKER; - if (yyaccept == 0) { - goto yy4; - } else { - goto yy10; + switch (yyaccept) { + case 0: goto yy4; + case 1: goto yy10; } yy3: yyaccept = 0; @@ -82,7 +81,7 @@ yy3: yy4: #line 63 "ext/pdo/pdo_sql_parser.re" { SKIP_ONE(PDO_PARSER_TEXT); } -#line 86 "ext/pdo/pdo_sql_parser.c" +#line 85 "ext/pdo/pdo_sql_parser.c" yy5: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); @@ -166,7 +165,7 @@ yy7: yy8: #line 62 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND_POS); } -#line 170 "ext/pdo/pdo_sql_parser.c" +#line 169 "ext/pdo/pdo_sql_parser.c" yy9: ++YYCURSOR; switch ((yych = *YYCURSOR)) { @@ -176,7 +175,7 @@ yy9: yy10: #line 65 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 180 "ext/pdo/pdo_sql_parser.c" +#line 179 "ext/pdo/pdo_sql_parser.c" yy11: yych = *++YYCURSOR; switch (yych) { @@ -213,7 +212,7 @@ yy14: yy16: #line 64 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 217 "ext/pdo/pdo_sql_parser.c" +#line 216 "ext/pdo/pdo_sql_parser.c" yy17: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -293,7 +292,7 @@ yy29: yy31: #line 60 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 297 "ext/pdo/pdo_sql_parser.c" +#line 296 "ext/pdo/pdo_sql_parser.c" yy32: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -367,7 +366,7 @@ yy32: yy34: #line 61 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_BIND); } -#line 371 "ext/pdo/pdo_sql_parser.c" +#line 370 "ext/pdo/pdo_sql_parser.c" yy35: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -397,7 +396,7 @@ yy40: ++YYCURSOR; #line 59 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 401 "ext/pdo/pdo_sql_parser.c" +#line 400 "ext/pdo/pdo_sql_parser.c" yy42: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); @@ -419,7 +418,7 @@ yy45: ++YYCURSOR; #line 58 "ext/pdo/pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } -#line 423 "ext/pdo/pdo_sql_parser.c" +#line 422 "ext/pdo/pdo_sql_parser.c" } #line 66 "ext/pdo/pdo_sql_parser.re" @@ -781,9 +780,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char padding = 3; } if(params) { - HashPosition *param_pos; - zend_hash_internal_pointer_reset(params); - while ((param == zend_hash_get_current_data_ptr_ex(params, ¶m_pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(params, param) { if(param->parameter) { convert_to_string(param->parameter); /* accommodate a string that needs to be fully quoted @@ -792,8 +789,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char */ newbuffer_len += padding * Z_STRLEN_P(param->parameter); } - zend_hash_move_forward(params); - } + } ZEND_HASH_FOREACH_END(); } *outquery = (char *) emalloc(newbuffer_len + 1); *outquery_len = 0; diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index ef989d35c4d..1297e45db79 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -422,9 +422,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char padding = 3; } if(params) { - HashPosition *param_pos; - zend_hash_internal_pointer_reset(params); - while ((param == zend_hash_get_current_data_ptr_ex(params, ¶m_pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(params, param) { if(param->parameter) { convert_to_string(param->parameter); /* accommodate a string that needs to be fully quoted @@ -433,8 +431,7 @@ int old_pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char */ newbuffer_len += padding * Z_STRLEN_P(param->parameter); } - zend_hash_move_forward(params); - } + } ZEND_HASH_FOREACH_END(); } *outquery = (char *) emalloc(newbuffer_len + 1); *outquery_len = 0; diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 194c7ee99b9..92b5d9da5fc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -447,36 +447,27 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in /* counting static properties */ count = zend_hash_num_elements(&ce->properties_info); if (count > 0) { - HashPosition pos; zend_property_info *prop; - zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); - - while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { if(prop->flags & ZEND_ACC_SHADOW) { count_shadow_props++; } else if (prop->flags & ZEND_ACC_STATIC) { count_static_props++; } - zend_hash_move_forward_ex(&ce->properties_info, &pos); - } + } ZEND_HASH_FOREACH_END(); } /* static properties */ string_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); if (count_static_props > 0) { - HashPosition pos; zend_property_info *prop; - zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); - - while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) { _property_string(str, prop, NULL, sub_indent.buf->val); } - - zend_hash_move_forward_ex(&ce->properties_info, &pos); - } + } ZEND_HASH_FOREACH_END(); } string_printf(str, "%s }\n", indent); } @@ -486,38 +477,30 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in /* counting static methods */ count = zend_hash_num_elements(&ce->function_table); if (count > 0) { - HashPosition pos; zend_function *mptr; - zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); - - while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { if (mptr->common.fn_flags & ZEND_ACC_STATIC && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { count_static_funcs++; } - zend_hash_move_forward_ex(&ce->function_table, &pos); - } + } ZEND_HASH_FOREACH_END(); } /* static methods */ string_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); if (count_static_funcs > 0) { - HashPosition pos; zend_function *mptr; - zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); - - while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { if (mptr->common.fn_flags & ZEND_ACC_STATIC && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { string_printf(str, "\n"); _function_string(str, mptr, ce, sub_indent.buf->val); } - zend_hash_move_forward_ex(&ce->function_table, &pos); - } + } ZEND_HASH_FOREACH_END(); } else { string_printf(str, "\n"); } @@ -529,17 +512,13 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in count = zend_hash_num_elements(&ce->properties_info) - count_static_props - count_shadow_props; string_printf(str, "\n%s - Properties [%d] {\n", indent, count); if (count > 0) { - HashPosition pos; zend_property_info *prop; - zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); - - while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) { + ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) { _property_string(str, prop, NULL, sub_indent.buf->val); } - zend_hash_move_forward_ex(&ce->properties_info, &pos); - } + } ZEND_HASH_FOREACH_END(); } string_printf(str, "%s }\n", indent); } @@ -547,29 +526,20 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_properties) { string dyn; HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj); - HashPosition pos; - zval **prop; + zend_string *prop_name; string_init(&dyn); count = 0; if (properties && zend_hash_num_elements(properties)) { - zend_hash_internal_pointer_reset_ex(properties, &pos); - - while ((prop = zend_hash_get_current_data_ptr_ex(properties, &pos)) != NULL) { - zend_string *prop_name; - zend_ulong index; - - if (zend_hash_get_current_key_ex(properties, &prop_name, &index, &pos) == HASH_KEY_IS_STRING) { - if (prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */ - if (!zend_hash_exists(&ce->properties_info, prop_name)) { - count++; - _property_string(&dyn, NULL, prop_name->val, sub_indent.buf->val); - } + ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) { + if (prop_name && prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */ + if (!zend_hash_exists(&ce->properties_info, prop_name)) { + count++; + _property_string(&dyn, NULL, prop_name->val, sub_indent.buf->val); } } - zend_hash_move_forward_ex(properties, &pos); - } + } ZEND_HASH_FOREACH_END(); } string_printf(str, "\n%s - Dynamic properties [%d] {\n", indent, count); @@ -582,26 +552,23 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (&ce->function_table) { count = zend_hash_num_elements(&ce->function_table) - count_static_funcs; if (count > 0) { - HashPosition pos; zend_function *mptr; + zend_string *key; string dyn; count = 0; string_init(&dyn); - zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); - while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) { + ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, key, mptr) { if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0 && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { - zend_string *key; - zend_ulong num_index; size_t len = mptr->common.function_name->len; /* Do not display old-style inherited constructors */ if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || mptr->common.scope == ce - || zend_hash_get_current_key_ex(&ce->function_table, &key, &num_index, &pos) != HASH_KEY_IS_STRING + || !key || zend_binary_strcasecmp(key->val, key->len, mptr->common.function_name->val, len) == 0) { zend_function *closure; @@ -620,8 +587,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in _free_function(closure); } } - zend_hash_move_forward_ex(&ce->function_table, &pos); - } + } ZEND_HASH_FOREACH_END(); string_printf(str, "\n%s - Methods [%d] {", indent, count); if (!count) { string_printf(str, "\n"); @@ -777,10 +743,8 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i static void _function_closure_string(string *str, zend_function *fptr, char* indent) { uint32_t i, count; - zend_ulong num_index; zend_string *key; HashTable *static_variables; - HashPosition pos; if (fptr->type != ZEND_USER_FUNCTION || !fptr->op_array.static_variables) { return; @@ -795,13 +759,10 @@ static void _function_closure_string(string *str, zend_function *fptr, char* ind string_printf(str, "\n"); string_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables)); - zend_hash_internal_pointer_reset_ex(static_variables, &pos); i = 0; - while (i < count) { - zend_hash_get_current_key_ex(static_variables, &key, &num_index, &pos); + ZEND_HASH_FOREACH_STR_KEY(static_variables, key) { string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, key->val); - zend_hash_move_forward_ex(static_variables, &pos); - } + } ZEND_HASH_FOREACH_END(); string_printf(str, "%s}\n", indent); } /* }}} */ @@ -1118,12 +1079,10 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde } { - HashPosition iterator; zend_function *fptr; int first = 1; - zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator); - while ((fptr = zend_hash_get_current_data_ptr_ex(CG(function_table), &iterator)) != NULL) { + ZEND_HASH_FOREACH_PTR(CG(function_table), fptr) { if (fptr->common.type==ZEND_INTERNAL_FUNCTION && fptr->internal_function.module == module) { if (first) { @@ -1132,8 +1091,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde } _function_string(str, fptr, NULL, " "); } - zend_hash_move_forward_ex(CG(function_table), &iterator); - } + } ZEND_HASH_FOREACH_END(); if (!first) { string_printf(str, "%s }\n", indent); } @@ -5300,7 +5258,6 @@ ZEND_METHOD(reflection_extension, getFunctions) { reflection_object *intern; zend_module_entry *module; - HashPosition iterator; zval function; zend_function *fptr; @@ -5310,15 +5267,13 @@ ZEND_METHOD(reflection_extension, getFunctions) GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); - zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator); - while ((fptr = zend_hash_get_current_data_ptr_ex(CG(function_table), &iterator)) != NULL) { + ZEND_HASH_FOREACH_PTR(CG(function_table), fptr) { if (fptr->common.type==ZEND_INTERNAL_FUNCTION && fptr->internal_function.module == module) { reflection_function_factory(fptr, NULL, &function); zend_hash_update(Z_ARRVAL_P(return_value), fptr->common.function_name, &function); } - zend_hash_move_forward_ex(CG(function_table), &iterator); - } + } ZEND_HASH_FOREACH_END(); } /* }}} */ diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 963db66818d..f6a86315b10 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -217,17 +217,14 @@ static unsigned from_array_iterate(const zval *arr, void **args, ser_context *ctx) { - HashPosition pos; unsigned i; zval *elem; char buf[sizeof("element #4294967295")]; char *bufp = buf; /* Note i starts at 1, not 0! */ - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos), i = 1; - !ctx->err.has_error - && (elem = zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), &pos)) != NULL; - zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos), i++) { + i = 1; + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), elem) { if (snprintf(buf, sizeof(buf), "element #%u", i) >= sizeof(buf)) { memcpy(buf, "element", sizeof("element")); } @@ -236,7 +233,11 @@ static unsigned from_array_iterate(const zval *arr, func(elem, i, args, ctx); zend_llist_remove_tail(&ctx->keys); - } + if (ctx->err.has_error) { + break; + } + i++; + } ZEND_HASH_FOREACH_END(); return i -1; } diff --git a/ext/standard/info.c b/ext/standard/info.c index e188a1287fb..eb0a7ca1318 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -102,7 +102,7 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht) /* {{{ * if (ht) { if (zend_hash_num_elements(ht)) { - HashPosition pos; + int first = 1; if (!sapi_module.phpinfo_as_text) { php_info_printf("