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

feat: Remove largest duplicate substr of reg name #268

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shaydonb
Copy link

@shaydonb shaydonb commented Jan 10, 2025

Problem: Sometimes register names contain duplicate strings that unnecessarily lengthen them.

Solution: Remove the largest duplicated substring, with a specified delimiter to avoid removing mere duplicated characters.

Testing: Unit-level test of helper function, integration level test with SVD file in and expected out.

Issues: Closes #267.

@shaydonb shaydonb force-pushed the feat/remove-duplicates branch from 603e2fb to 1f9bdf8 Compare January 10, 2025 06:43
Problem: Sometimes register names contain duplicate strings that
unnecessarily lengthen them.

Solution: Remove the largest duplicated substring, with a specified
delimiter to avoid removing mere duplicated characters.

Testing: Unit-level test of helper function, integration level test with
SVD file in and expected out.

Issues: Closes rust-embedded#267.
@shaydonb shaydonb force-pushed the feat/remove-duplicates branch from 1f9bdf8 to 0e3ac47 Compare January 10, 2025 07:04
Comment on lines +481 to +483
// Define a regex to match duplicated groups of underscore-separated words
// As it turns out, this is not viable since backreferences are not supported by Regex in Rust
// let re = Regex::new(r"(?i)(\b(?:\w+_)+\w+)_\1").unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Sounds not very good.

As for me this case looks too specific. What vendor do this?

Some time ago I was thinking about some more common way like supporting regex based replace. Something like:

PER:
  _replace:
    "REGSPEC*":
      name: # what string entry to process
        "namematch": "to"  # first replacement
        "namematch2": "to2"  # second replacement
      description:
        "descmatch": "to"

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.

Create a remove duplicates functionality
3 participants