com php-src: Always add a newline before a warning or a notice: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg_utils.c

From: Date: Wed, 24 Sep 2014 22:55:17 +0000
Subject: com php-src: Always add a newline before a warning or a notice: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg_utils.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82628@lists.php.net to get a copy of this message
Commit: 2bd1a74690b03694d32c3cff7b7e4cb2281c50c3 Author: Bob Weinand <bobwei9@hotmail.com> Thu, 25 Sep 2014 00:55:17 +0200 Parents: 92fe2d0a85ab831b01e2de9802da1753c144b808 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2bd1a74690b03694d32c3cff7b7e4cb2281c50c3 Log: Always add a newline before a warning or a notice Changed paths: M phpdbg.c M phpdbg.h M phpdbg_cmd.c M phpdbg_utils.c Diff: diff --git a/phpdbg.c b/phpdbg.c index 1e1642f..e30d35d 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 2fa2d50..f9ca0f2 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -64,7 +64,7 @@ # include "TSRM.h" #endif -#ifdef HAVE_LIBREADLINE +#ifdef LIBREADLINE # include <readline/readline.h> # include <readline/history.h> #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 a45513b..8ca56aa 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 3ce2fad..22a7b56 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;

« previous php.cvs (#82628) next »