johannes Sat Jun 3 22:00:31 2006 UTC Modified files: /php-src/sapi/cli php_cli.c /php-src/sapi/cgi cgi_main.c Log: - Removed useless -g command line option from CGI and CLI - Fixed conflicting behaviour if -B and -a are set with CLI - Fixed handling of auto_prepend and exceptions in readline-a-mode http://cvs.php.net/viewcvs.cgi/php-src/sapi/cli/php_cli.c?r1=1.155&r2=1.156&diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.155 php-src/sapi/cli/php_cli.c:1.156 --- php-src/sapi/cli/php_cli.c:1.155 Sat Jun 3 11:19:44 2006 +++ php-src/sapi/cli/php_cli.c Sat Jun 3 22:00:30 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c,v 1.155 2006/06/03 11:19:44 mike Exp $ */ +/* $Id: php_cli.c,v 1.156 2006/06/03 22:00:30 johannes Exp $ */ #include "php.h" #include "php_globals.h" @@ -130,7 +130,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"}, @@ -424,7 +423,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" @@ -453,21 +452,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) @@ -577,7 +561,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; @@ -699,8 +682,6 @@ module_started = 1; zend_first_try { - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - CG(in_compilation) = 0; /* not initialized but needed for several options */ EG(uninitialized_zval_ptr) = NULL; @@ -782,12 +763,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; @@ -825,14 +805,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; @@ -860,7 +832,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; } @@ -888,7 +860,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; } @@ -902,7 +874,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; } @@ -958,6 +930,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 */ @@ -1014,10 +995,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) { @@ -1034,6 +1012,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 = "$"; @@ -1077,6 +1068,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.290&r2=1.291&diff_format=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.290 php-src/sapi/cgi/cgi_main.c:1.291 --- php-src/sapi/cgi/cgi_main.c:1.290 Fri Jun 2 19:51:43 2006 +++ php-src/sapi/cgi/cgi_main.c Sat Jun 3 22:00:30 2006 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c,v 1.290 2006/06/02 19:51:43 mike Exp $ */ +/* $Id: cgi_main.c,v 1.291 2006/06/03 22:00:30 johannes Exp $ */ #include "php.h" #include "php_globals.h" @@ -127,7 +127,6 @@ {'d', 1, "define"}, {'e', 0, "profile-info"}, {'f', 1, "file"}, - {'g', 1, "global"}, {'h', 0, "help"}, {'i', 0, "info"}, {'l', 0, "syntax-check"}, @@ -865,21 +864,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); -} - /** * Clean up child processes upon exit */ @@ -928,7 +912,6 @@ int orig_optind = php_optind; char *orig_optarg = php_optarg; char *script_file = NULL; - zend_llist global_vars; int ini_entries_len = 0; /* end of temporary locals */ @@ -1292,7 +1275,6 @@ while (!fastcgi || fcgi_accept_request(&request) >= 0) { SG(server_context) = (void *) &request; init_request_info(TSRMLS_C); - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); CG(interactive) = 0; if (!cgi && !fastcgi) { @@ -1329,14 +1311,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); @@ -1492,10 +1466,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