summaryrefslogtreecommitdiff
path: root/ext/phar/phar.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/phar/phar.c')
-rw-r--r--ext/phar/phar.c99
1 files changed, 4 insertions, 95 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index ec82351410..cc0fad28eb 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -27,9 +27,7 @@
static void destroy_phar_data(void *pDest);
ZEND_DECLARE_MODULE_GLOBALS(phar)
-#if PHP_VERSION_ID >= 50300
char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
-#endif
/**
* set's phar->is_writeable based on the current INI value
@@ -1964,7 +1962,7 @@ woohoo:
zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
while (FAILURE != zend_hash_has_more_elements(&(PHAR_GLOBALS->phar_fname_map))) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -1994,7 +1992,7 @@ woohoo:
zend_hash_internal_pointer_reset(&cached_phars);
while (FAILURE != zend_hash_has_more_elements(&cached_phars)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -3321,31 +3319,18 @@ static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS
}
/* }}} */
-#if PHP_VERSION_ID >= 50300
static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
{
return ((phar_archive_data*)handle)->halt_offset + 32;
} /* }}} */
-#else /* PHP_VERSION_ID */
-
-static long phar_stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
-{
- return (long)php_stream_tell(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC));
-}
-/* }}} */
-#endif
-
zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
-#if PHP_VERSION_ID >= 50300
#define phar_orig_zend_open zend_stream_open_function
+
static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
{
return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
}
-#else
-int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
-#endif
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
{
@@ -3378,7 +3363,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
}
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
/* compressed phar */
-#if PHP_VERSION_ID >= 50300
file_handle->type = ZEND_HANDLE_STREAM;
/* we do our own reading directly from the phar, don't change the next line */
file_handle->handle.stream.handle = phar;
@@ -3390,24 +3374,13 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
php_stream_rewind(phar->fp);
memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
-#else /* PHP_VERSION_ID */
- file_handle->type = ZEND_HANDLE_STREAM;
- /* we do our own reading directly from the phar, don't change the next line */
- file_handle->handle.stream.handle = phar;
- file_handle->handle.stream.reader = phar_zend_stream_reader;
- file_handle->handle.stream.closer = NULL; /* don't close - let phar handle this one */
- file_handle->handle.stream.fteller = phar_stream_fteller_for_zend;
- file_handle->handle.stream.interactive = 0;
- phar->is_persistent ?
- php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
- php_stream_rewind(phar->fp);
-#endif
}
}
}
zend_try {
failed = 0;
+ CG(zend_lineno) = 0;
res = phar_orig_compile_file(file_handle, type TSRMLS_CC);
} zend_catch {
failed = 1;
@@ -3426,60 +3399,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
}
/* }}} */
-#if PHP_VERSION_ID < 50300
-int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */
-{
- char *arch, *entry;
- int arch_len, entry_len;
-
- /* this code is obsoleted in php 5.3 */
- entry = (char *) filename;
- if (!IS_ABSOLUTE_PATH(entry, strlen(entry)) && !strstr(entry, "://")) {
- phar_archive_data **pphar = NULL;
- char *fname;
- int fname_len;
-
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
- fname_len = strlen(fname);
-
- if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) {
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
- zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
- if (!pphar && PHAR_G(manifest_cached)) {
- zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
- }
- efree(arch);
- efree(entry);
- }
- }
-
- /* retrieving an include within the current directory, so use this if possible */
- if (!(entry = phar_find_in_include_path((char *) filename, strlen(filename), NULL TSRMLS_CC))) {
- /* this file is not in the phar, use the original path */
- goto skip_phar;
- }
-
- if (SUCCESS == phar_orig_zend_open(entry, handle TSRMLS_CC)) {
- if (!handle->opened_path) {
- handle->opened_path = entry;
- }
- if (entry != filename) {
- handle->free_filename = 1;
- }
- return SUCCESS;
- }
-
- if (entry != filename) {
- efree(entry);
- }
-
- return FAILURE;
- }
-skip_phar:
- return phar_orig_zend_open(filename, handle TSRMLS_CC);
-}
-/* }}} */
-#endif
typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
@@ -3556,13 +3475,8 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */
phar_orig_compile_file = zend_compile_file;
zend_compile_file = phar_compile_file;
-#if PHP_VERSION_ID >= 50300
phar_save_resolve_path = zend_resolve_path;
zend_resolve_path = phar_resolve_path;
-#else
- phar_orig_zend_open = zend_stream_open_function;
- zend_stream_open_function = phar_zend_open;
-#endif
phar_object_init(TSRMLS_C);
@@ -3583,11 +3497,6 @@ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
zend_compile_file = phar_orig_compile_file;
}
-#if PHP_VERSION_ID < 50300
- if (zend_stream_open_function == phar_zend_open) {
- zend_stream_open_function = phar_orig_zend_open;
- }
-#endif
if (PHAR_G(manifest_cached)) {
zend_hash_destroy(&(cached_phars));
zend_hash_destroy(&(cached_alias));