I want to automate moving duplicate or similar C code into functions.
This must work under Linux.
A subset of your problem: Detecting duplicate code:
Try: PMD
Duplicate code can be hard to find, especially in a large project. But PMD's Copy/Paste Detector (CPD) can find it for you! CPD has been through three major incarnations:
- First we wrote it using a variant of Michael Wise's Greedy String Tiling algorithm (our variant is described here)
...
Note that CPD works with Java, JSP, C, C++, Fortran and PHP code.