r5003 - trunk/gta02-core/scripts

werner at docs.openmoko.org werner at docs.openmoko.org
Wed May 20 08:31:59 CEST 2009


Author: werner
Date: 2009-05-20 08:31:59 +0200 (Wed, 20 May 2009)
New Revision: 5003

Added:
   trunk/gta02-core/scripts/psdiff
Log:
Utility to diff two eeschema postscript files. If a file name ends with .gz,
psdiff automatically invokes zcat.



Added: trunk/gta02-core/scripts/psdiff
===================================================================
--- trunk/gta02-core/scripts/psdiff	                        (rev 0)
+++ trunk/gta02-core/scripts/psdiff	2009-05-20 06:31:59 UTC (rev 5003)
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# diff two KiCad eeschema Postscript files. Removals are red, additions are
+# green.
+#
+
+if (@ARGV != 2) {
+    print STDERR "usage: $0 (file_a.ps|file_a.gz) (file_b.ps|file_b.gz)\n";
+    exit(1);
+}
+
+if ($ARGV[0] =~ /\.gz$/) {
+    open(A, "zcat '$ARGV[0]' |") || die "popen: $!";
+} else {
+    open(A, $ARGV[0]) || die "$ARGV[0]: $!";
+}
+
+if ($ARGV[1] =~ /\.gz$/) {
+    open(B, "zcat '$ARGV[1]' |") || die "popen: $!";
+} else {
+    open(B, $ARGV[0]) || die "$ARGV[1]: $!";
+}
+
+($pa, $pb) = (1, 1);
+while (<A>) {
+    push(@a, $_);
+    $pa++ if /showpage/;
+    $a{"$pa:$_"} = 1;
+}
+
+while (<B>) {
+    push(@b, $_);
+    $pb++ if /showpage/;
+    $b{"$pb:$_"} = 1;
+}
+
+($pa, $pb) = (1, 1);
+while (@a && @b) {
+    while (@a) {
+	$a = shift @a;
+	$pa++ if $a =~ /showpage/;
+	last if $a =~ /cleartomark end/;
+	$diff = !$b{"$pa:$a"} && $a !~ /^%/;
+	if ($diff) {
+	    print "1 0 0 setrgbcolor\n";
+	}
+	print $a;
+	if ($diff) {
+	    print "0 0 0 setrgbcolor\n";
+	}
+    }
+    undef $q;
+    while (@b) {
+	$b = shift @b;
+	next if $b =~ /^%/;
+	$pb++ if $b =~ /showpage/;
+	next if $b =~ /showpage/;
+	next if $b =~ /gsave mark/;
+	last if $b =~ /cleartomark end/;
+	if ($b =~ /^[Qq]/) {
+	     $q .= $b;
+	     next;
+	}
+	if (!$a{"$pb:$b"}) {
+	    print $q if defined $q;
+	    undef $q;
+	    # need to set the color before each line
+	    print "0 0.7 0 setrgbcolor\n";
+	    print $b;
+	}
+    }
+    print "0 0 0 setrgbcolor\n";
+    print $b;
+}
+print "1 0 0 setrgbcolor\n";
+print join("\n", @a);
+print "0 0.7 0 setrgbcolor\n";
+print join("\n", @b);


Property changes on: trunk/gta02-core/scripts/psdiff
___________________________________________________________________
Name: svn:executable
   + *




More information about the commitlog mailing list