summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-08-04 00:53:19 +0000
committerKarl Berry <karl@freefriends.org>2008-08-04 00:53:19 +0000
commitebf95d1a539a67d13d805b20a21b80fc311e8229 (patch)
tree1b4418ab527c3e09fb1776c80e67c3d98dbd8c6c
parentfce534655df057bec4988cf7850018db3b8a5452 (diff)
do not consider text files with just CR (Mac) line endings different from files with LF or CRLF line endings
git-svn-id: svn://tug.org/texlive/trunk@10058 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/tlpkg/bin/cmp-textfiles45
-rwxr-xr-xMaster/tlpkg/bin/place28
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check5
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: