Hi, I've been tracking down a bug in GNU Octave and I think it's
actually a bug in readline. The attached example program reproduces the
error only when USE_HOOK is defined, which installs a trivial
rl_event_hook function.
Without USE_HOOK:
>>> hello
<<< hello
Entering ^R e <Right Arrow> displays ">>> hello" with the cursor on the
first l, as expected.
With USE_HOOK:
>>> hello
<<< hello
Entering ^R e <Right Arrow> displays ">>> h[Cello" with the cursor on
the e.
The following patch to readline git master resolves this issue for me.
Does this look like a reasonable fix?
---
diff --git a/isearch.c b/isearch.c
index 712b9ea..d830f99 100644
--- a/isearch.c
+++ b/isearch.c
@@ -393,7 +393,7 @@ _rl_isearch_dispatch (cxt, c)
XXX - since _rl_input_available depends on the application-
settable keyboard timeout value, this could alternatively
use _rl_input_queued(100000) */
- if (cxt->lastc == ESC && _rl_input_available ())
+ if (cxt->lastc == ESC && (_rl_any_typein () || _rl_input_available ()))
rl_execute_next (ESC);
return (0);
}
--
mike
#include <stdio.h>
#include <readline/readline.h>
#ifdef USE_HOOK
int idle_func (void)
{
return 0;
}
#endif
int main (int argc, char *argv[])
{
char *line = 0;
rl_readline_name = "TestProgram";
#ifdef USE_HOOK
rl_event_hook = &idle_func;
#endif
while ((line = readline (">>> ")))
{
add_history (line);
printf ("<<< %s\n", line);
}
return 0;
}
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline