mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
ini patch to allow 'entry[] = value' entries
This commit is contained in:
parent
697398e18e
commit
b51b6f0fbf
2 changed files with 70 additions and 33 deletions
|
@ -2824,6 +2824,33 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
|
||||||
zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
|
zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZEND_INI_PARSER_POP_ENTRY:
|
||||||
|
{
|
||||||
|
zval *hash, **find_hash;
|
||||||
|
|
||||||
|
if (!arg2) {
|
||||||
|
/* bare string - nothing to do */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zend_hash_find(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void **) &find_hash) == FAILURE) {
|
||||||
|
ALLOC_ZVAL(hash);
|
||||||
|
INIT_PZVAL(hash);
|
||||||
|
array_init(hash);
|
||||||
|
|
||||||
|
zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &hash, sizeof(zval *), NULL);
|
||||||
|
} else {
|
||||||
|
hash = *find_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALLOC_ZVAL(element);
|
||||||
|
*element = *arg2;
|
||||||
|
zval_copy_ctor(element);
|
||||||
|
INIT_PZVAL(element);
|
||||||
|
add_next_index_zval(hash, element);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ZEND_INI_PARSER_SECTION:
|
case ZEND_INI_PARSER_SECTION:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2831,44 +2858,26 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
|
||||||
|
|
||||||
static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback_type, zval *arr)
|
static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback_type, zval *arr)
|
||||||
{
|
{
|
||||||
zval *element;
|
|
||||||
TSRMLS_FETCH();
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
switch (callback_type) {
|
if (callback_type == ZEND_INI_PARSER_SECTION) {
|
||||||
|
MAKE_STD_ZVAL(BG(active_ini_file_section));
|
||||||
|
array_init(BG(active_ini_file_section));
|
||||||
|
zend_hash_update( Z_ARRVAL_P(arr),
|
||||||
|
Z_STRVAL_P(arg1),
|
||||||
|
Z_STRLEN_P(arg1)+1,
|
||||||
|
&BG(active_ini_file_section),
|
||||||
|
sizeof(zval *), NULL);
|
||||||
|
} else if (arg2) {
|
||||||
|
zval *active_arr;
|
||||||
|
|
||||||
case ZEND_INI_PARSER_ENTRY:
|
if (BG(active_ini_file_section)) {
|
||||||
{
|
active_arr = BG(active_ini_file_section);
|
||||||
zval *active_arr;
|
} else {
|
||||||
|
active_arr = arr;
|
||||||
if (!arg2) {
|
|
||||||
/* bare string - nothing to do */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BG(active_ini_file_section)) {
|
|
||||||
active_arr = BG(active_ini_file_section);
|
|
||||||
} else {
|
|
||||||
active_arr = arr;
|
|
||||||
}
|
|
||||||
ALLOC_ZVAL(element);
|
|
||||||
*element = *arg2;
|
|
||||||
zval_copy_ctor(element);
|
|
||||||
INIT_PZVAL(element);
|
|
||||||
zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1),
|
|
||||||
Z_STRLEN_P(arg1)+1, &element,
|
|
||||||
sizeof(zval *), NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case ZEND_INI_PARSER_SECTION:
|
php_simple_ini_parser_cb(arg1, arg2, callback_type, active_arr);
|
||||||
MAKE_STD_ZVAL(BG(active_ini_file_section));
|
|
||||||
array_init(BG(active_ini_file_section));
|
|
||||||
zend_hash_update( Z_ARRVAL_P(arr),
|
|
||||||
Z_STRVAL_P(arg1),
|
|
||||||
Z_STRLEN_P(arg1)+1,
|
|
||||||
&BG(active_ini_file_section),
|
|
||||||
sizeof(zval *), NULL);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,34 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ZEND_INI_PARSER_POP_ENTRY: {
|
||||||
|
zval *hash;
|
||||||
|
zval **find_hash;
|
||||||
|
zval *element;
|
||||||
|
|
||||||
|
if (!arg2) {
|
||||||
|
/* bare string - nothing to do */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zend_hash_find(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void **) &find_hash) == FAILURE) {
|
||||||
|
ALLOC_ZVAL(hash);
|
||||||
|
array_init(hash);
|
||||||
|
|
||||||
|
zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &hash, sizeof(zval *), NULL);
|
||||||
|
} else {
|
||||||
|
hash = *find_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALLOC_ZVAL(element);
|
||||||
|
*element = *arg2;
|
||||||
|
zval_copy_ctor(element);
|
||||||
|
INIT_PZVAL(element);
|
||||||
|
add_next_index_zval(hash, element);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ZEND_INI_PARSER_SECTION:
|
case ZEND_INI_PARSER_SECTION:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue