CDIF(1) CDIF(1)
NAME
cdif - word context diff
SYNOPSIS
cdif [-B] [-v] [-n] [-A #] [-C #] [-D #] [-[bwcu]] file1
file2
cdif [-rcs] [-q] [-rrev1 [-rrev2]] [cdif options] file
cdif [cdif options] [diff-output-file]
DESCRIPTION
Cdif is a post-processor of the Unix diff command. It
highlights deleted, changed and added words based on word
context. Highlighting is usually done by using different
style font and the output looks like this:
1c1
< highlights deleted and changed and words
---
> highlights and modified and added words
Appended and deleted lines are not effected at all.
You may want to compare character-by-character rather than
word-by-word. Option -B option can be used for that pur-
pose and the output looks like:
1c1
< $opts = 'cubdvqnBA:C:D:';
---
> $opts = 'bdvqnxyBP:Q:R:';
If the standard output is a terminal, cdif uses termcap to
highlights words. It uses md and me (bold or bright)
sequence for changed words and so and se (standout)
sequence for deleted and added part.
If the standard output is not a terminal, it uses nroff
style overstriking to highlight them. You won't be able
to tell the difference on normal screen but using pager
command like more or less, or printing to appropriate
printer will make them visible.
If only one file is specified, cdif reads that file (stdin
if no file) as a output from diff command. Lines those
don't look like diff output are simply ignored and printed
same as input. So you can use cdif from rn(1) like
`|cdif'.
OPTIONS
-B Compare the data character-by-character context.
-v Force to use video effect even if the output is not
1992/12/28 (v1.8) 1
CDIF(1) CDIF(1)
a terminal.
-n Force not to use video effect even if the output is
a terminal.
-[ACD] effect
Specify the effect to use for added, changed and
deleted words respectively. Special effects are:
vso: video standout
vul: video underline
vbd: video bold
bd: nroff style overstrike
ul: nroff style underline
If specified effect doesn't match to any of special
words, the sequence is used to highlighting string.
Start and end string are separated by comma. So
command:
cdif -D'<,>' -C'[,]' -A'{,}'
produces following output.
1c1
< highlights <deleted >and [changed] and words
---
> highlights and [modified] and{ added} words
-I string
Specify the string to be shown at the inserted or
deleted point. Normally the point at where new
text is inserted or old text is deleted is not
indicated in the output. -I option specifies the
string which is to be shown at the insertion point.
For example, command
cdif -D'<,>' -C'[,]' -A'{,}' -I'|'
produces the output like below.
1c1
< highlights <deleted >and [changed] and| words
---
> highlights |and [modified] and{ added} words
Following four options are used to specify how this
string is printed in the output.
-ib Makes the string overstruck.
-iu Put the string under the line. According to
1992/12/28 (v1.8) 2
CDIF(1) CDIF(1)
the sequence of Teletype model 37, the
string is enclosed by ESC-9 and ESC-8
sequences.
-ix Put the string at the exact point. The
string is enclosed by non-standard ESC-6
sequences which indecate to move the print-
ing point half-character backward. Cur-
rently this sequence is understood only by
my perl version of a2ps. See RELATED COM-
MANDS.
Special strings vbar, VBAR, caret, CARET are pre-
pared for shortcut. `vbar' means putting the ver-
tical bar (|) at the exact insertion point.
`caret' means putting the caret mark (^) under the
exact inserntion point. Uppercase chacacter makes
them overstruck.
-diff=command
Specify the diff command to use.
-rcs, -rrev
Use rcsdiff instead of normal diff. Option -rcs is
not required when -rrev is supplied.
-b, -w, -c, -u
Passed through to the back-end diff command. Cdif
can process the output from context diff (-c) and
unified diff (-u) if those are available.
RELATED COMMANDS
a2ps is a command which converts ascii text to
postscript program. C version was originally
posted to usenet by miguel@imag.imag.fr (Miguel
Santana). I reimplemented it by perl and enhanced
to use different font family for overstruck and
underlined characters. This is a convenient tool
to print the output from cdif to postscript
printer.
sdif is a System V's sdiff clone written in perl. It
also can handle overstruck and underlined charac-
ter, and has -cdif option to use cdif instead of
normal diff.
termfix
is a program to change termcap capability of cur-
rent terminal temporarily. Recent more and less
uses md and me capability to display overstruck
character if available. Sometimes we want to use
standout rather than bolding. Termfix allows to
cancel md and md capability only for the invoking
command by ``md@'' option.
1992/12/28 (v1.8) 3
CDIF(1) CDIF(1)
All of these programs can be ftp'ed from sra.co.jp
(133.137.4.3) by anonymous ftp from the directory
~ftp/pub/lang/perl/sra-scripts.
AUTHOR
Kazumasa Utashiro <utashiro@sra.co.jp>
Software Research Associates, Inc., Japan
SEE ALSO
perl(1), diff(1), sdif(1), a2ps(1), termfix(1)
BUGS
Cdif is naturally slow because it uses normal diff command
as a back-end processor to compare words.
1992/12/28 (v1.8) 4