cdif - word context diff


SYNOPSIS

       cdif [-Bvn] [-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.  This is conve-
       nient  because  you don't have to retype the command line.
       Cdif is often used in following context.

            % rcsdiff foo.c
            (I can't see any difference...)
            % !! | cdif

       Lines those don't look like diff output are simply ignored


OPTIONS

       -B     Compare the data character-by-character context.

       -v     Force to use video effect even if the output is not
              a terminal.

       -n     Force not to use video effect even if the output is
              a terminal.

       -e expression
              By default `word' is defined by pattern `\w+'.  You
              can  specify the Perl regular expression for `word'
              with this option.  If you want to treat period same
              as  other  alphabetical  characters  use  option -e
              '[\w\.]+'.

       -[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'|'

                   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
                     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 indicate 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  insertion  point.  Uppercase character 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.
              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 bold.  Termfix allows to can-
              cel md and me capability only for the invoking com-
              mand by ``md@'' option.

       All  these  programs  are  available  from  anonymous ftp:
       ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/.


AUTHOR

       Kazumasa Utashiro <utashiro@iij.ad.jp>
       Internet Initiative Japan Inc.
       3-13 Kanda Nishiki-cho, Chiyoda-ku, Tokyo 101-0054, Japan


SEE ALSO

       perl(1), diff(1), sdif(1), a2ps(1), termfix(1)


BUGS

       When the last one word (the last byte with -B option) of a
       line moved to the other line, it is treated as disappeared
       and the new word was appeared in the other line.  This  is
       due to the behavior of diff command.

       Cdif is naturally slow because it uses normal diff command
       as a back-end processor to compare words.





















Man(1) output converted with man2html