summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcrawl-ref/source/util/checkwhite17
-rwxr-xr-xcrawl-ref/source/util/unbrace26
2 files changed, 35 insertions, 8 deletions
diff --git a/crawl-ref/source/util/checkwhite b/crawl-ref/source/util/checkwhite
index e6397cdc41..a93ef6763f 100755
--- a/crawl-ref/source/util/checkwhite
+++ b/crawl-ref/source/util/checkwhite
@@ -3,8 +3,11 @@ use Encode;
use Text::Tabs;
use Getopt::Std;
-getopt('t'); # this removes -t from @ARGV;
+our ($opt_n, $opt_t);
+getopts('t:n'); # this removes -t and -n from @ARGV;
$tabstop = $opt_t if ($opt_t);
+my $dry_run = $opt_n;
+my $any_bad = 0;
my @files = @ARGV;
unless (@files)
@@ -56,8 +59,14 @@ for (@files)
if ($_ ne $cont)
{
- open F, ">$file" or die;
- print F;
- close F;
+ $any_bad = 1;
+ if (!$dry_run)
+ {
+ open F, ">$file" or die;
+ print F;
+ close F;
+ }
}
}
+
+exit 1 if ($dry_run and $any_bad);
diff --git a/crawl-ref/source/util/unbrace b/crawl-ref/source/util/unbrace
index 7cff755dde..ac73a24fa2 100755
--- a/crawl-ref/source/util/unbrace
+++ b/crawl-ref/source/util/unbrace
@@ -1,7 +1,19 @@
#!/usr/bin/perl -w
+use Getopt::Std;
+our ($opt_n);
+getopts('n');
+my $dry_run = $opt_n;
+my $any_bad = 0;
+
+my @files = @ARGV;
undef $/;
-for $f (grep /\.(cc|h)$/, split /\n/, `git ls-files`)
+unless (@files)
+{
+ @files = (grep /\.(cc|h)$/, split /\n/, `git ls-files`);
+}
+
+for $f (@files)
{
open F, "<", $f or die "Can't read $f\n";
my $old = $_ = <F>;
@@ -47,8 +59,14 @@ for $f (grep /\.(cc|h)$/, split /\n/, `git ls-files`)
if ($old ne $_)
{
print "$f\n";
- open F, ">", $f or die "Can't write $f\n";
- print F;
- close F;
+ $any_bad = 1;
+ if (!$dry_run)
+ {
+ open F, ">", $f or die "Can't write $f\n";
+ print F;
+ close F;
+ }
}
}
+
+exit 1 if ($dry_run and $any_bad);