php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48089 Mask filesystem autocompletion
Submitted: 2009-04-27 13:41 UTC Modified: 2011-01-02 02:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: wcandillon at gmail dot com Assigned:
Status: Open Package: Readline related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wcandillon at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-27 13:41 UTC] wcandillon at gmail dot com
Description:
------------
This patch provides a new mean to mask filesystem autocompletion:
readline_info('autocomplete_files', false);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-27 14:58 UTC] wcandillon at gmail dot com
--- /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';
 [2011-01-02 02:35 UTC] jani@php.net
-Summary: ext/readline: Mask filesystem autocompletion +Summary: Mask filesystem autocompletion -Package: Feature/Change Request +Package: Readline related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 05:01:26 2024 UTC