%
%  Replaces TeX's output routine with some hooks
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\def\outputsignal#1{\par\penalty #1}
\newcount\sign@ls\sign@ls=-'10000000000 % ten zeros
\outer\def\newsignal#1{\xdef#1{\number\sign@ls}\advance\sign@ls by 1\relax}
\def\defsig#1{\expandafter\def\csname sig#1\endcsname}
\newsignal{\fin@l}
\defsig\fin@l{\plainoutput}
\def\p@stoutput{}\def\p@stalloutput{}
\def\pr@output{}\def\pr@alloutput{}
%
\output{%
\pr@alloutput
\ifnum\outputpenalty<\sign@ls\relax
\csname sig\number\outputpenalty\endcsname
\else
%
\pr@output
\plainoutput
\p@stoutput
%
\fi\p@stalloutput}
%
\catcode`\@=\c@tcode
