summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2016-10-16 15:46:33 +0200
committerBob Weinand <bobwei9@hotmail.com>2016-10-16 15:46:33 +0200
commitf8c2089651a2cdc9eb515afc7d64bc5392930c69 (patch)
treee400d5db3bf16c8cae0ee144c46640cee531308d
parent47bd3d982eedf33ef73a8fb8e42b283da9fcee02 (diff)
parentd82da7de3a460f1eee3d34448be79bca3de7abc1 (diff)
downloadphp-git-f8c2089651a2cdc9eb515afc7d64bc5392930c69.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r--sapi/phpdbg/phpdbg.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 36af9b3719..b800f061d2 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1392,6 +1392,7 @@ int main(int argc, char **argv) /* {{{ */
int exit_status;
char *read_from_stdin = NULL;
zend_string *backup_phpdbg_compile = NULL;
+ zend_bool show_help = 0, show_version = 0;
#ifndef _WIN32
struct sigaction sigio_struct;
@@ -1581,36 +1582,11 @@ phpdbg_main:
} break;
case 'h': {
- ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL);
- sapi_startup(phpdbg);
- phpdbg->startup(phpdbg);
- PHPDBG_G(flags) = 0;
- /* It ain't gonna proceed to real execution anyway,
- but the correct descriptor is needed already. */
- PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout;
- PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout);
- phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);
- phpdbg_do_help(NULL);
- sapi_deactivate();
- sapi_shutdown();
- return 0;
+ show_help = 1;
} break;
case 'V': {
- ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL);
- sapi_startup(phpdbg);
- phpdbg->startup(phpdbg);
- printf(
- "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s",
- PHPDBG_VERSION,
- __DATE__,
- __TIME__,
- PHP_VERSION,
- get_zend_version()
- );
- sapi_deactivate();
- sapi_shutdown();
- return 0;
+ show_version = 1;
} break;
}
@@ -1678,6 +1654,14 @@ phpdbg_main:
ZEND_INIT_MODULE_GLOBALS(phpdbg, php_phpdbg_globals_ctor, NULL);
+ /* set default colors */
+ phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold"));
+ phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold"));
+ phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green"));
+
+ /* set default prompt */
+ phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);
+
if (settings > (zend_phpdbg_globals *) 0x2) {
#ifdef ZTS
*((zend_phpdbg_globals *) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings;
@@ -1700,6 +1684,43 @@ phpdbg_main:
void (*_free)(void*);
void* (*_realloc)(void*, size_t);
+ if (show_version || show_help) {
+ /* It ain't gonna proceed to real execution anyway,
+ but the correct descriptor is needed already. */
+ PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout;
+ PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout);
+ if (show_help) {
+ phpdbg_do_help(NULL);
+ } else if (show_version) {
+ phpdbg_out(
+ "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s",
+ PHPDBG_VERSION,
+ __DATE__,
+ __TIME__,
+ PHP_VERSION,
+ get_zend_version()
+ );
+ }
+ sapi_deactivate();
+ sapi_shutdown();
+ if (ini_entries) {
+ free(ini_entries);
+ }
+ if (ini_override) {
+ free(ini_override);
+ }
+ if (exec) {
+ free(exec);
+ }
+ if (oplog_file) {
+ free(oplog_file);
+ }
+ if (init_file) {
+ free(init_file);
+ }
+ goto free_and_return;
+ }
+
zend_try {
zend_signal_activate();
} zend_end_try();
@@ -1839,14 +1860,6 @@ phpdbg_main:
oplog_file = NULL;
}
- /* set default colors */
- phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold"));
- phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold"));
- phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green"));
-
- /* set default prompt */
- phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);
-
{
php_stream_wrapper *wrapper = zend_hash_str_find_ptr(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php"));
PHPDBG_G(orig_url_wrap_php) = wrapper->wops->stream_opener;
@@ -2158,6 +2171,7 @@ phpdbg_out:
free(sapi_name);
}
+free_and_return:
if (read_from_stdin) {
free(read_from_stdin);
read_from_stdin = NULL;