Repository navigation
expander.py: don't expand includes inside multi-line comments - #196
Open
ItsDeadlyProgrammer wants to merge 1 commit into
Open
ItsDeadlyProgrammer wants to merge 1 commit into
ItsDeadlyProgrammer wants to merge 1 commit into
Conversation
Fixes atcoder#194. An #include on its own line inside a /* ... */ block was expanded, which also marked that header as included, so a later real #include of it was dropped and the output failed to compile.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #194.
If an
#include <atcoder/...>sits on its own line inside a/* ... */block, expander.py expands it anyway. That also marks the header as included, so a later real#includeof the same header gets skipped and the combined file doesn't compile (the example in the issue fails with'atcoder' has not been declared).This keeps track of whether we're inside a block comment while going through the source, and skips includes on lines that start inside one.
//comments and"..."/'...'literals are skipped while scanning, so something like"/*"in a string doesn't open a comment.Added
test/expander/comment_out_multiline.cppwith the case from the issue, plus a comment opened on the same line after another one, plus"/*"in a string. It fails before the change and passes after. I also checked that the expanded output for the existing test files is unchanged.