Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Expose attempted_completion_over variable from readline library #349

Closed
wants to merge 2 commits into from

3 participants

hartmel Xinchen Hui Account for PHP Pull Requests
hartmel

This variable allows to prevent filename completion in completer function by exposing this variable and allowing PHP to update it. It closes https://bugs.php.net/bug.php?id=55694
Patch used (and updated) since PHP 5.2.

Xinchen Hui

better to be : strncasecmp(what, "attempted_completion_over", sizeof("attempted_completion_over") - 1)

Xinchen Hui

and also, test script is needed , thanks

hartmel

It seemed safe to use strcasecmp since others statements dealing with readline variables use it too.
I updated the test script to handle the new variable.

$ ./run-tests.php ext/readline/tests/readline_info_001.phpt

PHP : ./sapi/cli/php
PHP_SAPI : cli
PHP_VERSION : 5.6.0-dev
ZEND_VERSION: 2.6.0-dev
PHP_OS : Linux - Linux hartmel-wheezy64 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64
INI actual : /home/hartmel/php-src
More .INIs :
CWD : /home/hartmel/php-src
Extra dirs :
VALGRIND : Not used
Running selected tests.
PASS readline_info(): Basic test [ext/readline/tests/readline_info_001.phpt]
Number of tests : 1 1
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)

Tests passed : 1 (100.0%) (100.0%)

Time taken : 0 seconds

Account for PHP Pull Requests
Collaborator

Comment on behalf of stas at php.net:

merged

Account for PHP Pull Requests php-pulls closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2013
Commits on May 28, 2013
This page is out of date. Refresh to see the latest.
10 ext/readline/readline.c
View
@@ -259,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;
@@ -313,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);
+ }
}
}
8 ext/readline/tests/readline_info_001.phpt
View
@@ -12,10 +12,12 @@ var_dump(readline_info('line_buffer'));
var_dump(readline_info('readline_name'));
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'));
?>
--EXPECTF--
-array(10) {
+array(11) {
["line_buffer"]=>
string(0) ""
["point"]=>
@@ -36,6 +38,8 @@ array(10) {
string(%d) "%s"
["readline_name"]=>
string(5) "other"
+ ["attempted_completion_over"]=>
+ int(0)
}
NULL
NULL
@@ -43,3 +47,5 @@ string(0) ""
string(5) "other"
string(5) "other"
string(1) "1"
+int(0)
+int(1)
Something went wrong with that request. Please try again.