From 909af9dbd2c625153e431883db291ee69ad13562 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 1 Jan 2005 18:35:23 +0000 Subject: [PATCH] small tool to compare to files which are produced for swish-e -S prog git-svn-id: file:///home/dpavlin/private/svn/webpac/trunk@621 13eb9ef6-21d5-0310-b721-a9d68796d827 --- tools/swishdiff.pl | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 tools/swishdiff.pl diff --git a/tools/swishdiff.pl b/tools/swishdiff.pl new file mode 100755 index 0000000..438eaca --- /dev/null +++ b/tools/swishdiff.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl -w + +use strict; +use XML::Simple; +use Data::Diff; +use Data::Dumper; + +die "usage: $0 swish-prog-input-1 swish-prog-input-2" if ($#ARGV < 1); + +my ($file1, $file2) = @ARGV; + +my ($in1, $in2); + +open($in1, $file1) || die "$file1: $!"; +open($in2, $file2) || die "$file2: $!"; + +sub read_record { + my $fh = shift || die; + + my $header = 1; + + my ($path, $size); + + while(<$fh>) { + chomp; + $path = $1 if (/^Path-Name:\s*(.+)$/i); + $size = $1 if (/^Content-Length:\s*(.+)$/); + + if (/^$/) { + $header = 0; + } + + next if ($header); + + print STDERR "$path [$size]\n"; + + my $xml; + my $s = read *{$fh}, $xml, $size; + warn "read differs from decleared size! $s != $size" if ($s != $size); + + $xml =~ s/md5=[a-zA-Z0-9]{32}//gs; + $xml =~ s/_userid=\d+//gs; + + return $xml; + } +} + +while(! eof($in1) && ! eof($in2)) { + my $a = read_record($in1); + my $b = read_record($in2); + + next if ($a eq $b); + + my $diff = Data::Diff->new( XMLin($a), XMLin($b) ); + + my $raw = $diff->raw; + + print Dumper($raw->{diff}) if ($raw->{diff}); +} -- 2.20.1