com php-src: prepare setting EOL with command or INI: phpdbg.c phpdbg_prompt.c phpdbg_prompt.h
| From: | Bob Weinand | Date: | Tue, 21 Oct 2014 09:47:20 +0000 |
| Subject: | com php-src: prepare setting EOL with command or INI: phpdbg.c phpdbg_prompt.c phpdbg_prompt.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82521@lists.php.net to get a copy of this message | ||
Commit: e011f0ca60a7d4d062b559dbbf7cfabef8f7a75b
Author: Anatol Belski <ab@php.net> Tue, 21 Oct 2014 10:35:20 +0200
Parents: 55936dc23d7adabb90c5cec06ac1eaf8e294f82b
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e011f0ca60a7d4d062b559dbbf7cfabef8f7a75b
Log:
prepare setting EOL with command or INI
Changed paths:
M phpdbg.c
M phpdbg_prompt.c
M phpdbg_prompt.h
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index 0eb07bc..1133cd9 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 39d474c..387054f 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 314f711..94e24df 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 */