summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2000-08-13 18:00:50 +0000
committerStanislav Malyshev <stas@php.net>2000-08-13 18:00:50 +0000
commit5090b1e8d5d3a3dc2afcb418d059520e8b9dd528 (patch)
tree35d04f58ed639d32ca9e59f9f817b67be3c15dad
parent93acbedce8afa8f77478eea30985e89efcdc61d1 (diff)
downloadphp-git-5090b1e8d5d3a3dc2afcb418d059520e8b9dd528.tar.gz
Fix zend_fiel_handle handling. Should fix URL include
and various opened_path inconsistencies.
-rw-r--r--Zend/zend-scanner.l21
-rw-r--r--Zend/zend.c1
-rw-r--r--Zend/zend_compile.c8
-rw-r--r--Zend/zend_compile.h4
-rw-r--r--Zend/zend_execute.c13
-rw-r--r--main/main.c2
-rw-r--r--sapi/cgi/cgi_main.c1
-rw-r--r--sapi/isapi/php4isapi.c1
-rw-r--r--sapi/nsapi/nsapi.c1
-rw-r--r--sapi/roxen/roxen.c1
-rw-r--r--sapi/thttpd/thttpd.c1
11 files changed, 27 insertions, 27 deletions
diff --git a/Zend/zend-scanner.l b/Zend/zend-scanner.l
index f95d7a13da..ada9c08cff 100644
--- a/Zend/zend-scanner.l
+++ b/Zend/zend-scanner.l
@@ -183,7 +183,7 @@ inline void restore_lexical_state(zend_lex_state *lex_state CLS_DC)
BEGIN_EXTERN_C()
-ZEND_API void zend_open_file_dtor(zend_file_handle *fh)
+ZEND_API void zend_file_handle_dtor(zend_file_handle *fh)
{
switch (fh->type) {
case ZEND_HANDLE_FP:
@@ -235,7 +235,7 @@ int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2)
}
-ZEND_API void zend_close_file_handle(zend_file_handle *file_handle CLS_DC)
+ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle CLS_DC)
{
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
}
@@ -252,19 +252,20 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
file_path = file_handle->opened_path;
break;
case ZEND_HANDLE_FD:
- file_path = file_handle->filename;
- file_handle->opened_path = NULL;
+ /* file_handle->opened_path = NULL; */
file_handle->handle.fp = fdopen(file_handle->handle.fd, "r");
break;
case ZEND_HANDLE_FP:
- file_path = file_handle->filename;
- file_handle->opened_path = NULL;
+ /* file_handle->opened_path = NULL; */
file_handle->handle.fp = file_handle->handle.fp;
break;
}
if (!file_handle->handle.fp) {
return FAILURE;
}
+ if (!file_path) {
+ file_path = file_handle->filename;
+ }
file_handle->type = ZEND_HANDLE_FP;
if (file_handle->handle.fp != stdin) {
zend_llist_add_element(&CG(open_files), file_handle);
@@ -276,7 +277,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
#else
switch (file_handle->type) {
case ZEND_HANDLE_FD:
- file_handle->opened_path = NULL;
+ /* file_handle->opened_path = NULL; */
file_handle->handle.is = new ifstream(file_handle->handle.fd);
file_handle->type = ZEND_HANDLE_FSTREAM;
break;
@@ -291,7 +292,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
break;
}
case ZEND_HANDLE_FP:
- file_handle->opened_path = NULL;
+ /* file_handle->opened_path = NULL; */
if (file_handle->handle.fp==stdin) {
file_handle->handle.is = &cin;
} else {
@@ -353,7 +354,6 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle CLS_DC)
CG(in_compilation) = 1;
CG(active_op_array) = op_array;
compiler_result = zendparse(CLS_C);
- zend_close_file_handle(file_handle CLS_CC);
do_return(&retval_znode, 0 CLS_CC);
restore_lexical_state(&original_lex_state CLS_CC);
CG(in_compilation) = original_in_compilation;
@@ -404,6 +404,7 @@ zend_op_array *compile_filename(int type, zval *filename CLS_DC ELS_DC)
EG(error_reporting) = 0;
}
retval = zend_compile_file(&file_handle CLS_CC);
+ zend_destroy_file_handle(&file_handle CLS_CC);
if (type==ZEND_REQUIRE) {
EG(error_reporting) = error_reporting;
@@ -513,7 +514,7 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
return FAILURE;
}
zend_highlight(syntax_highlighter_ini);
- zend_close_file_handle(&file_handle CLS_CC);
+ zend_destroy_file_handle(&file_handle CLS_CC);
restore_lexical_state(&original_lex_state CLS_CC);
return SUCCESS;
}
diff --git a/Zend/zend.c b/Zend/zend.c
index 5a12267e9c..f18beea9f4 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -707,6 +707,7 @@ ZEND_API int zend_execute_scripts(int type CLS_DC ELS_DC, int file_count, ...)
continue;
}
EG(active_op_array) = zend_compile_file(file_handle CLS_CC);
+ zend_destroy_file_handle(file_handle CLS_CC);
if (EG(active_op_array)) {
zend_execute(EG(active_op_array) ELS_CC);
zval_ptr_dtor(EG(return_value_ptr_ptr));
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index e76e542ba8..4061ccfa4b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -65,12 +65,6 @@ static void build_runtime_defined_function_key(zval *result, zval *name, zend_op
}
-static void zend_open_file_dtor_wrapper(zend_file_handle *fh)
-{
- zend_open_file_dtor(fh);
-}
-
-
static void init_compiler_declarables(CLS_D ELS_DC)
{
CG(declarables).ticks.type = IS_LONG;
@@ -94,7 +88,7 @@ void init_compiler(CLS_D ELS_DC)
CG(in_compilation) = 0;
zend_init_rsrc_list(ELS_C);
CG(unclean_shutdown) = 0;
- zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_open_file_dtor, 0);
+ zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0);
init_compiler_declarables(CLS_C ELS_CC);
}
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index bb49951afb..c0f64c3880 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -382,8 +382,8 @@ ZEND_API int zend_execute_scripts(int type CLS_DC ELS_DC, int file_count, ...);
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle CLS_DC);
ZEND_API void init_op_array(zend_op_array *op_array, int type, int initial_ops_size CLS_DC);
ZEND_API void destroy_op_array(zend_op_array *op_array);
-ZEND_API void zend_close_file_handle(zend_file_handle *file_handle CLS_DC);
-ZEND_API void zend_open_file_dtor(zend_file_handle *fh);
+ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle CLS_DC);
+ZEND_API void zend_file_handle_dtor(zend_file_handle *fh);
ZEND_API void destroy_zend_function(zend_function *function);
ZEND_API void destroy_zend_class(zend_class_entry *ce);
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 1017543cf3..a4e3e3f36f 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1978,17 +1978,14 @@ send_by_ref:
file_handle.handle.fp = zend_fopen(inc_filename->value.str.val, &opened_path);
file_handle.type = ZEND_HANDLE_FP;
- if (opened_path) {
- file_handle.filename = opened_path;
- file_handle.free_filename = 0;
- } else {
- file_handle.filename = inc_filename->value.str.val;
- file_handle.free_filename = 0;
- }
-
+ file_handle.filename = inc_filename->value.str.val;
+ file_handle.opened_path = opened_path;
+ file_handle.free_filename = 0;
+
if (file_handle.handle.fp) {
if (!opened_path || zend_hash_add(&EG(included_files), opened_path, strlen(opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) {
new_op_array = zend_compile_file(&file_handle CLS_CC);
+ zend_destroy_file_handle(&file_handle CLS_CC);
if (!new_op_array) {
fclose(file_handle.handle.fp);
}
diff --git a/main/main.c b/main/main.c
index 8186830c3e..c400928b5b 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1149,6 +1149,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
prepend_file.filename = PG(auto_prepend_file);
+ prepend_file.opened_path = NULL;
prepend_file.free_filename = 0;
prepend_file.type = ZEND_HANDLE_FILENAME;
prepend_file_p = &prepend_file;
@@ -1157,6 +1158,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
}
if (PG(auto_append_file) && PG(auto_append_file)[0]) {
append_file.filename = PG(auto_append_file);
+ append_file.opened_path = NULL;
append_file.free_filename = 0;
append_file.type = ZEND_HANDLE_FILENAME;
append_file_p = &append_file;
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index a985ebee22..6e5ae10467 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -641,6 +641,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
file_handle.filename = "-";
file_handle.type = ZEND_HANDLE_FP;
file_handle.handle.fp = stdin;
+ file_handle.opened_path = NULL;
/* This actually destructs the elements of the list - ugly hack */
zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars);
diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c
index 441b38d72a..6943ff2074 100644
--- a/sapi/isapi/php4isapi.c
+++ b/sapi/isapi/php4isapi.c
@@ -575,6 +575,7 @@ DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
file_handle.filename = sapi_globals->request_info.path_translated;
file_handle.free_filename = 0;
file_handle.type = ZEND_HANDLE_FILENAME;
+ file_handle.opened_path = NULL;
php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC);
php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index 94ac4072f7..210ac1766f 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -514,6 +514,7 @@ nsapi_module_main(NSLS_D SLS_DC)
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
+ file_handle.opened_path = NULL;
#if defined(NSAPI_DEBUG)
log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq),
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index 740104da91..62c17a7726 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -609,6 +609,7 @@ static int php_roxen_module_main(SLS_D)
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = THIS->filename;
file_handle.free_filename = 0;
+ file_handle.opened_path = NULL;
THREADS_ALLOW();
res = php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC);
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index daef768dfc..fb1fdd3c7a 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -213,6 +213,7 @@ static void thttpd_module_main(TLS_D SLS_DC)
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = TG(hc)->expnfilename;
file_handle.free_filename = 0;
+ file_handle.opened_path = NULL;
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
return;