summaryrefslogtreecommitdiffstats
path: root/scripts/whitespace.pl
blob: ad53804424ece774f2ce0bac5127346c476aa83e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#! /usr/bin/perl

my $input = $ARGV[0];
my $source = `clang-format $input`;
$source =~ s/^(.*each.*\(.*\).*)\n\s*{\s*$/$1 {/img;
$source =~ s/^(\s*struct.*)\n\s*{\s*$/$1 {/img;
$source =~ s/^(\s*class.*)\n\s*{\s*$/$1 {/img;
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
open (DIFF, "| diff -u $input -");
print DIFF $source ;