From: Anatol Belski Date: Tue, 21 Oct 2014 09:29:18 +0000 (+0200) Subject: reworked the current EOL stuff X-Git-Tag: php-5.6.3RC1~51^2~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63a450281ae5d2e22cf5c28357f230f704905cb3;p=php reworked the current EOL stuff --- diff --git a/config.m4 b/config.m4 index 3bedc3cad9..3f24e303de 100644 --- a/config.m4 +++ b/config.m4 @@ -33,7 +33,7 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c phpdbg_eol.c" if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS" diff --git a/config.w32 b/config.w32 index 40a593331d..3f4639399b 100644 --- a/config.w32 +++ b/config.w32 @@ -5,7 +5,7 @@ PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help. 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + 'phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c '+ 'phpdbg_parser.c phpdbg_lexer.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c ' + - 'phpdbg_sigio_win32.c'; + 'phpdbg_sigio_win32.c phpdbg_eol.c'; PHPDBG_DLL='php' + PHP_VERSION + 'phpdbg.dll'; PHPDBG_EXE='phpdbg.exe'; diff --git a/phpdbg.c b/phpdbg.c index 1133cd9f42..8686dcd1c3 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -30,6 +30,7 @@ #include "phpdbg_set.h" #include "phpdbg_io.h" #include "zend_alloc.h" +#include "phpdbg_eol.h" /* {{{ remote console headers */ #ifndef _WIN32 @@ -51,24 +52,12 @@ static PHP_INI_MH(OnUpdateEol) return FAILURE; } - if (0 == strcmp(new_value, "CRLF", 4) || 0 == strcmp(new_value, "crlf", 4)) { - PHPDBG_G(eol) = "\r\n"; - } else if (0 == strcmp(new_value, "LF", 2) || 0 == strcmp(new_value, "lf", 4)) { - PHPDBG_G(eol) = "\n"; - } else if (0 == strcmp(new_value, "CR", 2) || 0 == strcmp(new_value, "cr", 4)) { - PHPDBG_G(eol) = "\r"; - } else if (0 == strcmp(new_value, "LFCR", 4) || 0 == strcmp(new_value, "lfcr", 4)) { - PHPDBG_G(eol) = "\n\r"; - } else { - return FAILURE; - } - - return SUCCESS; + return phpdbg_update_eol_global(new_value TSRMLS_CC); } PHP_INI_BEGIN() STD_PHP_INI_ENTRY("phpdbg.path", "", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdateString, socket_path, zend_phpdbg_globals, phpdbg_globals) - STD_PHP_INI_ENTRY("phpdbg.eol", "lf", PHP_INI_ALL, OnUpdateEol, socket_path, zend_phpdbg_globals, phpdbg_globals) + STD_PHP_INI_ENTRY("phpdbg.eol", "2", PHP_INI_ALL, OnUpdateEol, socket_path, zend_phpdbg_globals, phpdbg_globals) PHP_INI_END() static zend_bool phpdbg_booted = 0; @@ -116,7 +105,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ memset(&pg->swd, 0, sizeof(struct win32_sigio_watcher_data)); #endif - pg->eol = "\n"; + pg->eol = PHPDBG_EOL_LF; } /* }}} */ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ diff --git a/phpdbg.h b/phpdbg.h index 41124eada3..b7346ab8bf 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -286,7 +286,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HANDLE sigio_watcher_thread; /* sigio watcher thread handle */ struct win32_sigio_watcher_data swd; #endif - char *eol; + int8_t eol; ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 387054f0d0..20de859f03 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -83,7 +83,7 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0, PHPDBG_ASYNC_SAFE), PHPDBG_COMMAND_D(wait, "wait for other process", 'W', NULL, 0, 0), PHPDBG_COMMAND_D(watch, "set watchpoint", 'w', phpdbg_watch_commands, "|ss", 0), - PHPDBG_COMMAND_D(eol, "set eol", 'E', NULL, "|s", 0), + PHPDBG_COMMAND_D(eol, "set EOL", 'E', NULL, "|s", 0), PHPDBG_END_COMMAND }; /* }}} */ @@ -1567,18 +1567,11 @@ next: PHPDBG_COMMAND(eol) /* {{{ */ { if (!param || param->type == EMPTY_PARAM) { - //phpdbg_notice("eol", "variable=\"%.*s\"", "Set watchpoint on %.*s", (int) param->len, param->str); phpdbg_notice("eol", "argument required, supported crlf, lfcr, lf, cr", "argument required, supported crlf, lfcr, lf, cr"); } else switch (param->type) { case STR_PARAM: - if (0 == strcmp(param->str, "CRLF", 4) || 0 == strcmp(param->str, "crlf", 4)) { - PHPDBG_G(eol) = "\r\n"; - } else if (0 == strcmp(param->str, "LF", 2) || 0 == strcmp(param->str, "lf", 4)) { - PHPDBG_G(eol) = "\n"; - } else if (0 == strcmp(param->str, "CR", 2) || 0 == strcmp(param->str, "cr", 4)) { - PHPDBG_G(eol) = "\r"; - } else if (0 == strcmp(param->str, "LFCR", 4) || 0 == strcmp(param->str, "lfcr", 4)) { - PHPDBG_G(eol) = "\n\r"; + if (FAILURE == phpdbg_update_eol_global(param->str TSRMLS_CC)) { + phpdbg_notice("eol", "unknown EOL name '%s', give crlf, lfcr, lf, cr", "unknown EOL name '%s', give crlf, lfcr, lf, cr", param->str); } break;