Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake header #1491

Merged
merged 2 commits into from
Aug 23, 2020
Merged

Fix cmake header #1491

merged 2 commits into from
Aug 23, 2020

Conversation

roskakori
Copy link
Contributor

The current regex to guess CMake by header has several flaws this patch fixes:

  • Version number can have multiple digits.
  • Tabs are handled as white space.
  • Trailing comments are ignored.

Reference: https://cmake.org/cmake/help/v3.13/manual/cmake-language.7.html#syntax

* Version number can have multiple digits.
* Tabs are handled as white space.
* Trailing comments are ignored.
r'^[ \t]*CMAKE_MINIMUM_REQUIRED[ \t]*'
r'\([ \t]*VERSION[ \t]*\d+(\.\d+)*[ \t]*'
r'([ \t]FATAL_ERROR)?[ \t]*\)[ \t]*'
r'(#[^\n]*)?$'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this last expression for? Consume an arbitrary number of comments? Is that really needed for the analysis?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please shed some more light on this?

Copy link
Contributor Author

@roskakori roskakori Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to ignore comments at the end of the line, e.g. in

cmake_minimum_required(version 3.13)  # CMake version check

including an empty comment at the end of the line:

cmake_minimum_required(version 3.13)  #

@Anteru Anteru merged commit 2a762c5 into pygments:master Aug 23, 2020
@Anteru
Copy link
Collaborator

Anteru commented Aug 23, 2020

Thanks, merged!

@Anteru Anteru self-assigned this Aug 23, 2020
@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Aug 23, 2020
@Anteru Anteru added this to the 2.7 milestone Aug 23, 2020
@Anteru Anteru removed the changelog-update Items which need to get mentioned in the changelog label Sep 3, 2020
Kenny2github pushed a commit to Kenny2github/pygments that referenced this pull request Sep 22, 2020
* Fixed guessing of CMake by header.

* Version number can have multiple digits.
* Tabs are handled as white space.
* Trailing comments are ignored.

* Cleaned up regex to detect CMake header.
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.

None yet

2 participants