Public bug reported:
Binary package hint: libreadline5
Description
=======
Using up-to-date feisty.
I am using libreadline to provide custom completion for an application.
Using custom completion involves setting a global C symbol
(rl_attempted_completion_function) to a function that returns with a list
of suitable matches:
char ** match_generator(char * prefix, ...);
The char ** result ends with a (char *)NULL. If no matches are found, this
returns the NULL on the first position which confuses readline (see patch).
Steps to reproduce:
============
/* compile: gcc -Wall -O -o rltest rltest.c -lreadline */
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
char ** match_func(const char * text, int start, int end)
{
char ** ret = (char **)malloc(sizeof(char *));
ret[0] = 0;
return ret;
}
int main()
{
rl_attempted_completion_over = 1;
rl_attempted_completion_function = match_func;
readline("hit TAB> ");
return 0;
}
Fixes
====
Existing applications can simply do "if !matches[0] then matches=0".
To get expected (IMHO) behaviour from the library:
--- readline-5.2/complete.c 2006-07-28 17:35:49.000000000 +0200
+++ readline-5.2-fixed/complete.c 2007-07-27 16:57:02.000000000 +0200
@@ -961,6 +961,7 @@
if (rl_attempted_completion_function)
{
matches = (*rl_attempted_completion_function) (text, start, end);
+ if (matches && ! matches[0]) matches = 0;
if (matches || rl_attempted_completion_over)
{
====
Cheers!
** Affects: readline5 (Ubuntu)
Importance: Undecided
Status: New
--
Readline library crash on custom completion
https://bugs.launchpad.net/bugs/128727
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs