diff options
Diffstat (limited to 'Master/tlpkg')
-rwxr-xr-x | Master/tlpkg/bin/cmp-textfiles | 45 | ||||
-rwxr-xr-x | Master/tlpkg/bin/place | 28 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 5 |
3 files changed, 64 insertions, 14 deletions
diff --git a/Master/tlpkg/bin/cmp-textfiles b/Master/tlpkg/bin/cmp-textfiles new file mode 100755 index 00000000000..439fa1c0f28 --- /dev/null +++ b/Master/tlpkg/bin/cmp-textfiles @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +# $Id$ +# Public domain. Originally written 2008, Karl Berry. +# Compare two files considering CR, LF, and CRLF as equivalent. +# Used in place and tlpkg-ctan-check in TeX Live. + +exit (&main ()); + +sub main +{ + if (@ARGV != 2) { + warn <<END_USAGE; +Usage: $0 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 + exit $ARGV[0] eq "--help" ? 0 : 2; + } + + my $file1 = &read_file ($ARGV[0]); + my $file2 = &read_file ($ARGV[1]); + + 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 +{ + 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; +} diff --git a/Master/tlpkg/bin/place b/Master/tlpkg/bin/place index 08fdd9b28a2..19646cb6d79 100755 --- a/Master/tlpkg/bin/place +++ b/Master/tlpkg/bin/place @@ -118,25 +118,31 @@ if (!defined($tlpold)) { my @difffiles = `comm -12 $TMP/tlplace.new $TMP/tlplace.old`; chomp (@difffiles); my $sum = 0; + my $identical = 0; + # my $diff_file = "$TMP/tlplace.diff"; unlink ($diff_file); my $diff_cmd = "diff --text --strip-trailing-cr --ignore-all-space -U 0 -s"; - foreach (@difffiles) { - my @foo = `$diff_cmd $M/$_ $cooked/$package/$_ | tee -a $diff_file`; - $sum += $#foo; # zero-based, so first line doesn't count. - } - my $nrcommfiles = @difffiles; # - my $identical; - if (-s $diff_file) { - chomp ($identical = `grep --text 'are identical' $diff_file | wc -l`); - } else { - $identical = 0; + for my $f (@difffiles) { + my $master_file = "$M/$f"; + my $cooked_file = "$cooked/$package/$f"; + # diff has no options for handling Mac line endings; the above + # don't suffice. So use our own script for the initial comparison. + if (system ("cmp-textfiles $master_file $cooked_file") == 0) { + $identical++; + } else { + my @diff_out = `$diff_cmd $master_file $cooked_file | tee -a $diff_file`; + $sum += $#diff_out - 2; # zero-based, so first line doesn't count. + # subtract another two lines for the heading + # and at least one hunk marker. + } } + my $nrcommfiles = @difffiles; # my $changed = $nrcommfiles - $identical; print "$nrcommfiles common files, $changed changed, ~$sum lines different ($diff_file)\n\n\f\n"; - #`rm -f $TMP/tlplace.new $TMP/tlplace.old $TMP/tlplace.diff`; + #`rm -f $TMP/tlplace.new $TMP/tlplace.old $diff_file`; } &xchdir ("$cooked/$package"); diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 3cfa7b054e1..70e778b754a 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -365,9 +365,8 @@ sub do_tlp sub files_differ { my ($tl_file,$ctan_file) = @_; -#warn "comparing $tl_file $ctan_file\n"; - return (system ( - "diff -q --strip-trailing-cr $tl_file $ctan_file >/dev/null") != 0); +#warn "comparing $ctan_file $tl_file\n"; + return system ("cmp-textfiles $ctan_file $tl_file"); } # vim: set ts=8 sw=2 expandtab: |