2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 2.00 of the Zend license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.zend.com/license/2_00.txt. |
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
23 #include "zend_extensions.h"
24 #include "zend_modules.h"
25 #include "zend_constants.h"
26 #include "zend_list.h"
28 #include "zend_exceptions.h"
29 #include "zend_builtin_functions.h"
32 #include "zend_dtrace.h"
35 # define GLOBAL_FUNCTION_TABLE global_function_table
36 # define GLOBAL_CLASS_TABLE global_class_table
37 # define GLOBAL_CONSTANTS_TABLE global_constants_table
38 # define GLOBAL_AUTO_GLOBALS_TABLE global_auto_globals_table
40 # define GLOBAL_FUNCTION_TABLE CG(function_table)
41 # define GLOBAL_CLASS_TABLE CG(class_table)
42 # define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals)
43 # define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
46 #if defined(ZEND_WIN32) && ZEND_DEBUG
47 BOOL WINAPI
IsDebuggerPresent(VOID
);
50 /* true multithread-shared globals */
51 ZEND_API zend_class_entry
*zend_standard_class_def
= NULL
;
52 ZEND_API
int (*zend_printf
)(const char *format
, ...);
53 ZEND_API zend_write_func_t zend_write
;
54 ZEND_API
FILE *(*zend_fopen
)(const char *filename
, char **opened_path TSRMLS_DC
);
55 ZEND_API
int (*zend_stream_open_function
)(const char *filename
, zend_file_handle
*handle TSRMLS_DC
);
56 ZEND_API
void (*zend_block_interruptions
)(void);
57 ZEND_API
void (*zend_unblock_interruptions
)(void);
58 ZEND_API
void (*zend_ticks_function
)(int ticks
);
59 ZEND_API
void (*zend_error_cb
)(int type
, const char *error_filename
, const uint error_lineno
, const char *format
, va_list args
);
60 int (*zend_vspprintf
)(char **pbuf
, size_t max_len
, const char *format
, va_list ap
);
61 ZEND_API
char *(*zend_getenv
)(char *name
, size_t name_len TSRMLS_DC
);
62 ZEND_API
char *(*zend_resolve_path
)(const char *filename
, int filename_len TSRMLS_DC
);
64 void (*zend_on_timeout
)(int seconds TSRMLS_DC
);
66 static void (*zend_message_dispatcher_p
)(long message
, const void *data TSRMLS_DC
);
67 static int (*zend_get_configuration_directive_p
)(const char *name
, uint name_length
, zval
*contents
);
69 static ZEND_INI_MH(OnUpdateErrorReporting
) /* {{{ */
72 EG(error_reporting
) = E_ALL
& ~E_NOTICE
& ~E_STRICT
& ~E_DEPRECATED
;
74 EG(error_reporting
) = atoi(new_value
);
80 static ZEND_INI_MH(OnUpdateGCEnabled
) /* {{{ */
82 OnUpdateBool(entry
, new_value
, new_value_length
, mh_arg1
, mh_arg2
, mh_arg3
, stage TSRMLS_CC
);
84 if (GC_G(gc_enabled
)) {
92 static ZEND_INI_MH(OnUpdateScriptEncoding
) /* {{{ */
97 if (!zend_multibyte_get_functions(TSRMLS_C
)) {
100 return zend_multibyte_set_script_encoding_by_string(new_value
, new_value_length TSRMLS_CC
);
106 ZEND_INI_ENTRY("error_reporting", NULL
, ZEND_INI_ALL
, OnUpdateErrorReporting
)
107 STD_ZEND_INI_BOOLEAN("zend.enable_gc", "1", ZEND_INI_ALL
, OnUpdateGCEnabled
, gc_enabled
, zend_gc_globals
, gc_globals
)
108 STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR
, OnUpdateBool
, multibyte
, zend_compiler_globals
, compiler_globals
)
109 ZEND_INI_ENTRY("zend.script_encoding", NULL
, ZEND_INI_ALL
, OnUpdateScriptEncoding
)
110 STD_ZEND_INI_BOOLEAN("zend.detect_unicode", "1", ZEND_INI_ALL
, OnUpdateBool
, detect_unicode
, zend_compiler_globals
, compiler_globals
)
112 STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM
, OnUpdateBool
, check
, zend_signal_globals_t
, zend_signal_globals
)
118 ZEND_API
int compiler_globals_id
;
119 ZEND_API
int executor_globals_id
;
120 static HashTable
*global_function_table
= NULL
;
121 static HashTable
*global_class_table
= NULL
;
122 static HashTable
*global_constants_table
= NULL
;
123 static HashTable
*global_auto_globals_table
= NULL
;
124 static HashTable
*global_persistent_list
= NULL
;
127 ZEND_API zend_utility_values zend_uv
;
129 ZEND_API zval zval_used_for_init
; /* True global variable */
131 /* version information */
132 static char *zend_version_info
;
133 static uint zend_version_info_length
;
134 #define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2013 Zend Technologies\n"
135 #define PRINT_ZVAL_INDENT 4
137 static void print_hash(zend_write_func_t write_func
, HashTable
*ht
, int indent
, zend_bool is_object TSRMLS_DC
) /* {{{ */
141 HashPosition iterator
;
146 for (i
= 0; i
< indent
; i
++) {
150 indent
+= PRINT_ZVAL_INDENT
;
151 zend_hash_internal_pointer_reset_ex(ht
, &iterator
);
152 while (zend_hash_get_current_data_ex(ht
, (void **) &tmp
, &iterator
) == SUCCESS
) {
153 for (i
= 0; i
< indent
; i
++) {
157 switch (zend_hash_get_current_key_ex(ht
, &string_key
, &str_len
, &num_key
, 0, &iterator
)) {
158 case HASH_KEY_IS_STRING
:
160 const char *prop_name
, *class_name
;
161 int mangled
= zend_unmangle_property_name(string_key
, str_len
- 1, &class_name
, &prop_name
);
163 ZEND_PUTS_EX(prop_name
);
164 if (class_name
&& mangled
== SUCCESS
) {
165 if (class_name
[0]=='*') {
166 ZEND_PUTS_EX(":protected");
169 ZEND_PUTS_EX(class_name
);
170 ZEND_PUTS_EX(":private");
174 ZEND_WRITE_EX(string_key
, str_len
-1);
177 case HASH_KEY_IS_LONG
:
180 snprintf(key
, sizeof(key
), "%ld", num_key
);
185 ZEND_PUTS_EX("] => ");
186 zend_print_zval_r_ex(write_func
, *tmp
, indent
+PRINT_ZVAL_INDENT TSRMLS_CC
);
188 zend_hash_move_forward_ex(ht
, &iterator
);
190 indent
-= PRINT_ZVAL_INDENT
;
191 for (i
= 0; i
< indent
; i
++) {
198 static void print_flat_hash(HashTable
*ht TSRMLS_DC
) /* {{{ */
202 HashPosition iterator
;
207 zend_hash_internal_pointer_reset_ex(ht
, &iterator
);
208 while (zend_hash_get_current_data_ex(ht
, (void **) &tmp
, &iterator
) == SUCCESS
) {
213 switch (zend_hash_get_current_key_ex(ht
, &string_key
, &str_len
, &num_key
, 0, &iterator
)) {
214 case HASH_KEY_IS_STRING
:
215 ZEND_PUTS(string_key
);
217 case HASH_KEY_IS_LONG
:
218 zend_printf("%ld", num_key
);
222 zend_print_flat_zval_r(*tmp TSRMLS_CC
);
223 zend_hash_move_forward_ex(ht
, &iterator
);
228 ZEND_API
void zend_make_printable_zval(zval
*expr
, zval
*expr_copy
, int *use_copy
) /* {{{ */
230 if (Z_TYPE_P(expr
)==IS_STRING
) {
234 switch (Z_TYPE_P(expr
)) {
236 Z_STRLEN_P(expr_copy
) = 0;
237 Z_STRVAL_P(expr_copy
) = STR_EMPTY_ALLOC();
240 if (Z_LVAL_P(expr
)) {
241 Z_STRLEN_P(expr_copy
) = 1;
242 Z_STRVAL_P(expr_copy
) = estrndup("1", 1);
244 Z_STRLEN_P(expr_copy
) = 0;
245 Z_STRVAL_P(expr_copy
) = STR_EMPTY_ALLOC();
249 Z_STRVAL_P(expr_copy
) = (char *) emalloc(sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG
);
250 Z_STRLEN_P(expr_copy
) = snprintf(Z_STRVAL_P(expr_copy
), sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG
, "Resource id #%ld", Z_LVAL_P(expr
));
253 zend_error(E_NOTICE
, "Array to string conversion");
254 Z_STRLEN_P(expr_copy
) = sizeof("Array") - 1;
255 Z_STRVAL_P(expr_copy
) = estrndup("Array", Z_STRLEN_P(expr_copy
));
261 if (zend_std_cast_object_tostring(expr
, expr_copy
, IS_STRING TSRMLS_CC
) == SUCCESS
) {
264 if (Z_OBJ_HANDLER_P(expr
, cast_object
)) {
268 INIT_PZVAL_COPY(val
, expr
);
270 if (Z_OBJ_HANDLER_P(expr
, cast_object
)(val
, expr_copy
, IS_STRING TSRMLS_CC
) == SUCCESS
) {
276 if (!Z_OBJ_HANDLER_P(expr
, cast_object
) && Z_OBJ_HANDLER_P(expr
, get
)) {
277 zval
*z
= Z_OBJ_HANDLER_P(expr
, get
)(expr TSRMLS_CC
);
280 if (Z_TYPE_P(z
) != IS_OBJECT
) {
281 zend_make_printable_zval(z
, expr_copy
, use_copy
);
285 ZVAL_ZVAL(expr_copy
, z
, 0, 1);
292 zend_error(EG(exception
) ? E_ERROR
: E_RECOVERABLE_ERROR
, "Object of class %s could not be converted to string", Z_OBJCE_P(expr
)->name
);
293 Z_STRLEN_P(expr_copy
) = 0;
294 Z_STRVAL_P(expr_copy
) = STR_EMPTY_ALLOC();
299 zval_copy_ctor(expr_copy
);
300 zend_locale_sprintf_double(expr_copy ZEND_FILE_LINE_CC
);
304 zval_copy_ctor(expr_copy
);
305 convert_to_string(expr_copy
);
308 Z_TYPE_P(expr_copy
) = IS_STRING
;
313 ZEND_API
int zend_print_zval(zval
*expr
, int indent
) /* {{{ */
315 return zend_print_zval_ex(zend_write
, expr
, indent
);
319 ZEND_API
int zend_print_zval_ex(zend_write_func_t write_func
, zval
*expr
, int indent
) /* {{{ */
324 zend_make_printable_zval(expr
, &expr_copy
, &use_copy
);
328 if (Z_STRLEN_P(expr
) == 0) { /* optimize away empty strings */
334 write_func(Z_STRVAL_P(expr
), Z_STRLEN_P(expr
));
338 return Z_STRLEN_P(expr
);
342 ZEND_API
void zend_print_flat_zval_r(zval
*expr TSRMLS_DC
) /* {{{ */
344 switch (Z_TYPE_P(expr
)) {
346 ZEND_PUTS("Array (");
347 if (++Z_ARRVAL_P(expr
)->nApplyCount
>1) {
348 ZEND_PUTS(" *RECURSION*");
349 Z_ARRVAL_P(expr
)->nApplyCount
--;
352 print_flat_hash(Z_ARRVAL_P(expr
) TSRMLS_CC
);
354 Z_ARRVAL_P(expr
)->nApplyCount
--;
358 HashTable
*properties
= NULL
;
359 const char *class_name
= NULL
;
362 if (Z_OBJ_HANDLER_P(expr
, get_class_name
)) {
363 Z_OBJ_HANDLER_P(expr
, get_class_name
)(expr
, &class_name
, &clen
, 0 TSRMLS_CC
);
366 zend_printf("%s Object (", class_name
);
368 zend_printf("%s Object (", "Unknown Class");
371 efree((char*)class_name
);
373 if (Z_OBJ_HANDLER_P(expr
, get_properties
)) {
374 properties
= Z_OBJPROP_P(expr
);
377 if (++properties
->nApplyCount
>1) {
378 ZEND_PUTS(" *RECURSION*");
379 properties
->nApplyCount
--;
382 print_flat_hash(properties TSRMLS_CC
);
383 properties
->nApplyCount
--;
389 zend_print_variable(expr
);
395 ZEND_API
void zend_print_zval_r(zval
*expr
, int indent TSRMLS_DC
) /* {{{ */
397 zend_print_zval_r_ex(zend_write
, expr
, indent TSRMLS_CC
);
401 ZEND_API
void zend_print_zval_r_ex(zend_write_func_t write_func
, zval
*expr
, int indent TSRMLS_DC
) /* {{{ */
403 switch (Z_TYPE_P(expr
)) {
405 ZEND_PUTS_EX("Array\n");
406 if (++Z_ARRVAL_P(expr
)->nApplyCount
>1) {
407 ZEND_PUTS_EX(" *RECURSION*");
408 Z_ARRVAL_P(expr
)->nApplyCount
--;
411 print_hash(write_func
, Z_ARRVAL_P(expr
), indent
, 0 TSRMLS_CC
);
412 Z_ARRVAL_P(expr
)->nApplyCount
--;
416 HashTable
*properties
;
417 const char *class_name
= NULL
;
421 if (Z_OBJ_HANDLER_P(expr
, get_class_name
)) {
422 Z_OBJ_HANDLER_P(expr
, get_class_name
)(expr
, &class_name
, &clen
, 0 TSRMLS_CC
);
425 ZEND_PUTS_EX(class_name
);
427 ZEND_PUTS_EX("Unknown Class");
429 ZEND_PUTS_EX(" Object\n");
431 efree((char*)class_name
);
433 if ((properties
= Z_OBJDEBUG_P(expr
, is_temp
)) == NULL
) {
436 if (++properties
->nApplyCount
>1) {
437 ZEND_PUTS_EX(" *RECURSION*");
438 properties
->nApplyCount
--;
441 print_hash(write_func
, properties
, indent
, 1 TSRMLS_CC
);
442 properties
->nApplyCount
--;
444 zend_hash_destroy(properties
);
450 zend_print_zval_ex(write_func
, expr
, indent
);
456 static FILE *zend_fopen_wrapper(const char *filename
, char **opened_path TSRMLS_DC
) /* {{{ */
459 *opened_path
= estrdup(filename
);
461 return fopen(filename
, "rb");
466 static zend_bool asp_tags_default
= 0;
467 static zend_bool short_tags_default
= 1;
468 static zend_uint compiler_options_default
= ZEND_COMPILE_DEFAULT
;
470 # define asp_tags_default 0
471 # define short_tags_default 1
472 # define compiler_options_default ZEND_COMPILE_DEFAULT
475 static void zend_set_default_compile_time_values(TSRMLS_D
) /* {{{ */
477 /* default compile-time values */
478 CG(asp_tags
) = asp_tags_default
;
479 CG(short_tags
) = short_tags_default
;
480 CG(compiler_options
) = compiler_options_default
;
484 static void zend_init_exception_op(TSRMLS_D
) /* {{{ */
486 memset(EG(exception_op
), 0, sizeof(EG(exception_op
)));
487 EG(exception_op
)[0].opcode
= ZEND_HANDLE_EXCEPTION
;
488 EG(exception_op
)[0].op1_type
= IS_UNUSED
;
489 EG(exception_op
)[0].op2_type
= IS_UNUSED
;
490 EG(exception_op
)[0].result_type
= IS_UNUSED
;
491 ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op
));
492 EG(exception_op
)[1].opcode
= ZEND_HANDLE_EXCEPTION
;
493 EG(exception_op
)[1].op1_type
= IS_UNUSED
;
494 EG(exception_op
)[1].op2_type
= IS_UNUSED
;
495 EG(exception_op
)[1].result_type
= IS_UNUSED
;
496 ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op
)+1);
497 EG(exception_op
)[2].opcode
= ZEND_HANDLE_EXCEPTION
;
498 EG(exception_op
)[2].op1_type
= IS_UNUSED
;
499 EG(exception_op
)[2].op2_type
= IS_UNUSED
;
500 EG(exception_op
)[2].result_type
= IS_UNUSED
;
501 ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op
)+2);
506 static void compiler_globals_ctor(zend_compiler_globals
*compiler_globals TSRMLS_DC
) /* {{{ */
508 zend_function tmp_func
;
509 zend_class_entry
*tmp_class
;
511 compiler_globals
->compiled_filename
= NULL
;
513 compiler_globals
->function_table
= (HashTable
*) malloc(sizeof(HashTable
));
514 zend_hash_init_ex(compiler_globals
->function_table
, 100, NULL
, ZEND_FUNCTION_DTOR
, 1, 0);
515 zend_hash_copy(compiler_globals
->function_table
, global_function_table
, NULL
, &tmp_func
, sizeof(zend_function
));
517 compiler_globals
->class_table
= (HashTable
*) malloc(sizeof(HashTable
));
518 zend_hash_init_ex(compiler_globals
->class_table
, 10, NULL
, ZEND_CLASS_DTOR
, 1, 0);
519 zend_hash_copy(compiler_globals
->class_table
, global_class_table
, (copy_ctor_func_t
) zend_class_add_ref
, &tmp_class
, sizeof(zend_class_entry
*));
521 zend_set_default_compile_time_values(TSRMLS_C
);
525 compiler_globals
->auto_globals
= (HashTable
*) malloc(sizeof(HashTable
));
526 zend_hash_init_ex(compiler_globals
->auto_globals
, 8, NULL
, NULL
, 1, 0);
527 zend_hash_copy(compiler_globals
->auto_globals
, global_auto_globals_table
, NULL
, NULL
, sizeof(zend_auto_global
) /* empty element */);
529 compiler_globals
->last_static_member
= zend_hash_num_elements(compiler_globals
->class_table
);
530 if (compiler_globals
->last_static_member
) {
531 compiler_globals
->static_members_table
= calloc(compiler_globals
->last_static_member
, sizeof(zval
**));
533 compiler_globals
->static_members_table
= NULL
;
535 compiler_globals
->script_encoding_list
= NULL
;
539 static void compiler_globals_dtor(zend_compiler_globals
*compiler_globals TSRMLS_DC
) /* {{{ */
541 if (compiler_globals
->function_table
!= GLOBAL_FUNCTION_TABLE
) {
542 zend_hash_destroy(compiler_globals
->function_table
);
543 free(compiler_globals
->function_table
);
545 if (compiler_globals
->class_table
!= GLOBAL_CLASS_TABLE
) {
546 zend_hash_destroy(compiler_globals
->class_table
);
547 free(compiler_globals
->class_table
);
549 if (compiler_globals
->auto_globals
!= GLOBAL_AUTO_GLOBALS_TABLE
) {
550 zend_hash_destroy(compiler_globals
->auto_globals
);
551 free(compiler_globals
->auto_globals
);
553 if (compiler_globals
->static_members_table
) {
554 free(compiler_globals
->static_members_table
);
556 if (compiler_globals
->script_encoding_list
) {
557 pefree(compiler_globals
->script_encoding_list
, 1);
559 compiler_globals
->last_static_member
= 0;
563 static void executor_globals_ctor(zend_executor_globals
*executor_globals TSRMLS_DC
) /* {{{ */
565 zend_startup_constants(TSRMLS_C
);
566 zend_copy_constants(EG(zend_constants
), GLOBAL_CONSTANTS_TABLE
);
567 zend_init_rsrc_plist(TSRMLS_C
);
568 zend_init_exception_op(TSRMLS_C
);
569 EG(lambda_count
) = 0;
570 EG(user_error_handler
) = NULL
;
571 EG(user_exception_handler
) = NULL
;
572 EG(in_execution
) = 0;
573 EG(in_autoload
) = NULL
;
574 EG(current_execute_data
) = NULL
;
575 EG(current_module
) = NULL
;
578 EG(saved_fpu_cw
) = 0;
580 EG(saved_fpu_cw_ptr
) = NULL
;
585 static void executor_globals_dtor(zend_executor_globals
*executor_globals TSRMLS_DC
) /* {{{ */
587 zend_ini_shutdown(TSRMLS_C
);
588 if (&executor_globals
->persistent_list
!= global_persistent_list
) {
589 zend_destroy_rsrc_list(&executor_globals
->persistent_list TSRMLS_CC
);
591 if (executor_globals
->zend_constants
!= GLOBAL_CONSTANTS_TABLE
) {
592 zend_hash_destroy(executor_globals
->zend_constants
);
593 free(executor_globals
->zend_constants
);
598 static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC
) /* {{{ */
600 if (zend_copy_ini_directives(TSRMLS_C
) == SUCCESS
) {
601 zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC
);
607 #if defined(__FreeBSD__) || defined(__DragonFly__)
608 /* FreeBSD and DragonFly floating point precision fix */
609 #include <floatingpoint.h>
612 static void ini_scanner_globals_ctor(zend_ini_scanner_globals
*scanner_globals_p TSRMLS_DC
) /* {{{ */
614 memset(scanner_globals_p
, 0, sizeof(*scanner_globals_p
));
618 static void php_scanner_globals_ctor(zend_php_scanner_globals
*scanner_globals_p TSRMLS_DC
) /* {{{ */
620 memset(scanner_globals_p
, 0, sizeof(*scanner_globals_p
));
624 void zend_init_opcodes_handlers(void);
626 static zend_bool
php_auto_globals_create_globals(const char *name
, uint name_len TSRMLS_DC
) /* {{{ */
631 Z_SET_REFCOUNT_P(globals
, 1);
632 Z_SET_ISREF_P(globals
);
633 Z_TYPE_P(globals
) = IS_ARRAY
;
634 Z_ARRVAL_P(globals
) = &EG(symbol_table
);
635 zend_hash_update(&EG(symbol_table
), name
, name_len
+ 1, &globals
, sizeof(zval
*), NULL
);
640 int zend_startup(zend_utility_functions
*utility_functions
, char **extensions TSRMLS_DC
) /* {{{ */
643 zend_compiler_globals
*compiler_globals
;
644 zend_executor_globals
*executor_globals
;
645 extern ZEND_API ts_rsrc_id ini_scanner_globals_id
;
646 extern ZEND_API ts_rsrc_id language_scanner_globals_id
;
648 extern zend_ini_scanner_globals ini_scanner_globals
;
649 extern zend_php_scanner_globals language_scanner_globals
;
652 start_memory_manager(TSRMLS_C
);
654 #if defined(__FreeBSD__) || defined(__DragonFly__)
655 /* FreeBSD and DragonFly floating point precision fix */
659 zend_startup_strtod();
660 zend_startup_extensions_mechanism();
662 /* Set up utility functions and values */
663 zend_error_cb
= utility_functions
->error_function
;
664 zend_printf
= utility_functions
->printf_function
;
665 zend_write
= (zend_write_func_t
) utility_functions
->write_function
;
666 zend_fopen
= utility_functions
->fopen_function
;
668 zend_fopen
= zend_fopen_wrapper
;
670 zend_stream_open_function
= utility_functions
->stream_open_function
;
671 zend_message_dispatcher_p
= utility_functions
->message_handler
;
673 zend_block_interruptions
= utility_functions
->block_interruptions
;
674 zend_unblock_interruptions
= utility_functions
->unblock_interruptions
;
676 zend_get_configuration_directive_p
= utility_functions
->get_configuration_directive
;
677 zend_ticks_function
= utility_functions
->ticks_function
;
678 zend_on_timeout
= utility_functions
->on_timeout
;
679 zend_vspprintf
= utility_functions
->vspprintf_function
;
680 zend_getenv
= utility_functions
->getenv_function
;
681 zend_resolve_path
= utility_functions
->resolve_path_function
;
684 /* build with dtrace support */
685 zend_compile_file
= dtrace_compile_file
;
686 zend_execute
= dtrace_execute
;
687 zend_execute_internal
= dtrace_execute_internal
;
689 zend_compile_file
= compile_file
;
690 zend_execute
= execute
;
691 zend_execute_internal
= NULL
;
692 #endif /* HAVE_SYS_SDT_H */
693 zend_compile_string
= compile_string
;
694 zend_throw_exception_hook
= NULL
;
696 zend_init_opcodes_handlers();
699 zend_version_info
= strdup(ZEND_CORE_VERSION_INFO
);
700 zend_version_info_length
= sizeof(ZEND_CORE_VERSION_INFO
) - 1;
702 GLOBAL_FUNCTION_TABLE
= (HashTable
*) malloc(sizeof(HashTable
));
703 GLOBAL_CLASS_TABLE
= (HashTable
*) malloc(sizeof(HashTable
));
704 GLOBAL_AUTO_GLOBALS_TABLE
= (HashTable
*) malloc(sizeof(HashTable
));
705 GLOBAL_CONSTANTS_TABLE
= (HashTable
*) malloc(sizeof(HashTable
));
707 zend_hash_init_ex(GLOBAL_FUNCTION_TABLE
, 100, NULL
, ZEND_FUNCTION_DTOR
, 1, 0);
708 zend_hash_init_ex(GLOBAL_CLASS_TABLE
, 10, NULL
, ZEND_CLASS_DTOR
, 1, 0);
709 zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE
, 8, NULL
, NULL
, 1, 0);
710 zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE
, 20, NULL
, ZEND_CONSTANT_DTOR
, 1, 0);
712 zend_hash_init_ex(&module_registry
, 50, NULL
, ZEND_MODULE_DTOR
, 1, 0);
713 zend_init_rsrc_list_dtors();
715 /* This zval can be used to initialize allocate zval's to an uninit'ed value */
716 Z_UNSET_ISREF(zval_used_for_init
);
717 Z_SET_REFCOUNT(zval_used_for_init
, 1);
718 Z_TYPE(zval_used_for_init
) = IS_NULL
;
721 ts_allocate_id(&compiler_globals_id
, sizeof(zend_compiler_globals
), (ts_allocate_ctor
) compiler_globals_ctor
, (ts_allocate_dtor
) compiler_globals_dtor
);
722 ts_allocate_id(&executor_globals_id
, sizeof(zend_executor_globals
), (ts_allocate_ctor
) executor_globals_ctor
, (ts_allocate_dtor
) executor_globals_dtor
);
723 ts_allocate_id(&language_scanner_globals_id
, sizeof(zend_php_scanner_globals
), (ts_allocate_ctor
) php_scanner_globals_ctor
, NULL
);
724 ts_allocate_id(&ini_scanner_globals_id
, sizeof(zend_ini_scanner_globals
), (ts_allocate_ctor
) ini_scanner_globals_ctor
, NULL
);
725 compiler_globals
= ts_resource(compiler_globals_id
);
726 executor_globals
= ts_resource(executor_globals_id
);
728 compiler_globals_dtor(compiler_globals TSRMLS_CC
);
729 compiler_globals
->in_compilation
= 0;
730 compiler_globals
->function_table
= (HashTable
*) malloc(sizeof(HashTable
));
731 compiler_globals
->class_table
= (HashTable
*) malloc(sizeof(HashTable
));
733 *compiler_globals
->function_table
= *GLOBAL_FUNCTION_TABLE
;
734 *compiler_globals
->class_table
= *GLOBAL_CLASS_TABLE
;
735 compiler_globals
->auto_globals
= GLOBAL_AUTO_GLOBALS_TABLE
;
737 zend_hash_destroy(executor_globals
->zend_constants
);
738 *executor_globals
->zend_constants
= *GLOBAL_CONSTANTS_TABLE
;
740 ini_scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC
);
741 php_scanner_globals_ctor(&language_scanner_globals TSRMLS_CC
);
742 zend_set_default_compile_time_values(TSRMLS_C
);
743 EG(user_error_handler
) = NULL
;
744 EG(user_exception_handler
) = NULL
;
747 zend_interned_strings_init(TSRMLS_C
);
748 zend_startup_builtin_functions(TSRMLS_C
);
749 zend_register_standard_constants(TSRMLS_C
);
750 zend_register_auto_global("GLOBALS", sizeof("GLOBALS") - 1, 1, php_auto_globals_create_globals TSRMLS_CC
);
753 zend_init_rsrc_plist(TSRMLS_C
);
754 zend_init_exception_op(TSRMLS_C
);
757 zend_ini_startup(TSRMLS_C
);
760 tsrm_set_new_thread_end_handler(zend_new_thread_end_handler
);
767 void zend_register_standard_ini_entries(TSRMLS_D
) /* {{{ */
769 int module_number
= 0;
771 REGISTER_INI_ENTRIES();
775 /* Unlink the global (r/o) copies of the class, function and constant tables,
776 * and use a fresh r/w copy for the startup thread
778 void zend_post_startup(TSRMLS_D
) /* {{{ */
781 zend_encoding
**script_encoding_list
;
783 zend_compiler_globals
*compiler_globals
= ts_resource(compiler_globals_id
);
784 zend_executor_globals
*executor_globals
= ts_resource(executor_globals_id
);
786 *GLOBAL_FUNCTION_TABLE
= *compiler_globals
->function_table
;
787 *GLOBAL_CLASS_TABLE
= *compiler_globals
->class_table
;
788 *GLOBAL_CONSTANTS_TABLE
= *executor_globals
->zend_constants
;
790 asp_tags_default
= CG(asp_tags
);
791 short_tags_default
= CG(short_tags
);
792 compiler_options_default
= CG(compiler_options
);
794 zend_destroy_rsrc_list(&EG(persistent_list
) TSRMLS_CC
);
795 free(compiler_globals
->function_table
);
796 free(compiler_globals
->class_table
);
797 if ((script_encoding_list
= (zend_encoding
**)compiler_globals
->script_encoding_list
)) {
798 compiler_globals_ctor(compiler_globals
, tsrm_ls
);
799 compiler_globals
->script_encoding_list
= (const zend_encoding
**)script_encoding_list
;
801 compiler_globals_ctor(compiler_globals
, tsrm_ls
);
803 free(EG(zend_constants
));
804 executor_globals_ctor(executor_globals
, tsrm_ls
);
805 global_persistent_list
= &EG(persistent_list
);
806 zend_copy_ini_directives(TSRMLS_C
);
811 void zend_shutdown(TSRMLS_D
) /* {{{ */
814 zend_signal_shutdown(TSRMLS_C
);
817 zend_shutdown_timeout_thread();
819 zend_destroy_rsrc_list(&EG(persistent_list
) TSRMLS_CC
);
820 zend_destroy_modules();
822 zend_hash_destroy(GLOBAL_FUNCTION_TABLE
);
823 zend_hash_destroy(GLOBAL_CLASS_TABLE
);
825 zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE
);
826 free(GLOBAL_AUTO_GLOBALS_TABLE
);
828 zend_shutdown_extensions(TSRMLS_C
);
829 free(zend_version_info
);
831 free(GLOBAL_FUNCTION_TABLE
);
832 free(GLOBAL_CLASS_TABLE
);
834 zend_hash_destroy(GLOBAL_CONSTANTS_TABLE
);
835 free(GLOBAL_CONSTANTS_TABLE
);
836 zend_shutdown_strtod();
839 GLOBAL_FUNCTION_TABLE
= NULL
;
840 GLOBAL_CLASS_TABLE
= NULL
;
841 GLOBAL_AUTO_GLOBALS_TABLE
= NULL
;
842 GLOBAL_CONSTANTS_TABLE
= NULL
;
844 zend_destroy_rsrc_list_dtors();
846 zend_interned_strings_dtor(TSRMLS_C
);
850 void zend_set_utility_values(zend_utility_values
*utility_values
) /* {{{ */
852 zend_uv
= *utility_values
;
853 zend_uv
.import_use_extension_length
= strlen(zend_uv
.import_use_extension
);
857 /* this should be compatible with the standard zenderror */
858 void zenderror(const char *error
) /* {{{ */
860 zend_error(E_PARSE
, "%s", error
);
865 ZEND_API
void _zend_bailout(char *filename
, uint lineno
) /* {{{ */
870 zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename
, lineno
);
873 CG(unclean_shutdown
) = 1;
874 CG(active_class_entry
) = NULL
;
875 CG(in_compilation
) = EG(in_execution
) = 0;
876 EG(current_execute_data
) = NULL
;
877 LONGJMP(*EG(bailout
), FAILURE
);
882 void zend_append_version_info(const zend_extension
*extension
) /* {{{ */
885 uint new_info_length
;
887 new_info_length
= sizeof(" with v, , by \n")
888 + strlen(extension
->name
)
889 + strlen(extension
->version
)
890 + strlen(extension
->copyright
)
891 + strlen(extension
->author
);
893 new_info
= (char *) malloc(new_info_length
+ 1);
895 snprintf(new_info
, new_info_length
, " with %s v%s, %s, by %s\n", extension
->name
, extension
->version
, extension
->copyright
, extension
->author
);
897 zend_version_info
= (char *) realloc(zend_version_info
, zend_version_info_length
+new_info_length
+ 1);
898 strncat(zend_version_info
, new_info
, new_info_length
);
899 zend_version_info_length
+= new_info_length
;
904 ZEND_API
char *get_zend_version(void) /* {{{ */
906 return zend_version_info
;
910 void zend_activate(TSRMLS_D
) /* {{{ */
913 init_compiler(TSRMLS_C
);
914 init_executor(TSRMLS_C
);
915 startup_scanner(TSRMLS_C
);
919 void zend_call_destructors(TSRMLS_D
) /* {{{ */
922 shutdown_destructors(TSRMLS_C
);
927 void zend_deactivate(TSRMLS_D
) /* {{{ */
929 /* we're no longer executing anything */
930 EG(opline_ptr
) = NULL
;
931 EG(active_symbol_table
) = NULL
;
934 shutdown_scanner(TSRMLS_C
);
937 /* shutdown_executor() takes care of its own bailout handling */
938 shutdown_executor(TSRMLS_C
);
941 shutdown_compiler(TSRMLS_C
);
944 zend_destroy_rsrc_list(&EG(regular_list
) TSRMLS_CC
);
947 if (GC_G(gc_enabled
) && !CG(unclean_shutdown
)) {
948 gc_collect_cycles(TSRMLS_C
);
953 fprintf(stderr
, "GC Statistics\n");
954 fprintf(stderr
, "-------------\n");
955 fprintf(stderr
, "Runs: %d\n", GC_G(gc_runs
));
956 fprintf(stderr
, "Collected: %d\n", GC_G(collected
));
957 fprintf(stderr
, "Root buffer length: %d\n", GC_G(root_buf_length
));
958 fprintf(stderr
, "Root buffer peak: %d\n\n", GC_G(root_buf_peak
));
959 fprintf(stderr
, " Possible Remove from Marked\n");
960 fprintf(stderr
, " Root Buffered buffer grey\n");
961 fprintf(stderr
, " -------- -------- ----------- ------\n");
962 fprintf(stderr
, "ZVAL %8d %8d %9d %8d\n", GC_G(zval_possible_root
), GC_G(zval_buffered
), GC_G(zval_remove_from_buffer
), GC_G(zval_marked_grey
));
963 fprintf(stderr
, "ZOBJ %8d %8d %9d %8d\n", GC_G(zobj_possible_root
), GC_G(zobj_buffered
), GC_G(zobj_remove_from_buffer
), GC_G(zobj_marked_grey
));
967 zend_ini_deactivate(TSRMLS_C
);
973 ZEND_API
void zend_message_dispatcher(long message
, const void *data TSRMLS_DC
) /* {{{ */
975 if (zend_message_dispatcher_p
) {
976 zend_message_dispatcher_p(message
, data TSRMLS_CC
);
982 ZEND_API
int zend_get_configuration_directive(const char *name
, uint name_length
, zval
*contents
) /* {{{ */
984 if (zend_get_configuration_directive_p
) {
985 return zend_get_configuration_directive_p(name
, name_length
, contents
);
992 #define SAVE_STACK(stack) do { \
993 if (CG(stack).top) { \
994 memcpy(&stack, &CG(stack), sizeof(zend_stack)); \
995 CG(stack).top = CG(stack).max = 0; \
996 CG(stack).elements = NULL; \
1002 #define RESTORE_STACK(stack) do { \
1004 zend_stack_destroy(&CG(stack)); \
1005 memcpy(&CG(stack), &stack, sizeof(zend_stack)); \
1009 ZEND_API
void zend_error(int type
, const char *format
, ...) /* {{{ */
1015 zval
*z_error_type
, *z_error_message
, *z_error_filename
, *z_error_lineno
, *z_context
;
1016 const char *error_filename
;
1018 zval
*orig_user_error_handler
;
1019 zend_bool in_compilation
;
1020 zend_class_entry
*saved_class_entry
;
1021 zend_stack bp_stack
;
1022 zend_stack function_call_stack
;
1023 zend_stack switch_cond_stack
;
1024 zend_stack foreach_copy_stack
;
1025 zend_stack object_stack
;
1026 zend_stack declare_stack
;
1027 zend_stack list_stack
;
1028 zend_stack context_stack
;
1031 /* Report about uncaught exception in case of fatal errors */
1032 if (EG(exception
)) {
1036 case E_RECOVERABLE_ERROR
:
1038 case E_COMPILE_ERROR
:
1040 if (zend_is_executing(TSRMLS_C
)) {
1041 error_lineno
= zend_get_executed_lineno(TSRMLS_C
);
1043 zend_exception_error(EG(exception
), E_WARNING TSRMLS_CC
);
1044 EG(exception
) = NULL
;
1045 if (zend_is_executing(TSRMLS_C
) && EG(opline_ptr
)) {
1046 active_opline
->lineno
= error_lineno
;
1054 /* Obtain relevant filename and lineno */
1057 case E_CORE_WARNING
:
1058 error_filename
= NULL
;
1062 case E_COMPILE_ERROR
:
1063 case E_COMPILE_WARNING
:
1070 case E_USER_WARNING
:
1072 case E_USER_DEPRECATED
:
1073 case E_RECOVERABLE_ERROR
:
1074 if (zend_is_compiling(TSRMLS_C
)) {
1075 error_filename
= zend_get_compiled_filename(TSRMLS_C
);
1076 error_lineno
= zend_get_compiled_lineno(TSRMLS_C
);
1077 } else if (zend_is_executing(TSRMLS_C
)) {
1078 error_filename
= zend_get_executed_filename(TSRMLS_C
);
1079 error_lineno
= zend_get_executed_lineno(TSRMLS_C
);
1081 error_filename
= NULL
;
1086 error_filename
= NULL
;
1090 if (!error_filename
) {
1091 error_filename
= "Unknown";
1094 va_start(args
, format
);
1097 if(DTRACE_ERROR_ENABLED()) {
1098 char *dtrace_error_buffer
;
1099 zend_vspprintf(&dtrace_error_buffer
, 0, format
, args
);
1100 DTRACE_ERROR(dtrace_error_buffer
, error_filename
, error_lineno
);
1101 efree(dtrace_error_buffer
);
1103 #endif /* HAVE_DTRACE */
1105 /* if we don't have a user defined error handler */
1106 if (!EG(user_error_handler
)
1107 || !(EG(user_error_handler_error_reporting
) & type
)
1108 || EG(error_handling
) != EH_NORMAL
) {
1109 zend_error_cb(type
, error_filename
, error_lineno
, format
, args
);
1110 } else switch (type
) {
1114 case E_CORE_WARNING
:
1115 case E_COMPILE_ERROR
:
1116 case E_COMPILE_WARNING
:
1117 /* The error may not be safe to handle in user-space */
1118 zend_error_cb(type
, error_filename
, error_lineno
, format
, args
);
1121 /* Handle the error in user space */
1122 ALLOC_INIT_ZVAL(z_error_message
);
1123 ALLOC_INIT_ZVAL(z_error_type
);
1124 ALLOC_INIT_ZVAL(z_error_filename
);
1125 ALLOC_INIT_ZVAL(z_error_lineno
);
1126 ALLOC_INIT_ZVAL(z_context
);
1128 /* va_copy() is __va_copy() in old gcc versions.
1129 * According to the autoconf manual, using
1130 * memcpy(&dst, &src, sizeof(va_list))
1131 * gives maximum portability. */
1134 # define va_copy(dest, src) __va_copy((dest), (src))
1136 # define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
1139 va_copy(usr_copy
, args
);
1140 Z_STRLEN_P(z_error_message
) = zend_vspprintf(&Z_STRVAL_P(z_error_message
), 0, format
, usr_copy
);
1144 Z_TYPE_P(z_error_message
) = IS_STRING
;
1146 Z_LVAL_P(z_error_type
) = type
;
1147 Z_TYPE_P(z_error_type
) = IS_LONG
;
1149 if (error_filename
) {
1150 ZVAL_STRING(z_error_filename
, error_filename
, 1);
1153 Z_LVAL_P(z_error_lineno
) = error_lineno
;
1154 Z_TYPE_P(z_error_lineno
) = IS_LONG
;
1156 if (!EG(active_symbol_table
)) {
1157 zend_rebuild_symbol_table(TSRMLS_C
);
1160 /* during shutdown the symbol table table can be still null */
1161 if (!EG(active_symbol_table
)) {
1162 Z_TYPE_P(z_context
) = IS_NULL
;
1164 Z_ARRVAL_P(z_context
) = EG(active_symbol_table
);
1165 Z_TYPE_P(z_context
) = IS_ARRAY
;
1166 zval_copy_ctor(z_context
);
1169 params
= (zval
***) emalloc(sizeof(zval
**)*5);
1170 params
[0] = &z_error_type
;
1171 params
[1] = &z_error_message
;
1172 params
[2] = &z_error_filename
;
1173 params
[3] = &z_error_lineno
;
1174 params
[4] = &z_context
;
1176 orig_user_error_handler
= EG(user_error_handler
);
1177 EG(user_error_handler
) = NULL
;
1179 /* User error handler may include() additinal PHP files.
1180 * If an error was generated during comilation PHP will compile
1181 * such scripts recursivly, but some CG() variables may be
1184 in_compilation
= zend_is_compiling(TSRMLS_C
);
1185 if (in_compilation
) {
1186 saved_class_entry
= CG(active_class_entry
);
1187 CG(active_class_entry
) = NULL
;
1188 SAVE_STACK(bp_stack
);
1189 SAVE_STACK(function_call_stack
);
1190 SAVE_STACK(switch_cond_stack
);
1191 SAVE_STACK(foreach_copy_stack
);
1192 SAVE_STACK(object_stack
);
1193 SAVE_STACK(declare_stack
);
1194 SAVE_STACK(list_stack
);
1195 SAVE_STACK(context_stack
);
1198 if (call_user_function_ex(CG(function_table
), NULL
, orig_user_error_handler
, &retval
, 5, params
, 1, NULL TSRMLS_CC
) == SUCCESS
) {
1200 if (Z_TYPE_P(retval
) == IS_BOOL
&& Z_LVAL_P(retval
) == 0) {
1201 zend_error_cb(type
, error_filename
, error_lineno
, format
, args
);
1203 zval_ptr_dtor(&retval
);
1205 } else if (!EG(exception
)) {
1206 /* The user error handler failed, use built-in error handler */
1207 zend_error_cb(type
, error_filename
, error_lineno
, format
, args
);
1210 if (in_compilation
) {
1211 CG(active_class_entry
) = saved_class_entry
;
1212 RESTORE_STACK(bp_stack
);
1213 RESTORE_STACK(function_call_stack
);
1214 RESTORE_STACK(switch_cond_stack
);
1215 RESTORE_STACK(foreach_copy_stack
);
1216 RESTORE_STACK(object_stack
);
1217 RESTORE_STACK(declare_stack
);
1218 RESTORE_STACK(list_stack
);
1219 RESTORE_STACK(context_stack
);
1222 if (!EG(user_error_handler
)) {
1223 EG(user_error_handler
) = orig_user_error_handler
;
1226 zval_ptr_dtor(&orig_user_error_handler
);
1230 zval_ptr_dtor(&z_error_message
);
1231 zval_ptr_dtor(&z_error_type
);
1232 zval_ptr_dtor(&z_error_filename
);
1233 zval_ptr_dtor(&z_error_lineno
);
1234 zval_ptr_dtor(&z_context
);
1240 if (type
== E_PARSE
) {
1241 /* eval() errors do not affect exit_status */
1242 if (!(EG(current_execute_data
) &&
1243 EG(current_execute_data
)->opline
&&
1244 EG(current_execute_data
)->opline
->opcode
== ZEND_INCLUDE_OR_EVAL
&&
1245 EG(current_execute_data
)->opline
->extended_value
== ZEND_EVAL
)) {
1246 EG(exit_status
) = 255;
1248 zend_init_compiler_data_structures(TSRMLS_C
);
1253 #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
1254 void zend_error_noreturn(int type
, const char *format
, ...) __attribute__ ((alias("zend_error"),noreturn
));
1257 ZEND_API
void zend_output_debug_string(zend_bool trigger_break
, const char *format
, ...) /* {{{ */
1262 va_start(args
, format
);
1265 char output_buf
[1024];
1267 vsnprintf(output_buf
, 1024, format
, args
);
1268 OutputDebugString(output_buf
);
1269 OutputDebugString("\n");
1270 if (trigger_break
&& IsDebuggerPresent()) {
1275 vfprintf(stderr
, format
, args
);
1276 fprintf(stderr
, "\n");
1283 ZEND_API
int zend_execute_scripts(int type TSRMLS_DC
, zval
**retval
, int file_count
, ...) /* {{{ */
1287 zend_file_handle
*file_handle
;
1288 zend_op_array
*orig_op_array
= EG(active_op_array
);
1289 zval
**orig_retval_ptr_ptr
= EG(return_value_ptr_ptr
);
1290 long orig_interactive
= CG(interactive
);
1292 va_start(files
, file_count
);
1293 for (i
= 0; i
< file_count
; i
++) {
1294 file_handle
= va_arg(files
, zend_file_handle
*);
1299 if (orig_interactive
) {
1300 if (file_handle
->filename
[0] != '-' || file_handle
->filename
[1]) {
1301 CG(interactive
) = 0;
1303 CG(interactive
) = 1;
1307 EG(active_op_array
) = zend_compile_file(file_handle
, type TSRMLS_CC
);
1308 if (file_handle
->opened_path
) {
1310 zend_hash_add(&EG(included_files
), file_handle
->opened_path
, strlen(file_handle
->opened_path
) + 1, (void *)&dummy
, sizeof(int), NULL
);
1312 zend_destroy_file_handle(file_handle TSRMLS_CC
);
1313 if (EG(active_op_array
)) {
1314 EG(return_value_ptr_ptr
) = retval
? retval
: NULL
;
1315 zend_execute(EG(active_op_array
) TSRMLS_CC
);
1316 zend_exception_restore(TSRMLS_C
);
1317 if (EG(exception
)) {
1318 if (EG(user_exception_handler
)) {
1319 zval
*orig_user_exception_handler
;
1320 zval
**params
[1], *retval2
, *old_exception
;
1321 old_exception
= EG(exception
);
1322 EG(exception
) = NULL
;
1323 params
[0] = &old_exception
;
1324 orig_user_exception_handler
= EG(user_exception_handler
);
1325 if (call_user_function_ex(CG(function_table
), NULL
, orig_user_exception_handler
, &retval2
, 1, params
, 1, NULL TSRMLS_CC
) == SUCCESS
) {
1326 if (retval2
!= NULL
) {
1327 zval_ptr_dtor(&retval2
);
1329 if (EG(exception
)) {
1330 zval_ptr_dtor(&EG(exception
));
1331 EG(exception
) = NULL
;
1333 zval_ptr_dtor(&old_exception
);
1335 EG(exception
) = old_exception
;
1336 zend_exception_error(EG(exception
), E_ERROR TSRMLS_CC
);
1339 zend_exception_error(EG(exception
), E_ERROR TSRMLS_CC
);
1342 destroy_op_array(EG(active_op_array
) TSRMLS_CC
);
1343 efree(EG(active_op_array
));
1344 } else if (type
==ZEND_REQUIRE
) {
1346 EG(active_op_array
) = orig_op_array
;
1347 EG(return_value_ptr_ptr
) = orig_retval_ptr_ptr
;
1348 CG(interactive
) = orig_interactive
;
1353 EG(active_op_array
) = orig_op_array
;
1354 EG(return_value_ptr_ptr
) = orig_retval_ptr_ptr
;
1355 CG(interactive
) = orig_interactive
;
1361 #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
1363 ZEND_API
char *zend_make_compiled_string_description(const char *name TSRMLS_DC
) /* {{{ */
1365 const char *cur_filename
;
1367 char *compiled_string_description
;
1369 if (zend_is_compiling(TSRMLS_C
)) {
1370 cur_filename
= zend_get_compiled_filename(TSRMLS_C
);
1371 cur_lineno
= zend_get_compiled_lineno(TSRMLS_C
);
1372 } else if (zend_is_executing(TSRMLS_C
)) {
1373 cur_filename
= zend_get_executed_filename(TSRMLS_C
);
1374 cur_lineno
= zend_get_executed_lineno(TSRMLS_C
);
1376 cur_filename
= "Unknown";
1380 zend_spprintf(&compiled_string_description
, 0, COMPILED_STRING_DESCRIPTION_FORMAT
, cur_filename
, cur_lineno
, name
);
1381 return compiled_string_description
;
1385 void free_estring(char **str_p
) /* {{{ */
1395 * indent-tabs-mode: t