Skip to content

Fix #671: Missing newline at end of file should produce a warning#672

Open
glankk wants to merge 3 commits into
cppcheck-opensource:masterfrom
glankk:671
Open

Fix #671: Missing newline at end of file should produce a warning#672
glankk wants to merge 3 commits into
cppcheck-opensource:masterfrom
glankk:671

Conversation

@glankk

@glankk glankk commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@firewave firewave linked an issue Jul 9, 2026 that may be closed by this pull request
@firewave

firewave commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

All these stray -1 and \n are really awful and make this feel very wrong.

@danmar

danmar commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

All these stray -1 and \n are really awful and make this feel very wrong.

I am not sure why the -1 are needed. Not saying it's wrong, I just don't understand it.

The \n makes the testcode technically valid. Are you suggestion to remove those and ensure that warnings are written properly?

@firewave

firewave commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

I am not sure why the -1 are needed. Not saying it's wrong, I just don't understand it.

Me neither. Passing less means that the newline would be missing and the other changes add it. That is kind of a flip-flop.

The \n makes the testcode technically valid. Are you suggestion to remove those and ensure that warnings are written properly?

If fiddling with the trailing newline is necessary that seems like a possible source of issues for users of the library.

@glankk

glankk commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

I am not sure why the -1 are needed. Not saying it's wrong, I just don't understand it.

The char arrays that are initialized with a string constant include a null terminator, which makes these test cases fail because they end with '\0' instead of '\n'.

All these stray -1 and \n are really awful and make this feel very wrong.

I agree that it looks really ugly but it's not wrong.

@glankk

glankk commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

I also agree that it's a bit awkward to implement this in simplecpp, since it doesn't really distinguish between C and C++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing newline at end of file should produce a warning

3 participants