This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 127364 - Add to "Blank lines" - add empty line at end of file
Summary: Add to "Blank lines" - add empty line at end of file
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Alexander Simon
URL:
Keywords:
: 186355 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-14 09:49 UTC by avp
Modified: 2016-08-21 11:53 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description avp 2008-02-14 09:49:26 UTC
when GCC parse a file and don't see empty last line he show warning. I propose add to Code style option-Blank lines add
option "add empty last line if she don't exist"
Comment 1 Alexander Simon 2008-11-18 19:40:11 UTC
IMHO formatter should add missing new line in end of file in any case.
Comment 2 Alexey Vladykin 2010-05-21 07:10:55 UTC
*** Bug 186355 has been marked as a duplicate of this bug. ***
Comment 3 Alexey Vladykin 2010-05-21 07:12:46 UTC
Bug 186355 suggests that NB should just add missing new line on saving file, without the need to call formatting.
Comment 4 brucec 2010-05-21 07:25:50 UTC
Note that GCC does *not* want an empty line at the end of the file: it just wants to see a newline character. i.e. it wants to see:

void somefunc(void)\n
{\n
   dostuff();\n
}\n

not:

void somefunc(void)\n
{\n
    dostuff();\n
}\n
\n

What NB currently produces is:

void somefunc(void)\n
{\n
    dostuff();\n
}
Comment 5 dpirch 2016-08-21 11:52:37 UTC
The C standard requires a newline at the end of a file, which is why gcc and clang warn if it is missing:

"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character [...]" (C11, 5.1.1.2.2)

Ideally NetBeans would have would an "Ensure newline at end of file" option for each language, under Tools > Options > Editor > On Save.

There is already a plugin called "EOF Line Feed" for this, which can be enabled through Tools > Plugins > Available Plugins (works in NetBeans 8.1, http://plugins.netbeans.org/plugin/56323/eof-line-feed)