How can I implement a diff function, such as Stack Overflow\'s question revision history?
diff
I would find the code for the FreeBSD diff utility and use that as the baseline. There's no point in re-inventing wheels when the licence allows for this sort of copying.