Recent

Author Topic: Native Pascal code for Diff utility?  (Read 5434 times)

DaltonCalford

  • Newbie
  • Posts: 1
Native Pascal code for Diff utility?
« on: October 22, 2009, 10:17:47 pm »
Hi all,
I am writing a series of components for Firebird (UDF'S) that will get compiled into a general use library.   The code is compiled by Freepascal and I will be calling the firebird code from lazarus.

I was wondering if anyone knew where i could find some reference code in pascal that would perform the same task as diff does?   I want to perform the task on text blobs in the database.

Thanks in advance.

Dalton

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Native Pascal code for Diff utility?
« Reply #1 on: October 24, 2009, 09:50:08 am »
Lazarus source includes support for diff, you just need to look for it.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Native Pascal code for Diff utility?
« Reply #2 on: October 27, 2009, 12:14:46 pm »
I think he's looking for Pascal source code to generate diff-data.

If you're using *NIX may be you can call the "diff" command and get it's output via a pipe. I can't remember how to create a pipe on Pascal but I'm sure it's possible.

If you actually need Pascal code to do the work, I did wrote a small program that does it. It was pretty simple and detects fairly differences but it's slower and less perfect than other tools, and I'm not sure it will work with binary data (I'd test it only with text data). It uses a sort of "incremental search". I found the algorithm incrementally: I did a simple diff-search program, then optimize it a bit, then a bit more, until I can't do it better. Most diff tools uses table-guided searches or matrix based algorithms much more complex than the mine. The sad thing is it was written in Spanish (naming and documentation).

I never released the code, but if you need it I'll give it to you with a MIT or ZLib license (open & free).
« Last Edit: October 27, 2009, 12:17:01 pm by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Native Pascal code for Diff utility?
« Reply #3 on: October 28, 2009, 07:47:45 am »
Quote
I think he's looking for Pascal source code to generate diff-data.
I know. Lazarus has that support and the source code is given, so it must be somewhere in the .pas / .pp in Lazarus directory.

 

TinyPortal © 2005-2018