Rearrange badly designed C code

I have about 12,000 lines of poorly written C code, for example.

initholeend=(mm_footer *) (end-sizeof(mm_footer));
initholeend->magic=MM_MAGIC;
initholestart->used+=amount;

What I would like to do is automatically add spaces around all binary operands and settings:

initholeend = (mm_footer *) (end - sizeof(mm_footer));
initholeend->magic = MM_MAGIC;
initholestart->used += amount;

Is there a recommended tool for this?

Thanks in advance.

+3
source share
5 answers

astyle is not bad.

+4
source

I would recommend uncrustify to you . I am quite pleased with this code improver and provides good results for even more programming languages.

+4
source

IDE ( ) " " . Eclipse - IDE.

+1

(1).

It has about a billion options that should meet your requirements.

+1
source

If you use unix, just open it in vi by turning on the auto-format function. If you are running Windows or Mac, use Codeblocks - or Notepad ++ if you do not like the IDE, which by default uses indentation and color coding to balance pairs.

0
source

Source: https://habr.com/ru/post/1791876/


All Articles