From: Norman Walsh Date: Sun, 29 Dec 2002 14:43:34 +0000 (+0000) Subject: Support multiple filenames on a single run X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4259a488b36a62beb6e7e929fc3a2eb354a443d1;p=docbook-dsssl Support multiple filenames on a single run --- 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);