GDiff

I recently ported Brian Schroeder’s great GDiff
(http://ruby.brian-schroeder.de/gdiff/) program to Windows with just
one small problem: it doesn’t work. The required extension (Zed S.'s
suffix array) needed some minor changes to compile with silly MS VC++
6 and then everything seemed to be working except the GDiff files
produced when running the program look invalid.

The gpatch command and the tests with gdiff have never worked but that
was ok for me because gdiff worked under Linux and I wrote a gpatch in
C. Now I really need gdiff to run on Windows (my gpatch runs on an ARM
inside a device).

Now for the Windows port:
I did some basic tests with the suffix array and it looks functional.
I don’t have comprehensive tests.

Running the gdiff test suite gives this on both platforms:

Loaded suite tc_gdiff
Started
E…E.
Finished in 13.757589 seconds.

  1. Error:
    test_big(TC_GDiff):
    NoMethodError: undefined method operations' for #<Diff::GDiff:0x402ba89c> /usr/local/lib/site_ruby/1.8/gdiff.rb:244:in to_s’
    tc_gdiff.rb:27:in `test_big’

  2. Error:
    test_pack_unpack(TC_GDiff):
    NoMethodError: undefined method operations' for #<Diff::GDiff:0x402b8074> /usr/local/lib/site_ruby/1.8/gdiff.rb:244:in to_s’
    tc_gdiff.rb:36:in test_pack_unpack' tc_gdiff.rb:32:in each’
    tc_gdiff.rb:32:in `test_pack_unpack’

7 tests, 26 assertions, 0 failures, 2 errors

My next thought was to require breakpoint in lib/gdiff.rb on both
platforms and have them stop at some crucial places so I could inspect
the state. But when I put “breakpoint” on a line, suddenly this error
occurred:

lesliev@redebo:~/svnroot/bootpatcher/test$ ./gdiff_t one.bin two.bin

patch.bin
/usr/local/lib/site_ruby/1.8/gdiff_t.rb:246:in to_s': undefined method operations’ for #Diff::GDiff:0x4041c87c (NoMethodError)
from /usr/lib/ruby/1.8/irb.rb:270:in prompt' from /usr/lib/ruby/1.8/irb.rb:265:in gsub!’
from /usr/lib/ruby/1.8/irb.rb:265:in prompt' from /usr/lib/ruby/1.8/irb.rb:114:in eval_input’
from /usr/lib/ruby/1.8/irb.rb:103:in call' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:200:in prompt’
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:214:in initialize_input' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:221:in each_top_level_statement’
… 10 levels…
from /usr/local/lib/site_ruby/1.8/breakpoint.rb:537:in
breakpoint' from /usr/local/lib/site_ruby/1.8/gdiff_t.rb:193:in initialize’
from ./gdiff_t:25:in `diff’
from ./gdiff_t:25

  • very similar to the tests.

So much for platform Independence! I have tried to contact Brian
without success and now I’m running out of time.

Any suggestions?

Les

On 5/19/06, Leslie V. [email protected] wrote:

So much for platform Independence! I have tried to contact Brian
without success and now I’m running out of time.

Any suggestions?

Gonzalo sent me a ported suffix array and the tests and it all works
very well - although Gdiff still produces broken files. I am going to
go through it and try to debug it.

Is there some difference between how Ruby handles binary files on
Windows and on Linux? Could it be ios.binmode? I am going to give it a
try…

On 5/20/06, Leslie V. [email protected] wrote:

Is there some difference between how Ruby handles binary files on
Windows and on Linux? Could it be ios.binmode? I am going to give it a
try…

Working better now… the patch files are very similar…

On 5/20/06, Leslie V. [email protected] wrote:

go through it and try to debug it.

Is there some difference between how Ruby handles binary files on
Windows and on Linux? Could it be ios.binmode? I am going to give it a
try…

Working better now… the patch files are very similar…

Problem solved! I had to set binmode on all three files in question:

require “gdiff”

source = File.new(ARGV[0])
source.binmode

target = File.new(ARGV[1])
target.binmode

$stdout.binmode

puts Diff::GDiff.diff(source.read, target.read).pack

///////\

Sorry for the running soap-opera-like updates, but it sure was
exciting wasn’t it!?
If anyone needs GDiff/GPatch to run on Windows they can send me an email
and I’ll give them the full run-down.

Les