%
% \GetFileInfo{gmoldcomm.sty}
% \title{The \pk{gmoldcomm} Package\thfileinfo}
% \author{Natror (Grzegorz Murzynowski)}
% \date{\today}
% \maketitle
%
%
% This is a~package
% for handling the old comments in \LaTeXe\ Source Files when \LaTeX^^B
% ing them with the \pk{gmdoc} package. 
%
% Written by Natror (Grzegorz Murzynowski) 2007/11/10.
%
% It's a~part of the \pk{gmdoc} bundle and as such a~subject to the
% \LaTeX\ Project Public License.
%
% 
% \stanza
% Scan CSs and put them in tt. If at beginning of line, precede them
% with |%|. Obey lines in the commentary.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmoldcomm}
         [2007/11/10 v0.99 LaTeX old comments handling (GM)]

\newenvironment{oldcomments}{%
  \catcode`\\=\active
  \let\do\@makeother
  \do\$% Not only CSs but also special chars happen in the old comments.
  \do\|\do\#\do\{\do\}\do\^\do\_\do\&%
  \gmoc@defbslash
  \obeylines
  \StoreMacro\finish@macroscan
  \def\finish@macroscan{%
    \@xa\gmd@ifinmeaning\macro@pname\of\gmoc@notprinted%
    {}{{\tt\ifvmode\%\fi\bslash\macro@pname}}%
    \gmoc@checkenv
  }%
}{}

{\escapechar\m@ne
\xdef\gmoc@notprinted{\string\begin,\string\end}}

\def\gmoc@maccname{macrocode}
\def\gmoc@ocname{oldcomments}


\foone{%
  \catcode`\[=1 \catcode`\]=2
  \catcode`\{=12 \catcode`\}=12 }
[\def\gmoc@checkenv[%
  \@ifnextchar{%^^A}
    [\gmoc@checkenvinn][]]%
%
\def\gmoc@checkenvinn{#1}[%
  \def\gmoc@resa[#1]%
  \ifx\gmoc@resa\gmoc@maccname
    \def\next[%
      \begingroup
      \def\@currenvir[macrocode]%
      \RestoreMacro\finish@macroscan
      \catcode`\\=\z@
      \catcode`\{=1 \catcode`\}=2
      \macrocode]%
  \else
    \ifx\gmoc@resa\gmoc@ocname
      \def\next[\end[oldcomments]]%
    \else
      \def\next[%
        % ^^A        \typeout[**** detected environment [#1]]%
        \{#1\}%
        % ^^A  \show\relax
      ]%
    \fi
  \fi
  \next]%
]

\foone{%
  \catcode`\/=\z@
  \catcode`\\=\active}
% \CodeEscapeChar\/
{/def/gmoc@defbslash{%
    /let\/scan@macro}}
% \CodeEscapeChar\\

\def\task#1#2{}

\endinput

%\NoEOF
