]> granicus.if.org Git - php/commitdiff
MFZE1 (support return value in execute_scripts)
authorZeev Suraski <zeev@php.net>
Mon, 10 Sep 2001 00:07:32 +0000 (00:07 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 10 Sep 2001 00:07:32 +0000 (00:07 +0000)
Zend/zend.c
Zend/zend_execute_API.c
Zend/zend_globals.h

index 6eb3e931b621e97796063ee7ae64cd00798acf45..56e50c082dd447755a226ff08216f5a59c04228d 100644 (file)
@@ -794,6 +794,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
        int i;
        zend_file_handle *file_handle;
        zend_op_array *orig_op_array = EG(active_op_array);
+       zval *local_retval=NULL;
 
        va_start(files, file_count);
        for (i=0; i<file_count; i++) {
@@ -804,14 +805,12 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                EG(active_op_array) = zend_compile_file(file_handle, ZEND_INCLUDE TSRMLS_CC);
                zend_destroy_file_handle(file_handle TSRMLS_CC);
                if (EG(active_op_array)) {
+                       EG(return_value_ptr_ptr) = retval ? retval : &local_retval;
                        zend_execute(EG(active_op_array) TSRMLS_CC);
-                       zval_ptr_dtor(EG(return_value_ptr_ptr));
-                       if (retval) {
-                               EG(return_value_ptr_ptr) = retval;
-                       } else {
-                               EG(return_value_ptr_ptr) = &EG(global_return_value_ptr);
+                       if (!retval) {
+                               zval_ptr_dtor(EG(return_value_ptr_ptr));
+                               local_retval = NULL;
                        }
-                       EG(global_return_value_ptr) = NULL;
                        destroy_op_array(EG(active_op_array));
                        efree(EG(active_op_array));
                } else if (type==ZEND_REQUIRE) {
index 2a0b042e034f73f9e94f3d2fe8e9744f7ea595ba..abacd87026f9852a5fca8d4b68b853f30213ce16 100644 (file)
@@ -121,8 +121,7 @@ void init_executor(TSRMLS_D)
 #if 0&&ZEND_DEBUG
        original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
 #endif
-       EG(return_value_ptr_ptr) = &EG(global_return_value_ptr);
-       EG(global_return_value_ptr) = NULL;
+       EG(return_value_ptr_ptr) = NULL;
 
        EG(symtable_cache_ptr) = EG(symtable_cache)-1;
        EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1;
@@ -608,6 +607,7 @@ void execute_new_code(TSRMLS_D)
 {
     zend_op *opline, *end;
        zend_op *ret_opline;
+       zval *local_retval=NULL;
 
        if (!CG(interactive)
                || CG(active_op_array)->backpatch_count>0
@@ -641,9 +641,13 @@ void execute_new_code(TSRMLS_D)
         opline++;
     }
 
+       EG(return_value_ptr_ptr) = &local_retval;
        EG(active_op_array) = CG(active_op_array);
        zend_execute(CG(active_op_array) TSRMLS_CC);
-       zval_ptr_dtor(EG(return_value_ptr_ptr));
+       if (local_retval) {
+               zval_ptr_dtor(&local_retval);
+       }
+
        CG(active_op_array)->last--;    /* get rid of that ZEND_RETURN */
        CG(active_op_array)->start_op = CG(active_op_array)->opcodes+CG(active_op_array)->last;
 }
index 814f65be770828ada7c120d759178a5a9d3431c0..d3132e2b7a6a8bca76280d176c98442ba732538a 100644 (file)
@@ -143,9 +143,6 @@ struct _zend_executor_globals {
        zend_function_state *function_state_ptr;
        zend_ptr_stack arg_types_stack;
 
-       /* for global return() support */
-       zval *global_return_value_ptr;
-
        /* symbol table cache */
        HashTable *symtable_cache[SYMTABLE_CACHE_SIZE];
        HashTable **symtable_cache_limit;