CG(ZFL)->switch_streams(input_stream, &cout);
#endif
+ zend_set_compiled_filename("Eval code");
+ CG(zend_lineno) = 1;
return SUCCESS;
}
ZEND_API void zend_error(int type, const char *format, ...)
{
va_list args;
- zval **params;
- zval retval;
- zval error_type, error_message;
+ zval ***params;
+ zval *retval;
+ zval *error_type, *error_message;
char *error_filename;
uint error_lineno;
ELS_FETCH();
break;
default:
/* Handle the error in user space */
- INIT_PZVAL(&error_message);
- INIT_PZVAL(&error_type);
- error_message.value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
+ ALLOC_INIT_ZVAL(error_message);
+ ALLOC_INIT_ZVAL(error_type);
+ error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
#ifdef HAVE_VSNPRINTF
- error_message.value.str.len = vsnprintf(error_message.value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
+ error_message->value.str.len = vsnprintf(error_message->value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
#else
/* This is risky... */
- error_message.value.str.len = vsprintf(error_message.value.str.val, format, args);
+ error_message->value.str.len = vsprintf(error_message->value.str.val, format, args);
#endif
- error_message.type = IS_STRING;
+ error_message->type = IS_STRING;
- error_type.value.lval = type;
- error_type.type = IS_LONG;
+ error_type->value.lval = type;
+ error_type->type = IS_LONG;
- params = (zval **) emalloc(sizeof(zval *)*2);
+ params = (zval ***) emalloc(sizeof(zval **)*2);
params[0] = &error_type;
params[1] = &error_message;
- if (call_user_function(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params)==SUCCESS) {
- zval_dtor(&retval);
+ if (call_user_function_ex(CG(function_table), NULL, EG(user_error_handler), &retval, 2, params, 1, NULL)==SUCCESS) {
+ zval_ptr_dtor(&retval);
} else {
/* The user error handler failed, use built-in error handler */
zend_error_cb(type, error_filename, error_lineno, format, args);
}
efree(params);
- efree(error_message.value.str.val);
+ zval_ptr_dtor(&error_message);
+ zval_ptr_dtor(&error_type);
break;
}
ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, int param_count, zval *params[]);
-ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation);
+ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table);
ZEND_API int add_property_long(zval *arg, char *key, long l);
ZEND_API int add_property_unset(zval *arg, char *key);
for (i=0; i<param_count; i++) {
params_array[i] = ¶ms[i];
}
- ex_retval = call_user_function_ex(function_table, object, function_name, &local_retval_ptr, param_count, params_array, 1);
+ ex_retval = call_user_function_ex(function_table, object, function_name, &local_retval_ptr, param_count, params_array, 1, NULL);
if (local_retval_ptr) {
COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
} else {
}
-int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation)
+int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table)
{
int i;
zval **original_return_value;
if (function_state.function->type == ZEND_USER_FUNCTION) {
calling_symbol_table = EG(active_symbol_table);
- ALLOC_HASHTABLE(EG(active_symbol_table));
- zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+ if (symbol_table) {
+ EG(active_symbol_table) = symbol_table;
+ } else {
+ ALLOC_HASHTABLE(EG(active_symbol_table));
+ zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
+ }
if (object) {
zval *dummy, **this_ptr;
EG(active_op_array) = (zend_op_array *) function_state.function;
original_opline_ptr = EG(opline_ptr);
zend_execute(EG(active_op_array) ELS_CC);
- zend_hash_destroy(EG(active_symbol_table));
- FREE_HASHTABLE(EG(active_symbol_table));
+ if (!symbol_table) {
+ zend_hash_destroy(EG(active_symbol_table));
+ FREE_HASHTABLE(EG(active_symbol_table));
+ }
EG(active_symbol_table) = calling_symbol_table;
EG(active_op_array) = original_op_array;
EG(return_value_ptr_ptr)=original_return_value;