fcomp(1) file compare

SYNOPSIS

fcomp [ option... ] filename1 filename2

fcomp -Help

fcomp -VERSion

DESCRIPTION

The fcomp program is used to compare text files, similar to the diff(1) program. Its advantage is that it always produces minimal differences, and so will never mis-sync when comparing files. Its disadvantage is that it runs slower due to the extra work required to produce optimal differences. However, for files differing by less than a few thousand lines, its performance is adequate. The algorithms used by this utility are also used by the fhist(1) program in order to produce the edit history.

To compare file old to file new, the command:

fcomp old new
would be used. This gives the differences involved in converting from file old to file new. This is analogous to the use of the cp(1) command. Either the old or new file may be a directory, in which case the comparison is done to the file in the directory with the same name as the other file. An error is given if old and new are both directories.

OPTIONS

The following options are understood:
-BINary
This option may be used to compare binary files on a byte-for-byte basis. (Each byte is treated as a "line" by the algorithm.) Byte values are displayed in hexadecimal, as are the addresses. Note: this is different behaviour to the fhist(1) option of the same name.
-No_BINary
This option may be used to avoid comparing binary files. A warnign will be prointed on the standard error, but the program will report success without printing andy other output.
-Blank

Ignore blank lines in the input files.
-Context number

This specifies the number of lines of "context" which is displayed. This shows the specified number of lines before and after the actual lines being changed. This is useful to locate and identify the line which is actually being changed, when there are many identical copies of the line in the file.
-Edit

Output an edit script which is machine readable.
-Failures number

This stops the comparison if the number of changes exceeds the specified number. Each change is a delete or insert of a single line. This is useful when you are not interested in the results when the files are totally different. Another use is a quick check to see if two files are identical, by using a value of zero.
-Help

Give some help on how to use the fcomp program.
-Join number

This merges together lines which have changed, if they are separated by up to the specified number of unchanged lines. This makes a change look bigger, but reduces the "choppiness" of the output by showing fewer regions being changed. This is particularly effective to suppress worthless matchings of single blank lines or comment beginning and ending lines. A useful value for this option is 3 or so.
-Matching

Output matching lines, rather then changed lines.
-Number

This outputs the line numbers at the left edge of the output. This isn't normally needed, since the line numbers are displayed in the comment line preceding the lines being displayed. Not outputting the line numbers prevents the terminal from needlessly scrolling for long lines.
-Output filename

Send the output to this file, rather than the standard output.
-Quiet

Output only a quick summary of changes needed.
-Spaces

This option ignores differences in the number of spaces in the two lines. That is, two or more adjacent spaces are handled as a single space. Spaces at the beginning or end of a line are totally ignored.
-Upcase

Uppercase lines before comparing.
-VERSion

Show what version of fcomp is running.
-What

This outputs all of both files together, showing what happened to each line of the first file in order to change to the line in the second file. This output is in "change bar" format, where inserted lines begin with |+, deleted lines begin with |-, and unchanged lines begin with spaces. The presence of the vertical bar makes it easy to search for the changed lines.

All options may be abbreviated; the abbreviation is documented as the upper case letters, all lower case letters and underscores (_) are optional. You must use consecutive sequences of optional letters.

All options are case insensitive, you may type them in upper case or lower case or a combination of both, case is not important.

For example: the arguments "-help, "-HELP" and "-h" are all interpreted to mean the -Help option. The argument "-hlp" will not be understood, because consecutive optional characters were not supplied.

Options and other command line arguments may be mixed arbitrarily on the command line.

The GNU long option names are understood. Since all option names for fcomp are long, this means ignoring the extra leading '-'. The "-option=value" convention is also understood.

FILE NAME EXPANSION

As a convenience, if a pathname begins with a period and a environment variable exists with that name, then the value of the environment variable will be used as the actual pathname. For example, if a environment variable of .FOO has the value this.is.a.long.name, then the command
fcomp -o .FOO
is actually equivilant to the command
fcomp -o this.is.a.long.name
If you want to prevent the expansion of a pathname which begins with a period, then you can use an alternate form for the pathname, as in:
fcomp -o ./.FOO

BINARY FILES

In general, fcomp can handle all text files you throw at it, even international text with unusual encodings. However, fcomp is unable to cope elegantly with files which contain the NUL character.

The fcomp(1) program simply prints a warning, and continues, you need to know that it converts NUL characters into an 0x80 value before performing the comparison.

The fmerge(1) program also converts the NUL character to an 0x80 value before merging, after a warning, and any output file will contain this value, rather than the original NUL character.

The fhist(1) program, however, generates a fatal error if any input file contains NUL characters. This is intended to protect your source files for unintentional corruption. Use -BINary for files which absolutely must contain NUL characters.

EXIT STATUS

The fcomp program will exit with a status of 1 on any error. The fcomp program will only exit with a status of 0 if there are no errors.

REFERENCES

This program is based on the algorithm in
An O(ND) Difference Algorithm and Its Variations, Eugene W. Myers, TR 85-6, 10-April-1985, Department of Computer Science, The University of Arizona, Tuscon, Arizona 85721.
See also:
A File Comparison Program, Webb Miller and Eugene W. Myers, Software Practice and Experience, Volume 15, No. 11, November 1985.

COPYRIGHT

fcomp version 1.18.D001
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Peter Miller;

This program is derived from a work
Copyright (C) 1990 David I. Bell.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.