Ausam/doc/man/man1/diff.1
.th DIFF I 5/15/74
.sh NAME
diff \*- differential file comparator
.sh SYNOPSIS
.bd diff
[
.bd \*-
]
[ [
.bd \*-c
] [
.bd \*-s
] [
.bd \*-d
] ]
name1 name2
[symbol]
.sh DESCRIPTION
.it Diff
tells what lines must be changed in two files to bring them
into agreement.
The normal output contains lines of these forms:
.s3
.lp +5 0
.it n1
a
.it n3,n4
.br
.it n1,n2
d
.it n3
.br
.it n1,n2
c
.it n3,n4
.s3
.i0
These lines resemble
.it ed
commands to convert file
.it name1
into file
.it name2.
The numbers after the letters pertain to file
.it name2.
In fact, by exchanging `a' for `d' and reading backward
one may ascertain equally how to convert file
.it name2
into
.it name1.
As in
.it ed,
identical pairs where
.it n1
=
.it n2
or
.it n3
=
.it n4
are abbreviated as a single number.
.s3
Following each of these lines come all the lines that are
affected in the first file flagged by `<',
then all the lines that are affected in the second file
flagged by `>'.
.s3
Under the \fB\*-\fR option,
the output of
.it diff
is a script of
.it "a, c"
and
.it d
commands for the editor
.it ed,
which will change the contents of the first file
into the contents of the second.
In this connection, the following shell program may help maintain
multiple versions of a file.
Only an ancestral file ($1) and a chain of
version-to-version
.it ed
scripts ($2,$3,...) made by
.it diff
need be on hand.
A `latest version' appears on
the standard output.
.s3
.lp +5 0
.tr ||
(cat $2 ... $9; echo "1,$p") \*v ed \*- $1
.s3
.i0
The
.bd -c
option causes diff to output its first input file
with the changes required to produce its second input file demarcated by
.bd "#ifndef\ symbol"\c
,
.bd "#ifdef\ symbol"
and
.bd "#endif\ symbol"
(\c
.bd "#else\ symbol"
is also used where possible).
This is most useful if the two files are C-programs.
The
.bd -s
option works similarly for UNIX-Assembler programs,
producing \fI.if symbol-1\fR, \fI.if symbol\fR
and \fI.endif\fR.
In this case, the first line of the output contains the line
.bd "symbol=0."
In both cases, file
.it name2
corresponds to defining
.bd symbol.
.s3
The
.bd -d
option causes diff to output the complete contents
of each file with those sections unique to each file
boxed by '+'s or '-'s.
This option is extremely useful.
.s3
Except for occasional `jackpots',
.it diff
finds a smallest sufficient set of file
differences.
.sh "SEE ALSO"
cmp (I), comm (I), ed (I)
.sh DIAGNOSTICS
`jackpot' \*- To speed things up, the program uses hashing.
You have stumbled on a case where there is a chance that
this has resulted in
a difference being called where none actually existed.
Sometimes reversing the order of files will make a
jackpot go away.
.sh BUGS
Editing scripts produced under the
\fB\*-\fR option are naive about
creating lines consisting of a single `\fB.\fR'.
Under the -c option, diff doesn't know about
#ifdef's and #endif's that are already in the file.
In such a case, the output could conceivably be nonsense.