]> granicus.if.org Git - php/commitdiff
Allow the symbol_table to be passed to call_user_function_ex()
authorZeev Suraski <zeev@php.net>
Sat, 17 Jun 2000 16:50:38 +0000 (16:50 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 17 Jun 2000 16:50:38 +0000 (16:50 +0000)
Zend/zend-scanner.l
Zend/zend.c
Zend/zend_API.h
Zend/zend_execute_API.c

index a69a51098258dac934dc80d9d26750204c0a0100..cbbb19a186903cd68cd5e53d33c1752a5f7021f4 100644 (file)
@@ -460,6 +460,8 @@ static inline int prepare_string_for_scanning(zval *str CLS_DC)
 
        CG(ZFL)->switch_streams(input_stream, &cout);
 #endif
+       zend_set_compiled_filename("Eval code");
+       CG(zend_lineno) = 1;
        return SUCCESS;
 }
 
index 48bad64c21f565ae87674810916cfd848ae01c4b..692d766576b25ae48f77b4fd2df159c120e64d08 100644 (file)
@@ -527,9 +527,9 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents)
 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();
@@ -589,33 +589,34 @@ ZEND_API void zend_error(int type, const char *format, ...)
                        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;
        }
 
index 5412a4fe8826cef96e7f5ba1c3908cb5fc971f0f..31b81f2572ef5761f8ac5c6195a786d0c0b0a740 100644 (file)
@@ -178,7 +178,7 @@ ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, i
 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);
index 8ba3ff8213f5785b758de5214d6b11137f492b04..1ff6bd937e54a1deeb7f9d4bda04aaeb50a457be 100644 (file)
@@ -325,7 +325,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n
        for (i=0; i<param_count; i++) {
                params_array[i] = &params[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 {
@@ -336,7 +336,7 @@ int call_user_function(HashTable *function_table, zval *object, zval *function_n
 }
 
 
-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;
@@ -417,8 +417,12 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
 
        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;
 
@@ -434,8 +438,10 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio
                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;