Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 26, 2010 [Issue 5378] New: File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5378 Summary: File.byLine terminator string Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2010-12-26 07:11:51 PST --- This is the signature of File.byLine: ByLine!(Char,Terminator) byLine(Terminator = char, Char = char) (KeepTerminator keepTerminator = KeepTerminator.no, Terminator terminator = '\x0a'); But on Windows the line terminators are 2 chars long (CR+LF), see: http://en.wikipedia.org/wiki/Newline#Representations So I think the second argument of argument byLine() needs to be a string. This is code I expected to use, that currently is not accepted: import std.stdio; void main() { auto lines = File("test.txt").byLine(File.KeepTerminator.no, "\r\n"); } ---------------- After that bug report, a little enhancement request: generally on Windows I usually open files with Windows-style line terminators, while on Linux I open files with Unix-style line terminators, so if possible a better default for the second argument of byLine() is a string constant that changes according to the operating system. ---------------- A workaround is to open the file in text mode, but I don't know if this works well if you want to open a Windows-style file on Linux: import std.stdio; void main() { auto lines = File("test.txt", "r").byLine(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2011 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |andrei@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 08, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |INVALID --- Comment #1 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-08 01:11:43 PST --- This is by design. The length name is special and defined to return size_t compulsively. You may want to choose a different name instead. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 08, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | --- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-08 01:12:15 PST --- Oops, wrong window. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 16, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-03-16 10:40:03 EET --- Would it be acceptable if we special-cased byLine to strip a trailing \r if the terminator is \n? Often, the programmer doesn't know beforehand if the line terminator of a text file will be \r\n or \n. A behavior close to that of splitLines would be more useful than forcing the programmer to choose an exact terminator sequence. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 18, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 --- Comment #4 from bearophile_hugs@eml.cc 2013-03-17 17:44:06 PDT --- (In reply to comment #3) > Would it be acceptable if we special-cased byLine to strip a trailing \r if the terminator is \n? Probably the problem presented in this issue has various solutions. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 18, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 --- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-18 12:11:08 PDT --- *** Issue 9750 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 08, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Nick Treleaven <ntrel-public@yahoo.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull CC| |ntrel-public@yahoo.co.uk --- Comment #6 from Nick Treleaven <ntrel-public@yahoo.co.uk> 2013-08-08 07:18:09 PDT --- https://github.com/D-Programming-Language/phobos/pull/1458 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 12, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 --- Comment #7 from github-bugzilla@puremagic.com 2013-08-11 19:19:36 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/7f76586e16623894c7b6119014f76ed7bfef527e Fix Issue 5378 - Make File.byLine accept a string terminator Add an overload of byLine without a default argument for terminator. Before, byLine!string tried to instantiate "string terminator = '\n'", which is invalid. Note: This removes the default arguments from ByLine.this, but the constructor was never documented anyway (unlike the range primitives). https://github.com/D-Programming-Language/phobos/commit/5576d899af510de798b0d5aaa8bd13e6caebfbce Merge pull request #1458 from ntrel/byLine-crlf Fix Issue 5378 - Make File.byLine accept a string terminator -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 12, 2013 [Issue 5378] File.byLine terminator string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5378 Nick Treleaven <ntrel-public@yahoo.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation