#!/usr/local/bin/perl
# -*-Fundamental-*-

# CAVEAT - this is not a "finished" tool by any stretch of the
# imagination, and there is virtually 0 chance you'll be able to use
# it in your own context without tweaking it. (AT LEAST the pathnames
# in the main while() loop at the bottom!)
#

#  perl_template - please see the comment at the end!

#eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
#  & eval 'exec perl -S $0 $argv:q'
#  if 0;
#  THE PRECEEDING STUFF EXECS perl via $PATH

use Carp;
$| = 1;

($Myname = $0) =~ s%^.*/%%;

$Usage = <<LIT;
$Myname: usage: $Myname
LIT


sub usage
{
  print STDERR $Usage;
  exit 1;
}


sub help
{
  print STDERR <<LIT;
$Usage
$Myname is...
LIT
  exit 1;
}


sub same
{
  my ($f1, $f2) = @_;

  if (! (-T $f1 && -T $f2))
    {
      my $cmd = "/bin/cmp $f1 $f2";
#      print STDERR "$Myname: binary compare: $cmd\n";
      return ! (system $cmd);
    }


#  print STDERR "$Myname: text compare: $f1 $f2\n";

  if (! open(Y, "<$f1"))
    { print STDERR "$Myname: can't open \"$f1\": $!\n"; return 0; }
  if (! open(T, "<$f2"))
    { close Y; print STDERR "$Myname: can't open \"$f2\": $!\n"; return 0; }

  while (<Y>)
    {
      $y_ = $_;
      $t_ = <T>;
      $y_ =~ s/\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State).*\$/\$XXX\$/g;
      $t_ =~ s/\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State).*\$/\$XXX\$/g;
      if ($y_ ne $t_) { close Y; close T; return 0; }
    }

  $t_ = <T>;

  close Y; close T;
  if ($t_ eq "") { return 1; } else { return 0; }
}


# option switch variables get defaults here...

$Valopt = "default";
$Boolopt = 0;

while ($#ARGV >= 0)
  {
    if ($ARGV[0] eq "-boolopt")    { $Boolopt = 1; shift; next; }
    elsif ($ARGV[0] eq "-valopt")
      {
        shift; if ($ARGV[0] < 0) { &usage; }
        $Valopt = $ARGV[0]; shift; next;
      }
    elsif ($ARGV[0] eq "-help")
      { &help; }
    elsif ($ARGV[0] =~ /^-/) { &usage; }
    if ($Args ne "") { $Args .= " "; }
    push(@Args, $ARGV[0]);
    shift;
  }


while (<>)
  {
    chop;
    $file = $_;
    if (! &same("/rlse/4.3.3/$file", "/rlse/4.3.4/$file"))
      { print "\n\n===== $file\n"; system "diff /rlse/4.3.3/$file /rlse/4.3.4/$file"; }
    else
      { print "$file OK\n"; }
  }
 

#
#  Note to the esteemed reader:
#
#  This file is a quick-start template perl script, meant to make it
#  easy to get a new script off the ground. It's _also_ quite
#  possible, therefore, that you're looking at a *descendant* of
#  "perl_template", which might explain certain oddities. (E.g., code
#  with variable names like):
#
#    my $Valopt = "default";
#    my $Boolopt = 0;
#
#  (or other cruft that seems to have nothing to do with the task at
#  hand, or incomplete usage information, and so on. Different script
#  based hereupon will be finished to different levels of goodness,
#  depending on the intended purpose, lifetime, audience, my whims,
#  and the time avialable for applying a spit-shine.
#