I need a tool to find duplicates or similar blocks of text in a singular text file or set of text files

后端 未结 6 1312
甜味超标
甜味超标 2021-02-06 13:49

I want to automate moving duplicate or similar C code into functions.

This must work under Linux.

6条回答
  •  无人及你
    2021-02-06 14:15

    Be aware that you can't just compare lines of text. You will have to parse the code, in this manner, you could also detect segments that are semantically correct but may have different named identifiers.

    For example, given two functions that are equivalent but use different identifiers, a text search will not see them as identical, but a parser can.

    Also note that writing a C++ parser is not a trivial task, even when given the grammar. I suggest the advice of others and seek out a tool for this. Also search for refactoring tools.

提交回复
热议问题