>>>> "SJT" == Stephen J Turnbull
<turnbull(a)sk.tsukuba.ac.jp> writes:
>>>> "mb" == Martin Buchholz
<martin(a)xemacs.org> writes:
mb> Would anyone like to volunteer to do the
testing job?
SJT> I just updated xemacs-packages and 21.2-HEAD, and am doing a make
SJT> world anyway. So I'll apply Martin's patch and do a second round of
SJT> byte-compiling. I'll package up the .elcs, but I am not competent to
SJT> do the audit.
SJT> As a summary, will forcing diff to treat .elcs as text Do The Right
SJT> Thing? Or should I just do a diff -q?
Because I'm excessively careful, I've done a similar exercise in the
past. You want to compare two elc files for differences in the
generated bytecode.
Here's my program elc-cmp (additional hacking may be required):
: #-*- Perl -*-
# Copyright (C) 2000 Martin Buchholz
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with XEmacs; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0;
use strict;
use FileHandle;
use Carp;
(my $myName = $0) =~ s@.*/@@; my $usage="
Usage: $myName FILE1 FILE2
Compares two elc files for equivalence, discarding randomness
introduced by the byte-compiler, such as time stamps and gensyms.\n";
die $usage unless @ARGV == 2;
if (ELCFileContents ($ARGV[0]) eq ELCFileContents ($ARGV[1])) {
exit 0;
} else {
warn "Files differ: @ARGV\n";
WriteStringToFile ("$ARGV[0].1", ELCFileContents ($ARGV[0]));
WriteStringToFile ("$ARGV[0].2", ELCFileContents ($ARGV[1]));
exit 1;
}
sub ELCFileContents {
my $contents = FileContents ($_[0]);
$contents =~ s/^;.*\n//gmo; # Remove comments
$contents =~ s/\#:[a-z0-9-]+//gmo; # Remove gensyms
# Following should be REAL gensyms
$contents =~ s/G[0-9][0-9][0-9][0-9][0-9]?//gmo;
$contents =~ s/\#\$ \. -?[0-9]+//gmo;
$contents =~ s/\#\@[0-9]+//gmo;
return $contents;
}
sub SafeOpen {
open ((my $fh = new FileHandle), $_[0]);
confess "Can't open $_[0]: $!" if ! defined $fh;
return $fh;
}
sub SafeClose {
close $_[0] or confess "Can't close $_[0]: $!";
}
sub FileContents {
local $/ = undef;
open (FILE, "< $_[0]") or confess "$_[0]: $!";
return scalar <FILE>;
}
sub WriteStringToFile {
my $fh = SafeOpen ("> $_[0]");
print $fh $_[1] or confess "$_[0]: $!\n";
SafeClose $fh;
}