summaryrefslogtreecommitdiff
path: root/ext/zip
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-11-14 02:44:25 +0300
committerDmitry Stogov <dmitry@zend.com>2018-11-14 02:44:25 +0300
commitc6ad0b92b7d8e66a07cf75ed4abc39fe3e13e00d (patch)
tree7bee04b4a982731b930fce3fef7017c442d46fb0 /ext/zip
parent6bb94eacd72499b62bf636d1338ba0b77cdf1671 (diff)
downloadphp-git-c6ad0b92b7d8e66a07cf75ed4abc39fe3e13e00d.tar.gz
Replace getThis() by EX(This), when additional check is not necessary.
Diffstat (limited to 'ext/zip')
-rw-r--r--ext/zip/php_zip.c232
1 files changed, 41 insertions, 191 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index c4c3e90f53..5f124846a6 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1441,17 +1441,15 @@ static ZIPARCHIVE_METHOD(open)
zend_long flags = 0;
char *resolved_path;
zend_string *filename;
- zval *self = getThis();
- ze_zip_object *ze_obj = NULL;
+ zval *self = &EX(This);
+ ze_zip_object *ze_obj;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|l", &filename, &flags) == FAILURE) {
return;
}
- if (self) {
- /* We do not use ZIP_FROM_OBJECT, zip init function here */
- ze_obj = Z_ZIP_P(self);
- }
+ /* We do not use ZIP_FROM_OBJECT, zip init function here */
+ ze_obj = Z_ZIP_P(self);
if (ZSTR_LEN(filename) == 0) {
php_error_docref(NULL, E_WARNING, "Empty string as source");
@@ -1497,14 +1495,10 @@ Set the password for the active archive */
static ZIPARCHIVE_METHOD(setPassword)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
char *password;
size_t password_len;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &password, &password_len) == FAILURE) {
@@ -1529,14 +1523,10 @@ close the zip archive */
static ZIPARCHIVE_METHOD(close)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
ze_zip_object *ze_obj;
int err;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
ze_obj = Z_ZIP_P(self);
@@ -1568,11 +1558,7 @@ close the zip archive */
static ZIPARCHIVE_METHOD(count)
{
struct zip *intern;
- zval *self = getThis();
-
- if (!self) {
- RETURN_FALSE;
- }
+ zval *self = &EX(This);
ZIP_FROM_OBJECT(intern, self);
@@ -1585,7 +1571,7 @@ static ZIPARCHIVE_METHOD(count)
static ZIPARCHIVE_METHOD(getStatusString)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
#if LIBZIP_VERSION_MAJOR < 1
int zep, syp, len;
char error_string[128];
@@ -1593,10 +1579,6 @@ static ZIPARCHIVE_METHOD(getStatusString)
zip_error_t *err;
#endif
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
#if LIBZIP_VERSION_MAJOR < 1
@@ -1617,17 +1599,13 @@ Returns the index of the entry named filename in the archive */
static ZIPARCHIVE_METHOD(addEmptyDir)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
char *dirname;
size_t dirname_len;
int idx;
struct zip_stat sb;
char *s;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
@@ -1668,7 +1646,7 @@ static ZIPARCHIVE_METHOD(addEmptyDir)
static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
char *path = ".";
char *remove_path = NULL;
char *add_path = NULL;
@@ -1679,10 +1657,6 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
int found;
zend_string *pattern;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
/* 1 == glob, 2 == pcre */
if (type == 1) {
@@ -1793,16 +1767,12 @@ Add a file in a Zip archive using its path and the name to use. */
static ZIPARCHIVE_METHOD(addFile)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
char *entry_name = NULL;
size_t entry_name_len = 0;
zend_long offset_start = 0, offset_len = 0;
zend_string *filename;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|sll",
@@ -1833,7 +1803,7 @@ Add a file using content and the entry name */
static ZIPARCHIVE_METHOD(addFromString)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_string *buffer;
char *name;
size_t name_len;
@@ -1842,10 +1812,6 @@ static ZIPARCHIVE_METHOD(addFromString)
int pos = 0;
int cur_idx;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS",
@@ -1895,15 +1861,11 @@ Returns the information about a the zip entry filename */
static ZIPARCHIVE_METHOD(statName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long flags = 0;
struct zip_stat sb;
zend_string *name;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|l", &name, &flags) == FAILURE) {
@@ -1921,15 +1883,11 @@ Returns the zip entry information using its index */
static ZIPARCHIVE_METHOD(statIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index, flags = 0;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l",
@@ -1949,15 +1907,11 @@ Returns the index of the entry named filename in the archive */
static ZIPARCHIVE_METHOD(locateName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long flags = 0;
zend_long idx = -1;
zend_string *name;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|l", &name, &flags) == FAILURE) {
@@ -1983,14 +1937,10 @@ Returns the name of the file at position index */
static ZIPARCHIVE_METHOD(getNameIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
const char *name;
zend_long flags = 0, index = 0;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l",
@@ -2013,14 +1963,10 @@ Set or remove (NULL/'') the comment of the archive */
static ZIPARCHIVE_METHOD(setArchiveComment)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
size_t comment_len;
char * comment;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &comment, &comment_len) == FAILURE) {
@@ -2039,15 +1985,11 @@ Returns the comment of an entry using its index */
static ZIPARCHIVE_METHOD(getArchiveComment)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long flags = 0;
const char * comment;
int comment_len = 0;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flags) == FAILURE) {
@@ -2067,15 +2009,11 @@ Set or remove (NULL/'') the comment of an entry using its Name */
static ZIPARCHIVE_METHOD(setCommentName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
size_t comment_len, name_len;
char * comment, *name;
int idx;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
@@ -2100,16 +2038,12 @@ Set or remove (NULL/'') the comment of an entry using its index */
static ZIPARCHIVE_METHOD(setCommentIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index;
size_t comment_len;
char * comment;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls",
@@ -2130,16 +2064,12 @@ Set external attributes for file in zip, using its name */
static ZIPARCHIVE_METHOD(setExternalAttributesName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
size_t name_len;
char *name;
zend_long flags=0, opsys, attr;
zip_int64_t idx;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|l",
@@ -2168,14 +2098,10 @@ Set external attributes for file in zip, using its index */
static ZIPARCHIVE_METHOD(setExternalAttributesIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index, flags=0, opsys, attr;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll|l",
@@ -2197,7 +2123,7 @@ Get external attributes for file in zip, using its name */
static ZIPARCHIVE_METHOD(getExternalAttributesName)
{
struct zip *intern;
- zval *self = getThis(), *z_opsys, *z_attr;
+ zval *self = &EX(This), *z_opsys, *z_attr;
size_t name_len;
char *name;
zend_long flags=0;
@@ -2205,10 +2131,6 @@ static ZIPARCHIVE_METHOD(getExternalAttributesName)
zip_uint32_t attr;
zip_int64_t idx;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz/z/|l",
@@ -2241,16 +2163,12 @@ Get external attributes for file in zip, using its index */
static ZIPARCHIVE_METHOD(getExternalAttributesIndex)
{
struct zip *intern;
- zval *self = getThis(), *z_opsys, *z_attr;
+ zval *self = &EX(This), *z_opsys, *z_attr;
zend_long index, flags=0;
zip_uint8_t opsys;
zip_uint32_t attr;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/|l",
@@ -2278,16 +2196,12 @@ Set encryption method for file in zip, using its name */
static ZIPARCHIVE_METHOD(setEncryptionName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long method;
zip_int64_t idx;
char *name, *password = NULL;
size_t name_len, password_len;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|s",
@@ -2316,15 +2230,11 @@ Set encryption method for file in zip, using its index */
static ZIPARCHIVE_METHOD(setEncryptionIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index, method;
char *password = NULL;
size_t password_len;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|s",
@@ -2345,7 +2255,7 @@ Returns the comment of an entry using its name */
static ZIPARCHIVE_METHOD(getCommentName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
size_t name_len;
int idx;
zend_long flags = 0;
@@ -2353,10 +2263,6 @@ static ZIPARCHIVE_METHOD(getCommentName)
const char * comment;
char *name;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l",
@@ -2383,16 +2289,12 @@ Returns the comment of an entry using its index */
static ZIPARCHIVE_METHOD(getCommentIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index, flags = 0;
const char * comment;
int comment_len = 0;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l",
@@ -2411,16 +2313,12 @@ Set the compression of a file in zip, using its name */
static ZIPARCHIVE_METHOD(setCompressionName)
{
struct zip *intern;
- zval *this = getThis();
+ zval *this = &EX(This);
size_t name_len;
char *name;
zip_int64_t idx;
zend_long comp_method, comp_flags = 0;
- if (!this) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, this);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l",
@@ -2450,14 +2348,10 @@ Set the compression of a file in zip, using its index */
static ZIPARCHIVE_METHOD(setCompressionIndex)
{
struct zip *intern;
- zval *this = getThis();
+ zval *this = &EX(This);
zend_long index;
zend_long comp_method, comp_flags = 0;
- if (!this) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, this);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|l",
@@ -2478,13 +2372,9 @@ Delete a file using its index */
static ZIPARCHIVE_METHOD(deleteIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
@@ -2508,15 +2398,11 @@ Delete a file using its index */
static ZIPARCHIVE_METHOD(deleteName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
size_t name_len;
char *name;
struct zip_stat sb;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
@@ -2539,15 +2425,11 @@ Rename an entry selected by its index to new_name */
static ZIPARCHIVE_METHOD(renameIndex)
{
struct zip *intern;
- zval *self = getThis();
-
+ zval *self = &EX(This);
char *new_name;
size_t new_name_len;
zend_long index;
- if (!self) {
- RETURN_FALSE;
- }
ZIP_FROM_OBJECT(intern, self);
@@ -2575,15 +2457,11 @@ Rename an entry selected by its name to new_name */
static ZIPARCHIVE_METHOD(renameName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
struct zip_stat sb;
char *name, *new_name;
size_t name_len, new_name_len;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &new_name, &new_name_len) == FAILURE) {
@@ -2609,13 +2487,9 @@ Changes to the file at position index are reverted */
static ZIPARCHIVE_METHOD(unchangeIndex)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zend_long index;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
@@ -2639,15 +2513,11 @@ Changes to the file named 'name' are reverted */
static ZIPARCHIVE_METHOD(unchangeName)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
struct zip_stat sb;
char *name;
size_t name_len;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
@@ -2673,11 +2543,7 @@ All changes to files and global information in archive are reverted */
static ZIPARCHIVE_METHOD(unchangeAll)
{
struct zip *intern;
- zval *self = getThis();
-
- if (!self) {
- RETURN_FALSE;
- }
+ zval *self = &EX(This);
ZIP_FROM_OBJECT(intern, self);
@@ -2694,11 +2560,7 @@ Revert all global changes to the archive archive. For now, this only reverts ar
static ZIPARCHIVE_METHOD(unchangeArchive)
{
struct zip *intern;
- zval *self = getThis();
-
- if (!self) {
- RETURN_FALSE;
- }
+ zval *self = &EX(This);
ZIP_FROM_OBJECT(intern, self);
@@ -2721,7 +2583,7 @@ static ZIPARCHIVE_METHOD(extractTo)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
zval *zval_files = NULL;
zval *zval_file = NULL;
php_stream_statbuf ssb;
@@ -2731,10 +2593,6 @@ static ZIPARCHIVE_METHOD(extractTo)
int nelems;
- if (!self) {
- RETURN_FALSE;
- }
-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z", &pathto, &pathto_len, &zval_files) == FAILURE) {
return;
}
@@ -2805,7 +2663,7 @@ static ZIPARCHIVE_METHOD(extractTo)
static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
struct zip_stat sb;
struct zip_file *zf;
@@ -2819,10 +2677,6 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
int n = 0;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (type == 1) {
@@ -2889,17 +2743,13 @@ get a stream for an entry using its name */
static ZIPARCHIVE_METHOD(getStream)
{
struct zip *intern;
- zval *self = getThis();
+ zval *self = &EX(This);
struct zip_stat sb;
char *mode = "rb";
zend_string *filename;
php_stream *stream;
ze_zip_object *obj;
- if (!self) {
- RETURN_FALSE;
- }
-
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P", &filename) == FAILURE) {