Skip to content

Commit 63dba7e

Browse files
committed
Remove outdate codes, make it clearer, although just a bit..
1 parent 906d3ae commit 63dba7e

File tree

6 files changed

+6
-546
lines changed

6 files changed

+6
-546
lines changed

ext/phar/phar.c

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
static void destroy_phar_data(void *pDest);
2828

2929
ZEND_DECLARE_MODULE_GLOBALS(phar)
30-
#if PHP_VERSION_ID >= 50300
3130
char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
32-
#endif
3331

3432
/**
3533
* set's phar->is_writeable based on the current INI value
@@ -3321,31 +3319,18 @@ static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS
33213319
}
33223320
/* }}} */
33233321

3324-
#if PHP_VERSION_ID >= 50300
33253322
static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
33263323
{
33273324
return ((phar_archive_data*)handle)->halt_offset + 32;
33283325
} /* }}} */
33293326

3330-
#else /* PHP_VERSION_ID */
3331-
3332-
static long phar_stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
3333-
{
3334-
return (long)php_stream_tell(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC));
3335-
}
3336-
/* }}} */
3337-
#endif
3338-
33393327
zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
3340-
#if PHP_VERSION_ID >= 50300
33413328
#define phar_orig_zend_open zend_stream_open_function
3329+
33423330
static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
33433331
{
33443332
return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
33453333
}
3346-
#else
3347-
int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
3348-
#endif
33493334

33503335
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
33513336
{
@@ -3378,7 +3363,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
33783363
}
33793364
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
33803365
/* compressed phar */
3381-
#if PHP_VERSION_ID >= 50300
33823366
file_handle->type = ZEND_HANDLE_STREAM;
33833367
/* we do our own reading directly from the phar, don't change the next line */
33843368
file_handle->handle.stream.handle = phar;
@@ -3390,18 +3374,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
33903374
php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
33913375
php_stream_rewind(phar->fp);
33923376
memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
3393-
#else /* PHP_VERSION_ID */
3394-
file_handle->type = ZEND_HANDLE_STREAM;
3395-
/* we do our own reading directly from the phar, don't change the next line */
3396-
file_handle->handle.stream.handle = phar;
3397-
file_handle->handle.stream.reader = phar_zend_stream_reader;
3398-
file_handle->handle.stream.closer = NULL; /* don't close - let phar handle this one */
3399-
file_handle->handle.stream.fteller = phar_stream_fteller_for_zend;
3400-
file_handle->handle.stream.interactive = 0;
3401-
phar->is_persistent ?
3402-
php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
3403-
php_stream_rewind(phar->fp);
3404-
#endif
34053377
}
34063378
}
34073379
}
@@ -3426,60 +3398,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
34263398
}
34273399
/* }}} */
34283400

3429-
#if PHP_VERSION_ID < 50300
3430-
int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */
3431-
{
3432-
char *arch, *entry;
3433-
int arch_len, entry_len;
3434-
3435-
/* this code is obsoleted in php 5.3 */
3436-
entry = (char *) filename;
3437-
if (!IS_ABSOLUTE_PATH(entry, strlen(entry)) && !strstr(entry, "://")) {
3438-
phar_archive_data **pphar = NULL;
3439-
char *fname;
3440-
int fname_len;
3441-
3442-
fname = (char*)zend_get_executed_filename(TSRMLS_C);
3443-
fname_len = strlen(fname);
3444-
3445-
if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) {
3446-
if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
3447-
zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
3448-
if (!pphar && PHAR_G(manifest_cached)) {
3449-
zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
3450-
}
3451-
efree(arch);
3452-
efree(entry);
3453-
}
3454-
}
3455-
3456-
/* retrieving an include within the current directory, so use this if possible */
3457-
if (!(entry = phar_find_in_include_path((char *) filename, strlen(filename), NULL TSRMLS_CC))) {
3458-
/* this file is not in the phar, use the original path */
3459-
goto skip_phar;
3460-
}
3461-
3462-
if (SUCCESS == phar_orig_zend_open(entry, handle TSRMLS_CC)) {
3463-
if (!handle->opened_path) {
3464-
handle->opened_path = entry;
3465-
}
3466-
if (entry != filename) {
3467-
handle->free_filename = 1;
3468-
}
3469-
return SUCCESS;
3470-
}
3471-
3472-
if (entry != filename) {
3473-
efree(entry);
3474-
}
3475-
3476-
return FAILURE;
3477-
}
3478-
skip_phar:
3479-
return phar_orig_zend_open(filename, handle TSRMLS_CC);
3480-
}
3481-
/* }}} */
3482-
#endif
34833401
typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
34843402
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
34853403

@@ -3556,13 +3474,8 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */
35563474
phar_orig_compile_file = zend_compile_file;
35573475
zend_compile_file = phar_compile_file;
35583476

3559-
#if PHP_VERSION_ID >= 50300
35603477
phar_save_resolve_path = zend_resolve_path;
35613478
zend_resolve_path = phar_resolve_path;
3562-
#else
3563-
phar_orig_zend_open = zend_stream_open_function;
3564-
zend_stream_open_function = phar_zend_open;
3565-
#endif
35663479

35673480
phar_object_init(TSRMLS_C);
35683481

@@ -3583,11 +3496,6 @@ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
35833496
zend_compile_file = phar_orig_compile_file;
35843497
}
35853498

3586-
#if PHP_VERSION_ID < 50300
3587-
if (zend_stream_open_function == phar_zend_open) {
3588-
zend_stream_open_function = phar_orig_zend_open;
3589-
}
3590-
#endif
35913499
if (PHAR_G(manifest_cached)) {
35923500
zend_hash_destroy(&(cached_phars));
35933501
zend_hash_destroy(&(cached_alias));

ext/phar/phar_internal.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -516,76 +516,17 @@ union _phar_entry_object {
516516
#endif
517517

518518
#ifndef PHAR_MAIN
519-
# if PHP_VERSION_ID >= 50300
520519
extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
521-
# endif
522520
#endif
523521

524-
#if PHP_VERSION_ID < 50209
525-
static inline size_t phar_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
526-
{
527-
size_t ret = php_stream_copy_to_stream(src, dest, maxlen);
528-
if (len) {
529-
*len = ret;
530-
}
531-
if (ret) {
532-
return SUCCESS;
533-
}
534-
return FAILURE;
535-
}
536-
#else
537522
# define phar_stream_copy_to_stream(src, dest, maxlen, len) _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC)
538523

539-
#endif
540-
541-
#if PHP_VERSION_ID >= 60000
542-
typedef zstr phar_zstr;
543-
#define PHAR_STR(a, b) \
544-
spprintf(&b, 0, "%s", a.s);
545-
#define PHAR_ZSTR(a, b) \
546-
b = ZSTR(a);
547-
#define PHAR_STR_FREE(a) \
548-
efree(a);
549-
static inline int phar_make_unicode(zstr *c_var, char *arKey, uint nKeyLength TSRMLS_DC)
550-
{
551-
int c_var_len;
552-
UConverter *conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv));
553-
554-
c_var->u = NULL;
555-
if (zend_string_to_unicode(conv, &c_var->u, &c_var_len, arKey, nKeyLength TSRMLS_CC) == FAILURE) {
556-
557-
if (c_var->u) {
558-
efree(c_var->u);
559-
}
560-
return 0;
561-
562-
}
563-
return c_var_len;
564-
}
565-
static inline int phar_find_key(HashTable *_SERVER, char *key, int len, void **stuff TSRMLS_DC)
566-
{
567-
if (SUCCESS == zend_hash_find(_SERVER, key, len, stuff)) {
568-
return 1;
569-
} else {
570-
int s = len;
571-
zstr var;
572-
s = phar_make_unicode(&var, key, len TSRMLS_CC);
573-
if (SUCCESS == zend_u_hash_find(_SERVER, IS_UNICODE, var, s, stuff)) {
574-
efree(var.u);
575-
return 1;
576-
}
577-
efree(var.u);
578-
return 0;
579-
}
580-
}
581-
#else
582524
typedef char *phar_zstr;
583525
#define PHAR_STR(a, b) \
584526
b = a;
585527
#define PHAR_ZSTR(a, b) \
586528
b = a;
587529
#define PHAR_STR_FREE(a)
588-
#endif
589530

590531
BEGIN_EXTERN_C()
591532

0 commit comments

Comments
 (0)