4545#endif /* }}} */
4646
4747ZEND_DECLARE_MODULE_GLOBALS (phpdbg );
48+ int phpdbg_startup_run = 0 ;
49+ char * phpdbg_exec = NULL ;
4850
4951static PHP_INI_MH (OnUpdateEol )
5052{
@@ -487,7 +489,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
487489 case PHPDBG_NEXT :
488490 return ;
489491 }
490- } while (!(PHPDBG_G (flags ) & PHPDBG_IS_QUITTING ));
492+ } while (!(PHPDBG_G (flags ) & PHPDBG_IS_STOPPING ));
491493
492494 }
493495 } else fprintf (stdout , "%s\n" , message );
@@ -752,7 +754,7 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */
752754 phpdbg_writeln ("intro" , "help=\"help\"" , "To get help using phpdbg type \"help\" and press enter" );
753755 phpdbg_notice ("intro" , "report=\"%s\"" , "Please report bugs to <%s>" , PHPDBG_ISSUES );
754756 phpdbg_xml ("</intros>" );
755- } else {
757+ } else if ( phpdbg_startup_run == 0 ) {
756758 if (!(PHPDBG_G (flags ) & PHPDBG_WRITE_XML )) {
757759 phpdbg_notice (NULL , NULL , "Clean Execution Environment" );
758760 }
@@ -776,7 +778,7 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */
776778 if (PHPDBG_G (flags ) & PHPDBG_IS_INTERACTIVE ) {
777779 /* we quit remote consoles on recv SIGINT */
778780 if (PHPDBG_G (flags ) & PHPDBG_IS_REMOTE ) {
779- PHPDBG_G (flags ) |= PHPDBG_IS_QUITTING ;
781+ PHPDBG_G (flags ) |= PHPDBG_IS_STOPPING ;
780782 zend_bailout ();
781783 }
782784 } else {
@@ -961,8 +963,6 @@ int main(int argc, char **argv) /* {{{ */
961963 zend_ulong zend_extensions_len = 0L ;
962964 zend_bool ini_ignore ;
963965 char * ini_override ;
964- char * exec ;
965- size_t exec_len ;
966966 char * init_file ;
967967 size_t init_file_len ;
968968 zend_bool init_file_default ;
@@ -973,7 +973,6 @@ int main(int argc, char **argv) /* {{{ */
973973 int php_optind , opt , show_banner = 1 ;
974974 long cleaning = 0 ;
975975 zend_bool remote = 0 ;
976- int run = 0 ;
977976 int step = 0 ;
978977
979978#ifdef _WIN32
@@ -1046,8 +1045,6 @@ int main(int argc, char **argv) /* {{{ */
10461045 ini_override = NULL ;
10471046 zend_extensions = NULL ;
10481047 zend_extensions_len = 0L ;
1049- exec = NULL ;
1050- exec_len = 0 ;
10511048 init_file = NULL ;
10521049 init_file_len = 0 ;
10531050 init_file_default = 1 ;
@@ -1057,14 +1054,13 @@ int main(int argc, char **argv) /* {{{ */
10571054 php_optarg = NULL ;
10581055 php_optind = 1 ;
10591056 opt = 0 ;
1060- run = 0 ;
10611057 step = 0 ;
10621058 sapi_name = NULL ;
10631059
10641060 while ((opt = php_getopt (argc , argv , OPTIONS , & php_optarg , & php_optind , 0 , 2 )) != -1 ) {
10651061 switch (opt ) {
10661062 case 'r' :
1067- run ++ ;
1063+ phpdbg_startup_run ++ ;
10681064 break ;
10691065 case 'n' :
10701066 ini_ignore = 1 ;
@@ -1201,14 +1197,12 @@ int main(int argc, char **argv) /* {{{ */
12011197 }
12021198
12031199 /* set exec if present on command line */
1204- if ((argc > php_optind ) && (strcmp (argv [php_optind - 1 ],"--" ) != SUCCESS ))
1205- {
1206- exec_len = strlen (argv [php_optind ]);
1207- if (exec_len ) {
1208- if (exec ) {
1209- free (exec );
1200+ if (!phpdbg_exec && (argc > php_optind ) && (strcmp (argv [php_optind - 1 ],"--" ) != SUCCESS )) {
1201+ if (strlen (argv [php_optind ])) {
1202+ if (phpdbg_exec ) {
1203+ free (phpdbg_exec );
12101204 }
1211- exec = strdup (argv [php_optind ]);
1205+ phpdbg_exec = strdup (argv [php_optind ]);
12121206 }
12131207 php_optind ++ ;
12141208 }
@@ -1331,7 +1325,7 @@ int main(int argc, char **argv) /* {{{ */
13311325 for (i = SG (request_info ).argc ; -- i ;) {
13321326 SG (request_info ).argv [i ] = estrdup (argv [php_optind - 1 + i ]);
13331327 }
1334- SG (request_info ).argv [i ] = exec ? estrndup ( exec , exec_len ) : estrdup ("" );
1328+ SG (request_info ).argv [i ] = phpdbg_exec ? estrdup ( phpdbg_exec ) : estrdup ("" );
13351329
13361330 php_hash_environment (TSRMLS_C );
13371331 }
@@ -1394,11 +1388,12 @@ int main(int argc, char **argv) /* {{{ */
13941388 php_stream_stdio_ops .write = phpdbg_stdiop_write ;
13951389#endif
13961390
1397- if (exec ) { /* set execution context */
1398- PHPDBG_G (exec ) = phpdbg_resolve_path (exec TSRMLS_CC );
1391+ if (phpdbg_exec ) { /* set execution context */
1392+ PHPDBG_G (exec ) = phpdbg_resolve_path (phpdbg_exec TSRMLS_CC );
13991393 PHPDBG_G (exec_len ) = strlen (PHPDBG_G (exec ));
14001394
1401- free (exec );
1395+ free (phpdbg_exec );
1396+ phpdbg_exec = NULL ;
14021397 }
14031398
14041399 if (oplog_file ) { /* open oplog */
@@ -1448,13 +1443,14 @@ int main(int argc, char **argv) /* {{{ */
14481443 PHPDBG_G (flags ) |= PHPDBG_IS_STEPPING ;
14491444 }
14501445
1451- if (run ) {
1446+ if (phpdbg_startup_run ) {
14521447 /* no need to try{}, run does it ... */
14531448 PHPDBG_COMMAND_HANDLER (run )(NULL TSRMLS_CC );
1454- if (run > 1 ) {
1449+ if (phpdbg_startup_run > 1 ) {
14551450 /* if -r is on the command line more than once just quit */
14561451 goto phpdbg_out ;
14571452 }
1453+ phpdbg_startup_run = 0 ;
14581454 }
14591455
14601456phpdbg_interact :
@@ -1494,7 +1490,7 @@ int main(int argc, char **argv) /* {{{ */
14941490 }
14951491 }
14961492 } zend_end_try ();
1497- } while (! cleaning && ! (PHPDBG_G (flags ) & PHPDBG_IS_QUITTING ));
1493+ } while (! (PHPDBG_G (flags ) & PHPDBG_IS_STOPPING ));
14981494
14991495 /* this must be forced */
15001496 CG (unclean_shutdown ) = 0 ;
0 commit comments