diff options
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r-- | sapi/cli/php_cli.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 7096829c63..ed66a8f940 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -38,6 +38,7 @@ #ifdef PHP_WIN32 #include "win32/time.h" #include "win32/signal.h" +#include "win32/console.h" #include <process.h> #include <shellapi.h> #endif @@ -243,6 +244,9 @@ static void print_extensions(void) /* {{{ */ #ifndef STDOUT_FILENO #define STDOUT_FILENO 1 #endif +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif static inline int sapi_cli_select(int fd) { @@ -670,7 +674,12 @@ static int do_cli(int argc, char **argv) /* {{{ */ char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL; char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL, *translated_path = NULL; +#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE) + DWORD pl[1]; + int interactive = GetConsoleProcessList(pl, 1) == 1; +#else int interactive=0; +#endif int lineno = 0; const char *param_error=NULL; int hide_argv = 0; @@ -944,7 +953,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ /* here but this would make things only more complicated. And it */ /* is consitent with the way -R works where the stdin file handle*/ /* is also accessible. */ - file_handle.filename = "-"; + file_handle.filename = "Standard input code"; file_handle.handle.fp = stdin; } file_handle.type = ZEND_HANDLE_FP; @@ -983,7 +992,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ PG(during_request_startup) = 0; switch (behavior) { case PHP_MODE_STANDARD: - if (strcmp(file_handle.filename, "-")) { + if (strcmp(file_handle.filename, "Standard input code")) { cli_register_file_handles(); } @@ -1125,7 +1134,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ } case PHP_MODE_REFLECTION_EXT_INFO: { - int len = (int)strlen(reflection_what); + size_t len = strlen(reflection_what); char *lcname = zend_str_tolower_dup(reflection_what, len); zend_module_entry *module; @@ -1201,7 +1210,7 @@ int main(int argc, char *argv[]) int php_optind = 1, use_extended_info = 0; char *ini_path_override = NULL; char *ini_entries = NULL; - int ini_entries_len = 0; + size_t ini_entries_len = 0; int ini_ignore = 0; sapi_module_struct *sapi_module = &cli_sapi_module; @@ -1211,6 +1220,11 @@ int main(int argc, char *argv[]) */ argv = save_ps_args(argc, argv); +#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) + php_win32_console_fileno_set_vt100(STDOUT_FILENO, TRUE); + php_win32_console_fileno_set_vt100(STDERR_FILENO, TRUE); +#endif + cli_sapi_module.additional_functions = additional_functions; #if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP) @@ -1270,7 +1284,7 @@ int main(int argc, char *argv[]) break; case 'd': { /* define ini entries on command line */ - int len = (int)strlen(php_optarg); + size_t len = strlen(php_optarg); char *val; if ((val = strchr(php_optarg, '='))) { @@ -1278,11 +1292,11 @@ int main(int argc, char *argv[]) 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 += (int)(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 - (int)(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 { |