reading formatted strings: readf("%s", &stringvar)

Matt Peterson ricochet1k at gmail.com
Tue Mar 27 12:08:11 PDT 2012


On Tuesday, 27 March 2012 at 19:05:19 UTC, H. S. Teoh wrote:
> On Tue, Mar 27, 2012 at 08:56:56PM +0200, Matt Peterson wrote:
>> On Tuesday, 27 March 2012 at 15:14:07 UTC, Andrei Alexandrescu
>> wrote:
> [...]
>> >You're in a sparse minority at best. Every Unix application 
>> >out there
>> >uses Ctrl-D for end-of-console-input, and your users would be
>> >surprised by your exotic use of it.
>> >
>> >Why not pick any other character for end of chunk - double 
>> >newline,
>> >Ctrl-S, pretty much anything but Ctrl-D? It's a waste of your 
>> >time to
>> >fight a long-established standard.
> [...]
>> 
>> GDB handles Ctrl-D differently. It doesn't close the input on 
>> the
>> first one, it waits for the second one and then exits. After 
>> the first
>> one it acts like you typed 'quit', which asks you if you 
>> really want
>> to quit when there's a program still running.
>
> That's because gdb uses libreadline (or something along those 
> lines)
> with cbreak, so it can intercept control characters without 
> them getting
> interpreted by the terminal. This requires manual control of 
> terminal
> functions, which is something outside the scope of readf(). 
> (You'd be
> better off writing your own terminal handling from scratch, if 
> that's
> what you want.)
>
>
> T

Ah, nice to know. Thanks.


More information about the Digitalmars-d mailing list