# $Id: DIFF 1.2 Fri, 18 Jul 1997 15:53:23 -0700 wlee $

#!/usr/local/bin/perl

$from = $ARGV[0];
$to = $ARGV[1];
&sort_net_list($from, "/tmp/$from.$$");
&sort_net_list($to, "/tmp/$to.$$");
system "diff -b /tmp/$from.$$ /tmp/$to.$$";
unlink "/tmp/$from.$$";
unlink "/tmp/$to.$$";

exit;


sub sort_net_list {
  local ($from, $to) = (@_);
  local ($list) = 0;
  local (@list) = ();

  open(F, "$from");
  open(T, ">$to");

  while (<F>) {
    $list || print T;
    if (/^import/) {
      $list = 1;
      @list = ();
      next;
    }
    if (/^\};/) { 
      $list = 0;
      print T sort @list;
      print T;
      next;
    }
    if ($list) {
      push(@list, $_);
    }
  }

  close F;
  close T;
}
