Skip to content

expander.py: don't expand includes inside multi-line comments - #196

Open
ItsDeadlyProgrammer wants to merge 1 commit into
atcoder:masterfrom
ItsDeadlyProgrammer:fix-expander-multiline-comment
Open

ItsDeadlyProgrammer wants to merge 1 commit into
atcoder:masterfrom
ItsDeadlyProgrammer:fix-expander-multiline-comment

Conversation

@ItsDeadlyProgrammer

Copy link
Copy Markdown

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 #include of 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.cpp with 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.

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

No deployments
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.

expander.pyが複数行コメントアウトされたincludeを展開してしまう

1 participant