Skip to content

Commit

Permalink
Use new ZEND_HASH_FOREACH_... API.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Feb 10, 2015
1 parent 4a875e1 commit 1eb4352
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 198 deletions.
17 changes: 4 additions & 13 deletions ext/dom/php_dom.c
Expand Up @@ -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;

Expand All @@ -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;
}

Expand All @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions ext/dom/xpath.c
Expand Up @@ -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;

Expand Down
4 changes: 0 additions & 4 deletions ext/mysqlnd/mysqlnd_plugin.c
Expand Up @@ -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;

Expand Down
32 changes: 14 additions & 18 deletions 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"
/*
+----------------------------------------------------------------------+
Expand Down Expand Up @@ -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;
Expand All @@ -82,7 +81,7 @@ static int scan(Scanner *s)
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);
Expand Down Expand Up @@ -166,7 +165,7 @@ static int scan(Scanner *s)
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)) {
Expand All @@ -176,7 +175,7 @@ static int scan(Scanner *s)
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) {
Expand Down Expand Up @@ -213,7 +212,7 @@ static int scan(Scanner *s)
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);
Expand Down Expand Up @@ -293,7 +292,7 @@ static int scan(Scanner *s)
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);
Expand Down Expand Up @@ -367,7 +366,7 @@ static int scan(Scanner *s)
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);
Expand Down Expand Up @@ -397,7 +396,7 @@ static int scan(Scanner *s)
++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);
Expand All @@ -419,7 +418,7 @@ static int scan(Scanner *s)
++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"

Expand Down Expand Up @@ -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, &param_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
Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions ext/pdo/pdo_sql_parser.re
Expand Up @@ -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, &param_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
Expand All @@ -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;
Expand Down

0 comments on commit 1eb4352

Please sign in to comment.