From 1ab4af6719c349f3e204e2c571ff9be40e82a37a Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Sun, 29 Dec 2002 14:43:34 +0000 Subject: [PATCH] Support multiple filenames on a single run --- cvstools/untidy | 64 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/cvstools/untidy b/cvstools/untidy index 944a31c54..05ca15108 100755 --- a/cvstools/untidy +++ b/cvstools/untidy @@ -1,27 +1,57 @@ #!/usr/bin/perl -w -- # -*- Perl -*- -my $filename = pop @ARGV; -my $opts = join(" ", @ARGV); +my @filenames = (); +my $opts = ""; -my $content = ""; - -open (F, "/usr/bin/tidy $opts $filename |"); -while () { - $content .= $_; +while (@ARGV) { + $_ = shift @ARGV; + if (@filenames || !/^-/) { + push (@filenames, $_); + } else { + $opts .= " " if $opts ne ""; + $opts .= $_; + } } -close (F); -if ($content eq '') { - # we must have done an "in-place" tidy - if (open (F, $filename)) { - read (F, $content, -s $filename); +if ($#filenames == 0) { + my $filename = shift @filenames; + my $content = ""; + + open (F, "/usr/bin/tidy $opts $filename |"); + while () { + $content .= $_; + } + close (F); + + if ($content eq '') { + # we must have done an "in-place" tidy + if (open (F, $filename)) { + read (F, $content, -s $filename); + close (F); + } + } + + $content =~ s/(]+>)\s+/$1/sg; + $content =~ s/\s+(<\/a>)/$1/sg; + + open (F, ">$filename"); + print F $content; + close (F); +} else { + system ("/usr/bin/tidy $opts " . join(" ", @filenames)); + foreach my $filename (@filenames) { + if (open (F, $filename)) { + read (F, $content, -s $filename); + close (F); + } + + $content =~ s/(]+>)\s+/$1/sg; + $content =~ s/\s+(<\/a>)/$1/sg; + + open (F, ">$filename"); + print F $content; close (F); } } -$content =~ s/(]+>)\s+/$1/sg; -$content =~ s/\s+(<\/a>)/$1/sg; -open (F, ">$filename"); -print F $content; -close (F); -- 2.50.1