Dec 192017
 
UNIX Diff and Diff3 utilities with full C source code.
File GNUDIFF.ZIP from The Programmer’s Corner in
Category C Source Code
UNIX Diff and Diff3 utilities with full C source code.
File Name File Size Zip Size Zip Type
ANALYZE.C 23475 7092 deflated
CONTEXT.C 8685 2999 deflated
COPYING 7163 2944 deflated
DIAGMEET.TXT 1069 411 deflated
DIFF.C 14254 4749 deflated
DIFF.EXE 61495 30074 deflated
DIFF.H 10080 3643 deflated
DIFF3.C 45796 12817 deflated
DIR.C 6561 2626 deflated
ED.C 4959 1698 deflated
IO.C 14729 4424 deflated
LIMITS.H 1161 348 deflated
MAKEFILE 594 383 deflated
NORMAL.C 2309 1030 deflated
PATCHES.DOS 29509 9005 deflated
PROTO.H 3245 810 deflated
README 2170 1085 deflated
REGEX.C 50081 14110 deflated
REGEX.H 12504 4742 deflated
UTIL.C 14807 5043 deflated

Download File GNUDIFF.ZIP Here

Contents of the README file


This directory contains the GNU DIFF and DIFF3 utilities, version 1.4.
See file COPYING for copying conditions.

This version of diff provides all the features of BSD's diff
except the -D output format (insertion of #ifdef's).

It has these additional features:

-aAlways treat files as text and compare them line-by-line,
even if they do not appear to be ASCII.

-Bignore changes that just insert or delete blank lines.

-Cequivalent to -c -F'^[_a-zA-Z]'. This is useful for C code
because it shows which function each change is in.

-F regexp
in context format, for each unit of differences, show some of
the last preceding line that matches the specified regexp.

-Huse heuristics to speed handling of large files that
have numerous scattered small changes.

-I regexp
ignore changes that just insert or delete lines that
match the specified regexp.

-Nin directory comparison, if a file is found in only one directory,
treat it as present but empty in the other directory.

-Tprint a tab rather than a space before the text of a line
in normal or context format. This causes the alignment
of tabs in the line to look normal.


The basic algorithm is described in:
"An O(ND) Difference Algorithm and its Variations", Eugene Myers,
Algorithmica Vol. 1 No. 2, 1986, p 251.


Suggested projects for improving GNU DIFF:

1. Implement the option -D: -DSTRING means generate a merged version of
the two input files containing #ifdef STRING conditionals that would
cause the result of cpp to be one or the other of the files.

2. Handle very large files by not keeping the entire text in core.

One way to do this is to scan the files sequentally to compute hash
codes of the lines and put the lines in equivalence classes based only
on hash code. Then compare the files normally. This will produce
some false matches.

Then scan the two files sequentially again, checking each match to see
whether it is real. When a match is not real, mark both the
"matching" lines as changed. Then build an edit script as usual.

The output routines would have to be changed to scan the files
sequentially looking for the text to print.


 December 19, 2017  Add comments

Leave a Reply