mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/phar: Use HASH_FOREACH macro in phar_wrapper_open_dir()
Also simplify the inner if condition
This commit is contained in:
parent
615960be9c
commit
a600713cd6
1 changed files with 9 additions and 18 deletions
|
@ -291,8 +291,6 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
|
||||||
php_url *resource = NULL;
|
php_url *resource = NULL;
|
||||||
php_stream *ret;
|
php_stream *ret;
|
||||||
char *internal_file, *error;
|
char *internal_file, *error;
|
||||||
zend_string *str_key;
|
|
||||||
zend_ulong unused;
|
|
||||||
phar_archive_data *phar;
|
phar_archive_data *phar;
|
||||||
phar_entry_info *entry = NULL;
|
phar_entry_info *entry = NULL;
|
||||||
|
|
||||||
|
@ -363,25 +361,18 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
|
||||||
return phar_make_dirstream(internal_file, &phar->manifest);
|
return phar_make_dirstream(internal_file, &phar->manifest);
|
||||||
} else {
|
} else {
|
||||||
size_t i_len = strlen(internal_file);
|
size_t i_len = strlen(internal_file);
|
||||||
|
zend_string *str_key;
|
||||||
|
|
||||||
/* search for directory */
|
/* search for directory */
|
||||||
zend_hash_internal_pointer_reset(&phar->manifest);
|
ZEND_HASH_MAP_FOREACH_STR_KEY(&phar->manifest, str_key) {
|
||||||
while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
|
if (zend_string_starts_with_cstr(str_key, internal_file, i_len)) {
|
||||||
if (HASH_KEY_NON_EXISTENT !=
|
/* directory found */
|
||||||
zend_hash_get_current_key(&phar->manifest, &str_key, &unused)) {
|
internal_file = estrndup(internal_file,
|
||||||
if (ZSTR_LEN(str_key) > i_len && 0 == memcmp(ZSTR_VAL(str_key), internal_file, i_len)) {
|
i_len);
|
||||||
/* directory found */
|
php_url_free(resource);
|
||||||
internal_file = estrndup(internal_file,
|
return phar_make_dirstream(internal_file, &phar->manifest);
|
||||||
i_len);
|
|
||||||
php_url_free(resource);
|
|
||||||
return phar_make_dirstream(internal_file, &phar->manifest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} ZEND_HASH_FOREACH_END();
|
||||||
if (SUCCESS != zend_hash_move_forward(&phar->manifest)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
php_url_free(resource);
|
php_url_free(resource);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue