From: Bob Weinand Date: Wed, 24 Sep 2014 22:55:17 +0000 (+0200) Subject: Always add a newline before a warning or a notice X-Git-Tag: php-5.6.3RC1~51^2~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2bd1a74690b03694d32c3cff7b7e4cb2281c50c3;p=php Always add a newline before a warning or a notice --- diff --git a/phpdbg.c b/phpdbg.c index 1e1642fb76..e30d35d71f 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -63,6 +63,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->exec = NULL; pg->exec_len = 0; pg->buffer = NULL; + pg->last_was_newline = 1; pg->ops = NULL; pg->vmret = 0; pg->bp_count = 0; diff --git a/phpdbg.h b/phpdbg.h index 2fa2d5093a..f9ca0f2a71 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -64,7 +64,7 @@ # include "TSRM.h" #endif -#ifdef HAVE_LIBREADLINE +#ifdef LIBREADLINE # include # include #endif @@ -208,6 +208,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) char *prompt[2]; /* prompt */ const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */ char *buffer; /* buffer */ + zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */ zend_ulong flags; /* phpdbg flags */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index a45513bee6..8ca56aa25c 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -816,6 +816,7 @@ disconnect: if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) { goto disconnect; } + PHPDBG_G(last_was_newline) = 1; } /* note: EOF is ignored */ @@ -836,7 +837,10 @@ readline: if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { cmd = buf; } else goto disconnect; - } else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + } else { + cmd = readline(phpdbg_get_prompt(TSRMLS_C)); + PHPDBG_G(last_was_newline) = 1; + } if (!cmd) { goto readline; diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 3ce2fade17..22a7b56282 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -240,6 +240,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, .. switch (type) { case P_ERROR: + if (!PHPDBG_G(last_was_newline)) { + fprintf(fp, "\n"); + PHPDBG_G(last_was_newline) = 1; + } if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { rc = fprintf(fp, "\033[%sm[%s]\033[0m\n", @@ -250,6 +254,10 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, .. break; case P_NOTICE: + if (!PHPDBG_G(last_was_newline)) { + fprintf(fp, "\n"); + PHPDBG_G(last_was_newline) = 1; + } if (PHPDBG_G(flags) & PHPDBG_IS_COLOURED) { rc = fprintf(fp, "\033[%sm[%s]\033[0m\n", @@ -265,11 +273,13 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, .. } else { rc = fprintf(fp, "\n"); } + PHPDBG_G(last_was_newline) = 1; } break; case P_WRITE: if (buffer) { rc = fprintf(fp, "%s", buffer); + PHPDBG_G(last_was_newline) = buffer[strlen(buffer) - 1] == '\n'; } break;