ID:               48089
 User updated by:  wcandillon at gmail dot com
 Reported By:      wcandillon at gmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Readline related
 Operating System: All
 PHP Version:      5.2.9
 New Comment:

--- /Users/wcandillon/readline.c        2009-03-24 11:37:07.000000000 +0100
+++ Desktop/php-5.2.8/ext/readline/readline.c   2009-04-27
15:25:29.000000000 +0200
@@ -2,7 +2,7 @@
   
+----------------------------------------------------------------------+
    | PHP Version 5                                                    
   |
   
+----------------------------------------------------------------------+
-   | Copyright (c) 1997-2009 The PHP Group                            
   |
+   | Copyright (c) 1997-2008 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.42.2.3.2.9 2008/12/31 11:17:42 sebastian Exp $
*/
+/* $Id: readline.c,v 1.42.2.3.2.8 2008/11/21 22:48:27 felipe Exp $ */
 
 /* {{{ includes & prototypes */
 
@@ -48,7 +48,6 @@
 PHP_FUNCTION(readline_read_history);
 PHP_FUNCTION(readline_write_history);
 PHP_FUNCTION(readline_completion_function);
-
 #if HAVE_RL_CALLBACK_READ_CHAR
 PHP_FUNCTION(readline_callback_handler_install);
 PHP_FUNCTION(readline_callback_read_char);
@@ -132,6 +131,8 @@
 
 /* }}} */
 
+char* no_filename_completion_function(){ return 0; }
+
 /* {{{ proto string readline([string prompt]) 
    Reads a line */
 PHP_FUNCTION(readline)
@@ -246,8 +247,20 @@
                                rl_readline_name = strdup(Z_STRVAL_PP(value));;
                        }
                        RETVAL_STRING(SAFE_STRING(oldstr),1);
-               } 
-       }
+               } else if (! strcasecmp(Z_STRVAL_PP(what), 
"autocomplete_files")) {
+      if (ac == 2 )
+      {
+        //convert_to_bool_ex(value);
+        if(Z_BVAL_PP(value))
+        {
+          rl_completion_entry_function = NULL;
+        } else {
+          rl_completion_entry_function =
no_filename_completion_function;
+        }
+       
RETVAL_BOOL(rl_completion_entry_function!=no_filename_completion_function);     
+      }
+    }
+  }
 }
 
 /* }}} */
@@ -383,7 +396,7 @@
                }
        }
 
-       return NULL;
+       return ((char *)NULL);
 }
 
 static zval *_readline_string_zval(const char *str)
@@ -420,15 +433,19 @@
        char **matches = NULL;
        TSRMLS_FETCH();
 
+  //reinit the appended char
+  rl_completion_append_character = ' ';
        params[0]=_readline_string_zval(text);
        params[1]=_readline_long_zval(start);
        params[2]=_readline_long_zval(end);
 
        if (call_user_function(CG(function_table), NULL,
_readline_completion, &_readline_array, 3, params TSRMLS_CC) == SUCCESS)
{
-               if (Z_TYPE(_readline_array) == IS_ARRAY) {
+               if (Z_TYPE(_readline_array) == IS_ARRAY ) {
                        if (zend_hash_num_elements(Z_ARRVAL(_readline_array))) {
                                matches =
rl_completion_matches(text,_readline_command_generator);
                        } else {
+        //set the char to null
+        rl_completion_append_character = '\0';
                                matches = malloc(sizeof(char *) * 2);
                                matches[0] = strdup("");
                                matches[1] = '\0';


Previous Comments:
------------------------------------------------------------------------

[2009-04-27 14:01:08] scott...@php.net

Can you provide patches as a unified diff.

------------------------------------------------------------------------

[2009-04-27 13:42:01] wcandillon at gmail dot com

Here's the patch:
5c5
<    | Copyright (c) 1997-2008 The PHP Group                           
    |
---
>    | Copyright (c) 1997-2009 The PHP Group                           
    |
19c19
< /* $Id: readline.c,v 1.42.2.3.2.8 2008/11/21 22:48:27 felipe Exp $
*/
---
> /* $Id: readline.c,v 1.42.2.3.2.9 2008/12/31 11:17:42 sebastian Exp $
*/
50a51
> 
134,135d134
< char* no_filename_completion_function(){ return 0; }
< 
250,263c249,250
<               } else if (! strcasecmp(Z_STRVAL_PP(what), 
"autocomplete_files"))
{
<       if (ac == 2 )
<       {
<         //convert_to_bool_ex(value);
<         if(Z_BVAL_PP(value))
<         {
<           rl_completion_entry_function = NULL;
<         } else {
<           rl_completion_entry_function =
no_filename_completion_function;
<         }
<        
RETVAL_BOOL(rl_completion_entry_function!=no_filename_completion_function);     
<       }
<     }
<   }
---
>               } 
>       }
399c386
<       return ((char *)NULL);
---
>       return NULL;
436,437d422
<   //reinit the appended char
<   rl_completion_append_character = ' ';
443c428
<               if (Z_TYPE(_readline_array) == IS_ARRAY ) {
---
>               if (Z_TYPE(_readline_array) == IS_ARRAY) {
447,448d431
<         //set the char to null
<         rl_completion_append_character = '\0';

------------------------------------------------------------------------

[2009-04-27 13:41:02] wcandillon at gmail dot com

Description:
------------
This patch provides a new mean to mask filesystem autocompletion:
readline_info('autocomplete_files', false);



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48089&edit=1

Reply via email to