%
%  Stolen from TeXhax V90 # 26
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
\chardef \l@tter = 11
\chardef \@ther = 12
\newcount \c@unt 
\newcount \ch@rcode
\newif \ifd@bugging 
\ifd@bugging \let \m@ssage = \message \else \def \m@ssage #1{}\fi
%
\def \verbatim #1%
    {\begingroup
     \def \n@sted 
         {\begingroup
          \let \n@sted = \endgroup 
          \@nvironment 
          \ignorespaces
         }%
     \tt
     \edef \@nvironment 
          {\parindent = \the \parindent 
           \parskip = \the \parskip 
           \relax
          }%
     \parskip = 0 pt 
     \parindent = 0 pt
     \c@unt = 0 
     \loop 
            \ifnum \c@unt < `\A%
                   \s@ve \catcode \c@unt = \@ther
            \else  \ifnum \c@unt > `\z%
                          \s@ve \catcode \c@unt = \@ther
                   \else  \ifnum \c@unt > `\Z%
                                 \ifnum \c@unt < `\a%
                                        \s@ve \catcode \c@unt = \@ther
                                 \else  \s@ve \catcode \c@unt = \l@tter
                                 \fi
                          \else  \s@ve \catcode \c@unt = \l@tter
                          \fi
                   \fi
            \fi
            \advance \c@unt by 1
     \ifnum \c@unt < 128 % or 256 for the V3 sites ...
     \repeat
     \ch@rcode = `#1%
     \edef \@nvironment {\@nvironment \catcode \the \ch@rcode = \active \space}%
     \catcode \ch@rcode = \active 
     \uccode `\^^M = \ch@rcode 
     \@x \uppercase \@x {\@x \def \r@turn {\n@sted}}
     \uccode `\^^M = 0
     \@ctivecr
     \@ctivespace
     \v@id
    }%
%
\let \@x = \expandafter
\def \v@id {\futurelet \n@xt \v@idifspace}
\def \k@rn {\leavevmode \kern \fontdimen 2 \font \futurelet \n@xt \k@rnifspace}
\def \pr@nt {\char 32\relax}
\def \v@idifspace {\testn@xt {\afterassignment \v@id}}
\def \k@rnifspace {\testn@xt {}}
\def \AfterGroup #1{\global \def \@ftergroup {#1}\aftergroup \@ftergroup}
%
\def \s@ve #1#2=#3%
    {\ifnum #1#2 = #3%
     \else \edef \@nvironment{\@nvironment#1\the #2=\the #1#2 }#1#2 = #3%
     \fi
    }
%
\def \testn@xt #1%
    {\ifx  \n@xt \sp@c@
           \m@ssage {Next character is a space}%
           \let \n@xt = \relax
     \else \ifx  \n@xt \r@t@rn
                 \m@ssage {Next character is a return}%
                 \def \n@xt {#1\let \n@xt = }%
           \else \m@ssage {Next character is \meaning \n@xt}%
                 \let \n@xt = \relax
                 \@x \let \sp@ce = \pr@nt
           \fi
     \fi
     \n@xt
    }%
%
\catcode `\ = \active%
\def\sp@ce{ }%
\def\@ctivespace{\catcode`\ =\active\def {\v@id}\let\sp@c@= }%
\catcode`\ =10\relax
%
\catcode `\^^M = \active %
\def \r@turn {^^M}%
\let \r@t@rn = ^^M%
\def \@ctivecr %
    {\catcode `\^^M = \active %
     \def ^^M%
         {\@x \def \sp@ce {\k@rn}%
          \@x \let \@x \sp@c@ \@x =\sp@ce %
          \endgraf %
          \futurelet \n@xt \k@rnifspace %
         }%
     \let \r@t@rn = ^^M%
    }%
\catcode `\^^M = 5 %
%
\catcode `\@ = \c@tcode
\def \endverbatim {\endgroup \endgroup}
