diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-02-12 22:30:03 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-12 22:33:01 -0800 |
commit | 933d44083e2f0787c46228ce03f924e8f4f84414 (patch) | |
tree | 57fdeb780f445049eea8b52e26a87c549d667924 /scripts | |
parent | 23baf20f569f1f34ab4efa68996f24c3ad49fe05 (diff) | |
download | subsurface-933d44083e2f0787c46228ce03f924e8f4f84414.tar.gz |
Add a simplistic tool to clean up whitespace
This hasn't been tested enought, but it seems to get really close.
It assumes that clang-format is in your patch.
Run
perl scripys/whitespace.pl FILENAME
and you'll get a diff of what it things is wrong with that file.
If you like what you see, simply pipe the output into patch -p0
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/whitespace.pl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/whitespace.pl b/scripts/whitespace.pl new file mode 100644 index 000000000..1d6548092 --- /dev/null +++ b/scripts/whitespace.pl @@ -0,0 +1,11 @@ +#! /usr/bin/perl + +my $input = $ARGV[0]; +my $source = `clang-format $input`; +$source =~ s/^(.*each.*\(.*\).*)\n\s*{\s*$/$1 {/img; +$source =~ s/^(.*struct.*)\n\s*{\s*$/$1 {/img; +$source =~ s/^(.*class.*)\n\s*{\s*$/$1 {/img; +$source =~ s/^(\S*::\S*.*)\n\s*: /$1 :\n\t/img; +$source =~ s/(?:\G|^)[ ]{6}/\t/mg; +open (DIFF, "| diff -u $input -"); +print DIFF $source ; |