Skip to content
C++ C D Objective-C Shell Python Other
Pull request Compare This branch is 1 commit ahead of uncrustify:master.
Latest commit a78d4e6 May 27, 2016 @bengardner parse_pawn_pattern: do not include an escaped newline
This was getting parsed wrong, as the backslash was included as part of the
pattern.

#define x(%0,%1)\
    y(%1,%0)
Failed to load latest commit information.
documentation for 0.63 May 10, 2016
etc Merge pull request #461 from todd-richmond/master May 27, 2016
man Don't use backslash in Unix file path in the man page May 19, 2016
osx Add missing osx directory. Oct 25, 2009
scripts Merge pull request #484 from dirk-thomas/make_token_names_py May 27, 2016
src parse_pawn_pattern: do not include an escaped newline May 27, 2016
tests parse_pawn_pattern: do not include an escaped newline May 27, 2016
uncrustify.xcodeproj modernize Xcode project, include required source files missing from p… Apr 8, 2016
win32 add missing files to Visual Studio project files May 17, 2016
.gitattributes Add gitattributes file May 25, 2016
.gitignore Add executable sanity check test file to .gitignore Apr 2, 2016
.travis.yml travis.yml: fix typeo Mar 15, 2016
AUTHORS Import r1644 from subversion Oct 17, 2009
BUGS Update BUGS a bit Oct 14, 2014
CMakeLists.txt Add CMake script May 25, 2016
COPYING Import r1644 from subversion Oct 17, 2009
ChangeLog The proposal #477 is implemented. May 26, 2016
Comments.txt prepare the configuration file for the sources Apr 25, 2016
HELP Import r1644 from subversion Oct 17, 2009
INSTALL Simplify expressions such as: May 2, 2016
Makefile.am Adding README.md to the distribution Mar 27, 2016
NEWS Import r1644 from subversion Oct 17, 2009
README.md Updated build steps Mar 14, 2016
TESTING Tweaks to the TESTING how-to Aug 26, 2011
autogen.sh Import r1644 from subversion Oct 17, 2009
commit.log Update ChangeLog and commit.log Feb 2, 2016
compile The issue is similar to bug #651 May 16, 2016
config.guess Import r1644 from subversion Oct 17, 2009
config.sub Import r1644 from subversion Oct 17, 2009
configure.ac Prepare 0.63 May 10, 2016
extras.vpj Add a few files to the workspace Jan 1, 2013
forUncrustifySources.cfg uncrustify all the sources with forUncrustifySources.cfg Apr 27, 2016
forUncrustifySources.txt uncrustify all the sources with forUncrustifySources.cfg Apr 27, 2016
install-sh Test data for Issue #478 May 17, 2016
make_token_names.sh Remove the date from token_names.h/make_token_names.sh Dec 28, 2012
make_version.py make_version.py: no need to split lines of uncrustify_version.h.in Aug 21, 2014
make_win32.sh Rework make_win32.sh to build outside of the source tree. Feb 2, 2016
missing The issue is similar to bug #651 May 16, 2016
package.json Added package.json for npm Feb 18, 2015
release-steps.txt The issue #411 is partialy fixed. May 12, 2016
run_tests.sh Import r1644 from subversion Oct 17, 2009
test-driver Test data for Issue #478 May 17, 2016
uncrustify.vpj Add ability to get config from UNCRUSTIFY_CONFIG env var to win32 Dec 29, 2011
uncrustify.vpw Update SlickEdit project files Oct 8, 2011
working.txt save off work in the freebsd branch Dec 5, 2009

README.md

README for Uncrustify

Post any bugs to the issue tracker found on the project's Sourceforge page: http://sourceforge.net/projects/uncrustify

Please include the following with your issue:

  • a description of what is not working right
  • input code sufficient to demonstrate the issue
  • expected output code
  • configuration options used to generate the output

If the issue cannot be easily reproduced, then it isn't likely to be fixed.

Building the program

Quick start:

$ ./autogen.sh
$ ./configure
$ make

The executable is src/uncrustify. Copy that to your ~/bin/ folder or wherever you want.

Building the program using Xcode on Mac OS X

You can of course just open the Xcode project and build uncrustify using the default 'Debug' configuration but if you want to install it the 'Install' configuration will not work from within Xcode.

For that you will have to use the Xcode command line tool 'xcodebuild'.

To do that, cd into the uncrustify project folder where uncrustify.xcodeproj resides and enter the following command:

$ sudo xcodebuild -configuration 'Install'

You will be prompted for the root level password. By doing this you will install uncrustify into /usr/local/bin. The install location can be changed by editing the Build Settings for the uncrustify target. The setting you need to change is called, surprisingly enough, 'Installation Directory'.

Configuring the program

Examine the example config files in etc (such as ben.cfg) and/or read configuration.txt. Copy the existing config file that closely matches your style and put in ~/.uncrustify/. Find complete configuration file options in this file. Modify to your liking.

Running the program (and refining your style)

As of the current release, I don't particularly trust this program to not make mistakes and screw up my whitespace formatting.

Here's how to run it:

$ uncrustify -c ~/.uncrustify/mystyle.cfg -f somefile.c > somefile.c.unc

The -c option selects the configuration file. The -f option specifies the input file. The output is sent to stdout. Error messages are sent to stderr.

Use a quality side-by-side diff tool to determine if the program did what you wanted. Repeat until your style is refined.

Running the program (once you've found your style)

Write a script to automate the above. Check out etc/dofiles.sh for an example. That script is used as follows:

  1. navigate one level above your project
  2. make a list of file to process $ find myproj -name "*.[ch]" > files.txt
  3. $ sh etc/dofiles.sh files.txt
  4. Use your favorite diff/merge program to merge in the changes $ xxdiff out/myproj myproj
Something went wrong with that request. Please try again.