summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorrgrimes <rgrimes@FreeBSD.org>1994-05-27 12:33:43 +0000
committerrgrimes <rgrimes@FreeBSD.org>1994-05-27 12:33:43 +0000
commitf9ab90d9d6d02989a075d0f0074496d5b1045e4b (patch)
treeadd7e996bac5289cdc55e6935750c352505560a9 /usr.bin/diff
parentbe22b15ae2ff8d7fe06b6e14fddf0c5b444a95da (diff)
downloadFreeBSD-src-f9ab90d9d6d02989a075d0f0074496d5b1045e4b.zip
FreeBSD-src-f9ab90d9d6d02989a075d0f0074496d5b1045e4b.tar.gz
BSD 4.4 Lite Usr.bin Sources
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/diff/diff.1387
-rw-r--r--usr.bin/diff/diff3/diff3.1172
2 files changed, 559 insertions, 0 deletions
diff --git a/usr.bin/diff/diff/diff.1 b/usr.bin/diff/diff/diff.1
new file mode 100644
index 0000000..1b5c078
--- /dev/null
+++ b/usr.bin/diff/diff/diff.1
@@ -0,0 +1,387 @@
+.\" Copyright (c) 1980, 1990, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)diff.1 8.1 (Berkeley) 6/30/93
+.\"
+.Dd June 30, 1993
+.Dt DIFF 1
+.Os BSD 4
+.Sh NAME
+.Nm diff
+.Nd differential file and directory comparator
+.Sh SYNOPSIS
+.Nm diff
+.Op Fl cefhn
+.Op Fl biwt
+.Ar file1 file2
+.Nm diff
+.Op Fl D Ns Ar string
+.Op Fl biw
+.Ar file1 file2
+.Nm diff
+.Op Fl l
+.Op Fl r
+.Op Fl s
+.Op Fl cefhn
+.Op Fl biwt
+.Op Fl S Ns Ar name
+.Ar dir1 dir2
+.Sh DESCRIPTION
+The
+.Nm diff
+utility compares the contents of
+.Ar file1
+and
+.Ar file2
+and writes to the standard output the list of changes necessary to
+convert one file into the other.
+No output is produced if the files are identical.
+.Pp
+Output options (mutually exclusive):
+.Bl -tag -width Ds
+.It Fl c
+produces a diff with lines of context.
+The default is to present 3 lines of context and may be changed, e.g., to 10, by
+.Fl c10 .
+With
+.Fl c
+the output format is modified slightly:
+the output beginning with identification of the files involved and
+their creation dates and then each change is separated
+by a line with a dozen *'s.
+The lines removed from
+.Ar file1
+are marked with `\(mi '; those added to
+.Ar file2
+are marked `+ '. Lines which are changed from one
+file to the other are marked in both files with `! '.
+Changes which lie within <context> lines of each other are grouped
+together on output. (This is a change from the previous ``diff -c''
+but the resulting output is usually much easier to interpret.)
+.It Fl e
+produces output in a form suitable as input for the editor utility,
+.Xr ed 1 ,
+which can then be used to convert file1 into file2.
+.Pp
+Extra commands are added to the output when comparing directories with
+.Fl e ,
+so that the result is a
+.Xr sh 1
+script for converting text files which are common to the two directories
+from their state in
+.Ar dir1
+to their state in
+.Ar dir2 .
+.It Fl f
+identical output to that of the
+.Fl e
+flag, but in reverse order. It cannot
+be digested by
+.Xr ed 1 .
+.It Fl h
+Invokes an alternate algorithm which can handle files of very long lengths.
+There is a trade off. The algorithm can only deal with changes which are
+clearly delimited and brief. Long sections of changes and overlaps will
+confuse it.
+.It Fl n
+produces a script similar to that of
+.Fl e ,
+but in the opposite order and with a count of changed lines on each
+insert or delete command. This is the form used by
+.Xr rcsdiff 1 .
+.It Fl D Ns Ar string
+creates a merged version of
+.Ar file1
+and
+.Ar file2
+on the standard output, with C preprocessor controls included so that
+a compilation of the result without defining
+.Ar string
+is equivalent
+to compiling
+.Ar file1 ,
+while defining
+.Ar string
+will yield
+.Ar file2 .
+.El
+.Pp
+Comparison options:
+.Bl -tag -width Ds
+.It Fl b
+causes trailing blanks (spaces and tabs) to be ignored, and other
+strings of blanks to compare equal.
+.It Fl i
+ignores the case of letters. E.g., ``A'' will compare equal to ``a''.
+.It Fl t
+will expand tabs in output lines. Normal or
+.Fl c
+output adds character(s) to the front of each line which may screw up
+the indentation of the original source lines and make the output listing
+difficult to interpret. This option will preserve the original source's
+indentation.
+.It Fl w
+is similar to
+.Fl b
+but causes whitespace (blanks and tabs) to be totally ignored. E.g.,
+``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''.
+.El
+.Pp
+Directory comparison options:
+.Bl -tag -width Ds
+.It Fl l
+long output format; each text file
+.Nm diff Ns \'d
+is piped through
+.Xr pr 1
+to paginate it,
+other differences are remembered and summarized
+after all text file differences are reported.
+.It Fl r
+causes application of
+.Nm diff
+recursively to common subdirectories encountered.
+.It Fl s
+causes
+.Nm diff
+to report files which are the same, which are otherwise not mentioned.
+.It Fl S Ns Ar name
+re-starts a directory
+.Nm diff
+in the middle beginning with file
+.Ar name .
+.El
+.Pp
+If both arguments are directories,
+.Nm diff
+sorts the contents of the directories by name, and then runs the
+regular file
+.Nm diff
+algorithm, producing a change list,
+on text files which are different.
+Binary files which differ,
+common subdirectories, and files which appear in only one directory
+are described as such.
+.Pp
+If only one of
+.Ar file1
+and
+.Ar file2
+is a directory,
+.Nm diff
+is applied to the non-directory file and the file contained in
+the directory file with a filename that is the same as the
+last component of the non-directory file.
+.Pp
+If either
+.Ar file1
+or
+.Ar file2
+is
+.Sq Fl ,
+the standard input is
+used in its place.
+.Ss Output Style
+The default (without
+.Fl e ,
+.Fl c ,
+or
+.Fl n
+.\" -C
+options)
+output contains lines of these forms, where
+.Va XX , YY , ZZ , QQ
+are line numbers respective of file order.
+.Pp
+.Bl -tag -width "XX,YYcZZ,QQ" -compact
+.It Li XX Ns Ic a Ns Li YY
+At (the end of) line
+.Va XX
+of
+.Ar file1 ,
+append the contents
+of line
+.Va YY
+of
+.Ar file2
+to make them equal.
+.It Li XX Ns Ic a Ns Li YY,ZZ
+Same as above, but append the range of lines,
+.Va YY
+through
+.Va ZZ
+of
+.Ar file2
+to line
+.Va XX
+of file1.
+.It Li XX Ns Ic d Ns Li YY
+At line
+.Va XX
+delete
+the line. The value
+.Va YY
+tells to which line the change
+would bring
+.Ar file1
+in line with
+.Ar file1 .
+.It Li XX,YY Ns Ic d Ns Li ZZ
+Delete the range of lines
+.Va XX
+through
+.Va YY
+in
+.Ar file1 .
+.It Li XX Ns Ic c Ns Li YY
+Change the line
+.Va XX
+in
+.Ar file1
+to the line
+.Va YY
+in
+.Ar file2.
+.It Li XX,YY Ns Ic c Ns Li ZZ
+Replace the range of specified lines with the line
+.Va ZZ .
+.It Li XX,YY Ns Ic c Ns Li ZZ,QQ
+Replace the range
+.Va XX , Ns YY
+from
+.Ar file1
+with the range
+.Va ZZ , Ns QQ
+from
+.Ar file2 .
+.El
+.Pp
+These lines resemble
+.Xr ed 1
+subcommands to convert
+.Ar file1
+into
+.Ar file2 .
+The line numbers before the action letters pertain to
+.Ar file1 ;
+those after pertain to
+.Ar file2 .
+Thus, by exchanging
+.Ic a
+for
+.Ic d
+and reading the line in reverse order, one can also
+determine how to convert
+.Ar file2
+into
+.Ar file1 .
+As in
+.Xr ed 1 ,
+identical
+pairs (where num1 = num2) are abbreviated as a single
+number.
+.Sh ENVIRONMENT
+.Bl -tag -width TMPDIR
+.It Ev TMPDIR
+If the environment variable
+.Ev TMPDIR
+exists,
+.Nm diff
+will use the directory specified by
+.Ev TMPDIR
+as the temporary directory.
+.El
+.Sh FILES
+.Bl -tag -width /usr/bin/diffh -compact
+.It Pa /tmp/d?????
+.It Pa /usr/bin/diffh
+Alternate algorithm version (used by option
+.Fl h ) .
+.It Pa /usr/bin/diff
+for directory diffs
+.It Pa /usr/bin/pr
+used by the
+.Fl l
+option.
+.El
+.Sh SEE ALSO
+.Xr cmp 1 ,
+.Xr cc 1 ,
+.Xr comm 1 ,
+.Xr ed 1 ,
+.Xr diff3 1
+.br
+.ne 1i
+.Sh DIAGNOSTICS
+The
+.Nm diff
+utility exits with one of the following values:
+.Pp
+.Bl -tag -width Ds -compact -offset indent
+.It \&0
+No differences were found.
+.It \&1
+Differences were found.
+.It "\&>\&1"
+An error occurred.
+.El
+.Sh BUGS
+The
+.Fl f
+and
+.Fl e
+options
+do not provide special handling for lines on which the
+first and only character is
+.Dq Li \&. .
+This can cause problems for
+.Xr ed 1 .
+.Pp
+When comparing directories with the
+.Fl b ,
+.Fl w
+or
+.Fl i
+options specified,
+.Nm diff
+first compares the files ala
+.Ar cmp ,
+and then decides to run the
+.Nm diff
+algorithm if they are not equal.
+This may cause a small amount of spurious output if the files
+then turn out to be identical because the only differences are
+insignificant white space or case differences.
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.At v6 .
diff --git a/usr.bin/diff/diff3/diff3.1 b/usr.bin/diff/diff3/diff3.1
new file mode 100644
index 0000000..09b1d72
--- /dev/null
+++ b/usr.bin/diff/diff3/diff3.1
@@ -0,0 +1,172 @@
+.\" Copyright (c) 1990, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)diff3.1 8.2 (Berkeley) 4/18/94
+.\"
+.Dd April 18, 1994
+.Dt DIFF3 1
+.Os BSD 4.3R
+.Sh NAME
+.Nm diff3
+.Nd 3-way differential file comparison
+.Sh SYNOPSIS
+.Nm diff3
+.Op Fl exEX3
+.Ar file1 file2 file3
+.Sh DESCRIPTION
+The
+.Nm diff3
+utility compares the contents of three different versions of a file,
+.Ar file1 ,
+.Ar file2
+and
+.Ar file3 ,
+writing the result to the standard output.
+The options describe different methods of merging and
+purging
+the separate versions into a new file.
+.Nm Diff3
+is used by
+.Xr RCS 1
+to merge specific versions or create
+new versions.
+.Pp
+Options are:
+.Bl -tag -width "--E, --X"
+.It Fl e
+Produces output in a form suitable as an input script for the
+.Xr ed 1
+utility. The script may then be used to merge differences common
+between all three files and differences specific to file1 and file3.
+In other words, the
+.Fl e
+option ignores differences specific to file1 and file2, and those
+specific to file2 and file3. It is useful for backing out changes
+specific to file2 only.
+.It Fl x
+Produces an output script suitable for
+.Xr ed 1
+with changes
+specific only to all three versions.
+.It Fl 3
+Produces an output script suitable for
+.Xr ed 1
+with changes
+specific only to file3.
+.It Fl E , X
+Similar to
+.Fl e
+and
+.Fl x ,
+respectively, but treat overlapping changes (i.e., changes that would
+be noted with ==== in the normal listing) differently. The overlapping
+lines from both files will be inserted by the edit script, bracketed
+by "<<<<<<" and ">>>>>>" lines.
+.El
+.Pp
+The
+.Fl E
+option is used by
+.Tn RCS
+.Xr merge 1
+to insure that overlapping changes in the merged files are preserved
+and brought to someone's attention.
+.Pp
+For example, suppose lines 7-8 are changed in both file1 and file2.
+Applying the edit script generated by the command
+.Pp
+.Dl diff3 -E file1 file2 file3
+.Pp
+to file1 results in the file:
+.Pp
+.Bd -literal -offset indent -compact
+lines 1-6
+of file1
+<<<<<<< file1
+lines 7-8
+of file1
+=======
+lines 7-8
+of file3
+>>>>>>> file3
+rest of file1
+.Ed
+.Pp
+The default output of
+.Nm diff3
+makes notation of the differences between all files, and those differences
+specific to each pair of files. The
+changes are described by
+the commands necessary for
+.Xr ed 1
+to create the desired target from the different versions.
+See
+.Xr diff 1
+for a description of the commands.
+.Bl -tag -width "====="
+.It Li \&====
+The lines beneath this notation are ranges of lines which are different
+between all files.
+.It \&==== Ns Va n
+The lines beneath this notation are ranges of lines which are exclusively
+different in file
+.Va n .
+.El
+.Sh FILES
+.Bl -tag -width /usr/bin/diff3 -compact
+.It Pa /tmp/d3?????
+temporary files.
+.It Pa /usr/bin/diff3
+the executable.
+.El
+.Sh SEE ALSO
+.Xr diff 1
+.Xr ed 1
+.Xr rcs 1
+.Sh BUGS
+The
+.Fl e
+option
+cannot catch and change
+lines which have
+.Ql \&.
+as the first and only character on the line.
+The resulting script will fail on that line
+as
+.Ql \&.
+is an
+.Xr ed 1
+editing command.
+.Sh HISTORY
+A
+.Nm
+command appeared in
+.At v7 .
OpenPOWER on IntegriCloud