File: lstpatch.sty

package info (click to toggle)
xmds-doc 0~svn.1884-3.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 8,336 kB
  • ctags: 192
  • sloc: makefile: 135; python: 55
file content (206 lines) | stat: -rw-r--r-- 7,001 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
%%
%% 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'.