CMP -- Compare Text or Binary Files
Revision History

program and documentation by Stan Brown, Oak Road Systems
release 4.9 (5.0 beta), revised 8 Feb 2001
Copyright © 1984-2001 by Stan Brown, Oak Road Systems

CMP will compare text or binary files (or groups of files) and report any differences. Output is suitable for piping, or processing by other programs. A value returned in ERRORLEVEL lets batch files take action based on whether files are the same or differ.

This document is the complete revision history, starting with the most recent changes. For user instructions, please see the separate user guide.


What's New in CMP 5


CMP 5.0 is a complete rewrite of the program from scratch. The program is about 40 pages of code, compared to about 14 pages for the previous release, CMP 4.3! The executables are still comfortably small, about 80 KB for CMP32 and 26 KB for CMP16. If you used CMP 4.x, please see the Transitional Note.

The present release, CMP 4.9, 2001-02-08, is a beta release of 5.0. The only known bug is that under certain circumstances CMP does not resynchronize soon enough. After some difference blocks, you may see one or two identical lines from both files reported. I am of course working to fix that problem.

The new program can handle binary files, can search subdirectories, and makes better use of available memory; details are listed below. The user guide has been very greatly revised and expanded, and this revision history has become a separate document.

Significant enhancements are:


 

Transitional Note, CMP 4 -> CMP 5


If you are upgrading from CMP 4.x, please note that certain options have changed their meanings. This section points them out and tells you how to retain the old behavior if you want to.

Please see What's New in CMP 5 for a number of new options and other enhancements.

Transforming Inputs: /B, /E, /T

The /B option and the /E option now default to the opposite of their old settings. Formerly, if you did not specify any options, CMP would do some massaging of the file lines before comparing. Now, by default CMP compares files character for character.

If you want the old behavior, you can get it easily. For individual runs of CMP, specify the /BE options on the command line. If you simply want to restore the old defaults, you can use the environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/BE
The /T option has been withdrawn. It allowed you to expand tabs to an equivalent run of spaces, but this was redundant with the /B option.

Comparison Resync: /L

CMP 4.x would consider that files were resynchronized after a difference block as soon as it found a line in file 1 that matched a line in file 2. If you edited every other line of a paragraph or block of code, you would get a lot of little difference blocks.

To avoid this, CMP now requires two consecutive identical lines before it considers a difference block to have ended. But that will not be the best choice for every comparison, and you can now use the /L option to increase or decrease that value.

If you want to restore the old behavior, you can use an environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/L,1

Note that comma after the letter L.

Suppressing Messages: /Q, /QQ

The /Q option has changed from a pure toggle to a numeric, /Q0 through /Q3. You will still get the old behavior if you type /Q or /QQ.

Because you can combine options, one particular combination has changed its meaning. /Q1 or /Q0 used to mean the /Q option followed by the /1 option or the /0 option; now it means the /Q option setting quietness level 1 or 0. To specify separate options, simply use a slash or hyphen between them, or specify them in the other order: /Q/1 or /1Q.

Displaying Massaged Lines: /M

Before release 5.0, CMP would transform ("massage") the input lines to collapse runs of blanks. To conserve computer memory, CMP would store and display only the massaged lines. Then when CMP reported differences, it would display the massaged lines, which would be similar to the lines in the files but not necessarily identical.

Beginning with release 5.0, CMP saves both the massaged and the original lines, and displays the original lines. If you want to display the massaged lines, use the /M option. If you want that behavior to be the default, you can use the environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/M

This is less of an issue than it was before CMP 5.0. In earlier releases of CMP, lines were massaged unless you set options to prevent it. Now, lines are not massaged unless you set /B option or the /I option. So if you set no options at all, CMP 5.0 will display difference lines exactly as they are in the files, which is probbly what you'd expect.


History of Older Versions


This section is of only historical interest, since the program was completely rewritten in February 2001. But some users have said they find a complete revision history interesting, so here it is.

CMP 4.3, 2000-05-22

Added the /Z option; updated the logo message to use the URL for Oak Road Systems; expanded the help message; suggested "cmp /?|more" when the user types cmp with no files.

CMP 4.3a, 2000-08-24, updated the user guide but did not change the program. It clarified the ERRORLEVEL returns with the /1 and /0 options when multiple files are compared. It also spelled out the limitation that CMP couldn't be used for binary files; that capability was added in CMP 5.0.

CMP 4.2, 1999-10-31

Added the /F option, the /N option, and the /QQ option; sent the help message to stdout instead of stderr as previously; reorganized the user guide, adding many hyperlinks and a few small clarifications.

CMP 4.1, 1999-01-09

Added the /I and /D options. Split the confusing three-valued /Bn option into separate /B and /T toggle-type options. (The /T option was dropped from release 5.0.) Changed the CMP32 default to /L100. Improved diagnostics for a bad option in the environment variable. Converted documentation to HTML from Word for Windows.

Two minor releases involved no changes to the program or user guide. Version 4.1a (1999-02-20) updated contact information when we changed Internet providers. Version 4.1b (1999-08-04) updated contact information when we changed physical addresses; it also simplified the registration options and added site license pricing.

CMP 4.0, 1998-06

Allowed multiple file specs before a directory name, not just one file spec with wild cards. Supported long filenames in the new 32-bit version.

CMP 4.0 was packaged on 1998-11-18 as the first shareware release.

CMP 3.4, 1997-10

Added the /0 and /1 options; systematized all return values. Stopped requiring the trailing backslash on a directory argument. Instead of "effectively identical", reported a more specific phrase when the files are not significantly different based on the /B option and the /E option.

CMP 3.3, 1997-07

Compressed sequences of spaces and tabs to a single space; added the /B option to control that feature and tab expansion. Added the /Q option. Made the format of command-line options more flexible, and scanned the ORS_CMP environment variable for options.

CMP 3.0, 1994-07

Allocated string arrays far, allowing larger combined values of /L and /W.

CMP 2.4, 1989-11

Defaulted to /L20 (previously /L10).

CMP 2.1, 1985-03

Expanded tabs in input lines to the appropriate number of spaces.

CMP 1.1, 1984-10

Allowed wild cards in the first file argument.

CMP 1.0, 1984-08

Initial release (private releases, to clients only, until 4.0)