Missing newline check

Michael Reeves reeves.87 at gmail.com
Wed Dec 12 16:30:00 GMT 2018


In unix context that probably makes sense for comparability. Especially for
commandline tools. In any event I use vscode which can silently and this.
Give that it must be there it makes sense to just have it happen on its
own. I already do this with code formatting. Its nice not to have to
constantly think about it while coding.

On Tue, Dec 11, 2018, 3:11 AM David Faure <faure at kde.org wrote:

> "cat file1.cpp file2.cpp > file3.cpp" will be broken in the contexts in
> which
> you don't support that file1.cpp should end with a newline.
>
> IMHO text editors should (and most do) just ensure a newline is present at
> the
> end so that this all works without human intervention.
>
> David.
>
> On lundi 10 d├ęcembre 2018 13:47:46 CET Michael Reeves wrote:
> > Thanks for the reply in my view not treating endof file as newline is a
> > flaw in the standard itself. But that's not my call for a kde app. I will
> > not be supporting this outside kde context with regard to source files.
> >
> > On Mon, Dec 10, 2018, 6:30 AM Boudhayan Gupta <bgupta at kde.org wrote:
> > > Hi Michael,
> > >
> > > In Unix, text files are defined as a file containing *lines* of text
> [1].
> > > Necessarily, this means that a character is required to signify the
> end of
> > > line, which just happens to be the '\n' character.
> > >
> > > Practically, this means certain Unix utilities, (although the GNU ones
> are
> > > smart about this) will not count your last line, since it doesn't end
> with
> > > a newline. GNU utilities try to sanitise your input by adding newlines
> > > anyway (so the output of `printf "b\na" | sort | wc -c` is different
> from
> > > the output of `printf "b\na" | wc -c`), and then there are countless
> > > scripts out in the wild that, depending on how they're written, will
> try
> > > to match a line using the newline character at the end.
> > >
> > > In short, if it doesn't end with a newline character, by definition
> it's
> > > not a line, and standards-compliant scripts and utilities are free to
> > > ignore it.
> > >
> > > Also in my private opinion, "modern" tools which don't get tripped up
> by
> > > this are just contributing to sloppiness by developers, and also the
> lack
> > > of awareness as to why you need a newline, and then you have devs
> who're
> > > scratching their heads wondering why their stuff doesn't work when
> they're
> > > forced to use one old tool that doesn't cover up for this
> sloppiness... so
> > > the fact that Krazy is complaining loudly about this is a *very good*
> > > thing.
> > >
> > > Thanks,
> > > Boudhayan
> > >
> > > [1]:
> > >
> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#ta
> > > g_03_392>
> > > On Mon, 10 Dec 2018 at 09:56, Michael Reeves <reeves.87 at gmail.com>
> wrote:
> > >> Why is krazy still checking for newlines at the end of files? Modern
> > >> tools don't seem to get tripped up by this.
> > >>
> > >> http://ebn.kde.org/krazy/reports/kdereview/kdiff3/src/index.html
>
>
> --
> David Faure, faure at kde.org, http://www.davidfaure.fr
> Working on KDE Frameworks 5
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20181212/e3f160b4/attachment.htm>


More information about the kde-core-devel mailing list