Skip to content

Recognize *.h.in template files as C source - #55

Open
nikhilanand0105 wants to merge 1 commit into
aboutcode-org:mainfrom
nikhilanand0105:fix-605-config-h-in
Open

nikhilanand0105 wants to merge 1 commit into
aboutcode-org:mainfrom
nikhilanand0105:fix-605-config-h-in

Conversation

@nikhilanand0105

Copy link
Copy Markdown

Summary

This PR fixes incorrect programming language detection for C header template files such as config.h.in.

Problem

TypeCode correctly identifies config.h as C but fails to recognize config.h.in.

Because the .h.in filename 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_language is returned as an empty string.

Solution

  • Added *.h.in to the filename patterns of CLexer in src/typecode/pygments_lexers_mapping.py.
  • Added a real-world config.h.in regression fixture.
  • Added a YAML expectation file to verify the detected file properties.

This follows the existing convention used for template files in TypeCode, such as *.rs.in for Rust.

Testing

  • Regression test: 1 passed.
  • Existing C/C++ tests: 18 passed.
  • Ruff: All checks passed.
  • git diff --check: No errors.
  • Full test suite: Three failures were also reproduced on the unmodified baseline.

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.

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>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants