Code refactoring tools for C, usable on GNU/Linux? FOSS preferable

Variations of this question have been asked, but not specific to GNU/Linux and C. I use Komodo Edit as my usual Editor, but I'd actually prefer something that can be used from CLI. I don't need C++ support; it's fine if the tool can only handle plain C.

I really appreciate any direction, as I was unable to find anything. I hope I'm not forced to 'roll' something myself.

NOTE: Please refrain from mention vim ; I know it exists and what its capabilities are. I purposefully choose to avoid vim , which is why I use Komodo (or nano on the servers).


I don't think that a pure console refactoring tool would be nice to use.
I use Eclipse CDT on linux to write and refactor C-Code.
There exists also Xrefactory for Emacs http://www.xref.sk/xrefactory/main.html

if a non console refactoring tool is ok for you as well.


You could consider coding a GCC plugin or a MELT extension (MELT is a domain specific language to extend GCC) for your needs.

However, such approach would take you some time, because you'll need to understand some of GCC internals.


For Windows only, and not FOSS but you said "any direction..."

Our DMS Software Reengineering Toolkit" with its C Front End can apply transformations to C source code. DMS can be configured to carry out custom, complex reliable transformations, although the configuration isn't as easy as typing just a command like "refactor frazzle by doobaz".

One of the principal stumbling blocks is still the preprocessor. DMS can transform code that has preprocessor directives in typical places (around statements, expressions, if/for/while loop heads, declarations, etc.) but other "unstructured conditionals" give it trouble. You can run DMS by expanding the preprocessor directives out of existence, or more imporantly, expanding out the ones that give it trouble, but mostly people don't like this because they prefer to keep thier preprocessor directives. So it isn't perfect.

[Another answer suggested Concinelle, which looks pretty good from my point of view. As far as I know, it doesn't handle preprocessor directives at all; I could be wrong and it might handle some cases as DMS does, but I'm sure it can't handle all the cases].

You don't want to consider rolling your own. Building a transformation/refactoring tool is much harder than you might guess having never tried it. You need full, accurate parsers for the (C) dialect of interest and just that is pretty hard to get right. You need a preprocessor, symbol tables, flow analysis, transformation, code regeneration machinery, ... this stuff takes years of effort to build and get right. Trust me, been there, done that.

链接地址: http://www.djcxy.com/p/57796.html

上一篇: 如何打印到C ++ Builder输出窗口

下一篇: 用于C的代码重构工具,可在GNU / Linux上使用? FOSS更可取