%% 
%% This is file `changebar.sty', generated on <1993/10/11> 
%% with the docstrip utility (2.1e).
%% 
%% The original source file was `changebar.doc'.
%% 
%% 
%% IMPORTANT NOTICE:
%% You are not allowed to distribute this file.
%% For distribution of the original source see
%% the copyright notice in the file changebar.doc.
%% 
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Braams J.L.",
%%%     version         = "3.1b",
%%%     date            = "11 October 1993",
%%%     time            = "09:12:24 MET",
%%%     filename        = "changebar.doc",
%%%     address         = "PTT Research
%%%                        St. Paulusstraat 4
%%%                        2264 XZ Leidschendam
%%%                        The Netherlands",
%%%     telephone       = "(70) 3325051",
%%%     FAX             = "(70) 3326477",
%%%     checksum        = "51434 1276 6008 47620",
%%%     email           = "J.L.Braams@research.ptt.nl (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "",
%%%     supported       = "yes",
%%%     abstract        = "",
%%%     docstring       = "THis LaTeX document style option implements
%%%                        changebars for LaTeX documents. It supports
%%%                        various printer drivers through a selection
%%%                        mechanism.
%%%
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================
\def\fileversion{v3.1b}
\def\filedate{11 october 93}
\wlog{Document style option `changebar', \fileversion\space<\filedate>}
\chardef\atcatcode=\catcode`\@
\catcode`\@=11\relax
\def\cb@maxpoint{80}
\def\cb@minpoint{1}
\def\cb@nil{0}
\newcount\cb@nextpoint
\cb@nextpoint=\cb@minpoint
\newcount\cb@currentpoint
\newcount\cb@page
\newcount\cb@pagecount
\cb@pagecount=0
\newif\ifouterbars \outerbarsfalse
\newdimen\cb@odd
\newdimen\cb@even
\def\cb@positions{%
  \global\cb@odd =\hoffset
  \global\advance\cb@odd by \oddsidemargin
  \ifouterbars
    \global\advance\cb@odd by \textwidth
    \global\advance\cb@odd by \changebarsep
    \global\advance\cb@odd by 0.5\changebarwidth
  \else
    \global\advance\cb@odd by -\changebarsep
    \global\advance\cb@odd by -0.5\changebarwidth
  \fi
  \global\cb@even =\hoffset
  \global\advance\cb@even by \evensidemargin
  \if@twoside
    \ifouterbars
      \global\advance\cb@even by -\changebarsep
      \global\advance\cb@even by -0.5\changebarwidth
    \else
      \global\advance\cb@even by \textwidth
      \global\advance\cb@even by \changebarsep
      \global\advance\cb@even by 0.5\changebarwidth
    \fi
  \else
    \ifouterbars
      \global\advance\cb@even by \textwidth
      \global\advance\cb@even by \changebarsep
      \global\advance\cb@even by 0.5\changebarwidth
    \else
      \global\advance\cb@even by -\changebarsep
      \global\advance\cb@even by -0.5\changebarwidth
    \fi
  \fi}
{\catcode`\p=12\catcode`\t=12 \gdef\cb@removedim#1pt{#1}}
\def\driver#1{%
  \bgroup\edef\next{\def\noexpand\tempa{#1}}%
    \uppercase\expandafter{\next}%
    \def\LN{DVITOLN03}%
    \def\DVItoPS{DVITOPS}%
    \def\DVIPS{DVIPS}%
    \def\emTeX{EMTEX}%
    \global\chardef\cb@driver@setup=0\relax
    \ifx\tempa\LN      \global\chardef\cb@driver@setup=0\fi
    \ifx\tempa\DVItoPS \global\chardef\cb@driver@setup=1\fi
    \ifx\tempa\DVIPS   \global\chardef\cb@driver@setup=2\fi
    \ifx\tempa\emTeX   \global\chardef\cb@driver@setup=3\fi
  \egroup}
{\def\do{\noexpand\do\noexpand}
 \xdef\@preamblecmds{\@preamblecmds \do\driver}
}
\def\cb@setup@specials{%
\ifcase\cb@driver@setup
  \def\cb@defpoint##1##2{\special{ln03:defpoint \the##1(\the##2,)}}
  \def\cb@connect##1##2##3{%
    \special{ln03:connect \the##1\space\space \the##2\space \the##3}}
  \def\cb@resetpoints{%
    \special{ln03:resetpoints \cb@minpoint \space\cb@maxpoint}}
\or
  \def\cb@defpoint##1##2{%
    \special{dvitops: inline
                \expandafter\cb@removedim\the##2\space 6.5536 mul\space
                /CBarX\the##1\space exch def currentpoint exch pop
                /CBarY\the##1\space exch def}}
  \def\cb@connect##1##2##3{%
    \special{dvitops: inline
                gsave \thechangebargrey\space 100 div setgray
                \expandafter\cb@removedim\the##3\space 6.5536 mul\space
                CBarX\the##1\space\space CBarY\the##1\space\space moveto
                CBarX\the##2\space\space CBarY\the##2\space\space lineto
                stroke grestore}}
  \let\cb@resetpoints\relax
\or
  \def\cb@defpoint##1##2{%
     \special{ps:
                \expandafter\cb@removedim\the##2\space
                Resolution\space mul\space 72.27\space div\space
                /CBarX\the##1\space exch def currentpoint exch pop
                /CBarY\the##1\space exch def}}
    \def\cb@connect##1##2##3{%
      \special{ps:
                gsave \thechangebargrey\space 100 div setgray
                \expandafter\cb@removedim\the##3\space
                Resolution\space mul\space 72.27\space div\space
                setlinewidth
                CBarX\the##1\space\space CBarY\the##1\space\space moveto
                CBarX\the##2\space\space CBarY\the##2\space\space lineto
                stroke grestore}}
    \let\cb@resetpoints\relax
\or
  \typeout{Changebar Warning: changebars only supported for v1.5+ of dvidrv}%
  \def\cb@defpoint##1##2{\special{em:point \the##1,\the##2}}%
  \def\cb@connect##1##2##3{\special{em:line \the##1,\the##2,\the##3}}%
  \let\cb@resetpoints\relax
\else
  \typeout{Changebar Warning: changebars not supported in unknown setup}
  \def\cb@defpoint##1##2{}%
  \def\cb@connect##1##2##3{}%
  \let\cb@resetpoints\relax
\fi
\global\let\cb@setup@specials\relax}
\def\cbstart{\@ifnextchar [{\cb@start}{\cb@start[\changebarwidth]}}
\def\cbend{\cb@end}
\def\cbdelete{\@ifnextchar [{\cb@delete}{\cb@delete[\deletebarwidth]}}
\def\cb@delete[#1]{\vbox to 0pt{\vss\cb@start[#1]\vskip #1\cb@end}}
\def\changebar{\@ifnextchar [{\cb@start}{\cb@start[\changebarwidth]}}%
\def\endchangebar{\cb@end}
\def\nochangebars{\def\cb@start[##1]{}%
                  \def\cb@delete[##1]{}%
                  \let\cb@end\relax}
\newlength{\changebarwidth}
\setlength{\changebarwidth}{2pt}
\newlength{\deletebarwidth}
\setlength{\deletebarwidth}{4pt}
\newlength{\changebarsep}
\setlength{\changebarsep}{30pt}
\newcounter{changebargrey}
\setcounter{changebargrey}{65}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\cb@start[#1]{\cb@currentpoint=\cb@nextpoint
        \@tempdima=#1\relax                             % for \cb@push
        \cb@push\cb@currentlist
        \ifvmode \cb@setBeginPoint\cb@currentpoint
        \else \vbox to 0pt{\vskip -\ht\strutbox         %jump up a line to
        \cb@setBeginPoint\cb@currentpoint               %set point
        \vskip \ht\strutbox}\fi
        \cb@writeAux\cb@advancePoint}
\def\cb@advancePoint{%
  \global\advance\cb@nextpoint by 2\relax
  \ifnum\cb@nextpoint>\cb@maxpoint
    \global\cb@nextpoint=\cb@minpoint\relax
  \fi}
\def\cb@end{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \typeout{Changebar Warning: Badly nested changebars;
                                Expect erroneous results}%
  \else
    \cb@setEndPoint\cb@currentpoint
    \advance\cb@currentpoint by1\cb@writeAux
  \fi}
\def\cb@setBeginPoint#1{%
  \ifodd\cb@pagecount
    \cb@defpoint{#1}{\cb@even}%
  \else
    \cb@defpoint{#1}{\cb@odd}%
  \fi}
\def\cb@setEndPoint#1{%
  \@tempcnta=#1\advance\@tempcnta by1\relax
  \ifodd\cb@pagecount
    \cb@defpoint{\@tempcnta}{\cb@even}%
  \else
    \cb@defpoint{\@tempcnta}{\cb@odd}%
  \fi
  \cb@connect{#1}{\@tempcnta}{\@tempdima}}%
\def\cb@writeAux{%
  \if@filesw
    \begingroup
      \edef\point{\the\cb@currentpoint}%
      \edef\level{\the\@tempdima}%
      \let\the=0%
      \edef\cb@temp{\write\@auxout
          {\string\cb@barpoint{\point}{\the\cb@pagecount}{\level}}}%
      \cb@temp
    \endgroup
  \fi}
\let\cb@makecol=\@makecol
\def\@makecol{%
  \setbox\@cclv=\vbox{\cb@resetpoints\cb@beginSaves\unvbox\@cclv}%
  \gdef\cb@beginSaves{}
  \global\advance\cb@pagecount by 1\relax
  \cb@buildActive\cb@processActive
  \cb@makecol}
\def\cb@processActive{%
  \cb@pop\cb@spanlist
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \setbox\@cclv=\vbox{\unvbox\@cclv\advance\cb@pagecount by -1\relax
                        \cb@setEndPoint\cb@currentpoint}%
    \cb@saveBeginPoint\cb@currentpoint
    \cb@push\cb@history
    \cb@processActive
  \fi}
\def\cb@saveBeginPoint#1{%
  \ifodd\cb@pagecount
    \xdef\cb@beginSaves{\cb@defpoint{#1}{\cb@even}\cb@beginSaves}%
  \else
    \xdef\cb@beginSaves{\cb@defpoint{#1}{\cb@odd}\cb@beginSaves}%
  \fi}
\def\cb@beginSaves{}                % initially empty
\def\cb@buildActive{\cb@initlist\cb@spanlist\cb@pushNextActive}
\def\cb@pushNextActive{%
  \cb@pop\cb@history
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \ifnum\cb@page>\cb@pagecount
      \cb@push\cb@history
    \else
      \ifodd\cb@currentpoint
        \cb@push\cb@spanlist
      \else
        \cb@pop\cb@spanlist
      \fi
      \cb@pushNextActive
    \fi
  \fi}
\def\cb@initlist#1{\xdef#1{}}
\cb@initlist\cb@history         % the history list; initially empty
\cb@initlist\cb@spanlist        % list of bars spanning current page
\cb@initlist\cb@currentlist     % used to implement nesting without using
                                % TeX grouping

\newwrite\cb@write              % file for history list
\newread\cb@read
\immediate\openout\cb@write=\jobname.cb % open for building of history list
\def\cb@pop#1{%
  \ifx #1\cb@history
    \ifeof\cb@read
    \else
      {\endlinechar=-1\read\cb@read to\@temp
       \xdef\cb@history{\cb@history\@temp}%
      }%
    \fi
  \fi
  \ifx#1\@empty
    \cb@currentpoint=\cb@nil\cb@page=0\relax
  \else
    \expandafter\cb@carcdr#1e#1%
  \fi}
\def\cb@carcdr#1n#2p#3l#4e#5{%
  \cb@currentpoint=#1\cb@page=#2\relax\@tempdima=#3\xdef#5{#4}}
\def\cb@push#1{%
  \xdef#1{\the\cb@currentpoint n\the\cb@page p\the\@tempdima l#1}}
\def\cb@barpoint#1#2#3{\immediate\write\cb@write{#1n#2p#3l}}
\let\cb@document=\document
\def\document{\cb@document
              \cb@setup@specials
              \cb@positions
              \immediate\closeout\cb@write
              \immediate\openin\cb@read=\jobname.cb}
\let\cb@enddocument\enddocument
\def\enddocument{\clearpage\cb@initlist\cb@history
   \immediate\closein\cb@read\immediate\openin\cb@read=\jobname.cb%
   \let\cb@barpoint=\cb@checkHistory\cb@enddocument}
\def\cb@checkHistory#1#2#3{\cb@pop\cb@history
        \ifnum #1=\cb@currentpoint\relax
            \ifnum #2=\cb@page\relax  % do nothing
            \else \cb@error           % page numbers mismatched
            \fi
        \else \cb@error               % point numbers mismatched
        \fi}
\def\cb@error{%
  \message{Changebar Warning: Changebar info has changed. %
                              Rerun to get right.}
  \gdef\cb@checkHistory##1##2##3{}%
  \let\cb@barpoint=\cb@checkHistory}
\let\cb@endfloat=\end@float
\def\end@float{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
  \else
    \cb@push\cb@currentlist
    \global\@tempdima=\@tempdima
    \egroup
    \global\setbox\@currbox=%
        \vbox\bgroup\cb@start[\@tempdima]\unvbox\@currbox\cb@end
  \fi
  \cb@endfloat}
\let\endfigure=\end@float       % need to rebind these to new def
\let\endtable=\end@float
\let\cb@footnote=\@footnotetext
\long\def\@footnotetext#1{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \cb@footnote{#1}%
  \else
    \cb@push\cb@currentlist
    \edef\cb@temp{\the\@tempdima}%
    \cb@footnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\let\cb@mpfootnote=\@mpfootnotetext
\long\def\@mpfootnotetext#1{%
  \cb@pop\cb@currentlist
  \ifnum\cb@currentpoint=\cb@nil
    \cb@mpfootnote{#1}%
  \else
    \cb@push\cb@currentlist
    \edef\cb@temp{\the\@tempdima}%
    \cb@mpfootnote{\cb@start[\cb@temp]#1\cb@end}%
  \fi}
\catcode`\@=\atcatcode \let\atcatcode\relax
\endinput
%% 
%% End of file `changebar.sty'.
