bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Readline 6.2 regression vs. 6.1 on Mac OS X and perha


From: Chet Ramey
Subject: Re: [Bug-readline] Readline 6.2 regression vs. 6.1 on Mac OS X and perhaps elsewhere
Date: Mon, 25 Jun 2012 21:36:20 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 6/24/12 6:08 PM, Max Horn wrote:
> Dear GNU readline team,
> 
> I would like to report on an issue with readline 6.2 on Mac OS X 10.6.8 which 
> does not occur with 6.1 and older. I also have reports for this on 10.7 and 
> also on older Mac OS X systems.
> 
> To reproduce the issue,
> 1) compile the attached sample program (or any other program that sets 
> rl_event_hook),
> 2) run it inside Mac OS X' Terminal.app,
> 3) paste some text, e.g. this line.
> 
> What happens is that you can see the text slowly appear, character by 
> character, like in a bad sci-fi flick. Pressing any key will cause the 
> remaining text to appear instantly.
> 
> I traced this back to the change in input.c, in rl_read_key(), from 6.1 to 
> 6.2. You see, on Mac OS X, if you paste a string, then all characters are 
> instantly visible as input to the program. So, if you paste 50 chars,  you 
> will see 50 chars pending on stdin. Now when rl_event_hook is set, then 
> rl_gather_tyi() is used to read pending input. This function proceeds to read 
> all 50 pending characters at once. Previously, readline would then proceed to 
> feed this input to the program. Specifically, this is the old loop:

They key is that the hook needs to be run after the check for already-read-
and-queued input, and it should only be run if rl_gather_tyi doesn't
detect any input available.  That was the issue with bash-4.1/readline-6.1:
the input hook got run for every input character, whether anything was
available or not, making it very hard to use it as something that got run
after a specified timeout, for instance.

Here's a patch against bash-4.2.  Applying it to a standalone readline
installation is left as an exercise for the reader. :-)

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/


Attachment: readline-input-hook.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]