[Issue 10098] byLine should return empty string instead of null when line is empty

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 18 05:35:21 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10098


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|pull                        |
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-09-18 05:35:20 PDT ---
The test-case was invalid, the code worked as-is in 2.060+. Here's a better
example:

-----
import std.stdio;
import std.range;

void main()
{
    auto fn1 = "foo1.txt";
    auto fn2 = "foo2.txt";
    scope(exit) std.file.remove(fn1);
    scope(exit) std.file.remove(fn2);
    std.file.write(fn1, "\n\n\n\n");
    std.file.write(fn2, "a\nb\nc\n");
    auto file1 = File(fn1, "r");
    auto file2 = File(fn2, "r");
    size_t lines1, lines2;

    foreach (char[] line1, char[] line2; zip(StoppingPolicy.longest,
file1.byLine, file2.byLine))
    {
        // line1 or line2 should be null only if the files are exhausted,
        // and not when the lines are empty (tested as true in 2.060+)
        writefln(`line1 is null: %s - "%s"`, line1 is null, line1);
        writefln(`line2 is null: %s - "%s"`, line2 is null, line2);
    }
}
-----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list