% \def\obeytabs turns all tabs into 8 non-breakable spaces

{\catcode`\^^I=\active\gdef\obeytabs{\catcode`\^^I=\active\let^^I=\@obeytabs}}

\def\@obeytabs{\@xobeysp\@xobeysp\@xobeysp\@xobeysp
	       \@xobeysp\@xobeysp\@xobeysp\@xobeysp}

\def\@code{\trivlist
  \item[]\if@minipage\else\vskip\parskip\fi
  \leftskip\@totalleftmargin
  \rightskip\z@
  \parindent\z@
  \parfillskip\@flushglue
  \parskip\z@
  \@tempswafalse
  \def\par{\if@tempswa\hbox{}\@@par\vfil\penalty -200\vfilneg
           \else\@tempswatrue\@@par\fi}%
  \obeylines
  \obeytabs
  \tt \catcode``=13 \@noligs
  \let\do\@makeother \dospecials
  \frenchspacing
  \@vobeyspaces
  \def\\{\char`\\}\def\t{\\t}\def\n{\\n}}

\let\endcode=\endtrivlist

\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12 |long|gdef|@xcode#1\end{code}[#1|end[code]]
|endgroup

\def\code{\@code\@xcode}

%
% Now we define \inputcode
%
% This is similar to \code but does not need \@xcode trickery
% to delimit the begining and end of the code text.

\def\inputcode#1{{\@code\input{#1}\endcode}}

% macro for programming language identifiers that include underscore char
% e.g. \ident{an_identifier}
\def\@ident#1{#1\endgroup}
\def\ident{\begingroup \tt \catcode`_=11 \catcode`^=11 \@ident}
