digitalmars.D.learn - eof
- lx (9/9) Jun 24 2013 Hi,everyone,
- bearophile (6/10) Jun 24 2013 I think this is a library bug, I noticed it some times, but I
- bearophile (5/9) Jun 24 2013 I have added this bug report, is this the issue you are
- monarch_dodra (10/20) Jun 24 2013 I don't think this is a bug (I replied on the bug report):
- bearophile (6/8) Jun 24 2013 I have given an answer, comparing to Python. I think the current
- lx (10/20) Jun 25 2013 I read those information and yes,it is the issue I am having.I
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (18/21) Jun 25 2013 Making a copy of stdin works on Linux (where the stream is terminated by...
- lx (6/28) Jun 26 2013 Hi,Ali,I tried those codes,it doesn't work under win7.The result
- lx (6/38) Jun 26 2013 Hi,Ali,I tried those codes,it doesn't work under win7.The
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (24/26) Jun 25 2013 Ctrl-C appears as SIGINT under POSIX systems. You need to register a
Hi,everyone, I am learning D.I installed a plugin-visusl D to visual studio 2008.I am very confused that ctrl+z didn't teminate the input of console,it result in a dead loop.When reading from a txt file,a extra line will be read and usually it result in a wrong result.Is there anyone who has experienced such a situation and can tell me what I should pay attention to. Thanks a lot. lx
Jun 24 2013
lx:I am very confused that ctrl+z didn't teminate the input of console,it result in a dead loop.I think this is a library bug, I noticed it some times, but I didn't file it. Maybe it's worth filing in Bugzilla.When reading from a txt file,a extra line will be read and usually it result in a wrong result.Can you show the code? Bye, bearophile
Jun 24 2013
I have added this bug report, is this the issue you are seeing/having? http://d.puremagic.com/issues/show_bug.cgi?id=10467 Bye, bearophileI am very confused that ctrl+z didn't teminate the input of console,it result in a dead loop.I think this is a library bug, I noticed it some times, but I didn't file it. Maybe it's worth filing in Bugzilla.
Jun 24 2013
On Monday, 24 June 2013 at 21:13:31 UTC, bearophile wrote:I don't think this is a bug (I replied on the bug report): terminating the stream doesn't mean terminating the program, and if the program doesn't know how to handle a closed/eof/error'd stdin, it will just loop... This FAQ link explains it pretty well for C++, which is pretty much the same thing as in D: http://www.parashift.com/c++-faq/stream-input-failure.html (the next few points are relevant too). We could argue the design isn't optimal, yes, but it's not bugged.I have added this bug report, is this the issue you are seeing/having? http://d.puremagic.com/issues/show_bug.cgi?id=10467 Bye, bearophileI am very confused that ctrl+z didn't teminate the input of console,it result in a dead loop.I think this is a library bug, I noticed it some times, but I didn't file it. Maybe it's worth filing in Bugzilla.
Jun 24 2013
monarch_dodra:I don't think this is a bugI see. Then lx will have to explain the problem better.(I replied on the bug report):I have given an answer, comparing to Python. I think the current Phobos behavour is bad. Bye, bearophile
Jun 24 2013
On Monday, 24 June 2013 at 21:13:31 UTC, bearophile wrote:I read those information and yes,it is the issue I am having.I should have handled it in right way.Ctrl+z seems close the stream.So,if I want to input another batch of data,it became impossilbe.So,how to reopen the stream again to allow me to input another batch of data? And,another problem:if I input ctrl+c,the code will terminate abnormally.Why this happened? Thanks. lxI have added this bug report, is this the issue you are seeing/having? http://d.puremagic.com/issues/show_bug.cgi?id=10467 Bye, bearophileI am very confused that ctrl+z didn't teminate the input of console,it result in a dead loop.I think this is a library bug, I noticed it some times, but I didn't file it. Maybe it's worth filing in Bugzilla.
Jun 25 2013
On 06/25/2013 09:26 PM, lx wrote:Ctrl+z seems close the stream.So,if I want to input another batch of data,it became impossilbe.So,how to reopen the stream again to allow me to input another batch of data?Making a copy of stdin works on Linux (where the stream is terminated by Ctrl-D in the console): import std.stdio; import std.algorithm; void main() { auto stdin_dup = stdin; stdin .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done"); stdin_dup .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done again"); } Ali
Jun 25 2013
On Wednesday, 26 June 2013 at 04:46:32 UTC, Ali Çehreli wrote:On 06/25/2013 09:26 PM, lx wrote:Hi,Ali,I tried those codes,it doesn't work under win7.The result is "done again" will follow "done",without giving me any chance to input. lxCtrl+z seems close the stream.So,if I want to input another batch of data,it became impossilbe.So,how toreopen thestream again to allow me to input another batch of data?Making a copy of stdin works on Linux (where the stream is terminated by Ctrl-D in the console): import std.stdio; import std.algorithm; void main() { auto stdin_dup = stdin; stdin .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done"); stdin_dup .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done again"); } Ali
Jun 26 2013
On Wednesday, 26 June 2013 at 13:45:41 UTC, lx wrote:On Wednesday, 26 June 2013 at 04:46:32 UTC, Ali Çehreli wrote:Hi,Ali,I tried those codes,it doesn't work under win7.The result is "done again" will follow "done",without giving me any chance to input again after I enter ctrl-z . lxOn 06/25/2013 09:26 PM, lx wrote:Ctrl+z seems close the stream.So,if I want to input another batch of data,it became impossilbe.So,how toreopen thestream again to allow me to input another batch of data?Making a copy of stdin works on Linux (where the stream is terminated by Ctrl-D in the console): import std.stdio; import std.algorithm; void main() { auto stdin_dup = stdin; stdin .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done"); stdin_dup .byLine(KeepTerminator.yes) .copy(stdout.lockingTextWriter); writeln("done again"); } Ali
Jun 26 2013
On 06/25/2013 09:26 PM, lx wrote:I input ctrl+c,the code will terminate abnormally.Why this happened?Ctrl-C appears as SIGINT under POSIX systems. You need to register a handler for that signal: import std.stdio; import std.string; import core.sys.posix.signal; bool isDone = false; extern(C) void mySIGINThandler(int) nothrow system { isDone = true; } void main() { signal(SIGINT, &mySIGINThandler); while (true) { string line = chomp(readln()); if (stdin.eof() || isDone) { break; } else { writefln("Nice line: %s", line); } } } Ali
Jun 25 2013