%%
%%     Name   : ecluntab.sty
%%     Author : Hideki ISOZAKI
%%     Date   : July 1, 1992
%%     Version: 1.0
%%

\newcount\untablineno
\newdimen\utb@eight
\newdimen\utb@realwd
\newbox\utb@box

\begingroup \catcode `|=0 \catcode `[= 1 
\catcode`]=2 \catcode `\{=12 \catcode `\}=12 
\catcode`\\=12 
|gdef|utb@args#1\end{untabify}[#1|end[untabify]]
|gdef|utb@argsS#1\end{untabify*}[#1|end[untabify*]]
|endgroup

\def\utb@start{\setbox\utb@box=\hbox\bgroup}
\def\utb@tab{\leavevmode\egroup\utb@caltab\box\utb@box\utb@start}
\def\utb@par{\leavevmode\egroup\utb@caltab\box\utb@box\endgraf}
\def\utb@cntline{\everypar{\leavevmode\hbox to \untablinenowidth{\hss
\ifnum\untablineno>\z@\the\untablineno:\ %
\global\advance\untablineno\@ne\fi}\utb@start}}

\def\utb@caltab{\utb@realwd=\wd\utb@box
\advance\utb@realwd\utb@eight
\divide\utb@realwd\utb@eight
\multiply\utb@realwd\utb@eight
\wd\utb@box=\utb@realwd}

{\catcode`\^^I=\active\catcode`\^^M=\active
\gdef\utb@chars{\tt \let\par\utb@par %
  \catcode`\^^M=\active\def^^M{\let^^M=\par}%
  \catcode``=\active \@noligs\let\do\@makeother\dospecials %
  \catcode`\^^I=\active\let^^I=\utb@tab}}

% The space after #1 is essential to ignore the first CR.
% So do not put % immediately after \begin{untabify}{1}.

\newbox\untab@box

\def\untabify{\settowidth{\utb@eight}{\tt AAAAAAAA}%
\setbox\untab@box=\vbox\bgroup
\advance\linewidth by -2\fboxsep
\advance\linewidth by -2\fboxrule
\parindent\z@
\hsize\linewidth
\everyuntabify\utb@chars
\utb@cntline
\frenchspacing
\@vobeyspaces\utb@args}

\@namedef{untabify*}{\settowidth{\utb@eight}{\tt AAAAAAAA}%
\setbox\untab@box=\vbox\bgroup
\advance\linewidth by -2\fboxsep
\advance\linewidth by -2\fboxrule
\parindent\z@
\hsize\linewidth
\everyuntabify\utb@chars
\utb@cntline
\utb@argsS}

\let\everyuntabify=\relax

\def\enduntabify{\egroup\trivlist\vskip.5\baselineskip\item[]%
\fbox{\box\untab@box}\vskip.5\baselineskip\endtrivlist}

\@namedef{enduntabify*}{\enduntabify}

\untablineno\@ne

\def\untablinenowidth{1cm}

