#!/usr/bin/perl # # Copyright (c) 2002, DecisionSoft Limited All rights reserved. # Please see: # http://software.decisionsoft.com/licence.html # for more information. # # # xmldiff: xmldiff program - uses xmlpp # #Change this if xmlpp is not in your current path #for example: $XMLPP = "./xmlpp"; $XMLPP = "xmlpp"; # older versions of less don't support -R, consider -r instead my $pagerCmd = ' | less -R '; use Getopt::Std; getopts('tsncupChHSi'); if ($opt_h || @ARGV != 2) { usage(); } my $diffOpts; if ($opt_n) { $pagerCmd = ''; } if ($opt_u + $opt_c + $opt_s + $opt_p + $opt_C > 1) { print STDERR "Error: Only one mode may be specified\n"; usage(); } # Set diff options if ($opt_u) { $diffOpts .= '-u '; } if ($opt_c) { $diffOpts .= '-c '; } if (!$opt_s) { $diffOpts = "--changed-group-format='%<%>' "; $diffOpts .= " --new-group-format='%>' "; $diffOpts .= "--old-group-format='%<' "; $diffOpts .= "--new-line-format='+ %l\n' "; $diffOpts .= "--old-line-format='- %l\n' "; $diffOpts .= "--unchanged-line-format=' %l\n' "; } if ($opt_C) { $diffOpts = "--changed-group-format='\n<<<<<<<<<<<<<<\n%<==============\n%>>>>>>>>>>>>>>>\n\n' "; $diffOpts .= "--new-line-format='+ %l\n' "; $diffOpts .= "--old-line-format='- %l\n' "; $diffOpts .= "--unchanged-line-format=' %l\n' "; } if($opt_H){ $diffOpts = "--changed-group-format='%<%>' "; $diffOpts .= " --new-group-format='%>' "; $diffOpts .= "--old-group-format='%<' "; $diffOpts .= "--new-line-format='+ %l\n' "; $diffOpts .= "--old-line-format='- %l\n' "; $diffOpts .= "--unchanged-line-format=' %l\n' "; } # Set up xmlpp options my $prettyOpts = $opt_t ? "-t " : ""; $prettyOpts .= $opt_S ? "-S " : ""; $prettyOpts .= $opt_H ? "-H " : ""; $prettyOpts .= "-s -e "; $file1 = "xmlppTEMP1.$$"; $file2 = "xmlppTEMP2.$$"; system("$XMLPP $prettyOpts '$ARGV[0]' > $file1"); system("$XMLPP $prettyOpts '$ARGV[1]' > $file2"); if($opt_H) { print < XML diff
 
EOF

  system("diff -bB $diffOpts $file1 $file2");

print <
  

EOF

} else {

  system("diff -bB $diffOpts $file1 $file2 $pagerCmd");
}


unlink($file1,$file2);

exit($? >> 8);

sub usage {
  print STDERR <