1 | %% |
---|
2 | %% This is file `listings.sty', |
---|
3 | %% generated with the docstrip utility. |
---|
4 | %% |
---|
5 | %% The original source files were: |
---|
6 | %% |
---|
7 | %% listings.dtx (with options: `kernel') |
---|
8 | %% |
---|
9 | %% Please read the software license in listings-1.3.dtx or listings-1.3.pdf. |
---|
10 | %% |
---|
11 | %% (w)(c) 1996--2004 Carsten Heinz and/or any other author listed |
---|
12 | %% elsewhere in this file. |
---|
13 | %% (c) 2006 Brooks Moses |
---|
14 | %% (c) 2013- Jobst Hoffmann |
---|
15 | %% |
---|
16 | %% Send comments and ideas on the package, error reports and additional |
---|
17 | %% programming languages to Jobst Hoffmann at <j.hoffmann@fh-aachen.de>. |
---|
18 | %% |
---|
19 | \def\filedate{2015/06/04} |
---|
20 | \def\fileversion{1.6} |
---|
21 | \NeedsTeXFormat{LaTeX2e} |
---|
22 | \AtEndOfPackage{\ProvidesPackage{listings} |
---|
23 | [\filedate\space\fileversion\space(Carsten Heinz)]} |
---|
24 | \def\lst@CheckVersion#1{\edef\reserved@a{#1}% |
---|
25 | \ifx\lst@version\reserved@a \expandafter\@gobble |
---|
26 | \else \expandafter\@firstofone \fi} |
---|
27 | \let\lst@version\fileversion |
---|
28 | \def\lst@InputCatcodes{% |
---|
29 | \makeatletter \catcode`\"12% |
---|
30 | \catcode`\^^@\active |
---|
31 | \catcode`\^^I9% |
---|
32 | \catcode`\^^L9% |
---|
33 | \catcode`\^^M9% |
---|
34 | \catcode`\%14% |
---|
35 | \catcode`\~\active} |
---|
36 | \def\lst@RestoreCatcodes#1{% |
---|
37 | \ifx\relax#1\else |
---|
38 | \noexpand\catcode`\noexpand#1\the\catcode`#1\relax |
---|
39 | \expandafter\lst@RestoreCatcodes |
---|
40 | \fi} |
---|
41 | \edef\lst@RestoreCatcodes{% |
---|
42 | \noexpand\lccode`\noexpand\/`\noexpand\/% |
---|
43 | \lst@RestoreCatcodes\"\^^I\^^M\~\^^@\relax |
---|
44 | \catcode12\active} |
---|
45 | \lst@InputCatcodes |
---|
46 | \AtEndOfPackage{\lst@RestoreCatcodes} |
---|
47 | \def\@lst{lst} |
---|
48 | \def\lst@IfSubstring#1#2{% |
---|
49 | \def\lst@temp##1#1##2##3\relax{% |
---|
50 | \ifx \@empty##2\expandafter\@secondoftwo |
---|
51 | \else \expandafter\@firstoftwo \fi}% |
---|
52 | \expandafter\lst@temp#2#1\@empty\relax} |
---|
53 | \def\lst@IfOneOf#1\relax#2{% |
---|
54 | \def\lst@temp##1,#1,##2##3\relax{% |
---|
55 | \ifx \@empty##2\expandafter\@secondoftwo |
---|
56 | \else \expandafter\@firstoftwo \fi}% |
---|
57 | \expandafter\lst@temp\expandafter,#2,#1,\@empty\relax} |
---|
58 | \def\lst@DeleteKeysIn#1#2{% |
---|
59 | \expandafter\lst@DeleteKeysIn@\expandafter#1#2,\relax,} |
---|
60 | \def\lst@DeleteKeysIn@#1#2,{% |
---|
61 | \ifx\relax#2\@empty |
---|
62 | \expandafter\@firstoftwo\expandafter\lst@RemoveCommas |
---|
63 | \else |
---|
64 | \ifx\@empty#2\@empty\else |
---|
65 | \def\lst@temp##1,#2,##2{% |
---|
66 | ##1% |
---|
67 | \ifx\@empty##2\@empty\else |
---|
68 | \expandafter\lst@temp\expandafter,% |
---|
69 | \fi ##2}% |
---|
70 | \edef#1{\expandafter\lst@temp\expandafter,#1,#2,\@empty}% |
---|
71 | \fi |
---|
72 | \fi |
---|
73 | \lst@DeleteKeysIn@#1} |
---|
74 | \def\lst@RemoveCommas#1{\edef#1{\expandafter\lst@RC@#1\@empty}} |
---|
75 | \def\lst@RC@#1{\ifx,#1\expandafter\lst@RC@ \else #1\fi} |
---|
76 | \def\lst@ReplaceIn#1#2{% |
---|
77 | \expandafter\lst@ReplaceIn@\expandafter#1#2\@empty\@empty} |
---|
78 | \def\lst@ReplaceInArg#1#2{\lst@ReplaceIn@#1#2\@empty\@empty} |
---|
79 | \def\lst@ReplaceIn@#1#2#3{% |
---|
80 | \ifx\@empty#3\relax\else |
---|
81 | \def\lst@temp##1#2##2{% |
---|
82 | \ifx\@empty##2% |
---|
83 | \lst@lAddTo#1{##1}% |
---|
84 | \else |
---|
85 | \lst@lAddTo#1{##1#3}\expandafter\lst@temp |
---|
86 | \fi ##2}% |
---|
87 | \let\@tempa#1\let#1\@empty |
---|
88 | \expandafter\lst@temp\@tempa#2\@empty |
---|
89 | \expandafter\lst@ReplaceIn@\expandafter#1% |
---|
90 | \fi} |
---|
91 | \providecommand*\@gobblethree[3]{} |
---|
92 | \def\lst@GobbleNil#1\@nil{} |
---|
93 | \def\lst@Swap#1#2{#2#1} |
---|
94 | \def\lst@true{\let\lst@if\iftrue} |
---|
95 | \def\lst@false{\let\lst@if\iffalse} |
---|
96 | \lst@false |
---|
97 | \def\lst@IfNextCharsArg#1{% |
---|
98 | \def\lst@tofind{#1}\lst@IfNextChars\lst@tofind} |
---|
99 | \def\lst@IfNextChars#1#2#3{% |
---|
100 | \let\lst@tofind#1\def\@tempa{#2}\def\@tempb{#3}% |
---|
101 | \let\lst@eaten\@empty \lst@IfNextChars@} |
---|
102 | \def\lst@IfNextChars@{\expandafter\lst@IfNextChars@@\lst@tofind\relax} |
---|
103 | \def\lst@IfNextChars@@#1#2\relax#3{% |
---|
104 | \def\lst@tofind{#2}\lst@lAddTo\lst@eaten{#3}% |
---|
105 | \ifx#1#3% |
---|
106 | \ifx\lst@tofind\@empty |
---|
107 | \let\lst@next\@tempa |
---|
108 | \else |
---|
109 | \let\lst@next\lst@IfNextChars@ |
---|
110 | \fi |
---|
111 | \expandafter\lst@next |
---|
112 | \else |
---|
113 | \expandafter\@tempb |
---|
114 | \fi} |
---|
115 | \def\lst@IfNextCharActive#1#2#3{% |
---|
116 | \begingroup \lccode`\~=`#3\lowercase{\endgroup |
---|
117 | \ifx~}#3% |
---|
118 | \def\lst@next{#1}% |
---|
119 | \else |
---|
120 | \def\lst@next{#2}% |
---|
121 | \fi \lst@next #3} |
---|
122 | \def\lst@for#1\do#2{% |
---|
123 | \def\lst@forbody##1{#2}% |
---|
124 | \def\@tempa{#1}% |
---|
125 | \ifx\@tempa\@empty\else\expandafter\lst@f@r#1,\@nil,\fi |
---|
126 | } |
---|
127 | \def\lst@f@r#1,{% |
---|
128 | \def\@tempa{#1}% |
---|
129 | \ifx\@tempa\@nnil\else\lst@forbody{#1}\expandafter\lst@f@r\fi |
---|
130 | } |
---|
131 | \def\lst@MakeActive#1{% |
---|
132 | \let\lst@temp\@empty \lst@MakeActive@#1% |
---|
133 | \relax\relax\relax\relax\relax\relax\relax\relax\relax} |
---|
134 | \begingroup |
---|
135 | \catcode`\^^@=\active \catcode`\^^A=\active \catcode`\^^B=\active |
---|
136 | \catcode`\^^C=\active \catcode`\^^D=\active \catcode`\^^E=\active |
---|
137 | \catcode`\^^F=\active \catcode`\^^G=\active \catcode`\^^H=\active |
---|
138 | \gdef\lst@MakeActive@#1#2#3#4#5#6#7#8#9{\let\lst@next\relax |
---|
139 | \ifx#1\relax |
---|
140 | \else \lccode`\^^@=`#1% |
---|
141 | \ifx#2\relax |
---|
142 | \lowercase{\lst@lAddTo\lst@temp{^^@}}% |
---|
143 | \else \lccode`\^^A=`#2% |
---|
144 | \ifx#3\relax |
---|
145 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A}}% |
---|
146 | \else \lccode`\^^B=`#3% |
---|
147 | \ifx#4\relax |
---|
148 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B}}% |
---|
149 | \else \lccode`\^^C=`#4% |
---|
150 | \ifx#5\relax |
---|
151 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C}}% |
---|
152 | \else \lccode`\^^D=`#5% |
---|
153 | \ifx#6\relax |
---|
154 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D}}% |
---|
155 | \else \lccode`\^^E=`#6% |
---|
156 | \ifx#7\relax |
---|
157 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E}}% |
---|
158 | \else \lccode`\^^F=`#7% |
---|
159 | \ifx#8\relax |
---|
160 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F}}% |
---|
161 | \else \lccode`\^^G=`#8% |
---|
162 | \ifx#9\relax |
---|
163 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F^^G}}% |
---|
164 | \else \lccode`\^^H=`#9% |
---|
165 | \lowercase{\lst@lAddTo\lst@temp{^^@^^A^^B^^C^^D^^E^^F^^G^^H}}% |
---|
166 | \let\lst@next\lst@MakeActive@ |
---|
167 | \fi \fi \fi \fi \fi \fi \fi \fi \fi |
---|
168 | \lst@next} |
---|
169 | \endgroup |
---|
170 | \def\lst@DefActive#1#2{\lst@MakeActive{#2}\let#1\lst@temp} |
---|
171 | \def\lst@DefOther#1#2{% |
---|
172 | \begingroup \def#1{#2}\escapechar\m@ne \expandafter\endgroup |
---|
173 | \expandafter\lst@DefOther@\meaning#1\relax#1} |
---|
174 | \def\lst@DefOther@#1>#2\relax#3{\edef#3{\zap@space#2 \@empty}} |
---|
175 | \def\lst@InsideConvert#1{% |
---|
176 | \lst@ifmathescape |
---|
177 | \lst@InsideConvert@e#1$\@nil |
---|
178 | \lst@if |
---|
179 | \lst@InsideConvert@ey#1\@nil |
---|
180 | \else |
---|
181 | \lst@InsideConvert@#1 \@empty |
---|
182 | \expandafter\@gobbletwo |
---|
183 | \fi |
---|
184 | \expandafter\lst@next |
---|
185 | \else |
---|
186 | \lst@InsideConvert@#1 \@empty |
---|
187 | \fi} |
---|
188 | \begingroup \lccode`\~=`\ \relax \lowercase{% |
---|
189 | \gdef\lst@InsideConvert@#1 #2{% |
---|
190 | \lst@MakeActive{#1}% |
---|
191 | \ifx\@empty#2% |
---|
192 | \lst@lExtend\lst@arg{\lst@temp}% |
---|
193 | \else |
---|
194 | \lst@lExtend\lst@arg{\lst@temp~}% |
---|
195 | \expandafter\lst@InsideConvert@ |
---|
196 | \fi #2} |
---|
197 | }\endgroup |
---|
198 | \def\lst@InsideConvert@e#1$#2\@nil{% |
---|
199 | \ifx\@empty#2\@empty \lst@false \else \lst@true \fi} |
---|
200 | \def\lst@InsideConvert@ey#1$#2$#3\@nil{% |
---|
201 | \lst@InsideConvert@#1 \@empty |
---|
202 | \lst@lAddTo\lst@arg{% |
---|
203 | \lst@ifdropinput\else |
---|
204 | \lst@TrackNewLines\lst@OutputLostSpace \lst@XPrintToken |
---|
205 | \setbox\@tempboxa=\hbox\bgroup$\lst@escapebegin |
---|
206 | #2% |
---|
207 | \lst@escapeend$\egroup \lst@CalcLostSpaceAndOutput |
---|
208 | \lst@whitespacefalse |
---|
209 | \fi}% |
---|
210 | \def\lst@next{\lst@InsideConvert{#3}}% |
---|
211 | } |
---|
212 | \def\lst@XConvert{\@ifnextchar\bgroup \lst@XConvertArg\lst@XConvert@} |
---|
213 | \def\lst@XConvertArg#1{% |
---|
214 | {\lst@false \let\lst@arg\@empty |
---|
215 | \lst@XConvert#1\@nil |
---|
216 | \global\let\@gtempa\lst@arg}% |
---|
217 | \lst@lExtend\lst@arg{\expandafter{\@gtempa}}% |
---|
218 | \lst@XConvertNext} |
---|
219 | \def\lst@XConvert@#1{% |
---|
220 | \ifx\@nil#1\else |
---|
221 | \begingroup\lccode`\~=`#1\lowercase{\endgroup |
---|
222 | \lst@lAddTo\lst@arg~}% |
---|
223 | \expandafter\lst@XConvertNext |
---|
224 | \fi} |
---|
225 | \def\lst@XConvertNext{% |
---|
226 | \lst@if \expandafter\lst@XConvertX |
---|
227 | \else \expandafter\lst@XConvert \fi} |
---|
228 | \def\lst@XConvertX#1{% |
---|
229 | \ifx\@nil#1\else |
---|
230 | \lst@XConvertX@#1\relax |
---|
231 | \expandafter\lst@XConvert |
---|
232 | \fi} |
---|
233 | \def\lst@XConvertX@#1#2\relax{% |
---|
234 | \begingroup\lccode`\~=`#1\lowercase{\endgroup |
---|
235 | \lst@XCConvertX@@~}{#2}} |
---|
236 | \def\lst@XCConvertX@@#1#2{\lst@lAddTo\lst@arg{{#1#2}}} |
---|
237 | \def\lst@Require#1#2#3#4#5{% |
---|
238 | \begingroup |
---|
239 | \aftergroup\lst@true |
---|
240 | \ifx\@empty#3\@empty\else |
---|
241 | \def\lst@prefix{#2}\let\lst@require\@empty |
---|
242 | \edef\lst@temp{\expandafter\zap@space#3 \@empty}% |
---|
243 | \lst@for\lst@temp\do{% |
---|
244 | \ifx\@empty##1\@empty\else \lstKV@OptArg[]{##1}{% |
---|
245 | #4[####1]{####2}% |
---|
246 | \@ifundefined{\@lst\lst@prefix @\lst@malias $\lst@oalias}% |
---|
247 | {\edef\lst@require{\lst@require,\lst@malias $\lst@oalias}}% |
---|
248 | {}}% |
---|
249 | \fi}% |
---|
250 | \global\let\lst@loadaspects\@empty |
---|
251 | \lst@InputCatcodes |
---|
252 | \ifx\lst@require\@empty\else |
---|
253 | \lst@for{#5}\do{% |
---|
254 | \ifx\lst@require\@empty\else |
---|
255 | \InputIfFileExists{##1}{}{}% |
---|
256 | \fi}% |
---|
257 | \fi |
---|
258 | \ifx\lst@require\@empty\else |
---|
259 | \PackageError{Listings}{Couldn't load requested #1}% |
---|
260 | {The following #1s weren't loadable:^^J\@spaces |
---|
261 | \lst@require^^JThis may cause errors in the sequel.}% |
---|
262 | \aftergroup\lst@false |
---|
263 | \fi |
---|
264 | \ifx\lst@loadaspects\@empty\else |
---|
265 | \lst@RequireAspects\lst@loadaspects |
---|
266 | \fi |
---|
267 | \fi |
---|
268 | \endgroup} |
---|
269 | \def\lst@IfRequired[#1]#2{% |
---|
270 | \lst@NormedDef\lst@temp{[#1]#2}% |
---|
271 | \expandafter\lst@IfRequired@\lst@temp\relax} |
---|
272 | \def\lst@IfRequired@[#1]#2\relax#3{% |
---|
273 | \lst@IfOneOf #2$#1\relax\lst@require |
---|
274 | {\lst@DeleteKeysIn@\lst@require#2$#1,\relax,% |
---|
275 | \global\expandafter\let |
---|
276 | \csname\@lst\lst@prefix @#2$#1\endcsname\@empty |
---|
277 | #3}} |
---|
278 | \let\lst@require\@empty |
---|
279 | \def\lst@NoAlias[#1]#2{% |
---|
280 | \lst@NormedDef\lst@oalias{#1}\lst@NormedDef\lst@malias{#2}} |
---|
281 | \gdef\lst@LAS#1#2#3#4#5#6#7{% |
---|
282 | \lst@Require{#1}{#2}{#3}#4#5% |
---|
283 | #4#3% |
---|
284 | \@ifundefined{lst#2@\lst@malias$\lst@oalias}% |
---|
285 | {\PackageError{Listings}% |
---|
286 | {#1 \ifx\@empty\lst@oalias\else \lst@oalias\space of \fi |
---|
287 | \lst@malias\space undefined}% |
---|
288 | {The #1 is not loadable. \@ehc}}% |
---|
289 | {#6\csname\@lst#2@\lst@malias $\lst@oalias\endcsname #7}} |
---|
290 | \def\lst@RequireAspects#1{% |
---|
291 | \lst@Require{aspect}{asp}{#1}\lst@NoAlias\lstaspectfiles} |
---|
292 | \let\lstloadaspects\lst@RequireAspects |
---|
293 | \@ifundefined{lstaspectfiles} |
---|
294 | {\newcommand\lstaspectfiles{lstmisc0.sty,lstmisc.sty}}{} |
---|
295 | \gdef\lst@DefDriver#1#2#3#4{% |
---|
296 | \@ifnextchar[{\lst@DefDriver@{#1}{#2}#3#4}% |
---|
297 | {\lst@DefDriver@{#1}{#2}#3#4[]}} |
---|
298 | \gdef\lst@DefDriver@#1#2#3#4[#5]#6{% |
---|
299 | \def\lst@name{#1}\let\lst@if#4% |
---|
300 | \lst@NormedDef\lst@driver{\@lst#2@#6$#5}% |
---|
301 | \lst@IfRequired[#5]{#6}{\begingroup \lst@true}% |
---|
302 | {\begingroup}% |
---|
303 | \lst@setcatcodes |
---|
304 | \@ifnextchar[{\lst@XDefDriver{#1}#3}{\lst@DefDriver@@#3}} |
---|
305 | \gdef\lst@DefDriver@@#1#2{% |
---|
306 | \lst@if |
---|
307 | \global\@namedef{\lst@driver}{#1{#2}}% |
---|
308 | \fi |
---|
309 | \endgroup |
---|
310 | \@ifnextchar[\lst@XXDefDriver\@empty} |
---|
311 | \gdef\lst@XXDefDriver[#1]{% |
---|
312 | \ifx\@empty#1\@empty\else |
---|
313 | \lst@if |
---|
314 | \lstloadaspects{#1}% |
---|
315 | \else |
---|
316 | \@ifundefined{\lst@driver}{}% |
---|
317 | {\xdef\lst@loadaspects{\lst@loadaspects,#1}}% |
---|
318 | \fi |
---|
319 | \fi} |
---|
320 | \gdef\lst@XDefDriver#1#2[#3]#4#5{\lst@DefDriver@@#2{also#1=[#3]#4,#5}} |
---|
321 | \let\lst@UserCommand\gdef |
---|
322 | \newcommand*\lst@BeginAspect[2][]{% |
---|
323 | \def\lst@curraspect{#2}% |
---|
324 | \ifx \lst@curraspect\@empty |
---|
325 | \expandafter\lst@GobbleAspect |
---|
326 | \else |
---|
327 | \let\lst@next\@empty |
---|
328 | \lst@IfRequired[]{#2}% |
---|
329 | {\lst@RequireAspects{#1}% |
---|
330 | \lst@if\else \let\lst@next\lst@GobbleAspect \fi}% |
---|
331 | {\let\lst@next\lst@GobbleAspect}% |
---|
332 | \expandafter\lst@next |
---|
333 | \fi} |
---|
334 | \def\lst@EndAspect{% |
---|
335 | \csname\@lst patch@\lst@curraspect\endcsname |
---|
336 | \let\lst@curraspect\@empty} |
---|
337 | \long\def\lst@GobbleAspect#1\lst@EndAspect{\let\lst@curraspect\@empty} |
---|
338 | \def\lst@Key#1#2{% |
---|
339 | \@ifnextchar[{\lstKV@def{#1}{#2}}% |
---|
340 | {\def\lst@temp{\lst@Key@{#1}{#2}} |
---|
341 | \afterassignment\lst@temp |
---|
342 | \global\@namedef{KV@\@lst @#1}####1}} |
---|
343 | \def\lstKV@def#1#2[#3]{% |
---|
344 | \global\@namedef{KV@\@lst @#1@default\expandafter}\expandafter |
---|
345 | {\csname KV@\@lst @#1\endcsname{#3}}% |
---|
346 | \def\lst@temp{\lst@Key@{#1}{#2}}\afterassignment\lst@temp |
---|
347 | \global\@namedef{KV@\@lst @#1}##1} |
---|
348 | \def\lst@Key@#1#2{% |
---|
349 | \ifx\relax#2\@empty\else |
---|
350 | \begingroup \globaldefs\@ne |
---|
351 | \csname KV@\@lst @#1\endcsname{#2}% |
---|
352 | \endgroup |
---|
353 | \fi} |
---|
354 | \def\lst@UseHook#1{\csname\@lst hk@#1\endcsname} |
---|
355 | \def\lst@AddToHook{\lst@ATH@\iffalse\lst@AddTo} |
---|
356 | \def\lst@AddToHookExe{\lst@ATH@\iftrue\lst@AddTo} |
---|
357 | \def\lst@AddToHookAtTop{\lst@ATH@\iffalse\lst@AddToAtTop} |
---|
358 | \long\def\lst@ATH@#1#2#3#4{% |
---|
359 | \@ifundefined{\@lst hk@#3}{% |
---|
360 | \expandafter\gdef\csname\@lst hk@#3\endcsname{}}{}% |
---|
361 | \expandafter#2\csname\@lst hk@#3\endcsname{#4}% |
---|
362 | \def\lst@temp{#4}% |
---|
363 | #1% \iftrue|false |
---|
364 | \begingroup \globaldefs\@ne \lst@temp \endgroup |
---|
365 | \fi} |
---|
366 | \long\def\lst@AddTo#1#2{% |
---|
367 | \expandafter\gdef\expandafter#1\expandafter{#1#2}} |
---|
368 | \def\lst@AddToAtTop#1#2{\def\lst@temp{#2}% |
---|
369 | \expandafter\expandafter\expandafter\gdef |
---|
370 | \expandafter\expandafter\expandafter#1% |
---|
371 | \expandafter\expandafter\expandafter{\expandafter\lst@temp#1}} |
---|
372 | \def\lst@lAddTo#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} |
---|
373 | \def\lst@Extend#1#2{% |
---|
374 | \expandafter\lst@AddTo\expandafter#1\expandafter{#2}} |
---|
375 | \def\lst@lExtend#1#2{% |
---|
376 | \expandafter\lst@lAddTo\expandafter#1\expandafter{#2}} |
---|
377 | \RequirePackage{keyval}[1997/11/10] |
---|
378 | \def\lstKV@TwoArg#1#2{\gdef\@gtempa##1##2{#2}\@gtempa#1{}{}} |
---|
379 | \def\lstKV@ThreeArg#1#2{\gdef\@gtempa##1##2##3{#2}\@gtempa#1{}{}{}} |
---|
380 | \def\lstKV@FourArg#1#2{\gdef\@gtempa##1##2##3##4{#2}\@gtempa#1{}{}{}{}} |
---|
381 | \def\lstKV@OptArg[#1]#2#3{% |
---|
382 | \gdef\@gtempa[##1]##2{#3}\lstKV@OptArg@{#1}#2\@} |
---|
383 | \def\lstKV@OptArg@#1{\@ifnextchar[\lstKV@OptArg@@{\lstKV@OptArg@@[#1]}} |
---|
384 | \def\lstKV@OptArg@@[#1]#2\@{\@gtempa[#1]{#2}} |
---|
385 | \def\lstKV@XOptArg[#1]#2#3{% |
---|
386 | \global\let\@gtempa#3\lstKV@OptArg@{#1}#2\@} |
---|
387 | \def\lstKV@CSTwoArg#1#2{% |
---|
388 | \gdef\@gtempa##1,##2,##3\relax{#2}% |
---|
389 | \@gtempa#1,,\relax} |
---|
390 | \def\lstKV@SetIf#1{\lstKV@SetIf@#1\relax} |
---|
391 | \def\lstKV@SetIf@#1#2\relax#3{\lowercase{% |
---|
392 | \expandafter\let\expandafter#3% |
---|
393 | \csname if\ifx #1t}true\else false\fi\endcsname} |
---|
394 | \def\lstKV@SwitchCases#1#2#3{% |
---|
395 | \def\lst@temp##1\\#1&##2\\##3##4\@nil{% |
---|
396 | \ifx\@empty##3% |
---|
397 | #3% |
---|
398 | \else |
---|
399 | ##2% |
---|
400 | \fi |
---|
401 | }% |
---|
402 | \lst@temp\\#2\\#1&\\\@empty\@nil} |
---|
403 | \lst@UserCommand\lstset{\begingroup \lst@setcatcodes \lstset@} |
---|
404 | \def\lstset@#1{\endgroup \ifx\@empty#1\@empty\else\setkeys{lst}{#1}\fi} |
---|
405 | \def\lst@setcatcodes{\makeatletter \catcode`\==12\relax} |
---|
406 | \def\lst@NewMode#1{% |
---|
407 | \ifx\@undefined#1% |
---|
408 | \lst@mode\lst@newmode\relax \advance\lst@mode\@ne |
---|
409 | \xdef\lst@newmode{\the\lst@mode}% |
---|
410 | \global\chardef#1=\lst@mode |
---|
411 | \lst@mode\lst@nomode |
---|
412 | \fi} |
---|
413 | \newcount\lst@mode |
---|
414 | \def\lst@newmode{\m@ne}% init |
---|
415 | \lst@NewMode\lst@nomode % init (of \lst@mode :-) |
---|
416 | \def\lst@UseDynamicMode{% |
---|
417 | \@tempcnta\lst@dynamicmode\relax \advance\@tempcnta\@ne |
---|
418 | \edef\lst@dynamicmode{\the\@tempcnta}% |
---|
419 | \expandafter\lst@Swap\expandafter{\expandafter{\lst@dynamicmode}}} |
---|
420 | \lst@AddToHook{InitVars}{\let\lst@dynamicmode\lst@newmode} |
---|
421 | \def\lst@EnterMode#1#2{% |
---|
422 | \bgroup \lst@mode=#1\relax #2% |
---|
423 | \lst@FontAdjust |
---|
424 | \lst@lAddTo\lst@entermodes{\lst@EnterMode{#1}{#2}}} |
---|
425 | \lst@AddToHook{InitVars}{\let\lst@entermodes\@empty} |
---|
426 | \let\lst@entermodes\@empty % init |
---|
427 | \def\lst@LeaveMode{% |
---|
428 | \ifnum\lst@mode=\lst@nomode\else |
---|
429 | \egroup \expandafter\lsthk@EndGroup |
---|
430 | \fi} |
---|
431 | \lst@AddToHook{EndGroup}{}% init |
---|
432 | \def\lst@InterruptModes{% |
---|
433 | \lst@Extend\lst@modestack{\expandafter{\lst@entermodes}}% |
---|
434 | \lst@LeaveAllModes} |
---|
435 | \lst@AddToHook{InitVars}{\global\let\lst@modestack\@empty} |
---|
436 | \def\lst@ReenterModes{% |
---|
437 | \ifx\lst@modestack\@empty\else |
---|
438 | \lst@LeaveAllModes |
---|
439 | \global\let\@gtempa\lst@modestack |
---|
440 | \global\let\lst@modestack\@empty |
---|
441 | \expandafter\lst@ReenterModes@\@gtempa\relax |
---|
442 | \fi} |
---|
443 | \def\lst@ReenterModes@#1#2{% |
---|
444 | \ifx\relax#2\@empty |
---|
445 | \gdef\@gtempa##1{#1}% |
---|
446 | \expandafter\@gtempa |
---|
447 | \else |
---|
448 | \lst@AddTo\lst@modestack{{#1}}% |
---|
449 | \expandafter\lst@ReenterModes@ |
---|
450 | \fi |
---|
451 | {#2}} |
---|
452 | \def\lst@LeaveAllModes{% |
---|
453 | \ifnum\lst@mode=\lst@nomode |
---|
454 | \expandafter\lsthk@EndGroup |
---|
455 | \else |
---|
456 | \expandafter\egroup\expandafter\lst@LeaveAllModes |
---|
457 | \fi} |
---|
458 | \lst@AddToHook{ExitVars}{\lst@LeaveAllModes} |
---|
459 | \lst@NewMode\lst@Pmode |
---|
460 | \lst@NewMode\lst@GPmode |
---|
461 | \def\lst@modetrue{\let\lst@ifmode\iftrue \lsthk@ModeTrue} |
---|
462 | \let\lst@ifmode\iffalse % init |
---|
463 | \lst@AddToHook{ModeTrue}{}% init |
---|
464 | \def\lst@Lmodetrue{\let\lst@ifLmode\iftrue} |
---|
465 | \let\lst@ifLmode\iffalse % init |
---|
466 | \lst@AddToHook{EOL}{\@whilesw \lst@ifLmode\fi \lst@LeaveMode} |
---|
467 | \def\lst@NormedDef#1#2{\lowercase{\edef#1{\zap@space#2 \@empty}}} |
---|
468 | \def\lst@NormedNameDef#1#2{% |
---|
469 | \lowercase{\edef\lst@temp{\zap@space#1 \@empty}% |
---|
470 | \expandafter\xdef\csname\lst@temp\endcsname{\zap@space#2 \@empty}}} |
---|
471 | \def\lst@GetFreeMacro#1{% |
---|
472 | \@tempcnta\z@ \def\lst@freemacro{#1\the\@tempcnta}% |
---|
473 | \lst@GFM@} |
---|
474 | \def\lst@GFM@{% |
---|
475 | \expandafter\ifx \csname\lst@freemacro\endcsname \relax |
---|
476 | \edef\lst@freemacro{\csname\lst@freemacro\endcsname}% |
---|
477 | \else |
---|
478 | \advance\@tempcnta\@ne |
---|
479 | \expandafter\lst@GFM@ |
---|
480 | \fi} |
---|
481 | \newbox\lst@gtempboxa |
---|
482 | \newtoks\lst@token \newcount\lst@length \newcount\lst@colposn |
---|
483 | \def\lst@ResetToken{\lst@token{}\lst@length\z@} |
---|
484 | \lst@AddToHook{InitVarsBOL}{\lst@ResetToken \let\lst@lastother\@empty} |
---|
485 | \lst@AddToHook{EndGroup}{\lst@ResetToken \let\lst@lastother\@empty} |
---|
486 | \def\lst@lettertrue{\let\lst@ifletter\iftrue} |
---|
487 | \def\lst@letterfalse{\let\lst@ifletter\iffalse} |
---|
488 | \lst@AddToHook{InitVars}{\lst@letterfalse} |
---|
489 | \def\lst@Append#1{\advance\lst@length\@ne |
---|
490 | \lst@token=\expandafter{\the\lst@token#1}} |
---|
491 | \def\lst@AppendOther{% |
---|
492 | \lst@ifletter \lst@Output\lst@letterfalse \fi |
---|
493 | \futurelet\lst@lastother\lst@Append} |
---|
494 | \def\lst@AppendLetter{% |
---|
495 | \lst@ifletter\else \lst@OutputOther\lst@lettertrue \fi |
---|
496 | \lst@Append} |
---|
497 | \def\lst@SaveToken{% |
---|
498 | \global\let\lst@gthestyle\lst@thestyle |
---|
499 | \global\let\lst@glastother\lst@lastother |
---|
500 | \xdef\lst@RestoreToken{\noexpand\lst@token{\the\lst@token}% |
---|
501 | \noexpand\lst@length\the\lst@length\relax |
---|
502 | \noexpand\let\noexpand\lst@thestyle |
---|
503 | \noexpand\lst@gthestyle |
---|
504 | \noexpand\let\noexpand\lst@lastother |
---|
505 | \noexpand\lst@glastother}} |
---|
506 | \def\lst@IfLastOtherOneOf#1{\lst@IfLastOtherOneOf@ #1\relax} |
---|
507 | \def\lst@IfLastOtherOneOf@#1{% |
---|
508 | \ifx #1\relax |
---|
509 | \expandafter\@secondoftwo |
---|
510 | \else |
---|
511 | \ifx\lst@lastother#1% |
---|
512 | \lst@IfLastOtherOneOf@t |
---|
513 | \else |
---|
514 | \expandafter\expandafter\expandafter\lst@IfLastOtherOneOf@ |
---|
515 | \fi |
---|
516 | \fi} |
---|
517 | \def\lst@IfLastOtherOneOf@t#1\fi\fi#2\relax{\fi\fi\@firstoftwo} |
---|
518 | \newdimen\lst@currlwidth % \global |
---|
519 | \newcount\lst@column \newcount\lst@pos % \global |
---|
520 | \lst@AddToHook{InitVarsBOL} |
---|
521 | {\global\lst@currlwidth\z@ \global\lst@pos\z@ \global\lst@column\z@} |
---|
522 | \def\lst@CalcColumn{% |
---|
523 | \@tempcnta\lst@column |
---|
524 | \advance\@tempcnta\lst@length |
---|
525 | \advance\@tempcnta-\lst@pos} |
---|
526 | \newdimen\lst@lostspace % \global |
---|
527 | \lst@AddToHook{InitVarsBOL}{\global\lst@lostspace\z@} |
---|
528 | \def\lst@UseLostSpace{\ifdim\lst@lostspace>\z@ \lst@InsertLostSpace \fi} |
---|
529 | \def\lst@InsertLostSpace{% |
---|
530 | \lst@Kern\lst@lostspace \global\lst@lostspace\z@} |
---|
531 | \def\lst@InsertHalfLostSpace{% |
---|
532 | \global\lst@lostspace.5\lst@lostspace \lst@Kern\lst@lostspace} |
---|
533 | \newdimen\lst@width |
---|
534 | \lst@Key{basewidth}{0.6em,0.45em}{\lstKV@CSTwoArg{#1}% |
---|
535 | {\def\lst@widthfixed{##1}\def\lst@widthflexible{##2}% |
---|
536 | \ifx\lst@widthflexible\@empty |
---|
537 | \let\lst@widthflexible\lst@widthfixed |
---|
538 | \fi |
---|
539 | \def\lst@temp{\PackageError{Listings}% |
---|
540 | {Negative value(s) treated as zero}% |
---|
541 | \@ehc}% |
---|
542 | \let\lst@error\@empty |
---|
543 | \ifdim \lst@widthfixed<\z@ |
---|
544 | \let\lst@error\lst@temp \let\lst@widthfixed\z@ |
---|
545 | \fi |
---|
546 | \ifdim \lst@widthflexible<\z@ |
---|
547 | \let\lst@error\lst@temp \let\lst@widthflexible\z@ |
---|
548 | \fi |
---|
549 | \lst@error}} |
---|
550 | \lst@AddToHook{FontAdjust} |
---|
551 | {\lst@width=\lst@ifflexible\lst@widthflexible |
---|
552 | \else\lst@widthfixed\fi \relax} |
---|
553 | \lst@Key{fontadjust}{false}[t]{\lstKV@SetIf{#1}\lst@iffontadjust} |
---|
554 | \def\lst@FontAdjust{\lst@iffontadjust \lsthk@FontAdjust \fi} |
---|
555 | \lst@AddToHook{InitVars}{\lsthk@FontAdjust} |
---|
556 | \def\lst@OutputBox#1{\lst@alloverstyle{\box#1}} |
---|
557 | \def\lst@alloverstyle#1{#1}% init |
---|
558 | \def\lst@Kern#1{% |
---|
559 | \setbox\z@\hbox{{\lst@currstyle{\kern#1}}}% |
---|
560 | \global\advance\lst@currlwidth \wd\z@ |
---|
561 | \lst@OutputBox\z@} |
---|
562 | \def\lst@CalcLostSpaceAndOutput{% |
---|
563 | \global\advance\lst@lostspace \lst@length\lst@width |
---|
564 | \global\advance\lst@lostspace-\wd\@tempboxa |
---|
565 | \global\advance\lst@currlwidth \wd\@tempboxa |
---|
566 | \global\advance\lst@pos -\lst@length |
---|
567 | \setbox\@tempboxa\hbox{\let\lst@OutputBox\box |
---|
568 | \ifdim\lst@lostspace>\z@ \lst@leftinsert \fi |
---|
569 | \box\@tempboxa |
---|
570 | \ifdim\lst@lostspace>\z@ \lst@rightinsert \fi}% |
---|
571 | \lst@OutputBox\@tempboxa \lsthk@PostOutput} |
---|
572 | \lst@AddToHook{PostOutput}{}% init |
---|
573 | \def\lst@OutputToken{% |
---|
574 | \lst@TrackNewLines \lst@OutputLostSpace |
---|
575 | \lst@ifgobbledws |
---|
576 | \lst@gobbledwhitespacefalse |
---|
577 | \lst@@discretionary |
---|
578 | \fi |
---|
579 | \lst@CheckMerge |
---|
580 | {\lst@thestyle{\lst@FontAdjust |
---|
581 | \setbox\@tempboxa\lst@hbox |
---|
582 | {\lsthk@OutputBox |
---|
583 | \lst@lefthss |
---|
584 | \expandafter\lst@FillOutputBox\the\lst@token\@empty |
---|
585 | \lst@righthss}% |
---|
586 | \lst@CalcLostSpaceAndOutput}}% |
---|
587 | \lst@ResetToken} |
---|
588 | \lst@AddToHook{OutputBox}{}% init |
---|
589 | \def\lst@gobbledwhitespacetrue{\global\let\lst@ifgobbledws\iftrue} |
---|
590 | \def\lst@gobbledwhitespacefalse{\global\let\lst@ifgobbledws\iffalse} |
---|
591 | \lst@AddToHookExe{InitBOL}{\lst@gobbledwhitespacefalse}% init |
---|
592 | \def\lst@Delay#1{% |
---|
593 | \lst@CheckDelay |
---|
594 | #1% |
---|
595 | \lst@GetOutputMacro\lst@delayedoutput |
---|
596 | \edef\lst@delayed{\the\lst@token}% |
---|
597 | \edef\lst@delayedlength{\the\lst@length}% |
---|
598 | \lst@ResetToken} |
---|
599 | \def\lst@Merge#1{% |
---|
600 | \lst@CheckMerge |
---|
601 | #1% |
---|
602 | \edef\lst@merged{\the\lst@token}% |
---|
603 | \edef\lst@mergedlength{\the\lst@length}% |
---|
604 | \lst@ResetToken} |
---|
605 | \def\lst@MergeToken#1#2{% |
---|
606 | \advance\lst@length#2% |
---|
607 | \lst@lExtend#1{\the\lst@token}% |
---|
608 | \expandafter\lst@token\expandafter{#1}% |
---|
609 | \let#1\@empty} |
---|
610 | \def\lst@CheckDelay{% |
---|
611 | \ifx\lst@delayed\@empty\else |
---|
612 | \lst@GetOutputMacro\@gtempa |
---|
613 | \ifx\lst@delayedoutput\@gtempa |
---|
614 | \lst@MergeToken\lst@delayed\lst@delayedlength |
---|
615 | \else |
---|
616 | {\lst@ResetToken |
---|
617 | \lst@MergeToken\lst@delayed\lst@delayedlength |
---|
618 | \lst@delayedoutput}% |
---|
619 | \let\lst@delayed\@empty |
---|
620 | \fi |
---|
621 | \fi} |
---|
622 | \def\lst@CheckMerge{% |
---|
623 | \ifx\lst@merged\@empty\else |
---|
624 | \lst@MergeToken\lst@merged\lst@mergedlength |
---|
625 | \fi} |
---|
626 | \let\lst@delayed\@empty % init |
---|
627 | \let\lst@merged\@empty % init |
---|
628 | \def\lst@column@fixed{% |
---|
629 | \lst@flexiblefalse |
---|
630 | \lst@width\lst@widthfixed\relax |
---|
631 | \let\lst@OutputLostSpace\lst@UseLostSpace |
---|
632 | \let\lst@FillOutputBox\lst@FillFixed |
---|
633 | \let\lst@hss\hss |
---|
634 | \def\lst@hbox{\hbox to\lst@length\lst@width}} |
---|
635 | \def\lst@FillFixed#1{#1\lst@FillFixed@} |
---|
636 | \def\lst@FillFixed@#1{% |
---|
637 | \ifx\@empty#1\else \lst@hss#1\expandafter\lst@FillFixed@ \fi} |
---|
638 | \def\lst@column@flexible{% |
---|
639 | \lst@flexibletrue |
---|
640 | \lst@width\lst@widthflexible\relax |
---|
641 | \let\lst@OutputLostSpace\lst@UseLostSpace |
---|
642 | \let\lst@FillOutputBox\@empty |
---|
643 | \let\lst@hss\@empty |
---|
644 | \let\lst@hbox\hbox} |
---|
645 | \def\lst@column@fullflexible{% |
---|
646 | \lst@column@flexible |
---|
647 | \def\lst@OutputLostSpace{\lst@ifnewline \lst@UseLostSpace\fi}% |
---|
648 | \let\lst@leftinsert\@empty |
---|
649 | \let\lst@rightinsert\@empty} |
---|
650 | \def\lst@column@spaceflexible{% |
---|
651 | \lst@column@flexible |
---|
652 | \def\lst@OutputLostSpace{% |
---|
653 | \lst@ifwhitespace |
---|
654 | \ifx\lst@outputspace\lst@visiblespace |
---|
655 | \else |
---|
656 | \lst@UseLostSpace |
---|
657 | \fi |
---|
658 | \else |
---|
659 | \lst@ifnewline \lst@UseLostSpace\fi |
---|
660 | \fi}% |
---|
661 | \let\lst@leftinsert\@empty |
---|
662 | \let\lst@rightinsert\@empty} |
---|
663 | \def\lst@outputpos#1#2\relax{% |
---|
664 | \def\lst@lefthss{\lst@hss}\let\lst@righthss\lst@lefthss |
---|
665 | \let\lst@rightinsert\lst@InsertLostSpace |
---|
666 | \ifx #1c% |
---|
667 | \let\lst@leftinsert\lst@InsertHalfLostSpace |
---|
668 | \else\ifx #1r% |
---|
669 | \let\lst@righthss\@empty |
---|
670 | \let\lst@leftinsert\lst@InsertLostSpace |
---|
671 | \let\lst@rightinsert\@empty |
---|
672 | \else |
---|
673 | \let\lst@lefthss\@empty |
---|
674 | \let\lst@leftinsert\@empty |
---|
675 | \ifx #1l\else \PackageWarning{Listings}% |
---|
676 | {Unknown positioning for output boxes}% |
---|
677 | \fi |
---|
678 | \fi\fi} |
---|
679 | \def\lst@flexibletrue{\let\lst@ifflexible\iftrue} |
---|
680 | \def\lst@flexiblefalse{\let\lst@ifflexible\iffalse} |
---|
681 | \lst@Key{columns}{[c]fixed}{\lstKV@OptArg[]{#1}{% |
---|
682 | \ifx\@empty##1\@empty\else \lst@outputpos##1\relax\relax \fi |
---|
683 | \expandafter\let\expandafter\lst@arg |
---|
684 | \csname\@lst @column@##2\endcsname |
---|
685 | \lst@arg |
---|
686 | \ifx\lst@arg\relax |
---|
687 | \PackageWarning{Listings}{Unknown column format `##2'}% |
---|
688 | \else |
---|
689 | \lst@ifflexible |
---|
690 | \let\lst@columnsflexible\lst@arg |
---|
691 | \else |
---|
692 | \let\lst@columnsfixed\lst@arg |
---|
693 | \fi |
---|
694 | \fi}} |
---|
695 | \let\lst@columnsfixed\lst@column@fixed % init |
---|
696 | \let\lst@columnsflexible\lst@column@flexible % init |
---|
697 | \lst@Key{flexiblecolumns}\relax[t]{% |
---|
698 | \lstKV@SetIf{#1}\lst@ifflexible |
---|
699 | \lst@ifflexible \lst@columnsflexible |
---|
700 | \else \lst@columnsfixed \fi} |
---|
701 | \newcount\lst@newlines |
---|
702 | \lst@AddToHook{InitVars}{\global\lst@newlines\z@} |
---|
703 | \lst@AddToHook{InitVarsBOL}{\global\advance\lst@newlines\@ne} |
---|
704 | \def\lst@NewLine{% |
---|
705 | \ifx\lst@OutputBox\@gobble\else |
---|
706 | \par\noindent \hbox{}% |
---|
707 | \fi |
---|
708 | \lst@colposn\z@ |
---|
709 | \global\advance\lst@newlines\m@ne |
---|
710 | \lst@newlinetrue} |
---|
711 | \def\lst@newlinetrue{\global\let\lst@ifnewline\iftrue} |
---|
712 | \lst@AddToHookExe{PostOutput}{\global\let\lst@ifnewline\iffalse}% init |
---|
713 | \def\lst@TrackNewLines{% |
---|
714 | \ifnum\lst@newlines>\z@ |
---|
715 | \lsthk@OnNewLine |
---|
716 | \lst@DoNewLines |
---|
717 | \fi} |
---|
718 | \lst@AddToHook{OnNewLine}{}% init |
---|
719 | \lst@Key{emptylines}\maxdimen{% |
---|
720 | \@ifstar{\lst@true\@tempcnta\@gobble#1\relax\lst@GobbleNil}% |
---|
721 | {\lst@false\@tempcnta#1\relax\lst@GobbleNil}#1\@nil |
---|
722 | \advance\@tempcnta\@ne |
---|
723 | \edef\lst@maxempty{\the\@tempcnta\relax}% |
---|
724 | \let\lst@ifpreservenumber\lst@if} |
---|
725 | \def\lst@DoNewLines{ |
---|
726 | \@whilenum\lst@newlines>\lst@maxempty \do |
---|
727 | {\lst@ifpreservenumber |
---|
728 | \lsthk@OnEmptyLine |
---|
729 | \global\advance\c@lstnumber\lst@advancelstnum |
---|
730 | \fi |
---|
731 | \global\advance\lst@newlines\m@ne}% |
---|
732 | \@whilenum \lst@newlines>\@ne \do |
---|
733 | {\lsthk@OnEmptyLine \lst@NewLine}% |
---|
734 | \ifnum\lst@newlines>\z@ \lst@NewLine \fi} |
---|
735 | \lst@AddToHook{OnEmptyLine}{}% init |
---|
736 | \lst@Key{identifierstyle}{}{\def\lst@identifierstyle{#1}} |
---|
737 | \lst@AddToHook{EmptyStyle}{\let\lst@identifierstyle\@empty} |
---|
738 | \def\lst@GotoTabStop{% |
---|
739 | \ifnum\lst@newlines=\z@ |
---|
740 | \setbox\@tempboxa\hbox{\lst@outputspace}% |
---|
741 | \setbox\@tempboxa\hbox to\wd\@tempboxa{{\lst@currstyle{\hss}}}% |
---|
742 | \lst@CalcLostSpaceAndOutput |
---|
743 | \else |
---|
744 | \global\advance\lst@lostspace \lst@length\lst@width |
---|
745 | \global\advance\lst@column\lst@length \lst@length\z@ |
---|
746 | \fi} |
---|
747 | \def\lst@OutputOther{% |
---|
748 | \lst@CheckDelay |
---|
749 | \ifnum\lst@length=\z@\else |
---|
750 | \let\lst@thestyle\lst@currstyle |
---|
751 | \lsthk@OutputOther |
---|
752 | \lst@OutputToken |
---|
753 | \fi} |
---|
754 | \lst@AddToHook{OutputOther}{}% init |
---|
755 | \let\lst@currstyle\relax % init |
---|
756 | \def\lst@Output{% |
---|
757 | \lst@CheckDelay |
---|
758 | \ifnum\lst@length=\z@\else |
---|
759 | \ifx\lst@currstyle\relax |
---|
760 | \let\lst@thestyle\lst@identifierstyle |
---|
761 | \else |
---|
762 | \let\lst@thestyle\lst@currstyle |
---|
763 | \fi |
---|
764 | \lsthk@Output |
---|
765 | \lst@OutputToken |
---|
766 | \fi |
---|
767 | \let\lst@lastother\relax} |
---|
768 | \lst@AddToHook{Output}{}% init |
---|
769 | \def\lst@GetOutputMacro#1{% |
---|
770 | \lst@ifletter \global\let#1\lst@Output |
---|
771 | \else \global\let#1\lst@OutputOther\fi} |
---|
772 | \def\lst@PrintToken{% |
---|
773 | \lst@ifletter \lst@Output \lst@letterfalse |
---|
774 | \else \lst@OutputOther \let\lst@lastother\@empty \fi} |
---|
775 | \def\lst@XPrintToken{% |
---|
776 | \lst@PrintToken \lst@CheckMerge |
---|
777 | \ifnum\lst@length=\z@\else \lst@PrintToken \fi} |
---|
778 | \def\lst@BeginDropOutput#1{% |
---|
779 | \xdef\lst@BDOnewlines{\the\lst@newlines}% |
---|
780 | \global\let\lst@BDOifnewline\lst@ifnewline |
---|
781 | \lst@EnterMode{#1}% |
---|
782 | {\lst@modetrue |
---|
783 | \let\lst@OutputBox\@gobble |
---|
784 | \aftergroup\lst@BDORestore}} |
---|
785 | \def\lst@BDORestore{% |
---|
786 | \global\lst@newlines\lst@BDOnewlines |
---|
787 | \global\let\lst@ifnewline\lst@BDOifnewline} |
---|
788 | \let\lst@EndDropOutput\lst@LeaveMode |
---|
789 | \def\lst@ProcessLetter{\lst@whitespacefalse \lst@AppendLetter} |
---|
790 | \def\lst@ProcessOther{\lst@whitespacefalse \lst@AppendOther} |
---|
791 | \def\lst@ProcessDigit{% |
---|
792 | \lst@whitespacefalse |
---|
793 | \lst@ifletter \expandafter\lst@AppendLetter |
---|
794 | \else \expandafter\lst@AppendOther\fi} |
---|
795 | \def\lst@whitespacetrue{\global\let\lst@ifwhitespace\iftrue} |
---|
796 | \def\lst@whitespacefalse{\global\let\lst@ifwhitespace\iffalse} |
---|
797 | \lst@AddToHook{InitVarsBOL}{\lst@whitespacetrue} |
---|
798 | \lst@Key{tabsize}{8} |
---|
799 | {\ifnum#1>\z@ \def\lst@tabsize{#1}\else |
---|
800 | \PackageError{Listings}{Strict positive integer expected}% |
---|
801 | {You can't use `#1' as tabsize. \@ehc}% |
---|
802 | \fi} |
---|
803 | \lst@Key{showtabs}f[t]{\lstKV@SetIf{#1}\lst@ifshowtabs} |
---|
804 | \lst@Key{tab}{\kern.06em\hbox{\vrule\@height.3ex}% |
---|
805 | \hrulefill\hbox{\vrule\@height.3ex}} |
---|
806 | {\def\lst@tab{#1}} |
---|
807 | \def\lst@ProcessTabulator{% |
---|
808 | \lst@XPrintToken \lst@whitespacetrue |
---|
809 | \global\advance\lst@column -\lst@pos |
---|
810 | \@whilenum \lst@pos<\@ne \do |
---|
811 | {\global\advance\lst@pos\lst@tabsize}% |
---|
812 | \lst@length\lst@pos |
---|
813 | \lst@PreGotoTabStop} |
---|
814 | \def\lst@PreGotoTabStop{% |
---|
815 | \lst@ifshowtabs |
---|
816 | \lst@TrackNewLines |
---|
817 | \setbox\@tempboxa\hbox to\lst@length\lst@width |
---|
818 | {{\lst@currstyle{\hss\lst@tab}}}% |
---|
819 | \lst@CalcLostSpaceAndOutput |
---|
820 | \else |
---|
821 | \lst@ifkeepspaces |
---|
822 | % \@tempcnta\lst@length \lst@length\z@ |
---|
823 | \@tempcnta\lst@length |
---|
824 | % \@whilenum \@tempcnta>\z@ \do |
---|
825 | % { |
---|
826 | % \lst@AppendOther\lst@outputspace |
---|
827 | %\the\lst@column |
---|
828 | %\the\lst@colposn/\the\lst@length/\the\lst@column/\the\numexpr ( \lst@column + \lst@tabsize ) |
---|
829 | \the\lst@currlwidth |
---|
830 | \ifnum\lst@colposn=\z@ |
---|
831 | \ifnum\lst@length=\lst@tabsize |
---|
832 | \makebox[\the\numexpr ( \lst@tabsize ) * 10pt]{} |
---|
833 | \else |
---|
834 | \makebox[\the\numexpr ( \lst@length ) * 5pt]{} |
---|
835 | \fi |
---|
836 | \else |
---|
837 | \makebox[\the\numexpr ( \lst@length ) * 5pt]{} |
---|
838 | \fi |
---|
839 | \advance\lst@column\lst@length |
---|
840 | % \advance\@tempcnta\m@ne |
---|
841 | % }% |
---|
842 | \lst@OutputOther |
---|
843 | \else |
---|
844 | \lst@GotoTabStop |
---|
845 | \fi |
---|
846 | \fi |
---|
847 | \lst@length\z@ \global\lst@pos\z@} |
---|
848 | \def\lst@outputspace{\ } |
---|
849 | \def\lst@visiblespace{\lst@ttfamily{\char32}\textvisiblespace} |
---|
850 | \lst@Key{showspaces}{false}[t]{\lstKV@SetIf{#1}\lst@ifshowspaces} |
---|
851 | \lst@Key{keepspaces}{false}[t]{\lstKV@SetIf{#1}\lst@ifkeepspaces} |
---|
852 | \lst@AddToHook{Init} |
---|
853 | {\lst@ifshowspaces |
---|
854 | \let\lst@outputspace\lst@visiblespace |
---|
855 | \lst@keepspacestrue |
---|
856 | \fi} |
---|
857 | \def\lst@keepspacestrue{\let\lst@ifkeepspaces\iftrue} |
---|
858 | \def\lst@ProcessSpace{% |
---|
859 | \lst@ifkeepspaces |
---|
860 | \lst@PrintToken |
---|
861 | \lst@whitespacetrue |
---|
862 | \lst@AppendOther\lst@outputspace |
---|
863 | \lst@PrintToken |
---|
864 | \else \ifnum\lst@newlines=\z@ |
---|
865 | \lst@AppendSpecialSpace |
---|
866 | \else \ifnum\lst@length=\z@ |
---|
867 | \global\advance\lst@lostspace\lst@width |
---|
868 | \global\advance\lst@pos\m@ne |
---|
869 | \lst@whitespacetrue |
---|
870 | \else |
---|
871 | \lst@AppendSpecialSpace |
---|
872 | \fi |
---|
873 | \fi \fi} |
---|
874 | \def\lst@AppendSpecialSpace{% |
---|
875 | \lst@ifwhitespace |
---|
876 | \lst@PrintToken |
---|
877 | \global\advance\lst@lostspace\lst@width |
---|
878 | \global\advance\lst@pos\m@ne |
---|
879 | \lst@gobbledwhitespacetrue |
---|
880 | \else |
---|
881 | \lst@PrintToken |
---|
882 | \lst@whitespacetrue |
---|
883 | \lst@AppendOther\lst@outputspace |
---|
884 | \lst@PrintToken |
---|
885 | \fi} |
---|
886 | \lst@Key{formfeed}{\bigbreak}{\def\lst@formfeed{#1}} |
---|
887 | \def\lst@ProcessFormFeed{% |
---|
888 | \lst@XPrintToken |
---|
889 | \ifnum\lst@newlines=\z@ |
---|
890 | \lst@EOLUpdate \lsthk@InitVarsBOL |
---|
891 | \fi |
---|
892 | \lst@formfeed |
---|
893 | \lst@whitespacetrue} |
---|
894 | \def\lst@Def#1{\lccode`\~=#1\lowercase{\def~}} |
---|
895 | \def\lst@Let#1{\lccode`\~=#1\lowercase{\let~}} |
---|
896 | \lst@AddToAtTop{\try@load@fontshape}{\def\space{ }} |
---|
897 | \def\lst@SelectStdCharTable{% |
---|
898 | \lst@Def{9}{\lst@ProcessTabulator}% |
---|
899 | \lst@Def{12}{\lst@ProcessFormFeed}% |
---|
900 | \lst@Def{32}{\lst@ProcessSpace}} |
---|
901 | \def\lst@CCPut#1#2{% |
---|
902 | \ifnum#2=\z@ |
---|
903 | \expandafter\@gobbletwo |
---|
904 | \else |
---|
905 | \lccode`\~=#2\lccode`\/=#2\lowercase{\lst@CCPut@~{#1/}}% |
---|
906 | \fi |
---|
907 | \lst@CCPut#1} |
---|
908 | \def\lst@CCPut@#1#2{\lst@lAddTo\lst@SelectStdCharTable{\def#1{#2}}} |
---|
909 | \lst@CCPut \lst@ProcessOther |
---|
910 | {"21}{"22}{"28}{"29}{"2B}{"2C}{"2E}{"2F} |
---|
911 | {"3A}{"3B}{"3D}{"3F}{"5B}{"5D} |
---|
912 | \z@ |
---|
913 | \lst@CCPut \lst@ProcessDigit |
---|
914 | {"30}{"31}{"32}{"33}{"34}{"35}{"36}{"37}{"38}{"39} |
---|
915 | \z@ |
---|
916 | \lst@CCPut \lst@ProcessLetter |
---|
917 | {"40}{"41}{"42}{"43}{"44}{"45}{"46}{"47} |
---|
918 | {"48}{"49}{"4A}{"4B}{"4C}{"4D}{"4E}{"4F} |
---|
919 | {"50}{"51}{"52}{"53}{"54}{"55}{"56}{"57} |
---|
920 | {"58}{"59}{"5A} |
---|
921 | {"61}{"62}{"63}{"64}{"65}{"66}{"67} |
---|
922 | {"68}{"69}{"6A}{"6B}{"6C}{"6D}{"6E}{"6F} |
---|
923 | {"70}{"71}{"72}{"73}{"74}{"75}{"76}{"77} |
---|
924 | {"78}{"79}{"7A} |
---|
925 | \z@ |
---|
926 | \def\lst@CCPutMacro#1#2#3{% |
---|
927 | \ifnum#2=\z@ \else |
---|
928 | \begingroup\lccode`\~=#2\relax \lccode`\/=#2\relax |
---|
929 | \lowercase{\endgroup\expandafter\lst@CCPutMacro@ |
---|
930 | \csname\@lst @um/\expandafter\endcsname |
---|
931 | \csname\@lst @um/@\endcsname /~}#1{#3}% |
---|
932 | \expandafter\lst@CCPutMacro |
---|
933 | \fi} |
---|
934 | \def\lst@CCPutMacro@#1#2#3#4#5#6{% |
---|
935 | \lst@lAddTo\lst@SelectStdCharTable{\def#4{#5#1}}% |
---|
936 | \def#1{\lst@UM#3}% |
---|
937 | \def#2{#6}} |
---|
938 | \def\lst@UM#1{\csname\@lst @um#1@\endcsname} |
---|
939 | \lst@CCPutMacro |
---|
940 | \lst@ProcessOther {"23}\# |
---|
941 | \lst@ProcessLetter{"24}\textdollar |
---|
942 | \lst@ProcessOther {"25}\% |
---|
943 | \lst@ProcessOther {"26}\& |
---|
944 | \lst@ProcessOther {"27}{\lst@ifupquote \textquotesingle |
---|
945 | \else \char39\relax \fi} |
---|
946 | \lst@ProcessOther {"2A}{\lst@ttfamily*\textasteriskcentered} |
---|
947 | \lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{$-$}} |
---|
948 | \lst@ProcessOther {"3C}{\lst@ttfamily<\textless} |
---|
949 | \lst@ProcessOther {"3E}{\lst@ttfamily>\textgreater} |
---|
950 | \lst@ProcessOther {"5C}{\lst@ttfamily{\char92}\textbackslash} |
---|
951 | \lst@ProcessOther {"5E}\textasciicircum |
---|
952 | \lst@ProcessLetter{"5F}{\lst@ttfamily{\char95}\textunderscore} |
---|
953 | \lst@ProcessOther {"60}{\lst@ifupquote \textasciigrave |
---|
954 | \else \char96\relax \fi} |
---|
955 | \lst@ProcessOther {"7B}{\lst@ttfamily{\char123}\textbraceleft} |
---|
956 | \lst@ProcessOther {"7C}{\lst@ttfamily|\textbar} |
---|
957 | \lst@ProcessOther {"7D}{\lst@ttfamily{\char125}\textbraceright} |
---|
958 | \lst@ProcessOther {"7E}\textasciitilde |
---|
959 | \lst@ProcessOther {"7F}- |
---|
960 | \@empty\z@\@empty |
---|
961 | \def\lst@ttfamily#1#2{\ifx\f@family\ttdefault#1\relax\else#2\fi} |
---|
962 | \lst@AddToHook{Init}{\edef\ttdefault{\ttdefault}} |
---|
963 | \lst@Key{upquote}{false}[t]{\lstKV@SetIf{#1}\lst@ifupquote |
---|
964 | \lst@ifupquote |
---|
965 | \@ifundefined{textasciigrave}% |
---|
966 | {\let\KV@lst@upquote\@gobble |
---|
967 | \lstKV@SetIf f\lst@ifupquote \@gobble\fi |
---|
968 | \PackageError{Listings}{Option `upquote' requires `textcomp' |
---|
969 | package.\MessageBreak The option has been disabled}% |
---|
970 | {Add \string\usepackage{textcomp} to your preamble.}}% |
---|
971 | {}% |
---|
972 | \fi} |
---|
973 | \AtBeginDocument{% |
---|
974 | \@ifpackageloaded{upquote}{\RequirePackage{textcomp}% |
---|
975 | \lstset{upquote}}{}% |
---|
976 | \@ifpackageloaded{upquote2}{\lstset{upquote}}{}} |
---|
977 | \def\lst@activecharstrue{\let\lst@ifactivechars\iftrue} |
---|
978 | \def\lst@activecharsfalse{\let\lst@ifactivechars\iffalse} |
---|
979 | \lst@activecharstrue |
---|
980 | \def\lst@SelectCharTable{% |
---|
981 | \lst@SelectStdCharTable |
---|
982 | \lst@ifactivechars |
---|
983 | \catcode9\active \catcode12\active \catcode13\active |
---|
984 | \@tempcnta=32\relax |
---|
985 | \@whilenum\@tempcnta<128\do |
---|
986 | {\catcode\@tempcnta\active\advance\@tempcnta\@ne}% |
---|
987 | \fi |
---|
988 | \lst@ifec \lst@DefEC \fi |
---|
989 | \let\do\lst@do@noligs \verbatim@nolig@list |
---|
990 | \lsthk@SelectCharTable |
---|
991 | \lst@DeveloperSCT |
---|
992 | \lst@DefRange |
---|
993 | \ifx\lst@Backslash\relax\else |
---|
994 | \lst@LetSaveDef{"5C}\lsts@backslash\lst@Backslash |
---|
995 | \fi} |
---|
996 | \lst@Key{SelectCharTable}{}{\def\lst@DeveloperSCT{#1}} |
---|
997 | \lst@Key{MoreSelectCharTable}\relax{\lst@lAddTo\lst@DeveloperSCT{#1}} |
---|
998 | \lst@AddToHook{SetLanguage}{\let\lst@DeveloperSCT\@empty} |
---|
999 | \def\lst@do@noligs#1{% |
---|
1000 | \begingroup \lccode`\~=`#1\lowercase{\endgroup |
---|
1001 | \lst@do@noligs@~}} |
---|
1002 | \def\lst@do@noligs@#1{% |
---|
1003 | \expandafter\expandafter\expandafter\def |
---|
1004 | \expandafter\expandafter\expandafter#1% |
---|
1005 | \expandafter\expandafter\expandafter{\expandafter\lst@NoLig#1}} |
---|
1006 | \def\lst@NoLig{\advance\lst@length\m@ne \lst@Append\lst@nolig} |
---|
1007 | \def\lst@nolig{\lst@UM\@empty}% |
---|
1008 | \@namedef{\@lst @um@}{\leavevmode\kern\z@} |
---|
1009 | \def\lst@SaveOutputDef#1#2{% |
---|
1010 | \begingroup \lccode`\~=#1\relax \lowercase{\endgroup |
---|
1011 | \def\lst@temp##1\def~##2##3\relax}{% |
---|
1012 | \global\expandafter\let\expandafter#2\@gobble##2\relax}% |
---|
1013 | \expandafter\lst@temp\lst@SelectStdCharTable\relax} |
---|
1014 | \lst@SaveOutputDef{"5C}\lstum@backslash |
---|
1015 | \lst@Key{extendedchars}{true}[t]{\lstKV@SetIf{#1}\lst@ifec} |
---|
1016 | \def\lst@DefEC{% |
---|
1017 | \lst@CCECUse \lst@ProcessLetter |
---|
1018 | ^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f% |
---|
1019 | ^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f% |
---|
1020 | ^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af% |
---|
1021 | ^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf% |
---|
1022 | ^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf% |
---|
1023 | ^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df% |
---|
1024 | ^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef% |
---|
1025 | ^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff% |
---|
1026 | ^^00} |
---|
1027 | \def\lst@CCECUse#1#2{% |
---|
1028 | \ifnum`#2=\z@ |
---|
1029 | \expandafter\@gobbletwo |
---|
1030 | \else |
---|
1031 | \ifnum\catcode`#2=\active |
---|
1032 | \lccode`\~=`#2\lccode`\/=`#2\lowercase{\lst@CCECUse@#1~/}% |
---|
1033 | \else |
---|
1034 | \lst@ifactivechars \catcode`#2=\active \fi |
---|
1035 | \lccode`\~=`#2\lccode`\/=`#2\lowercase{\def~{#1/}}% |
---|
1036 | \fi |
---|
1037 | \fi |
---|
1038 | \lst@CCECUse#1} |
---|
1039 | \def\lst@CCECUse@#1#2#3{% |
---|
1040 | \expandafter\def\csname\@lst @EC#3\endcsname{\lst@UM#3}% |
---|
1041 | \expandafter\let\csname\@lst @um#3@\endcsname #2% |
---|
1042 | \edef#2{\noexpand#1% |
---|
1043 | \expandafter\noexpand\csname\@lst @EC#3\endcsname}} |
---|
1044 | \lst@AddToHook{Init} |
---|
1045 | {\let\lsts@nfss@catcodes\nfss@catcodes |
---|
1046 | \let\nfss@catcodes\lst@nfss@catcodes} |
---|
1047 | \def\lst@nfss@catcodes{% |
---|
1048 | \lst@makeletter |
---|
1049 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\relax |
---|
1050 | \@makeother (\@makeother )\@makeother ,\@makeother :\@makeother\&% |
---|
1051 | \@makeother 0\@makeother 1\@makeother 2\@makeother 3\@makeother 4% |
---|
1052 | \@makeother 5\@makeother 6\@makeother 7\@makeother 8\@makeother 9% |
---|
1053 | \@makeother =\lsts@nfss@catcodes} |
---|
1054 | \def\lst@makeletter#1{% |
---|
1055 | \ifx\relax#1\else\catcode`#111\relax \expandafter\lst@makeletter\fi} |
---|
1056 | \lst@Key{useoutput}{2}{\edef\lst@useoutput{\ifcase0#1 0\or 1\else 2\fi}} |
---|
1057 | \lst@AddToHook{Init} |
---|
1058 | {\edef\lst@OrgOutput{\the\output}% |
---|
1059 | \ifcase\lst@useoutput\relax |
---|
1060 | \or |
---|
1061 | \output{\global\setbox\lst@gtempboxa\box\@cclv |
---|
1062 | \expandafter\egroup |
---|
1063 | \lst@SaveToken |
---|
1064 | \lst@InterruptModes |
---|
1065 | \setbox\@cclv\box\lst@gtempboxa |
---|
1066 | \bgroup\lst@OrgOutput\egroup |
---|
1067 | \bgroup |
---|
1068 | \aftergroup\pagegoal\aftergroup\vsize |
---|
1069 | \aftergroup\lst@ReenterModes\aftergroup\lst@RestoreToken}% |
---|
1070 | \else |
---|
1071 | \output{\lst@RestoreOrigCatcodes |
---|
1072 | \lst@ifec \lst@RestoreOrigExtendedCatcodes \fi |
---|
1073 | \lst@OrgOutput}% |
---|
1074 | \fi} |
---|
1075 | \def\lst@GetChars#1#2#3{% |
---|
1076 | \let#1\@empty |
---|
1077 | \@tempcnta#2\relax \@tempcntb#3\relax |
---|
1078 | \loop \ifnum\@tempcnta<\@tempcntb\relax |
---|
1079 | \lst@lExtend#1{\expandafter\catcode\the\@tempcnta=}% |
---|
1080 | \lst@lExtend#1{\the\catcode\@tempcnta\relax}% |
---|
1081 | \ifnum\the\catcode\@tempcnta=\active |
---|
1082 | \begingroup\lccode`\~=\@tempcnta |
---|
1083 | \lowercase{\endgroup |
---|
1084 | \lst@lExtend#1{\expandafter\let\expandafter~\csname |
---|
1085 | lstecs@\the\@tempcnta\endcsname}% |
---|
1086 | \expandafter\let\csname lstecs@\the\@tempcnta\endcsname~}% |
---|
1087 | \fi |
---|
1088 | \advance\@tempcnta\@ne |
---|
1089 | \repeat} |
---|
1090 | \begingroup \catcode12=\active\let^^L\@empty |
---|
1091 | \gdef\lst@ScanChars{% |
---|
1092 | \let\lsts@ssL^^L% |
---|
1093 | \def^^L{\par}% |
---|
1094 | \lst@GetChars\lst@RestoreOrigCatcodes\@ne {128}% |
---|
1095 | \let^^L\lsts@ssL |
---|
1096 | \lst@GetChars\lst@RestoreOrigExtendedCatcodes{128}{256}} |
---|
1097 | \endgroup |
---|
1098 | \lst@Key{rescanchars}\relax{\lst@ScanChars} |
---|
1099 | \AtBeginDocument{\lst@ScanChars} |
---|
1100 | \lst@Key{alsoletter}\relax{% |
---|
1101 | \lst@DoAlso{#1}\lst@alsoletter\lst@ProcessLetter} |
---|
1102 | \lst@Key{alsodigit}\relax{% |
---|
1103 | \lst@DoAlso{#1}\lst@alsodigit\lst@ProcessDigit} |
---|
1104 | \lst@Key{alsoother}\relax{% |
---|
1105 | \lst@DoAlso{#1}\lst@alsoother\lst@ProcessOther} |
---|
1106 | \lst@AddToHook{SelectCharTable} |
---|
1107 | {\lst@alsoother \lst@alsodigit \lst@alsoletter} |
---|
1108 | \lst@AddToHookExe{SetLanguage}% init |
---|
1109 | {\let\lst@alsoletter\@empty |
---|
1110 | \let\lst@alsodigit\@empty |
---|
1111 | \let\lst@alsoother\@empty} |
---|
1112 | \def\lst@DoAlso#1#2#3{% |
---|
1113 | \lst@DefOther\lst@arg{#1}\let#2\@empty |
---|
1114 | \expandafter\lst@DoAlso@\expandafter#2\expandafter#3\lst@arg\relax} |
---|
1115 | \def\lst@DoAlso@#1#2#3{% |
---|
1116 | \ifx\relax#3\expandafter\@gobblethree \else |
---|
1117 | \begingroup \lccode`\~=`#3\relax \lowercase{\endgroup |
---|
1118 | \def\lst@temp##1\def~##2##3\relax{% |
---|
1119 | \edef\lst@arg{\def\noexpand~{\noexpand#2\expandafter |
---|
1120 | \noexpand\@gobble##2}}}}% |
---|
1121 | \expandafter\lst@temp\lst@SelectStdCharTable\relax |
---|
1122 | \lst@lExtend#1{\lst@arg}% |
---|
1123 | \fi |
---|
1124 | \lst@DoAlso@#1#2} |
---|
1125 | \def\lst@SaveDef#1#2{% |
---|
1126 | \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~}} |
---|
1127 | \def\lst@DefSaveDef#1#2{% |
---|
1128 | \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~\def~}} |
---|
1129 | \def\lst@LetSaveDef#1#2{% |
---|
1130 | \begingroup \lccode`\~=#1\relax \lowercase{\endgroup\let#2~\let~}} |
---|
1131 | \def\lst@CDef#1{\lst@CDef@#1} |
---|
1132 | \def\lst@CDef@#1#2#3#4{\lst@CDefIt#1{#2}{#3}{#4#2#3}#4} |
---|
1133 | \def\lst@CDefX#1{\lst@CDefX@#1} |
---|
1134 | \def\lst@CDefX@#1#2#3{\lst@CDefIt#1{#2}{#3}{}} |
---|
1135 | \def\lst@CDefIt#1#2#3#4#5#6#7#8{% |
---|
1136 | \ifx\@empty#2\@empty |
---|
1137 | \def#1{#6\def\lst@next{#7#4#8}\lst@next}% |
---|
1138 | \else \ifx\@empty#3\@empty |
---|
1139 | \def#1##1{% |
---|
1140 | #6% |
---|
1141 | \ifx##1#2\def\lst@next{#7#4#8}\else |
---|
1142 | \def\lst@next{#5##1}\fi |
---|
1143 | \lst@next}% |
---|
1144 | \else |
---|
1145 | \def#1{% |
---|
1146 | #6% |
---|
1147 | \lst@IfNextCharsArg{#2#3}{#7#4#8}% |
---|
1148 | {\expandafter#5\lst@eaten}}% |
---|
1149 | \fi \fi} |
---|
1150 | \def\lst@CArgX#1#2\relax{% |
---|
1151 | \lst@DefActive\lst@arg{#1#2}% |
---|
1152 | \expandafter\lst@CArg\lst@arg\relax} |
---|
1153 | \def\lst@CArg#1#2\relax{% |
---|
1154 | \lccode`\/=`#1\lowercase{\def\lst@temp{/}}% |
---|
1155 | \lst@GetFreeMacro{lst@c\lst@temp}% |
---|
1156 | \expandafter\lst@CArg@\lst@freemacro#1#2\@empty\@empty\relax} |
---|
1157 | \def\lst@CArg@#1#2#3#4\@empty#5\relax#6{% |
---|
1158 | \let#1#2% |
---|
1159 | \ifx\@empty#3\@empty |
---|
1160 | \def\lst@next{#6{#2{}{}}}% |
---|
1161 | \else |
---|
1162 | \def\lst@next{#6{#2#3{#4}}}% |
---|
1163 | \fi |
---|
1164 | \lst@next #1} |
---|
1165 | \def\lst@CArgEmpty#1\@empty{#1} |
---|
1166 | \lst@Key{excludedelims}\relax |
---|
1167 | {\lsthk@ExcludeDelims \lst@NormedDef\lst@temp{#1}% |
---|
1168 | \expandafter\lst@for\lst@temp\do |
---|
1169 | {\expandafter\let\csname\@lst @ifex##1\endcsname\iftrue}} |
---|
1170 | \def\lst@DelimPrint#1#2{% |
---|
1171 | #1% |
---|
1172 | \begingroup |
---|
1173 | \lst@mode\lst@nomode \lst@modetrue |
---|
1174 | #2\lst@XPrintToken |
---|
1175 | \endgroup |
---|
1176 | \lst@ResetToken |
---|
1177 | \fi} |
---|
1178 | \def\lst@DelimOpen#1#2#3#4#5#6\@empty{% |
---|
1179 | \lst@TrackNewLines \lst@XPrintToken |
---|
1180 | \lst@DelimPrint#1{#6}% |
---|
1181 | \lst@EnterMode{#4}{\def\lst@currstyle#5}% |
---|
1182 | \lst@DelimPrint{#1#2}{#6}% |
---|
1183 | #3} |
---|
1184 | \def\lst@DelimClose#1#2#3\@empty{% |
---|
1185 | \lst@TrackNewLines \lst@XPrintToken |
---|
1186 | \lst@DelimPrint{#1#2}{#3}% |
---|
1187 | \lst@LeaveMode |
---|
1188 | \lst@DelimPrint{#1}{#3}} |
---|
1189 | \def\lst@BeginDelim{\lst@DelimOpen\iffalse\else{}} |
---|
1190 | \def\lst@EndDelim{\lst@DelimClose\iffalse\else} |
---|
1191 | \def\lst@BeginIDelim{\lst@DelimOpen\iffalse{}{}} |
---|
1192 | \def\lst@EndIDelim{\lst@DelimClose\iffalse{}} |
---|
1193 | \lst@AddToHook{SelectCharTable}{\lst@DefDelims} |
---|
1194 | \lst@AddToHookExe{SetLanguage}{\let\lst@DefDelims\@empty} |
---|
1195 | \def\lst@Delim#1{% |
---|
1196 | \lst@false \let\lst@cumulative\@empty \let\lst@arg\@empty |
---|
1197 | \@ifstar{\@ifstar{\lst@Delim@{#1}}% |
---|
1198 | {\let\lst@cumulative\relax |
---|
1199 | \lst@Delim@{#1}}}% |
---|
1200 | {\lst@true\lst@Delim@{#1}}} |
---|
1201 | \def\lst@Delim@#1[#2]{% |
---|
1202 | \gdef\lst@delimtype{#2}% |
---|
1203 | \@ifnextchar[\lst@Delim@sty |
---|
1204 | {\lst@Delim@sty[#1]}} |
---|
1205 | \def\lst@Delim@sty[#1]{% |
---|
1206 | \def\lst@delimstyle{#1}% |
---|
1207 | \ifx\@empty#1\@empty\else |
---|
1208 | \lst@Delim@sty@ #1\@nil |
---|
1209 | \fi |
---|
1210 | \@ifnextchar[\lst@Delim@option |
---|
1211 | \lst@Delim@delim} |
---|
1212 | \def\lst@Delim@option[#1]{\def\lst@arg{[#1]}\lst@Delim@delim} |
---|
1213 | \def\lst@Delim@sty@#1#2\@nil{% |
---|
1214 | \if\relax\noexpand#1\else |
---|
1215 | \edef\lst@delimstyle{\expandafter\noexpand |
---|
1216 | \csname\@lst @\lst@delimstyle\endcsname}% |
---|
1217 | \fi} |
---|
1218 | \def\lst@Delim@delim#1\relax#2#3#4#5#6#7#8{% |
---|
1219 | \ifx #4\@empty \lst@Delim@delall{#2}\fi |
---|
1220 | \ifx\@empty#1\@empty |
---|
1221 | \ifx #4\@nil |
---|
1222 | \@ifundefined{\@lst @#2DM@\lst@delimtype}% |
---|
1223 | {\lst@Delim@delall{#2@\lst@delimtype}}% |
---|
1224 | {\lst@Delim@delall{#2DM@\lst@delimtype}}% |
---|
1225 | \fi |
---|
1226 | \else |
---|
1227 | \expandafter\lst@Delim@args\expandafter |
---|
1228 | {\lst@delimtype}{#1}{#5}#6{#7}{#8}#4% |
---|
1229 | \let\lst@delim\@empty |
---|
1230 | \expandafter\lst@IfOneOf\lst@delimtype\relax#3% |
---|
1231 | {\@ifundefined{\@lst @#2DM@\lst@delimtype}% |
---|
1232 | {\lst@lExtend\lst@delim{\csname\@lst @#2@\lst@delimtype |
---|
1233 | \expandafter\endcsname\lst@arg}}% |
---|
1234 | {\lst@lExtend\lst@delim{\expandafter\lst@UseDynamicMode |
---|
1235 | \csname\@lst @#2DM@\lst@delimtype |
---|
1236 | \expandafter\endcsname\lst@arg}}% |
---|
1237 | \ifx #4\@nil |
---|
1238 | \let\lst@temp\lst@DefDelims \let\lst@DefDelims\@empty |
---|
1239 | \expandafter\lst@Delim@del\lst@temp\@empty\@nil\@nil\@nil |
---|
1240 | \else |
---|
1241 | \lst@lExtend\lst@DefDelims\lst@delim |
---|
1242 | \fi}% |
---|
1243 | {\PackageError{Listings}{Illegal type `\lst@delimtype'}% |
---|
1244 | {#2 types are #3.}}% |
---|
1245 | \fi} |
---|
1246 | \def\lst@Delim@args#1#2#3#4#5#6#7{% |
---|
1247 | \begingroup |
---|
1248 | \lst@false \let\lst@next\lst@XConvert |
---|
1249 | \@ifnextchar #4{\xdef\lst@delimtype{\expandafter\@gobble |
---|
1250 | \lst@delimtype}% |
---|
1251 | #5\lst@next#2\@nil |
---|
1252 | \lst@lAddTo\lst@arg{\@empty#6}% |
---|
1253 | \lst@GobbleNil}% |
---|
1254 | {\lst@next#2\@nil |
---|
1255 | \lst@lAddTo\lst@arg{\@empty#3}% |
---|
1256 | \lst@GobbleNil}% |
---|
1257 | #1\@nil |
---|
1258 | \global\let\@gtempa\lst@arg |
---|
1259 | \endgroup |
---|
1260 | \let\lst@arg\@gtempa |
---|
1261 | \ifx #7\@nil\else |
---|
1262 | \expandafter\lst@Delim@args@\expandafter{\lst@delimstyle}% |
---|
1263 | \fi} |
---|
1264 | \def\lst@Delim@args@#1{% |
---|
1265 | \lst@if |
---|
1266 | \lst@lAddTo\lst@arg{{{#1}\lst@modetrue}}% |
---|
1267 | \else |
---|
1268 | \ifx\lst@cumulative\@empty |
---|
1269 | \lst@lAddTo\lst@arg{{{}#1}}% |
---|
1270 | \else |
---|
1271 | \lst@lAddTo\lst@arg{{{#1}}}% |
---|
1272 | \fi |
---|
1273 | \fi} |
---|
1274 | \def\lst@Delim@del#1\@empty#2#3#4{% |
---|
1275 | \ifx #2\@nil\else |
---|
1276 | \def\lst@temp{#1\@empty#2#3}% |
---|
1277 | \ifx\lst@temp\lst@delim\else |
---|
1278 | \lst@lAddTo\lst@DefDelims{#1\@empty#2#3{#4}}% |
---|
1279 | \fi |
---|
1280 | \expandafter\lst@Delim@del |
---|
1281 | \fi} |
---|
1282 | \def\lst@Delim@delall#1{% |
---|
1283 | \begingroup |
---|
1284 | \edef\lst@delim{\expandafter\string\csname\@lst @#1\endcsname}% |
---|
1285 | \lst@false \global\let\@gtempa\@empty |
---|
1286 | \expandafter\lst@Delim@delall@\lst@DefDelims\@empty |
---|
1287 | \endgroup |
---|
1288 | \let\lst@DefDelims\@gtempa} |
---|
1289 | \def\lst@Delim@delall@#1{% |
---|
1290 | \ifx #1\@empty\else |
---|
1291 | \ifx #1\lst@UseDynamicMode |
---|
1292 | \lst@true |
---|
1293 | \let\lst@next\lst@Delim@delall@do |
---|
1294 | \else |
---|
1295 | \def\lst@next{\lst@Delim@delall@do#1}% |
---|
1296 | \fi |
---|
1297 | \expandafter\lst@next |
---|
1298 | \fi} |
---|
1299 | \def\lst@Delim@delall@do#1#2\@empty#3#4#5{% |
---|
1300 | \expandafter\lst@IfSubstring\expandafter{\lst@delim}{\string#1}% |
---|
1301 | {}% |
---|
1302 | {\lst@if \lst@AddTo\@gtempa\lst@UseDynamicMode \fi |
---|
1303 | \lst@AddTo\@gtempa{#1#2\@empty#3#4{#5}}}% |
---|
1304 | \lst@false \lst@Delim@delall@} |
---|
1305 | \gdef\lst@DefDelimB#1#2#3#4#5#6#7#8{% |
---|
1306 | \lst@CDef{#1}#2% |
---|
1307 | {#3}% |
---|
1308 | {\let\lst@bnext\lst@CArgEmpty |
---|
1309 | \lst@ifmode #4\else |
---|
1310 | #5% |
---|
1311 | \def\lst@bnext{#6{#7}{#8}}% |
---|
1312 | \fi |
---|
1313 | \lst@bnext}% |
---|
1314 | \@empty} |
---|
1315 | \gdef\lst@DefDelimE#1#2#3#4#5#6#7{% |
---|
1316 | \lst@CDef{#1}#2% |
---|
1317 | {#3}% |
---|
1318 | {\let\lst@enext\lst@CArgEmpty |
---|
1319 | \ifnum #7=\lst@mode% |
---|
1320 | #4% |
---|
1321 | \let\lst@enext#6% |
---|
1322 | \else |
---|
1323 | #5% |
---|
1324 | \fi |
---|
1325 | \lst@enext}% |
---|
1326 | \@empty} |
---|
1327 | \lst@AddToHook{Init}{\let\lst@bnext\relax \let\lst@enext\relax} |
---|
1328 | \gdef\lst@DefDelimBE#1#2#3#4#5#6#7#8#9{% |
---|
1329 | \lst@CDef{#1}#2% |
---|
1330 | {#3}% |
---|
1331 | {\let\lst@bnext\lst@CArgEmpty |
---|
1332 | \ifnum #7=\lst@mode |
---|
1333 | #4% |
---|
1334 | \let\lst@bnext#9% |
---|
1335 | \else |
---|
1336 | \lst@ifmode\else |
---|
1337 | #5% |
---|
1338 | \def\lst@bnext{#6{#7}{#8}}% |
---|
1339 | \fi |
---|
1340 | \fi |
---|
1341 | \lst@bnext}% |
---|
1342 | \@empty} |
---|
1343 | \gdef\lst@delimtypes{s,l} |
---|
1344 | \gdef\lst@DelimKey#1#2{% |
---|
1345 | \lst@Delim{}#2\relax |
---|
1346 | {Delim}\lst@delimtypes #1% |
---|
1347 | {\lst@BeginDelim\lst@EndDelim} |
---|
1348 | i\@empty{\lst@BeginIDelim\lst@EndIDelim}} |
---|
1349 | \lst@Key{delim}\relax{\lst@DelimKey\@empty{#1}} |
---|
1350 | \lst@Key{moredelim}\relax{\lst@DelimKey\relax{#1}} |
---|
1351 | \lst@Key{deletedelim}\relax{\lst@DelimKey\@nil{#1}} |
---|
1352 | \gdef\lst@DelimDM@l#1#2\@empty#3#4#5{% |
---|
1353 | \lst@CArg #2\relax\lst@DefDelimB{}{}{}#3{#1}{#5\lst@Lmodetrue}} |
---|
1354 | \gdef\lst@DelimDM@s#1#2#3\@empty#4#5#6{% |
---|
1355 | \lst@CArg #2\relax\lst@DefDelimB{}{}{}#4{#1}{#6}% |
---|
1356 | \lst@CArg #3\relax\lst@DefDelimE{}{}{}#5{#1}} |
---|
1357 | \def\lst@ReplaceInput#1{\lst@CArgX #1\relax\lst@CDefX{}{}} |
---|
1358 | \def\lst@Literatekey#1\@nil@{\let\lst@ifxliterate\lst@if |
---|
1359 | \def\lst@literate{#1}} |
---|
1360 | \lst@Key{literate}{}{\@ifstar{\lst@true \lst@Literatekey} |
---|
1361 | {\lst@false\lst@Literatekey}#1\@nil@} |
---|
1362 | \lst@AddToHook{SelectCharTable} |
---|
1363 | {\ifx\lst@literate\@empty\else |
---|
1364 | \expandafter\lst@Literate\lst@literate{}\relax\z@ |
---|
1365 | \fi} |
---|
1366 | \def\lst@Literate#1#2#3{% |
---|
1367 | \ifx\relax#2\@empty\else |
---|
1368 | \lst@CArgX #1\relax\lst@CDef |
---|
1369 | {} |
---|
1370 | {\let\lst@next\@empty |
---|
1371 | \lst@ifxliterate |
---|
1372 | \lst@ifmode \let\lst@next\lst@CArgEmpty \fi |
---|
1373 | \fi |
---|
1374 | \ifx\lst@next\@empty |
---|
1375 | \ifx\lst@OutputBox\@gobble\else |
---|
1376 | \lst@XPrintToken \let\lst@scanmode\lst@scan@m |
---|
1377 | \lst@token{#2}\lst@length#3\relax |
---|
1378 | \lst@XPrintToken |
---|
1379 | \fi |
---|
1380 | \let\lst@next\lst@CArgEmptyGobble |
---|
1381 | \fi |
---|
1382 | \lst@next}% |
---|
1383 | \@empty |
---|
1384 | \expandafter\lst@Literate |
---|
1385 | \fi} |
---|
1386 | \def\lst@CArgEmptyGobble#1\@empty{} |
---|
1387 | \def\lst@BeginDropInput#1{% |
---|
1388 | \lst@EnterMode{#1}% |
---|
1389 | {\lst@modetrue |
---|
1390 | \let\lst@OutputBox\@gobble |
---|
1391 | \let\lst@ifdropinput\iftrue |
---|
1392 | \let\lst@ProcessLetter\@gobble |
---|
1393 | \let\lst@ProcessDigit\@gobble |
---|
1394 | \let\lst@ProcessOther\@gobble |
---|
1395 | \let\lst@ProcessSpace\@empty |
---|
1396 | \let\lst@ProcessTabulator\@empty |
---|
1397 | \let\lst@ProcessFormFeed\@empty}} |
---|
1398 | \let\lst@ifdropinput\iffalse % init |
---|
1399 | \lst@Key{basicstyle}\relax{\def\lst@basicstyle{#1}} |
---|
1400 | \lst@Key{inputencoding}\relax{\def\lst@inputenc{#1}} |
---|
1401 | \lst@AddToHook{Init} |
---|
1402 | {\lst@basicstyle |
---|
1403 | \ifx\lst@inputenc\@empty\else |
---|
1404 | \@ifundefined{inputencoding}{}% |
---|
1405 | {\inputencoding\lst@inputenc}% |
---|
1406 | \fi} |
---|
1407 | \lst@AddToHookExe{EmptyStyle} |
---|
1408 | {\let\lst@basicstyle\@empty |
---|
1409 | \let\lst@inputenc\@empty} |
---|
1410 | \lst@Key{multicols}{}{\@tempcnta=0#1\relax\def\lst@multicols{#1}} |
---|
1411 | \def\lst@parshape{\parshape\@ne \z@ \linewidth} |
---|
1412 | \lst@AddToHookAtTop{EveryLine}{\lst@parshape} |
---|
1413 | \lst@AddToHookAtTop{EndGroup}{\lst@parshape} |
---|
1414 | \newcount\lst@lineno % \global |
---|
1415 | \lst@AddToHook{InitVars}{\global\lst@lineno\@ne} |
---|
1416 | \lst@Key{print}{true}[t]{\lstKV@SetIf{#1}\lst@ifprint} |
---|
1417 | \lst@Key{firstline}\relax{\def\lst@firstline{#1\relax}} |
---|
1418 | \lst@Key{lastline}\relax{\def\lst@lastline{#1\relax}} |
---|
1419 | \lst@AddToHook{PreSet} |
---|
1420 | {\let\lst@firstline\@ne \def\lst@lastline{9999999\relax}} |
---|
1421 | \lst@Key{linerange}\relax{\lstKV@OptArg[]{#1}{% |
---|
1422 | \def\lst@interrange{##1}\def\lst@linerange{##2,}}} |
---|
1423 | \lst@Key{rangeprefix}\relax{\def\lst@rangebeginprefix{#1}% |
---|
1424 | \def\lst@rangeendprefix{#1}} |
---|
1425 | \lst@Key{rangesuffix}\relax{\def\lst@rangebeginsuffix{#1}% |
---|
1426 | \def\lst@rangeendsuffix{#1}} |
---|
1427 | \lst@Key{rangebeginprefix}{}{\def\lst@rangebeginprefix{#1}} |
---|
1428 | \lst@Key{rangebeginsuffix}{}{\def\lst@rangebeginsuffix{#1}} |
---|
1429 | \lst@Key{rangeendprefix}{}{\def\lst@rangeendprefix{#1}} |
---|
1430 | \lst@Key{rangeendsuffix}{}{\def\lst@rangeendsuffix{#1}} |
---|
1431 | \lst@Key{includerangemarker}{true}[t]{\lstKV@SetIf{#1}\lst@ifincluderangemarker} |
---|
1432 | \lst@AddToHook{PreSet}{\def\lst@firstline{1\relax}% |
---|
1433 | \let\lst@linerange\@empty} |
---|
1434 | \lst@AddToHook{Init} |
---|
1435 | {\ifx\lst@linerange\@empty |
---|
1436 | \edef\lst@linerange{{\lst@firstline}-{\lst@lastline},}% |
---|
1437 | \fi |
---|
1438 | \lst@GetLineInterval}% |
---|
1439 | \def\lst@GetLineInterval{\expandafter\lst@GLI\lst@linerange\@nil} |
---|
1440 | \def\lst@GLI#1,#2\@nil{\def\lst@linerange{#2}\lst@GLI@#1--\@nil} |
---|
1441 | \def\lst@GLI@#1-#2-#3\@nil{% |
---|
1442 | \lst@IfNumber{#1}% |
---|
1443 | {\ifx\@empty#1\@empty |
---|
1444 | \let\lst@firstline\@ne |
---|
1445 | \else |
---|
1446 | \def\lst@firstline{#1\relax}% |
---|
1447 | \fi |
---|
1448 | \ifx\@empty#3\@empty |
---|
1449 | \def\lst@lastline{9999999\relax}% |
---|
1450 | \else |
---|
1451 | \ifx\@empty#2\@empty |
---|
1452 | \let\lst@lastline\lst@firstline |
---|
1453 | \else |
---|
1454 | \def\lst@lastline{#2\relax}% |
---|
1455 | \fi |
---|
1456 | \fi}% |
---|
1457 | {\def\lst@firstline{9999999\relax}% |
---|
1458 | \let\lst@lastline\lst@firstline |
---|
1459 | \let\lst@rangebegin\lst@rangebeginprefix |
---|
1460 | \lst@AddTo\lst@rangebegin{#1}\lst@Extend\lst@rangebegin\lst@rangebeginsuffix |
---|
1461 | \ifx\@empty#3\@empty |
---|
1462 | \let\lst@rangeend\lst@rangeendprefix |
---|
1463 | \lst@AddTo\lst@rangeend{#1}\lst@Extend\lst@rangeend\lst@rangeendsuffix |
---|
1464 | \else |
---|
1465 | \ifx\@empty#2\@empty |
---|
1466 | \let\lst@rangeend\@empty |
---|
1467 | \else |
---|
1468 | \let\lst@rangeend\lst@rangeendprefix |
---|
1469 | \lst@AddTo\lst@rangeend{#2}\lst@Extend\lst@rangeend\lst@rangeendsuffix |
---|
1470 | \fi |
---|
1471 | \fi |
---|
1472 | \global\def\lst@DefRange{\expandafter\lst@CArgX\lst@rangebegin\relax\lst@DefRangeB}% |
---|
1473 | \ifnum\lst@mode=\lst@Pmode \expandafter\lst@DefRange \fi}} |
---|
1474 | \lst@AddToHookExe{DeInit}{\global\let\lst@DefRange\@empty} |
---|
1475 | \def\lst@DefRangeB#1#2{\lst@DefRangeB@#1#2} |
---|
1476 | \def\lst@DefRangeB@#1#2#3#4{% |
---|
1477 | \lst@CDef{#1{#2}{#3}}#4{}% |
---|
1478 | {\lst@ifincluderangemarker |
---|
1479 | \lst@LeaveMode |
---|
1480 | \let#1#4% |
---|
1481 | \lst@DefRangeEnd |
---|
1482 | \lst@InitLstNumber |
---|
1483 | \else |
---|
1484 | \@tempcnta\lst@lineno \advance\@tempcnta\@ne |
---|
1485 | \edef\lst@firstline{\the\@tempcnta\relax}% |
---|
1486 | \gdef\lst@OnceAtEOL{\let#1#4\lst@DefRangeEnd}% |
---|
1487 | \lst@InitLstNumber |
---|
1488 | \fi |
---|
1489 | \global\let\lst@DefRange\lst@DefRangeEnd |
---|
1490 | \lst@CArgEmpty}% |
---|
1491 | \@empty} |
---|
1492 | \def\lstpatch@labels{% |
---|
1493 | \gdef\lst@SetFirstNumber{% |
---|
1494 | \ifx\lst@firstnumber\@undefined |
---|
1495 | \@tempcnta 0\csname\@lst no@\lst@intname\endcsname\relax |
---|
1496 | \ifnum\@tempcnta=\z@ \else |
---|
1497 | \lst@nololtrue |
---|
1498 | \advance\@tempcnta\lst@advancenumber |
---|
1499 | \edef\lst@firstnumber{\the\@tempcnta\relax}% |
---|
1500 | \fi |
---|
1501 | \fi}% |
---|
1502 | } |
---|
1503 | \def\lst@InitLstNumber{% |
---|
1504 | \global\c@lstnumber\lst@firstnumber |
---|
1505 | \global\advance\c@lstnumber\lst@advancenumber |
---|
1506 | \global\advance\c@lstnumber-\lst@advancelstnum |
---|
1507 | \ifx \lst@firstnumber\c@lstnumber |
---|
1508 | \global\advance\c@lstnumber-\lst@advancelstnum |
---|
1509 | \fi% |
---|
1510 | \lst@ifincluderangemarker\else% |
---|
1511 | \global\advance\c@lstnumber by 1% |
---|
1512 | \fi% |
---|
1513 | } |
---|
1514 | \def\lst@DefRangeEnd{% |
---|
1515 | \ifx\lst@rangeend\@empty\else |
---|
1516 | \expandafter\lst@CArgX\lst@rangeend\relax\lst@DefRangeE |
---|
1517 | \fi} |
---|
1518 | \def\lst@DefRangeE#1#2{\lst@DefRangeE@#1#2} |
---|
1519 | \def\lst@DefRangeE@#1#2#3#4{% |
---|
1520 | \lst@CDef{#1#2{#3}}#4{}% |
---|
1521 | {\let#1#4% |
---|
1522 | \edef\lst@lastline{\the\lst@lineno\relax}% |
---|
1523 | \lst@DefRangeE@@}% |
---|
1524 | \@empty} |
---|
1525 | \def\lst@DefRangeE@@#1\@empty{% |
---|
1526 | \lst@ifincluderangemarker |
---|
1527 | #1\lst@XPrintToken |
---|
1528 | \fi |
---|
1529 | \lst@LeaveModeToPmode |
---|
1530 | \lst@BeginDropInput{\lst@Pmode}} |
---|
1531 | \def\lst@LeaveModeToPmode{% |
---|
1532 | \ifnum\lst@mode=\lst@Pmode |
---|
1533 | \expandafter\lsthk@EndGroup |
---|
1534 | \else |
---|
1535 | \expandafter\egroup\expandafter\lst@LeaveModeToPmode |
---|
1536 | \fi} |
---|
1537 | \lst@AddToHook{EOL}{\lst@OnceAtEOL\global\let\lst@OnceAtEOL\@empty} |
---|
1538 | \gdef\lst@OnceAtEOL{}% Init |
---|
1539 | \def\lst@MSkipToFirst{% |
---|
1540 | \global\advance\lst@lineno\@ne |
---|
1541 | \ifnum \lst@lineno=\lst@firstline |
---|
1542 | \def\lst@next{\lst@LeaveMode \global\lst@newlines\z@ |
---|
1543 | \lst@OnceAtEOL \global\let\lst@OnceAtEOL\@empty |
---|
1544 | \lst@InitLstNumber % Added to work with modified \lsthk@PreInit. |
---|
1545 | \lsthk@InitVarsBOL |
---|
1546 | \lst@BOLGobble}% |
---|
1547 | \expandafter\lst@next |
---|
1548 | \fi} |
---|
1549 | \def\lst@SkipToFirst{% |
---|
1550 | \ifnum \lst@lineno<\lst@firstline |
---|
1551 | \def\lst@next{\lst@BeginDropInput\lst@Pmode |
---|
1552 | \lst@Let{13}\lst@MSkipToFirst |
---|
1553 | \lst@Let{10}\lst@MSkipToFirst}% |
---|
1554 | \expandafter\lst@next |
---|
1555 | \else |
---|
1556 | \expandafter\lst@BOLGobble |
---|
1557 | \fi} |
---|
1558 | \def\lst@IfNumber#1{% |
---|
1559 | \ifx\@empty#1\@empty |
---|
1560 | \let\lst@next\@firstoftwo |
---|
1561 | \else |
---|
1562 | \lst@IfNumber@#1\@nil |
---|
1563 | \fi |
---|
1564 | \lst@next} |
---|
1565 | \def\lst@IfNumber@#1#2\@nil{% |
---|
1566 | \let\lst@next\@secondoftwo |
---|
1567 | \ifnum`#1>47\relax \ifnum`#1>57\relax\else |
---|
1568 | \let\lst@next\@firstoftwo |
---|
1569 | \fi\fi} |
---|
1570 | \lst@Key{nolol}{false}[t]{\lstKV@SetIf{#1}\lst@ifnolol} |
---|
1571 | \def\lst@nololtrue{\let\lst@ifnolol\iftrue} |
---|
1572 | \let\lst@ifnolol\iffalse % init |
---|
1573 | \lst@Key{captionpos}{t}{\def\lst@captionpos{#1}} |
---|
1574 | \lst@Key{abovecaptionskip}\smallskipamount{\def\lst@abovecaption{#1}} |
---|
1575 | \lst@Key{belowcaptionskip}\smallskipamount{\def\lst@belowcaption{#1}} |
---|
1576 | \lst@Key{label}\relax{\def\lst@label{#1}} |
---|
1577 | \lst@Key{title}\relax{\def\lst@title{#1}\let\lst@caption\relax} |
---|
1578 | \lst@Key{caption}\relax{\lstKV@OptArg[{#1}]{#1}% |
---|
1579 | {\def\lst@caption{##2}\def\lst@@caption{##1}}% |
---|
1580 | \let\lst@title\@empty} |
---|
1581 | \lst@AddToHookExe{TextStyle} |
---|
1582 | {\let\lst@caption\@empty \let\lst@@caption\@empty |
---|
1583 | \let\lst@title\@empty \let\lst@label\@empty} |
---|
1584 | \AtBeginDocument{ |
---|
1585 | \@ifundefined{thechapter}{\let\lst@ifnumberbychapter\iffalse}{} |
---|
1586 | \lst@ifnumberbychapter |
---|
1587 | \newcounter{lstlisting}[chapter] |
---|
1588 | \gdef\thelstlisting% |
---|
1589 | {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@lstlisting} |
---|
1590 | \else |
---|
1591 | \newcounter{lstlisting} |
---|
1592 | \gdef\thelstlisting{\@arabic\c@lstlisting} |
---|
1593 | \fi} |
---|
1594 | \lst@UserCommand\lstlistingname{Listing} |
---|
1595 | \lst@Key{numberbychapter}{true}[t]{\lstKV@SetIf{#1}\lst@ifnumberbychapter} |
---|
1596 | \@ifundefined{abovecaptionskip} |
---|
1597 | {\newskip\abovecaptionskip |
---|
1598 | \newskip\belowcaptionskip}{} |
---|
1599 | \@ifundefined{@makecaption} |
---|
1600 | {\long\def\@makecaption#1#2{% |
---|
1601 | \vskip\abovecaptionskip |
---|
1602 | \sbox\@tempboxa{#1: #2}% |
---|
1603 | \ifdim \wd\@tempboxa >\hsize |
---|
1604 | #1: #2\par |
---|
1605 | \else |
---|
1606 | \global \@minipagefalse |
---|
1607 | \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% |
---|
1608 | \fi |
---|
1609 | \vskip\belowcaptionskip}% |
---|
1610 | }{} |
---|
1611 | \def\fnum@lstlisting{% |
---|
1612 | \lstlistingname |
---|
1613 | \ifx\lst@@caption\@empty\else~\thelstlisting\fi}% |
---|
1614 | \def\lst@MakeCaption#1{% |
---|
1615 | \lst@ifdisplaystyle |
---|
1616 | \ifx #1t% |
---|
1617 | \ifx\lst@@caption\@empty\expandafter\lst@HRefStepCounter \else |
---|
1618 | \expandafter\refstepcounter |
---|
1619 | \fi {lstlisting}% |
---|
1620 | \ifx\lst@label\@empty\else \label{\lst@label}\fi |
---|
1621 | \let\lst@arg\lst@intname \lst@ReplaceIn\lst@arg\lst@filenamerpl |
---|
1622 | \global\let\lst@name\lst@arg \global\let\lstname\lst@name |
---|
1623 | \lst@ifnolol\else |
---|
1624 | \ifx\lst@@caption\@empty |
---|
1625 | \ifx\lst@caption\@empty |
---|
1626 | \ifx\lst@intname\@empty \else \def\lst@temp{ }% |
---|
1627 | \ifx\lst@intname\lst@temp \else |
---|
1628 | \addcontentsline{lol}{lstlisting}\lst@name |
---|
1629 | \fi\fi |
---|
1630 | \fi |
---|
1631 | \else |
---|
1632 | \addcontentsline{lol}{lstlisting}% |
---|
1633 | {\protect\numberline{\thelstlisting}\lst@@caption}% |
---|
1634 | \fi |
---|
1635 | \fi |
---|
1636 | \fi |
---|
1637 | \ifx\lst@caption\@empty\else |
---|
1638 | \lst@IfSubstring #1\lst@captionpos |
---|
1639 | {\begingroup \let\@@vskip\vskip |
---|
1640 | \def\vskip{\afterassignment\lst@vskip \@tempskipa}% |
---|
1641 | \def\lst@vskip{\nobreak\@@vskip\@tempskipa\nobreak}% |
---|
1642 | \par\@parboxrestore\normalsize\normalfont % \noindent (AS) |
---|
1643 | \ifx #1t\allowbreak \fi |
---|
1644 | \ifx\lst@title\@empty |
---|
1645 | \lst@makecaption\fnum@lstlisting{\ignorespaces \lst@caption} |
---|
1646 | \else |
---|
1647 | \lst@maketitle\lst@title % (AS) |
---|
1648 | \fi |
---|
1649 | \ifx #1b\allowbreak \fi |
---|
1650 | \endgroup}{}% |
---|
1651 | \fi |
---|
1652 | \fi} |
---|
1653 | \def\lst@makecaption{\@makecaption} |
---|
1654 | \def\lst@maketitle{\@makecaption\lst@title@dropdelim} |
---|
1655 | \def\lst@title@dropdelim#1{\ignorespaces} |
---|
1656 | \AtBeginDocument{% |
---|
1657 | \@ifundefined{captionlabelfalse}{}{% |
---|
1658 | \def\lst@maketitle{\captionlabelfalse\@makecaption\@empty}}% |
---|
1659 | \@ifundefined{caption@startrue}{}{% |
---|
1660 | \def\lst@maketitle{\caption@startrue\@makecaption\@empty}}% |
---|
1661 | } |
---|
1662 | \def\lst@HRefStepCounter#1{% |
---|
1663 | \begingroup |
---|
1664 | \c@lstlisting\lst@neglisting |
---|
1665 | \advance\c@lstlisting\m@ne \xdef\lst@neglisting{\the\c@lstlisting}% |
---|
1666 | \ifx\hyper@refstepcounter\@undefined\else |
---|
1667 | \hyper@refstepcounter{#1}% |
---|
1668 | \fi |
---|
1669 | \endgroup} |
---|
1670 | \gdef\lst@neglisting{\z@}% init |
---|
1671 | \lst@Key{boxpos}{c}{\def\lst@boxpos{#1}} |
---|
1672 | \def\lst@boxtrue{\let\lst@ifbox\iftrue} |
---|
1673 | \let\lst@ifbox\iffalse |
---|
1674 | \lst@Key{float}\relax[\lst@floatplacement]{% |
---|
1675 | \lstKV@SwitchCases{#1}% |
---|
1676 | {true&\let\lst@floatdefault\lst@floatplacement |
---|
1677 | \let\lst@float\lst@floatdefault\\% |
---|
1678 | false&\let\lst@floatdefault\relax |
---|
1679 | \let\lst@float\lst@floatdefault |
---|
1680 | }{\def\lst@next{\@ifstar{\let\lst@beginfloat\@dblfloat |
---|
1681 | \let\lst@endfloat\end@dblfloat |
---|
1682 | \lst@KFloat}% |
---|
1683 | {\let\lst@beginfloat\@float |
---|
1684 | \let\lst@endfloat\end@float |
---|
1685 | \lst@KFloat}} |
---|
1686 | \edef\lst@float{#1}% |
---|
1687 | \expandafter\lst@next\lst@float\relax}} |
---|
1688 | \def\lst@KFloat#1\relax{% |
---|
1689 | \ifx\@empty#1\@empty |
---|
1690 | \let\lst@float\lst@floatplacement |
---|
1691 | \else |
---|
1692 | \def\lst@float{#1}% |
---|
1693 | \fi} |
---|
1694 | \lst@Key{floatplacement}{tbp}{\def\lst@floatplacement{#1}} |
---|
1695 | \lst@AddToHook{PreSet}{\let\lst@float\lst@floatdefault} |
---|
1696 | \lst@AddToHook{TextStyle}{\let\lst@float\relax} |
---|
1697 | \let\lst@floatdefault\relax % init |
---|
1698 | \lst@AddToHook{DeInit}{% |
---|
1699 | \ifx\lst@float\relax |
---|
1700 | \global\let\lst@doendpe\@doendpe |
---|
1701 | \else |
---|
1702 | \global\let\lst@doendpe\@empty |
---|
1703 | \fi} |
---|
1704 | \AtBeginDocument{% |
---|
1705 | \@ifundefined{c@float@type}% |
---|
1706 | {\edef\ftype@lstlisting{\ifx\c@figure\@undefined 1\else 4\fi}} |
---|
1707 | {\edef\ftype@lstlisting{\the\c@float@type}% |
---|
1708 | \addtocounter{float@type}{\value{float@type}}}% |
---|
1709 | } |
---|
1710 | \lst@Key{aboveskip}\medskipamount{\def\lst@aboveskip{#1}} |
---|
1711 | \lst@Key{belowskip}\medskipamount{\def\lst@belowskip{#1}} |
---|
1712 | \lst@AddToHook{TextStyle} |
---|
1713 | {\let\lst@aboveskip\z@ \let\lst@belowskip\z@} |
---|
1714 | \lst@Key{everydisplay}{}{\def\lst@EveryDisplay{#1}} |
---|
1715 | \lst@AddToHook{TextStyle}{\let\lst@ifdisplaystyle\iffalse} |
---|
1716 | \lst@AddToHook{DisplayStyle}{\let\lst@ifdisplaystyle\iftrue} |
---|
1717 | \let\lst@ifdisplaystyle\iffalse |
---|
1718 | \def\lst@Init#1{% |
---|
1719 | \begingroup |
---|
1720 | \ifx\lst@float\relax\else |
---|
1721 | \edef\@tempa{\noexpand\lst@beginfloat{lstlisting}[\lst@float]}% |
---|
1722 | \expandafter\@tempa |
---|
1723 | \fi |
---|
1724 | \ifx\lst@multicols\@empty\else |
---|
1725 | \edef\lst@next{\noexpand\multicols{\lst@multicols}} |
---|
1726 | \expandafter\lst@next |
---|
1727 | \fi |
---|
1728 | \ifhmode\ifinner \lst@boxtrue \fi\fi |
---|
1729 | \lst@ifbox |
---|
1730 | \lsthk@BoxUnsafe |
---|
1731 | \hbox to\z@\bgroup |
---|
1732 | $\if t\lst@boxpos \vtop |
---|
1733 | \else \if b\lst@boxpos \vbox |
---|
1734 | \else \vcenter \fi\fi |
---|
1735 | \bgroup \par\noindent |
---|
1736 | \else |
---|
1737 | \lst@ifdisplaystyle |
---|
1738 | \lst@EveryDisplay |
---|
1739 | \par\penalty-50\relax |
---|
1740 | \vspace\lst@aboveskip |
---|
1741 | \fi |
---|
1742 | \fi |
---|
1743 | \normalbaselines |
---|
1744 | \abovecaptionskip\lst@abovecaption\relax |
---|
1745 | \belowcaptionskip\lst@belowcaption\relax |
---|
1746 | \lst@MakeCaption t% |
---|
1747 | \lsthk@PreInit \lsthk@Init |
---|
1748 | \lst@ifdisplaystyle |
---|
1749 | \global\let\lst@ltxlabel\@empty |
---|
1750 | \if@inlabel |
---|
1751 | \lst@ifresetmargins |
---|
1752 | \leavevmode |
---|
1753 | \else |
---|
1754 | \xdef\lst@ltxlabel{\the\everypar}% |
---|
1755 | \lst@AddTo\lst@ltxlabel{% |
---|
1756 | \global\let\lst@ltxlabel\@empty |
---|
1757 | \everypar{\lsthk@EveryLine\lsthk@EveryPar}}% |
---|
1758 | \fi |
---|
1759 | \fi |
---|
1760 | \everypar\expandafter{\lst@ltxlabel |
---|
1761 | \lsthk@EveryLine\lsthk@EveryPar}% |
---|
1762 | \else |
---|
1763 | \everypar{}\let\lst@NewLine\@empty |
---|
1764 | \fi |
---|
1765 | \lsthk@InitVars \lsthk@InitVarsBOL |
---|
1766 | \lst@Let{13}\lst@MProcessListing |
---|
1767 | \let\lst@Backslash#1% |
---|
1768 | \lst@EnterMode{\lst@Pmode}{\lst@SelectCharTable}% |
---|
1769 | \lst@InitFinalize} |
---|
1770 | \let\lst@InitFinalize\@empty % init |
---|
1771 | \lst@AddToHook{PreInit} |
---|
1772 | {\rightskip\z@ \leftskip\z@ \parfillskip=\z@ plus 1fil |
---|
1773 | \let\par\@@par} |
---|
1774 | \lst@AddToHook{EveryLine}{}% init |
---|
1775 | \lst@AddToHook{EveryPar}{}% init |
---|
1776 | \lst@Key{showlines}f[t]{\lstKV@SetIf{#1}\lst@ifshowlines} |
---|
1777 | \def\lst@DeInit{% |
---|
1778 | \lst@XPrintToken \lst@EOLUpdate |
---|
1779 | \global\advance\lst@newlines\m@ne |
---|
1780 | \lst@ifshowlines |
---|
1781 | \lst@DoNewLines |
---|
1782 | \else |
---|
1783 | \setbox\@tempboxa\vbox{\lst@DoNewLines}% |
---|
1784 | \fi |
---|
1785 | \lst@ifdisplaystyle \par\removelastskip \fi |
---|
1786 | \lsthk@ExitVars\everypar{}\lsthk@DeInit\normalbaselines\normalcolor |
---|
1787 | \lst@MakeCaption b% |
---|
1788 | \lst@ifbox |
---|
1789 | \egroup $\hss \egroup |
---|
1790 | \vrule\@width\lst@maxwidth\@height\z@\@depth\z@ |
---|
1791 | \else |
---|
1792 | \lst@ifdisplaystyle |
---|
1793 | \par\penalty-50\vspace\lst@belowskip |
---|
1794 | \fi |
---|
1795 | \fi |
---|
1796 | \ifx\lst@multicols\@empty\else |
---|
1797 | \def\lst@next{\global\let\@checkend\@gobble |
---|
1798 | \endmulticols |
---|
1799 | \global\let\@checkend\lst@@checkend} |
---|
1800 | \expandafter\lst@next |
---|
1801 | \fi |
---|
1802 | \ifx\lst@float\relax\else |
---|
1803 | \expandafter\lst@endfloat |
---|
1804 | \fi |
---|
1805 | \endgroup} |
---|
1806 | \let\lst@@checkend\@checkend |
---|
1807 | \newdimen\lst@maxwidth % \global |
---|
1808 | \lst@AddToHook{InitVars}{\global\lst@maxwidth\z@} |
---|
1809 | \lst@AddToHook{InitVarsEOL} |
---|
1810 | {\ifdim\lst@currlwidth>\lst@maxwidth |
---|
1811 | \global\lst@maxwidth\lst@currlwidth |
---|
1812 | \fi} |
---|
1813 | \def\lst@EOLUpdate{\lsthk@EOL \lsthk@InitVarsEOL} |
---|
1814 | \def\lst@MProcessListing{% |
---|
1815 | \lst@XPrintToken \lst@EOLUpdate \lsthk@InitVarsBOL |
---|
1816 | \global\advance\lst@lineno\@ne |
---|
1817 | \ifnum \lst@lineno>\lst@lastline |
---|
1818 | \lst@ifdropinput \lst@LeaveMode \fi |
---|
1819 | \ifx\lst@linerange\@empty |
---|
1820 | \expandafter\expandafter\expandafter\lst@EndProcessListing |
---|
1821 | \else |
---|
1822 | \lst@interrange |
---|
1823 | \lst@GetLineInterval |
---|
1824 | \expandafter\expandafter\expandafter\lst@SkipToFirst |
---|
1825 | \fi |
---|
1826 | \else |
---|
1827 | \expandafter\lst@BOLGobble |
---|
1828 | \fi} |
---|
1829 | \let\lst@EndProcessListing\endinput |
---|
1830 | \lst@Key{gobble}{0}{\def\lst@gobble{#1}} |
---|
1831 | \def\lst@BOLGobble{% |
---|
1832 | \ifnum\lst@gobble>\z@ |
---|
1833 | \@tempcnta\lst@gobble\relax |
---|
1834 | \expandafter\lst@BOLGobble@ |
---|
1835 | \fi} |
---|
1836 | \def\lst@BOLGobble@@{% |
---|
1837 | \ifnum\@tempcnta>\z@ |
---|
1838 | \expandafter\lst@BOLGobble@ |
---|
1839 | \fi} |
---|
1840 | \def\lstenv@BOLGobble@@{% |
---|
1841 | \lst@IfNextChars\lstenv@endstring{\lstenv@End}% |
---|
1842 | {\advance\@tempcnta\m@ne \expandafter\lst@BOLGobble@@\lst@eaten}} |
---|
1843 | \def\lst@BOLGobble@#1{% |
---|
1844 | \let\lst@next#1% |
---|
1845 | \ifx \lst@next\relax\else |
---|
1846 | \ifx \lst@next\lst@MProcessListing\else |
---|
1847 | \ifx \lst@next\lst@processformfeed\else |
---|
1848 | \ifx \lst@next\lstenv@backslash |
---|
1849 | \let\lst@next\lstenv@BOLGobble@@ |
---|
1850 | \else |
---|
1851 | \let\lst@next\lst@BOLGobble@@ |
---|
1852 | \ifx #1\lst@processtabulator |
---|
1853 | \advance\@tempcnta-\lst@tabsize\relax |
---|
1854 | \ifnum\@tempcnta<\z@ |
---|
1855 | \lst@length-\@tempcnta \lst@PreGotoTabStop |
---|
1856 | \fi |
---|
1857 | \else |
---|
1858 | \advance\@tempcnta\m@ne |
---|
1859 | \fi |
---|
1860 | \fi \fi \fi \fi |
---|
1861 | \lst@next} |
---|
1862 | \def\lst@processformfeed{\lst@ProcessFormFeed} |
---|
1863 | \def\lst@processtabulator{\lst@ProcessTabulator} |
---|
1864 | \lst@Key{name}\relax{\def\lst@intname{#1}} |
---|
1865 | \lst@AddToHookExe{PreSet}{\global\let\lst@intname\@empty} |
---|
1866 | \lst@AddToHook{PreInit}{% |
---|
1867 | \let\lst@arg\lst@intname \lst@ReplaceIn\lst@arg\lst@filenamerpl |
---|
1868 | \global\let\lst@name\lst@arg \global\let\lstname\lst@name} |
---|
1869 | \def\lst@filenamerpl{_\textunderscore $\textdollar -\textendash} |
---|
1870 | \def\l@lstlisting#1#2{\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}} |
---|
1871 | \lst@UserCommand\lstlistlistingname{Listings} |
---|
1872 | \lst@UserCommand\lstlistoflistings{\bgroup |
---|
1873 | \let\contentsname\lstlistlistingname |
---|
1874 | \let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}% |
---|
1875 | \tableofcontents \egroup} |
---|
1876 | \@ifundefined{float@listhead}{}{% |
---|
1877 | \renewcommand*{\lstlistoflistings}{% |
---|
1878 | \begingroup |
---|
1879 | \@ifundefined{@restonecoltrue}{}{% |
---|
1880 | \if@twocolumn |
---|
1881 | \@restonecoltrue\onecolumn |
---|
1882 | \else |
---|
1883 | \@restonecolfalse |
---|
1884 | \fi |
---|
1885 | }% |
---|
1886 | \float@listhead{\lstlistlistingname}% |
---|
1887 | \parskip\z@\parindent\z@\parfillskip \z@ \@plus 1fil% |
---|
1888 | \@starttoc{lol}% |
---|
1889 | \@ifundefined{@restonecoltrue}{}{% |
---|
1890 | \if@restonecol\twocolumn\fi |
---|
1891 | }% |
---|
1892 | \endgroup |
---|
1893 | }% |
---|
1894 | } |
---|
1895 | \AtBeginDocument{% |
---|
1896 | \@ifundefined{float@addtolists}% |
---|
1897 | {\gdef\float@addtolists#1{\addtocontents{lol}{#1}}}% |
---|
1898 | {\let\orig@float@addtolists\float@addtolists |
---|
1899 | \gdef\float@addtolists#1{% |
---|
1900 | \addtocontents{lol}{#1}% |
---|
1901 | \orig@float@addtolists{#1}}}% |
---|
1902 | }% |
---|
1903 | \newcommand\lstinline[1][]{% |
---|
1904 | \leavevmode\bgroup % \hbox\bgroup --> \bgroup |
---|
1905 | \def\lst@boxpos{b}% |
---|
1906 | \lsthk@PreSet\lstset{flexiblecolumns,#1}% |
---|
1907 | \lsthk@TextStyle |
---|
1908 | \@ifnextchar\bgroup{% |
---|
1909 | \afterassignment\lst@InlineG \let\@let@token}% |
---|
1910 | \lstinline@} |
---|
1911 | \def\lstinline@#1{% |
---|
1912 | \lst@Init\relax |
---|
1913 | \lst@IfNextCharActive{\lst@InlineM#1}{\lst@InlineJ#1}} |
---|
1914 | \lst@AddToHook{TextStyle}{}% init |
---|
1915 | \lst@AddToHook{SelectCharTable}{\lst@inlinechars} |
---|
1916 | \global\let\lst@inlinechars\@empty |
---|
1917 | \def\lst@InlineM#1{\gdef\lst@inlinechars{% |
---|
1918 | \lst@Def{`#1}{\lst@DeInit\egroup\global\let\lst@inlinechars\@empty}% |
---|
1919 | \lst@Def{13}{\lst@DeInit\egroup \global\let\lst@inlinechars\@empty |
---|
1920 | \PackageError{Listings}{lstinline ended by EOL}\@ehc}}% |
---|
1921 | \lst@inlinechars} |
---|
1922 | \def\lst@InlineJ#1{% |
---|
1923 | \def\lst@temp##1#1{% |
---|
1924 | \let\lst@arg\@empty \lst@InsideConvert{##1}\lst@arg |
---|
1925 | \lst@DeInit\egroup}% |
---|
1926 | \lst@temp} |
---|
1927 | \def\lst@InlineG{% |
---|
1928 | \lst@Init\relax |
---|
1929 | \lst@IfNextCharActive{\lst@InlineM\}}% |
---|
1930 | {\let\lst@arg\@empty \lst@InlineGJ}} |
---|
1931 | \def\lst@InlineGJ{\futurelet\@let@token\lst@InlineGJTest} |
---|
1932 | \def\lst@InlineGJTest{% |
---|
1933 | \ifx\@let@token\egroup |
---|
1934 | \afterassignment\lst@InlineGJEnd |
---|
1935 | \expandafter\let\expandafter\@let@token |
---|
1936 | \else |
---|
1937 | \ifx\@let@token\@sptoken |
---|
1938 | \let\lst@next\lst@InlineGJReadSp |
---|
1939 | \else |
---|
1940 | \let\lst@next\lst@InlineGJRead |
---|
1941 | \fi |
---|
1942 | \expandafter\lst@next |
---|
1943 | \fi} |
---|
1944 | \def\lst@InlineGJEnd{\lst@arg\lst@DeInit\egroup} |
---|
1945 | \def\lst@InlineGJRead#1{% |
---|
1946 | \lccode`\~=`#1\lowercase{\lst@lAddTo\lst@arg~}% |
---|
1947 | \lst@InlineGJ} |
---|
1948 | \def\lst@InlineGJReadSp#1{% |
---|
1949 | \lccode`\~=`\ \lowercase{\lst@lAddTo\lst@arg~}% |
---|
1950 | \lst@InlineGJ#1} |
---|
1951 | \newcommand\lstMakeShortInline[1][]{% |
---|
1952 | \def\lst@shortinlinedef{\lstinline[#1]}% |
---|
1953 | \lstMakeShortInline@}% |
---|
1954 | \def\lstMakeShortInline@#1{% |
---|
1955 | \expandafter\ifx\csname lst@ShortInlineOldCatcode\string#1\endcsname\relax |
---|
1956 | \lst@shortlstinlineinfo{Made }{#1}% |
---|
1957 | \lst@add@special{#1}% |
---|
1958 | \expandafter |
---|
1959 | \xdef\csname lst@ShortInlineOldCatcode\string#1\endcsname{\the\catcode`#1}% |
---|
1960 | \begingroup |
---|
1961 | \catcode`\~\active \lccode`\~`#1% |
---|
1962 | \lowercase{% |
---|
1963 | \global\expandafter\let |
---|
1964 | \csname lst@ShortInlineOldMeaning\string#1\endcsname~% |
---|
1965 | \expandafter\gdef\expandafter~\expandafter{\lst@shortinlinedef#1}}% |
---|
1966 | \endgroup |
---|
1967 | \global\catcode`#1\active |
---|
1968 | \else |
---|
1969 | \PackageError{Listings}% |
---|
1970 | {\string\lstMakeShorterInline\ definitions cannot be nested}% |
---|
1971 | {Use \string\lstDeleteShortInline first.}% |
---|
1972 | {}% |
---|
1973 | \fi} |
---|
1974 | \def\lstDeleteShortInline#1{% |
---|
1975 | \expandafter\ifx\csname lst@ShortInlineOldCatcode\string#1\endcsname\relax |
---|
1976 | \PackageError{Listings}% |
---|
1977 | {#1 is not a short reference for \string\lstinline}% |
---|
1978 | {Use \string\lstMakeShortInline first.}% |
---|
1979 | {}% |
---|
1980 | \else |
---|
1981 | \lst@shortlstinlineinfo{Deleted }{#1 as}% |
---|
1982 | \lst@rem@special{#1}% |
---|
1983 | \global\catcode`#1\csname lst@ShortInlineOldCatcode\string#1\endcsname |
---|
1984 | \global \expandafter\let% |
---|
1985 | \csname lst@ShortInlineOldCatcode\string#1\endcsname \relax |
---|
1986 | \ifnum\catcode`#1=\active |
---|
1987 | \begingroup |
---|
1988 | \catcode`\~\active \lccode`\~`#1% |
---|
1989 | \lowercase{% |
---|
1990 | \global\expandafter\let\expandafter~% |
---|
1991 | \csname lst@ShortInlineOldMeaning\string#1\endcsname}% |
---|
1992 | \endgroup |
---|
1993 | \fi |
---|
1994 | \fi} |
---|
1995 | \def\lst@shortlstinlineinfo#1#2{% |
---|
1996 | \PackageInfo{Listings}{% |
---|
1997 | #1\string#2 a short reference for \string\lstinline}} |
---|
1998 | \def\lst@add@special#1{% |
---|
1999 | \lst@rem@special{#1}% |
---|
2000 | \expandafter\gdef\expandafter\dospecials\expandafter |
---|
2001 | {\dospecials \do #1}% |
---|
2002 | \expandafter\gdef\expandafter\@sanitize\expandafter |
---|
2003 | {\@sanitize \@makeother #1}} |
---|
2004 | \def\lst@rem@special#1{% |
---|
2005 | \def\do##1{% |
---|
2006 | \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}% |
---|
2007 | \xdef\dospecials{\dospecials}% |
---|
2008 | \begingroup |
---|
2009 | \def\@makeother##1{% |
---|
2010 | \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}% |
---|
2011 | \xdef\@sanitize{\@sanitize}% |
---|
2012 | \endgroup} |
---|
2013 | \def\lst@MakePath#1{\ifx\@empty#1\@empty\else\lst@MakePath@#1/\@nil/\fi} |
---|
2014 | \def\lst@MakePath@#1/{#1/\lst@MakePath@@} |
---|
2015 | \def\lst@MakePath@@#1/{% |
---|
2016 | \ifx\@nil#1\expandafter\@gobble |
---|
2017 | \else \ifx\@empty#1\else #1/\fi \fi |
---|
2018 | \lst@MakePath@@} |
---|
2019 | \lst@Key{inputpath}{}{\edef\lst@inputpath{\lst@MakePath{#1}}} |
---|
2020 | \def\lstinputlisting{% |
---|
2021 | \begingroup \lst@setcatcodes \lst@inputlisting} |
---|
2022 | \newcommand\lst@inputlisting[2][]{% |
---|
2023 | \endgroup |
---|
2024 | \def\lst@set{#1}% |
---|
2025 | \IfFileExists{\lst@inputpath#2}% |
---|
2026 | {\expandafter\lst@InputListing\expandafter{\lst@inputpath#2}}% |
---|
2027 | {\filename@parse{\lst@inputpath#2}% |
---|
2028 | \edef\reserved@a{\noexpand\lst@MissingFileError |
---|
2029 | {\filename@area\filename@base}% |
---|
2030 | {\ifx\filename@ext\relax tex\else\filename@ext\fi}}% |
---|
2031 | \reserved@a}% |
---|
2032 | \lst@doendpe \@newlistfalse \ignorespaces} |
---|
2033 | \def\lst@MissingFileError#1#2{% |
---|
2034 | \typeout{^^J! Package Listings Error: File `#1(.#2)' not found.^^J% |
---|
2035 | ^^JType X to quit or <RETURN> to proceed,^^J% |
---|
2036 | or enter new name. (Default extension: #2)^^J}% |
---|
2037 | \message{Enter file name: }% |
---|
2038 | {\endlinechar\m@ne \global\read\m@ne to\@gtempa}% |
---|
2039 | \ifx\@gtempa\@empty \else |
---|
2040 | \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi |
---|
2041 | \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi |
---|
2042 | \filename@parse\@gtempa |
---|
2043 | \edef\filename@ext{% |
---|
2044 | \ifx\filename@ext\relax#2\else\filename@ext\fi}% |
---|
2045 | \edef\reserved@a{\noexpand\IfFileExists % |
---|
2046 | {\filename@area\filename@base.\filename@ext}% |
---|
2047 | {\noexpand\lst@InputListing % |
---|
2048 | {\filename@area\filename@base.\filename@ext}}% |
---|
2049 | {\noexpand\lst@MissingFileError |
---|
2050 | {\filename@area\filename@base}{\filename@ext}}}% |
---|
2051 | \expandafter\reserved@a % |
---|
2052 | \fi} |
---|
2053 | \let\lst@ifdraft\iffalse |
---|
2054 | \DeclareOption{draft}{\let\lst@ifdraft\iftrue} |
---|
2055 | \DeclareOption{final}{\let\lst@ifdraft\iffalse} |
---|
2056 | \lst@AddToHook{PreSet} |
---|
2057 | {\lst@ifdraft |
---|
2058 | \let\lst@ifprint\iffalse |
---|
2059 | \@gobbletwo\fi\fi |
---|
2060 | \fi} |
---|
2061 | \def\lst@InputListing#1{% |
---|
2062 | \begingroup |
---|
2063 | \lsthk@PreSet \gdef\lst@intname{#1}% |
---|
2064 | \expandafter\lstset\expandafter{\lst@set}% |
---|
2065 | \lsthk@DisplayStyle |
---|
2066 | \catcode\active=\active |
---|
2067 | \lst@Init\relax \let\lst@gobble\z@ |
---|
2068 | \lst@SkipToFirst |
---|
2069 | \lst@ifprint \def\lst@next{\input{#1}}% |
---|
2070 | \else \let\lst@next\@empty \fi |
---|
2071 | \lst@next |
---|
2072 | \lst@DeInit |
---|
2073 | \endgroup} |
---|
2074 | \def\lst@SkipToFirst{% |
---|
2075 | \ifnum \lst@lineno<\lst@firstline |
---|
2076 | \lst@BeginDropInput\lst@Pmode |
---|
2077 | \lst@Let{13}\lst@MSkipToFirst |
---|
2078 | \lst@Let{10}\lst@MSkipToFirst |
---|
2079 | \else |
---|
2080 | \expandafter\lst@BOLGobble |
---|
2081 | \fi} |
---|
2082 | \def\lst@MSkipToFirst{% |
---|
2083 | \global\advance\lst@lineno\@ne |
---|
2084 | \ifnum \lst@lineno=\lst@firstline |
---|
2085 | \lst@LeaveMode \global\lst@newlines\z@ |
---|
2086 | \lsthk@InitVarsBOL |
---|
2087 | \expandafter\lst@BOLGobble |
---|
2088 | \fi} |
---|
2089 | \def\lstenv@DroppedWarning{% |
---|
2090 | \ifx\lst@dropped\@undefined\else |
---|
2091 | \PackageWarning{Listings}{Text dropped after begin of listing}% |
---|
2092 | \fi} |
---|
2093 | \let\lst@dropped\@undefined % init |
---|
2094 | \begingroup \lccode`\~=`\^^M\lowercase{% |
---|
2095 | \gdef\lstenv@Process#1{% |
---|
2096 | \ifx~#1% |
---|
2097 | \lstenv@DroppedWarning \let\lst@next\lst@SkipToFirst |
---|
2098 | \else\ifx^^J#1% |
---|
2099 | \lstenv@DroppedWarning \let\lst@next\lstenv@ProcessJ |
---|
2100 | \else |
---|
2101 | \let\lst@dropped#1\let\lst@next\lstenv@Process |
---|
2102 | \fi \fi |
---|
2103 | \lst@next} |
---|
2104 | }\endgroup |
---|
2105 | \def\lstenv@ProcessJ{% |
---|
2106 | \let\lst@arg\@empty |
---|
2107 | \ifx\@currenvir\lstenv@name |
---|
2108 | \expandafter\lstenv@ProcessJEnv |
---|
2109 | \else |
---|
2110 | \expandafter\def\expandafter\lst@temp\expandafter##1% |
---|
2111 | \csname end\lstenv@name\endcsname |
---|
2112 | {\lst@InsideConvert{##1}\lstenv@ProcessJ@}% |
---|
2113 | \expandafter\lst@temp |
---|
2114 | \fi} |
---|
2115 | \begingroup \lccode`\~=`\\\lowercase{% |
---|
2116 | \gdef\lstenv@ProcessJ@{% |
---|
2117 | \lst@lExtend\lst@arg |
---|
2118 | {\expandafter\ \expandafter~\lstenv@endstring}% |
---|
2119 | \catcode10=\active \lst@Let{10}\lst@MProcessListing |
---|
2120 | \lst@SkipToFirst \lst@arg} |
---|
2121 | }\endgroup |
---|
2122 | \def\lstenv@ProcessJEnv#1\end#2{\def\lst@temp{#2}% |
---|
2123 | \ifx\lstenv@name\lst@temp |
---|
2124 | \lst@InsideConvert{#1}% |
---|
2125 | \expandafter\lstenv@ProcessJ@ |
---|
2126 | \else |
---|
2127 | \lst@InsideConvert{#1\\end\{#2\}}% |
---|
2128 | \expandafter\lstenv@ProcessJEnv |
---|
2129 | \fi} |
---|
2130 | \def\lstenv@backslash{% |
---|
2131 | \lst@IfNextChars\lstenv@endstring |
---|
2132 | {\lstenv@End}% |
---|
2133 | {\expandafter\lsts@backslash \lst@eaten}}% |
---|
2134 | \def\lstenv@End{% |
---|
2135 | \ifx\@currenvir\lstenv@name |
---|
2136 | \edef\lst@next{\noexpand\end{\lstenv@name}}% |
---|
2137 | \else |
---|
2138 | \def\lst@next{\csname end\lstenv@name\endcsname}% |
---|
2139 | \fi |
---|
2140 | \lst@next} |
---|
2141 | \lst@UserCommand\lstnewenvironment#1#2#{% |
---|
2142 | \@ifundefined{#1}% |
---|
2143 | {\let\lst@arg\@empty |
---|
2144 | \lst@XConvert{#1}\@nil |
---|
2145 | \expandafter\lstnewenvironment@\lst@arg{#1}{#2}}% |
---|
2146 | {\PackageError{Listings}{Environment `#1' already defined}\@eha |
---|
2147 | \@gobbletwo}} |
---|
2148 | \def\@tempa#1#2#3{% |
---|
2149 | \gdef\lstnewenvironment@##1##2##3##4##5{% |
---|
2150 | \begingroup |
---|
2151 | \global\@namedef{end##2}{\lstenv@Error{##2}}% |
---|
2152 | \global\@namedef{##2}{\def\lstenv@name{##2}% |
---|
2153 | \begingroup \lst@setcatcodes \catcode\active=\active |
---|
2154 | \csname##2@\endcsname}% |
---|
2155 | \let\l@ngrel@x\global |
---|
2156 | \let\@xargdef\lstenv@xargdef |
---|
2157 | \expandafter\new@command\csname##2@\endcsname##3% |
---|
2158 | {\lsthk@PreSet ##4% |
---|
2159 | \ifx\@currenvir\lstenv@name |
---|
2160 | \def\lstenv@endstring{#1#2##1#3}% |
---|
2161 | \else |
---|
2162 | \def\lstenv@endstring{#1##1}% |
---|
2163 | \fi |
---|
2164 | \@namedef{end##2}{\lst@DeInit ##5\endgroup |
---|
2165 | \lst@doendpe \@ignoretrue}% |
---|
2166 | \lsthk@DisplayStyle |
---|
2167 | \let\lst@EndProcessListing\lstenv@SkipToEnd |
---|
2168 | \lst@Init\lstenv@backslash |
---|
2169 | \lst@ifprint |
---|
2170 | \expandafter\expandafter\expandafter\lstenv@Process |
---|
2171 | \else |
---|
2172 | \expandafter\lstenv@SkipToEnd |
---|
2173 | \fi |
---|
2174 | \lst@insertargs}% |
---|
2175 | \endgroup}% |
---|
2176 | } |
---|
2177 | \let\lst@arg\@empty \lst@XConvert{end}\{\}\@nil |
---|
2178 | \expandafter\@tempa\lst@arg |
---|
2179 | \let\lst@insertargs\@empty |
---|
2180 | \def\lstenv@xargdef#1{ |
---|
2181 | \expandafter\lstenv@xargdef@\csname\string#1\endcsname#1} |
---|
2182 | \def\lstenv@xargdef@#1#2[#3][#4]#5{% |
---|
2183 | \@ifdefinable#2{% |
---|
2184 | \gdef#2{% |
---|
2185 | \ifx\protect\@typeset@protect |
---|
2186 | \expandafter\lstenv@testopt |
---|
2187 | \else |
---|
2188 | \@x@protect#2% |
---|
2189 | \fi |
---|
2190 | #1% |
---|
2191 | {#4}}% |
---|
2192 | \@yargdef |
---|
2193 | #1% |
---|
2194 | \tw@ |
---|
2195 | {#3}% |
---|
2196 | {#5}}} |
---|
2197 | \long\def\lstenv@testopt#1#2{% |
---|
2198 | \@ifnextchar[{\catcode\active5\relax \lstenv@testopt@#1}% |
---|
2199 | {#1[{#2}]}} |
---|
2200 | \def\lstenv@testopt@#1[#2]{% |
---|
2201 | \catcode\active\active |
---|
2202 | #1[#2]} |
---|
2203 | \begingroup \lccode`\~=`\\\lowercase{% |
---|
2204 | \gdef\lstenv@SkipToEnd{% |
---|
2205 | \long\expandafter\def\expandafter\lst@temp\expandafter##\expandafter |
---|
2206 | 1\expandafter~\lstenv@endstring{\lstenv@End}% |
---|
2207 | \lst@temp} |
---|
2208 | }\endgroup |
---|
2209 | \def\lstenv@Error#1{\PackageError{Listings}{Extra \string\end#1}% |
---|
2210 | {I'm ignoring this, since I wasn't doing a \csname#1\endcsname.}} |
---|
2211 | \begingroup \lccode`\~=`\^^M\lowercase{% |
---|
2212 | \gdef\lst@TestEOLChar#1{% |
---|
2213 | \def\lst@insertargs{#1}% |
---|
2214 | \ifx ~#1\@empty \else |
---|
2215 | \ifx^^J#1\@empty \else |
---|
2216 | \global\let\lst@intname\lst@insertargs |
---|
2217 | \let\lst@insertargs\@empty |
---|
2218 | \fi \fi} |
---|
2219 | }\endgroup |
---|
2220 | \lstnewenvironment{lstlisting}[2][] |
---|
2221 | {\lst@TestEOLChar{#2}% |
---|
2222 | \lstset{#1}% |
---|
2223 | \csname\@lst @SetFirstNumber\endcsname} |
---|
2224 | {\csname\@lst @SaveFirstNumber\endcsname} |
---|
2225 | \lst@Key{fancyvrb}\relax[t]{% |
---|
2226 | \lstKV@SetIf{#1}\lst@iffancyvrb |
---|
2227 | \lstFV@fancyvrb} |
---|
2228 | \ifx\lstFV@fancyvrb\@undefined |
---|
2229 | \gdef\lstFV@fancyvrb{\lst@RequireAspects{fancyvrb}\lstFV@fancyvrb} |
---|
2230 | \fi |
---|
2231 | \@ifundefined{ocp}{} |
---|
2232 | {\lst@AddToHook{OutputBox}% |
---|
2233 | {\let\lst@ProcessLetter\@firstofone |
---|
2234 | \let\lst@ProcessDigit\@firstofone |
---|
2235 | \let\lst@ProcessOther\@firstofone}} |
---|
2236 | \DeclareOption*{\expandafter\lst@ProcessOption\CurrentOption\relax} |
---|
2237 | \def\lst@ProcessOption#1#2\relax{% |
---|
2238 | \ifx #1!% |
---|
2239 | \lst@DeleteKeysIn\lst@loadaspects{#2}% |
---|
2240 | \else |
---|
2241 | \lst@lAddTo\lst@loadaspects{,#1#2}% |
---|
2242 | \fi} |
---|
2243 | \@ifundefined{lst@loadaspects} |
---|
2244 | {\def\lst@loadaspects{strings,comments,escape,style,language,% |
---|
2245 | keywords,labels,lineshape,frames,emph,index}% |
---|
2246 | }{} |
---|
2247 | \InputIfFileExists{lstpatch.sty}{}{} |
---|
2248 | \let\lst@ifsavemem\iffalse |
---|
2249 | \DeclareOption{savemem}{\let\lst@ifsavemem\iftrue} |
---|
2250 | \DeclareOption{noaspects}{\let\lst@loadaspects\@empty} |
---|
2251 | \ProcessOptions |
---|
2252 | \lst@RequireAspects\lst@loadaspects |
---|
2253 | \let\lst@loadaspects\@empty |
---|
2254 | \lst@UseHook{SetStyle}\lst@UseHook{EmptyStyle} |
---|
2255 | \lst@UseHook{SetLanguage}\lst@UseHook{EmptyLanguage} |
---|
2256 | \InputIfFileExists{listings.cfg}{}{} |
---|
2257 | \InputIfFileExists{lstlocal.cfg}{}{} |
---|
2258 | \endinput |
---|
2259 | %% |
---|
2260 | %% End of file `listings.sty'. |
---|