Hacker News new | past | comments | ask | show | jobs | submit login

Isn't a string with a newline character automatically multiline?

The new line is just empty but not the first line anymore.




No, it is not.

    3.195 Incomplete Line

    A sequence of one or more non-<newline> characters at the end of the file.

    3.206 Line

    A sequence of zero or more non-<newline> characters plus a terminating <newline> character.
courtesy of [0]. See also [1] for rationale on "text file":

   Text File

   [...] The definition of "text file" has caused controversy. The only difference between text and binary files is that text files have lines of less than {LINE_MAX} bytes, with no NUL characters, each terminated by a <newline>. The definition allows a file with a single <newline>, or a totally empty file, to be called a text file. If a file ends with an incomplete line it is not strictly a text file by this definition. [...]
[0] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...

[1] https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd...


Applications that write "incomplete lines"

- VSCODE

- Visual Studio

- Notepad

C/C++ compilers that process "incomplete lines"

   All of them.
Will my users consider it a bug if my program doesn't process "incomplete lines":

    Yes. (Yes, I have had this bug logged 
    against code that I wrote).
Will I consider it a bug if your program doesn't process "incomplete lines":

    Yes.


> Applications that write "incomplete lines"

Note that all of those three apps come from the Windows world where CRLF was indeed a line separator, and a file ending with CRLF was considered to have an empty line at the end.

But yes, you absolutely should accommodate for incomplete lines.


Not everything uses POSIX maybe that's a reason for the different results.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: