Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
reworked the current EOL stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Oct 21, 2014
1 parent e011f0c commit 63a4502
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
19 changes: 4 additions & 15 deletions phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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) /* {{{ */
Expand Down
2 changes: 1 addition & 1 deletion phpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions phpdbg_prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}; /* }}} */

Expand Down Expand Up @@ -1567,18 +1567,11 @@ void phpdbg_force_interruption(TSRMLS_D) {
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;

Expand Down

0 comments on commit 63a4502

Please sign in to comment.