home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl501m.zip / OS2 / compare.cmd next >
OS/2 REXX Batch file  |  1995-07-03  |  1KB  |  48 lines

  1. extproc perl5 -Sx
  2. #! perl
  3.  
  4. die "Usage: compare orig-dir actual-dir patchfile\n" unless $#ARGV >= 2;
  5.  
  6. system("rm -rc $ARGV[1]/*.diff");
  7. unlink($ARGV[2]);
  8.  
  9. open(F, "find $ARGV[0] -print |") || die "Cannot find\n";
  10. while (<F>) {
  11.     chop;
  12.     next if m'/\.';
  13.     next if m'/config\.'i;
  14.     next if m'/auto'i;
  15.     next if m'/ext/[^/]*/[^/]*\.(bs|bso|c|so)$'i;
  16.     next if m'/hints/';
  17.     next if m'/pod/';
  18.     next if m'/sdbm/';
  19.     next if m'/patches/';
  20.     next if m'\.orig$';
  21.     next if m'/h2ph$';
  22.     next if -d $_;
  23.     substr($_, 0, length($ARGV[0])+1) = "";
  24.     next unless -r "$ARGV[1]/$_";
  25.     print "$_\n";
  26.     if (compare("$ARGV[0]/$_", "$ARGV[1]/$_")) {
  27.         print "   is different\n";
  28.         system("diff -c $ARGV[0]/$_ $ARGV[1]/$_ > $ARGV[1]/$_.diff");
  29.         system("cat $ARGV[1]/$_.diff >> $ARGV[2]");
  30.     }
  31. }
  32. close(F);
  33.  
  34. sub compare
  35. {
  36.     open(F1, "< $_[0]") or die $_[0];
  37.     open(F2, "< $_[1]") or die $_[1];
  38.     do {
  39.     $l1 = <F1>;
  40.     $l2 = <F2>;
  41.     } while ($l1 eq $l2 && $l1);
  42.     close(F1);
  43.     close(F2);
  44.     return $l1 cmp $l2;
  45. }
  46.  
  47. exit 0;
  48.