%%
%% This is file `lstpatch.sty', generated manually.
%%
%% Please read the software license in listings.dtx or listings.dvi.
%%
%% (w)(c) 2003 Carsten Heinz
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.0 or, at your option, any later version.
%%
%% Send comments and ideas on the package, error reports and additional
%% programming languages to <cheinz@gmx.de>.
%%
%% This patch file will remove the following bugs from the listings package.
%% Each item contains the bug finder with date of report and first bug fix
%% version, a short description of the problem, and the reason for the bug
%% in parenthesis.
%%
%%  1) Werner Struckmann, 2003/06/25, 1.1a (2003/06/25)
%%
%%     undefined control sequence \lst@name
%%     (init of \lst@name not moved up to \lst@MakeCaption)
%%
%%  2) Denis Girou, 2003/07/04, 1.1b
%%
%%     problem in list environments with fancyvrb=true
%%     (wrong \linewidth used)
%%
%%  3) Carsten Heinz, 2003/07/05, 1.1b
%%
%%     indentation outside list environments with fancyvrb=true
%%     (unremoved par indentation)
%%
%%  4) Jared Warren, 2003/07/10, 1.1b
%%
%%     literate replacement produces "ghosts"
%%     (\lst@BeginDropInput did not suppress output)
%%
%%  5) David Aspinall, 2003/07/17, 1.1b
%%
%%     loading of .fd file inside tabular produces error
%%     (& in \lst@nfss@catcodes must be \&)
%%
%%  6) Edsko de Vries, 2003/07/20, 1.1b (2003/07/22)
%%
%%     bad keywords with language selections only in optional arguments
%%     (\lst@ProvideFamily defined a marker only locally)
%%
%%
%% Moreover the following features have been added.
%%
%%  a) directive delimiter is adjustable: moredelim=*[directive]\#
%%
%%
\ProvidesFile{lstpatch.sty}[2003/08/13 1.1c (Carsten Heinz)]
\lst@CheckVersion{1.1}
{\typeout{^^J%
    ***^^J%
    *** This is a patch for listings 1.1, but you're using^^J%
    *** version \lst@version.^^J%
    ***^^J
    *** Patch file not loaded.^^J%
    ***^^J}%
    \endinput
}
%
% 1) Insert initialization of \lst@name ...
\def\lst@MakeCaption#1{%
    \ifx #1t%
        \ifx\lst@@caption\@empty\expandafter\lst@HRefStepCounter \else
                                \expandafter\refstepcounter
        \fi {lstlisting}%
        \ifx\lst@label\@empty\else \label{\lst@label}\fi
%    ... here.
    \let\lst@arg\lst@intname \lst@ReplaceIn\lst@arg\lst@filenamerpl
    \global\let\lst@name\lst@arg \global\let\lstname\lst@name
        \lst@ifnolol\else
            \ifx\lst@@caption\@empty
                \ifx\lst@caption\@empty
                    \ifx\lst@intname\@empty \else \def\lst@temp{ }%
                    \ifx\lst@intname\lst@temp \else
                        \addcontentsline{lol}{lstlisting}\lst@name
                    \fi\fi
                \fi
            \else
                \addcontentsline{lol}{lstlisting}%
                    {\protect\numberline{\thelstlisting}\lst@@caption}%
            \fi
         \fi
     \fi
    \ifx\lst@caption\@empty\else
        \lst@IfSubstring #1\lst@captionpos
            {\begingroup \let\@@vskip\vskip
             \def\vskip{\afterassignment\lst@vskip \@tempskipa}%
             \def\lst@vskip{\nobreak\@@vskip\@tempskipa\nobreak}%
             \par\normalsize\normalfont
             \ifx #1t\allowbreak \fi
             \ifx\lst@title\@empty
                 \expandafter\@makecaption
             \else
                 \expandafter\lst@maketitle
             \fi
                {\noindent\lstlistingname
                 \ifx\lst@@caption\@empty\else~\thelstlisting\fi}%
                \lst@caption
             \ifx #1b\allowbreak \fi
             \endgroup}{}%
    \fi}
%
% 2) Save \linewidth and restore it after initialization.
\def\lstpatch@fancyvrb{%
\gdef\lstFV@VerbatimBegin{%
    \ifx\FancyVerbFormatLine\lstFV@FancyVerbFormatLine
        \lsthk@TextStyle \lsthk@BoxUnsafe
        \lsthk@PreSet
        \lst@activecharsfalse
        \let\normalbaselines\relax
\xdef\lstFV@RestoreData{\noexpand\linewidth\the\linewidth\relax}%
        \lst@Init\relax
        \lst@ifresetmargins \advance\linewidth-\@totalleftmargin \fi
\lstFV@RestoreData
        \everypar{}\global\lst@newlines\z@
        \lst@mode\lst@nomode \let\lst@entermodes\@empty
        \lst@InterruptModes
%% D.G. modification begin - Nov. 25, 1998
        \let\@noligs\relax
%% D.G. modification end
    \fi}%
% 3) Change \leavevmode to \noindent.
\gdef\lstFV@FancyVerbFormatLine##1{%
    \let\lst@arg\@empty \lst@FVConvert##1\@nil
    \global\lst@newlines\z@
    \vtop{\noindent\lst@parshape
          \lst@ReenterModes
          \lst@arg \lst@PrintToken\lst@EOLUpdate\lsthk@InitVarsBOL
          \lst@InterruptModes}}%
}
%
% 4) Suppress the output by \let\lst@OutputBox\@gobble and ...
\def\lst@BeginDropInput#1{%
    \lst@EnterMode{#1}%
    {\lst@modetrue
     \let\lst@OutputBox\@gobble
     \let\lst@ifdropinput\iftrue
     \let\lst@Process@i\@gobble
     \let\lst@Process@n\@gobble
     \let\lst@Process@m\@gobble
     \let\lst@ProcessSpace\@empty
     \let\lst@ProcessTabulator\@empty
     \let\lst@ProcessFormFeed\@empty}}
%   check for it here:
\def\lst@Literate#1#2#3{%
    \ifx\relax#2\@empty\else
        \lst@ReplaceInput{#1}%
            {\ifx\lst@OutputBox\@gobble\else
               \lst@XPrintToken \let\lst@scanmode\lst@scan@m
               \lst@token{#2}\lst@length#3\relax
               \lst@XPrintToken
             \fi}%
        \expandafter\lst@Literate
    \fi}
%
% 5) Change & to \& at the end of line number four.
\def\lst@nfss@catcodes{%
    \lst@makeletter
        ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\relax
    \@makeother (\@makeother )\@makeother ,\@makeother :\@makeother\&%
    \@makeother 0\@makeother 1\@makeother 2\@makeother 3\@makeother 4%
    \@makeother 5\@makeother 6\@makeother 7\@makeother 8\@makeother 9%
    \@makeother =\lsts@nfss@catcodes}
%
% 6) Insert \global in front of \@namedef.
\def\lstpatch@keywords{%
\gdef\lst@ProvideFamily##1{%
    \@ifundefined{lstfam@##1\ifnum\@tempcnta=\@ne\else\the\@tempcnta\fi}%
    {\global\@namedef{lstfam@##1\ifnum\@tempcnta=\@ne\else \the\@tempcnta\fi}{}%
     \expandafter\expandafter\expandafter\lst@ProvideFamily@
         \csname\@lst @##1@data\endcsname
         {\ifnum\@tempcnta=\@ne\else \the\@tempcnta \fi}}%
    {}}%
}
%
% a) Define new delimiter type `directive'.
\def\lstpatch@directives{%
\lst@AddTo\lst@delimtypes{,directive}
\gdef\lst@Delim@directive##1\@empty##2##3##4{%
    \lst@CArg ##1\relax\lst@DefDelimB
        {\lst@CalcColumn}%
        {}%
        {\ifnum\@tempcnta=\z@
             \def\lst@bnext{##2\lst@CDmode{##4\lst@Lmodetrue}%
			                \let\lst@currstyle\lst@directivestyle}%
		 \fi
		 \@gobblethree}%
        ##2\lst@CDmode{##4\lst@Lmodetrue}%
}% Disable old mechanism.
\lst@AddToHook{SelectCharTable}
    {\ifx\lst@directives\@empty\else
         \lst@Let{`\#}\lsts@CCD
     \fi}%
}
%%
\endinput
%%
%% End of file `lstpatch.sty'.
