digitalmars.D.bugs - stdin read returning wrong data
- Vathix (18/18) May 25 2004 Here's example code for Windows:
- Ben Hinkle (8/26) May 25 2004 The bug also reproduces in version 0.86 (that was the latest one I had
Here's example code for Windows:
import std.stream;
extern(Windows) void Sleep(uint);
int main()
{
stdout.writeLine("Type quickly but don't return:");
Sleep(3000);
stdout.writeString("Press return> ");
stdout.writeLine("You wrote> " ~ stdin.readLine());
return 0;
}
This is what happens:
Type quickly but don't return:
Press return> foo
You wrote> too
What happens is if you type while the program is busy but don't return, the
first character of the read data is wrong. I tested it with C functions and
it worked as expected.
May 25 2004
On Tue, 25 May 2004 10:32:42 -0400, "Vathix"
<vathixSpamFix dprogramming.com> wrote:
Here's example code for Windows:
import std.stream;
extern(Windows) void Sleep(uint);
int main()
{
stdout.writeLine("Type quickly but don't return:");
Sleep(3000);
stdout.writeString("Press return> ");
stdout.writeLine("You wrote> " ~ stdin.readLine());
return 0;
}
This is what happens:
Type quickly but don't return:
Press return> foo
You wrote> too
What happens is if you type while the program is busy but don't return, the
first character of the read data is wrong. I tested it with C functions and
it worked as expected.
The bug also reproduces in version 0.86 (that was the latest one I had
before 0.90) so it wasn't due to the recent std.stream changes.
I notice that including std.c.stdio and using scanf gets the right
answer.
Since I've been poking around in std.stream lately I'll give it a
shot.
May 25 2004








Ben Hinkle <bhinkle4 juno.com>