summaryrefslogtreecommitdiff
path: root/Zend/zend.c
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2007-11-02 19:40:39 +0000
committerJani Taskinen <jani@php.net>2007-11-02 19:40:39 +0000
commitb48925117750da2a7fb7cff629e3852d13917f2f (patch)
tree44671e4afbcd83803757998784821a6cc19007b5 /Zend/zend.c
parent0d7479891444f46d1c30cf875037e5099f8f782b (diff)
downloadphp-git-b48925117750da2a7fb7cff629e3852d13917f2f.tar.gz
- MFH from HEAD:
. Folding tags . Parameter parsing . SPL debug info . array function improvements (not all yet) . Improvements to function calling with call_user_* functions . Improvements to debugging info in var_dump/print_r # I propably forgot already something but this all was pretty close tied # to each other so it wasn't possible to do it in parts.
Diffstat (limited to 'Zend/zend.c')
-rw-r--r--Zend/zend.c473
1 files changed, 238 insertions, 235 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index e7767ceadf..30895c5a1a 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -30,15 +30,15 @@
#include "zend_ini.h"
#ifdef ZTS
-# define GLOBAL_FUNCTION_TABLE global_function_table
-# define GLOBAL_CLASS_TABLE global_class_table
-# define GLOBAL_CONSTANTS_TABLE global_constants_table
-# define GLOBAL_AUTO_GLOBALS_TABLE global_auto_globals_table
+# define GLOBAL_FUNCTION_TABLE global_function_table
+# define GLOBAL_CLASS_TABLE global_class_table
+# define GLOBAL_CONSTANTS_TABLE global_constants_table
+# define GLOBAL_AUTO_GLOBALS_TABLE global_auto_globals_table
#else
-# define GLOBAL_FUNCTION_TABLE CG(function_table)
-# define GLOBAL_CLASS_TABLE CG(class_table)
-# define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals)
-# define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
+# define GLOBAL_FUNCTION_TABLE CG(function_table)
+# define GLOBAL_CLASS_TABLE CG(class_table)
+# define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals)
+# define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
#endif
#if defined(ZEND_WIN32) && ZEND_DEBUG
@@ -63,8 +63,7 @@ void (*zend_on_timeout)(int seconds TSRMLS_DC);
static void (*zend_message_dispatcher_p)(long message, void *data);
static int (*zend_get_configuration_directive_p)(char *name, uint name_length, zval *contents);
-
-static ZEND_INI_MH(OnUpdateErrorReporting)
+static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
{
if (!new_value) {
EG(error_reporting) = E_ALL & ~E_NOTICE & ~E_STRICT;
@@ -73,7 +72,7 @@ static ZEND_INI_MH(OnUpdateErrorReporting)
}
return SUCCESS;
}
-
+/* }}} */
ZEND_INI_BEGIN()
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
@@ -87,10 +86,10 @@ ZEND_INI_END()
#ifdef ZTS
ZEND_API int compiler_globals_id;
ZEND_API int executor_globals_id;
-HashTable *global_function_table;
-HashTable *global_class_table;
-HashTable *global_constants_table;
-HashTable *global_auto_globals_table;
+static HashTable *global_function_table = NULL;
+static HashTable *global_class_table = NULL;
+static HashTable *global_constants_table = NULL;
+static HashTable *global_auto_globals_table = NULL;
static HashTable *global_persistent_list = NULL;
#endif
@@ -102,11 +101,9 @@ ZEND_API zval zval_used_for_init; /* True global variable */
static char *zend_version_info;
static uint zend_version_info_length;
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2007 Zend Technologies\n"
-
-
#define PRINT_ZVAL_INDENT 4
-static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent, zend_bool is_object TSRMLS_DC)
+static void print_hash(HashTable *ht, int indent, zend_bool is_object TSRMLS_DC) /* {{{ */
{
zval **tmp;
char *string_key;
@@ -115,116 +112,116 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
uint str_len;
int i;
- for (i=0; i<indent; i++) {
- ZEND_PUTS_EX(" ");
+ for (i = 0; i < indent; i++) {
+ ZEND_PUTS(" ");
}
- ZEND_PUTS_EX("(\n");
+ ZEND_PUTS("(\n");
indent += PRINT_ZVAL_INDENT;
zend_hash_internal_pointer_reset_ex(ht, &iterator);
while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == SUCCESS) {
- for (i=0; i<indent; i++) {
- ZEND_PUTS_EX(" ");
+ for (i = 0; i < indent; i++) {
+ ZEND_PUTS(" ");
}
- ZEND_PUTS_EX("[");
+ ZEND_PUTS("[");
switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
case HASH_KEY_IS_STRING:
if (is_object) {
char *prop_name, *class_name;
+ int mangled = zend_unmangle_property_name(string_key, str_len - 1, &class_name, &prop_name);
- int mangled = zend_unmangle_property_name(string_key, str_len-1, &class_name, &prop_name);
- ZEND_PUTS_EX(prop_name);
if (class_name && mangled == SUCCESS) {
if (class_name[0]=='*') {
- ZEND_PUTS_EX(":protected");
+ zend_printf("%s:protected", prop_name);
} else {
- ZEND_PUTS_EX(":private");
+ zend_printf("%s:%s:private", prop_name, class_name);
}
+ } else {
+ zend_printf("%s", prop_name);
}
} else {
- ZEND_WRITE_EX(string_key, str_len-1);
+ zend_printf("%s", string_key);
}
break;
case HASH_KEY_IS_LONG:
- {
- char key[25];
- snprintf(key, sizeof(key), "%ld", num_key);
- ZEND_PUTS_EX(key);
- }
+ zend_printf("%ld", num_key);
break;
}
- ZEND_PUTS_EX("] => ");
- zend_print_zval_r_ex(write_func, *tmp, indent+PRINT_ZVAL_INDENT TSRMLS_CC);
- ZEND_PUTS_EX("\n");
+ ZEND_PUTS("] => ");
+ zend_print_zval_r(*tmp, indent+PRINT_ZVAL_INDENT TSRMLS_CC);
+ ZEND_PUTS("\n");
zend_hash_move_forward_ex(ht, &iterator);
}
indent -= PRINT_ZVAL_INDENT;
- for (i=0; i<indent; i++) {
- ZEND_PUTS_EX(" ");
+ for (i = 0; i < indent; i++) {
+ ZEND_PUTS(" ");
}
- ZEND_PUTS_EX(")\n");
+ ZEND_PUTS(")\n");
}
+/* }}} */
-static void print_flat_hash(HashTable *ht TSRMLS_DC)
+static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
{
- zval **tmp;
- char *string_key;
- HashPosition iterator;
- ulong num_key;
- uint str_len;
- int i = 0;
-
- zend_hash_internal_pointer_reset_ex(ht, &iterator);
- while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == SUCCESS) {
- if (i++ > 0) {
- ZEND_PUTS(",");
- }
- ZEND_PUTS("[");
- switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
- case HASH_KEY_IS_STRING:
- ZEND_PUTS(string_key);
- break;
- case HASH_KEY_IS_LONG:
- zend_printf("%ld", num_key);
- break;
+ zval **tmp;
+ char *string_key;
+ HashPosition iterator;
+ ulong num_key;
+ uint str_len;
+ int i = 0;
+
+ zend_hash_internal_pointer_reset_ex(ht, &iterator);
+ while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == SUCCESS) {
+ if (i++ > 0) {
+ ZEND_PUTS(",");
+ }
+ ZEND_PUTS("[");
+ switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
+ case HASH_KEY_IS_STRING:
+ ZEND_PUTS(string_key);
+ break;
+ case HASH_KEY_IS_LONG:
+ zend_printf("%ld", num_key);
+ break;
+ }
+ ZEND_PUTS("] => ");
+ zend_print_flat_zval_r(*tmp TSRMLS_CC);
+ zend_hash_move_forward_ex(ht, &iterator);
}
- ZEND_PUTS("] => ");
- zend_print_flat_zval_r(*tmp TSRMLS_CC);
- zend_hash_move_forward_ex(ht, &iterator);
- }
}
+/* }}} */
-ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy)
+ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy) /* {{{ */
{
- if (expr->type==IS_STRING) {
+ if (Z_TYPE_P(expr)==IS_STRING) {
*use_copy = 0;
return;
}
- switch (expr->type) {
+ switch (Z_TYPE_P(expr)) {
case IS_NULL:
- expr_copy->value.str.len = 0;
- expr_copy->value.str.val = STR_EMPTY_ALLOC();
+ Z_STRLEN_P(expr_copy) = 0;
+ Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
break;
case IS_BOOL:
- if (expr->value.lval) {
- expr_copy->value.str.len = 1;
- expr_copy->value.str.val = estrndup("1", 1);
+ if (Z_LVAL_P(expr)) {
+ Z_STRLEN_P(expr_copy) = 1;
+ Z_STRVAL_P(expr_copy) = estrndup("1", 1);
} else {
- expr_copy->value.str.len = 0;
- expr_copy->value.str.val = STR_EMPTY_ALLOC();
+ Z_STRLEN_P(expr_copy) = 0;
+ Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
}
break;
case IS_RESOURCE:
- expr_copy->value.str.len = zend_spprintf(&expr_copy->value.str.val, 0, "Resource id #%ld", expr->value.lval);
+ Z_STRVAL_P(expr_copy) = (char *) emalloc(sizeof("Resource id #") - 1 + MAX_LENGTH_OF_LONG);
+ Z_STRLEN_P(expr_copy) = sprintf(Z_STRVAL_P(expr_copy), "Resource id #%ld", Z_LVAL_P(expr));
break;
case IS_ARRAY:
- expr_copy->value.str.len = sizeof("Array")-1;
- expr_copy->value.str.val = estrndup("Array", expr_copy->value.str.len);
+ Z_STRLEN_P(expr_copy) = sizeof("Array") - 1;
+ Z_STRVAL_P(expr_copy) = estrndup("Array", Z_STRLEN_P(expr_copy));
break;
case IS_OBJECT:
{
TSRMLS_FETCH();
- if(Z_OBJ_HANDLER_P(expr, cast_object) && Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
+ if (Z_OBJ_HANDLER_P(expr, cast_object) && Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) {
break;
}
/* Standard PHP objects */
@@ -237,7 +234,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC);
Z_ADDREF_P(z);
- if(Z_TYPE_P(z) != IS_OBJECT) {
+ if (Z_TYPE_P(z) != IS_OBJECT) {
zend_make_printable_zval(z, expr_copy, use_copy);
if (*use_copy) {
zval_ptr_dtor(&z);
@@ -250,8 +247,8 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
zval_ptr_dtor(&z);
}
zend_error(EG(exception) ? E_ERROR : E_RECOVERABLE_ERROR, "Object of class %s could not be converted to string", Z_OBJCE_P(expr)->name);
- expr_copy->value.str.len = 0;
- expr_copy->value.str.val = STR_EMPTY_ALLOC();
+ Z_STRLEN_P(expr_copy) = 0;
+ Z_STRVAL_P(expr_copy) = STR_EMPTY_ALLOC();
}
break;
case IS_DOUBLE:
@@ -265,18 +262,18 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
convert_to_string(expr_copy);
break;
}
- expr_copy->type = IS_STRING;
+ Z_TYPE_P(expr_copy) = IS_STRING;
*use_copy = 1;
}
+/* }}} */
-
-ZEND_API int zend_print_zval(zval *expr, int indent)
+ZEND_API int zend_print_zval(zval *expr, int indent) /* {{{ */
{
return zend_print_zval_ex(zend_write, expr, indent);
}
+/* }}} */
-
-ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent)
+ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
{
zval expr_copy;
int use_copy;
@@ -285,35 +282,36 @@ ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int in
if (use_copy) {
expr = &expr_copy;
}
- if (expr->value.str.len==0) { /* optimize away empty strings */
+ if (Z_STRLEN_P(expr) == 0) { /* optimize away empty strings */
if (use_copy) {
zval_dtor(expr);
}
return 0;
}
- write_func(expr->value.str.val, expr->value.str.len);
+ write_func(Z_STRVAL_P(expr), Z_STRLEN_P(expr));
if (use_copy) {
zval_dtor(expr);
}
- return expr->value.str.len;
+ return Z_STRLEN_P(expr);
}
+/* }}} */
-ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC)
+ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
{
- switch (expr->type) {
- case IS_ARRAY:
- ZEND_PUTS("Array (");
- if (++expr->value.ht->nApplyCount>1) {
- ZEND_PUTS(" *RECURSION*");
- expr->value.ht->nApplyCount--;
- return;
- }
- print_flat_hash(expr->value.ht TSRMLS_CC);
- ZEND_PUTS(")");
- expr->value.ht->nApplyCount--;
- break;
- case IS_OBJECT:
- {
+ switch (Z_TYPE_P(expr)) {
+ case IS_ARRAY:
+ ZEND_PUTS("Array (");
+ if (++Z_ARRVAL_P(expr)->nApplyCount>1) {
+ ZEND_PUTS(" *RECURSION*");
+ Z_ARRVAL_P(expr)->nApplyCount--;
+ return;
+ }
+ print_flat_hash(Z_ARRVAL_P(expr) TSRMLS_CC);
+ ZEND_PUTS(")");
+ Z_ARRVAL_P(expr)->nApplyCount--;
+ break;
+ case IS_OBJECT:
+ {
HashTable *properties = NULL;
char *class_name = NULL;
zend_uint clen;
@@ -321,7 +319,11 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC)
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
- zend_printf("%s Object (", class_name?class_name:"Unknown Class");
+ if (class_name) {
+ zend_printf("%s Object (", class_name);
+ } else {
+ zend_printf("%s Object (", "Unknown Class");
+ }
if (class_name) {
efree(class_name);
}
@@ -339,31 +341,32 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC)
}
ZEND_PUTS(")");
break;
- }
- default:
- zend_print_variable(expr);
- break;
- }
+ }
+ default:
+ zend_print_variable(expr);
+ break;
+ }
}
+/* }}} */
-ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC)
+ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC) /* {{{ */
{
zend_print_zval_r_ex(zend_write, expr, indent TSRMLS_CC);
}
+/* }}} */
-
-ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC)
+ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */
{
- switch (expr->type) {
+ switch (Z_TYPE_P(expr)) {
case IS_ARRAY:
- ZEND_PUTS_EX("Array\n");
- if (++expr->value.ht->nApplyCount>1) {
- ZEND_PUTS_EX(" *RECURSION*");
- expr->value.ht->nApplyCount--;
+ ZEND_PUTS("Array\n");
+ if (++Z_ARRVAL_P(expr)->nApplyCount>1) {
+ ZEND_PUTS(" *RECURSION*");
+ Z_ARRVAL_P(expr)->nApplyCount--;
return;
}
- print_hash(write_func, expr->value.ht, indent, 0 TSRMLS_CC);
- expr->value.ht->nApplyCount--;
+ print_hash(Z_ARRVAL_P(expr), indent, 0 TSRMLS_CC);
+ Z_ARRVAL_P(expr)->nApplyCount--;
break;
case IS_OBJECT:
{
@@ -376,11 +379,10 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
if (class_name) {
- ZEND_PUTS_EX(class_name);
+ zend_printf("%s Object\n", class_name);
} else {
- ZEND_PUTS_EX("Unknown Class");
+ zend_printf("%s Object\n", "Unknown class");
}
- ZEND_PUTS_EX(" Object\n");
if (class_name) {
efree(class_name);
}
@@ -388,11 +390,11 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
break;
}
if (++properties->nApplyCount>1) {
- ZEND_PUTS_EX(" *RECURSION*");
+ ZEND_PUTS(" *RECURSION*");
properties->nApplyCount--;
return;
}
- print_hash(write_func, properties, indent, 1 TSRMLS_CC);
+ print_hash(properties, indent, 1 TSRMLS_CC);
properties->nApplyCount--;
if (is_temp) {
zend_hash_destroy(properties);
@@ -401,22 +403,22 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
break;
}
default:
- zend_print_zval_ex(write_func, expr, indent);
+ zend_print_variable(expr);
break;
}
}
+/* }}} */
-
-static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
+static FILE *zend_fopen_wrapper(const char *filename, char **opened_path) /* {{{ */
{
if (opened_path) {
*opened_path = estrdup(filename);
}
return fopen(filename, "rb");
}
+/* }}} */
-
-static void register_standard_class(TSRMLS_D)
+static void register_standard_class(TSRMLS_D) /* {{{ */
{
zend_standard_class_def = calloc(1, sizeof(zend_class_entry));
@@ -427,20 +429,21 @@ static void register_standard_class(TSRMLS_D)
zend_hash_add(CG(class_table), "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry *), NULL);
}
+/* }}} */
#ifdef ZTS
-static zend_bool asp_tags_default = 0;
-static zend_bool short_tags_default = 1;
-static zend_bool ct_pass_ref_default = 1;
-static zend_bool extended_info_default = 0;
+static zend_bool asp_tags_default = 0;
+static zend_bool short_tags_default = 1;
+static zend_bool ct_pass_ref_default = 1;
+static zend_bool extended_info_default = 0;
#else
-# define asp_tags_default 0
-# define short_tags_default 1
-# define ct_pass_ref_default 1
-# define extended_info_default 0
+# define asp_tags_default 0
+# define short_tags_default 1
+# define ct_pass_ref_default 1
+# define extended_info_default 0
#endif
-static void zend_set_default_compile_time_values(TSRMLS_D)
+static void zend_set_default_compile_time_values(TSRMLS_D) /* {{{ */
{
/* default compile-time values */
CG(asp_tags) = asp_tags_default;
@@ -448,10 +451,10 @@ static void zend_set_default_compile_time_values(TSRMLS_D)
CG(allow_call_time_pass_reference) = ct_pass_ref_default;
CG(extended_info) = extended_info_default;
}
-
+/* }}} */
#ifdef ZTS
-static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC)
+static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */
{
zend_function tmp_func;
zend_class_entry *tmp_class;
@@ -459,12 +462,12 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
compiler_globals->compiled_filename = NULL;
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
- zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
+ zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
+ zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
- compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
- zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry *));
+ compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
+ zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
+ zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry *));
zend_set_default_compile_time_values(TSRMLS_C);
@@ -481,9 +484,9 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS
compiler_globals->static_members = NULL;
}
}
+/* }}} */
-
-static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS_DC)
+static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */
{
if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) {
zend_hash_destroy(compiler_globals->function_table);
@@ -502,14 +505,14 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS
}
compiler_globals->last_static_member = 0;
}
+/* }}} */
-
-static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC)
+static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC) /* {{{ */
{
zend_startup_constants(TSRMLS_C);
zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
zend_init_rsrc_plist(TSRMLS_C);
- EG(lambda_count)=0;
+ EG(lambda_count) = 0;
EG(user_error_handler) = NULL;
EG(user_exception_handler) = NULL;
EG(in_execution) = 0;
@@ -519,9 +522,9 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
EG(exit_status) = 0;
EG(active) = 0;
}
+/* }}} */
-
-static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC)
+static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC) /* {{{ */
{
zend_ini_shutdown(TSRMLS_C);
if (&executor_globals->persistent_list != global_persistent_list) {
@@ -532,14 +535,15 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS
free(executor_globals->zend_constants);
}
}
+/* }}} */
-
-static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
+static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC) /* {{{ */
{
if (zend_copy_ini_directives(TSRMLS_C) == SUCCESS) {
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
}
}
+/* }}} */
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
@@ -547,8 +551,7 @@ static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
#include <floatingpoint.h>
#endif
-
-static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_DC)
+static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_DC) /* {{{ */
{
scanner_globals_p->c_buf_p = (char *) 0;
scanner_globals_p->init = 1;
@@ -562,10 +565,11 @@ static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_
scanner_globals_p->yy_start_stack_depth = 0;
scanner_globals_p->yy_start_stack = 0;
}
+/* }}} */
void zend_init_opcodes_handlers(void);
-int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions)
+int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions) /* {{{ */
{
#ifdef ZTS
zend_compiler_globals *compiler_globals;
@@ -616,29 +620,27 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
/* set up version */
zend_version_info = strdup(ZEND_CORE_VERSION_INFO);
- zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO)-1;
+ zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO) - 1;
+
+ GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
+ GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
+ GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
+ GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));
- GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
- GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
- GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
-#ifdef ZTS
- GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));
-#endif
zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
zend_hash_init_ex(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
+ zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, (dtor_func_t) zend_auto_global_dtor, 1, 0);
+ zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 20, NULL, ZEND_CONSTANT_DTOR, 1, 0);
zend_hash_init_ex(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1, 0);
zend_init_rsrc_list_dtors();
-
/* This zval can be used to initialize allocate zval's to an uninit'ed value */
Z_UNSET_ISREF(zval_used_for_init);
Z_SET_REFCOUNT(zval_used_for_init, 1);
- zval_used_for_init.type = IS_NULL;
+ Z_TYPE(zval_used_for_init) = IS_NULL;
#ifdef ZTS
- zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 20, NULL, ZEND_CONSTANT_DTOR, 1, 0);
- zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, (dtor_func_t) zend_auto_global_dtor, 1, 0);
ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
ts_allocate_id(&language_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
@@ -659,17 +661,15 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_hash_destroy(executor_globals->zend_constants);
*executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE;
#else
- zend_hash_init_ex(CG(auto_globals), 8, NULL, (dtor_func_t) zend_auto_global_dtor, 1, 0);
scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
- zend_startup_constants();
zend_set_default_compile_time_values(TSRMLS_C);
EG(user_error_handler) = NULL;
EG(user_exception_handler) = NULL;
#endif
register_standard_class(TSRMLS_C);
zend_register_standard_constants(TSRMLS_C);
- zend_register_auto_global("GLOBALS", sizeof("GLOBALS")-1, NULL TSRMLS_CC);
+ zend_register_auto_global("GLOBALS", sizeof("GLOBALS") - 1, NULL TSRMLS_CC);
#ifndef ZTS
zend_init_rsrc_plist(TSRMLS_C);
@@ -687,22 +687,22 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
return SUCCESS;
}
+/* }}} */
-
-void zend_register_standard_ini_entries(TSRMLS_D)
+void zend_register_standard_ini_entries(TSRMLS_D) /* {{{ */
{
int module_number = 0;
REGISTER_INI_ENTRIES();
}
+/* }}} */
-
-#ifdef ZTS
/* Unlink the global (r/o) copies of the class, function and constant tables,
* and use a fresh r/w copy for the startup thread
*/
-void zend_post_startup(TSRMLS_D)
+void zend_post_startup(TSRMLS_D) /* {{{ */
{
+#ifdef ZTS
zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id);
zend_executor_globals *executor_globals = ts_resource(executor_globals_id);
@@ -723,11 +723,11 @@ void zend_post_startup(TSRMLS_D)
executor_globals_ctor(executor_globals, tsrm_ls);
global_persistent_list = &EG(persistent_list);
zend_copy_ini_directives(TSRMLS_C);
-}
#endif
+}
+/* }}} */
-
-void zend_shutdown(TSRMLS_D)
+void zend_shutdown(TSRMLS_D) /* {{{ */
{
#ifdef ZEND_WIN32
zend_shutdown_timeout_thread();
@@ -749,8 +749,8 @@ void zend_shutdown(TSRMLS_D)
zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
free(GLOBAL_CONSTANTS_TABLE);
-
zend_shutdown_strtod();
+
#ifdef ZTS
GLOBAL_FUNCTION_TABLE = NULL;
GLOBAL_CLASS_TABLE = NULL;
@@ -759,24 +759,24 @@ void zend_shutdown(TSRMLS_D)
#endif
zend_destroy_rsrc_list_dtors();
}
+/* }}} */
-
-void zend_set_utility_values(zend_utility_values *utility_values)
+void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
{
zend_uv = *utility_values;
zend_uv.import_use_extension_length = strlen(zend_uv.import_use_extension);
}
-
+/* }}} */
/* this should be compatible with the standard zenderror */
-void zenderror(char *error)
+void zenderror(char *error) /* {{{ */
{
zend_error(E_PARSE, "%s", error);
}
-
+/* }}} */
BEGIN_EXTERN_C()
-ZEND_API void _zend_bailout(char *filename, uint lineno)
+ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
{
TSRMLS_FETCH();
@@ -789,10 +789,10 @@ ZEND_API void _zend_bailout(char *filename, uint lineno)
EG(current_execute_data) = NULL;
longjmp(*EG(bailout), FAILURE);
}
+/* }}} */
END_EXTERN_C()
-
-void zend_append_version_info(zend_extension *extension)
+void zend_append_version_info(zend_extension *extension) /* {{{ */
{
char *new_info;
uint new_info_length;
@@ -803,37 +803,38 @@ void zend_append_version_info(zend_extension *extension)
+ strlen(extension->copyright)
+ strlen(extension->author);
- new_info = (char *) malloc(new_info_length+1);
+ new_info = (char *) malloc(new_info_length + 1);
sprintf(new_info, " with %s v%s, %s, by %s\n", extension->name, extension->version, extension->copyright, extension->author);
- zend_version_info = (char *) realloc(zend_version_info, zend_version_info_length+new_info_length+1);
+ zend_version_info = (char *) realloc(zend_version_info, zend_version_info_length+new_info_length + 1);
strcat(zend_version_info, new_info);
zend_version_info_length += new_info_length;
free(new_info);
}
+/* }}} */
-
-ZEND_API char *get_zend_version(void)
+ZEND_API char *get_zend_version(void) /* {{{ */
{
return zend_version_info;
}
+/* }}} */
-
-void zend_activate(TSRMLS_D)
+void zend_activate(TSRMLS_D) /* {{{ */
{
init_compiler(TSRMLS_C);
init_executor(TSRMLS_C);
startup_scanner(TSRMLS_C);
}
+/* }}} */
-
-void zend_activate_modules(TSRMLS_D)
+void zend_activate_modules(TSRMLS_D) /* {{{ */
{
zend_hash_apply(&module_registry, (apply_func_t) module_registry_request_startup TSRMLS_CC);
}
+/* }}} */
-void zend_deactivate_modules(TSRMLS_D)
+void zend_deactivate_modules(TSRMLS_D) /* {{{ */
{
EG(opline_ptr) = NULL; /* we're no longer executing anything */
@@ -841,15 +842,17 @@ void zend_deactivate_modules(TSRMLS_D)
zend_hash_apply(&module_registry, (apply_func_t) module_registry_cleanup TSRMLS_CC);
} zend_end_try();
}
+/* }}} */
-void zend_call_destructors(TSRMLS_D)
+void zend_call_destructors(TSRMLS_D) /* {{{ */
{
zend_try {
shutdown_destructors(TSRMLS_C);
} zend_end_try();
}
+/* }}} */
-void zend_deactivate(TSRMLS_D)
+void zend_deactivate(TSRMLS_D) /* {{{ */
{
/* we're no longer executing anything */
EG(opline_ptr) = NULL;
@@ -872,35 +875,35 @@ void zend_deactivate(TSRMLS_D)
zend_ini_deactivate(TSRMLS_C);
} zend_end_try();
}
+/* }}} */
-
-static int exec_done_cb(zend_module_entry *module TSRMLS_DC)
+static int exec_done_cb(zend_module_entry *module TSRMLS_DC) /* {{{ */
{
if (module->post_deactivate_func) {
module->post_deactivate_func();
}
return 0;
}
+/* }}} */
-
-void zend_post_deactivate_modules(TSRMLS_D)
+void zend_post_deactivate_modules(TSRMLS_D) /* {{{ */
{
zend_hash_apply(&module_registry, (apply_func_t) exec_done_cb TSRMLS_CC);
zend_hash_reverse_apply(&module_registry, (apply_func_t) module_registry_unload_temp TSRMLS_CC);
}
-
+/* }}} */
BEGIN_EXTERN_C()
-ZEND_API void zend_message_dispatcher(long message, void *data)
+ZEND_API void zend_message_dispatcher(long message, void *data) /* {{{ */
{
if (zend_message_dispatcher_p) {
zend_message_dispatcher_p(message, data);
}
}
+/* }}} */
END_EXTERN_C()
-
-ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents)
+ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents) /* {{{ */
{
if (zend_get_configuration_directive_p) {
return zend_get_configuration_directive_p(name, name_length, contents);
@@ -908,9 +911,9 @@ ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval
return FAILURE;
}
}
+/* }}} */
-
-ZEND_API void zend_error(int type, const char *format, ...)
+ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
{
va_list args;
va_list usr_copy;
@@ -998,26 +1001,24 @@ ZEND_API void zend_error(int type, const char *format, ...)
# endif
#endif
va_copy(usr_copy, args);
- z_error_message->value.str.len = zend_vspprintf(&z_error_message->value.str.val, 0, format, usr_copy);
+ Z_STRLEN_P(z_error_message) = zend_vspprintf(&Z_STRVAL_P(z_error_message), 0, format, usr_copy);
#ifdef va_copy
va_end(usr_copy);
#endif
- z_error_message->type = IS_STRING;
+ Z_TYPE_P(z_error_message) = IS_STRING;
- z_error_type->value.lval = type;
- z_error_type->type = IS_LONG;
+ Z_LVAL_P(z_error_type) = type;
+ Z_TYPE_P(z_error_type) = IS_LONG;
if (error_filename) {
- z_error_filename->value.str.len = strlen(error_filename);
- z_error_filename->value.str.val = estrndup(error_filename, z_error_filename->value.str.len);
- z_error_filename->type = IS_STRING;
+ ZVAL_STRING(z_error_filename, error_filename, 1);
}
- z_error_lineno->value.lval = error_lineno;
- z_error_lineno->type = IS_LONG;
+ Z_LVAL_P(z_error_lineno) = error_lineno;
+ Z_TYPE_P(z_error_lineno) = IS_LONG;
- z_context->value.ht = EG(active_symbol_table);
- z_context->type = IS_ARRAY;
+ Z_ARRVAL_P(z_context) = EG(active_symbol_table);
+ Z_TYPE_P(z_context) = IS_ARRAY;
zval_copy_ctor(z_context);
params = (zval ***) emalloc(sizeof(zval **)*5);
@@ -1041,7 +1042,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
CG(active_class_entry) = NULL;
}
- if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC)==SUCCESS) {
+ if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC) == SUCCESS) {
if (retval) {
if (Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) {
zend_error_cb(type, error_filename, error_lineno, format, args);
@@ -1080,12 +1081,13 @@ ZEND_API void zend_error(int type, const char *format, ...)
zend_init_compiler_data_structures(TSRMLS_C);
}
}
+/* }}} */
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
#endif
-ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...)
+ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...) /* {{{ */
{
#if ZEND_DEBUG
va_list args;
@@ -1109,27 +1111,27 @@ ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ..
va_end(args);
#endif
}
+/* }}} */
-
-ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_count, ...)
+ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_count, ...) /* {{{ */
{
va_list files;
int i;
zend_file_handle *file_handle;
zend_op_array *orig_op_array = EG(active_op_array);
zval **orig_retval_ptr_ptr = EG(return_value_ptr_ptr);
- zval *local_retval=NULL;
+ zval *local_retval = NULL;
va_start(files, file_count);
- for (i=0; i<file_count; i++) {
+ for (i = 0; i < file_count; i++) {
file_handle = va_arg(files, zend_file_handle *);
if (!file_handle) {
continue;
}
EG(active_op_array) = zend_compile_file(file_handle, type TSRMLS_CC);
- if(file_handle->opened_path) {
- int dummy=1;
- zend_hash_add(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path)+1, (void *)&dummy, sizeof(int), NULL);
+ if (file_handle->opened_path) {
+ int dummy = 1;
+ zend_hash_add(&EG(included_files), file_handle->opened_path, strlen(file_handle->opened_path) + 1, (void *)&dummy, sizeof(int), NULL);
}
zend_destroy_file_handle(file_handle TSRMLS_CC);
if (EG(active_op_array)) {
@@ -1186,10 +1188,11 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
return SUCCESS;
}
+/* }}} */
#define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
-ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC)
+ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC) /* {{{ */
{
char *cur_filename;
int cur_lineno;
@@ -1209,13 +1212,13 @@ ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC)
zend_spprintf(&compiled_string_description, 0, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name);
return compiled_string_description;
}
+/* }}} */
-
-void free_estring(char **str_p)
+void free_estring(char **str_p) /* {{{ */
{
efree(*str_p);
}
-
+/* }}} */
/*
* Local variables: