diff options
author | Steph Fox <sfox@php.net> | 2008-05-14 21:29:51 +0000 |
---|---|---|
committer | Steph Fox <sfox@php.net> | 2008-05-14 21:29:51 +0000 |
commit | 6a0682d986c8e7fa16b51a8c3fd8f7cc01660426 (patch) | |
tree | 3f4902979371a318d695b6a09dc003c95b6a0258 /ext/phar/phar_object.c | |
parent | b3b5126954689c93baddbbe48f714594bf7dac13 (diff) | |
download | php-git-6a0682d986c8e7fa16b51a8c3fd8f7cc01660426.tar.gz |
- MFH
- Make internal code forward-compatible. This included a binary cast in the default stub, hence test updates.
Diffstat (limited to 'ext/phar/phar_object.c')
-rwxr-xr-x | ext/phar/phar_object.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 98b602adbc..1e37e5d8c4 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -778,7 +778,7 @@ PHP_METHOD(Phar, webPhar) mime.len = Z_STRLEN_PP(val); \ } \ mime.type = ret; \ - zend_hash_update(&mimetypes, key, keylen-1, (void *)&mime, sizeof(phar_mime_type), NULL); + zend_hash_update(&mimetypes, str_key, keylen-1, (void *)&mime, sizeof(phar_mime_type), NULL); if (mimeoverride) { if (!zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) { @@ -786,9 +786,11 @@ PHP_METHOD(Phar, webPhar) } for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mimeoverride)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mimeoverride)); zend_hash_move_forward(Z_ARRVAL_P(mimeoverride))) { zval **val; - char *key; + phar_zstr key; + char *str_key; uint keylen; ulong intkey; + if (HASH_KEY_IS_LONG == zend_hash_get_current_key_ex(Z_ARRVAL_P(mimeoverride), &key, &keylen, &intkey, 0, NULL)) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Key of MIME type overrides array must be a file extension, was \"%d\"", intkey); phar_entry_delref(phar TSRMLS_CC); @@ -797,8 +799,11 @@ PHP_METHOD(Phar, webPhar) #endif RETURN_FALSE; } + + PHAR_STR(key, str_key); + if (FAILURE == zend_hash_get_current_data(Z_ARRVAL_P(mimeoverride), (void **) &val)) { - zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Failed to retrieve Mime type for extension \"%s\"", key); + zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Failed to retrieve Mime type for extension \"%s\"", str_key); phar_entry_delref(phar TSRMLS_CC); #ifdef PHP_WIN32 efree(fname); @@ -1114,11 +1119,8 @@ PHP_METHOD(Phar, __construct) return; } -#if PHP_VERSION_ID >= 60000 - objname = phar_obj->std.ce->name.s; -#else - objname = phar_obj->std.ce->name; -#endif + PHAR_STR(phar_obj->std.ce->name, objname); + if (!strncmp(objname, "PharData", 8)) { is_data = 1; } else { @@ -1315,7 +1317,9 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ phar_entry_data *data; php_stream *fp; long contents_len; - char *fname, *error, *str_key, *base = p_obj->b, *opened, *save = NULL, *temp = NULL; + char *fname, *error, *base = p_obj->b, *opened, *save = NULL, *temp = NULL; + phar_zstr key; + char *str_key; zend_class_entry *ce = p_obj->c; phar_archive_object *phar_obj = p_obj->p; char *str = "[stream]"; @@ -1339,10 +1343,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ return ZEND_HASH_APPLY_STOP; } if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + if (EG(exception)) { return ZEND_HASH_APPLY_STOP; } + + PHAR_STR(key, str_key); + if (key_type == HASH_KEY_IS_LONG) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %s returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; @@ -1438,10 +1446,14 @@ phar_spl_fileinfo: } } else { if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); + key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC); + if (EG(exception)) { return ZEND_HASH_APPLY_STOP; } + + PHAR_STR(key, str_key); + if (key_type == HASH_KEY_IS_LONG) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %s returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; |