johannes Sat Jun 3 22:02:02 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/sapi/cli php_cli.c /php-src/sapi/cgi cgi_main.c Log: MFH
http://cvs.php.net/viewcvs.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.2&r2=1.129.2.13.2.3&diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.2 php-src/sapi/cli/php_cli.c:1.129.2.13.2.3 --- php-src/sapi/cli/php_cli.c:1.129.2.13.2.2 Thu May 11 22:10:31 2006 +++ php-src/sapi/cli/php_cli.c Sat Jun 3 22:02:02 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c,v 1.129.2.13.2.2 2006/05/11 22:10:31 dmitry Exp $ */ +/* $Id: php_cli.c,v 1.129.2.13.2.3 2006/06/03 22:02:02 johannes Exp $ */ #include "php.h" #include "php_globals.h" @@ -122,7 +122,6 @@ {'e', 0, "profile-info"}, {'F', 1, "process-file"}, {'f', 1, "file"}, - {'g', 1, "global"}, {'h', 0, "help"}, {'i', 0, "info"}, {'l', 0, "syntax-check"}, @@ -415,7 +414,7 @@ " -n No php.ini file will be used\n" " -d foo[=bar] Define INI entry foo with value 'bar'\n" " -e Generate extended information for debugger/profiler\n" - " -f <file> Parse <file>.\n" + " -f <file> Parse and execute <file>.\n" " -h This help\n" " -i PHP information\n" " -l Syntax check only (lint)\n" @@ -467,21 +466,6 @@ } -static void php_register_command_line_global_vars(char **arg TSRMLS_DC) -{ - char *var, *val; - - var = *arg; - val = strchr(var, '='); - if (!val) { - printf("No value specified for variable '%s'\n", var); - } else { - *val++ = '\0'; - php_register_variable(var, val, NULL TSRMLS_CC); - } - efree(*arg); -} - static php_stream *s_in_process = NULL; static void cli_register_file_handles(TSRMLS_D) @@ -591,7 +575,6 @@ char *orig_optarg=php_optarg; char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL; - zend_llist global_vars; int interactive=0; int module_started = 0; int lineno = 0; @@ -690,8 +673,6 @@ module_started = 1; zend_first_try { - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ CG(in_compilation) = 0; /* not initialized but needed for several options */ EG(uninitialized_zval_ptr) = NULL; @@ -786,12 +767,11 @@ case 'a': /* interactive mode */ if (!interactive) { -#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE) - printf("Interactive shell\n\n"); -#else - printf("Interactive mode enabled\n\n"); -#endif - fflush(stdout); + if (behavior != PHP_MODE_STANDARD) { + param_error = param_mode_conflict; + break; + } + interactive=1; } break; @@ -829,14 +809,6 @@ script_file = php_optarg; break; - case 'g': /* define global variables on command line */ - { - char *arg = estrdup(php_optarg); - - zend_llist_add_element(&global_vars, &arg); - } - break; - case 'l': /* syntax check mode */ if (behavior != PHP_MODE_STANDARD) { break; @@ -864,7 +836,7 @@ param_error = "You can use -r only once.\n"; break; } - } else if (behavior != PHP_MODE_STANDARD) { + } else if (behavior != PHP_MODE_STANDARD || interactive) { param_error = param_mode_conflict; break; } @@ -892,7 +864,7 @@ param_error = "You can use -B only once.\n"; break; } - } else if (behavior != PHP_MODE_STANDARD) { + } else if (behavior != PHP_MODE_STANDARD || interactive) { param_error = param_mode_conflict; break; } @@ -906,7 +878,7 @@ param_error = "You can use -E only once.\n"; break; } - } else if (behavior != PHP_MODE_STANDARD) { + } else if (behavior != PHP_MODE_STANDARD || interactive) { param_error = param_mode_conflict; break; } @@ -962,6 +934,15 @@ goto err; } + if (interactive) { +#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE) + printf("Interactive shell\n\n"); +#else + printf("Interactive mode enabled\n\n"); +#endif + fflush(stdout); + } + CG(interactive) = interactive; /* only set script_file if not set already and not in direct mode and not at end of parameter list */ @@ -1018,10 +999,7 @@ } } - /* This actually destructs the elements of the list - ugly hack */ zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); - zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars TSRMLS_CC); - zend_llist_destroy(&global_vars); PG(during_request_startup) = 0; switch (behavior) { @@ -1038,6 +1016,19 @@ char *prompt = "php > "; char *history_file; + if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) { + zend_file_handle *prepend_file_p; + zend_file_handle prepend_file = {0}; + + prepend_file.filename = PG(auto_prepend_file); + prepend_file.opened_path = NULL; + prepend_file.free_filename = 0; + prepend_file.type = ZEND_HANDLE_FILENAME; + prepend_file_p = &prepend_file; + + zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, prepend_file_p); + } + history_file = tilde_expand("~/.php_history"); rl_attempted_completion_function = cli_code_completion; rl_special_prefixes = "$"; @@ -1081,6 +1072,11 @@ if (php_last_char != '\0' && php_last_char != '\n') { sapi_cli_single_write("\n", 1); } + + if (EG(exception)) { + zend_exception_error(EG(exception) TSRMLS_CC); + } + php_last_char = '\0'; } write_history(history_file); http://cvs.php.net/viewcvs.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.3&r2=1.267.2.15.2.4&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.3 php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.4 --- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.3 Wed May 24 09:42:21 2006 +++ php-src/sapi/cgi/cgi_main.c Sat Jun 3 22:02:02 2006 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c,v 1.267.2.15.2.3 2006/05/24 09:42:21 dmitry Exp $ */ +/* $Id: cgi_main.c,v 1.267.2.15.2.4 2006/06/03 22:02:02 johannes Exp $ */ #include "php.h" #include "php_globals.h" @@ -130,7 +130,6 @@ {'d', 1, "define"}, {'e', 0, "profile-info"}, {'f', 1, "file"}, - {'g', 1, "global"}, {'h', 0, "help"}, {'i', 0, "info"}, {'l', 0, "syntax-check"}, @@ -912,22 +911,6 @@ zend_alter_ini_entry(name, strlen(name) + 1, value, strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); } - -static void php_register_command_line_global_vars(char **arg TSRMLS_DC) -{ - char *var, *val; - - var = *arg; - val = strchr(var, '='); - if (!val) { - printf("No value specified for variable '%s'\n", var); - } else { - *val++ = '\0'; - php_register_variable(var, val, NULL TSRMLS_CC); - } - efree(*arg); -} - #if PHP_FASTCGI /** * Clean up child processes upon exit @@ -980,7 +963,6 @@ int orig_optind = php_optind; char *orig_optarg = php_optarg; char *script_file = NULL; - zend_llist global_vars; #if FORCE_CGI_REDIRECT long force_redirect = 1; char *redirect_status_env = NULL; @@ -1344,7 +1326,6 @@ SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ #endif init_request_info(TSRMLS_C); - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); CG(interactive) = 0; if (!cgi @@ -1389,14 +1370,6 @@ SG(request_info).argv = &argv[php_optind - 1]; break; - case 'g': /* define global variables on command line */ - { - char *arg = estrdup(php_optarg); - - zend_llist_add_element(&global_vars, &arg); - } - break; - case 'i': /* php info & quit */ if (php_request_startup(TSRMLS_C) == FAILURE) { php_module_shutdown(TSRMLS_C); @@ -1560,10 +1533,6 @@ SG(request_info).no_headers = 1; } - /* This actually destructs the elements of the list - ugly hack */ - zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars TSRMLS_CC); - zend_llist_destroy(&global_vars); - /* at this point path_translated will be set if: 1. we are running from shell and got filename was there
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php