%%
%% warning.sty
%%
%% Global warnings at the end of the screen output and the logfile
%%
%% Copyright 2001  Harald Harders (h.harders@tu-bs.de)
%%
%% License: LPPL
%%
%% Sometimes a class or package has to make a global warning such as
%% ``Rerun for this or that reason'' or ``This is draft, change this
%% before the final run''. If you are generating them with
%% \AtEndDocument{\PackageWarningNoLine{packagename}{warning}}
%% the warning appears very early before the filelist. Then the
%% warning can easily be overseen. This package provides a command
%% that surely puts the warning at the end near to the global
%% warnings generated by LaTeX itself.
%% You can add a warning to a list of user defined warnings using the
%% command \addglobalwarning as it can be seen in the example below.
%%
%% This package could be useful for the warnings generated e.g. by
%% the packages changebar.sty or longtable.sty.
%%
%% Harald Harders
%%
%%
%% Example:
%%
%% \documentclass{article}
%% \usepackage{warning}
%% \addglobalwarning{%
%%   \ClassWarningNoLine{testclass}{This is a global warning}}
%% \addglobalwarning{%
%%   \PackageWarningNoLine{testpackage}{This is another global warning}}
%% \begin{document}
%% Hello
%% \end{document}
%%
%%
\ProvidesPackage{warning}[2001/08/17 v0.01 Global warnings at end of logfile]

% Define a command that adds new warnings to the list of warnings.
% Modification of the \addto command provided by babel.def.
\def\addglobalwarning#1{%
  \ifx\wrn@warning\@undefined
    \def\wrn@warning{#1}%
  \else
    \ifx\wrn@warning\relax
      \def\wrn@warning{#1}%
    \else
      {\toks@\expandafter{\wrn@warning#1}%
        \xdef\wrn@warning{\the\toks@}}%
    \fi
  \fi
}

% Expand \@@end command. I have the feeling that is not too stable.
% Thus not used.
%\let\wrn@end\@@end
%\def\@@end{\wrn@warning\wrn@end}

% Expand \@refundefined command. This does not work if undefined
% references appear after the execution of \AtEndDocument which can happen.
% Thus not used.
%\AtEndDocument{%
%  \let\wrn@refundefined=\@refundefined
%  \def\@refundefined{\wrn@refundefined\wrn@warning}}

% Expand \@dofilelist
% This works with or without \listfiles because \listfile has to be
% used in the preamble and therefor is executed before this definition.
\AtBeginDocument{%
  \let\wrn@dofilelist\@dofilelist
  \def\@dofilelist{\wrn@dofilelist\wrn@warning}%
}

\let\wrn@warning\relax

\endinput
%% EOF