(Main home page - http://www.bigfoot.com/~davidsont/astyle/asbeautifier.html)
ASBeautifier is a C++ port of
the Java-based JSBeautifier.
When indenting source code, we as programmers have a tendency to use both spaces and tab characters to create the wanted indentation. Moreover, some editors by default insert spaces instead of tabs when pressing the tab key, and other editors (Emacs for example) have the ability to "pretty up" lines by automatically setting up the white space before the code on the line, possibly inserting spaces in a code that up to now used only tabs for indentation.
Since the NUMBER of space characters showed on screen for each tab character in the source code changes between editors (until the user sets up the number to his liking...), one of the standard problems facing programmers when moving from one source code editor to another is that code containing both spaces and tabs that was up to now perfectly indented, suddently becomes a mess to look at when changing to another editor. Even if you as a programmer take care to ONLY use spaces or tabs, looking at other peoples source code can still be problematic.
To address this problem when writing C/C++/Java, I created ASBeautifier - a small filter, written in C++, that automatically reindents java source files. The ASBeautifier class can be used from a command line, or it can be incorporated as a class in another C++ program.
ASBeautifier is distributed under the "Artistic License" - the same used by the Perl programming language.
1) Unzip astyle.zip and compile ASBeautifier (read README.txt for instructions).2) Either place the resulting executable file's directory in your PATH system-variable, or move the executable to a directory that appears in your PATH system-variable.
3) Run it with the following syntax:
ASBeautifier [options] < OriginalSourceFile > BeautifiedSourceFileORASBeautifier [options] Foo.java Bar.java AnotherBar.java [ . . . ]The < and > characters are used to redirect the files into standard input and out of standard output - don't forget them!!!
The following options are acceptable:
-j - Indent a Java file.Not specifying any option will bring to C/C++ style indentation, with a default of 4 spaces per indent.-t - Indent using a tab characters.
-s# - Indent using # spaces per indent (i.e. -s2).
-m# - Indent a maximal # spaces in a continuous statement, relatively to the previous line(i.e. -m40)
-ib - Add extra indentation to brackets.
-fs - Flush (i.e. don't indent) 'switch' blocks..
-h - print help message and quit
Reach me at davidsont@bigfoot.com
- There are NO current known bugs.- If you find a bug, please send me a bug-report including an example source code that generates the bug, and I will try to fix it as fast as possible.
- If you find a bug and find a fix for it in the source code, please send me a bug-report together with an example source-code that generates the bug PLUS the corrected ASBeautifier.java file, so that I can learn from it and publish it.
-Thanks to Jim Watson for creating the help message option !!!-Thanks to all the dedicated beta-testers and bug notifiers!!!