I have six chunks of 52 lines of very similar code that I need to isolate all the differences in.

I've been tackling it by eye, and have it mostly working, but there remains some small difference that I'm not seeing; and I'm going bug-eyed for looking.

Anyone any thoughts how to do a six-way diff?


Everything below is update.

I settled for a low tech solution that worked surprisingly well.

First, I put the six chunks of code into separate files. Then I wrote the following simple Perl script that loaded the lines of those files in to an AoAs: all the line 1s in to one array, all line 2s in to another; and so on; and then printed them to standard out:

#! perl -slw use strict; use Data::Dump qw[ pp ]; my @lines; for my $file ( qw[ x1.js x2.js y1.js y2.js z1.js z2.js ] ){ open FH, '<', $file or die $!; push @{ $lines[ $. ] }, $_ while <FH>; close FH; } for my $l ( @lines ) { next unless defined $l; print @$l; }

What I got after normalising the files and lines -- which was surprisingly quick by referencing the output -- was stuff that looked like this:

E:\Chart>diff6 | more gg = _GetGrid( this.Min.y / this.Parent.Zoom.y, this.Max.y / this.Pare +nt.Zoom.y, this.Scale.y ); gg = _GetGrid( this.Min.z / this.Parent.Zoom.z, this.Max.z / this.Pare +nt.Zoom.z, this.Scale.z ); gg = _GetGrid( this.Min.x / this.Parent.Zoom.x, this.Max.x / this.Pare +nt.Zoom.x, this.Scale.x ); gg = _GetGrid( this.Min.z / this.Parent.Zoom.z, this.Max.z / this.Pare +nt.Zoom.z, this.Scale.z ); gg = _GetGrid( this.Min.x / this.Parent.Zoom.x, this.Max.x / this.Pare +nt.Zoom.x, this.Scale.x ); gg = _GetGrid( this.Min.y / this.Parent.Zoom.y, this.Max.y / this.Pare +nt.Zoom.y, this.Scale.y ); if( this.GridDelta.y != 0 ) gg[1] = this.GridDelta.y; if( this.GridDelta.z != 0 ) gg[1] = this.GridDelta.z; if( this.GridDelta.x != 0 ) gg[1] = this.GridDelta.x; if( this.GridDelta.z != 0 ) gg[1] = this.GridDelta.z; if( this.GridDelta.x != 0 ) gg[1] = this.GridDelta.x; if( this.GridDelta.y != 0 ) gg[1] = this.GridDelta.y; var ii = 0; var ii = 0; var ii = 0; var ii = 0; var ii = 0; var ii = 0; for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { for( var jj = gg[2]; jj >= gg[0]; jj -= gg[1] ) { pp.y = jj * this.Parent.Zoom.y; pp.z = jj * this.Parent.Zoom.z; pp.x = jj * this.Parent.Zoom.x; pp.z = jj * this.Parent.Zoom.z; pp.x = jj * this.Parent.Zoom.x; pp.y = jj * this.Parent.Zoom.y; pp.z = this.Min.z; pp.y = this.Min.y; pp.z = this.Min.z; pp.x = this.Min.x; pp.y = this.Min.y; pp.x = this.Min.x; var vv = this.Parent.ScreenPos( pp ); var vv = this.Parent.ScreenPos( pp ); var vv = this.Parent.ScreenPos( pp ); var vv = this.Parent.ScreenPos( pp ); var vv = this.Parent.ScreenPos( pp ); var vv = this.Parent.ScreenPos( pp ); fromOV( this.Line[4][ii], vv.x, vv.y ); fromOV( this.Line[5][ii], vv.x, vv.y ); fromOV( this.Line[2][ii], vv.x, vv.y ); fromOV( this.Line[3][ii], vv.x, vv.y ); fromOV( this.Line[0][ii], vv.x, vv.y ); fromOV( this.Line[1][ii], vv.x, vv.y ); ...

I piped that into a file, wrapped it into a subroutine and eliminated the duplicates, then went through the sets of lines with differences and parameterised them one at a time. The result is:

Where first six lines are the call sites and the rest the fully parameterised function.

And the best bit: IT WORKS!

The names need work, but that's true for all the names in the library. And a job for tomorrow.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

In reply to Six way diff? (Solved. Low-tech rules!) by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.