]> granicus.if.org Git - php/commitdiff
reworked the current EOL stuff
authorAnatol Belski <ab@php.net>
Tue, 21 Oct 2014 09:29:18 +0000 (11:29 +0200)
committerAnatol Belski <ab@php.net>
Tue, 21 Oct 2014 09:47:21 +0000 (11:47 +0200)
config.m4
config.w32
phpdbg.c
phpdbg.h
phpdbg_prompt.c

index 3bedc3cad994ddd034b36a5bec76f9778bbd6d0d..3f24e303decf02e9a634cce0dc3d27275b40703c 100644 (file)
--- 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"
index 40a593331ddcc0f737acd2baf42103e199402c77..3f4639399be5d18380c919a3357837493f3d2a33 100644 (file)
@@ -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';
 
index 1133cd9f42516a948535c2b1e340d7b6c9901d0a..8686dcd1c3606530579358d10f4750a88cbace64 100644 (file)
--- 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) /* {{{ */
index 41124eada364af97f18ffee27ae5bfaceccdab1d..b7346ab8bf2ddf15a9e1109c4fa2f9a832f01be5 100644 (file)
--- 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
index 387054f0d07a7c4df9df6c5f28db982555db9d99..20de859f035d235dfcd32195cbc955a5eaf0b1d5 100644 (file)
@@ -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;