From e011f0ca60a7d4d062b559dbbf7cfabef8f7a75b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 21 Oct 2014 10:35:20 +0200 Subject: [PATCH] prepare setting EOL with command or INI --- phpdbg.c | 22 ++++++++++++++++++++++ phpdbg_prompt.c | 25 ++++++++++++++++++++++++- phpdbg_prompt.h | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/phpdbg.c b/phpdbg.c index 0eb07bce0ca..1133cd9f425 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -45,8 +45,30 @@ ZEND_DECLARE_MODULE_GLOBALS(phpdbg); +static PHP_INI_MH(OnUpdateEol) +{ + if (!new_value) { + 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; +} + 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) PHP_INI_END() static zend_bool phpdbg_booted = 0; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 39d474cd7b9..387054f0d07 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 }; /* }}} */ @@ -1563,3 +1563,26 @@ next: zend_bailout(); } } + +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"; + } + break; + + phpdbg_default_switch_case(); + } +} /* }}} */ + diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index 314f7110784..94e24df8334 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -56,6 +56,7 @@ PHPDBG_COMMAND(export); PHPDBG_COMMAND(register); PHPDBG_COMMAND(quit); PHPDBG_COMMAND(watch); +PHPDBG_COMMAND(eol); PHPDBG_COMMAND(wait); /* }}} */ /* {{{ prompt commands */