]> granicus.if.org Git - php/commitdiff
Add support for rl_completion_suppress_append and rl_completion_append_character
authorTim Bazuin <krageon@gmail.com>
Tue, 29 Aug 2017 08:43:04 +0000 (10:43 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 25 Mar 2018 16:21:35 +0000 (18:21 +0200)
These options are only available with libreadline.

NEWS
UPGRADING
ext/readline/readline.c
ext/readline/tests/readline_info_001.phpt

diff --git a/NEWS b/NEWS
index 680ef4ce82d670d4e32311f1b5402b94d206ca3f..7ec0062827054e0656b02f873a0685f4550d0304 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index 6729b745f1ec1ed5f2610d38c74491aed2c21e6c..0eec409b9cd404bdbdc48af36f05d324ff0d92a7 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -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
 ========================================
index bd443ebcd6a2afd990e0fa46c68a58d9a90055f7..7026b020f68e486670b7cad714fcdf71b21c1432 100644 (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")) {
index 81b7806b439631f621cc731d4f85ed55a084e37a..68599c1d6719f537090d8396b0b73947d694c2e1 100644 (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)
\ No newline at end of file