digitalmars.D.bugs - [Issue 387] New: When EOF of din is reached, a line of output is lost
- d-bugmail puremagic.com Sep 28 2006
- d-bugmail puremagic.com Sep 28 2006
- d-bugmail puremagic.com Sep 28 2006
- d-bugmail puremagic.com Sep 29 2006
- Derek Parnell <derek psyc.ward> Sep 29 2006
- Ary Manzana <asterite gmail.com> Sep 29 2006
- BCS <BCS pathlink.com> Sep 29 2006
- Stewart Gordon <smjg_1998 yahoo.com> Sep 30 2006
- Frits van Bommel <fvbommel REMwOVExCAPSs.nl> Sep 30 2006
- d-bugmail puremagic.com Sep 30 2006
- Walter Bright <newshound digitalmars.com> Oct 05 2006
- Stewart Gordon <smjg_1998 yahoo.com> Oct 07 2006
- Walter Bright <newshound digitalmars.com> Oct 07 2006
- d-bugmail puremagic.com Sep 30 2006
- d-bugmail puremagic.com Sep 30 2006
- d-bugmail puremagic.com Oct 14 2006
- Walter Bright <newshound digitalmars.com> Oct 14 2006
- d-bugmail puremagic.com May 28 2011
http://d.puremagic.com/issues/show_bug.cgi?id=387 Summary: When EOF of din is reached, a line of output is lost Product: D Version: 0.167 Platform: PC OS/Version: Windows Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: smjg iname.com The following program should wait for an EOF from the standard input, and then output two lines of text: ---------- import std.cstream; import std.stdio; void main() { while (din.getc != char.init) {} writefln("Line 1"); writefln("Line 2"); } ---------- In fact, only "Line 2" gets printed. I've experimented with writef, dout.writefln, dout.writef, dout.write(char), dout.writeString and dout.writeLine, all with the same results. The output is also the same if the writefln statements are consolidated into one: writefln("Line 1\nLine 2"); The bug also bites if din.readLine is used: while (din.readLine != "") {} Changing either or both lines of output to go to stderr also makes no difference. Mysteriously, if either input or output is redirected, or the program is at either end of a pipe, then the bug doesn't show. There's no obvious workaround. Calling din.flush() or dout.flush() at any point makes no difference. While you could add a dummy line of output, this would both break the program when the bug is fixed and break it with the aforementioned redirection and piping. This is likely to block people trying to write various Unix-style tools. --
Sep 28 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #1 from digitalmars-com baysmith.com 2006-09-29 00:15 ------- Works for me.dmd -run issue387.d
Line 1 Line 2
Window XP, DMD 0.167 --
Sep 28 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #2 from ddparnell bigpond.com 2006-09-29 01:40 ------- Works for me too ... c:\temp>type test.d import std.cstream; import std.stdio; void main() { while (din.getc != char.init) {} writefln("Line 1"); writefln("Line 2"); } c:\temp>bud test Path and Version : y:\util\bud.exe v3.03(2370) built on Wed Sep 20 16:16:41 2006 c:\temp>test <test.d Line 1 Line 2 c:\temp> --
Sep 28 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #3 from smjg iname.com 2006-09-29 05:42 ------- So it works on WinXP. It's 98SE I'm having trouble on. (In reply to comment #2)c:\temp>test <test.d Line 1 Line 2
My point is that it's when _not_ redirecting that the problem shows up. For the record, what OS version are you on, Derek? --
Sep 29 2006
On Fri, 29 Sep 2006 10:42:22 +0000 (UTC), d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #3 from smjg iname.com 2006-09-29 05:42 ------- So it works on WinXP. It's 98SE I'm having trouble on. (In reply to comment #2)c:\temp>test <test.d Line 1 Line 2
My point is that it's when _not_ redirecting that the problem shows up. For the record, what OS version are you on, Derek?
WinXP SP2. Is anyone still using Win98? ;-) -- Derek Parnell Melbourne, Australia "Down with mediocrity!"
Sep 29 2006
Derek Parnell wrote:On Fri, 29 Sep 2006 10:42:22 +0000 (UTC), d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #3 from smjg iname.com 2006-09-29 05:42 ------- So it works on WinXP. It's 98SE I'm having trouble on. (In reply to comment #2)c:\temp>test <test.d Line 1 Line 2
the record, what OS version are you on, Derek?
WinXP SP2. Is anyone still using Win98? ;-)
In Argentina, for instance, some people is still using Win98, because their computer isn't good enough to support WinXP. I also believe this happens in other countries...
Sep 29 2006
Ary Manzana wrote:Derek Parnell wrote:Is anyone still using Win98? ;-)
In Argentina, for instance, some people is still using Win98, because their computer isn't good enough to support WinXP. I also believe this happens in other countries...
4 out of the 8 computers I am connected with are Win98
Sep 29 2006
Derek Parnell wrote: <snip>WinXP SP2. Is anyone still using Win98? ;-)
Oh, you mean 98 as opposed to 98SE? I don't know. But my guess is that there are many people on older OSs who either: - haven't been bothered to upgrade - have acquired a second-hand or even third-hand computer - are making the most of an old system that still works before throwing it away I know somebody who was, until a year or three ago, still doing everything in MS-DOS. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 30 2006
Stewart Gordon wrote:I know somebody who was, until a year or three ago, still doing everything in MS-DOS.
I know someone who was, until a day or six ago, still doing everything in MS-DOS. With about 4MB RAM. At 12 Mhz (IIRC). Of course, "everything" here means "everything pc-related he does" which in turn means "run one specific program". All he did with it was use it as a terminal that connected (over an old-fashioned modem) to a special-purpose feeding computer on the farm he runs. Some people use old stuff because it works and they don't need more than it provides. Especially if they never connect to the net (so no security updates, latest-browser-features, etc. required). That said though, he has since upgraded... to Windows 98 ;) He still only runs one program that would run fine in DOS though. But now he runs it at 1 GHz.
Sep 30 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #4 from smjg iname.com 2006-09-30 11:47 ------- Alas, it's a bug with the OS. I've tried the C stdio API (both DM and Borland implementations) and the Windows file I/O API with the same effect. And I'm still lost for a workaround. I can't even find any stream state information that can have anything to do with the problem. But at least something that can be done now is to find out on which Windows versions the bug occurs. We have that it works on XP and fails on 98SE. This leaves 95, 98, ME, 2000 and Server 2003 to check if I haven't missed any. --
Sep 30 2006
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #4 from smjg iname.com 2006-09-30 11:47 ------- Alas, it's a bug with the OS. I've tried the C stdio API (both DM and Borland implementations) and the Windows file I/O API with the same effect. And I'm still lost for a workaround.
For a workaround, test to see which version of Windows you're running under, and generate an extra line of output for the buggy one. Look in std/file.d for how to determine the version.
Oct 05 2006
Walter Bright wrote: <snip>For a workaround, test to see which version of Windows you're running under, and generate an extra line of output for the buggy one. Look in std/file.d for how to determine the version.
That's what I thought for a moment. But how do I detect whether stdin or stdout is redirected? Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Oct 07 2006
Stewart Gordon wrote:Walter Bright wrote: <snip>For a workaround, test to see which version of Windows you're running under, and generate an extra line of output for the buggy one. Look in std/file.d for how to determine the version.
That's what I thought for a moment. But how do I detect whether stdin or stdout is redirected?
C's isatty()
Oct 07 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #5 from fvbommel wxs.nl 2006-09-30 12:22 ------- Stewart Gordons said:But at least something that can be done now is to find out on which Windows versions the bug occurs. We have that it works on XP and fails on 98SE. This leaves 95, 98, ME, 2000 and Server 2003 to check if I haven't missed any.
I think you missed previous NT versions. Anyway, it works fine on Win2000: -------------------------- D:\Temp>type test.d import std.cstream; import std.stdio; void main() { while (din.getc != char.init) {} writefln("Line 1"); writefln("Line 2"); } D:\Temp>dmd test.d d:\d\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; D:\Temp>test.exe ^Z Line 1 Line 2 D:\Temp>test.exe < test.d Line 1 Line 2 D:\Temp>ver Microsoft Windows 2000 [Version 5.00.2195] D:\Temp> -------------------------- --
Sep 30 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #7 from jpelcis gmail.com 2006-09-30 14:11 ------- (In reply to comment #4)But at least something that can be done now is to find out on which Windows versions the bug occurs.
Works Vista RC1. --
Sep 30 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 ------- Comment #8 from smjg iname.com 2006-10-14 15:58 ------- We've got that it works on 2000, XP and Vista RC1. And that it fails on 98SE. this leaves 95, 98FE, NT 4, ME and Server 2003. My guess would be that the bug is in 95 and 98FE as well as 98SE, and in Server 2003 as well as the others from 2000 up. But what about NT 4 and ME? I can't guess whether these have the bug at the moment. (OK, so there's also Win32s and NT 3.x - but do we really need to worry about these?) --
Oct 14 2006
d-bugmail puremagic.com wrote:(OK, so there's also Win32s and NT 3.x - but do we really need to worry about these?)
No.
Oct 14 2006
http://d.puremagic.com/issues/show_bug.cgi?id=387 --- Comment #9 from Stewart Gordon <smjg iname.com> 2011-05-28 09:28:45 PDT --- It's been established that it's a bug in some versions of Windows, not in Phobos or any of the C libraries it uses. Thinking about it now, I don't suppose it's worth adding a workaround layer. For all I know, the versions of Windows that suffer the bug are probably no longer supported. And those who want this compatibility anyway can use my library.... http://pr.stewartsplace.org.uk/d/sutil/ What are we going to do with this bug report now? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2011









d-bugmail puremagic.com 