Skip to content

Fix preprocessor statements close to empty lines - #15

Merged
Scylardor merged 2 commits into
Scylardor:masterfrom
psettle:master
Aug 26, 2021
Merged

Fix preprocessor statements close to empty lines#15
Scylardor merged 2 commits into
Scylardor:masterfrom
psettle:master

Conversation

@psettle

@psettle psettle commented Aug 21, 2021

Copy link
Copy Markdown
Contributor

I know this situation wouldn't typically come up for well designed C/C++ source... I am up to no good:

MarcosCosmos/cg-cpp-bundler#2

Preprocessor statement after non-preprocessor statements with empty
lines in between would result in the preprocessor statement being
appended to the end of the non-proprocessor statement:

  int demo();

  #include<vector>

Would be incorrectly minified to

  int demo();#include<vector>

This change updates the pre-process fix logic to apply new lines
more generally, and then adds a post processing step to remove
excessively long series of new lines.

Type: Bug Fix
C/C++ use ?, : and :: as 'operators' in a few different contexts.

Added these operators to the supported operator list, and added a
unit test case that spans a variety of valid places these operators
could appear.

Type: New Feature
@Scylardor
Scylardor merged commit bdde9e6 into Scylardor:master Aug 26, 2021
@Scylardor

Scylardor commented Aug 26, 2021

Copy link
Copy Markdown
Owner

Thanks for the PR !
I checked and it works fine.

However I just wanted to stress that this is first and foremost a C minifier and not really a C++ minifier.
So it's great that it still works for the small subset you included into it.
But just wanted to stress that I initially had no intention to open this can of worms.

Great work

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.

2 participants