summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_cmd.c
diff options
context:
space:
mode:
authorkrakjoe <joe.watkins@live.co.uk>2014-02-02 13:42:01 +0000
committerkrakjoe <joe.watkins@live.co.uk>2014-02-02 13:42:01 +0000
commita4a120d66aaf44cd0dc71f39a49998b924c2ef0e (patch)
treef48300cf85374f82a437a42f3a2d4ed88867f34d /sapi/phpdbg/phpdbg_cmd.c
parent8a7e2f8dd2116ff6ada654e301c593accf337250 (diff)
parent05c309f2d85bcc33e95415d7f50d7748a7c27498 (diff)
downloadphp-git-a4a120d66aaf44cd0dc71f39a49998b924c2ef0e.tar.gz
Merge branch 'PHP-5.6' of https://git.php.net/repository/php-src into PHP-5.6
Diffstat (limited to 'sapi/phpdbg/phpdbg_cmd.c')
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index 9f052d6f6f..c700851243 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2013 The PHP Group |
+ | Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -459,6 +459,9 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
phpdbg_input_t *buffer = NULL;
char *cmd = NULL;
+#ifndef HAVE_LIBREADLINE
+ char buf[PHPDBG_MAX_CMD];
+#endif
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) &&
@@ -467,32 +470,42 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
}
if (buffered == NULL) {
-#ifndef HAVE_LIBREADLINE
- char buf[PHPDBG_MAX_CMD];
- if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) ||
- !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
- /* the user has gone away */
- phpdbg_error("Failed to read console!");
+disconnect:
+ if (0) {
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout();
return NULL;
}
+#ifndef HAVE_LIBREADLINE
+ if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
+ if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) {
+ goto disconnect;
+ }
+ }
+
+ /* note: EOF is ignored */
+readline:
+ if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
+ /* the user has gone away */
+ if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
+ goto disconnect;
+ } else goto readline;
+ }
+
cmd = buf;
#else
+ /* note: EOF makes readline write prompt again in local console mode */
+readline:
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
char buf[PHPDBG_MAX_CMD];
if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
cmd = buf;
- } else cmd = NULL;
+ } else goto disconnect;
} else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
if (!cmd) {
- /* the user has gone away */
- phpdbg_error("Failed to read console!");
- PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
- zend_bailout();
- return NULL;
+ goto readline;
}
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {