From ba0b2ad46684631029c47631f063d2455bc254a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Sat, 23 Nov 2013 14:30:10 -0300 Subject: [PATCH] fix whitespace in phpdbg.c --- phpdbg.c | 550 +++++++++++++++++++++++++++---------------------------- 1 file changed, 275 insertions(+), 275 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index e5aee66d7e..eefdb3b79e 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -36,38 +36,38 @@ void (*zend_execute_old)(zend_op_array *op_array TSRMLS_DC); static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ { - pg->exec = NULL; - pg->exec_len = 0; - pg->ops = NULL; - pg->vmret = 0; - pg->bp_count = 0; - pg->lcmd = NULL; - pg->flags = PHPDBG_DEFAULT_FLAGS; - pg->oplog = NULL; - pg->io[PHPDBG_STDIN] = NULL; - pg->io[PHPDBG_STDOUT] = NULL; - pg->io[PHPDBG_STDERR] = NULL; - memset(&pg->lparam, 0, sizeof(phpdbg_param_t)); - pg->frame.num = 0; + pg->exec = NULL; + pg->exec_len = 0; + pg->ops = NULL; + pg->vmret = 0; + pg->bp_count = 0; + pg->lcmd = NULL; + pg->flags = PHPDBG_DEFAULT_FLAGS; + pg->oplog = NULL; + pg->io[PHPDBG_STDIN] = NULL; + pg->io[PHPDBG_STDOUT] = NULL; + pg->io[PHPDBG_STDERR] = NULL; + memset(&pg->lparam, 0, sizeof(phpdbg_param_t)); + pg->frame.num = 0; } /* }}} */ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ { - ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL); + ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL); #if PHP_VERSION_ID >= 50500 - zend_execute_old = zend_execute_ex; - zend_execute_ex = phpdbg_execute_ex; + zend_execute_old = zend_execute_ex; + zend_execute_ex = phpdbg_execute_ex; #else - zend_execute_old = zend_execute; - zend_execute = phpdbg_execute_ex; + zend_execute_old = zend_execute; + zend_execute = phpdbg_execute_ex; #endif - REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); - return SUCCESS; + return SUCCESS; } /* }}} */ static void php_phpdbg_destroy_bp_file(void *brake) /* {{{ */ @@ -82,23 +82,23 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */ static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */ { - zend_hash_destroy((HashTable*)brake); + zend_hash_destroy((HashTable*)brake); } /* }}} */ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */ { - phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*) data; - - if (brake) { - if (brake->ops) { - TSRMLS_FETCH(); - - destroy_op_array( - brake->ops TSRMLS_CC); - efree(brake->ops); - } - zval_dtor(&brake->code); - } + phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*) data; + + if (brake) { + if (brake->ops) { + TSRMLS_FETCH(); + + destroy_op_array( + brake->ops TSRMLS_CC); + efree(brake->ops); + } + zval_dtor(&brake->code); + } } /* }}} */ static void php_phpdbg_destroy_registered(void *data) @@ -115,9 +115,9 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0); @@ -126,104 +126,104 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ { - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); zend_hash_destroy(&PHPDBG_G(seek)); zend_hash_destroy(&PHPDBG_G(registered)); - if (PHPDBG_G(exec)) { - efree(PHPDBG_G(exec)); - PHPDBG_G(exec) = NULL; - } + if (PHPDBG_G(exec)) { + efree(PHPDBG_G(exec)); + PHPDBG_G(exec) = NULL; + } - if (PHPDBG_G(oplog)) { - fclose( - PHPDBG_G(oplog)); - PHPDBG_G(oplog) = NULL; - } + if (PHPDBG_G(oplog)) { + fclose( + PHPDBG_G(oplog)); + PHPDBG_G(oplog) = NULL; + } - if (PHPDBG_G(ops)) { - destroy_op_array(PHPDBG_G(ops) TSRMLS_CC); - efree(PHPDBG_G(ops)); - PHPDBG_G(ops) = NULL; - } + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops) TSRMLS_CC); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } - return SUCCESS; + return SUCCESS; } /* }}} */ /* {{{ proto void phpdbg_break([integer type, string expression]) instructs phpdbg to insert a breakpoint at the next opcode */ static PHP_FUNCTION(phpdbg_break) { - if (ZEND_NUM_ARGS() > 0) { - long type; - char *expr = NULL; - zend_uint expr_len = 0; - phpdbg_param_t param; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { - return; - } + if (ZEND_NUM_ARGS() > 0) { + long type; + char *expr = NULL; + zend_uint expr_len = 0; + phpdbg_param_t param; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) { + return; + } - phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); + phpdbg_parse_param(expr, expr_len, ¶m TSRMLS_CC); - switch (type) { - case METHOD_PARAM: - phpdbg_do_break_method(¶m, NULL TSRMLS_CC); - break; + switch (type) { + case METHOD_PARAM: + phpdbg_do_break_method(¶m, NULL TSRMLS_CC); + break; - case FILE_PARAM: - phpdbg_do_break_file(¶m, NULL TSRMLS_CC); - break; + case FILE_PARAM: + phpdbg_do_break_file(¶m, NULL TSRMLS_CC); + break; - case NUMERIC_PARAM: - phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC); - break; + case NUMERIC_PARAM: + phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC); + break; - case STR_PARAM: - phpdbg_do_break_func(¶m, NULL TSRMLS_CC); - break; + case STR_PARAM: + phpdbg_do_break_func(¶m, NULL TSRMLS_CC); + break; - default: zend_error( - E_WARNING, "unrecognized parameter type %ld", type); - } + default: zend_error( + E_WARNING, "unrecognized parameter type %ld", type); + } - phpdbg_clear_param(¶m TSRMLS_CC); + phpdbg_clear_param(¶m TSRMLS_CC); - } else if (EG(current_execute_data) && EG(active_op_array)) { - zend_ulong opline_num = (EG(current_execute_data)->opline - - EG(active_op_array)->opcodes); + } else if (EG(current_execute_data) && EG(active_op_array)) { + zend_ulong opline_num = (EG(current_execute_data)->opline - + EG(active_op_array)->opcodes); - phpdbg_set_breakpoint_opline_ex( - &EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC); - } + phpdbg_set_breakpoint_opline_ex( + &EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC); + } } /* }}} */ /* {{{ proto void phpdbg_clear(void) - instructs phpdbg to clear breakpoints */ + instructs phpdbg to clear breakpoints */ static PHP_FUNCTION(phpdbg_clear) { - zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); - zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); - zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); - zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); - zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) - ZEND_ARG_INFO(0, type) - ZEND_ARG_INFO(0, expression) + ZEND_BEGIN_ARG_INFO_EX(phpdbg_break_arginfo, 0, 0, 0) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, expression) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(phpdbg_clear_arginfo, 0, 0, 0) + ZEND_BEGIN_ARG_INFO_EX(phpdbg_clear_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() -zend_function_entry phpdbg_user_functions[] = { - PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) - PHP_FE(phpdbg_break, phpdbg_break_arginfo) + zend_function_entry phpdbg_user_functions[] = { + PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) + PHP_FE(phpdbg_break, phpdbg_break_arginfo) #ifdef PHP_FE_END PHP_FE_END #else @@ -246,7 +246,7 @@ static zend_module_entry sapi_phpdbg_module_entry = { static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) /* {{{ */ { - if (php_module_startup(module, &sapi_phpdbg_module_entry, 1) == FAILURE) { + if (php_module_startup(module, &sapi_phpdbg_module_entry, 1) == FAILURE) { return FAILURE; } return SUCCESS; @@ -254,7 +254,7 @@ static inline int php_sapi_phpdbg_module_startup(sapi_module_struct *module) /* static char* php_sapi_phpdbg_read_cookies(TSRMLS_D) /* {{{ */ { - return NULL; + return NULL; } /* }}} */ static int php_sapi_phpdbg_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s TSRMLS_DC) /* {{{ */ @@ -299,40 +299,40 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* { char *docroot = ""; /* In phpdbg mode, we consider the environment to be a part of the server variables - */ - php_import_environment_variables(track_vars_array TSRMLS_CC); - - if (PHPDBG_G(exec)) { - len = PHPDBG_G(exec_len); - if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", - &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { - php_register_variable("PHP_SELF", PHPDBG_G(exec), - track_vars_array TSRMLS_CC); - } - if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", - &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { - php_register_variable("SCRIPT_NAME", PHPDBG_G(exec), - track_vars_array TSRMLS_CC); - } - - if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", - &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { - php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec), - track_vars_array TSRMLS_CC); - } - if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED", - &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { - php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec), - track_vars_array TSRMLS_CC); - } - } - - /* any old docroot will doo */ - len = 0U; - if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", - &docroot, len, &len TSRMLS_CC)) { - php_register_variable("DOCUMENT_ROOT", docroot, track_vars_array TSRMLS_CC); - } + */ + php_import_environment_variables(track_vars_array TSRMLS_CC); + + if (PHPDBG_G(exec)) { + len = PHPDBG_G(exec_len); + if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("PHP_SELF", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("SCRIPT_NAME", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + + if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED", + &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) { + php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec), + track_vars_array TSRMLS_CC); + } + } + + /* any old docroot will doo */ + len = 0U; + if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", + &docroot, len, &len TSRMLS_CC)) { + php_register_variable("DOCUMENT_ROOT", docroot, track_vars_array TSRMLS_CC); + } } /* }}} */ @@ -349,7 +349,7 @@ static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ } /* }}} */ /* {{{ sapi_module_struct phpdbg_sapi_module - */ +*/ static sapi_module_struct phpdbg_sapi_module = { "phpdbg", /* name */ "phpdbg", /* pretty name */ @@ -402,33 +402,33 @@ const opt_struct OPTIONS[] = { /* {{{ */ }; /* }}} */ const char phpdbg_ini_hardcoded[] = - "html_errors=Off\n" - "register_argc_argv=On\n" - "implicit_flush=On\n" - "display_errors=Off\n" - "log_errors=On\n" - "max_execution_time=0\n" - "max_input_time=-1\n\0"; +"html_errors=Off\n" +"register_argc_argv=On\n" +"implicit_flush=On\n" +"display_errors=Off\n" +"log_errors=On\n" +"max_execution_time=0\n" +"max_input_time=-1\n\0"; /* overwriteable ini defaults must be set in phpdbg_ini_defaults() */ #define INI_DEFAULT(name,value)\ Z_SET_REFCOUNT(tmp, 0);\ - Z_UNSET_ISREF(tmp); \ - ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0);\ - zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);\ +Z_UNSET_ISREF(tmp); \ +ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0);\ +zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);\ void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */ { - zval tmp; + zval tmp; INI_DEFAULT("report_zend_debug", "0"); } /* }}} */ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ { - /* print blurb */ + /* print blurb */ if (!cleaning) { phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", - PHPDBG_VERSION); + PHPDBG_VERSION); phpdbg_writeln("To get help using phpdbg type \"help\" and press enter"); phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES); } else { @@ -517,95 +517,95 @@ int main(int argc, char **argv) /* {{{ */ switch (opt) { case 'r': run++; - break; + break; case 'n': ini_ignore = 1; - break; + break; case 'c': if (ini_override) { free(ini_override); } ini_override = strdup(php_optarg); - break; + break; case 'd': { - int len = strlen(php_optarg); - char *val; - - if ((val = strchr(php_optarg, '='))) { - val++; - if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') { - ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0")); - memcpy(ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); - ini_entries_len += (val - php_optarg); - memcpy(ini_entries + ini_entries_len, "\"", 1); - ini_entries_len++; - memcpy(ini_entries + ini_entries_len, val, len - (val - php_optarg)); - ini_entries_len += len - (val - php_optarg); - memcpy(ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0")); - ini_entries_len += sizeof("\n\0\"") - 2; - } else { - ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\n\0")); - memcpy(ini_entries + ini_entries_len, php_optarg, len); - memcpy(ini_entries + ini_entries_len + len, "\n\0", sizeof("\n\0")); - ini_entries_len += len + sizeof("\n\0") - 2; - } - } else { - ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("=1\n\0")); - memcpy(ini_entries + ini_entries_len, php_optarg, len); - memcpy(ini_entries + ini_entries_len + len, "=1\n\0", sizeof("=1\n\0")); - ini_entries_len += len + sizeof("=1\n\0") - 2; - } - } break; + int len = strlen(php_optarg); + char *val; + + if ((val = strchr(php_optarg, '='))) { + val++; + if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); + ini_entries_len += (val - php_optarg); + memcpy(ini_entries + ini_entries_len, "\"", 1); + ini_entries_len++; + memcpy(ini_entries + ini_entries_len, val, len - (val - php_optarg)); + ini_entries_len += len - (val - php_optarg); + memcpy(ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0")); + ini_entries_len += sizeof("\n\0\"") - 2; + } else { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, len); + memcpy(ini_entries + ini_entries_len + len, "\n\0", sizeof("\n\0")); + ini_entries_len += len + sizeof("\n\0") - 2; + } + } else { + ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("=1\n\0")); + memcpy(ini_entries + ini_entries_len, php_optarg, len); + memcpy(ini_entries + ini_entries_len + len, "=1\n\0", sizeof("=1\n\0")); + ini_entries_len += len + sizeof("=1\n\0") - 2; + } + } break; case 'z': - zend_load_extension(php_optarg); - break; + zend_load_extension(php_optarg); + break; - /* begin phpdbg options */ + /* begin phpdbg options */ case 'e': { /* set execution context */ - exec_len = strlen(php_optarg); - if (exec_len) { - exec = strdup(php_optarg); - } - } break; + exec_len = strlen(php_optarg); + if (exec_len) { + exec = strdup(php_optarg); + } + } break; case 'I': { /* ignore .phpdbginit */ - init_file_default = 0; - } break; + init_file_default = 0; + } break; case 'i': { /* set init file */ - init_file_len = strlen(php_optarg); - if (init_file_len) { - init_file = strdup(php_optarg); - } - } break; + init_file_len = strlen(php_optarg); + if (init_file_len) { + init_file = strdup(php_optarg); + } + } break; case 'O': { /* set oplog output */ - oplog_file_len = strlen(php_optarg); - if (oplog_file_len) { - oplog_file = strdup(php_optarg); - } - } break; + oplog_file_len = strlen(php_optarg); + if (oplog_file_len) { + oplog_file = strdup(php_optarg); + } + } break; case 'v': /* set quietness off */ - flags &= ~PHPDBG_IS_QUIET; - break; + flags &= ~PHPDBG_IS_QUIET; + break; case 's': /* set stepping on */ - step = 1; - break; + step = 1; + break; case 'E': /* stepping through eval on */ - flags |= PHPDBG_IS_STEPONEVAL; - break; + flags |= PHPDBG_IS_STEPONEVAL; + break; case 'b': /* set colours off */ - flags &= ~PHPDBG_IS_COLOURED; - break; + flags &= ~PHPDBG_IS_COLOURED; + break; case 'q': /* hide banner */ - show_banner = 0; - break; + show_banner = 0; + break; } } @@ -651,25 +651,25 @@ int main(int argc, char **argv) /* {{{ */ PHPDBG_G(io)[PHPDBG_STDOUT] = stdout; PHPDBG_G(io)[PHPDBG_STDERR] = stderr; - if (exec) { /* set execution context */ - PHPDBG_G(exec) = phpdbg_resolve_path( - exec TSRMLS_CC); - PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); + if (exec) { /* set execution context */ + PHPDBG_G(exec) = phpdbg_resolve_path( + exec TSRMLS_CC); + PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec)); - free(exec); - } + free(exec); + } if (oplog_file) { /* open oplog */ PHPDBG_G(oplog) = fopen(oplog_file, "w+"); if (!PHPDBG_G(oplog)) { phpdbg_error( - "Failed to open oplog %s", oplog_file); + "Failed to open oplog %s", oplog_file); } free(oplog_file); } - /* set flags from command line */ - PHPDBG_G(flags) = flags; + /* set flags from command line */ + PHPDBG_G(flags) = flags; zend_try { zend_activate_modules(TSRMLS_C); @@ -681,57 +681,57 @@ int main(int argc, char **argv) /* {{{ */ } zend_try { - /* activate globals, they can be overwritten */ - zend_activate_auto_globals(TSRMLS_C); - } zend_end_try(); - - /* initialize from file */ - zend_try { - PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; - phpdbg_init( - init_file, init_file_len, - init_file_default TSRMLS_CC); - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - } zend_catch { - PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } - } zend_end_try(); - - /* step from here, not through init */ - if (step) { - PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; - } - - if (run) { - /* no need to try{}, run does it ... */ - PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC); - if (run > 1) { - /* if -r is on the command line more than once just quit */ - goto phpdbg_out; - } - } - - /* phpdbg main() */ - do { - zend_try { - phpdbg_interactive(TSRMLS_C); - } zend_catch { - if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { - cleaning = 1; - goto phpdbg_out; - } else cleaning = 0; - - if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { - goto phpdbg_out; - } - } zend_end_try(); + /* activate globals, they can be overwritten */ + zend_activate_auto_globals(TSRMLS_C); + } zend_end_try(); + + /* initialize from file */ + zend_try { + PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; + phpdbg_init( + init_file, init_file_len, + init_file_default TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + } zend_catch { + PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } + } zend_end_try(); + + /* step from here, not through init */ + if (step) { + PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; + } + + if (run) { + /* no need to try{}, run does it ... */ + PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC); + if (run > 1) { + /* if -r is on the command line more than once just quit */ + goto phpdbg_out; + } + } + + /* phpdbg main() */ + do { + zend_try { + phpdbg_interactive(TSRMLS_C); + } zend_catch { + if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + cleaning = 1; + goto phpdbg_out; + } else cleaning = 0; + + if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { + goto phpdbg_out; + } + } zend_end_try(); } while(!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); phpdbg_out: if (ini_entries) { - free(ini_entries); + free(ini_entries); } if (ini_override) { @@ -757,15 +757,15 @@ int main(int argc, char **argv) /* {{{ */ #endif zend_try { - php_module_shutdown(TSRMLS_C); + php_module_shutdown(TSRMLS_C); } zend_end_try(); sapi_shutdown(); } if (cleaning) { - goto phpdbg_main; - } + goto phpdbg_main; + } #ifdef ZTS /* bugggy */