#!/usr/local/bin/perl # dvicheck -- DVI autotest helper. # $Id: //depot/Master/support/tests/checkdvi.pl#1 $ # # Public domain. # Originally written as a shell script by Patrice Dumas. # Revised version written in Perl by Karl Berry. # # (Although it's much simpler and more functional in sh, Perl makes it # possible to run on Windows, for TeX Live, etc. I hope someone cares # some day.) exit (&main ()); sub main { if (@ARGV != 2) { print <; #warn "read lines from $program @args:\n@lines"; close (PROG) || warn "close($program @args |) failed: $!"; return &clean_dvitype (@lines); } # # Read file, run through clean_dvitype, and return as a string. # sub clean_file { my ($file) = @_; local *FILE; open (FILE, $file) || die "open($file) failed: $!"; # read whole file. my @lines = ; close (FILE) || warn "close($file) failed: $!"; return &clean_dvitype (@lines); } # # Clean dvitype output. Make the first element of LINES be the empty # string (this contains the version number), and excise the first '...' # string (this is the DVI comment, which typically contains the date). # Return resulting string. # sub clean_dvitype { my (@lines) = @_; $lines[0] = ""; for my $line (@lines) { last if $line =~ s/^'.*'//; } my $clean = join ("", @lines); #warn "cleaned lines:\n@lines\ninto:$clean"; return $clean; } # # Save STRING into FILE. This will be the cleaned version, but that's ok. # sub save_file { my ($file,$string) = @_; local *FILE; open (FILE, ">$file") || die "open(>$FILE) failed: $!"; print FILE $string; close (FILE) || warn "close(>$FILE) failed: $!"; }