Skip to content
C++ C D Objective-C Shell Python Other
Find file
New pull request
Latest commit 9a46c56 @bengardner Merge pull request #372 from ravethetadpole/while_one_liners
add nl_while_leave_one_liners
Failed to load latest commit information.
documentation Handle Java's `synchronized(foo){ ... }` construction
etc Handle Java's `synchronized(foo){ ... }` construction
man Update the year in the man page
osx Add missing osx directory.
scripts Added a script that generates uncrustify_version.h on windows.
src Merge pull request #372 from ravethetadpole/while_one_liners
tests Merge branch 'master' of into npn…
uncrustify.xcodeproj Added fix for issue #124: #124
win32 Run uncrustify on itself using etc/ben.cfg, with a few manual fixes.
.gitignore Updating “.gitignore” for Xcode 4.
AUTHORS Import r1644 from subversion
BUGS Update BUGS a bit
COPYING Import r1644 from subversion
ChangeLog Update changelog
HELP Import r1644 from subversion
INSTALL Import r1644 from subversion Use silent rules instead of nostdinc Re-run on Ubuntu 14.04
NEWS Import r1644 from subversion Add file links to the readme
TESTING Tweaks to the TESTING how-to
aclocal.m4 Re-run on Ubuntu 14.04 Import r1644 from subversion
commit.log Extract the commit log
compile Re-run on Ubuntu 14.04
config.guess Import r1644 from subversion
config.sub Import r1644 from subversion
configure Documentation and script updates for version 0.61. Bump version to 0.61
extras.vpj Add a few files to the workspace
install-sh Re-run on Ubuntu 14.04 Remove the date from token_names.h/ no need to split lines of Rework to build with the latest mingw32.
missing Re-run on Ubuntu 14.04
package.json Added package.json for npm
release-steps.txt Save off changes for version 0.59 Import r1644 from subversion
test-driver Re-run on Ubuntu 14.04
uncrustify.vpj Add ability to get config from UNCRUSTIFY_CONFIG env var to win32
uncrustify.vpw Update SlickEdit project files Import r1644 from subversion
working.txt save off work in the freebsd branch

README for Uncrustify

Post any bugs to the issue tracker found on the project's Sourceforge page:

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:

$ ./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/ 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/ 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.