Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Reformat phpbb files to phpbb coding standards
#!/usr/bin/env perl
die "Usage: reformat-phpbb file ..." unless @ARGV;
if ($ARGV[0] == '-8') {
$indent = 8;
shift @ARGV;
} elsif ($ARGV[0] == '-2') {
$indent = 2;
shift @ARGV;
} else {
$indent = undef;
}
undef $/;
for $file (@ARGV) {
open FH, $file or die "Can't open file for reading: $file";
$_ = <FH>;
close FH;
if ($indent) {
$rep = $indent;
} else {
if (/^ {1,3}\S/m) {
$rep = 2;
} else {
$rep = 8;
}
}
s|^(( {$rep})+)|"\t" x (length($1) / $rep)|gem;
s|^(\t*)(.*) \{$|$1$2\n${1}{|gm;
s/^(\t*)} else/\1}\n\1else/gm;
s/^(\t*)$//gm;
open FH, ">$file" or die "Can't open file for writing: $file";
print FH $_;
print $rep;
close FH;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.