From: Andi Gutmans Date: Fri, 10 Mar 2000 16:36:30 +0000 (+0000) Subject: - Quick way of supporting include_once(). X-Git-Tag: PHP-4.0-RC1~199 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5951b166c84bbec2bb4c66bca15f5d3c17766629;p=php - Quick way of supporting include_once(). Good enough for RC1. --- diff --git a/Zend/zend-parser.y b/Zend/zend-parser.y index 01a50c56e3..6029e1e1b5 100644 --- a/Zend/zend-parser.y +++ b/Zend/zend-parser.y @@ -710,7 +710,7 @@ internal_functions_in_yacc: T_ISSET '(' cvar ')' { do_isset_or_isempty(ZEND_ISSET, &$$, &$3 CLS_CC); } | T_EMPTY '(' cvar ')' { do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 CLS_CC); } | T_INCLUDE expr { do_include_or_eval(ZEND_INCLUDE, &$$, &$2 CLS_CC); } - | T_INCLUDE_ONCE expr { do_include_or_eval(ZEND_INCLUDE, &$$, &$2 CLS_CC); } + | T_INCLUDE_ONCE expr { do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 CLS_CC); } | T_EVAL '(' expr ')' { do_include_or_eval(ZEND_EVAL, &$$, &$3 CLS_CC); } ; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index b7a4168d24..fb5fb432f2 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -49,7 +49,7 @@ static ZEND_FUNCTION(leak); static ZEND_FUNCTION(crash); #endif static ZEND_FUNCTION(get_used_files); -static ZEND_FUNCTION(get_imported_files); +static ZEND_FUNCTION(get_included_files); static ZEND_FUNCTION(is_subclass_of); static ZEND_FUNCTION(get_class_vars); static ZEND_FUNCTION(get_object_vars); @@ -79,7 +79,7 @@ static zend_function_entry builtin_functions[] = { ZEND_FE(crash, NULL) #endif ZEND_FE(get_used_files, NULL) - ZEND_FE(get_imported_files, NULL) + ZEND_FE(get_included_files, NULL) ZEND_FE(is_subclass_of, NULL) ZEND_FE(get_class_vars, NULL) ZEND_FE(get_object_vars, NULL) @@ -628,8 +628,8 @@ ZEND_FUNCTION(get_used_files) } -ZEND_FUNCTION(get_imported_files) +ZEND_FUNCTION(get_included_files) { array_init(return_value); - zend_hash_apply_with_argument(&EG(imported_files), (int (*)(void *, void *)) copy_import_use_file, return_value); + zend_hash_apply_with_argument(&EG(included_files), (int (*)(void *, void *)) copy_import_use_file, return_value); } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 8eb55c6de4..fd30dcaab8 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2055,6 +2055,24 @@ send_by_ref: return_value_used = RETURN_VALUE_USED(opline); switch (opline->op2.u.constant.value.lval) { + case ZEND_INCLUDE_ONCE: + { + FILE *inc_file; + char *opened_path; + int dummy = 0; + + inc_file = zend_fopen(opline->op1.u.constant.value.str.val, &opened_path); + + if (inc_file && opened_path) { + if (zend_hash_add(&EG(included_files), opened_path, strlen(opened_path)+1, (void *)&dummy, sizeof(int), NULL)==FAILURE) { + fclose(inc_file); + free(opened_path); + break; + } + fclose(inc_file); + free(opened_path); + } + } case ZEND_INCLUDE: case ZEND_REQUIRE: new_op_array = compile_filename(opline->op2.u.constant.value.lval, get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R) CLS_CC ELS_CC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index ee5485e14e..be10cb0606 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -115,7 +115,7 @@ void init_executor(CLS_D ELS_DC) EG(opline_ptr) = NULL; EG(garbage_ptr) = 0; - zend_hash_init(&EG(imported_files), 5, NULL, NULL, 0); + zend_hash_init(&EG(included_files), 5, NULL, NULL, 0); EG(ticks_count) = 0; } @@ -155,7 +155,7 @@ void shutdown_executor(ELS_D) #endif - zend_hash_destroy(&EG(imported_files)); + zend_hash_destroy(&EG(included_files)); } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index a592bebb5a..1a68f6c587 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -147,7 +147,7 @@ struct _zend_executor_globals { HashTable *active_symbol_table; HashTable symbol_table; /* main symbol table */ - HashTable imported_files; /* files already included using 'import' */ + HashTable included_files; /* files already included */ jmp_buf bailout;