Reputation: 303
I've got around 12,000 lines of badly styled C code, e.g.
initholeend=(mm_footer *) (end-sizeof(mm_footer));
initholeend->magic=MM_MAGIC;
initholestart->used+=amount;
What I'd like to do is automatically adding spaces around all binary operands and assigments:
initholeend = (mm_footer *) (end - sizeof(mm_footer));
initholeend->magic = MM_MAGIC;
initholestart->used += amount;
Is there any recommended tool to do so?
Thanks in advance.
Upvotes: 3
Views: 346
Reputation: 625
If using unix, just open it up in vi with the autoformat feature turned on. If you're on Windows or Mac, use Codeblocks --or Notepad++ if you don't like IDEs -- where indentation and color coding for paren balancing is the default.
Upvotes: 0
Reputation: 41749
The classic answer is indent(1).
It has about a billion options, which should handle your requirements
Upvotes: 1
Reputation: 19928
I would like to recommend you uncrustify. I am quite satisfied with that code beautifier and provides good results for even more programming languages.
Upvotes: 4
Reputation: 272487
Most IDEs (and several command-line options) have an option to "auto-format" code according to a coding style of your choice. Eclipse is one such IDE.
Upvotes: 1