--- embedaddon/php/ext/readline/readline.c 2012/02/21 23:48:00 1.1.1.1 +++ embedaddon/php/ext/readline/readline.c 2014/06/15 20:03:54 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: readline.c,v 1.1.1.1 2012/02/21 23:48:00 misho Exp $ */ +/* $Id: readline.c,v 1.1.1.4 2014/06/15 20:03:54 misho Exp $ */ /* {{{ includes & prototypes */ @@ -26,6 +26,7 @@ #include "php.h" #include "php_readline.h" +#include "readline_cli.h" #if HAVE_LIBREADLINE || HAVE_LIBEDIT @@ -66,7 +67,9 @@ static zval *_readline_completion = NULL; static zval _readline_array; PHP_MINIT_FUNCTION(readline); +PHP_MSHUTDOWN_FUNCTION(readline); PHP_RSHUTDOWN_FUNCTION(readline); +PHP_MINFO_FUNCTION(readline); /* }}} */ @@ -141,6 +144,8 @@ static const zend_function_entry php_readline_function PHP_FE(readline_callback_read_char, arginfo_readline_callback_read_char) PHP_FE(readline_callback_handler_remove, arginfo_readline_callback_handler_remove) PHP_FE(readline_redisplay, arginfo_readline_redisplay) +#endif +#if HAVE_RL_ON_NEW_LINE PHP_FE(readline_on_new_line, arginfo_readline_on_new_line) #endif PHP_FE_END @@ -151,11 +156,11 @@ zend_module_entry readline_module_entry = { "readline", php_readline_functions, PHP_MINIT(readline), + PHP_MSHUTDOWN(readline), NULL, - NULL, PHP_RSHUTDOWN(readline), - NULL, - NO_VERSION_YET, + PHP_MINFO(readline), + PHP_VERSION, STANDARD_MODULE_PROPERTIES }; @@ -166,9 +171,14 @@ ZEND_GET_MODULE(readline) PHP_MINIT_FUNCTION(readline) { using_history(); - return SUCCESS; + return PHP_MINIT(cli_readline)(INIT_FUNC_ARGS_PASSTHRU); } +PHP_MSHUTDOWN_FUNCTION(readline) +{ + return PHP_MSHUTDOWN(cli_readline)(SHUTDOWN_FUNC_ARGS_PASSTHRU); +} + PHP_RSHUTDOWN_FUNCTION(readline) { if (_readline_completion) { @@ -186,6 +196,11 @@ PHP_RSHUTDOWN_FUNCTION(readline) return SUCCESS; } +PHP_MINFO_FUNCTION(readline) +{ + PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); +} + /* }}} */ /* {{{ proto string readline([string prompt]) @@ -244,6 +259,7 @@ PHP_FUNCTION(readline_info) #endif add_assoc_string(return_value,"library_version",(char *)SAFE_STRING(rl_library_version),1); add_assoc_string(return_value,"readline_name",(char *)SAFE_STRING(rl_readline_name),1); + add_assoc_long(return_value,"attempted_completion_over",rl_attempted_completion_over); } else { if (!strcasecmp(what,"line_buffer")) { oldstr = rl_line_buffer; @@ -298,7 +314,14 @@ PHP_FUNCTION(readline_info) rl_readline_name = strdup(Z_STRVAL_PP(value));; } RETVAL_STRING(SAFE_STRING(oldstr),1); - } + } else if (!strcasecmp(what, "attempted_completion_over")) { + oldval = rl_attempted_completion_over; + if (value) { + convert_to_long_ex(value); + rl_attempted_completion_over = Z_LVAL_PP(value); + } + RETVAL_LONG(oldval); + } } } @@ -365,10 +388,14 @@ PHP_FUNCTION(readline_read_history) char *arg = NULL; int arg_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|p", &arg, &arg_len) == FAILURE) { return; } + if (php_check_open_basedir(arg TSRMLS_CC)) { + RETURN_FALSE; + } + /* XXX from & to NYI */ if (read_history(arg)) { RETURN_FALSE; @@ -385,10 +412,14 @@ PHP_FUNCTION(readline_write_history) char *arg = NULL; int arg_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|p", &arg, &arg_len) == FAILURE) { return; } + if (php_check_open_basedir(arg TSRMLS_CC)) { + RETURN_FALSE; + } + if (write_history(arg)) { RETURN_FALSE; } else { @@ -561,9 +592,8 @@ PHP_FUNCTION(readline_callback_handler_install) FREE_ZVAL(_prepped_callback); } - MAKE_STD_ZVAL(_prepped_callback); - *_prepped_callback = *callback; - zval_copy_ctor(_prepped_callback); + ALLOC_ZVAL(_prepped_callback); + MAKE_COPY_ZVAL(&callback, _prepped_callback); rl_callback_handler_install(prompt, php_rl_callback_handler); @@ -604,6 +634,9 @@ PHP_FUNCTION(readline_redisplay) } /* }}} */ +#endif + +#if HAVE_RL_ON_NEW_LINE /* {{{ proto void readline_on_new_line(void) Inform readline that the cursor has moved to a new line */ PHP_FUNCTION(readline_on_new_line)