Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #287 (closed defect: wontfix)

Opened 17 years ago

Last modified 17 years ago

Writing a single newline breaks Stdout/Cout

Reported by: demise Assigned to: kris
Priority: major Milestone: 0.96 Beta 2
Component: IO Version: 0.95.1
Keywords: Cc:

Description

This simple test case fails on Windows with dmd 1.006. From the manual "Line breaks may be embedded within the text also, using the traditional \n syntax.".

import tango.io.Stdout;

void main() {
  Stdout("Hello\nworld"); // works
  Stdout("\n"); // fails -> 
  Stdout("Hello"); // so this does nothing
  Stdout.flush;
}

Change History

02/19/07 21:52:17 changed by kris

  • status changed from new to closed.
  • resolution set to wontfix.
  • milestone set to 0.96 Beta 2.

embedded \n characters do not flush the output; they simply provide newline behaviour when the output is flushed. This is operating as intended :)

02/19/07 22:23:02 changed by demise

  • status changed from closed to reopened.
  • resolution deleted.

No, I didn't mean that. The \n character breaks the Stdout so that nothing comes out after that. That particular example should IMO print:

Hello world

Hello

but it just prints

Hello world

I had a simple socket listener that dumped the read data to console in an infinite loop. The exact source is on the forums. Trying to print a \n terminated the whole program.

02/20/07 00:18:21 changed by kris

Your code:

import tango.io.Stdout;

void main() {

Stdout("Hello\nworld"); Stdout("\n"); Stdout("Hello"); Stdout.flush;

}

Should emit exactly the following: Hello world Hello

There is no trailing \n -- only the one after the first Hello and the one emitted by itself. On Win32, the text is emitted exactly as expected. Which platform are you using?

02/20/07 00:21:24 changed by kris

Oh great; worthless formatting. Let's try again:

Your code:

import tango.io.Stdout;

void main() {
        Stdout("Hello\nworld"); 
        Stdout("\n"); 
        Stdout("Hello"); 
        Stdout.flush;
}

Should emit exactly the following:

Hello 
world 
Hello

There is no trailing \n -- only the one after the first Hello and the one emitted by itself. On Win32, the text is emitted exactly as expected. Which platform are you using?

02/20/07 01:25:12 changed by demise

I was using Windows XP SP2 + DMD 1.006 + tango 0.95.1 + newest rebuild. Yeah, I messed up with the expected results. It should display the thing you wrote. The problem is there is no output at all after one has written a single newline. I have the sample case + compiled obj-file + exe-binary here

http://users.utu.fi/jmjmak/temp/bug/

02/20/07 01:28:34 changed by demise

Ok, I tested it again. It seems it only doesn't work when run inside Poseidon IDE when the IDE is capturing the output. Sorry about this. I guess it's a problem with Poseiden then.

02/20/07 01:38:20 changed by demise

  • status changed from reopened to closed.
  • resolution set to wontfix.

Damn. Again, sorry about this. Previously I asked a friend to also test this and he was also using Poseidon as an IDE. That IDE just stops the program when it encounters a newline.

02/20/07 03:23:40 changed by kris

No worries. Thanks for bringing it up :)