mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Allow get_current_key() not to return the key itself, instead of a duplicate
This commit is contained in:
parent
0fcce4a77a
commit
36eaad252f
@ -94,10 +94,9 @@ static void print_hash(HashTable *ht, int indent)
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
ZEND_PUTS("[");
|
||||
switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, &iterator)) {
|
||||
switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
ZEND_PUTS(string_key);
|
||||
efree(string_key);
|
||||
break;
|
||||
case HASH_KEY_IS_LONG:
|
||||
zend_printf("%ld",num_key);
|
||||
|
@ -332,7 +332,7 @@ ZEND_FUNCTION(each)
|
||||
entry->refcount++;
|
||||
|
||||
/* add the key elements */
|
||||
switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
|
||||
switch (zend_hash_get_current_key(target_hash, &string_key, &num_key, 1)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
add_get_index_string(return_value,0,string_key,(void **) &inserted_pointer,0);
|
||||
break;
|
||||
@ -589,7 +589,7 @@ ZEND_FUNCTION(get_class_methods)
|
||||
efree(lcname);
|
||||
array_init(return_value);
|
||||
zend_hash_internal_pointer_reset(&ce->function_table);
|
||||
while ((key_type = zend_hash_get_current_key(&ce->function_table, &string_key, &num_key)) != HASH_KEY_NON_EXISTANT) {
|
||||
while ((key_type = zend_hash_get_current_key(&ce->function_table, &string_key, &num_key, 1)) != HASH_KEY_NON_EXISTANT) {
|
||||
if (key_type == HASH_KEY_IS_STRING) {
|
||||
MAKE_STD_ZVAL(method_name);
|
||||
ZVAL_STRING(method_name, string_key, 0);
|
||||
@ -731,7 +731,7 @@ ZEND_FUNCTION(get_included_files)
|
||||
|
||||
array_init(return_value);
|
||||
zend_hash_internal_pointer_reset(&EG(included_files));
|
||||
while(zend_hash_get_current_key(&EG(included_files), &entry,NULL) == HASH_KEY_IS_STRING) {
|
||||
while(zend_hash_get_current_key(&EG(included_files), &entry, NULL, 1) == HASH_KEY_IS_STRING) {
|
||||
add_next_index_string(return_value,entry,0);
|
||||
zend_hash_move_forward(&EG(included_files));
|
||||
}
|
||||
|
@ -2221,7 +2221,7 @@ send_by_ref:
|
||||
|
||||
ALLOC_ZVAL(key);
|
||||
INIT_PZVAL(key);
|
||||
switch (zend_hash_get_current_key(fe_ht, &str_key, &int_key)) {
|
||||
switch (zend_hash_get_current_key(fe_ht, &str_key, &int_key, 1)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
key->value.str.val = str_key;
|
||||
key->value.str.len = strlen(str_key);
|
||||
|
@ -1019,7 +1019,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(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, HashPosition *pos)
|
||||
ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos)
|
||||
{
|
||||
Bucket *p;
|
||||
|
||||
@ -1029,9 +1029,10 @@ ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong
|
||||
|
||||
if (p) {
|
||||
if (p->nKeyLength) {
|
||||
*str_index = (char *) estrndup(p->arKey, p->nKeyLength);
|
||||
if (ht->persistent) {
|
||||
persist_alloc(*str_index);
|
||||
if (duplicate) {
|
||||
*str_index = estrndup(p->arKey, p->nKeyLength);
|
||||
} else {
|
||||
*str_index = p->arKey;
|
||||
}
|
||||
if (str_length) {
|
||||
*str_length = p->nKeyLength;
|
||||
|
@ -146,7 +146,7 @@ ZEND_API ulong zend_hash_next_free_element(HashTable *ht);
|
||||
/* traversing */
|
||||
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(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos);
|
||||
ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
|
||||
@ -156,8 +156,8 @@ ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos
|
||||
zend_hash_move_forward_ex(ht, NULL)
|
||||
#define zend_hash_move_backwards(ht) \
|
||||
zend_hash_move_backwards_ex(ht, NULL)
|
||||
#define zend_hash_get_current_key(ht, str_index, num_index) \
|
||||
zend_hash_get_current_key_ex(ht, str_index, NULL, num_index, NULL)
|
||||
#define zend_hash_get_current_key(ht, str_index, num_index, duplicate) \
|
||||
zend_hash_get_current_key_ex(ht, str_index, NULL, num_index, duplicate, NULL)
|
||||
#define zend_hash_get_current_key_type(ht) \
|
||||
zend_hash_get_current_key_type_ex(ht, NULL)
|
||||
#define zend_hash_get_current_data(ht, pData) \
|
||||
|
Loading…
Reference in New Issue
Block a user