bug-readline
[Top][All Lists]
Advanced

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

Re: [Bug-readline] Unexpected ^@ in input


From: Zoltan Kovacs
Subject: Re: [Bug-readline] Unexpected ^@ in input
Date: Wed, 29 Apr 2009 07:49:05 +0200

First of all I'd like to thank you for your help.

In the meantime I managed to track down what the problem is, and the
^@ was inserted to the readline buffer because of my buggy strncpy().
The buggy function inserted a '\0' character to the end of the string
always and readline uses strncpy(a, b, 1) to put the new character
into the buffer.

Thanks again,
Zoltan

On Tue, Apr 28, 2009 at 5:47 PM, Chet Ramey <address@hidden> wrote:
> Zoltan Kovacs wrote:
>> Hi,
>>
>> I'm using libreadline in my project. The underlying terminal driver
>> that readline uses is also my own implementation.
>>
>> My problem is that when I type a few characters (e.g. 'hello') and I
>> press the left arrow key twice, then I should insert the next
>> character right after 'hel'. This is what I'm expecting, but the
>> result will be 'address@hidden' after pressing the 'a' key. Not to mention
>> that the returned line by the readline() call will be 'hela' only, the
>> remaining will be truncated.
>>
>> What did I do wrong? Is this a problem on my side or this is a readline 
>> issue?
>
> I can't say for sure that it's not a problem with readline, but I
> can't reproduce it.  What is happening is that there is a NUL being
> inserted into the readline line buffer (probably as the result of
> read(2) returning it), and it's being displayed as ^@, its printable
> equivalent.  The reason that more of the line is displayed is that
> rl_end, which readline uses to mark the end of the line, is beyond the
> NUL.  The line is truncated upon return because the NUL terminates the
> returned string.
>
> I'm not sure what else to tell you other than to check for read(2)
> returning a NUL to readline.
>
> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>
> Chet Ramey, ITS, CWRU   address@hidden    http://cnswww.cns.cwru.edu/~chet/
>




reply via email to

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