subsurface/scripts/whitespace.pl
Dirk Hohndel 933d44083e 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>
2014-02-12 22:33:01 -08:00

11 lines
361 B
Perl

#! /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 ;