diff options
author | Norbert Preining <preining@logic.at> | 2009-07-01 05:15:09 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-07-01 05:15:09 +0000 |
commit | ae9ec747ab13e48ba02b4cc23893f0acdc430505 (patch) | |
tree | 64001286f666b001a696f5d58a0300d94a938665 /Master/tlpkg/TeXLive/TLUtils.pm | |
parent | 6435f0b267d4bc786b93e0f180edc13b39d56781 (diff) |
add tlcmp from tlpkg/bin/cmp_textfiles to TLUtils, use it instead of
the call to external diff in tlmgr check runfiles, do the runfile test
if tlmgr check all is done
git-svn-id: svn://tug.org/texlive/trunk@14045 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 9b436d00175..34e9788bb88 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -48,6 +48,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::removed_dirs(@files); TeXLive::TLUtils::download_file($path, $destination [, $progs ]); TeXLive::TLUtils::setup_programs($bindir, $platform); + TeXLive::TLUtils::tlcmp($file, $file); =head2 Installer Functions @@ -123,6 +124,7 @@ BEGIN { &xsystem &run_cmd &announce_execute_actions + &tlcmp ); @EXPORT = qw(setup_programs download_file process_logging_options tldie tlwarn info log debug ddebug dddebug debug_hash @@ -1723,6 +1725,50 @@ sub untar { } +=item C<tlcmp($file, $file)> + +Compare two files considering CR, LF, and CRLF as equivalent. +Returns 1 if different, 0 if the same. + +=cut + +sub tlcmp +{ + my ($filea, $fileb) = @_; + if (!defined($fileb)) { + die <<END_USAGE; +tlcmp needs two arguments FILE1 FILE2. +Compare as text files, ignoring line endings. +Exit status is zero if the same, 1 if different, something else if trouble. +END_USAGE + } + my $file1 = &read_file_ignore_cr ($filea); + my $file2 = &read_file_ignore_cr ($fileb); + + return $file1 eq $file2 ? 0 : 1; +} + + +# Return contents of FNAME as a string, converting all of CR, LF, and +# CRLF to just LF. +# +sub read_file_ignore_cr +{ + my ($fname) = @_; + my $ret = ""; + + local *FILE; + open (FILE, $fname) || die "open($fname) failed: $!"; + while (<FILE>) { + s/\r\n?/\n/g; + #warn "line is |$_|"; + $ret .= $_; + } + close (FILE) || warn "close($fname) failed: $!"; + + return $ret; +} + =item C<setup_programs($bindir, $platform)> |