summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_cmd.c
diff options
context:
space:
mode:
authorJohannes Schlüter <johannes@php.net>2014-01-18 13:53:15 +0100
committerJohannes Schlüter <johannes@php.net>2014-01-18 13:53:15 +0100
commit84efb8fc718d63c8522b0c1602caa84c84de8db1 (patch)
treeeb34dd5a59e99d457ea8a9960781b5458f4f8666 /sapi/phpdbg/phpdbg_cmd.c
parent86096a99ece7e9ccc56446cf06c8963a3c770fb3 (diff)
parent8ff4d61f0864fbca7b2905f14de76fd400d9b3df (diff)
downloadphp-git-84efb8fc718d63c8522b0c1602caa84c84de8db1.tar.gz
Merge branch 'PHP-5.6'
Diffstat (limited to 'sapi/phpdbg/phpdbg_cmd.c')
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index 36a9d26dc2..29424d00fe 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -467,32 +467,43 @@ 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
+ char buf[PHPDBG_MAX_CMD];
+ 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)) {