In continuation to my once-upon-a-time post about code indentation here is a quick post.
This is particularly helpful to those of us who get this kick of writing code in a single column indentation, ( some fancy name for hopelessly written code :-| ). I discovered these tools called GNU Indent and Artistic Style, when pulling out my hair reading someone's code.
Perl has a beautifier called Perltidy. I searched for "Is there a ctidy" and that is when I came across the two tools mentioned earlier. GNU Indent seems to be a C only beautifier*.
( * Correct me if I am wrong. I just read the description )
Artistic Style on the other hand works for Java, C, C++ and C#. It is a simple light weight yet powerful code formatter. You can download the source from here. Extract it to a convenient folder. Change directory to build and run make. If you prefer installing in some local location like me, provide the prefix information in install: make prefix=$HOME install. If you don't bother much, just run make install. There you have AS installed.
Running is even simple, (assuming AS is installed in the user's local bin directory)
THAT'S IT!
AS does give plenty of options to format code, I wont go over all of it. Waste of time (:P) feel free to figure it out.
Now that the code is indented, let me figure out what it does!
Adios :)
This is particularly helpful to those of us who get this kick of writing code in a single column indentation, ( some fancy name for hopelessly written code :-| ). I discovered these tools called GNU Indent and Artistic Style, when pulling out my hair reading someone's code.
Perl has a beautifier called Perltidy. I searched for "Is there a ctidy" and that is when I came across the two tools mentioned earlier. GNU Indent seems to be a C only beautifier*.
( * Correct me if I am wrong. I just read the description )
Artistic Style on the other hand works for Java, C, C++ and C#. It is a simple light weight yet powerful code formatter. You can download the source from here. Extract it to a convenient folder. Change directory to build and run make. If you prefer installing in some local location like me, provide the prefix information in install: make prefix=$HOME install. If you don't bother much, just run make install. There you have AS installed.
Running is even simple, (assuming AS is installed in the user's local bin directory)
~/<username>/bin/astyle <source files>
AS does give plenty of options to format code, I wont go over all of it. Waste of time (:P) feel free to figure it out.
Now that the code is indented, let me figure out what it does!
Adios :)
No comments:
Post a Comment