Click here to Skip to main content
15,892,072 members
Articles / Desktop Programming / MFC

Diff Tool

Rate me:
Please Sign up or sign in to vote.
4.97/5 (64 votes)
17 May 20037 min read 400.4K   10K   153  
A simple diff tool, usable on arbitrary file formats, with a nice HTML rendering
This article provides a simple C++ WIN32 tool to perform diffs on arbitrary files. It also features a nice and workable HTML output.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!-- diff html gen, (c) Stephane Rodriguez - feb 2003 -->

<HTML>

<HEAD>

<TITLE> File Diff </TITLE>

<style type='text/css'>

<!--

.N { background-color:white; }

.C { background-color:#FFFFBB; }

.A { background-color:#BBFFBB; }

.D { background-color:#FFBBBB; }

-->

</style>

</HEAD>



<BODY BGCOLOR='#FFFFFF'>



<table border=0 bgcolor=0 cellpadding=1 cellspacing=1 width=100%><tr><td>

<table width=100% bgcolor=white border=0 cellpadding=0 cellspacing=0>

<tr bgColor='#EEEEEE' style='color:0'><td width=50%>old version</td><td width=50%>new version&nbsp;&nbsp;&nbsp;(<b style='background-color:#FFFFBB;width:20'>&nbsp;</b>changed&nbsp;&nbsp;<b style='background-color:#BBFFBB;width:20'>&nbsp;</b>added&nbsp;&nbsp;<b style='background-color:#FFBBBB;width:20'>&nbsp;</b>deleted)&nbsp;&nbsp;</td></tr>

<tr bgColor='#EEEEEE' style='color:0'><td width=50%><code>C:\tmp\diff\BOOKSHOP.XML</code></td><td width=50%><code>C:\tmp\diff\BOOKSHOP2.XML</code></td></tr></table>

</td></tr>

</table>



<br>



<table border=0 bgcolor=0 cellpadding=1 cellspacing=1 width=100%><tr><td><table width=100% bgcolor='#EEEEEE' border=0 style='color:#888888;font-family: Arial, Helvetica, sans-serif; font-size: 9pt'>

<tr><td width=50%>&lt;?xml version="1.0" encoding="UTF8"?&gt;</td><td width=50%>&lt;?xml version="1.0" encoding="UTF8"?&gt;</td></tr><tr><td width=50% class='D'>&lt;!DOCTYPE Bookstore SYSTEM "bookshop.dtd"&gt;</td><td width=50%>&nbsp;</td></tr><tr><td width=50%>&lt;Bookstore&gt;</td><td width=50%>&lt;Bookstore&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;!--J&R Booksellers Database--&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;!--J&R Booksellers Database--&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="" In_Stock="Yes"&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="" In_Stock="Yes"&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The Round Stephane Door&lt;/Title&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The Round Stephane Door&lt;/Title&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Tom Evans&lt;/Author&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Tom Evans&lt;/Author&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1996&lt;/Year_Published&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1996&lt;/Year_Published&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;0-9546-0274-3&lt;/ISBN&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;0-9546-0274-3&lt;/ISBN&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$23.00&lt;/Price&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$23.00&lt;/Price&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;An Intriguing Tale Of A Round Door In A Wall&lt;/Review&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;An Intriguing Tale Of A Round Door In A Wall&lt;/Review&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&lt;Book Genre="" In_Stock="Yes"&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The Round Stephane Door&lt;/Title&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Tom Evans&lt;/Author&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1996&lt;/Year_Published&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;0-9546-0274-3&lt;/ISBN&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$23.00&lt;/Price&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;An Intriguing Tale Of A Round Door In A Wall&lt;/Review&gt;</td></tr><tr><td width=50%>&nbsp;</td><td width=50% class='A'>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Non-Fiction" In_Stock="Yes"&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Non-Fiction" In_Stock="Yes"&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;Creating Real Xml Applications&lt;/Title&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;Creating Real Xml Applications&lt;/Title&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Bill Eaton&lt;/Author&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Bill Eaton&lt;/Author&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1998&lt;/Year_Published&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1998&lt;/Year_Published&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;7-4562-0167-8&lt;/ISBN&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;7-4562-0167-8&lt;/ISBN&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$35.00&lt;/Price&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$35.00&lt;/Price&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;A Look At How To Build Real Xml Applications&lt;/Review&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;A Look At How To Build Real Xml Applications&lt;/Review&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Fiction" In_Stock="No"&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Fiction" In_Stock="No"&gt;</td></tr><tr><td width=50% class='C'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;Over The Hills Of Yukon2&lt;/Title&gt;</td><td width=50% class='C'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;Over The Hills Of Yukon&lt;/Title&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Bert Colewell&lt;/Author&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Bert Colewell&lt;/Author&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1993&lt;/Year_Published&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1993&lt;/Year_Published&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;5-6524-3054-1&lt;/ISBN&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;5-6524-3054-1&lt;/ISBN&gt;</td></tr><tr><td width=50% class='D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$22.00&lt;/Price&gt;</td><td width=50%>&nbsp;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;A Warm Story About A Man And A Moose In Yukon&lt;/Review&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;A Warm Story About A Man And A Moose In Yukon&lt;/Review&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Fiction" In_Stock="Yes"&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;Book Genre="Fiction" In_Stock="Yes"&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The Lion's Gold&lt;/Title&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The Lion's Gold&lt;/Title&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Daphne Griswald&lt;/Author&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Author&gt;Daphne Griswald&lt;/Author&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1989&lt;/Year_Published&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Year_Published&gt;1989&lt;/Year_Published&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;6-7896-2498-2&lt;/ISBN&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ISBN&gt;6-7896-2498-2&lt;/ISBN&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$15.00&lt;/Price&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Price&gt;$15.00&lt;/Price&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;One Of The Most Compelling Books Since "The Tiger's Silver".&lt;/Review&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Review&gt;One Of The Most Compelling Books Since "The Tiger's Silver".&lt;/Review&gt;</td></tr><tr><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td><td width=50%>&nbsp;&nbsp;&nbsp;&lt;/Book&gt;</td></tr><tr><td width=50%>&lt;/Bookstore&gt;</td><td width=50%>&lt;/Bookstore&gt;</td></tr></table></td></tr></table>

<br><font size='-2' color='#BBBBBB'>S.Rodriguez, Feb 2003</font></BODY>

</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
France France
Addicted to reverse engineering. At work, I am developing business intelligence software in a team of smart people (independent software vendor).

Need a fast Excel generation component? Try xlsgen.

Comments and Discussions