]> granicus.if.org Git - php/commitdiff
MFH: Proper fix for bug #31796 .
authorIlia Alshanetsky <iliaa@php.net>
Fri, 4 Feb 2005 00:22:03 +0000 (00:22 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 4 Feb 2005 00:22:03 +0000 (00:22 +0000)
ext/readline/readline.c

index 3da4af0e9c71cb9d2d5f3911d99e2d438a59ec23..ec07121ff35d3bc9523ad59a8d3bfb48633f52c3 100644 (file)
@@ -354,7 +354,7 @@ static char *_readline_command_generator(char *text,int state)
                }
        }
 
-       return strdup("");
+       return NULL;
 }
 
 static zval *_readline_string_zval(const char *str)
@@ -393,7 +393,13 @@ static char **_readline_completion_cb(char *text, int start, int end)
 
        if (call_user_function(CG(function_table), NULL, params[0], &_readline_array, 3, params+1 TSRMLS_CC) == SUCCESS) {
                if (Z_TYPE(_readline_array) == IS_ARRAY) {
-                       matches = completion_matches(text,_readline_command_generator);
+                       if (zend_hash_num_elements(Z_ARRVAL(_readline_array))) {
+                               matches = completion_matches(text,_readline_command_generator);
+                       } else {
+                               matches = malloc(sizeof(char *) * 2);
+                               matches[0] = strdup("");
+                               matches[1] = '\0';
+                       }
                }
        }