1

I'm looking for an open source tool to compare two C++ sources and tell me if they are the same after disregarding comments, formatting and identifier renames.

The purpose is NOT to detect plagiarism, as some tools I've found do. The purpose is to automatically detect whether a cosmetic change to the source code is really purely cosmetic, i.e. whether it changes something other than formatting, comments or variable names (or other identifiers). Obviously a regular text diff tool can't efficiently help here; this needs a language-specific tool.

Preferably, if the tool finds a difference, it should indicate it and then continue analysis, so that I can evaluate myself whether that constitutes a cosmetic change or not (e.g. int i; for (i ...) -> for (int i ...)). I'm not asking for these kinds of changes to be automatically detected an ignored by the tool; it would be cool but it's not a requisite.

One possibility I have thought of, is to use a source minifier and compare the minified versions, but I haven't found a C++ minifier that is also able to deal with local identifiers.

0

I don’t think that you will get a better open source application than WinMerge (although it would do no harm to look at Kdiff3.

Neither of them will handle your int i; for (i ...) -> for (int i ...) example, but they are open source, so you might give it a try, or request the feature from the author.

enter image description here

General
• Supports Microsoft Windows XP or newer
• Handles Windows, Unix and Mac text file formats
• Unicode support
• Tabbed interface

File Compare
• 3-way File Comparison New!
• Visual differencing and merging of text files
• Flexible editor with syntax highlighting, line numbers and word-wrap
• Highlights differences inside lines <= ============================================
• Difference pane shows current difference in two vertical panes
• Location pane shows map of files compared
• Moved lines detection

Folder Compare
• Regular Expression based file filters allow excluding and including items
• Fast compare using file sizes and dates
• Compares one folder or includes all subfolders
• Can show folder compare results in a tree-style view
• 3-way Folder Comparison Work in progress

Image Compare New!
• Support many types of images
• Can highlight the differences with blocks
• Overlaying of the pictures is possible
Version Control
• Creates patch files (Normal-, Context- and Unified formats)
• Resolve conflict files

Other
• Shell Integration (supports 64-bit Windows versions)
• Archive file support using 7-Zip
• Plugin support
• Localizable interface
• Online manual and installed HTML Help manual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.