Commit: db6d93fecab928058956c71c35c67658152726b1
Author: Nikita Popov <ni...@php.net> Fri, 13 Sep 2013 21:40:32 +0200
Parents: e6b228332f3cd7b9e3a5f3ba8a8e08ae1b01abdf
Branches: master
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=db6d93fecab928058956c71c35c67658152726b1
Log:
Remove some more unnecessary macros from phar
Changed paths:
M ext/phar/phar.c
M ext/phar/phar_internal.h
M ext/phar/phar_object.c
M ext/phar/tar.c
M ext/phar/util.c
M ext/phar/zip.c
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 4de1aed..79f88b4 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -1639,7 +1639,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname,
int fname_len, char *a
php_stream_filter_append(&temp->writefilters,
filter);
- if (SUCCESS != phar_stream_copy_to_stream(fp,
temp, PHP_STREAM_COPY_ALL, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(fp,
temp, PHP_STREAM_COPY_ALL, NULL)) {
if (err) {
php_stream_close(temp);
MAPPHAR_ALLOC_FAIL("unable to
decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older
than 5.2.6")
@@ -1681,7 +1681,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname,
int fname_len, char *a
php_stream_filter_append(&temp->writefilters,
filter);
- if (SUCCESS != phar_stream_copy_to_stream(fp,
temp, PHP_STREAM_COPY_ALL, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(fp,
temp, PHP_STREAM_COPY_ALL, NULL)) {
php_stream_close(temp);
MAPPHAR_ALLOC_FAIL("unable to
decompress bzipped phar archive \"%s\" to temporary file")
}
@@ -2677,7 +2677,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub,
long len, int convert,
size_t written;
if (!user_stub && phar->halt_offset && oldfile &&
!phar->is_brandnew) {
- phar_stream_copy_to_stream(oldfile, newfile,
phar->halt_offset, &written);
+ php_stream_copy_to_stream_ex(oldfile, newfile,
phar->halt_offset, &written);
newstub = NULL;
} else {
/* this is either a brand new phar or a default stub
overwrite */
@@ -2865,7 +2865,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub,
long len, int convert,
return EOF;
}
php_stream_filter_append((&entry->cfp->writefilters), filter);
- if (SUCCESS != phar_stream_copy_to_stream(file, entry->cfp,
entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(file, entry->cfp,
entry->uncompressed_filesize, NULL)) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -3097,7 +3097,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub,
long len, int convert,
/* this will have changed for all files that have either
changed compression or been modified */
entry->offset = entry->offset_abs = offset;
offset += entry->compressed_filesize;
- if (phar_stream_copy_to_stream(file, newfile,
entry->compressed_filesize, &wrote) == FAILURE) {
+ if (php_stream_copy_to_stream_ex(file, newfile,
entry->compressed_filesize, &wrote) == FAILURE) {
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -3243,7 +3243,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub,
long len, int convert,
}
php_stream_filter_append(&phar->fp->writefilters,
filter);
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
php_stream_close(phar->fp);
@@ -3252,14 +3252,14 @@ int phar_flush(phar_archive_data *phar, char
*user_stub, long len, int convert,
} else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
filter = php_stream_filter_create("bzip2.compress",
NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
php_stream_filter_append(&phar->fp->writefilters,
filter);
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
} else {
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
/* we could also reopen the file in "rb" mode but there
is no need for that */
php_stream_close(newfile);
}
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index d12de71..64953f6 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -68,19 +68,6 @@
#include "ext/hash/php_hash_sha.h"
#endif
-#ifndef E_RECOVERABLE_ERROR
-# define E_RECOVERABLE_ERROR E_ERROR
-#endif
-
-#ifndef pestrndup
-# define pestrndup(s, length, persistent)
((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
-#endif
-
-#ifndef ALLOC_PERMANENT_ZVAL
-# define ALLOC_PERMANENT_ZVAL(z) \
- (z) = (zval*)malloc(sizeof(zval))
-#endif
-
/* PHP_ because this is public information via MINFO */
#define PHP_PHAR_API_VERSION "1.1.1"
/* x.y.z maps to 0xyz0 */
@@ -516,8 +503,6 @@ union _phar_entry_object {
extern char *(*phar_save_resolve_path)(const char *filename, int filename_len
TSRMLS_DC);
#endif
-#define phar_stream_copy_to_stream(src, dest, maxlen, len)
_php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC
TSRMLS_CC)
-
BEGIN_EXTERN_C()
#ifdef PHP_WIN32
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 7d2922f..7c11a48 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -1707,7 +1707,7 @@ after_open_fp:
data->internal_file->fp_type = PHAR_UFP;
data->internal_file->offset_abs = data->internal_file->offset =
php_stream_tell(p_obj->fp);
data->fp = NULL;
- phar_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL,
&contents_len);
+ php_stream_copy_to_stream_ex(fp, p_obj->fp,
PHP_STREAM_COPY_ALL, &contents_len);
data->internal_file->uncompressed_filesize =
data->internal_file->compressed_filesize =
php_stream_tell(p_obj->fp) -
data->internal_file->offset;
}
@@ -1997,7 +1997,7 @@ static int phar_copy_file_contents(phar_entry_info
*entry, php_stream *fp TSRMLS
link = entry;
}
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0
TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0
TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0
TSRMLS_CC,
"Cannot convert phar archive \"%s\", unable to copy
entry \"%s\" contents", entry->phar->fname, entry->filename);
return FAILURE;
@@ -3651,7 +3651,7 @@ static void phar_add_file(phar_archive_data **pphar, char
*filename, int filenam
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s
could not be written to", filename);
return;
}
- phar_stream_copy_to_stream(contents_file,
data->fp, PHP_STREAM_COPY_ALL, &contents_len);
+ php_stream_copy_to_stream_ex(contents_file,
data->fp, PHP_STREAM_COPY_ALL, &contents_len);
}
data->internal_file->compressed_filesize =
data->internal_file->uncompressed_filesize = contents_len;
@@ -4224,7 +4224,7 @@ static int phar_extract_file(zend_bool overwrite,
phar_entry_info *entry, char *
return FAILURE;
}
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0
TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0
TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying
contents failed", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 0e60e3d..180675a 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -783,7 +783,7 @@ static int phar_tar_writeheaders(void *pDest, void
*argument TSRMLS_DC) /* {{{ *
return ZEND_HASH_APPLY_STOP;
}
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0
TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry,
0 TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) {
if (fp->error) {
spprintf(fp->error, 4096, "tar-based phar
\"%s\" cannot be created, contents of file \"%s\" could not be written",
entry->phar->fname, entry->filename);
}
@@ -1288,7 +1288,7 @@ nostub:
if (!filter) {
/* copy contents uncompressed rather than lose
them */
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
php_stream_close(newfile);
if (error) {
spprintf(error, 4096, "unable to
compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6
have a buggy zlib", phar->fname);
@@ -1297,7 +1297,7 @@ nostub:
}
php_stream_filter_append(&phar->fp->writefilters,
filter);
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
php_stream_close(phar->fp);
@@ -1308,14 +1308,14 @@ nostub:
filter = php_stream_filter_create("bzip2.compress",
NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
php_stream_filter_append(&phar->fp->writefilters,
filter);
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
php_stream_close(phar->fp);
/* use the temp stream as our base */
phar->fp = newfile;
} else {
- phar_stream_copy_to_stream(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(newfile, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
/* we could also reopen the file in "rb" mode but there
is no need for that */
php_stream_close(newfile);
}
diff --git a/ext/phar/util.c b/ext/phar/util.c
index bf094af..d42164a 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -678,7 +678,7 @@ int phar_copy_entry_fp(phar_entry_info *source,
phar_entry_info *dest, char **er
link = source;
}
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0
TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0
TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) {
php_stream_close(dest->fp);
dest->fp_type = PHAR_FP;
if (error) {
@@ -780,7 +780,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char
**error, int follow_links TS
php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC),
phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
if (entry->uncompressed_filesize) {
- if (SUCCESS !=
phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp,
entry->compressed_filesize, NULL)) {
+ if (SUCCESS !=
php_stream_copy_to_stream_ex(phar_get_entrypfp(entry TSRMLS_CC), ufp,
entry->compressed_filesize, NULL)) {
spprintf(error, 4096, "phar error: internal corruption
of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname,
entry->filename);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
return FAILURE;
@@ -886,7 +886,7 @@ int phar_separate_entry_fp(phar_entry_info *entry, char
**error TSRMLS_DC) /* {{
link = entry;
}
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0
TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0
TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) {
if (error) {
spprintf(error, 4096, "phar error: cannot separate
entry file \"%s\" contents in phar archive \"%s\" for write access",
entry->filename, entry->phar->fname);
}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index e3b6485..2e977b8 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -417,11 +417,11 @@ foundit:
php_stream_seek(fp, 0, SEEK_SET);
/* copy file contents + local headers and zip comment,
if any, to be hashed for signature */
- phar_stream_copy_to_stream(fp, sigfile,
entry.header_offset, NULL);
+ php_stream_copy_to_stream_ex(fp, sigfile,
entry.header_offset, NULL);
/* seek to central directory */
php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset),
SEEK_SET);
/* copy central directory header */
- phar_stream_copy_to_stream(fp, sigfile, beforeus -
PHAR_GET_32(locator.cdir_offset), NULL);
+ php_stream_copy_to_stream_ex(fp, sigfile, beforeus -
PHAR_GET_32(locator.cdir_offset), NULL);
if (metadata) {
php_stream_write(sigfile, metadata,
PHAR_GET_16(locator.comment_len));
}
@@ -905,7 +905,7 @@ static int phar_zip_changed_apply(void *data, void *arg
TSRMLS_DC) /* {{{ */
php_stream_filter_append((&entry->cfp->writefilters), filter);
- if (SUCCESS != phar_stream_copy_to_stream(efp, entry->cfp,
entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp,
entry->uncompressed_filesize, NULL)) {
spprintf(p->error, 0, "unable to copy compressed file
contents of file \"%s\" while creating new phar \"%s\"", entry->filename,
entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -1010,7 +1010,7 @@ continue_dir:
if (!not_really_modified && entry->is_modified) {
if (entry->cfp) {
- if (SUCCESS != phar_stream_copy_to_stream(entry->cfp,
p->filefp, entry->compressed_filesize, NULL)) {
+ if (SUCCESS != php_stream_copy_to_stream_ex(entry->cfp,
p->filefp, entry->compressed_filesize, NULL)) {
spprintf(p->error, 0, "unable to write
compressed contents of file \"%s\" in zip-based phar \"%s\"", entry->filename,
entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -1024,7 +1024,7 @@ continue_dir:
phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC);
- if (SUCCESS !=
phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp,
entry->uncompressed_filesize, NULL)) {
+ if (SUCCESS !=
php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp,
entry->uncompressed_filesize, NULL)) {
spprintf(p->error, 0, "unable to write contents
of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -1050,7 +1050,7 @@ continue_dir:
}
}
- if (!entry->is_dir && entry->compressed_filesize && SUCCESS !=
phar_stream_copy_to_stream(p->old, p->filefp, entry->compressed_filesize,
NULL)) {
+ if (!entry->is_dir && entry->compressed_filesize && SUCCESS !=
php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize,
NULL)) {
spprintf(p->error, 0, "unable to copy contents of file
\"%s\" while creating zip-based phar \"%s\"", entry->filename,
entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
@@ -1093,10 +1093,10 @@ static int phar_zip_applysignature(phar_archive_data
*phar, struct _phar_zip_pas
st = tell = php_stream_tell(pass->filefp);
/* copy the local files, central directory, and the zip comment
to generate the hash */
php_stream_seek(pass->filefp, 0, SEEK_SET);
- phar_stream_copy_to_stream(pass->filefp, newfile, tell, NULL);
+ php_stream_copy_to_stream_ex(pass->filefp, newfile, tell, NULL);
tell = php_stream_tell(pass->centralfp);
php_stream_seek(pass->centralfp, 0, SEEK_SET);
- phar_stream_copy_to_stream(pass->centralfp, newfile, tell,
NULL);
+ php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell,
NULL);
if (metadata->c) {
php_stream_write(newfile, metadata->c, metadata->len);
}
@@ -1431,7 +1431,7 @@ nocentralerror:
{
size_t clen;
- int ret = phar_stream_copy_to_stream(pass.centralfp,
pass.filefp, PHP_STREAM_COPY_ALL, &clen);
+ int ret = php_stream_copy_to_stream_ex(pass.centralfp,
pass.filefp, PHP_STREAM_COPY_ALL, &clen);
if (SUCCESS != ret || clen != cdir_size) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\"
failed: unable to write central-directory", phar->fname);
@@ -1501,7 +1501,7 @@ nocentralerror:
return EOF;
}
php_stream_rewind(pass.filefp);
- phar_stream_copy_to_stream(pass.filefp, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
+ php_stream_copy_to_stream_ex(pass.filefp, phar->fp,
PHP_STREAM_COPY_ALL, NULL);
/* we could also reopen the file in "rb" mode but there is no
need for that */
php_stream_close(pass.filefp);
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php