Uncrustify - Source Code Beautifier
For C, C++, C#, D, and Java
The goals of this project are simple:
Create a highly configurable, easily modifiable source code beautifier.
Sourceforge project
web site
Download
Uncrustify 0.0.23 source
The change log is here.
What it does:
- Ident code, aligning on parens, assignments, etc
- Align on '=' and variable definitions
- Align structure initializers
- Align #define stuff
- Align backslash-newline stuff
- Reformat comments (a little bit)
- Fix inter-character spacing
- Add or remove parens on return statements
- Add or remove braces on single-statement if/do/while/for statements
- Highly configurable - 118 configurable options as of version 0.0.15
See some example output.
Want to help?
The most helpful way is to try it out and give feedback.
Documentation and examples are available in the source tree, so check it out.
You can find a copy of the configurable parameters here.
Here is the config file for my favorite style.
And one I set up for Linux.
And here is a before and after C source example.
That should give you a pretty good idea of what Uncrustify can do.
If you find a bug, please do the following:
- Reduce the input source file to the minimum that still has the problem
- Use the sourceforget.net bug tracker
- Attach the input source file, the configuration file, and a file that contains the expected output
If you want to add a feature, fix a bug, or implement missing functionality, feel free to do so!
Here are some areas that need attention:
- This web page (yeah, it's lame)
- Examples that can be put on this website to show off what Uncrustify can do
- A logo of some sort
- Anything marked with "Not Usable" or "Not Implemented" in configuration.txt could be implemented.
- Test Java support and provide feedback (or patches!)
- Improve comment formatting (see
output_comment_multi()
in c_output.c)
- Add advanced file ouput (ie, save to a file instead of to stdout)
- Add aligning thresholds
- Anything else that you want to do to make it better?
Portability
I'm pretty sure that I'm not using anything that is OS-specific.
The software has been tested on the following operating systems:
- Linux (Ubuntu)
- QNX (6.2.1)
- OS X (DMG file available thanks to Jim Hopper)
- OpenBSD 3.4
- NetBSD 1.6.1
- Sun Solaris 9
- Windows XP (binary available)
Links