Permalink
Browse files

- Quick way of supporting include_once().

  Good enough for RC1.
  • Loading branch information...
1 parent b5de395 commit 5951b166c84bbec2bb4c66bca15f5d3c17766629 @andigutmans andigutmans committed Mar 10, 2000
Showing with 26 additions and 8 deletions.
  1. +1 −1 Zend/zend-parser.y
  2. +4 −4 Zend/zend_builtin_functions.c
  3. +18 −0 Zend/zend_execute.c
  4. +2 −2 Zend/zend_execute_API.c
  5. +1 −1 Zend/zend_globals.h
View
@@ -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); }
;
@@ -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);
}
View
@@ -2055,6 +2055,24 @@ binary_assign_op_addr: {
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);
View
@@ -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));
}
View
@@ -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;

0 comments on commit 5951b16

Please sign in to comment.