com php-src: Use new zend_hash API: ext/phar/phar_obj ect.c
| From: | Dmitry Stogov | Date: | Wed, 28 May 2014 10:09:42 +0000 |
| Subject: | com php-src: Use new zend_hash API: ext/phar/phar_obj ect.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78609@lists.php.net to get a copy of this message | ||
Commit: aca34b127a2b1d7440bae0d7b0a9eb33e9c01004
Author: Dmitry Stogov <dmitry@zend.com> Wed, 28 May 2014 14:09:42 +0400
Parents: a1177760b4bf1b25e4be1b1cc5e1474b6583ae04
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=aca34b127a2b1d7440bae0d7b0a9eb33e9c01004
Log:
Use new zend_hash API
Changed paths:
M ext/phar/phar_object.c
Diff:
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index e8f9c4c..b5f2c95 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -861,7 +861,7 @@ PHP_METHOD(Phar, webPhar)
*/
PHP_METHOD(Phar, mungServer)
{
- zval *mungvalues;
+ zval *mungvalues, *data;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &mungvalues) == FAILURE) {
return;
@@ -879,13 +879,7 @@ PHP_METHOD(Phar, mungServer)
phar_request_initialize(TSRMLS_C);
- for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS ==
zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues)))
{
- zval *data = NULL;
-
- if (NULL == (data = zend_hash_get_current_data(Z_ARRVAL_P(mungvalues)))) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value
in Phar::mungServer()");
- return;
- }
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) {
if (Z_TYPE_P(data) != IS_STRING) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to
Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI,
SCRIPT_FILENAME, SCRIPT_NAME");
@@ -908,7 +902,7 @@ PHP_METHOD(Phar, mungServer)
if (Z_STRLEN_P(data) == sizeof("SCRIPT_FILENAME")-1 &&
!strncmp(Z_STRVAL_P(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
@@ -2244,16 +2238,7 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int
convert
}
/* first copy each file's uncompressed contents to a temporary file and set per-file flags */
- for (zend_hash_internal_pointer_reset(&source->manifest); SUCCESS ==
zend_hash_has_more_elements(&source->manifest);
zend_hash_move_forward(&source->manifest)) {
-
- if (NULL == (entry = zend_hash_get_current_data_ptr(&source->manifest))) {
- zend_hash_destroy(&(phar->manifest));
- php_stream_close(phar->fp);
- efree(phar);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot convert phar archive \"%s\"", source->fname);
- return NULL;
- }
+ ZEND_HASH_FOREACH_PTR(&source->manifest, entry) {
newentry = *entry;
@@ -2297,7 +2282,7 @@ no_copy:
phar_set_inode(&newentry TSRMLS_CC);
zend_hash_str_add_mem(&(phar->manifest), newentry.filename, newentry.filename_len,
(void*)&newentry, sizeof(phar_entry_info));
phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC);
- }
+ } ZEND_HASH_FOREACH_END();
if ((ret = phar_rename_archive(phar, ext, 0 TSRMLS_CC))) {
return ret;
@@ -4330,21 +4315,14 @@ all_files:
RETURN_TRUE;
}
- for (zend_hash_internal_pointer_reset(&phar->manifest);
- zend_hash_has_more_elements(&phar->manifest) == SUCCESS;
- zend_hash_move_forward(&phar->manifest)) {
-
- if ((entry = zend_hash_get_current_data_ptr(&phar->manifest)) == NULL) {
- continue;
- }
-
+ ZEND_HASH_FOREACH_PTR(&phar->manifest, entry) {
if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error TSRMLS_CC)) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC,
"Extraction from phar \"%s\" failed: %s", phar->fname, error);
efree(error);
return;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
RETURN_TRUE;
}