Add support for rl_completion_suppress_append and rl_completion_append_character

These options are only available with libreadline.
This commit is contained in:
Tim Bazuin 2017-08-29 10:43:04 +02:00 committed by Nikita Popov
parent f7f48643e7
commit 033907b9a5
4 changed files with 41 additions and 1 deletions

4
NEWS
View File

@ -146,6 +146,10 @@ PHP NEWS
. Fixed bug #65414 (deal with leading slash when adding files correctly).
(bishopb)
- readline:
. Added completion_append_character and completion_suppress_append options
to readline_info() if linked against libreadline. (krageon)
- Session:
. Fixed bug #74941 (session fails to start after having headers sent).
(morozov)

View File

@ -64,6 +64,11 @@ Core:
BCMath:
. bcscale() can now also be used as getter to retrieve the current scale in use.
readline:
. Support for the completion_append_character and completion_suppress_append
options has been added to readline_info(). These options are only available
if PHP is linked against libreadline (rather than libedit).
========================================
3. Changes in SAPI modules
========================================

View File

@ -262,6 +262,11 @@ PHP_FUNCTION(readline_info)
add_assoc_long(return_value,"pending_input",rl_pending_input);
add_assoc_string(return_value,"prompt",SAFE_STRING(rl_prompt));
add_assoc_string(return_value,"terminal_name",(char *)SAFE_STRING(rl_terminal_name));
add_assoc_str(return_value, "completion_append_character",
rl_completion_append_character == 0
? ZSTR_EMPTY_ALLOC()
: ZSTR_CHAR(rl_completion_append_character));
add_assoc_bool(return_value,"completion_suppress_append",rl_completion_suppress_append);
#endif
#if HAVE_ERASE_EMPTY_LINE
add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line);
@ -307,6 +312,20 @@ PHP_FUNCTION(readline_info)
RETVAL_STRING(SAFE_STRING(rl_prompt));
} else if (!strcasecmp(what, "terminal_name")) {
RETVAL_STRING((char *)SAFE_STRING(rl_terminal_name));
} else if (!strcasecmp(what, "completion_suppress_append")) {
oldval = rl_completion_suppress_append;
if (value) {
rl_completion_suppress_append = zend_is_true(value);
}
RETVAL_BOOL(oldval);
} else if (!strcasecmp(what, "completion_append_character")) {
oldval = rl_completion_append_character;
if (value) {
convert_to_string_ex(value)
rl_completion_append_character = (int)Z_STRVAL_P(value)[0];
}
RETVAL_INTERNED_STR(
oldval == 0 ? ZSTR_EMPTY_ALLOC() : ZSTR_CHAR(oldval));
#endif
#if HAVE_ERASE_EMPTY_LINE
} else if (!strcasecmp(what, "erase_empty_line")) {

View File

@ -16,10 +16,14 @@ var_dump(readline_info('readline_name', 1));
var_dump(readline_info('readline_name'));
var_dump(readline_info('attempted_completion_over',1));
var_dump(readline_info('attempted_completion_over'));
var_dump(readline_info('completion_append_character', "\0"));
var_dump(readline_info('completion_append_character'));
var_dump(readline_info('completion_suppress_append', true));
var_dump(readline_info('completion_suppress_append'));
?>
--EXPECTF--
array(11) {
array(13) {
["line_buffer"]=>
string(0) ""
["point"]=>
@ -36,6 +40,10 @@ array(11) {
string(0) ""
["terminal_name"]=>
string(0) ""
["completion_append_character"]=>
string(1) " "
["completion_suppress_append"]=>
bool(false)
["library_version"]=>
string(%d) "%s"
["readline_name"]=>
@ -51,3 +59,7 @@ string(5) "other"
string(1) "1"
int(0)
int(1)
string(1) " "
string(0) ""
bool(false)
bool(true)