July 26, 2017 Bug in File.byRecord ? | ||||
---|---|---|---|---|
| ||||
I have a file with empty lines: 2,3 and 5,6 filename.csv (with linenumbers for better view in this message) 1>Joe,Carpenter,300000 2> 3> 4>Fred,Blacksmith,400000 5> 6> Now, if I run: rdmd --eval='"filename.csv".File.byRecord!(string,string,int)("%s,%s,%d").writeln' It prints: [Tuple!(string, string, int)("Joe", "Carpenter", 300000), Tuple!(string, string, int)("Joe", "Carpenter", 300000), Tuple!(string, string, int)("Joe", "Carpenter", 300000), Tuple!(string, string, int)("Fred", "Blacksmith", 400000), Tuple!(string, string, int)("Fred", "Blacksmith", 400000), Tuple!(string, string, int)("Fred", "Blacksmith", 400000)] It happens because code in https://github.com/dlang/phobos/blob/master/std/stdio.d#L297 not checks return value after call formattedRead. Is this a bug? Or I not understand something? |
July 26, 2017 Re: Bug in File.byRecord ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to closescreen | On 07/26/2017 04:51 AM, closescreen wrote: > I have a file with empty lines: 2,3 and 5,6 > > filename.csv (with linenumbers for better view in this message) > 1>Joe,Carpenter,300000 > 2> > 3> > 4>Fred,Blacksmith,400000 > 5> > 6> > > Now, if I run: > rdmd > --eval='"filename.csv".File.byRecord!(string,string,int)("%s,%s,%d").writeln' > > > It prints: > > [Tuple!(string, string, int)("Joe", "Carpenter", 300000), > Tuple!(string, string, int)("Joe", "Carpenter", 300000), > Tuple!(string, string, int)("Joe", "Carpenter", 300000), > Tuple!(string, string, int)("Fred", "Blacksmith", 400000), > Tuple!(string, string, int)("Fred", "Blacksmith", 400000), > Tuple!(string, string, int)("Fred", "Blacksmith", 400000)] > > It happens because code in > > https://github.com/dlang/phobos/blob/master/std/stdio.d#L297 > > not checks return value after call formattedRead. > > Is this a bug? Yes, I think it's a bug. Ali |
Copyright © 1999-2021 by the D Language Foundation