Page MenuHomePhabricator

Fix no newline at end of file warning
Closed, ResolvedPublic

Description

Older compilers warn if a file does not end with an empty line.

Since the Mitk core library treats warnings as errors, the compilation of Mitk will fail on such systems.

Event Timeline

We should think of adding a git hook for checking the existence of a newline.

This probably relates with a general tooling support for checking source code style.

Script to add a new line to files without new lines at the end.

Hi Sascha, does the attached script help? For me it changed 199 files. However, there is only any point running it, if a commit hook is in place?

Matt

Hi, thanks for the script. I use the following script yesterday already :-)

#!/bin/bash

for i in find . -iname *.h -or -iname *.cpp -or -iname *.txx -or -iname *.cxx -or -iname *.c ; do

if diff /dev/null "$i" | tail -1 | grep '^\\ No newline' > /dev/null; then
  echo $i;
  echo >> $i;
fi;

done

I just wanted to merge, but still have to remove tabs which weren't checked for in the past, but are now blocked by a git hook.

We will add a git hook for the newline next week.

Excellent. I think this is quicker for me than compiling a new compiler on two different architectures :-)

M@

[5dd591]: Merge branch 'bug-12044-fix-no-newline-warning'

Merged commits:

2012-05-30 15:51:04 Sascha Zelzer [d1ff84]
Added missing newline characters.

If there are new files with missing newlines added to the repo before we can install the git hook, just reopen the bug.

MITK-1-0 keyword is obsolete, we use Target Milestones in the future.