lineSplitter ignores the the trailing newline?
Jonathan Marler
johnnymarler at gmail.com
Sun Nov 10 20:30:39 UTC 2019
On Sunday, 10 November 2019 at 12:29:12 UTC, Patrick Schluter
wrote:
> On Saturday, 9 November 2019 at 23:07:29 UTC, Jonathan Marler
> wrote:
>> On Saturday, 9 November 2019 at 23:04:11 UTC, Jonathan Marler
>> wrote:
>>> On Saturday, 9 November 2019 at 19:28:52 UTC, Paul Backus
>>> wrote:
>>>> [...]
>>>
>>> Interesting, do you have any links and or references that
>>> establish that unix uses newlines as terminators rather than
>>> separators?
>>
>> Also, if unix is using it as a "terminator" instead of a
>> "separator", if you don't have a trailing newline at the end
>> of the file then the last line wouldn't be "terminated"
>> properly, so should you ignore the last line? Should that be
>> an error?
>>
>> If so, then it sounds like the correct solution for the "tolf"
>> tool is to always make sure the last line is terminated with a
>> newline character. Does that sound correct?
>
> It would be necessary also for most Unices that don't use
> glibc. In a lot of libc implementation (Solaris definitely has
> the bug) fgets() doesn't return correctly the last line if it
> has no line feed. glibc corrects this behaviour so that most
> Linux users don't know about this issue.
Interesting. But it makes sense as it sounds like Unix requires
each line to end with a line feed, so if it's missing, then it's
up to the library whether or not they want to support a
non-standard feature such as a line without a line feed. It
makes sense that some libraries would choose not to support it.
More information about the Digitalmars-d
mailing list