From 933d44083e2f0787c46228ce03f924e8f4f84414 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 12 Feb 2014 22:30:03 -0800 Subject: 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 --- scripts/whitespace.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/whitespace.pl (limited to 'scripts/whitespace.pl') 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 ; -- cgit v1.2.3-70-g09d2