summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2015-07-03 16:21:02 -0500
committerAaron Piotrowski <aaron@trowski.com>2015-07-03 17:53:41 -0500
commit02623ddb828689d3eb4e60bba9124cccbf65ec6b (patch)
tree8444c1e041f3ebe608c2043d3198a6bdeaa8b85c /Zend/zend_execute_API.c
parent22c38b2ef58fc97ca8cd82ae456d0082d2a8cd22 (diff)
downloadphp-git-02623ddb828689d3eb4e60bba9124cccbf65ec6b.tar.gz
Switch macro with __VA_ARGS__ to function
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index fd94c723c4..dde4b20b0b 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -211,6 +211,25 @@ static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */
}
/* }}} */
+static void zend_throw_or_error(int fetch_type, zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
+{
+ va_list va;
+ char *message = NULL;
+
+ va_start(va, format);
+ zend_vspprintf(&message, 0, format, va);
+
+ if (fetch_type & ZEND_FETCH_CLASS_EXCEPTION) {
+ zend_throw_error(exception_ce, message);
+ } else {
+ zend_error(E_ERROR, message);
+ }
+
+ efree(message);
+ va_end(va);
+}
+/* }}} */
+
void shutdown_destructors(void) /* {{{ */
{
if (CG(unclean_shutdown)) {
@@ -527,13 +546,6 @@ ZEND_API void _zval_internal_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) /* {{{ *
#define MARK_CONSTANT_VISITED(p) Z_TYPE_INFO_P(p) |= IS_VISITED_CONSTANT
#define RESET_CONSTANT_VISITED(p) Z_TYPE_INFO_P(p) &= ~IS_VISITED_CONSTANT
-#define THROW_OR_ERROR(fetch_type, ce, message, ...) \
- if (fetch_type & ZEND_FETCH_CLASS_EXCEPTION) { \
- zend_throw_error(ce, message, ##__VA_ARGS__); \
- } else { \
- zend_error(E_ERROR, message, ##__VA_ARGS__); \
- }
-
ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_class_entry *scope) /* {{{ */
{
zval *const_value;
@@ -1321,22 +1333,22 @@ check_fetch_type:
switch (fetch_sub_type) {
case ZEND_FETCH_CLASS_SELF:
if (UNEXPECTED(!EG(scope))) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Cannot access self:: when no class scope is active")
+ zend_throw_or_error(fetch_type, zend_ce_error, "Cannot access self:: when no class scope is active");
}
return EG(scope);
case ZEND_FETCH_CLASS_PARENT:
if (UNEXPECTED(!EG(scope))) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Cannot access parent:: when no class scope is active");
+ zend_throw_or_error(fetch_type, zend_ce_error, "Cannot access parent:: when no class scope is active");
return NULL;
}
if (UNEXPECTED(!EG(scope)->parent)) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Cannot access parent:: when current class scope has no parent");
+ zend_throw_or_error(fetch_type, zend_ce_error, "Cannot access parent:: when current class scope has no parent");
}
return EG(scope)->parent;
case ZEND_FETCH_CLASS_STATIC:
ce = zend_get_called_scope(EG(current_execute_data));
if (UNEXPECTED(!ce)) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Cannot access static:: when no class scope is active");
+ zend_throw_or_error(fetch_type, zend_ce_error, "Cannot access static:: when no class scope is active");
return NULL;
}
return ce;
@@ -1354,11 +1366,11 @@ check_fetch_type:
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
if (!(fetch_type & ZEND_FETCH_CLASS_SILENT) && !EG(exception)) {
if (fetch_sub_type == ZEND_FETCH_CLASS_INTERFACE) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Interface '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Interface '%s' not found", ZSTR_VAL(class_name));
} else if (fetch_sub_type == ZEND_FETCH_CLASS_TRAIT) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Trait '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Trait '%s' not found", ZSTR_VAL(class_name));
} else {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Class '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Class '%s' not found", ZSTR_VAL(class_name));
}
}
return NULL;
@@ -1376,11 +1388,11 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *
} else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Interface '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Interface '%s' not found", ZSTR_VAL(class_name));
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Trait '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Trait '%s' not found", ZSTR_VAL(class_name));
} else {
- THROW_OR_ERROR(fetch_type, zend_ce_error, "Class '%s' not found", ZSTR_VAL(class_name));
+ zend_throw_or_error(fetch_type, zend_ce_error, "Class '%s' not found", ZSTR_VAL(class_name));
}
}
return NULL;