]> granicus.if.org Git - php/commitdiff
- Quick way of supporting include_once().
authorAndi Gutmans <andi@php.net>
Fri, 10 Mar 2000 16:36:30 +0000 (16:36 +0000)
committerAndi Gutmans <andi@php.net>
Fri, 10 Mar 2000 16:36:30 +0000 (16:36 +0000)
  Good enough for RC1.

Zend/zend-parser.y
Zend/zend_builtin_functions.c
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h

index 01a50c56e36aae9fc42a687ab76f3690d7fa75c0..6029e1e1b5a7bfe9a8bbca147fec8a088800cb65 100644 (file)
@@ -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); }
 ;
 
index b7a4168d24c4733e5d68571e5754011cc1f7a3ac..fb5fb432f278f3e0c77c077714ab766b1617b1ef 100644 (file)
@@ -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);
 }
index 8eb55c6de47806cb17300425e589672368d4de93..fd30dcaab87bef8f92d8e5d75ae9ae919ca896f2 100644 (file)
@@ -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);
index ee5485e14eab2fae1bce953691bdc31e331f3cc6..be10cb0606d7410b21f1e6db5955263f36a22761 100644 (file)
@@ -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));
 }
 
 
index a592bebb5a82ea6677e1a3dcc8146fb6d30b27ac..1a68f6c5879d8929cf74efbda8a0ab6a23329674 100644 (file)
@@ -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;