Created
April 7, 2011 17:56
-
-
Save cyborch/908323 to your computer and use it in GitHub Desktop.
While not a robust beautify library - this small snippet takes care of most cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
@_=<STDIN>; | |
$_=join("",@_); | |
# fix K&R style code | |
s/\s*\n\s*{/ {/gs; | |
s/}\s*\n\s*else/} else/gs; | |
s/ ?\){/\) {/g; | |
# convert "if( something ){" to "if (something) {" | |
s/if\( ?/if \(/g; | |
# ensure that "{" at end of line is preceeded by a space | |
s/([^ ]){\n/$1 {\n/gs; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment