Skip to content

Fix handling of CXX comment at EOF without \n#20

Open
pmhahn wants to merge 1 commit intofanf2:masterfrom
pmhahn:fix-eof
Open

Fix handling of CXX comment at EOF without \n#20
pmhahn wants to merge 1 commit intofanf2:masterfrom
pmhahn:fix-eof

Conversation

@pmhahn
Copy link
Copy Markdown

@pmhahn pmhahn commented Oct 7, 2025

If the file ends with a CXX comment (// …) and is not followed by a trailing newline / linefeed, unifdef fails with an error:

$ printf '// bar\n' | ./unifdef
// bar
$ printf '// bar' | ./unifdef
unifdef: [stdin]: 2: EOF in comment
// barunifdef: Output may be truncated

Detect this case and just close the comment in that case.

If the file ends with a CXX comment (`// …`) and is not followed by a
trailing newline / linefeed, `unifdef` fails with an error:
```console
$ printf '// bar\n' | ./unifdef
// bar
$ printf '// bar' | ./unifdef
unifdef: [stdin]: 2: EOF in comment
// barunifdef: Output may be truncated
```

Detect this case and just close the comment in that case.

Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
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.

1 participant