|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Diff tools
Does anyone know of a good resource for learning how a diff tool works?
__________________
blockcipher --------------- Gratuitously stolen... mysql> SELECT * FROM user WHERE clue > 0; 0 Results Returned. PHP5/MySQL/UTF-8 My Tech Blog |
|
#2
|
|||
|
|||
|
The Python language (http://www.python.org) has a diff module as part of its standard library. The module is implemented in Python so you can read the source and experiment with it. The module provides functions for standard text diffing, but also low-level control to allow you to create more specialised diffs.
Python is an open source dynamically typed language with a very clear, regular syntax. An experienced programmer could learn enough to start programming in a few hours. Dave - The Developers' Coach |
|
#3
|
||||
|
||||
|
I wrote one in VB a few years ago. It was pretty easy to figure out.
You start with pointers to each file. The pointers indicate the location of the last match. (they may not be the same, so you need one for each file) When the pointers stop matching, you advance one only, until it starts matching again. Then do the same for the other pointer. If Neither find a match, advance the pointer by one and repeat. (the line has changed) Your results will be: match Addition/removal (one side has data that doesn't match the other) Moved (pointers match somewhere, but not each other) Change (nothing matches on either side for a while) If you want to get a little more complex, you can store blocks of matching line numbers into a list and find the largest sets of matches, in case you're comparing text that repeats a lot. I hope that helps.
__________________
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Diff tools |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|