Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rearranging badly styled C code

Tags:

c

coding-style

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.

like image 457
tzwenn Avatar asked May 03 '26 04:05

tzwenn


2 Answers

astyle isn't bad.

like image 124
Jörgen Sigvardsson Avatar answered May 05 '26 17:05

Jörgen Sigvardsson


I would like to recommend you uncrustify. I am quite satisfied with that code beautifier and provides good results for even more programming languages.

like image 44
jdehaan Avatar answered May 05 '26 18:05

jdehaan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!