Skip to content

codespell ignores C/C++ tabs ('\t') in strings #17

Description

@orbitcowboy

I found out, that codespell gives wrong answers in case of a tab is used within a C/C++ string. For example:
test.c:

int main()
{
    std::cout<< "\tTest\n";
}

dict.txt:

ttest->test

Scanning with test.c with codespell gives a wrong result:

$ ../codespell.py dict.txt test.c 
test.c:3: tTest  ==> test

Activity

  1. vinc17fr commented on Jun 4, 2018

    @vinc17fr
    Contributor

    \n should also be ignored.

  2. yarikoptic commented on Feb 24, 2023

    @yarikoptic
    Contributor

    \t issue might have been resolved but I keep hitting this eldest ever issue with \n once in a while, e.g. on /tmp/1.c:

    int main()
    {
        std::cout<< "\tTest\nin here";
    }
    ❯ codespell --version
    2.2.2
    ❯ codespell /tmp/1.c
    /tmp/1.c:3: nin ==> inn, min, bin, nine
  3. DimitriPapadopoulos commented on Feb 27, 2023

    @DimitriPapadopoulos
    Collaborator

    codespell is language-agnostic. Handling escape characters would require to identify the type of each file and adapt --regex or --ignore-regex. A proof of concept could be a shell script identifying the type of each file and calling codespell with the proper --regex and --ignore-regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions