Repository navigation
Recognize *.h.in template files as C source - #55
Open
nikhilanand0105 wants to merge 1 commit into
Open
nikhilanand0105 wants to merge 1 commit into
nikhilanand0105 wants to merge 1 commit into
Conversation
Add *.h.in to the CLexer filename patterns so that C header templates such as config.h.in are correctly identified. Add a data-driven regression fixture for config.h.in. Fixes aboutcode-org/scancode-toolkit#605 Signed-off-by: Nikhil Anand <nikhilanand0105@gmail.com>
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.
Summary
This PR fixes incorrect programming language detection for C header template files such as
config.h.in.Problem
TypeCode correctly identifies
config.has C but fails to recognizeconfig.h.in.Because the
.h.infilename pattern is not registered with the C lexer, Pygments cannot identify the appropriate lexer. Content-based guessing is also skipped when a file extension is present.As a result,
programming_languageis returned as an empty string.Solution
*.h.into the filename patterns ofCLexerinsrc/typecode/pygments_lexers_mapping.py.config.h.inregression fixture.This follows the existing convention used for template files in TypeCode, such as
*.rs.infor Rust.Testing
git diff --check: No errors.Related Issue
Related to aboutcode-org/scancode-toolkit#605
I would appreciate feedback on whether the focused lexer mapping solution is preferred over the broader filename/extension registry approach discussed in the original issue.