lineSplitter ignores the the trailing newline?

Jonathan Marler johnnymarler at
Sat Nov 9 19:00:31 UTC 2019

In people's opinion, should lineSplitter handle files with 
trailing newlines differently or the same?  Currently, 
lineSplitter will ignore the trailing newline.  If it didn't 
ignore it, then I'd expect that a file with a trailing newline 
would return an empty string as its last element, but it doesn't 
do this.

I noticed this because the "tolf" tool in the tools repo uses 
lineSplitter and joins each line with a '\n' character (see  However, 
because lineSplitter ignores the trailing newline, this means it 
will always remove the last trailing newline in the file.  If we 
wanted to keep the trailing newline, then we could add an empty 
string to the lineSplitter range, but then if the original file 
didn't have a trailing newline then it would add one that it 
didn't have before.  This seems like a bug in lineSplitter but 
I'm not sure if everyone would agree.

More information about the Digitalmars-d mailing list