summaryrefslogtreecommitdiff
path: root/ext/readline/readline_cli.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-08-04 13:56:27 +0400
committerDmitry Stogov <dmitry@zend.com>2014-08-04 13:56:27 +0400
commit7301994c28d548c5a4eda6a3a4ae0fab6af04636 (patch)
tree4058df108a4ea2499c850a23eb7cf3850dd2941d /ext/readline/readline_cli.c
parent863a603fada3ce107cb402683bc79dce1359c463 (diff)
parentfe894c2154e6b013f0d0b29ca660ad719fd1affe (diff)
downloadphp-git-7301994c28d548c5a4eda6a3a4ae0fab6af04636.tar.gz
Merge branch 'master' into phpng
* master: (46 commits) PHP_INT_MIN and _MAX tests NEWS and UPGRADING Added PHP_INT_MIN Fix wrong lenght size Bug #51096 - Remove unnecessary ? for first/last day of Moved streams related functions to xp_ssl.c Remove duplicate NEWS Update NEWS Update NEWS Update NEWS BFN BFN Fixed bug #67715 (php-milter does not build and crashes randomly). We need to turn off any strict mode here for this warning to show up Disable restrictions regarding arrays in constants at run-time. For the discussion around it, see the thread on the mailing list: http://www.mail-archive.com/internals@lists.php.net/msg68245.html Revert "Fix bug #67064 in a BC safe way" Updated NEWS for #67693 Updated NEWS for #67693 Fixed bug #67693 - incorrect push to the empty array add missing entry to NEWS ... Conflicts: Zend/tests/errmsg_040.phpt Zend/tests/ns_059.phpt Zend/zend_language_parser.y Zend/zend_vm_def.h ext/openssl/openssl.c ext/reflection/php_reflection.c ext/session/session.c ext/spl/spl_directory.c ext/spl/spl_iterators.c ext/sqlite3/sqlite3.c ext/standard/array.c
Diffstat (limited to 'ext/readline/readline_cli.c')
-rw-r--r--ext/readline/readline_cli.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 84d27ca046..0ca9daf8ff 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -99,6 +99,9 @@ static size_t readline_shell_write(const char *str, uint str_length TSRMLS_DC) /
static int readline_shell_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
{
+ /* We just store the last char here and then pass back to the
+ caller (sapi_cli_single_write in sapi/cli) which will actually
+ write due to -1 return code */
php_last_char = str[str_length-1];
return -1;
}
@@ -589,6 +592,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
char *code = emalloc(size);
zend_string *prompt = cli_get_prompt("php", '>' TSRMLS_CC);
char *history_file;
+ int history_lines_to_write = 0;
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
zend_file_handle *prepend_file_p;
@@ -651,6 +655,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
if (*line) {
add_history(line);
+ history_lines_to_write += 1;
}
free(line);
@@ -660,6 +665,15 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
continue;
}
+ if (history_lines_to_write) {
+#if HAVE_LIBEDIT
+ write_history(history_file);
+#else
+ append_history(history_lines_to_write, history_file);
+#endif
+ history_lines_to_write = 0;
+ }
+
zend_try {
zend_eval_stringl(code, pos, NULL, "php shell code" TSRMLS_CC);
} zend_end_try();
@@ -667,7 +681,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
pos = 0;
if (!pager_pipe && php_last_char != '\0' && php_last_char != '\n') {
- readline_shell_write("\n", 1 TSRMLS_CC);
+ php_write("\n", 1 TSRMLS_CC);
}
if (EG(exception)) {
@@ -681,7 +695,6 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
php_last_char = '\0';
}
- write_history(history_file);
free(history_file);
efree(code);
STR_RELEASE(prompt);