NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/48957: Broken rl_callback_read_char() in libedit's readline emulation
>Number: 48957
>Category: lib
>Synopsis: Broken rl_callback_read_char() in libedit's readline emulation
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 30 20:30:00 +0000 2014
>Originator: Federico G. Schwindt
>Release: libedit
>Organization:
>Environment:
other
>Description:
readline.c r1.85 introduced, amongst lot of changes, this:
- el_set(e, EL_UNBUFFERED, 1);
+ //el_set(e, EL_UNBUFFERED, 1);
Unfortunately it's not clear why was this done as the commit message only says:
apply apple patches from:
http://opensource.apple.com/source/libedit/libedit-11/patches/
This breaks programs installing their own handler via
rl_callback_handler_install() and using rl_callback_read_char() since the line
buffer is not reset anymore.
>How-To-Repeat:
Testcase below.
This works fine with gnu readline and uncommenting the line previously
mentioned.
#include <editline/readline.h>
#include <poll.h>
#include <stdlib.h>
#include <unistd.h>
static int refresh = 0;
void
fn_handler(char *l)
{
if (l)
refresh = 1;
}
int
main()
{
struct pollfd fds[1];
int i;
rl_already_prompted = 1;
rl_callback_handler_install("prompt> ", fn_handler);
fds[0].fd = 0;
fds[0].events = POLLIN;
for (;;) {
i = poll(fds, 1, 50);
if (refresh) {
refresh = 0;
write(1, "\r \r", 13);
rl_forced_update_display();
}
if (fds[0].revents & POLLIN)
rl_callback_read_char();
}
exit(0);
}
>Fix:
Remove comment from rl_callback_read_char(). Alternatively ensure line buffer
is reset correctly after the callback is invoked.
Home |
Main Index |
Thread Index |
Old Index