Skip to content

Conversation

masatake
Copy link
Member

@masatake masatake commented Jun 8, 2025

main: using regex for choosing a parser for the given file name

This change extends --map- option to support regular
expression matching with the full file name.

The original --map- option supports glob based matching
and extension comparison with the file basename.
However, two methods are not enough if the file names are too
generic. See #3287 .

The regular expression passed to --map- must be surround
by % character like

--map-RpmMacros='%(.*/)?macros.d/macros.([^/]+)$%'

If you want to match in a case-insensitive way, append `i' after the second % like

--map-RpmMacros='%(.*/)?macros.d/macros.([^/]+)$%i'

If you want to use % as part of an expression, put \ before % for escaping.

TODO:

  • reconsider name regex, rxpr, or something
  • update ctags.1
  • add Tmain test cases
  • add description to --help
  • extend optlib2c
  • add --list-map-regex
  • add --list-maps
  • add pcre backend

@masatake masatake marked this pull request as draft June 8, 2025 23:34
@masatake masatake changed the title main: using regex for choosing a paser for given file name [WIP] main: using regex for choosing a paser for given file name Jun 8, 2025
This change extends --map-<LANG> option to support regular
expression matching with the full file name.

The original --map-<LANG> option supports glob based matching
and extension comparison with the file basename.
However, two methods are not enough if the file names are too
generic. See universal-ctags#3287 .

The regular expression passed to --map-<LANG> must be surround
by % character like

   --map-RpmMacros='%(.*/)?macros\.d/macros\.([^/]+)$%'

If you want to match in a case-insensitive way, append `i' after
the second % like

   --map-RpmMacros='%(.*/)?macros\.d/macros\.([^/]+)$%i'

If you want to use % as part of an expression, put \ before %
for escaping.

TODO:

- [ ] reconsider name regex, rxpr, or something
- [ ] update ctags.1
- [ ] add Tmain test cases
- [ ] add description to --help
- [X] extend optlib2c
- [X] add --list-map-regex
- [X] add --list-maps
- [ ] add pcre backend

Signed-off-by: Masatake YAMATO <[email protected]>
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

❌ Patch coverage is 54.68750% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.77%. Comparing base (241dfc3) to head (c50f467).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
main/parse.c 50.47% 52 Missing ⚠️
main/options.c 46.80% 25 Missing ⚠️
main/rexprcode.c 78.94% 8 Missing ⚠️
optlib/rpmMacros.c 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4270      +/-   ##
==========================================
- Coverage   85.87%   85.77%   -0.10%     
==========================================
  Files         248      249       +1     
  Lines       63593    63754     +161     
==========================================
+ Hits        54608    54688      +80     
- Misses       8985     9066      +81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant