Debian Codegraph @

texmf-dist/tex/latex/l3kernel/expl3-code.tex

raw
1 %%
2 %% This is file `expl3-code.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% expl3.dtx (with options: `code')
8 %% l3bootstrap.dtx (with options: `code')
9 %% l3names.dtx (with options: `code')
10 %% l3basics.dtx (with options: `code')
11 %% l3expan.dtx (with options: `code')
12 %% l3quark.dtx (with options: `code')
13 %% l3tl.dtx (with options: `code')
14 %% l3tl-build.dtx (with options: `code')
15 %% l3str.dtx (with options: `code')
16 %% l3seq.dtx (with options: `code')
17 %% l3int.dtx (with options: `code')
18 %% l3flag.dtx (with options: `code')
19 %% l3prg.dtx (with options: `code')
20 %% l3sys.dtx (with options: `code')
21 %% l3clist.dtx (with options: `code')
22 %% l3token.dtx (with options: `code')
23 %% l3prop.dtx (with options: `code')
24 %% l3msg.dtx (with options: `code')
25 %% l3file.dtx (with options: `code')
26 %% l3skip.dtx (with options: `code')
27 %% l3keys.dtx (with options: `code')
28 %% l3intarray.dtx (with options: `code')
29 %% l3fp.dtx (with options: `code')
30 %% l3fp-aux.dtx (with options: `code')
31 %% l3fp-traps.dtx (with options: `code')
32 %% l3fp-round.dtx (with options: `code')
33 %% l3fp-parse.dtx (with options: `code')
34 %% l3fp-assign.dtx (with options: `code')
35 %% l3fp-logic.dtx (with options: `code')
36 %% l3fp-basics.dtx (with options: `code')
37 %% l3fp-extended.dtx (with options: `code')
38 %% l3fp-expo.dtx (with options: `code')
39 %% l3fp-trig.dtx (with options: `code')
40 %% l3fp-convert.dtx (with options: `code')
41 %% l3fp-random.dtx (with options: `code')
42 %% l3fp-types.dtx (with options: `code')
43 %% l3fp-symbolic.dtx (with options: `code')
44 %% l3fp-functions.dtx (with options: `code')
45 %% l3fparray.dtx (with options: `code')
46 %% l3bitset.dtx (with options: `code')
47 %% l3cctab.dtx (with options: `code')
48 %% l3sort.dtx (with options: `code')
49 %% l3str-convert.dtx (with options: `code')
50 %% l3str-format.dtx (with options: `code')
51 %% l3tl-analysis.dtx (with options: `code')
52 %% l3benchmark.dtx (with options: `code')
53 %% l3regex.dtx (with options: `code')
54 %% l3box.dtx (with options: `code')
55 %% l3color.dtx (with options: `code')
56 %% l3graphics.dtx (with options: `code')
57 %% l3opacity.dtx (with options: `code')
58 %% l3pdf.dtx (with options: `code')
59 %% l3coffins.dtx (with options: `code')
60 %% l3luatex.dtx (with options: `code')
61 %% l3unicode.dtx (with options: `code')
62 %% l3text.dtx (with options: `code')
63 %% l3text-case.dtx (with options: `code')
64 %% l3text-map.dtx (with options: `code')
65 %% l3text-purify.dtx (with options: `code')
66 %% l3text-utils.dtx (with options: `code')
67 %% l3legacy.dtx (with options: `code')
68 %% l3deprecation.dtx (with options: `code')
69 %%
70 %% Copyright (C) 1990-2026 The LaTeX Project
71 %%
72 %% It may be distributed and/or modified under the conditions of
73 %% the LaTeX Project Public License (LPPL), either version 1.3c of
74 %% this license or (at your option) any later version. The latest
75 %% version of this license is in the file:
76 %%
77 %% https://www.latex-project.org/lppl.txt
78 %%
79 %% This file is part of the "l3kernel bundle" (The Work in LPPL)
80 %% and all files in that bundle must be distributed together.
81 %%
82 %% File: expl3.dtx
83 \def\ExplFileDate{2026-05-15}%
84 \begingroup
85 \def\next{\endgroup}%
86 \expandafter\ifx\csname PackageError\endcsname\relax
87 \begingroup
88 \def\next{\endgroup\endgroup}%
89 \def\PackageError#1#2#3%
90 {%
91 \endgroup
92 \errhelp{#3}%
93 \errmessage{#1 Error: #2!}%
94 }%
95 \fi
96 \expandafter\ifx\csname ExplLoaderFileDate\endcsname\relax
97 \def\next
98 {%
99 \PackageError{expl3}{No expl3 loader detected}
100 {%
101 You have attempted to use the expl3 code directly rather than using
102 the correct loader. Loading of expl3 will abort.
103 }%
104 \endgroup
105 \endinput
106 }
107 \else
108 \ifx\ExplLoaderFileDate\ExplFileDate
109 \else
110 \def\next
111 {%
112 \PackageError{expl3}{Mismatched expl3 files detected}
113 {%
114 You have attempted to load expl3 with mismatched files:
115 probably you have one or more files 'locally installed' which
116 are in conflict. Loading of expl3 will abort.
117 }%
118 \endgroup
119 \endinput
120 }%
121 \fi
122 \fi
123 \next
124 \begingroup\expandafter\expandafter\expandafter\endgroup
125 \expandafter\ifx\csname [email protected]\endcsname\relax
126 \expandafter\edef\csname [email protected]\endcsname
127 {%
128 \ExplFileDate\space
129 L3 programming layer
130 }%
131 \else
132 \expandafter\endinput
133 \fi
134 \immediate\write-1 %
135 {%
136 Package: expl3
137 \ExplFileDate\space
138 L3 programming layer (code)%
139 }%
140 %% File: l3bootstrap.dtx
141 \begingroup\expandafter\expandafter\expandafter\endgroup
142 \expandafter\ifx\csname pdfstrcmp\endcsname\relax
143 \let\pdfstrcmp\strcmp
144 \fi
145 \begingroup\expandafter\expandafter\expandafter\endgroup
146 \expandafter\ifx\csname directlua\endcsname\relax
147 \else
148 \ifnum\luatexversion<110 %
149 \else
150 \begingroup\expandafter\expandafter\expandafter\endgroup
151 \expandafter\ifx\csname newcatcodetable\endcsname\relax
152 \input{ltluatex}%
153 \fi
154 \begingroup\expandafter\expandafter\expandafter\endgroup
155 \expandafter\ifx\csname newluabytecode\endcsname\relax
156 \else
157 \newluabytecode\@expl@luadata@bytecode
158 \fi
159 \directlua{require("expl3")}%
160 \ifnum 0%
161 \directlua{
162 if status.ini_version then
163 tex.write("1")
164 end
165 }>0 %
166 \everyjob\expandafter{%
167 \the\expandafter\everyjob
168 \csname\detokenize{lua_now:n}\endcsname{require("expl3")}%
169 }%
170 \fi
171 \fi
172 \fi
173 \begingroup
174 \def\next{\endgroup}%
175 \def\ShortText{Required primitives not found}%
176 \def\LongText%
177 {%
178 The L3 programming layer requires the e-TeX primitives and the
179 \LineBreak 'pdfTeX utilities' as described in the README file.
180 \LineBreak
181 These are available in the engines\LineBreak
182 - pdfTeX v1.40.20\LineBreak
183 - XeTeX v0.999991\LineBreak
184 - LuaTeX v1.10\LineBreak
185 - e-(u)pTeX v3.8.2\LineBreak
186 - Prote (2021)\LineBreak
187 or later.\LineBreak
188 \LineBreak
189 }%
190 \ifnum0%
191 \expandafter\ifx\csname luatexversion\endcsname\relax
192 \expandafter\ifx\csname expanded\endcsname\relax\else 1\fi
193 \else
194 \ifnum\luatexversion<110 \else 1\fi
195 \fi
196 =0 %
197 \newlinechar`\^^J %
198 \def\LineBreak{\noexpand\MessageBreak}%
199 \expandafter\ifx\csname PackageError\endcsname\relax
200 \def\LineBreak{^^J}%
201 \begingroup
202 \lccode`\~=`\ \lccode`\}=`\ %
203 \lccode`\T=`\T\lccode`\H=`\H%
204 \catcode`\ =11 %
205 \lowercase{\endgroup\def\PackageError#1#2#3{%
206 \begingroup\errorcontextlines-1\immediate\write0{}\errhelp{#3}\def%
207 \ {#1 Error: #2.^^J^^J
208 Type H <return> for immediate help}\def~{\errmessage{%
209 \ }}~\endgroup}}%
210 \fi
211 \edef\next
212 {%
213 \noexpand\PackageError{expl3}{\ShortText}
214 {\LongText Loading of expl3 will abort!}%
215 \endgroup
216 \noexpand\endinput
217 }%
218 \fi
219 \next
220 \protected\edef\ExplSyntaxOff
221 {%
222 \protected\def\noexpand\ExplSyntaxOff{}%
223 \catcode 9 = \the\catcode 9\relax
224 \catcode 32 = \the\catcode 32\relax
225 \catcode 34 = \the\catcode 34\relax
226 \catcode 58 = \the\catcode 58\relax
227 \catcode 94 = \the\catcode 94\relax
228 \catcode 95 = \the\catcode 95\relax
229 \catcode 124 = \the\catcode 124\relax
230 \catcode 126 = \the\catcode 126\relax
231 \endlinechar = \the\endlinechar\relax
232 \chardef\csname\detokenize{l__kernel_expl_bool}\endcsname = 0\relax
233 }%
234 \catcode 9 = 9\relax
235 \catcode 32 = 9\relax
236 \catcode 34 = 12\relax
237 \catcode 58 = 11\relax
238 \catcode 94 = 7\relax
239 \catcode 95 = 11\relax
240 \catcode 124 = 12\relax
241 \catcode 126 = 10\relax
242 \endlinechar = 32\relax
243 \global\chardef\l__kernel_expl_bool = 1\relax
244 \protected \def \ExplSyntaxOn
245 {
246 \bool_if:NF \l__kernel_expl_bool
247 {
248 \cs_set_protected:Npe \ExplSyntaxOff
249 {
250 \char_set_catcode:nn { 9 } { \char_value_catcode:n { 9 } }
251 \char_set_catcode:nn { 32 } { \char_value_catcode:n { 32 } }
252 \char_set_catcode:nn { 34 } { \char_value_catcode:n { 34 } }
253 \char_set_catcode:nn { 58 } { \char_value_catcode:n { 58 } }
254 \char_set_catcode:nn { 94 } { \char_value_catcode:n { 94 } }
255 \char_set_catcode:nn { 95 } { \char_value_catcode:n { 95 } }
256 \char_set_catcode:nn { 124 } { \char_value_catcode:n { 124 } }
257 \char_set_catcode:nn { 126 } { \char_value_catcode:n { 126 } }
258 \tex_endlinechar:D =
259 \tex_the:D \tex_endlinechar:D \scan_stop:
260 \bool_set_false:N \l__kernel_expl_bool
261 \cs_set_protected:Npn \ExplSyntaxOff { }
262 }
263 }
264 \char_set_catcode_ignore:n { 9 } % tab
265 \char_set_catcode_ignore:n { 32 } % space
266 \char_set_catcode_other:n { 34 } % double quote
267 \char_set_catcode_letter:n { 58 } % colon
268 \char_set_catcode_math_superscript:n { 94 } % circumflex
269 \char_set_catcode_letter:n { 95 } % underscore
270 \char_set_catcode_other:n { 124 } % pipe
271 \char_set_catcode_space:n { 126 } % tilde
272 \tex_endlinechar:D = 32 \scan_stop:
273 \bool_set_true:N \l__kernel_expl_bool
274 }
275 %% File: l3names.dtx
276 \let \tex_global:D \global
277 \let \tex_let:D \let
278 \begingroup
279 \long \def \__kernel_primitive:NN #1#2
280 { \tex_global:D \tex_let:D #2 #1 }
281 \__kernel_primitive:NN \ \tex_space:D
282 \__kernel_primitive:NN \/ \tex_italiccorrection:D
283 \__kernel_primitive:NN \- \tex_hyphen:D
284 \__kernel_primitive:NN \above \tex_above:D
285 \__kernel_primitive:NN \abovedisplayshortskip \tex_abovedisplayshortskip:D
286 \__kernel_primitive:NN \abovedisplayskip \tex_abovedisplayskip:D
287 \__kernel_primitive:NN \abovewithdelims \tex_abovewithdelims:D
288 \__kernel_primitive:NN \accent \tex_accent:D
289 \__kernel_primitive:NN \adjdemerits \tex_adjdemerits:D
290 \__kernel_primitive:NN \advance \tex_advance:D
291 \__kernel_primitive:NN \afterassignment \tex_afterassignment:D
292 \__kernel_primitive:NN \aftergroup \tex_aftergroup:D
293 \__kernel_primitive:NN \atop \tex_atop:D
294 \__kernel_primitive:NN \atopwithdelims \tex_atopwithdelims:D
295 \__kernel_primitive:NN \badness \tex_badness:D
296 \__kernel_primitive:NN \baselineskip \tex_baselineskip:D
297 \__kernel_primitive:NN \batchmode \tex_batchmode:D
298 \__kernel_primitive:NN \begingroup \tex_begingroup:D
299 \__kernel_primitive:NN \belowdisplayshortskip \tex_belowdisplayshortskip:D
300 \__kernel_primitive:NN \belowdisplayskip \tex_belowdisplayskip:D
301 \__kernel_primitive:NN \binoppenalty \tex_binoppenalty:D
302 \__kernel_primitive:NN \botmark \tex_botmark:D
303 \__kernel_primitive:NN \box \tex_box:D
304 \__kernel_primitive:NN \boxmaxdepth \tex_boxmaxdepth:D
305 \__kernel_primitive:NN \brokenpenalty \tex_brokenpenalty:D
306 \__kernel_primitive:NN \catcode \tex_catcode:D
307 \__kernel_primitive:NN \char \tex_char:D
308 \__kernel_primitive:NN \chardef \tex_chardef:D
309 \__kernel_primitive:NN \cleaders \tex_cleaders:D
310 \__kernel_primitive:NN \closein \tex_closein:D
311 \__kernel_primitive:NN \closeout \tex_closeout:D
312 \__kernel_primitive:NN \clubpenalty \tex_clubpenalty:D
313 \__kernel_primitive:NN \copy \tex_copy:D
314 \__kernel_primitive:NN \count \tex_count:D
315 \__kernel_primitive:NN \countdef \tex_countdef:D
316 \__kernel_primitive:NN \cr \tex_cr:D
317 \__kernel_primitive:NN \crcr \tex_crcr:D
318 \__kernel_primitive:NN \csname \tex_csname:D
319 \__kernel_primitive:NN \day \tex_day:D
320 \__kernel_primitive:NN \deadcycles \tex_deadcycles:D
321 \__kernel_primitive:NN \def \tex_def:D
322 \__kernel_primitive:NN \defaulthyphenchar \tex_defaulthyphenchar:D
323 \__kernel_primitive:NN \defaultskewchar \tex_defaultskewchar:D
324 \__kernel_primitive:NN \delcode \tex_delcode:D
325 \__kernel_primitive:NN \delimiter \tex_delimiter:D
326 \__kernel_primitive:NN \delimiterfactor \tex_delimiterfactor:D
327 \__kernel_primitive:NN \delimitershortfall \tex_delimitershortfall:D
328 \__kernel_primitive:NN \dimen \tex_dimen:D
329 \__kernel_primitive:NN \dimendef \tex_dimendef:D
330 \__kernel_primitive:NN \discretionary \tex_discretionary:D
331 \__kernel_primitive:NN \displayindent \tex_displayindent:D
332 \__kernel_primitive:NN \displaylimits \tex_displaylimits:D
333 \__kernel_primitive:NN \displaystyle \tex_displaystyle:D
334 \__kernel_primitive:NN \displaywidowpenalty \tex_displaywidowpenalty:D
335 \__kernel_primitive:NN \displaywidth \tex_displaywidth:D
336 \__kernel_primitive:NN \divide \tex_divide:D
337 \__kernel_primitive:NN \doublehyphendemerits \tex_doublehyphendemerits:D
338 \__kernel_primitive:NN \dp \tex_dp:D
339 \__kernel_primitive:NN \dump \tex_dump:D
340 \__kernel_primitive:NN \edef \tex_edef:D
341 \__kernel_primitive:NN \else \tex_else:D
342 \__kernel_primitive:NN \emergencystretch \tex_emergencystretch:D
343 \__kernel_primitive:NN \end \tex_end:D
344 \__kernel_primitive:NN \endcsname \tex_endcsname:D
345 \__kernel_primitive:NN \endgroup \tex_endgroup:D
346 \__kernel_primitive:NN \endinput \tex_endinput:D
347 \__kernel_primitive:NN \endlinechar \tex_endlinechar:D
348 \__kernel_primitive:NN \eqno \tex_eqno:D
349 \__kernel_primitive:NN \errhelp \tex_errhelp:D
350 \__kernel_primitive:NN \errmessage \tex_errmessage:D
351 \__kernel_primitive:NN \errorcontextlines \tex_errorcontextlines:D
352 \__kernel_primitive:NN \errorstopmode \tex_errorstopmode:D
353 \__kernel_primitive:NN \escapechar \tex_escapechar:D
354 \__kernel_primitive:NN \everycr \tex_everycr:D
355 \__kernel_primitive:NN \everydisplay \tex_everydisplay:D
356 \__kernel_primitive:NN \everyhbox \tex_everyhbox:D
357 \__kernel_primitive:NN \everyjob \tex_everyjob:D
358 \__kernel_primitive:NN \everymath \tex_everymath:D
359 \__kernel_primitive:NN \everypar \tex_everypar:D
360 \__kernel_primitive:NN \everyvbox \tex_everyvbox:D
361 \__kernel_primitive:NN \exhyphenpenalty \tex_exhyphenpenalty:D
362 \__kernel_primitive:NN \expandafter \tex_expandafter:D
363 \__kernel_primitive:NN \fam \tex_fam:D
364 \__kernel_primitive:NN \fi \tex_fi:D
365 \__kernel_primitive:NN \finalhyphendemerits \tex_finalhyphendemerits:D
366 \__kernel_primitive:NN \firstmark \tex_firstmark:D
367 \__kernel_primitive:NN \floatingpenalty \tex_floatingpenalty:D
368 \__kernel_primitive:NN \font \tex_font:D
369 \__kernel_primitive:NN \fontdimen \tex_fontdimen:D
370 \__kernel_primitive:NN \fontname \tex_fontname:D
371 \__kernel_primitive:NN \futurelet \tex_futurelet:D
372 \__kernel_primitive:NN \gdef \tex_gdef:D
373 \__kernel_primitive:NN \global \tex_global:D
374 \__kernel_primitive:NN \globaldefs \tex_globaldefs:D
375 \__kernel_primitive:NN \halign \tex_halign:D
376 \__kernel_primitive:NN \hangafter \tex_hangafter:D
377 \__kernel_primitive:NN \hangindent \tex_hangindent:D
378 \__kernel_primitive:NN \hbadness \tex_hbadness:D
379 \__kernel_primitive:NN \hbox \tex_hbox:D
380 \__kernel_primitive:NN \hfil \tex_hfil:D
381 \__kernel_primitive:NN \hfill \tex_hfill:D
382 \__kernel_primitive:NN \hfilneg \tex_hfilneg:D
383 \__kernel_primitive:NN \hfuzz \tex_hfuzz:D
384 \__kernel_primitive:NN \hoffset \tex_hoffset:D
385 \__kernel_primitive:NN \holdinginserts \tex_holdinginserts:D
386 \__kernel_primitive:NN \hrule \tex_hrule:D
387 \__kernel_primitive:NN \hsize \tex_hsize:D
388 \__kernel_primitive:NN \hskip \tex_hskip:D
389 \__kernel_primitive:NN \hss \tex_hss:D
390 \__kernel_primitive:NN \ht \tex_ht:D
391 \__kernel_primitive:NN \hyphenation \tex_hyphenation:D
392 \__kernel_primitive:NN \hyphenchar \tex_hyphenchar:D
393 \__kernel_primitive:NN \hyphenpenalty \tex_hyphenpenalty:D
394 \__kernel_primitive:NN \if \tex_if:D
395 \__kernel_primitive:NN \ifcase \tex_ifcase:D
396 \__kernel_primitive:NN \ifcat \tex_ifcat:D
397 \__kernel_primitive:NN \ifdim \tex_ifdim:D
398 \__kernel_primitive:NN \ifeof \tex_ifeof:D
399 \__kernel_primitive:NN \iffalse \tex_iffalse:D
400 \__kernel_primitive:NN \ifhbox \tex_ifhbox:D
401 \__kernel_primitive:NN \ifhmode \tex_ifhmode:D
402 \__kernel_primitive:NN \ifinner \tex_ifinner:D
403 \__kernel_primitive:NN \ifmmode \tex_ifmmode:D
404 \__kernel_primitive:NN \ifnum \tex_ifnum:D
405 \__kernel_primitive:NN \ifodd \tex_ifodd:D
406 \__kernel_primitive:NN \iftrue \tex_iftrue:D
407 \__kernel_primitive:NN \ifvbox \tex_ifvbox:D
408 \__kernel_primitive:NN \ifvmode \tex_ifvmode:D
409 \__kernel_primitive:NN \ifvoid \tex_ifvoid:D
410 \__kernel_primitive:NN \ifx \tex_ifx:D
411 \__kernel_primitive:NN \ignorespaces \tex_ignorespaces:D
412 \__kernel_primitive:NN \immediate \tex_immediate:D
413 \__kernel_primitive:NN \indent \tex_indent:D
414 \__kernel_primitive:NN \input \tex_input:D
415 \__kernel_primitive:NN \inputlineno \tex_inputlineno:D
416 \__kernel_primitive:NN \insert \tex_insert:D
417 \__kernel_primitive:NN \insertpenalties \tex_insertpenalties:D
418 \__kernel_primitive:NN \interlinepenalty \tex_interlinepenalty:D
419 \__kernel_primitive:NN \jobname \tex_jobname:D
420 \__kernel_primitive:NN \kern \tex_kern:D
421 \__kernel_primitive:NN \language \tex_language:D
422 \__kernel_primitive:NN \lastbox \tex_lastbox:D
423 \__kernel_primitive:NN \lastkern \tex_lastkern:D
424 \__kernel_primitive:NN \lastpenalty \tex_lastpenalty:D
425 \__kernel_primitive:NN \lastskip \tex_lastskip:D
426 \__kernel_primitive:NN \lccode \tex_lccode:D
427 \__kernel_primitive:NN \leaders \tex_leaders:D
428 \__kernel_primitive:NN \left \tex_left:D
429 \__kernel_primitive:NN \lefthyphenmin \tex_lefthyphenmin:D
430 \__kernel_primitive:NN \leftskip \tex_leftskip:D
431 \__kernel_primitive:NN \leqno \tex_leqno:D
432 \__kernel_primitive:NN \let \tex_let:D
433 \__kernel_primitive:NN \limits \tex_limits:D
434 \__kernel_primitive:NN \linepenalty \tex_linepenalty:D
435 \__kernel_primitive:NN \lineskip \tex_lineskip:D
436 \__kernel_primitive:NN \lineskiplimit \tex_lineskiplimit:D
437 \__kernel_primitive:NN \long \tex_long:D
438 \__kernel_primitive:NN \looseness \tex_looseness:D
439 \__kernel_primitive:NN \lower \tex_lower:D
440 \__kernel_primitive:NN \lowercase \tex_lowercase:D
441 \__kernel_primitive:NN \mag \tex_mag:D
442 \__kernel_primitive:NN \mark \tex_mark:D
443 \__kernel_primitive:NN \mathaccent \tex_mathaccent:D
444 \__kernel_primitive:NN \mathbin \tex_mathbin:D
445 \__kernel_primitive:NN \mathchar \tex_mathchar:D
446 \__kernel_primitive:NN \mathchardef \tex_mathchardef:D
447 \__kernel_primitive:NN \mathchoice \tex_mathchoice:D
448 \__kernel_primitive:NN \mathclose \tex_mathclose:D
449 \__kernel_primitive:NN \mathcode \tex_mathcode:D
450 \__kernel_primitive:NN \mathinner \tex_mathinner:D
451 \__kernel_primitive:NN \mathop \tex_mathop:D
452 \__kernel_primitive:NN \mathopen \tex_mathopen:D
453 \__kernel_primitive:NN \mathord \tex_mathord:D
454 \__kernel_primitive:NN \mathpunct \tex_mathpunct:D
455 \__kernel_primitive:NN \mathrel \tex_mathrel:D
456 \__kernel_primitive:NN \mathsurround \tex_mathsurround:D
457 \__kernel_primitive:NN \maxdeadcycles \tex_maxdeadcycles:D
458 \__kernel_primitive:NN \maxdepth \tex_maxdepth:D
459 \__kernel_primitive:NN \meaning \tex_meaning:D
460 \__kernel_primitive:NN \medmuskip \tex_medmuskip:D
461 \__kernel_primitive:NN \message \tex_message:D
462 \__kernel_primitive:NN \mkern \tex_mkern:D
463 \__kernel_primitive:NN \month \tex_month:D
464 \__kernel_primitive:NN \moveleft \tex_moveleft:D
465 \__kernel_primitive:NN \moveright \tex_moveright:D
466 \__kernel_primitive:NN \mskip \tex_mskip:D
467 \__kernel_primitive:NN \multiply \tex_multiply:D
468 \__kernel_primitive:NN \muskip \tex_muskip:D
469 \__kernel_primitive:NN \muskipdef \tex_muskipdef:D
470 \__kernel_primitive:NN \newlinechar \tex_newlinechar:D
471 \__kernel_primitive:NN \noalign \tex_noalign:D
472 \__kernel_primitive:NN \noboundary \tex_noboundary:D
473 \__kernel_primitive:NN \noexpand \tex_noexpand:D
474 \__kernel_primitive:NN \noindent \tex_noindent:D
475 \__kernel_primitive:NN \nolimits \tex_nolimits:D
476 \__kernel_primitive:NN \nonscript \tex_nonscript:D
477 \__kernel_primitive:NN \nonstopmode \tex_nonstopmode:D
478 \__kernel_primitive:NN \nulldelimiterspace \tex_nulldelimiterspace:D
479 \__kernel_primitive:NN \nullfont \tex_nullfont:D
480 \__kernel_primitive:NN \number \tex_number:D
481 \__kernel_primitive:NN \omit \tex_omit:D
482 \__kernel_primitive:NN \openin \tex_openin:D
483 \__kernel_primitive:NN \openout \tex_openout:D
484 \__kernel_primitive:NN \or \tex_or:D
485 \__kernel_primitive:NN \outer \tex_outer:D
486 \__kernel_primitive:NN \output \tex_output:D
487 \__kernel_primitive:NN \outputpenalty \tex_outputpenalty:D
488 \__kernel_primitive:NN \over \tex_over:D
489 \__kernel_primitive:NN \overfullrule \tex_overfullrule:D
490 \__kernel_primitive:NN \overline \tex_overline:D
491 \__kernel_primitive:NN \overwithdelims \tex_overwithdelims:D
492 \__kernel_primitive:NN \pagedepth \tex_pagedepth:D
493 \__kernel_primitive:NN \pagefilllstretch \tex_pagefilllstretch:D
494 \__kernel_primitive:NN \pagefillstretch \tex_pagefillstretch:D
495 \__kernel_primitive:NN \pagefilstretch \tex_pagefilstretch:D
496 \__kernel_primitive:NN \pagegoal \tex_pagegoal:D
497 \__kernel_primitive:NN \pageshrink \tex_pageshrink:D
498 \__kernel_primitive:NN \pagestretch \tex_pagestretch:D
499 \__kernel_primitive:NN \pagetotal \tex_pagetotal:D
500 \__kernel_primitive:NN \par \tex_par:D
501 \__kernel_primitive:NN \parfillskip \tex_parfillskip:D
502 \__kernel_primitive:NN \parindent \tex_parindent:D
503 \__kernel_primitive:NN \parshape \tex_parshape:D
504 \__kernel_primitive:NN \parskip \tex_parskip:D
505 \__kernel_primitive:NN \patterns \tex_patterns:D
506 \__kernel_primitive:NN \pausing \tex_pausing:D
507 \__kernel_primitive:NN \penalty \tex_penalty:D
508 \__kernel_primitive:NN \postdisplaypenalty \tex_postdisplaypenalty:D
509 \__kernel_primitive:NN \predisplaypenalty \tex_predisplaypenalty:D
510 \__kernel_primitive:NN \predisplaysize \tex_predisplaysize:D
511 \__kernel_primitive:NN \pretolerance \tex_pretolerance:D
512 \__kernel_primitive:NN \prevdepth \tex_prevdepth:D
513 \__kernel_primitive:NN \prevgraf \tex_prevgraf:D
514 \__kernel_primitive:NN \radical \tex_radical:D
515 \__kernel_primitive:NN \raise \tex_raise:D
516 \__kernel_primitive:NN \read \tex_read:D
517 \__kernel_primitive:NN \relax \tex_relax:D
518 \__kernel_primitive:NN \relpenalty \tex_relpenalty:D
519 \__kernel_primitive:NN \right \tex_right:D
520 \__kernel_primitive:NN \righthyphenmin \tex_righthyphenmin:D
521 \__kernel_primitive:NN \rightskip \tex_rightskip:D
522 \__kernel_primitive:NN \romannumeral \tex_romannumeral:D
523 \__kernel_primitive:NN \scriptfont \tex_scriptfont:D
524 \__kernel_primitive:NN \scriptscriptfont \tex_scriptscriptfont:D
525 \__kernel_primitive:NN \scriptscriptstyle \tex_scriptscriptstyle:D
526 \__kernel_primitive:NN \scriptspace \tex_scriptspace:D
527 \__kernel_primitive:NN \scriptstyle \tex_scriptstyle:D
528 \__kernel_primitive:NN \scrollmode \tex_scrollmode:D
529 \__kernel_primitive:NN \setbox \tex_setbox:D
530 \__kernel_primitive:NN \setlanguage \tex_setlanguage:D
531 \__kernel_primitive:NN \sfcode \tex_sfcode:D
532 \__kernel_primitive:NN \shipout \tex_shipout:D
533 \__kernel_primitive:NN \show \tex_show:D
534 \__kernel_primitive:NN \showbox \tex_showbox:D
535 \__kernel_primitive:NN \showboxbreadth \tex_showboxbreadth:D
536 \__kernel_primitive:NN \showboxdepth \tex_showboxdepth:D
537 \__kernel_primitive:NN \showlists \tex_showlists:D
538 \__kernel_primitive:NN \showthe \tex_showthe:D
539 \__kernel_primitive:NN \skewchar \tex_skewchar:D
540 \__kernel_primitive:NN \skip \tex_skip:D
541 \__kernel_primitive:NN \skipdef \tex_skipdef:D
542 \__kernel_primitive:NN \spacefactor \tex_spacefactor:D
543 \__kernel_primitive:NN \spaceskip \tex_spaceskip:D
544 \__kernel_primitive:NN \span \tex_span:D
545 \__kernel_primitive:NN \special \tex_special:D
546 \__kernel_primitive:NN \splitbotmark \tex_splitbotmark:D
547 \__kernel_primitive:NN \splitfirstmark \tex_splitfirstmark:D
548 \__kernel_primitive:NN \splitmaxdepth \tex_splitmaxdepth:D
549 \__kernel_primitive:NN \splittopskip \tex_splittopskip:D
550 \__kernel_primitive:NN \string \tex_string:D
551 \__kernel_primitive:NN \tabskip \tex_tabskip:D
552 \__kernel_primitive:NN \textfont \tex_textfont:D
553 \__kernel_primitive:NN \textstyle \tex_textstyle:D
554 \__kernel_primitive:NN \the \tex_the:D
555 \__kernel_primitive:NN \thickmuskip \tex_thickmuskip:D
556 \__kernel_primitive:NN \thinmuskip \tex_thinmuskip:D
557 \__kernel_primitive:NN \time \tex_time:D
558 \__kernel_primitive:NN \toks \tex_toks:D
559 \__kernel_primitive:NN \toksdef \tex_toksdef:D
560 \__kernel_primitive:NN \tolerance \tex_tolerance:D
561 \__kernel_primitive:NN \topmark \tex_topmark:D
562 \__kernel_primitive:NN \topskip \tex_topskip:D
563 \__kernel_primitive:NN \tracingcommands \tex_tracingcommands:D
564 \__kernel_primitive:NN \tracinglostchars \tex_tracinglostchars:D
565 \__kernel_primitive:NN \tracingmacros \tex_tracingmacros:D
566 \__kernel_primitive:NN \tracingonline \tex_tracingonline:D
567 \__kernel_primitive:NN \tracingoutput \tex_tracingoutput:D
568 \__kernel_primitive:NN \tracingpages \tex_tracingpages:D
569 \__kernel_primitive:NN \tracingparagraphs \tex_tracingparagraphs:D
570 \__kernel_primitive:NN \tracingrestores \tex_tracingrestores:D
571 \__kernel_primitive:NN \tracingstats \tex_tracingstats:D
572 \__kernel_primitive:NN \uccode \tex_uccode:D
573 \__kernel_primitive:NN \uchyph \tex_uchyph:D
574 \__kernel_primitive:NN \underline \tex_underline:D
575 \__kernel_primitive:NN \unhbox \tex_unhbox:D
576 \__kernel_primitive:NN \unhcopy \tex_unhcopy:D
577 \__kernel_primitive:NN \unkern \tex_unkern:D
578 \__kernel_primitive:NN \unpenalty \tex_unpenalty:D
579 \__kernel_primitive:NN \unskip \tex_unskip:D
580 \__kernel_primitive:NN \unvbox \tex_unvbox:D
581 \__kernel_primitive:NN \unvcopy \tex_unvcopy:D
582 \__kernel_primitive:NN \uppercase \tex_uppercase:D
583 \__kernel_primitive:NN \vadjust \tex_vadjust:D
584 \__kernel_primitive:NN \valign \tex_valign:D
585 \__kernel_primitive:NN \vbadness \tex_vbadness:D
586 \__kernel_primitive:NN \vbox \tex_vbox:D
587 \__kernel_primitive:NN \vcenter \tex_vcenter:D
588 \__kernel_primitive:NN \vfil \tex_vfil:D
589 \__kernel_primitive:NN \vfill \tex_vfill:D
590 \__kernel_primitive:NN \vfilneg \tex_vfilneg:D
591 \__kernel_primitive:NN \vfuzz \tex_vfuzz:D
592 \__kernel_primitive:NN \voffset \tex_voffset:D
593 \__kernel_primitive:NN \vrule \tex_vrule:D
594 \__kernel_primitive:NN \vsize \tex_vsize:D
595 \__kernel_primitive:NN \vskip \tex_vskip:D
596 \__kernel_primitive:NN \vsplit \tex_vsplit:D
597 \__kernel_primitive:NN \vss \tex_vss:D
598 \__kernel_primitive:NN \vtop \tex_vtop:D
599 \__kernel_primitive:NN \wd \tex_wd:D
600 \__kernel_primitive:NN \widowpenalty \tex_widowpenalty:D
601 \__kernel_primitive:NN \write \tex_write:D
602 \__kernel_primitive:NN \xdef \tex_xdef:D
603 \__kernel_primitive:NN \xleaders \tex_xleaders:D
604 \__kernel_primitive:NN \xspaceskip \tex_xspaceskip:D
605 \__kernel_primitive:NN \year \tex_year:D
606 \__kernel_primitive:NN \beginL \tex_beginL:D
607 \__kernel_primitive:NN \beginR \tex_beginR:D
608 \__kernel_primitive:NN \botmarks \tex_botmarks:D
609 \__kernel_primitive:NN \clubpenalties \tex_clubpenalties:D
610 \__kernel_primitive:NN \currentgrouplevel \tex_currentgrouplevel:D
611 \__kernel_primitive:NN \currentgrouptype \tex_currentgrouptype:D
612 \__kernel_primitive:NN \currentifbranch \tex_currentifbranch:D
613 \__kernel_primitive:NN \currentiflevel \tex_currentiflevel:D
614 \__kernel_primitive:NN \currentiftype \tex_currentiftype:D
615 \__kernel_primitive:NN \detokenize \tex_detokenize:D
616 \__kernel_primitive:NN \dimexpr \tex_dimexpr:D
617 \__kernel_primitive:NN \displaywidowpenalties \tex_displaywidowpenalties:D
618 \__kernel_primitive:NN \endL \tex_endL:D
619 \__kernel_primitive:NN \endR \tex_endR:D
620 \__kernel_primitive:NN \eTeXrevision \tex_eTeXrevision:D
621 \__kernel_primitive:NN \eTeXversion \tex_eTeXversion:D
622 \__kernel_primitive:NN \everyeof \tex_everyeof:D
623 \__kernel_primitive:NN \firstmarks \tex_firstmarks:D
624 \__kernel_primitive:NN \fontchardp \tex_fontchardp:D
625 \__kernel_primitive:NN \fontcharht \tex_fontcharht:D
626 \__kernel_primitive:NN \fontcharic \tex_fontcharic:D
627 \__kernel_primitive:NN \fontcharwd \tex_fontcharwd:D
628 \__kernel_primitive:NN \glueexpr \tex_glueexpr:D
629 \__kernel_primitive:NN \glueshrink \tex_glueshrink:D
630 \__kernel_primitive:NN \glueshrinkorder \tex_glueshrinkorder:D
631 \__kernel_primitive:NN \gluestretch \tex_gluestretch:D
632 \__kernel_primitive:NN \gluestretchorder \tex_gluestretchorder:D
633 \__kernel_primitive:NN \gluetomu \tex_gluetomu:D
634 \__kernel_primitive:NN \ifcsname \tex_ifcsname:D
635 \__kernel_primitive:NN \ifdefined \tex_ifdefined:D
636 \__kernel_primitive:NN \iffontchar \tex_iffontchar:D
637 \__kernel_primitive:NN \interactionmode \tex_interactionmode:D
638 \__kernel_primitive:NN \interlinepenalties \tex_interlinepenalties:D
639 \__kernel_primitive:NN \lastlinefit \tex_lastlinefit:D
640 \__kernel_primitive:NN \lastnodetype \tex_lastnodetype:D
641 \__kernel_primitive:NN \marks \tex_marks:D
642 \__kernel_primitive:NN \middle \tex_middle:D
643 \__kernel_primitive:NN \muexpr \tex_muexpr:D
644 \__kernel_primitive:NN \mutoglue \tex_mutoglue:D
645 \__kernel_primitive:NN \numexpr \tex_numexpr:D
646 \__kernel_primitive:NN \pagediscards \tex_pagediscards:D
647 \__kernel_primitive:NN \parshapedimen \tex_parshapedimen:D
648 \__kernel_primitive:NN \parshapeindent \tex_parshapeindent:D
649 \__kernel_primitive:NN \parshapelength \tex_parshapelength:D
650 \__kernel_primitive:NN \predisplaydirection \tex_predisplaydirection:D
651 \__kernel_primitive:NN \protected \tex_protected:D
652 \__kernel_primitive:NN \readline \tex_readline:D
653 \__kernel_primitive:NN \savinghyphcodes \tex_savinghyphcodes:D
654 \__kernel_primitive:NN \savingvdiscards \tex_savingvdiscards:D
655 \__kernel_primitive:NN \scantokens \tex_scantokens:D
656 \__kernel_primitive:NN \showgroups \tex_showgroups:D
657 \__kernel_primitive:NN \showifs \tex_showifs:D
658 \__kernel_primitive:NN \showtokens \tex_showtokens:D
659 \__kernel_primitive:NN \splitbotmarks \tex_splitbotmarks:D
660 \__kernel_primitive:NN \splitdiscards \tex_splitdiscards:D
661 \__kernel_primitive:NN \splitfirstmarks \tex_splitfirstmarks:D
662 \__kernel_primitive:NN \TeXXeTstate \tex_TeXXeTstate:D
663 \__kernel_primitive:NN \topmarks \tex_topmarks:D
664 \__kernel_primitive:NN \tracingassigns \tex_tracingassigns:D
665 \__kernel_primitive:NN \tracinggroups \tex_tracinggroups:D
666 \__kernel_primitive:NN \tracingifs \tex_tracingifs:D
667 \__kernel_primitive:NN \tracingnesting \tex_tracingnesting:D
668 \__kernel_primitive:NN \tracingscantokens \tex_tracingscantokens:D
669 \__kernel_primitive:NN \unexpanded \tex_unexpanded:D
670 \__kernel_primitive:NN \unless \tex_unless:D
671 \__kernel_primitive:NN \widowpenalties \tex_widowpenalties:D
672 \__kernel_primitive:NN \pdfannot \tex_pdfannot:D
673 \__kernel_primitive:NN \pdfcatalog \tex_pdfcatalog:D
674 \__kernel_primitive:NN \pdfcompresslevel \tex_pdfcompresslevel:D
675 \__kernel_primitive:NN \pdfcolorstack \tex_pdfcolorstack:D
676 \__kernel_primitive:NN \pdfcolorstackinit \tex_pdfcolorstackinit:D
677 \__kernel_primitive:NN \pdfdecimaldigits \tex_pdfdecimaldigits:D
678 \__kernel_primitive:NN \pdfdest \tex_pdfdest:D
679 \__kernel_primitive:NN \pdfdestmargin \tex_pdfdestmargin:D
680 \__kernel_primitive:NN \pdfendlink \tex_pdfendlink:D
681 \__kernel_primitive:NN \pdfendthread \tex_pdfendthread:D
682 \__kernel_primitive:NN \pdffakespace \tex_pdffakespace:D
683 \__kernel_primitive:NN \pdffontattr \tex_pdffontattr:D
684 \__kernel_primitive:NN \pdffontname \tex_pdffontname:D
685 \__kernel_primitive:NN \pdffontobjnum \tex_pdffontobjnum:D
686 \__kernel_primitive:NN \pdfgamma \tex_pdfgamma:D
687 \__kernel_primitive:NN \pdfgentounicode \tex_pdfgentounicode:D
688 \__kernel_primitive:NN \pdfglyphtounicode \tex_pdfglyphtounicode:D
689 \__kernel_primitive:NN \pdfhorigin \tex_pdfhorigin:D
690 \__kernel_primitive:NN \pdfimageapplygamma \tex_pdfimageapplygamma:D
691 \__kernel_primitive:NN \pdfimagegamma \tex_pdfimagegamma:D
692 \__kernel_primitive:NN \pdfimagehicolor \tex_pdfimagehicolor:D
693 \__kernel_primitive:NN \pdfimageresolution \tex_pdfimageresolution:D
694 \__kernel_primitive:NN \pdfincludechars \tex_pdfincludechars:D
695 \__kernel_primitive:NN \pdfinclusioncopyfonts \tex_pdfinclusioncopyfonts:D
696 \__kernel_primitive:NN \pdfinclusionerrorlevel
697 \tex_pdfinclusionerrorlevel:D
698 \__kernel_primitive:NN \pdfinfo \tex_pdfinfo:D
699 \__kernel_primitive:NN \pdfinfoomitdate \tex_pdfinfoomitdate:D
700 \__kernel_primitive:NN \pdfinterwordspaceoff \tex_pdfinterwordspaceoff:D
701 \__kernel_primitive:NN \pdfinterwordspaceon \tex_pdfinterwordspaceon:D
702 \__kernel_primitive:NN \pdflastannot \tex_pdflastannot:D
703 \__kernel_primitive:NN \pdflastlink \tex_pdflastlink:D
704 \__kernel_primitive:NN \pdflastobj \tex_pdflastobj:D
705 \__kernel_primitive:NN \pdflastxform \tex_pdflastxform:D
706 \__kernel_primitive:NN \pdflastximage \tex_pdflastximage:D
707 \__kernel_primitive:NN \pdflastximagecolordepth
708 \tex_pdflastximagecolordepth:D
709 \__kernel_primitive:NN \pdflastximagepages \tex_pdflastximagepages:D
710 \__kernel_primitive:NN \pdflinkmargin \tex_pdflinkmargin:D
711 \__kernel_primitive:NN \pdfliteral \tex_pdfliteral:D
712 \__kernel_primitive:NN \pdfmapfile \tex_pdfmapfile:D
713 \__kernel_primitive:NN \pdfmapline \tex_pdfmapline:D
714 \__kernel_primitive:NN \pdfmajorversion \tex_pdfmajorversion:D
715 \__kernel_primitive:NN \pdfminorversion \tex_pdfminorversion:D
716 \__kernel_primitive:NN \pdfnames \tex_pdfnames:D
717 \__kernel_primitive:NN \pdfnobuiltintounicode \tex_pdfnobuiltintounicode:D
718 \__kernel_primitive:NN \pdfobj \tex_pdfobj:D
719 \__kernel_primitive:NN \pdfobjcompresslevel \tex_pdfobjcompresslevel:D
720 \__kernel_primitive:NN \pdfomitcharset \tex_pdfomitcharset:D
721 \__kernel_primitive:NN \pdfoutline \tex_pdfoutline:D
722 \__kernel_primitive:NN \pdfoutput \tex_pdfoutput:D
723 \__kernel_primitive:NN \pdfpageattr \tex_pdfpageattr:D
724 \__kernel_primitive:NN \pdfpagebox \tex_pdfpagebox:D
725 \__kernel_primitive:NN \pdfpageref \tex_pdfpageref:D
726 \__kernel_primitive:NN \pdfpageresources \tex_pdfpageresources:D
727 \__kernel_primitive:NN \pdfpagesattr \tex_pdfpagesattr:D
728 \__kernel_primitive:NN \pdfptexuseunderscore \tex_pdfptexuseunderscore:D
729 \__kernel_primitive:NN \pdfrefobj \tex_pdfrefobj:D
730 \__kernel_primitive:NN \pdfrefxform \tex_pdfrefxform:D
731 \__kernel_primitive:NN \pdfrefximage \tex_pdfrefximage:D
732 \__kernel_primitive:NN \pdfrestore \tex_pdfrestore:D
733 \__kernel_primitive:NN \pdfretval \tex_pdfretval:D
734 \__kernel_primitive:NN \pdfrunninglinkoff \tex_pdfrunninglinkoff:D
735 \__kernel_primitive:NN \pdfrunninglinkon \tex_pdfrunninglinkon:D
736 \__kernel_primitive:NN \pdfsave \tex_pdfsave:D
737 \__kernel_primitive:NN \pdfsetmatrix \tex_pdfsetmatrix:D
738 \__kernel_primitive:NN \pdfstartlink \tex_pdfstartlink:D
739 \__kernel_primitive:NN \pdfstartthread \tex_pdfstartthread:D
740 \__kernel_primitive:NN \pdfsuppressptexinfo \tex_pdfsuppressptexinfo:D
741 \__kernel_primitive:NN \pdfsuppresswarningdupdest
742 \tex_pdfsuppresswarningdupdest:D
743 \__kernel_primitive:NN \pdfsuppresswarningdupmap
744 \tex_pdfsuppresswarningdupmap:D
745 \__kernel_primitive:NN \pdfsuppresswarningpagegroup
746 \tex_pdfsuppresswarningpagegroup:D
747 \__kernel_primitive:NN \pdfthread \tex_pdfthread:D
748 \__kernel_primitive:NN \pdfthreadmargin \tex_pdfthreadmargin:D
749 \__kernel_primitive:NN \pdftrailer \tex_pdftrailer:D
750 \__kernel_primitive:NN \pdftrailerid \tex_pdftrailerid:D
751 \__kernel_primitive:NN \pdfuniqueresname \tex_pdfuniqueresname:D
752 \__kernel_primitive:NN \pdfvorigin \tex_pdfvorigin:D
753 \__kernel_primitive:NN \pdfxform \tex_pdfxform:D
754 \__kernel_primitive:NN \pdfxformname \tex_pdfxformname:D
755 \__kernel_primitive:NN \pdfximage \tex_pdfximage:D
756 \__kernel_primitive:NN \pdfximagebbox \tex_pdfximagebbox:D
757 \__kernel_primitive:NN \ifpdfabsdim \tex_ifabsdim:D
758 \__kernel_primitive:NN \ifpdfabsnum \tex_ifabsnum:D
759 \__kernel_primitive:NN \ifpdfprimitive \tex_ifprimitive:D
760 \__kernel_primitive:NN \pdfadjustinterwordglue
761 \tex_adjustinterwordglue:D
762 \__kernel_primitive:NN \pdfadjustspacing \tex_adjustspacing:D
763 \__kernel_primitive:NN \pdfappendkern \tex_appendkern:D
764 \__kernel_primitive:NN \pdfcopyfont \tex_copyfont:D
765 \__kernel_primitive:NN \pdfcreationdate \tex_creationdate:D
766 \__kernel_primitive:NN \pdfdraftmode \tex_draftmode:D
767 \__kernel_primitive:NN \pdfeachlinedepth \tex_eachlinedepth:D
768 \__kernel_primitive:NN \pdfeachlineheight \tex_eachlineheight:D
769 \__kernel_primitive:NN \pdfelapsedtime \tex_elapsedtime:D
770 \__kernel_primitive:NN \pdfescapehex \tex_escapehex:D
771 \__kernel_primitive:NN \pdfescapename \tex_escapename:D
772 \__kernel_primitive:NN \pdfescapestring \tex_escapestring:D
773 \__kernel_primitive:NN \pdffirstlineheight \tex_firstlineheight:D
774 \__kernel_primitive:NN \pdffontexpand \tex_fontexpand:D
775 \__kernel_primitive:NN \pdffontsize \tex_fontsize:D
776 \__kernel_primitive:NN \pdfignoreddimen \tex_ignoreddimen:D
777 \__kernel_primitive:NN \pdfinsertht \tex_insertht:D
778 \__kernel_primitive:NN \pdflastlinedepth \tex_lastlinedepth:D
779 \__kernel_primitive:NN \pdflastmatch \tex_lastmatch:D
780 \__kernel_primitive:NN \pdflastxpos \tex_lastxpos:D
781 \__kernel_primitive:NN \pdflastypos \tex_lastypos:D
782 \__kernel_primitive:NN \pdfmatch \tex_match:D
783 \__kernel_primitive:NN \pdfnoligatures \tex_noligatures:D
784 \__kernel_primitive:NN \pdfnormaldeviate \tex_normaldeviate:D
785 \__kernel_primitive:NN \pdfpageheight \tex_pageheight:D
786 \__kernel_primitive:NN \pdfpagewidth \tex_pagewidth:D
787 \__kernel_primitive:NN \pdfpkmode \tex_pkmode:D
788 \__kernel_primitive:NN \pdfpkresolution \tex_pkresolution:D
789 \__kernel_primitive:NN \pdfprimitive \tex_primitive:D
790 \__kernel_primitive:NN \pdfprependkern \tex_prependkern:D
791 \__kernel_primitive:NN \pdfprotrudechars \tex_protrudechars:D
792 \__kernel_primitive:NN \pdfpxdimen \tex_pxdimen:D
793 \__kernel_primitive:NN \pdfrandomseed \tex_randomseed:D
794 \__kernel_primitive:NN \pdfresettimer \tex_resettimer:D
795 \__kernel_primitive:NN \pdfsavepos \tex_savepos:D
796 \__kernel_primitive:NN \pdfsetrandomseed \tex_setrandomseed:D
797 \__kernel_primitive:NN \pdfshellescape \tex_shellescape:D
798 \__kernel_primitive:NN \pdftracingfonts \tex_tracingfonts:D
799 \__kernel_primitive:NN \pdfunescapehex \tex_unescapehex:D
800 \__kernel_primitive:NN \pdfuniformdeviate \tex_uniformdeviate:D
801 \__kernel_primitive:NN \pdftexbanner \tex_pdftexbanner:D
802 \__kernel_primitive:NN \pdftexrevision \tex_pdftexrevision:D
803 \__kernel_primitive:NN \pdftexversion \tex_pdftexversion:D
804 \__kernel_primitive:NN \efcode \tex_efcode:D
805 \__kernel_primitive:NN \ifincsname \tex_ifincsname:D
806 \__kernel_primitive:NN \knaccode \tex_knaccode:D
807 \__kernel_primitive:NN \knbccode \tex_knbccode:D
808 \__kernel_primitive:NN \knbscode \tex_knbscode:D
809 \__kernel_primitive:NN \leftmarginkern \tex_leftmarginkern:D
810 \__kernel_primitive:NN \letterspacefont \tex_letterspacefont:D
811 \__kernel_primitive:NN \lpcode \tex_lpcode:D
812 \__kernel_primitive:NN \quitvmode \tex_quitvmode:D
813 \__kernel_primitive:NN \rightmarginkern \tex_rightmarginkern:D
814 \__kernel_primitive:NN \rpcode \tex_rpcode:D
815 \__kernel_primitive:NN \shbscode \tex_shbscode:D
816 \__kernel_primitive:NN \stbscode \tex_stbscode:D
817 \__kernel_primitive:NN \synctex \tex_synctex:D
818 \__kernel_primitive:NN \tagcode \tex_tagcode:D
819 \tex_long:D \tex_def:D \use_ii:nn #1#2 {#2}
820 \tex_long:D \tex_def:D \use_none:n #1 { }
821 \tex_long:D \tex_def:D \__kernel_primitive:NN #1#2
822 {
823 \tex_ifdefined:D #1
824 \tex_expandafter:D \use_ii:nn
825 \tex_fi:D
826 \use_none:n { \tex_global:D \tex_let:D #2 #1 }
827 }
828 \__kernel_primitive:NN \pdfstrcmp \tex_strcmp:D
829 \__kernel_primitive:NN \pdffilesize \tex_filesize:D
830 \__kernel_primitive:NN \pdfmdfivesum \tex_mdfivesum:D
831 \__kernel_primitive:NN \pdffilemoddate \tex_filemoddate:D
832 \__kernel_primitive:NN \pdffiledump \tex_filedump:D
833 \__kernel_primitive:NN \suppressfontnotfounderror
834 \tex_suppressfontnotfounderror:D
835 \__kernel_primitive:NN \XeTeXcharclass \tex_XeTeXcharclass:D
836 \__kernel_primitive:NN \XeTeXcharglyph \tex_XeTeXcharglyph:D
837 \__kernel_primitive:NN \XeTeXcountfeatures \tex_XeTeXcountfeatures:D
838 \__kernel_primitive:NN \XeTeXcountglyphs \tex_XeTeXcountglyphs:D
839 \__kernel_primitive:NN \XeTeXcountselectors \tex_XeTeXcountselectors:D
840 \__kernel_primitive:NN \XeTeXcountvariations \tex_XeTeXcountvariations:D
841 \__kernel_primitive:NN \XeTeXdefaultencoding \tex_XeTeXdefaultencoding:D
842 \__kernel_primitive:NN \XeTeXdashbreakstate \tex_XeTeXdashbreakstate:D
843 \__kernel_primitive:NN \XeTeXfeaturecode \tex_XeTeXfeaturecode:D
844 \__kernel_primitive:NN \XeTeXfeaturename \tex_XeTeXfeaturename:D
845 \__kernel_primitive:NN \XeTeXfindfeaturebyname
846 \tex_XeTeXfindfeaturebyname:D
847 \__kernel_primitive:NN \XeTeXfindselectorbyname
848 \tex_XeTeXfindselectorbyname:D
849 \__kernel_primitive:NN \XeTeXfindvariationbyname
850 \tex_XeTeXfindvariationbyname:D
851 \__kernel_primitive:NN \XeTeXfirstfontchar \tex_XeTeXfirstfontchar:D
852 \__kernel_primitive:NN \XeTeXfonttype \tex_XeTeXfonttype:D
853 \__kernel_primitive:NN \XeTeXgenerateactualtext
854 \tex_XeTeXgenerateactualtext:D
855 \__kernel_primitive:NN \XeTeXglyph \tex_XeTeXglyph:D
856 \__kernel_primitive:NN \XeTeXglyphbounds \tex_XeTeXglyphbounds:D
857 \__kernel_primitive:NN \XeTeXglyphindex \tex_XeTeXglyphindex:D
858 \__kernel_primitive:NN \XeTeXglyphname \tex_XeTeXglyphname:D
859 \__kernel_primitive:NN \XeTeXinputencoding \tex_XeTeXinputencoding:D
860 \__kernel_primitive:NN \XeTeXinputnormalization
861 \tex_XeTeXinputnormalization:D
862 \__kernel_primitive:NN \XeTeXinterchartokenstate
863 \tex_XeTeXinterchartokenstate:D
864 \__kernel_primitive:NN \XeTeXinterchartoks \tex_XeTeXinterchartoks:D
865 \__kernel_primitive:NN \XeTeXisdefaultselector
866 \tex_XeTeXisdefaultselector:D
867 \__kernel_primitive:NN \XeTeXisexclusivefeature
868 \tex_XeTeXisexclusivefeature:D
869 \__kernel_primitive:NN \XeTeXlastfontchar \tex_XeTeXlastfontchar:D
870 \__kernel_primitive:NN \XeTeXlinebreakskip \tex_XeTeXlinebreakskip:D
871 \__kernel_primitive:NN \XeTeXlinebreaklocale \tex_XeTeXlinebreaklocale:D
872 \__kernel_primitive:NN \XeTeXlinebreakpenalty \tex_XeTeXlinebreakpenalty:D
873 \__kernel_primitive:NN \XeTeXOTcountfeatures \tex_XeTeXOTcountfeatures:D
874 \__kernel_primitive:NN \XeTeXOTcountlanguages \tex_XeTeXOTcountlanguages:D
875 \__kernel_primitive:NN \XeTeXOTcountscripts \tex_XeTeXOTcountscripts:D
876 \__kernel_primitive:NN \XeTeXOTfeaturetag \tex_XeTeXOTfeaturetag:D
877 \__kernel_primitive:NN \XeTeXOTlanguagetag \tex_XeTeXOTlanguagetag:D
878 \__kernel_primitive:NN \XeTeXOTscripttag \tex_XeTeXOTscripttag:D
879 \__kernel_primitive:NN \XeTeXpdffile \tex_XeTeXpdffile:D
880 \__kernel_primitive:NN \XeTeXpdfpagecount \tex_XeTeXpdfpagecount:D
881 \__kernel_primitive:NN \XeTeXpicfile \tex_XeTeXpicfile:D
882 \__kernel_primitive:NN \XeTeXrevision \tex_XeTeXrevision:D
883 \__kernel_primitive:NN \XeTeXselectorname \tex_XeTeXselectorname:D
884 \__kernel_primitive:NN \XeTeXtracingfonts \tex_XeTeXtracingfonts:D
885 \__kernel_primitive:NN \XeTeXupwardsmode \tex_XeTeXupwardsmode:D
886 \__kernel_primitive:NN \XeTeXuseglyphmetrics \tex_XeTeXuseglyphmetrics:D
887 \__kernel_primitive:NN \XeTeXvariation \tex_XeTeXvariation:D
888 \__kernel_primitive:NN \XeTeXvariationdefault \tex_XeTeXvariationdefault:D
889 \__kernel_primitive:NN \XeTeXvariationmax \tex_XeTeXvariationmax:D
890 \__kernel_primitive:NN \XeTeXvariationmin \tex_XeTeXvariationmin:D
891 \__kernel_primitive:NN \XeTeXvariationname \tex_XeTeXvariationname:D
892 \__kernel_primitive:NN \XeTeXversion \tex_XeTeXversion:D
893 \__kernel_primitive:NN \XeTeXselectorcode \tex_XeTeXselectorcode:D
894 \__kernel_primitive:NN \XeTeXinterwordspaceshaping
895 \tex_XeTeXinterwordspaceshaping:D
896 \__kernel_primitive:NN \XeTeXhyphenatablelength
897 \tex_XeTeXhyphenatablelength:D
898 \__kernel_primitive:NN \creationdate \tex_creationdate:D
899 \__kernel_primitive:NN \elapsedtime \tex_elapsedtime:D
900 \__kernel_primitive:NN \filedump \tex_filedump:D
901 \__kernel_primitive:NN \filemoddate \tex_filemoddate:D
902 \__kernel_primitive:NN \filesize \tex_filesize:D
903 \__kernel_primitive:NN \mdfivesum \tex_mdfivesum:D
904 \__kernel_primitive:NN \ifprimitive \tex_ifprimitive:D
905 \__kernel_primitive:NN \primitive \tex_primitive:D
906 \__kernel_primitive:NN \resettimer \tex_resettimer:D
907 \__kernel_primitive:NN \shellescape \tex_shellescape:D
908 \__kernel_primitive:NN \XeTeXprotrudechars \tex_protrudechars:D
909 \__kernel_primitive:NN \alignmark \tex_alignmark:D
910 \__kernel_primitive:NN \aligntab \tex_aligntab:D
911 \__kernel_primitive:NN \attribute \tex_attribute:D
912 \__kernel_primitive:NN \attributedef \tex_attributedef:D
913 \__kernel_primitive:NN \automaticdiscretionary
914 \tex_automaticdiscretionary:D
915 \__kernel_primitive:NN \automatichyphenmode \tex_automatichyphenmode:D
916 \__kernel_primitive:NN \automatichyphenpenalty
917 \tex_automatichyphenpenalty:D
918 \__kernel_primitive:NN \begincsname \tex_begincsname:D
919 \__kernel_primitive:NN \bodydir \tex_bodydir:D
920 \__kernel_primitive:NN \bodydirection \tex_bodydirection:D
921 \__kernel_primitive:NN \boundary \tex_boundary:D
922 \__kernel_primitive:NN \boxdir \tex_boxdir:D
923 \__kernel_primitive:NN \boxdirection \tex_boxdirection:D
924 \__kernel_primitive:NN \breakafterdirmode \tex_breakafterdirmode:D
925 \__kernel_primitive:NN \catcodetable \tex_catcodetable:D
926 \__kernel_primitive:NN \clearmarks \tex_clearmarks:D
927 \__kernel_primitive:NN \crampeddisplaystyle \tex_crampeddisplaystyle:D
928 \__kernel_primitive:NN \crampedscriptscriptstyle
929 \tex_crampedscriptscriptstyle:D
930 \__kernel_primitive:NN \crampedscriptstyle \tex_crampedscriptstyle:D
931 \__kernel_primitive:NN \crampedtextstyle \tex_crampedtextstyle:D
932 \__kernel_primitive:NN \csstring \tex_csstring:D
933 \__kernel_primitive:NN \deferred \tex_deferred:D
934 \__kernel_primitive:NN \discretionaryligaturemode
935 \tex_discretionaryligaturemode:D
936 \__kernel_primitive:NN \directlua \tex_directlua:D
937 \__kernel_primitive:NN \dviextension \tex_dviextension:D
938 \__kernel_primitive:NN \dvifeedback \tex_dvifeedback:D
939 \__kernel_primitive:NN \dvivariable \tex_dvivariable:D
940 \__kernel_primitive:NN \eTeXglueshrinkorder \tex_eTeXglueshrinkorder:D
941 \__kernel_primitive:NN \eTeXgluestretchorder \tex_eTeXgluestretchorder:D
942 \__kernel_primitive:NN \endlocalcontrol \tex_endlocalcontrol:D
943 \__kernel_primitive:NN \etoksapp \tex_etoksapp:D
944 \__kernel_primitive:NN \etokspre \tex_etokspre:D
945 \__kernel_primitive:NN \exceptionpenalty \tex_exceptionpenalty:D
946 \__kernel_primitive:NN \exhyphenchar \tex_exhyphenchar:D
947 \__kernel_primitive:NN \explicithyphenpenalty \tex_explicithyphenpenalty:D
948 \__kernel_primitive:NN \expanded \tex_expanded:D
949 \__kernel_primitive:NN \explicitdiscretionary \tex_explicitdiscretionary:D
950 \__kernel_primitive:NN \firstvalidlanguage \tex_firstvalidlanguage:D
951 \__kernel_primitive:NN \fontid \tex_fontid:D
952 \__kernel_primitive:NN \formatname \tex_formatname:D
953 \__kernel_primitive:NN \hjcode \tex_hjcode:D
954 \__kernel_primitive:NN \hpack \tex_hpack:D
955 \__kernel_primitive:NN \hyphenationbounds \tex_hyphenationbounds:D
956 \__kernel_primitive:NN \hyphenationmin \tex_hyphenationmin:D
957 \__kernel_primitive:NN \hyphenpenaltymode \tex_hyphenpenaltymode:D
958 \__kernel_primitive:NN \gleaders \tex_gleaders:D
959 \__kernel_primitive:NN \glet \tex_glet:D
960 \__kernel_primitive:NN \glyphdimensionsmode \tex_glyphdimensionsmode:D
961 \__kernel_primitive:NN \gtoksapp \tex_gtoksapp:D
962 \__kernel_primitive:NN \gtokspre \tex_gtokspre:D
963 \__kernel_primitive:NN \ifcondition \tex_ifcondition:D
964 \__kernel_primitive:NN \immediateassigned \tex_immediateassigned:D
965 \__kernel_primitive:NN \immediateassignment \tex_immediateassignment:D
966 \__kernel_primitive:NN \initcatcodetable \tex_initcatcodetable:D
967 \__kernel_primitive:NN \lastnamedcs \tex_lastnamedcs:D
968 \__kernel_primitive:NN \latelua \tex_latelua:D
969 \__kernel_primitive:NN \lateluafunction \tex_lateluafunction:D
970 \__kernel_primitive:NN \leftghost \tex_leftghost:D
971 \__kernel_primitive:NN \letcharcode \tex_letcharcode:D
972 \__kernel_primitive:NN \linedir \tex_linedir:D
973 \__kernel_primitive:NN \linedirection \tex_linedirection:D
974 \__kernel_primitive:NN \localbrokenpenalty \tex_localbrokenpenalty:D
975 \__kernel_primitive:NN \localinterlinepenalty \tex_localinterlinepenalty:D
976 \__kernel_primitive:NN \luabytecode \tex_luabytecode:D
977 \__kernel_primitive:NN \luabytecodecall \tex_luabytecodecall:D
978 \__kernel_primitive:NN \luacopyinputnodes \tex_luacopyinputnodes:D
979 \__kernel_primitive:NN \luadef \tex_luadef:D
980 \__kernel_primitive:NN \localleftbox \tex_localleftbox:D
981 \__kernel_primitive:NN \localrightbox \tex_localrightbox:D
982 \__kernel_primitive:NN \luaescapestring \tex_luaescapestring:D
983 \__kernel_primitive:NN \luafunction \tex_luafunction:D
984 \__kernel_primitive:NN \luafunctioncall \tex_luafunctioncall:D
985 \__kernel_primitive:NN \luatexbanner \tex_luatexbanner:D
986 \__kernel_primitive:NN \luatexrevision \tex_luatexrevision:D
987 \__kernel_primitive:NN \luatexversion \tex_luatexversion:D
988 \__kernel_primitive:NN \mathdefaultsmode \tex_mathdefaultsmode:D
989 \__kernel_primitive:NN \mathdelimitersmode \tex_mathdelimitersmode:D
990 \__kernel_primitive:NN \mathdir \tex_mathdir:D
991 \__kernel_primitive:NN \mathdirection \tex_mathdirection:D
992 \__kernel_primitive:NN \mathdisplayskipmode \tex_mathdisplayskipmode:D
993 \__kernel_primitive:NN \matheqdirmode \tex_matheqdirmode:D
994 \__kernel_primitive:NN \matheqnogapstep \tex_matheqnogapstep:D
995 \__kernel_primitive:NN \mathemptydisplaymode \tex_mathemptydisplaymode:D
996 \__kernel_primitive:NN \mathflattenmode \tex_mathflattenmode:D
997 \__kernel_primitive:NN \mathitalicsmode \tex_mathitalicsmode:D
998 \__kernel_primitive:NN \mathnolimitsmode \tex_mathnolimitsmode:D
999 \__kernel_primitive:NN \mathoption \tex_mathoption:D
1000 \__kernel_primitive:NN \mathpenaltiesmode \tex_mathpenaltiesmode:D
1001 \__kernel_primitive:NN \mathrulesfam \tex_mathrulesfam:D
1002 \__kernel_primitive:NN \mathscriptsmode \tex_mathscriptsmode:D
1003 \__kernel_primitive:NN \mathscriptboxmode \tex_mathscriptboxmode:D
1004 \__kernel_primitive:NN \mathscriptcharmode \tex_mathscriptcharmode:D
1005 \__kernel_primitive:NN \mathstyle \tex_mathstyle:D
1006 \__kernel_primitive:NN \mathsurroundmode \tex_mathsurroundmode:D
1007 \__kernel_primitive:NN \mathsurroundskip \tex_mathsurroundskip:D
1008 \__kernel_primitive:NN \nohrule \tex_nohrule:D
1009 \__kernel_primitive:NN \nokerns \tex_nokerns:D
1010 \__kernel_primitive:NN \noligs \tex_noligs:D
1011 \__kernel_primitive:NN \nospaces \tex_nospaces:D
1012 \__kernel_primitive:NN \novrule \tex_novrule:D
1013 \__kernel_primitive:NN \outputbox \tex_outputbox:D
1014 \__kernel_primitive:NN \pagebottomoffset \tex_pagebottomoffset:D
1015 \__kernel_primitive:NN \pagedir \tex_pagedir:D
1016 \__kernel_primitive:NN \pagedirection \tex_pagedirection:D
1017 \__kernel_primitive:NN \pageleftoffset \tex_pageleftoffset:D
1018 \__kernel_primitive:NN \pagerightoffset \tex_pagerightoffset:D
1019 \__kernel_primitive:NN \pagetopoffset \tex_pagetopoffset:D
1020 \__kernel_primitive:NN \pardir \tex_pardir:D
1021 \__kernel_primitive:NN \pardirection \tex_pardirection:D
1022 \__kernel_primitive:NN \pdfextension \tex_pdfextension:D
1023 \__kernel_primitive:NN \pdffeedback \tex_pdffeedback:D
1024 \__kernel_primitive:NN \pdfvariable \tex_pdfvariable:D
1025 \__kernel_primitive:NN \postexhyphenchar \tex_postexhyphenchar:D
1026 \__kernel_primitive:NN \posthyphenchar \tex_posthyphenchar:D
1027 \__kernel_primitive:NN \prebinoppenalty \tex_prebinoppenalty:D
1028 \__kernel_primitive:NN \predisplaygapfactor \tex_predisplaygapfactor:D
1029 \__kernel_primitive:NN \preexhyphenchar \tex_preexhyphenchar:D
1030 \__kernel_primitive:NN \prehyphenchar \tex_prehyphenchar:D
1031 \__kernel_primitive:NN \prerelpenalty \tex_prerelpenalty:D
1032 \__kernel_primitive:NN \protrusionboundary \tex_protrusionboundary:D
1033 \__kernel_primitive:NN \rightghost \tex_rightghost:D
1034 \__kernel_primitive:NN \savecatcodetable \tex_savecatcodetable:D
1035 \__kernel_primitive:NN \scantextokens \tex_scantextokens:D
1036 \__kernel_primitive:NN \setfontid \tex_setfontid:D
1037 \__kernel_primitive:NN \shapemode \tex_shapemode:D
1038 \__kernel_primitive:NN \suppressifcsnameerror \tex_suppressifcsnameerror:D
1039 \__kernel_primitive:NN \suppresslongerror \tex_suppresslongerror:D
1040 \__kernel_primitive:NN \suppressmathparerror \tex_suppressmathparerror:D
1041 \__kernel_primitive:NN \suppressoutererror \tex_suppressoutererror:D
1042 \__kernel_primitive:NN \suppressprimitiveerror
1043 \tex_suppressprimitiveerror:D
1044 \__kernel_primitive:NN \textdir \tex_textdir:D
1045 \__kernel_primitive:NN \textdirection \tex_textdirection:D
1046 \__kernel_primitive:NN \toksapp \tex_toksapp:D
1047 \__kernel_primitive:NN \tokspre \tex_tokspre:D
1048 \__kernel_primitive:NN \tpack \tex_tpack:D
1049 \__kernel_primitive:NN \variablefam \tex_variablefam:D
1050 \__kernel_primitive:NN \vpack \tex_vpack:D
1051 \__kernel_primitive:NN \wordboundary \tex_wordboundary:D
1052 \__kernel_primitive:NN \xtoksapp \tex_xtoksapp:D
1053 \__kernel_primitive:NN \xtokspre \tex_xtokspre:D
1054 \__kernel_primitive:NN \adjustspacing \tex_adjustspacing:D
1055 \__kernel_primitive:NN \copyfont \tex_copyfont:D
1056 \__kernel_primitive:NN \draftmode \tex_draftmode:D
1057 \__kernel_primitive:NN \expandglyphsinfont \tex_fontexpand:D
1058 \__kernel_primitive:NN \ifabsdim \tex_ifabsdim:D
1059 \__kernel_primitive:NN \ifabsnum \tex_ifabsnum:D
1060 \__kernel_primitive:NN \ignoreligaturesinfont \tex_ignoreligaturesinfont:D
1061 \__kernel_primitive:NN \insertht \tex_insertht:D
1062 \__kernel_primitive:NN \lastsavedboxresourceindex
1063 \tex_pdflastxform:D
1064 \__kernel_primitive:NN \lastsavedimageresourceindex
1065 \tex_pdflastximage:D
1066 \__kernel_primitive:NN \lastsavedimageresourcepages
1067 \tex_pdflastximagepages:D
1068 \__kernel_primitive:NN \lastxpos \tex_lastxpos:D
1069 \__kernel_primitive:NN \lastypos \tex_lastypos:D
1070 \__kernel_primitive:NN \normaldeviate \tex_normaldeviate:D
1071 \__kernel_primitive:NN \outputmode \tex_pdfoutput:D
1072 \__kernel_primitive:NN \pageheight \tex_pageheight:D
1073 \__kernel_primitive:NN \pagewidth \tex_pagewidth:D
1074 \__kernel_primitive:NN \protrudechars \tex_protrudechars:D
1075 \__kernel_primitive:NN \pxdimen \tex_pxdimen:D
1076 \__kernel_primitive:NN \randomseed \tex_randomseed:D
1077 \__kernel_primitive:NN \useboxresource \tex_pdfrefxform:D
1078 \__kernel_primitive:NN \useimageresource \tex_pdfrefximage:D
1079 \__kernel_primitive:NN \savepos \tex_savepos:D
1080 \__kernel_primitive:NN \saveboxresource \tex_pdfxform:D
1081 \__kernel_primitive:NN \saveimageresource \tex_pdfximage:D
1082 \__kernel_primitive:NN \setrandomseed \tex_setrandomseed:D
1083 \__kernel_primitive:NN \tracingfonts \tex_tracingfonts:D
1084 \__kernel_primitive:NN \uniformdeviate \tex_uniformdeviate:D
1085 \__kernel_primitive:NN \Uchar \tex_Uchar:D
1086 \__kernel_primitive:NN \Ucharcat \tex_Ucharcat:D
1087 \__kernel_primitive:NN \Udelcode \tex_Udelcode:D
1088 \__kernel_primitive:NN \Udelcodenum \tex_Udelcodenum:D
1089 \__kernel_primitive:NN \Udelimiter \tex_Udelimiter:D
1090 \__kernel_primitive:NN \Udelimiterover \tex_Udelimiterover:D
1091 \__kernel_primitive:NN \Udelimiterunder \tex_Udelimiterunder:D
1092 \__kernel_primitive:NN \Uhextensible \tex_Uhextensible:D
1093 \__kernel_primitive:NN \Uleft \tex_Uleft:D
1094 \__kernel_primitive:NN \Umathaccent \tex_Umathaccent:D
1095 \__kernel_primitive:NN \Umathaxis \tex_Umathaxis:D
1096 \__kernel_primitive:NN \Umathbinbinspacing \tex_Umathbinbinspacing:D
1097 \__kernel_primitive:NN \Umathbinclosespacing \tex_Umathbinclosespacing:D
1098 \__kernel_primitive:NN \Umathbininnerspacing \tex_Umathbininnerspacing:D
1099 \__kernel_primitive:NN \Umathbinopenspacing \tex_Umathbinopenspacing:D
1100 \__kernel_primitive:NN \Umathbinopspacing \tex_Umathbinopspacing:D
1101 \__kernel_primitive:NN \Umathbinordspacing \tex_Umathbinordspacing:D
1102 \__kernel_primitive:NN \Umathbinpunctspacing \tex_Umathbinpunctspacing:D
1103 \__kernel_primitive:NN \Umathbinrelspacing \tex_Umathbinrelspacing:D
1104 \__kernel_primitive:NN \Umathchar \tex_Umathchar:D
1105 \__kernel_primitive:NN \Umathcharclass \tex_Umathcharclass:D
1106 \__kernel_primitive:NN \Umathchardef \tex_Umathchardef:D
1107 \__kernel_primitive:NN \Umathcharfam \tex_Umathcharfam:D
1108 \__kernel_primitive:NN \Umathcharnum \tex_Umathcharnum:D
1109 \__kernel_primitive:NN \Umathcharnumdef \tex_Umathcharnumdef:D
1110 \__kernel_primitive:NN \Umathcharslot \tex_Umathcharslot:D
1111 \__kernel_primitive:NN \Umathclosebinspacing \tex_Umathclosebinspacing:D
1112 \__kernel_primitive:NN \Umathcloseclosespacing
1113 \tex_Umathcloseclosespacing:D
1114 \__kernel_primitive:NN \Umathcloseinnerspacing
1115 \tex_Umathcloseinnerspacing:D
1116 \__kernel_primitive:NN \Umathcloseopenspacing \tex_Umathcloseopenspacing:D
1117 \__kernel_primitive:NN \Umathcloseopspacing \tex_Umathcloseopspacing:D
1118 \__kernel_primitive:NN \Umathcloseordspacing \tex_Umathcloseordspacing:D
1119 \__kernel_primitive:NN \Umathclosepunctspacing
1120 \tex_Umathclosepunctspacing:D
1121 \__kernel_primitive:NN \Umathcloserelspacing \tex_Umathcloserelspacing:D
1122 \__kernel_primitive:NN \Umathcode \tex_Umathcode:D
1123 \__kernel_primitive:NN \Umathcodenum \tex_Umathcodenum:D
1124 \__kernel_primitive:NN \Umathconnectoroverlapmin
1125 \tex_Umathconnectoroverlapmin:D
1126 \__kernel_primitive:NN \Umathfractiondelsize \tex_Umathfractiondelsize:D
1127 \__kernel_primitive:NN \Umathfractiondenomdown
1128 \tex_Umathfractiondenomdown:D
1129 \__kernel_primitive:NN \Umathfractiondenomvgap
1130 \tex_Umathfractiondenomvgap:D
1131 \__kernel_primitive:NN \Umathfractionnumup \tex_Umathfractionnumup:D
1132 \__kernel_primitive:NN \Umathfractionnumvgap \tex_Umathfractionnumvgap:D
1133 \__kernel_primitive:NN \Umathfractionrule \tex_Umathfractionrule:D
1134 \__kernel_primitive:NN \Umathinnerbinspacing \tex_Umathinnerbinspacing:D
1135 \__kernel_primitive:NN \Umathinnerclosespacing
1136 \tex_Umathinnerclosespacing:D
1137 \__kernel_primitive:NN \Umathinnerinnerspacing
1138 \tex_Umathinnerinnerspacing:D
1139 \__kernel_primitive:NN \Umathinneropenspacing \tex_Umathinneropenspacing:D
1140 \__kernel_primitive:NN \Umathinneropspacing \tex_Umathinneropspacing:D
1141 \__kernel_primitive:NN \Umathinnerordspacing \tex_Umathinnerordspacing:D
1142 \__kernel_primitive:NN \Umathinnerpunctspacing
1143 \tex_Umathinnerpunctspacing:D
1144 \__kernel_primitive:NN \Umathinnerrelspacing \tex_Umathinnerrelspacing:D
1145 \__kernel_primitive:NN \Umathlimitabovebgap \tex_Umathlimitabovebgap:D
1146 \__kernel_primitive:NN \Umathlimitabovekern \tex_Umathlimitabovekern:D
1147 \__kernel_primitive:NN \Umathlimitabovevgap \tex_Umathlimitabovevgap:D
1148 \__kernel_primitive:NN \Umathlimitbelowbgap \tex_Umathlimitbelowbgap:D
1149 \__kernel_primitive:NN \Umathlimitbelowkern \tex_Umathlimitbelowkern:D
1150 \__kernel_primitive:NN \Umathlimitbelowvgap \tex_Umathlimitbelowvgap:D
1151 \__kernel_primitive:NN \Umathnolimitsubfactor \tex_Umathnolimitsubfactor:D
1152 \__kernel_primitive:NN \Umathnolimitsupfactor \tex_Umathnolimitsupfactor:D
1153 \__kernel_primitive:NN \Umathopbinspacing \tex_Umathopbinspacing:D
1154 \__kernel_primitive:NN \Umathopclosespacing \tex_Umathopclosespacing:D
1155 \__kernel_primitive:NN \Umathopenbinspacing \tex_Umathopenbinspacing:D
1156 \__kernel_primitive:NN \Umathopenclosespacing \tex_Umathopenclosespacing:D
1157 \__kernel_primitive:NN \Umathopeninnerspacing \tex_Umathopeninnerspacing:D
1158 \__kernel_primitive:NN \Umathopenopenspacing \tex_Umathopenopenspacing:D
1159 \__kernel_primitive:NN \Umathopenopspacing \tex_Umathopenopspacing:D
1160 \__kernel_primitive:NN \Umathopenordspacing \tex_Umathopenordspacing:D
1161 \__kernel_primitive:NN \Umathopenpunctspacing \tex_Umathopenpunctspacing:D
1162 \__kernel_primitive:NN \Umathopenrelspacing \tex_Umathopenrelspacing:D
1163 \__kernel_primitive:NN \Umathoperatorsize \tex_Umathoperatorsize:D
1164 \__kernel_primitive:NN \Umathopinnerspacing \tex_Umathopinnerspacing:D
1165 \__kernel_primitive:NN \Umathopopenspacing \tex_Umathopopenspacing:D
1166 \__kernel_primitive:NN \Umathopopspacing \tex_Umathopopspacing:D
1167 \__kernel_primitive:NN \Umathopordspacing \tex_Umathopordspacing:D
1168 \__kernel_primitive:NN \Umathoppunctspacing \tex_Umathoppunctspacing:D
1169 \__kernel_primitive:NN \Umathoprelspacing \tex_Umathoprelspacing:D
1170 \__kernel_primitive:NN \Umathordbinspacing \tex_Umathordbinspacing:D
1171 \__kernel_primitive:NN \Umathordclosespacing \tex_Umathordclosespacing:D
1172 \__kernel_primitive:NN \Umathordinnerspacing \tex_Umathordinnerspacing:D
1173 \__kernel_primitive:NN \Umathordopenspacing \tex_Umathordopenspacing:D
1174 \__kernel_primitive:NN \Umathordopspacing \tex_Umathordopspacing:D
1175 \__kernel_primitive:NN \Umathordordspacing \tex_Umathordordspacing:D
1176 \__kernel_primitive:NN \Umathordpunctspacing \tex_Umathordpunctspacing:D
1177 \__kernel_primitive:NN \Umathordrelspacing \tex_Umathordrelspacing:D
1178 \__kernel_primitive:NN \Umathoverbarkern \tex_Umathoverbarkern:D
1179 \__kernel_primitive:NN \Umathoverbarrule \tex_Umathoverbarrule:D
1180 \__kernel_primitive:NN \Umathoverbarvgap \tex_Umathoverbarvgap:D
1181 \__kernel_primitive:NN \Umathoverdelimiterbgap
1182 \tex_Umathoverdelimiterbgap:D
1183 \__kernel_primitive:NN \Umathoverdelimitervgap
1184 \tex_Umathoverdelimitervgap:D
1185 \__kernel_primitive:NN \Umathpunctbinspacing \tex_Umathpunctbinspacing:D
1186 \__kernel_primitive:NN \Umathpunctclosespacing
1187 \tex_Umathpunctclosespacing:D
1188 \__kernel_primitive:NN \Umathpunctinnerspacing
1189 \tex_Umathpunctinnerspacing:D
1190 \__kernel_primitive:NN \Umathpunctopenspacing \tex_Umathpunctopenspacing:D
1191 \__kernel_primitive:NN \Umathpunctopspacing \tex_Umathpunctopspacing:D
1192 \__kernel_primitive:NN \Umathpunctordspacing \tex_Umathpunctordspacing:D
1193 \__kernel_primitive:NN \Umathpunctpunctspacing
1194 \tex_Umathpunctpunctspacing:D
1195 \__kernel_primitive:NN \Umathpunctrelspacing \tex_Umathpunctrelspacing:D
1196 \__kernel_primitive:NN \Umathquad \tex_Umathquad:D
1197 \__kernel_primitive:NN \Umathradicaldegreeafter
1198 \tex_Umathradicaldegreeafter:D
1199 \__kernel_primitive:NN \Umathradicaldegreebefore
1200 \tex_Umathradicaldegreebefore:D
1201 \__kernel_primitive:NN \Umathradicaldegreeraise
1202 \tex_Umathradicaldegreeraise:D
1203 \__kernel_primitive:NN \Umathradicalkern \tex_Umathradicalkern:D
1204 \__kernel_primitive:NN \Umathradicalrule \tex_Umathradicalrule:D
1205 \__kernel_primitive:NN \Umathradicalvgap \tex_Umathradicalvgap:D
1206 \__kernel_primitive:NN \Umathrelbinspacing \tex_Umathrelbinspacing:D
1207 \__kernel_primitive:NN \Umathrelclosespacing \tex_Umathrelclosespacing:D
1208 \__kernel_primitive:NN \Umathrelinnerspacing \tex_Umathrelinnerspacing:D
1209 \__kernel_primitive:NN \Umathrelopenspacing \tex_Umathrelopenspacing:D
1210 \__kernel_primitive:NN \Umathrelopspacing \tex_Umathrelopspacing:D
1211 \__kernel_primitive:NN \Umathrelordspacing \tex_Umathrelordspacing:D
1212 \__kernel_primitive:NN \Umathrelpunctspacing \tex_Umathrelpunctspacing:D
1213 \__kernel_primitive:NN \Umathrelrelspacing \tex_Umathrelrelspacing:D
1214 \__kernel_primitive:NN \Umathskewedfractionhgap
1215 \tex_Umathskewedfractionhgap:D
1216 \__kernel_primitive:NN \Umathskewedfractionvgap
1217 \tex_Umathskewedfractionvgap:D
1218 \__kernel_primitive:NN \Umathspaceafterscript \tex_Umathspaceafterscript:D
1219 \__kernel_primitive:NN \Umathstackdenomdown \tex_Umathstackdenomdown:D
1220 \__kernel_primitive:NN \Umathstacknumup \tex_Umathstacknumup:D
1221 \__kernel_primitive:NN \Umathstackvgap \tex_Umathstackvgap:D
1222 \__kernel_primitive:NN \Umathsubshiftdown \tex_Umathsubshiftdown:D
1223 \__kernel_primitive:NN \Umathsubshiftdrop \tex_Umathsubshiftdrop:D
1224 \__kernel_primitive:NN \Umathsubsupshiftdown \tex_Umathsubsupshiftdown:D
1225 \__kernel_primitive:NN \Umathsubsupvgap \tex_Umathsubsupvgap:D
1226 \__kernel_primitive:NN \Umathsubtopmax \tex_Umathsubtopmax:D
1227 \__kernel_primitive:NN \Umathsupbottommin \tex_Umathsupbottommin:D
1228 \__kernel_primitive:NN \Umathsupshiftdrop \tex_Umathsupshiftdrop:D
1229 \__kernel_primitive:NN \Umathsupshiftup \tex_Umathsupshiftup:D
1230 \__kernel_primitive:NN \Umathsupsubbottommax \tex_Umathsupsubbottommax:D
1231 \__kernel_primitive:NN \Umathunderbarkern \tex_Umathunderbarkern:D
1232 \__kernel_primitive:NN \Umathunderbarrule \tex_Umathunderbarrule:D
1233 \__kernel_primitive:NN \Umathunderbarvgap \tex_Umathunderbarvgap:D
1234 \__kernel_primitive:NN \Umathunderdelimiterbgap
1235 \tex_Umathunderdelimiterbgap:D
1236 \__kernel_primitive:NN \Umathunderdelimitervgap
1237 \tex_Umathunderdelimitervgap:D
1238 \__kernel_primitive:NN \Umiddle \tex_Umiddle:D
1239 \__kernel_primitive:NN \Unosubscript \tex_Unosubscript:D
1240 \__kernel_primitive:NN \Unosuperscript \tex_Unosuperscript:D
1241 \__kernel_primitive:NN \Uoverdelimiter \tex_Uoverdelimiter:D
1242 \__kernel_primitive:NN \Uradical \tex_Uradical:D
1243 \__kernel_primitive:NN \Uright \tex_Uright:D
1244 \__kernel_primitive:NN \Uroot \tex_Uroot:D
1245 \__kernel_primitive:NN \Uskewed \tex_Uskewed:D
1246 \__kernel_primitive:NN \Uskewedwithdelims \tex_Uskewedwithdelims:D
1247 \__kernel_primitive:NN \Ustack \tex_Ustack:D
1248 \__kernel_primitive:NN \Ustartdisplaymath \tex_Ustartdisplaymath:D
1249 \__kernel_primitive:NN \Ustartmath \tex_Ustartmath:D
1250 \__kernel_primitive:NN \Ustopdisplaymath \tex_Ustopdisplaymath:D
1251 \__kernel_primitive:NN \Ustopmath \tex_Ustopmath:D
1252 \__kernel_primitive:NN \Usubscript \tex_Usubscript:D
1253 \__kernel_primitive:NN \Usuperscript \tex_Usuperscript:D
1254 \__kernel_primitive:NN \Uunderdelimiter \tex_Uunderdelimiter:D
1255 \__kernel_primitive:NN \Uvextensible \tex_Uvextensible:D
1256 \__kernel_primitive:NN \autospacing \tex_autospacing:D
1257 \__kernel_primitive:NN \autoxspacing \tex_autoxspacing:D
1258 \__kernel_primitive:NN \currentcjktoken \tex_currentcjktoken:D
1259 \__kernel_primitive:NN \currentspacingmode \tex_currentspacingmode:D
1260 \__kernel_primitive:NN \currentxspacingmode \tex_currentxspacingmode:D
1261 \__kernel_primitive:NN \disinhibitglue \tex_disinhibitglue:D
1262 \__kernel_primitive:NN \dtou \tex_dtou:D
1263 \__kernel_primitive:NN \epTeXinputencoding \tex_epTeXinputencoding:D
1264 \__kernel_primitive:NN \epTeXversion \tex_epTeXversion:D
1265 \__kernel_primitive:NN \euc \tex_euc:D
1266 \__kernel_primitive:NN \hfi \tex_hfi:D
1267 \__kernel_primitive:NN \ifdbox \tex_ifdbox:D
1268 \__kernel_primitive:NN \ifddir \tex_ifddir:D
1269 \__kernel_primitive:NN \ifjfont \tex_ifjfont:D
1270 \__kernel_primitive:NN \ifmbox \tex_ifmbox:D
1271 \__kernel_primitive:NN \ifmdir \tex_ifmdir:D
1272 \__kernel_primitive:NN \iftbox \tex_iftbox:D
1273 \__kernel_primitive:NN \iftfont \tex_iftfont:D
1274 \__kernel_primitive:NN \iftdir \tex_iftdir:D
1275 \__kernel_primitive:NN \ifybox \tex_ifybox:D
1276 \__kernel_primitive:NN \ifydir \tex_ifydir:D
1277 \__kernel_primitive:NN \inhibitglue \tex_inhibitglue:D
1278 \__kernel_primitive:NN \inhibitxspcode \tex_inhibitxspcode:D
1279 \__kernel_primitive:NN \jcharwidowpenalty \tex_jcharwidowpenalty:D
1280 \__kernel_primitive:NN \jfam \tex_jfam:D
1281 \__kernel_primitive:NN \jfont \tex_jfont:D
1282 \__kernel_primitive:NN \jis \tex_jis:D
1283 \__kernel_primitive:NN \kanjiskip \tex_kanjiskip:D
1284 \__kernel_primitive:NN \kansuji \tex_kansuji:D
1285 \__kernel_primitive:NN \kansujichar \tex_kansujichar:D
1286 \__kernel_primitive:NN \kcatcode \tex_kcatcode:D
1287 \__kernel_primitive:NN \kuten \tex_kuten:D
1288 \__kernel_primitive:NN \lastnodechar \tex_lastnodechar:D
1289 \__kernel_primitive:NN \lastnodefont \tex_lastnodefont:D
1290 \__kernel_primitive:NN \lastnodesubtype \tex_lastnodesubtype:D
1291 \__kernel_primitive:NN \noautospacing \tex_noautospacing:D
1292 \__kernel_primitive:NN \noautoxspacing \tex_noautoxspacing:D
1293 \__kernel_primitive:NN \pagefistretch \tex_pagefistretch:D
1294 \__kernel_primitive:NN \postbreakpenalty \tex_postbreakpenalty:D
1295 \__kernel_primitive:NN \prebreakpenalty \tex_prebreakpenalty:D
1296 \__kernel_primitive:NN \ptexfontname \tex_ptexfontname:D
1297 \__kernel_primitive:NN \ptexlineendmode \tex_lineendmode:D
1298 \__kernel_primitive:NN \ptexminorversion \tex_ptexminorversion:D
1299 \__kernel_primitive:NN \ptexrevision \tex_ptexrevision:D
1300 \__kernel_primitive:NN \ptextracingfonts \tex_ptextracingfonts:D
1301 \__kernel_primitive:NN \ptexversion \tex_ptexversion:D
1302 \__kernel_primitive:NN \readpapersizespecial \tex_readpapersizespecial:D
1303 \__kernel_primitive:NN \scriptbaselineshiftfactor
1304 \tex_scriptbaselineshiftfactor:D
1305 \__kernel_primitive:NN \scriptscriptbaselineshiftfactor
1306 \tex_scriptscriptbaselineshiftfactor:D
1307 \__kernel_primitive:NN \showmode \tex_showmode:D
1308 \__kernel_primitive:NN \sjis \tex_sjis:D
1309 \__kernel_primitive:NN \tate \tex_tate:D
1310 \__kernel_primitive:NN \tbaselineshift \tex_tbaselineshift:D
1311 \__kernel_primitive:NN \textbaselineshiftfactor
1312 \tex_textbaselineshiftfactor:D
1313 \__kernel_primitive:NN \tfont \tex_tfont:D
1314 \__kernel_primitive:NN \tojis \tex_tojis:D
1315 \__kernel_primitive:NN \toucs \tex_toucs:D
1316 \__kernel_primitive:NN \ucs \tex_ucs:D
1317 \__kernel_primitive:NN \xkanjiskip \tex_xkanjiskip:D
1318 \__kernel_primitive:NN \xspcode \tex_xspcode:D
1319 \__kernel_primitive:NN \ybaselineshift \tex_ybaselineshift:D
1320 \__kernel_primitive:NN \yoko \tex_yoko:D
1321 \__kernel_primitive:NN \vfi \tex_vfi:D
1322 \__kernel_primitive:NN \disablecjktoken \tex_disablecjktoken:D
1323 \__kernel_primitive:NN \enablecjktoken \tex_enablecjktoken:D
1324 \__kernel_primitive:NN \forcecjktoken \tex_forcecjktoken:D
1325 \__kernel_primitive:NN \kchar \tex_kchar:D
1326 \__kernel_primitive:NN \kchardef \tex_kchardef:D
1327 \__kernel_primitive:NN \uptexrevision \tex_uptexrevision:D
1328 \__kernel_primitive:NN \uptexversion \tex_uptexversion:D
1329 \__kernel_primitive:NN \odelcode \tex_odelcode:D
1330 \__kernel_primitive:NN \odelimiter \tex_odelimiter:D
1331 \__kernel_primitive:NN \omathaccent \tex_omathaccent:D
1332 \__kernel_primitive:NN \omathchar \tex_omathchar:D
1333 \__kernel_primitive:NN \omathchardef \tex_omathchardef:D
1334 \__kernel_primitive:NN \omathcode \tex_omathcode:D
1335 \__kernel_primitive:NN \oradical \tex_oradical:D
1336 \__kernel_primitive:NN \ignoreprimitiveerror \tex_ignoreprimitiveerror:D
1337 \__kernel_primitive:NN \partokencontext \tex_partokencontext:D
1338 \__kernel_primitive:NN \partokenname \tex_partokenname:D
1339 \__kernel_primitive:NN \showstream \tex_showstream:D
1340 \__kernel_primitive:NN \tracingstacklevels \tex_tracingstacklevels:D
1341 \tex_endgroup:D
1342 \tex_ifdefined:D \@@end
1343 \tex_let:D \tex_end:D \@@end
1344 \tex_let:D \tex_input:D \@@input
1345 \tex_fi:D
1346 \tex_ifdefined:D \@@hyph
1347 \tex_let:D \tex_everydisplay:D \frozen@everydisplay
1348 \tex_let:D \tex_everymath:D \frozen@everymath
1349 \tex_let:D \tex_hyphen:D \@@hyph
1350 \tex_let:D \tex_italiccorrection:D \@@italiccorr
1351 \tex_let:D \tex_underline:D \@@underline
1352 \tex_ifdefined:D \@@shipout
1353 \tex_let:D \tex_shipout:D \@@shipout
1354 \tex_fi:D
1355 \tex_begingroup:D
1356 \tex_edef:D \l_tmpa_tl { \tex_string:D \shipout }
1357 \tex_edef:D \l_tmpb_tl { \tex_meaning:D \shipout }
1358 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1359 \tex_else:D
1360 \tex_expandafter:D \@tfor \tex_expandafter:D \@tempa \tex_string:D :=
1361 \CROP@shipout
1362 \dup@shipout
1363 \GPTorg@shipout
1364 \LL@shipout
1365 \mem@oldshipout
1366 \opem@shipout
1367 \pgfpages@originalshipout
1368 \pr@shipout
1369 \Shipout
1370 \verso@orig@shipout
1371 \do
1372 {
1373 \tex_edef:D \l_tmpb_tl
1374 { \tex_expandafter:D \tex_meaning:D \@tempa }
1375 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1376 \tex_global:D \tex_expandafter:D \tex_let:D
1377 \tex_expandafter:D \tex_shipout:D \@tempa
1378 \tex_fi:D
1379 }
1380 \tex_fi:D
1381 \tex_endgroup:D
1382 \tex_let:D \tex_tracingfonts:D \tex_undefined:D
1383 \tex_ifdefined:D \pdftracingfonts
1384 \tex_let:D \tex_tracingfonts:D \pdftracingfonts
1385 \tex_else:D
1386 \tex_ifdefined:D \tex_directlua:D
1387 \tex_directlua:D { tex.enableprimitives("@@", {"tracingfonts"}) }
1388 \tex_let:D \tex_tracingfonts:D \@@tracingfonts
1389 \tex_fi:D
1390 \tex_fi:D
1391 \tex_fi:D
1392 \tex_ifnum:D 0
1393 \tex_ifdefined:D \tex_pdftexversion:D 1 \tex_fi:D
1394 \tex_ifdefined:D \tex_luatexversion:D 1 \tex_fi:D
1395 = 0 %
1396 \tex_let:D \tex_pdfmapfile:D \tex_undefined:D
1397 \tex_let:D \tex_pdfmapline:D \tex_undefined:D
1398 \tex_fi:D
1399 \tex_begingroup:D
1400 \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_time:D }
1401 \tex_edef:D \l_tmpb_tl { \tex_string:D \time }
1402 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1403 \tex_else:D
1404 \tex_global:D \tex_let:D \tex_time:D \tex_undefined:D
1405 \tex_fi:D
1406 \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_day:D }
1407 \tex_edef:D \l_tmpb_tl { \tex_string:D \day }
1408 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1409 \tex_else:D
1410 \tex_global:D \tex_let:D \tex_day:D \tex_undefined:D
1411 \tex_fi:D
1412 \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_month:D }
1413 \tex_edef:D \l_tmpb_tl { \tex_string:D \month }
1414 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1415 \tex_else:D
1416 \tex_global:D \tex_let:D \tex_month:D \tex_undefined:D
1417 \tex_fi:D
1418 \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_year:D }
1419 \tex_edef:D \l_tmpb_tl { \tex_string:D \year }
1420 \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
1421 \tex_else:D
1422 \tex_global:D \tex_let:D \tex_year:D \tex_undefined:D
1423 \tex_fi:D
1424 \tex_endgroup:D
1425 \tex_ifdefined:D \orieveryjob
1426 \tex_let:D \tex_everyjob:D \orieveryjob
1427 \tex_fi:D
1428 \tex_ifdefined:D \oripdfoutput
1429 \tex_let:D \tex_pdfoutput:D \oripdfoutput
1430 \tex_fi:D
1431 \tex_ifdefined:D \normalend
1432 \tex_let:D \tex_end:D \normalend
1433 \tex_let:D \tex_everyjob:D \normaleveryjob
1434 \tex_let:D \tex_input:D \normalinput
1435 \tex_let:D \tex_language:D \normallanguage
1436 \tex_let:D \tex_mathop:D \normalmathop
1437 \tex_let:D \tex_month:D \normalmonth
1438 \tex_let:D \tex_outer:D \normalouter
1439 \tex_let:D \tex_over:D \normalover
1440 \tex_let:D \tex_vcenter:D \normalvcenter
1441 \tex_let:D \tex_unexpanded:D \normalunexpanded
1442 \tex_let:D \tex_expanded:D \normalexpanded
1443 \tex_fi:D
1444 \tex_ifdefined:D \normalitaliccorrection
1445 \tex_let:D \tex_hoffset:D \normalhoffset
1446 \tex_let:D \tex_italiccorrection:D \normalitaliccorrection
1447 \tex_let:D \tex_voffset:D \normalvoffset
1448 \tex_let:D \tex_showtokens:D \normalshowtokens
1449 \tex_fi:D
1450 \tex_ifdefined:D \normalleft
1451 \tex_let:D \tex_left:D \normalleft
1452 \tex_let:D \tex_middle:D \normalmiddle
1453 \tex_let:D \tex_right:D \normalright
1454 \tex_fi:D
1455 %% File: l3basics.dtx
1456 \tex_global:D \tex_let:D \if_true: \tex_iftrue:D
1457 \tex_global:D \tex_let:D \if_false: \tex_iffalse:D
1458 \tex_global:D \tex_let:D \or: \tex_or:D
1459 \tex_global:D \tex_let:D \else: \tex_else:D
1460 \tex_global:D \tex_let:D \fi: \tex_fi:D
1461 \tex_global:D \tex_let:D \reverse_if:N \tex_unless:D
1462 \tex_global:D \tex_let:D \if:w \tex_if:D
1463 \tex_global:D \tex_let:D \if_charcode:w \tex_if:D
1464 \tex_global:D \tex_let:D \if_catcode:w \tex_ifcat:D
1465 \tex_global:D \tex_let:D \if_meaning:w \tex_ifx:D
1466 \tex_global:D \tex_let:D \if_bool:N \tex_ifodd:D
1467 \tex_global:D \tex_let:D \if_mode_math: \tex_ifmmode:D
1468 \tex_global:D \tex_let:D \if_mode_horizontal: \tex_ifhmode:D
1469 \tex_global:D \tex_let:D \if_mode_vertical: \tex_ifvmode:D
1470 \tex_global:D \tex_let:D \if_mode_inner: \tex_ifinner:D
1471 \tex_global:D \tex_let:D \if_cs_exist:N \tex_ifdefined:D
1472 \tex_global:D \tex_let:D \if_cs_exist:w \tex_ifcsname:D
1473 \tex_global:D \tex_let:D \cs:w \tex_csname:D
1474 \tex_global:D \tex_let:D \cs_end: \tex_endcsname:D
1475 \tex_global:D \tex_let:D \exp_after:wN \tex_expandafter:D
1476 \tex_global:D \tex_let:D \exp_not:N \tex_noexpand:D
1477 \tex_global:D \tex_let:D \exp_not:n \tex_unexpanded:D
1478 \tex_global:D \tex_let:D \exp:w \tex_romannumeral:D
1479 \tex_global:D \tex_chardef:D \exp_end: = 0 ~
1480 \tex_global:D \tex_let:D \token_to_meaning:N \tex_meaning:D
1481 \tex_global:D \tex_let:D \cs_meaning:N \tex_meaning:D
1482 \tex_global:D \tex_let:D \tl_to_str:n \tex_detokenize:D
1483 \tex_global:D \tex_let:D \token_to_str:N \tex_string:D
1484 \tex_global:D \tex_let:D \__kernel_tl_to_str:w \tex_detokenize:D
1485 \tex_global:D \tex_let:D \scan_stop: \tex_relax:D
1486 \tex_global:D \tex_let:D \group_begin: \tex_begingroup:D
1487 \tex_global:D \tex_let:D \group_end: \tex_endgroup:D
1488 \tex_global:D \tex_let:D \if_int_compare:w \tex_ifnum:D
1489 \tex_global:D \tex_let:D \__int_to_roman:w \tex_romannumeral:D
1490 \tex_global:D \tex_let:D \group_insert_after:N \tex_aftergroup:D
1491 \tex_long:D \tex_gdef:D \exp_args:Nc #1#2
1492 { \exp_after:wN #1 \cs:w #2 \cs_end: }
1493 \tex_long:D \tex_gdef:D \exp_args:cc #1#2
1494 { \cs:w #1 \exp_after:wN \cs_end: \cs:w #2 \cs_end: }
1495 \tex_gdef:D \token_to_str:c { \exp_args:Nc \token_to_str:N }
1496 \tex_long:D \tex_gdef:D \cs_meaning:c #1
1497 {
1498 \if_cs_exist:w #1 \cs_end:
1499 \exp_after:wN \use_i:nn
1500 \else:
1501 \exp_after:wN \use_ii:nn
1502 \fi:
1503 { \exp_args:Nc \cs_meaning:N {#1} }
1504 { \tl_to_str:n {undefined} }
1505 }
1506 \tex_global:D \tex_let:D \token_to_meaning:c = \cs_meaning:c
1507 \tex_global:D \tex_chardef:D \c_zero_int = 0 ~
1508 \tex_ifdefined:D \tex_luatexversion:D
1509 \tex_global:D \tex_chardef:D \c_max_register_int = 65 535 ~
1510 \tex_else:D
1511 \tex_ifdefined:D \tex_omathchardef:D
1512 \tex_global:D \tex_omathchardef:D \c_max_register_int = 65535 ~
1513 \tex_else:D
1514 \tex_global:D \tex_mathchardef:D \c_max_register_int = 32767 ~
1515 \tex_fi:D
1516 \tex_fi:D
1517 \tex_global:D \tex_let:D \cs_gset_nopar:Npn \tex_gdef:D
1518 \tex_global:D \tex_let:D \cs_gset_nopar:Npe \tex_xdef:D
1519 \tex_global:D \tex_let:D \cs_gset_nopar:Npx \tex_xdef:D
1520 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset:Npn
1521 { \tex_long:D \tex_gdef:D }
1522 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset:Npe
1523 { \tex_long:D \tex_xdef:D }
1524 \tex_global:D \tex_let:D \cs_gset:Npx \cs_gset:Npe
1525 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset_protected_nopar:Npn
1526 { \tex_protected:D \tex_gdef:D }
1527 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset_protected_nopar:Npe
1528 { \tex_protected:D \tex_xdef:D }
1529 \tex_global:D \tex_let:D \cs_gset_protected_nopar:Npx \cs_gset_protected_nopar:Npe
1530 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset_protected:Npn
1531 { \tex_protected:D \tex_long:D \tex_gdef:D }
1532 \tex_protected:D \tex_long:D \tex_gdef:D \cs_gset_protected:Npe
1533 { \tex_protected:D \tex_long:D \tex_xdef:D }
1534 \tex_global:D \tex_let:D \cs_gset_protected:Npx \cs_gset_protected:Npe
1535 \tex_global:D \tex_let:D \cs_set_nopar:Npn \tex_def:D
1536 \tex_global:D \tex_let:D \cs_set_nopar:Npe \tex_edef:D
1537 \tex_global:D \tex_let:D \cs_set_nopar:Npx \tex_edef:D
1538 \cs_gset_protected:Npn \cs_set:Npn
1539 { \tex_long:D \tex_def:D }
1540 \cs_gset_protected:Npn \cs_set:Npe
1541 { \tex_long:D \tex_edef:D }
1542 \tex_global:D \tex_let:D \cs_set:Npx \cs_set:Npe
1543 \cs_gset_protected:Npn \cs_set_protected_nopar:Npn
1544 { \tex_protected:D \tex_def:D }
1545 \cs_gset_protected:Npn \cs_set_protected_nopar:Npe
1546 { \tex_protected:D \tex_edef:D }
1547 \tex_global:D \tex_let:D \cs_set_protected_nopar:Npx \cs_set_protected_nopar:Npe
1548 \cs_gset_protected:Npn \cs_set_protected:Npn
1549 { \tex_protected:D \tex_long:D \tex_def:D }
1550 \cs_gset_protected:Npn \cs_set_protected:Npe
1551 { \tex_protected:D \tex_long:D \tex_edef:D }
1552 \tex_global:D \tex_let:D \cs_set_protected:Npx \cs_set_protected:Npe
1553 \cs_gset_nopar:Npn \l__exp_tmp_tl { }
1554 \cs_gset:Npn \use:c #1 { \cs:w #1 \cs_end: }
1555 \cs_gset_protected:Npn \use:x #1
1556 {
1557 \cs_set_nopar:Npx \l__exp_tmp_tl {#1}
1558 \l__exp_tmp_tl
1559 }
1560 \cs_gset:Npn \use:e #1 { \tex_expanded:D {#1} }
1561 \cs_gset:Npn \use:n #1 {#1}
1562 \cs_gset:Npn \use:nn #1#2 {#1#2}
1563 \cs_gset:Npn \use:nnn #1#2#3 {#1#2#3}
1564 \cs_gset:Npn \use:nnnn #1#2#3#4 {#1#2#3#4}
1565 \cs_gset:Npn \use_i:nn #1#2 {#1}
1566 \cs_gset:Npn \use_ii:nn #1#2 {#2}
1567 \cs_gset:Npn \use_i:nnn #1#2#3 {#1}
1568 \cs_gset:Npn \use_ii:nnn #1#2#3 {#2}
1569 \cs_gset:Npn \use_iii:nnn #1#2#3 {#3}
1570 \cs_gset:Npn \use_i:nnnn #1#2#3#4 {#1}
1571 \cs_gset:Npn \use_ii:nnnn #1#2#3#4 {#2}
1572 \cs_gset:Npn \use_iii:nnnn #1#2#3#4 {#3}
1573 \cs_gset:Npn \use_iv:nnnn #1#2#3#4 {#4}
1574 \cs_gset:Npn \use_i:nnnnn #1#2#3#4#5 {#1}
1575 \cs_gset:Npn \use_ii:nnnnn #1#2#3#4#5 {#2}
1576 \cs_gset:Npn \use_iii:nnnnn #1#2#3#4#5 {#3}
1577 \cs_gset:Npn \use_iv:nnnnn #1#2#3#4#5 {#4}
1578 \cs_gset:Npn \use_v:nnnnn #1#2#3#4#5 {#5}
1579 \cs_gset:Npn \use_i:nnnnnn #1#2#3#4#5#6 {#1}
1580 \cs_gset:Npn \use_ii:nnnnnn #1#2#3#4#5#6 {#2}
1581 \cs_gset:Npn \use_iii:nnnnnn #1#2#3#4#5#6 {#3}
1582 \cs_gset:Npn \use_iv:nnnnnn #1#2#3#4#5#6 {#4}
1583 \cs_gset:Npn \use_v:nnnnnn #1#2#3#4#5#6 {#5}
1584 \cs_gset:Npn \use_vi:nnnnnn #1#2#3#4#5#6 {#6}
1585 \cs_gset:Npn \use_i:nnnnnnn #1#2#3#4#5#6#7 {#1}
1586 \cs_gset:Npn \use_ii:nnnnnnn #1#2#3#4#5#6#7 {#2}
1587 \cs_gset:Npn \use_iii:nnnnnnn #1#2#3#4#5#6#7 {#3}
1588 \cs_gset:Npn \use_iv:nnnnnnn #1#2#3#4#5#6#7 {#4}
1589 \cs_gset:Npn \use_v:nnnnnnn #1#2#3#4#5#6#7 {#5}
1590 \cs_gset:Npn \use_vi:nnnnnnn #1#2#3#4#5#6#7 {#6}
1591 \cs_gset:Npn \use_vii:nnnnnnn #1#2#3#4#5#6#7 {#7}
1592 \cs_gset:Npn \use_i:nnnnnnnn #1#2#3#4#5#6#7#8 {#1}
1593 \cs_gset:Npn \use_ii:nnnnnnnn #1#2#3#4#5#6#7#8 {#2}
1594 \cs_gset:Npn \use_iii:nnnnnnnn #1#2#3#4#5#6#7#8 {#3}
1595 \cs_gset:Npn \use_iv:nnnnnnnn #1#2#3#4#5#6#7#8 {#4}
1596 \cs_gset:Npn \use_v:nnnnnnnn #1#2#3#4#5#6#7#8 {#5}
1597 \cs_gset:Npn \use_vi:nnnnnnnn #1#2#3#4#5#6#7#8 {#6}
1598 \cs_gset:Npn \use_vii:nnnnnnnn #1#2#3#4#5#6#7#8 {#7}
1599 \cs_gset:Npn \use_viii:nnnnnnnn #1#2#3#4#5#6#7#8 {#8}
1600 \cs_gset:Npn \use_i:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#1}
1601 \cs_gset:Npn \use_ii:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#2}
1602 \cs_gset:Npn \use_iii:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#3}
1603 \cs_gset:Npn \use_iv:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#4}
1604 \cs_gset:Npn \use_v:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#5}
1605 \cs_gset:Npn \use_vi:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#6}
1606 \cs_gset:Npn \use_vii:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#7}
1607 \cs_gset:Npn \use_viii:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#8}
1608 \cs_gset:Npn \use_ix:nnnnnnnnn #1#2#3#4#5#6#7#8#9 {#9}
1609 \cs_gset:Npn \use_i_ii:nnn #1#2#3 {#1#2}
1610 \cs_gset:Npn \use_ii_i:nn #1#2 { #2 #1 }
1611 \cs_gset:Npn \use_none_delimit_by_q_nil:w #1 \q_nil { }
1612 \cs_gset:Npn \use_none_delimit_by_q_stop:w #1 \q_stop { }
1613 \cs_gset:Npn \use_none_delimit_by_q_recursion_stop:w #1 \q_recursion_stop { }
1614 \cs_gset:Npn \use_i_delimit_by_q_nil:nw #1#2 \q_nil {#1}
1615 \cs_gset:Npn \use_i_delimit_by_q_stop:nw #1#2 \q_stop {#1}
1616 \cs_gset:Npn \use_i_delimit_by_q_recursion_stop:nw
1617 #1#2 \q_recursion_stop {#1}
1618 \cs_gset:Npn \use_none:n #1 { }
1619 \cs_gset:Npn \use_none:nn #1#2 { }
1620 \cs_gset:Npn \use_none:nnn #1#2#3 { }
1621 \cs_gset:Npn \use_none:nnnn #1#2#3#4 { }
1622 \cs_gset:Npn \use_none:nnnnn #1#2#3#4#5 { }
1623 \cs_gset:Npn \use_none:nnnnnn #1#2#3#4#5#6 { }
1624 \cs_gset:Npn \use_none:nnnnnnn #1#2#3#4#5#6#7 { }
1625 \cs_gset:Npn \use_none:nnnnnnnn #1#2#3#4#5#6#7#8 { }
1626 \cs_gset:Npn \use_none:nnnnnnnnn #1#2#3#4#5#6#7#8#9 { }
1627 \cs_gset_protected:Npn \__kernel_if_debug:TF #1#2 {#2}
1628 \cs_gset_protected:Npn \debug_on:n #1
1629 {
1630 \sys_load_debug:
1631 \cs_if_exist:NT \__debug_all_on:
1632 { \debug_on:n {#1} }
1633 }
1634 \cs_gset_protected:Npn \debug_off:n #1
1635 {
1636 \sys_load_debug:
1637 \cs_if_exist:NT \__debug_all_on:
1638 { \debug_off:n {#1} }
1639 }
1640 \cs_gset_protected:Npn \debug_suspend: { }
1641 \cs_gset_protected:Npn \debug_resume: { }
1642 \cs_gset:Npn \debug_assert:nN #1#2 { }
1643 \cs_gset:Npn \debug_assert:nn #1#2 { }
1644 \cs_gset:Npn \debug_assert:nNn #1#2#3 { }
1645 \cs_gset:Npn \debug_assert:nnn #1#2#3 { }
1646 \cs_gset_nopar:Npn \g__debug_deprecation_on_tl { }
1647 \cs_gset_nopar:Npn \g__debug_deprecation_off_tl { }
1648 \cs_gset_protected:Npn \__kernel_deprecation_code:nn #1#2
1649 {
1650 \tl_gput_right:Nn \g__debug_deprecation_on_tl {#1}
1651 \tl_gput_right:Nn \g__debug_deprecation_off_tl {#2}
1652 }
1653 \cs_gset:Npn \prg_return_true:
1654 { \exp_after:wN \use_i:nn \exp:w }
1655 \cs_gset:Npn \prg_return_false:
1656 { \exp_after:wN \use_ii:nn \exp:w}
1657 \cs_gset:Npn \__prg_use_none_delimit_by_q_recursion_stop:w
1658 #1 \q__prg_recursion_stop { }
1659 \cs_gset_protected:Npn \prg_set_conditional:Npnn
1660 { \__prg_generate_conditional_parm:NNNpnn \cs_set:Npn e }
1661 \cs_gset_protected:Npn \prg_gset_conditional:Npnn
1662 { \__prg_generate_conditional_parm:NNNpnn \cs_gset:Npn e }
1663 \cs_gset_protected:Npn \prg_new_conditional:Npnn
1664 { \__prg_generate_conditional_parm:NNNpnn \cs_new:Npn e }
1665 \cs_gset_protected:Npn \prg_set_protected_conditional:Npnn
1666 { \__prg_generate_conditional_parm:NNNpnn \cs_set_protected:Npn p }
1667 \cs_gset_protected:Npn \prg_gset_protected_conditional:Npnn
1668 { \__prg_generate_conditional_parm:NNNpnn \cs_gset_protected:Npn p }
1669 \cs_gset_protected:Npn \prg_new_protected_conditional:Npnn
1670 { \__prg_generate_conditional_parm:NNNpnn \cs_new_protected:Npn p }
1671 \cs_gset_protected:Npn \__prg_generate_conditional_parm:NNNpnn #1#2#3#4#
1672 {
1673 \use:e
1674 {
1675 \__prg_generate_conditional:nnNNNnnn
1676 \cs_split_function:N #3
1677 }
1678 #1 #2 {#4}
1679 }
1680 \cs_gset_protected:Npn \prg_set_conditional:Nnn
1681 { \__prg_generate_conditional_count:NNNnn \cs_set:Npn e }
1682 \cs_gset_protected:Npn \prg_gset_conditional:Nnn
1683 { \__prg_generate_conditional_count:NNNnn \cs_gset:Npn e }
1684 \cs_gset_protected:Npn \prg_new_conditional:Nnn
1685 { \__prg_generate_conditional_count:NNNnn \cs_new:Npn e }
1686 \cs_gset_protected:Npn \prg_set_protected_conditional:Nnn
1687 { \__prg_generate_conditional_count:NNNnn \cs_set_protected:Npn p }
1688 \cs_gset_protected:Npn \prg_gset_protected_conditional:Nnn
1689 { \__prg_generate_conditional_count:NNNnn \cs_gset_protected:Npn p }
1690 \cs_gset_protected:Npn \prg_new_protected_conditional:Nnn
1691 { \__prg_generate_conditional_count:NNNnn \cs_new_protected:Npn p }
1692 \cs_gset_protected:Npn \__prg_generate_conditional_count:NNNnn #1#2#3
1693 {
1694 \use:e
1695 {
1696 \__prg_generate_conditional_count:nnNNNnn
1697 \cs_split_function:N #3
1698 }
1699 #1 #2
1700 }
1701 \cs_gset_protected:Npn \__prg_generate_conditional_count:nnNNNnn #1#2#3#4#5
1702 {
1703 \__kernel_cs_parm_from_arg_count:nnF
1704 { \__prg_generate_conditional:nnNNNnnn {#1} {#2} #3 #4 #5 }
1705 { \tl_count:n {#2} }
1706 {
1707 \msg_error:nnee { kernel } { bad-number-of-arguments }
1708 { \token_to_str:c { #1 : #2 } }
1709 { \tl_count:n {#2} }
1710 \use_none:nn
1711 }
1712 }
1713 \cs_gset_protected:Npn \__prg_generate_conditional:nnNNNnnn #1#2#3#4#5#6#7#8
1714 {
1715 \if_meaning:w \c_false_bool #3
1716 \msg_error:nne { kernel } { missing-colon }
1717 { \token_to_str:c {#1} }
1718 \exp_after:wN \use_none:nn
1719 \fi:
1720 \use:e
1721 {
1722 \exp_not:N \__prg_generate_conditional:NNnnnnNw
1723 \exp_not:n { #4 #5 {#1} {#2} {#6} }
1724 \__prg_generate_conditional_test:w
1725 #8 \s__prg_mark
1726 \__prg_generate_conditional_fast:nw
1727 \prg_return_true: \else: \prg_return_false: \fi: \s__prg_mark
1728 \use_none:n
1729 \exp_not:n { {#8} \use_i_ii:nnn }
1730 \tl_to_str:n {#7}
1731 \exp_not:n { , \q__prg_recursion_tail , \q__prg_recursion_stop }
1732 }
1733 }
1734 \cs_gset:Npn \__prg_generate_conditional_test:w
1735 #1 \prg_return_true: \else: \prg_return_false: \fi: \s__prg_mark #2
1736 { #2 {#1} }
1737 \cs_gset:Npn \__prg_generate_conditional_fast:nw #1#2 \exp_not:n #3
1738 { \exp_not:n { {#1} \use_i:nn } }
1739 \cs_gset_protected:Npn \__prg_generate_conditional:NNnnnnNw #1#2#3#4#5#6#7#8 ,
1740 {
1741 \if_meaning:w \q__prg_recursion_tail #8
1742 \exp_after:wN \__prg_use_none_delimit_by_q_recursion_stop:w
1743 \fi:
1744 \use:c { __prg_generate_ #8 _form:wNNnnnnN }
1745 \tl_if_empty:nF {#8}
1746 {
1747 \msg_error:nnee
1748 { kernel } { conditional-form-unknown }
1749 {#8} { \token_to_str:c { #3 : #4 } }
1750 }
1751 \use_none:nnnnnnnn
1752 \s__prg_stop
1753 #1 #2 {#3} {#4} {#5} {#6} #7
1754 \__prg_generate_conditional:NNnnnnNw #1 #2 {#3} {#4} {#5} {#6} #7
1755 }
1756 \cs_gset_protected:Npn \__prg_generate_p_form:wNNnnnnN
1757 #1 \s__prg_stop #2#3#4#5#6#7#8
1758 {
1759 \if_meaning:w e #3
1760 \exp_after:wN \use_i:nn
1761 \else:
1762 \exp_after:wN \use_ii:nn
1763 \fi:
1764 {
1765 #8
1766 { \exp_args:Nc #2 { #4 _p: #5 } #6 }
1767 { { #7 \exp_end: \c_true_bool \c_false_bool } }
1768 { #7 \__prg_p_true:w \fi: \c_false_bool }
1769 }
1770 {
1771 \msg_error:nne { kernel } { protected-predicate }
1772 { \token_to_str:c { #4 _p: #5 } }
1773 }
1774 }
1775 \cs_gset_protected:Npn \__prg_generate_T_form:wNNnnnnN
1776 #1 \s__prg_stop #2#3#4#5#6#7#8
1777 {
1778 #8
1779 { \exp_args:Nc #2 { #4 : #5 T } #6 }
1780 { { #7 \exp_end: \use:n \use_none:n } }
1781 { #7 \__prg_T_true:w \fi: \use_none:n }
1782 }
1783 \cs_gset_protected:Npn \__prg_generate_F_form:wNNnnnnN
1784 #1 \s__prg_stop #2#3#4#5#6#7#8
1785 {
1786 #8
1787 { \exp_args:Nc #2 { #4 : #5 F } #6 }
1788 { { #7 \exp_end: { } } }
1789 { #7 \__prg_F_true:w \fi: \use:n }
1790 }
1791 \cs_gset_protected:Npn \__prg_generate_TF_form:wNNnnnnN
1792 #1 \s__prg_stop #2#3#4#5#6#7#8
1793 {
1794 #8
1795 { \exp_args:Nc #2 { #4 : #5 TF } #6 }
1796 { { #7 \exp_end: } }
1797 { #7 \__prg_TF_true:w \fi: \use_ii:nn }
1798 }
1799 \cs_gset:Npn \__prg_p_true:w \fi: \c_false_bool { \fi: \c_true_bool }
1800 \cs_gset:Npn \__prg_T_true:w \fi: \use_none:n { \fi: \use:n }
1801 \cs_gset:Npn \__prg_F_true:w \fi: \use:n { \fi: \use_none:n }
1802 \cs_gset:Npn \__prg_TF_true:w \fi: \use_ii:nn { \fi: \use_i:nn }
1803 \cs_gset_protected:Npn \prg_set_eq_conditional:NNn
1804 { \__prg_set_eq_conditional:NNNn \cs_set_eq:cc }
1805 \cs_gset_protected:Npn \prg_gset_eq_conditional:NNn
1806 { \__prg_set_eq_conditional:NNNn \cs_gset_eq:cc }
1807 \cs_gset_protected:Npn \prg_new_eq_conditional:NNn
1808 { \__prg_set_eq_conditional:NNNn \cs_new_eq:cc }
1809 \cs_gset_protected:Npn \__prg_set_eq_conditional:NNNn #1#2#3#4
1810 {
1811 \use:e
1812 {
1813 \exp_not:N \__prg_set_eq_conditional:nnNnnNNw
1814 \cs_split_function:N #2
1815 \cs_split_function:N #3
1816 \exp_not:N #1
1817 \tl_to_str:n {#4}
1818 \exp_not:n { , \q__prg_recursion_tail , \q__prg_recursion_stop }
1819 }
1820 }
1821 \cs_gset_protected:Npn \__prg_set_eq_conditional:nnNnnNNw #1#2#3#4#5#6
1822 {
1823 \if_meaning:w \c_false_bool #3
1824 \msg_error:nne { kernel } { missing-colon }
1825 { \token_to_str:c {#1} }
1826 \exp_after:wN \__prg_use_none_delimit_by_q_recursion_stop:w
1827 \fi:
1828 \if_meaning:w \c_false_bool #6
1829 \msg_error:nne { kernel } { missing-colon }
1830 { \token_to_str:c {#4} }
1831 \exp_after:wN \__prg_use_none_delimit_by_q_recursion_stop:w
1832 \fi:
1833 \__prg_set_eq_conditional_loop:nnnnNw {#1} {#2} {#4} {#5}
1834 }
1835 \cs_gset_protected:Npn \__prg_set_eq_conditional_loop:nnnnNw #1#2#3#4#5#6 ,
1836 {
1837 \if_meaning:w \q__prg_recursion_tail #6
1838 \exp_after:wN \__prg_use_none_delimit_by_q_recursion_stop:w
1839 \fi:
1840 \use:c { __prg_set_eq_conditional_ #6 _form:wNnnnn }
1841 \tl_if_empty:nF {#6}
1842 {
1843 \msg_error:nnee
1844 { kernel } { conditional-form-unknown }
1845 {#6} { \token_to_str:c { #1 : #2 } }
1846 }
1847 \use_none:nnnnnn
1848 \s__prg_stop
1849 #5 {#1} {#2} {#3} {#4}
1850 \__prg_set_eq_conditional_loop:nnnnNw {#1} {#2} {#3} {#4} #5
1851 }
1852 \cs_gset:Npn \__prg_set_eq_conditional_p_form:wNnnnn #1 \s__prg_stop #2#3#4#5#6
1853 { #2 { #3 _p : #4 } { #5 _p : #6 } }
1854 \cs_gset:Npn \__prg_set_eq_conditional_TF_form:wNnnnn #1 \s__prg_stop #2#3#4#5#6
1855 { #2 { #3 : #4 TF } { #5 : #6 TF } }
1856 \cs_gset:Npn \__prg_set_eq_conditional_T_form:wNnnnn #1 \s__prg_stop #2#3#4#5#6
1857 { #2 { #3 : #4 T } { #5 : #6 T } }
1858 \cs_gset:Npn \__prg_set_eq_conditional_F_form:wNnnnn #1 \s__prg_stop #2#3#4#5#6
1859 { #2 { #3 : #4 F } { #5 : #6 F } }
1860 \tex_global:D \tex_chardef:D \c_true_bool = 1 ~
1861 \tex_global:D \tex_chardef:D \c_false_bool = 0 ~
1862 \cs_gset:Npn \cs_to_str:N
1863 {
1864 \tex_romannumeral:D
1865 \if:w \token_to_str:N \ \__cs_to_str:w \fi:
1866 \exp_after:wN \__cs_to_str:N \token_to_str:N
1867 }
1868 \cs_gset:Npn \__cs_to_str:N #1 { \c_zero_int }
1869 \cs_gset:Npn \__cs_to_str:w #1 \__cs_to_str:N
1870 { - \int_value:w \fi: \exp_after:wN \c_zero_int }
1871 \cs_gset_protected:Npn \__cs_tmp:w #1
1872 {
1873 \cs_gset:Npn \cs_split_function:N ##1
1874 {
1875 \exp_after:wN \exp_after:wN \exp_after:wN
1876 \__cs_split_function_auxi:w
1877 \cs_to_str:N ##1 \s__cs_mark \c_true_bool
1878 #1 \s__cs_mark \c_false_bool \s__cs_stop
1879 }
1880 \cs_gset:Npn \__cs_split_function_auxi:w
1881 ##1 #1 ##2 \s__cs_mark ##3##4 \s__cs_stop
1882 { \__cs_split_function_auxii:w ##1 \s__cs_mark \s__cs_stop {##2} ##3 }
1883 \cs_gset:Npn \__cs_split_function_auxii:w ##1 \s__cs_mark ##2 \s__cs_stop
1884 { {##1} }
1885 }
1886 \exp_after:wN \__cs_tmp:w \token_to_str:N :
1887 \prg_gset_conditional:Npnn \cs_if_exist:N #1 { p , T , F , TF }
1888 {
1889 \if_meaning:w #1 \scan_stop:
1890 \use_i:nnnn
1891 \else:
1892 \fi:
1893 \if_cs_exist:N #1
1894 \prg_return_true:
1895 \else:
1896 \prg_return_false:
1897 \fi:
1898 }
1899 \cs_if_exist:NTF \tex_lastnamedcs:D
1900 {
1901 \prg_gset_conditional:Npnn \cs_if_exist:c #1 { p , T , F , TF }
1902 {
1903 \if_cs_exist:w #1 \cs_end:
1904 \__cs_if_exist_c_aux:
1905 \prg_return_true:
1906 \else:
1907 \prg_return_false:
1908 \fi:
1909 }
1910 \cs_gset:Npn \__cs_if_exist_c_aux:
1911 { \fi: \exp_after:wN \if_meaning:w \tex_lastnamedcs:D \scan_stop: \else: }
1912 }
1913 {
1914 \prg_gset_conditional:Npnn \cs_if_exist:c #1 { p , T , F , TF }
1915 {
1916 \if_cs_exist:w #1 \cs_end:
1917 \__cs_if_exist_c_aux:w
1918 \fi:
1919 \use_none:n {#1}
1920 \if_false:
1921 \prg_return_true:
1922 \else:
1923 \prg_return_false:
1924 \fi:
1925 }
1926 \cs_gset:Npn \__cs_if_exist_c_aux:w \fi: \use_none:n #1 \if_false:
1927 { \fi: \exp_after:wN \if_meaning:w \cs:w #1 \cs_end: \scan_stop: \else: }
1928 }
1929 \prg_gset_conditional:Npnn \cs_if_free:N #1 { p , T , F , TF }
1930 {
1931 \if_cs_exist:N #1
1932 \else:
1933 \use_none:nnnn
1934 \fi:
1935 \if_meaning:w #1 \scan_stop:
1936 \prg_return_true:
1937 \else:
1938 \prg_return_false:
1939 \fi:
1940 }
1941 \cs_if_exist:NTF \tex_lastnamedcs:D
1942 {
1943 \prg_gset_conditional:Npnn \cs_if_free:c #1 { p , T , F , TF }
1944 {
1945 \if_cs_exist:w #1 \cs_end:
1946 \__cs_if_free_c_aux:w
1947 \fi:
1948 \if_true:
1949 \prg_return_true:
1950 \else:
1951 \prg_return_false:
1952 \fi:
1953 }
1954 \cs_gset:Npn \__cs_if_free_c_aux:w \fi: \if_true:
1955 { \fi: \exp_after:wN \if_meaning:w \tex_lastnamedcs:D \scan_stop: }
1956 }
1957 {
1958 \prg_gset_conditional:Npnn \cs_if_free:c #1 { p , T , F , TF }
1959 {
1960 \if_cs_exist:w #1 \cs_end:
1961 \__cs_if_free_c_aux:w
1962 \fi:
1963 \use_none:n {#1}
1964 \if_true:
1965 \prg_return_true:
1966 \else:
1967 \prg_return_false:
1968 \fi:
1969 }
1970 \cs_gset:Npn \__cs_if_free_c_aux:w \fi: \use_none:n #1 \if_true:
1971 { \fi: \exp_after:wN \if_meaning:w \cs:w #1 \cs_end: \scan_stop: }
1972 }
1973 \cs_gset:Npn \cs_if_exist_use:NTF #1#2
1974 { \cs_if_exist:NTF #1 { #1 #2 } }
1975 \cs_gset:Npn \cs_if_exist_use:NF #1
1976 { \cs_if_exist:NTF #1 #1 }
1977 \cs_gset:Npn \cs_if_exist_use:NT #1 #2
1978 { \cs_if_exist:NT #1 { #1 #2 } }
1979 \cs_gset:Npn \cs_if_exist_use:N #1
1980 { \cs_if_exist:NT #1 #1 }
1981 \cs_if_exist:NTF \tex_lastnamedcs:D
1982 {
1983 \cs_gset:Npn \cs_if_exist_use:cTF #1
1984 {
1985 \if_cs_exist:w #1 \cs_end:
1986 \__cs_if_exist_use_aux:w
1987 \fi:
1988 \use_ii:nn
1989 }
1990 \cs_gset:Npn \__cs_if_exist_use_aux:w \fi: \use_ii:nn
1991 { \fi: \exp_after:wN \__cs_if_exist_use_aux:Nnn \tex_lastnamedcs:D }
1992 }
1993 {
1994 \cs_gset:Npn \cs_if_exist_use:cTF #1
1995 {
1996 \if_cs_exist:w #1 \cs_end:
1997 \__cs_if_exist_use_aux:w
1998 \fi:
1999 \use_iii:nnn {#1}
2000 }
2001 \cs_gset:Npn \__cs_if_exist_use_aux:w \fi: \use_iii:nnn #1
2002 { \fi: \exp_after:wN \__cs_if_exist_use_aux:Nnn \cs:w #1 \cs_end: }
2003 }
2004 \cs_gset:Npn \__cs_if_exist_use_aux:Nnn #1#2
2005 {
2006 \if_meaning:w #1 \scan_stop:
2007 \exp_after:wN \use_iii:nnn
2008 \fi:
2009 \use_i:nn { #1 #2 }
2010 }
2011 \cs_gset:Npn \cs_if_exist_use:cF #1
2012 { \cs_if_exist_use:cTF {#1} {} }
2013 \cs_gset:Npn \cs_if_exist_use:cT #1#2
2014 { \cs_if_exist_use:cTF {#1} {#2} {} }
2015 \cs_gset:Npn \cs_if_exist_use:c #1
2016 { \cs_if_exist_use:cTF {#1} {} {} }
2017 \cs_gset_protected:Npn \msg_error:nnee #1#2#3#4
2018 {
2019 \tex_newlinechar:D = `\^^J \scan_stop:
2020 \tex_errmessage:D
2021 {
2022 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!~! ^^J
2023 Argh,~internal~LaTeX3~error! ^^J ^^J
2024 Module ~ #1 , ~ message~name~"#2": ^^J
2025 Arguments~'#3'~and~'#4' ^^J ^^J
2026 This~is~one~for~The~LaTeX3~Project:~bailing~out
2027 }
2028 \tex_end:D
2029 }
2030 \cs_gset_protected:Npn \msg_error:nne #1#2#3
2031 { \msg_error:nnee {#1} {#2} {#3} { } }
2032 \cs_gset_protected:Npn \msg_error:nn #1#2
2033 { \msg_error:nnee {#1} {#2} { } { } }
2034 \cs_gset:Npn \msg_line_context:
2035 { on~line~ \tex_the:D \tex_inputlineno:D }
2036 \cs_gset_protected:Npn \__kernel_chk_if_free_cs:N #1
2037 {
2038 \cs_if_free:NF #1
2039 {
2040 \msg_error:nnee { kernel } { command-already-defined }
2041 { \token_to_str:N #1 } { \token_to_meaning:N #1 }
2042 }
2043 }
2044 \cs_gset_protected:Npn \__kernel_chk_if_free_cs:c
2045 { \exp_args:Nc \__kernel_chk_if_free_cs:N }
2046 \cs_set:Npn \__cs_tmp:w #1#2
2047 {
2048 \cs_gset_protected:Npn #1 ##1
2049 {
2050 \__kernel_chk_if_free_cs:N ##1
2051 #2 ##1
2052 }
2053 }
2054 \__cs_tmp:w \cs_new_nopar:Npn \cs_gset_nopar:Npn
2055 \__cs_tmp:w \cs_new_nopar:Npe \cs_gset_nopar:Npe
2056 \__cs_tmp:w \cs_new_nopar:Npx \cs_gset_nopar:Npx
2057 \__cs_tmp:w \cs_new:Npn \cs_gset:Npn
2058 \__cs_tmp:w \cs_new:Npe \cs_gset:Npe
2059 \__cs_tmp:w \cs_new:Npx \cs_gset:Npx
2060 \__cs_tmp:w \cs_new_protected_nopar:Npn \cs_gset_protected_nopar:Npn
2061 \__cs_tmp:w \cs_new_protected_nopar:Npe \cs_gset_protected_nopar:Npe
2062 \__cs_tmp:w \cs_new_protected_nopar:Npx \cs_gset_protected_nopar:Npx
2063 \__cs_tmp:w \cs_new_protected:Npn \cs_gset_protected:Npn
2064 \__cs_tmp:w \cs_new_protected:Npe \cs_gset_protected:Npe
2065 \__cs_tmp:w \cs_new_protected:Npx \cs_gset_protected:Npx
2066 \cs_set:Npn \__cs_tmp:w #1#2
2067 { \cs_new_protected_nopar:Npn #1 { \exp_args:Nc #2 } }
2068 \__cs_tmp:w \cs_set_nopar:cpn \cs_set_nopar:Npn
2069 \__cs_tmp:w \cs_set_nopar:cpe \cs_set_nopar:Npe
2070 \__cs_tmp:w \cs_set_nopar:cpx \cs_set_nopar:Npx
2071 \__cs_tmp:w \cs_gset_nopar:cpn \cs_gset_nopar:Npn
2072 \__cs_tmp:w \cs_gset_nopar:cpe \cs_gset_nopar:Npe
2073 \__cs_tmp:w \cs_gset_nopar:cpx \cs_gset_nopar:Npx
2074 \__cs_tmp:w \cs_new_nopar:cpn \cs_new_nopar:Npn
2075 \__cs_tmp:w \cs_new_nopar:cpe \cs_new_nopar:Npe
2076 \__cs_tmp:w \cs_new_nopar:cpx \cs_new_nopar:Npx
2077 \__cs_tmp:w \cs_set:cpn \cs_set:Npn
2078 \__cs_tmp:w \cs_set:cpe \cs_set:Npe
2079 \__cs_tmp:w \cs_set:cpx \cs_set:Npx
2080 \__cs_tmp:w \cs_gset:cpn \cs_gset:Npn
2081 \__cs_tmp:w \cs_gset:cpe \cs_gset:Npe
2082 \__cs_tmp:w \cs_gset:cpx \cs_gset:Npx
2083 \__cs_tmp:w \cs_new:cpn \cs_new:Npn
2084 \__cs_tmp:w \cs_new:cpe \cs_new:Npe
2085 \__cs_tmp:w \cs_new:cpx \cs_new:Npx
2086 \__cs_tmp:w \cs_set_protected_nopar:cpn \cs_set_protected_nopar:Npn
2087 \__cs_tmp:w \cs_set_protected_nopar:cpe \cs_set_protected_nopar:Npe
2088 \__cs_tmp:w \cs_set_protected_nopar:cpx \cs_set_protected_nopar:Npx
2089 \__cs_tmp:w \cs_gset_protected_nopar:cpn \cs_gset_protected_nopar:Npn
2090 \__cs_tmp:w \cs_gset_protected_nopar:cpe \cs_gset_protected_nopar:Npe
2091 \__cs_tmp:w \cs_gset_protected_nopar:cpx \cs_gset_protected_nopar:Npx
2092 \__cs_tmp:w \cs_new_protected_nopar:cpn \cs_new_protected_nopar:Npn
2093 \__cs_tmp:w \cs_new_protected_nopar:cpe \cs_new_protected_nopar:Npe
2094 \__cs_tmp:w \cs_new_protected_nopar:cpx \cs_new_protected_nopar:Npx
2095 \__cs_tmp:w \cs_set_protected:cpn \cs_set_protected:Npn
2096 \__cs_tmp:w \cs_set_protected:cpe \cs_set_protected:Npe
2097 \__cs_tmp:w \cs_set_protected:cpx \cs_set_protected:Npx
2098 \__cs_tmp:w \cs_gset_protected:cpn \cs_gset_protected:Npn
2099 \__cs_tmp:w \cs_gset_protected:cpe \cs_gset_protected:Npe
2100 \__cs_tmp:w \cs_gset_protected:cpx \cs_gset_protected:Npx
2101 \__cs_tmp:w \cs_new_protected:cpn \cs_new_protected:Npn
2102 \__cs_tmp:w \cs_new_protected:cpe \cs_new_protected:Npe
2103 \__cs_tmp:w \cs_new_protected:cpx \cs_new_protected:Npx
2104 \cs_new_protected:Npn \cs_set_eq:NN #1 { \tex_let:D #1 =~ }
2105 \cs_new_protected:Npn \cs_set_eq:cN { \exp_args:Nc \cs_set_eq:NN }
2106 \cs_new_protected:Npn \cs_set_eq:Nc { \exp_args:NNc \cs_set_eq:NN }
2107 \cs_new_protected:Npn \cs_set_eq:cc { \exp_args:Ncc \cs_set_eq:NN }
2108 \cs_new_protected:Npn \cs_gset_eq:NN { \tex_global:D \cs_set_eq:NN }
2109 \cs_new_protected:Npn \cs_gset_eq:Nc { \exp_args:NNc \cs_gset_eq:NN }
2110 \cs_new_protected:Npn \cs_gset_eq:cN { \exp_args:Nc \cs_gset_eq:NN }
2111 \cs_new_protected:Npn \cs_gset_eq:cc { \exp_args:Ncc \cs_gset_eq:NN }
2112 \cs_new_protected:Npn \cs_new_eq:NN #1
2113 {
2114 \__kernel_chk_if_free_cs:N #1
2115 \tex_global:D \cs_set_eq:NN #1
2116 }
2117 \cs_new_protected:Npn \cs_new_eq:cN { \exp_args:Nc \cs_new_eq:NN }
2118 \cs_new_protected:Npn \cs_new_eq:Nc { \exp_args:NNc \cs_new_eq:NN }
2119 \cs_new_protected:Npn \cs_new_eq:cc { \exp_args:Ncc \cs_new_eq:NN }
2120 \cs_new_protected:Npn \cs_undefine:N #1
2121 { \cs_gset_eq:NN #1 \tex_undefined:D }
2122 \cs_new_protected:Npn \cs_undefine:c #1
2123 {
2124 \if_cs_exist:w #1 \cs_end:
2125 \else:
2126 \use_i:nnnn
2127 \fi:
2128 \exp_args:Nc \cs_undefine:N {#1}
2129 }
2130 \cs_new_protected:Npn \__kernel_cs_parm_from_arg_count:nnF #1#2
2131 {
2132 \exp_args:Ne \__cs_parm_from_arg_count_test:nnF
2133 {
2134 \exp_after:wN \exp_not:n
2135 \if_case:w \int_eval:n {#2}
2136 { }
2137 \or: { ##1 }
2138 \or: { ##1##2 }
2139 \or: { ##1##2##3 }
2140 \or: { ##1##2##3##4 }
2141 \or: { ##1##2##3##4##5 }
2142 \or: { ##1##2##3##4##5##6 }
2143 \or: { ##1##2##3##4##5##6##7 }
2144 \or: { ##1##2##3##4##5##6##7##8 }
2145 \or: { ##1##2##3##4##5##6##7##8##9 }
2146 \else: { \c_false_bool }
2147 \fi:
2148 }
2149 {#1}
2150 }
2151 \cs_new_protected:Npn \__cs_parm_from_arg_count_test:nnF #1#2
2152 {
2153 \if_meaning:w \c_false_bool #1
2154 \exp_after:wN \use_ii:nn
2155 \else:
2156 \exp_after:wN \use_i:nn
2157 \fi:
2158 { #2 {#1} }
2159 }
2160 \cs_new:Npn \__cs_count_signature:N #1
2161 { \exp_args:Nf \__cs_count_signature:n { \cs_split_function:N #1 } }
2162 \cs_new:Npn \__cs_count_signature:n #1
2163 { \int_eval:n { \__cs_count_signature:nnN #1 } }
2164 \cs_new:Npn \__cs_count_signature:nnN #1#2#3
2165 {
2166 \if_meaning:w \c_true_bool #3
2167 \tl_count:n {#2}
2168 \else:
2169 -1
2170 \fi:
2171 }
2172 \cs_new:Npn \__cs_count_signature:c
2173 { \exp_args:Nc \__cs_count_signature:N }
2174 \cs_new_protected:Npn \cs_generate_from_arg_count:NNnn #1#2#3#4
2175 {
2176 \__kernel_cs_parm_from_arg_count:nnF { \use:nnn #2 #1 } {#3}
2177 {
2178 \msg_error:nnee { kernel } { bad-number-of-arguments }
2179 { \token_to_str:N #1 } { \int_eval:n {#3} }
2180 \use_none:n
2181 }
2182 {#4}
2183 }
2184 \cs_new_protected:Npn \cs_generate_from_arg_count:cNnn
2185 { \exp_args:Nc \cs_generate_from_arg_count:NNnn }
2186 \cs_new_protected:Npn \cs_generate_from_arg_count:Ncnn
2187 { \exp_args:NNc \cs_generate_from_arg_count:NNnn }
2188 \cs_set:Npn \__cs_tmp:w #1#2#3
2189 {
2190 \cs_new_protected:cpx { cs_ #1 : #2 }
2191 {
2192 \exp_not:N \__cs_generate_from_signature:NNn
2193 \exp_after:wN \exp_not:N \cs:w cs_ #1 : #3 \cs_end:
2194 }
2195 }
2196 \cs_new_protected:Npn \__cs_generate_from_signature:NNn #1#2
2197 {
2198 \use:e
2199 {
2200 \__cs_generate_from_signature:nnNNNn
2201 \cs_split_function:N #2
2202 }
2203 #1 #2
2204 }
2205 \cs_new_protected:Npn \__cs_generate_from_signature:nnNNNn #1#2#3#4#5#6
2206 {
2207 \bool_if:NTF #3
2208 {
2209 \cs_set_nopar:Npx \__cs_tmp:w
2210 { \tl_map_function:nN {#2} \__cs_generate_from_signature:n }
2211 \tl_if_empty:oF \__cs_tmp:w
2212 {
2213 \msg_error:nneee { kernel } { non-base-function }
2214 { \token_to_str:N #5 } {#2} { \__cs_tmp:w }
2215 }
2216 \cs_generate_from_arg_count:NNnn
2217 #5 #4 { \tl_count:n {#2} } {#6}
2218 }
2219 {
2220 \msg_error:nne { kernel } { missing-colon }
2221 { \token_to_str:N #5 }
2222 }
2223 }
2224 \cs_new:Npn \__cs_generate_from_signature:n #1
2225 {
2226 \if:w n #1 \else: \if:w N #1 \else:
2227 \if:w T #1 \else: \if:w F #1 \else: #1 \fi: \fi: \fi: \fi:
2228 }
2229 \__cs_tmp:w { set } { Nn } { Npn }
2230 \__cs_tmp:w { set } { Ne } { Npe }
2231 \__cs_tmp:w { set } { Nx } { Npx }
2232 \__cs_tmp:w { set_nopar } { Nn } { Npn }
2233 \__cs_tmp:w { set_nopar } { Ne } { Npe }
2234 \__cs_tmp:w { set_nopar } { Nx } { Npx }
2235 \__cs_tmp:w { set_protected } { Nn } { Npn }
2236 \__cs_tmp:w { set_protected } { Ne } { Npe }
2237 \__cs_tmp:w { set_protected } { Nx } { Npx }
2238 \__cs_tmp:w { set_protected_nopar } { Nn } { Npn }
2239 \__cs_tmp:w { set_protected_nopar } { Ne } { Npe }
2240 \__cs_tmp:w { set_protected_nopar } { Nx } { Npx }
2241 \__cs_tmp:w { gset } { Nn } { Npn }
2242 \__cs_tmp:w { gset } { Ne } { Npe }
2243 \__cs_tmp:w { gset } { Nx } { Npx }
2244 \__cs_tmp:w { gset_nopar } { Nn } { Npn }
2245 \__cs_tmp:w { gset_nopar } { Ne } { Npe }
2246 \__cs_tmp:w { gset_nopar } { Nx } { Npx }
2247 \__cs_tmp:w { gset_protected } { Nn } { Npn }
2248 \__cs_tmp:w { gset_protected } { Ne } { Npe }
2249 \__cs_tmp:w { gset_protected } { Nx } { Npx }
2250 \__cs_tmp:w { gset_protected_nopar } { Nn } { Npn }
2251 \__cs_tmp:w { gset_protected_nopar } { Ne } { Npe }
2252 \__cs_tmp:w { gset_protected_nopar } { Nx } { Npx }
2253 \__cs_tmp:w { new } { Nn } { Npn }
2254 \__cs_tmp:w { new } { Ne } { Npe }
2255 \__cs_tmp:w { new } { Nx } { Npx }
2256 \__cs_tmp:w { new_nopar } { Nn } { Npn }
2257 \__cs_tmp:w { new_nopar } { Ne } { Npe }
2258 \__cs_tmp:w { new_nopar } { Nx } { Npx }
2259 \__cs_tmp:w { new_protected } { Nn } { Npn }
2260 \__cs_tmp:w { new_protected } { Ne } { Npe }
2261 \__cs_tmp:w { new_protected } { Nx } { Npx }
2262 \__cs_tmp:w { new_protected_nopar } { Nn } { Npn }
2263 \__cs_tmp:w { new_protected_nopar } { Ne } { Npe }
2264 \__cs_tmp:w { new_protected_nopar } { Nx } { Npx }
2265 \cs_set:Npn \__cs_tmp:w #1#2
2266 {
2267 \cs_new_protected:cpx { cs_ #1 : c #2 }
2268 {
2269 \exp_not:N \exp_args:Nc
2270 \exp_after:wN \exp_not:N \cs:w cs_ #1 : N #2 \cs_end:
2271 }
2272 }
2273 \__cs_tmp:w { set } { n }
2274 \__cs_tmp:w { set } { e }
2275 \__cs_tmp:w { set } { x }
2276 \__cs_tmp:w { set_nopar } { n }
2277 \__cs_tmp:w { set_nopar } { e }
2278 \__cs_tmp:w { set_nopar } { x }
2279 \__cs_tmp:w { set_protected } { n }
2280 \__cs_tmp:w { set_protected } { e }
2281 \__cs_tmp:w { set_protected } { x }
2282 \__cs_tmp:w { set_protected_nopar } { n }
2283 \__cs_tmp:w { set_protected_nopar } { e }
2284 \__cs_tmp:w { set_protected_nopar } { x }
2285 \__cs_tmp:w { gset } { n }
2286 \__cs_tmp:w { gset } { e }
2287 \__cs_tmp:w { gset } { x }
2288 \__cs_tmp:w { gset_nopar } { n }
2289 \__cs_tmp:w { gset_nopar } { e }
2290 \__cs_tmp:w { gset_nopar } { x }
2291 \__cs_tmp:w { gset_protected } { n }
2292 \__cs_tmp:w { gset_protected } { e }
2293 \__cs_tmp:w { gset_protected } { x }
2294 \__cs_tmp:w { gset_protected_nopar } { n }
2295 \__cs_tmp:w { gset_protected_nopar } { e }
2296 \__cs_tmp:w { gset_protected_nopar } { x }
2297 \__cs_tmp:w { new } { n }
2298 \__cs_tmp:w { new } { e }
2299 \__cs_tmp:w { new } { x }
2300 \__cs_tmp:w { new_nopar } { n }
2301 \__cs_tmp:w { new_nopar } { e }
2302 \__cs_tmp:w { new_nopar } { x }
2303 \__cs_tmp:w { new_protected } { n }
2304 \__cs_tmp:w { new_protected } { e }
2305 \__cs_tmp:w { new_protected } { x }
2306 \__cs_tmp:w { new_protected_nopar } { n }
2307 \__cs_tmp:w { new_protected_nopar } { e }
2308 \__cs_tmp:w { new_protected_nopar } { x }
2309 \prg_new_conditional:Npnn \cs_if_eq:NN #1#2 { p , T , F , TF }
2310 {
2311 \if_meaning:w #1#2
2312 \prg_return_true: \else: \prg_return_false: \fi:
2313 }
2314 \cs_new:Npn \cs_if_eq_p:cN { \exp_args:Nc \cs_if_eq_p:NN }
2315 \cs_new:Npn \cs_if_eq:cNTF { \exp_args:Nc \cs_if_eq:NNTF }
2316 \cs_new:Npn \cs_if_eq:cNT { \exp_args:Nc \cs_if_eq:NNT }
2317 \cs_new:Npn \cs_if_eq:cNF { \exp_args:Nc \cs_if_eq:NNF }
2318 \cs_new:Npn \cs_if_eq_p:Nc { \exp_args:NNc \cs_if_eq_p:NN }
2319 \cs_new:Npn \cs_if_eq:NcTF { \exp_args:NNc \cs_if_eq:NNTF }
2320 \cs_new:Npn \cs_if_eq:NcT { \exp_args:NNc \cs_if_eq:NNT }
2321 \cs_new:Npn \cs_if_eq:NcF { \exp_args:NNc \cs_if_eq:NNF }
2322 \cs_new:Npn \cs_if_eq_p:cc { \exp_args:Ncc \cs_if_eq_p:NN }
2323 \cs_new:Npn \cs_if_eq:ccTF { \exp_args:Ncc \cs_if_eq:NNTF }
2324 \cs_new:Npn \cs_if_eq:ccT { \exp_args:Ncc \cs_if_eq:NNT }
2325 \cs_new:Npn \cs_if_eq:ccF { \exp_args:Ncc \cs_if_eq:NNF }
2326 \cs_new_protected:Npn \__kernel_chk_defined:NT #1#2
2327 {
2328 \cs_if_exist:NTF #1
2329 {#2}
2330 {
2331 \msg_error:nne { kernel } { variable-not-defined }
2332 { \token_to_str:N #1 }
2333 }
2334 }
2335 \cs_new_protected:Npn \__kernel_register_show:N
2336 { \__kernel_register_show_aux:NN \tl_show:n }
2337 \cs_new_protected:Npn \__kernel_register_show:c
2338 { \exp_args:Nc \__kernel_register_show:N }
2339 \cs_new_protected:Npn \__kernel_register_log:N
2340 { \__kernel_register_show_aux:NN \tl_log:n }
2341 \cs_new_protected:Npn \__kernel_register_log:c
2342 { \exp_args:Nc \__kernel_register_log:N }
2343 \cs_new_protected:Npn \__kernel_register_show_aux:NN #1#2
2344 {
2345 \__kernel_chk_defined:NT #2
2346 {
2347 \exp_args:No \__kernel_register_show_aux:nNN
2348 { \tex_the:D #2 } #2 #1
2349 }
2350 }
2351 \cs_new_protected:Npn \__kernel_register_show_aux:nNN #1#2#3
2352 { \exp_args:No #3 { \token_to_str:N #2 = #1 } }
2353 \cs_new_protected:Npn \cs_show:N { \__kernel_show:NN \tl_show:n }
2354 \cs_new_protected:Npn \cs_show:c
2355 { \group_begin: \exp_args:NNc \group_end: \cs_show:N }
2356 \cs_new_protected:Npn \cs_log:N { \__kernel_show:NN \tl_log:n }
2357 \cs_new_protected:Npn \cs_log:c
2358 { \group_begin: \exp_args:NNc \group_end: \cs_log:N }
2359 \cs_new_protected:Npn \__kernel_show:NN #1#2
2360 {
2361 \group_begin:
2362 \int_set:Nn \tex_escapechar:D { `\\ }
2363 \exp_args:NNe
2364 \group_end:
2365 #1 { \token_to_str:N #2 = \cs_meaning:N #2 }
2366 }
2367 \cs_new_protected:Npn \group_show_list:
2368 { \__kernel_group_show:NN \use_none:n 1 }
2369 \cs_new_protected:Npn \group_log_list:
2370 { \__kernel_group_show:NN \int_gzero:N 0 }
2371 \cs_new_protected:Npn \__kernel_group_show:NN #1#2
2372 {
2373 \use:e
2374 {
2375 #1 \tex_interactionmode:D
2376 \int_set:Nn \tex_tracingonline:D {#2}
2377 \int_set:Nn \tex_errorcontextlines:D { -1 }
2378 \exp_not:N \exp_after:wN \scan_stop:
2379 \tex_showgroups:D
2380 \int_gset:Nn \tex_interactionmode:D
2381 { \int_use:N \tex_interactionmode:D }
2382 \int_set:Nn \tex_tracingonline:D
2383 { \int_use:N \tex_tracingonline:D }
2384 \int_set:Nn \tex_errorcontextlines:D
2385 { \int_use:N \tex_errorcontextlines:D }
2386 }
2387 }
2388 \use:e
2389 {
2390 \exp_not:n { \cs_new:Npn \__cs_prefix_arg_replacement:wN #1 }
2391 \tl_to_str:n { macro : } \exp_not:n { #2 -> #3 \s__cs_stop #4 }
2392 }
2393 { #4 {#1} {#2} {#3} }
2394
2395 \cs_if_exist:NTF \__cs_macro_prefix_spec:N
2396 {
2397 \cs_new:Npn \cs_prefix_spec:N #1
2398 {
2399 \token_if_macro:NTF #1
2400 { \__cs_macro_prefix_spec:N #1 }
2401 { \scan_stop: }
2402 }
2403 }
2404 {
2405 \cs_new:Npn \cs_prefix_spec:N #1
2406 {
2407 \token_if_macro:NTF #1
2408 {
2409 \exp_after:wN \__cs_prefix_arg_replacement:wN
2410 \token_to_meaning:N #1 \s__cs_stop \use_i:nnn
2411 }
2412 { \scan_stop: }
2413 }
2414 }
2415 \cs_if_exist:NTF \__cs_macro_parameter_spec:N
2416 {
2417 \cs_new:Npn \cs_parameter_spec:N #1
2418 {
2419 \token_if_macro:NTF #1
2420 { \__cs_macro_parameter_spec:N #1 }
2421 { \scan_stop: }
2422 }
2423 }
2424 {
2425 \cs_new:Npn \cs_parameter_spec:N #1
2426 {
2427 \token_if_macro:NTF #1
2428 {
2429 \exp_after:wN \__cs_prefix_arg_replacement:wN
2430 \token_to_meaning:N #1 \s__cs_stop \use_ii:nnn
2431 }
2432 { \scan_stop: }
2433 }
2434 }
2435 \cs_if_exist:NTF \__cs_macro_replacement_spec:N
2436 {
2437 \cs_new:Npn \cs_replacement_spec:N #1
2438 {
2439 \token_if_macro:NTF #1
2440 { \__cs_macro_replacement_spec:N #1 }
2441 { \scan_stop: }
2442 }
2443 }
2444 {
2445 \cs_new:Npn \cs_replacement_spec:N #1
2446 {
2447 \token_if_macro:NTF #1
2448 {
2449 \exp_after:wN \__cs_prefix_arg_replacement:wN
2450 \token_to_meaning:N #1 \s__cs_stop \use_iii:nnn
2451 }
2452 { \scan_stop: }
2453 }
2454 }
2455 \cs_new:Npn \prg_do_nothing: { }
2456 \cs_new_eq:NN \prg_break_point:Nn \use_ii:nn
2457 \cs_new:Npn \prg_map_break:Nn #1#2#3 \prg_break_point:Nn #4#5
2458 {
2459 #5
2460 \if_meaning:w #1 #4
2461 \exp_after:wN \use_iii:nnn
2462 \fi:
2463 \prg_map_break:Nn #1 {#2}
2464 }
2465 \cs_new_eq:NN \prg_break_point: \prg_do_nothing:
2466 \cs_new:Npn \prg_break: #1 \prg_break_point: { }
2467 \cs_new:Npn \prg_break:n #1#2 \prg_break_point: {#1}
2468 \cs_new_protected:Npn \mode_leave_vertical:
2469 {
2470 \if_mode_vertical:
2471 \exp_after:wN \tex_indent:D
2472 \fi:
2473 }
2474 %% File: l3expan.dtx
2475 \cs_new:Npn \__exp_arg_next:nnn #1#2#3 { #2 \::: { #3 {#1} } }
2476 \cs_new:Npn \__exp_arg_next:Nnn #1#2#3 { #2 \::: { #3 #1 } }
2477 \cs_new:Npn \::: #1 {#1}
2478 \cs_new:Npn \::n #1 \::: #2#3 { #1 \::: { #2 {#3} } }
2479 \cs_new:Npn \::N #1 \::: #2#3 { #1 \::: {#2#3} }
2480 \cs_new:Npn \::p #1 \::: #2#3# { #1 \::: {#2#3} }
2481 \cs_new:Npn \::c #1 \::: #2#3
2482 { \exp_after:wN \__exp_arg_next:Nnn \cs:w #3 \cs_end: {#1} {#2} }
2483 \cs_new:Npn \::o #1 \::: #2#3
2484 { \exp_after:wN \__exp_arg_next:nnn \exp_after:wN {#3} {#1} {#2} }
2485 \cs_new:Npn \::e #1 \::: #2#3
2486 { \tex_expanded:D { \exp_not:n { #1 \::: } { \exp_not:n {#2} {#3} } } }
2487 \cs_new:Npn \::f #1 \::: #2#3
2488 {
2489 \exp_after:wN \__exp_arg_next:nnn
2490 \exp_after:wN { \exp:w \exp_end_continue_f:w #3 }
2491 {#1} {#2}
2492 }
2493 \use:nn { \cs_new_eq:NN \exp_stop_f: } { ~ }
2494 \cs_new_protected:Npn \::x #1 \::: #2#3
2495 {
2496 \cs_set_nopar:Npe \l__exp_tmp_tl
2497 { \exp_not:n { #1 \::: } { \exp_not:n {#2} {#3} } }
2498 \l__exp_tmp_tl
2499 }
2500 \cs_new:Npn \::V #1 \::: #2#3
2501 {
2502 \exp_after:wN \__exp_arg_next:nnn
2503 \exp_after:wN { \exp:w \__exp_eval_register:N #3 }
2504 {#1} {#2}
2505 }
2506 \cs_new:Npn \::v #1 \::: #2#3
2507 {
2508 \exp_after:wN \__exp_arg_next:nnn
2509 \exp_after:wN { \exp:w \__exp_eval_register:c {#3} }
2510 {#1} {#2}
2511 }
2512 \cs_new:Npn \__exp_eval_register:N #1
2513 {
2514 \exp_after:wN \if_meaning:w \exp_not:N #1 #1
2515 \if_meaning:w \scan_stop: #1
2516 \__exp_eval_error_msg:w
2517 \fi:
2518 \else:
2519 \exp_after:wN \use_i_ii:nnn
2520 \fi:
2521 \exp_after:wN \exp_end: \tex_the:D #1
2522 }
2523 \cs_new:Npn \__exp_eval_register:c #1
2524 { \exp_after:wN \__exp_eval_register:N \cs:w #1 \cs_end: }
2525 \cs_new:Npn \__exp_eval_error_msg:w #1 \tex_the:D #2
2526 {
2527 \fi:
2528 \fi:
2529 \msg_expandable_error:nnn { kernel } { bad-variable } {#2}
2530 \exp_end:
2531 }
2532 \cs_new:Npn \exp_args:NNc #1#2#3
2533 { \exp_after:wN #1 \exp_after:wN #2 \cs:w # 3\cs_end: }
2534 \cs_new:Npn \exp_args:Ncc #1#2#3
2535 { \exp_after:wN #1 \cs:w #2 \exp_after:wN \cs_end: \cs:w #3 \cs_end: }
2536 \cs_new:Npn \exp_args:Nccc #1#2#3#4
2537 {
2538 \exp_after:wN #1
2539 \cs:w #2 \exp_after:wN \cs_end:
2540 \cs:w #3 \exp_after:wN \cs_end:
2541 \cs:w #4 \cs_end:
2542 }
2543 \cs_new:Npn \exp_args:No #1#2 { \exp_after:wN #1 \exp_after:wN {#2} }
2544 \cs_new:Npn \exp_args:NNo #1#2#3
2545 { \exp_after:wN #1 \exp_after:wN #2 \exp_after:wN {#3} }
2546 \cs_new:Npn \exp_args:NNNo #1#2#3#4
2547 { \exp_after:wN #1 \exp_after:wN#2 \exp_after:wN #3 \exp_after:wN {#4} }
2548 \cs_new:Npn \exp_args:Ne #1#2
2549 { \exp_after:wN #1 \tex_expanded:D { {#2} } }
2550 \cs_new:Npn \exp_args:Nf #1#2
2551 { \exp_after:wN #1 \exp_after:wN { \exp:w \exp_end_continue_f:w #2 } }
2552 \cs_new:Npn \exp_args:Nv #1#2
2553 {
2554 \exp_after:wN #1 \exp_after:wN
2555 { \exp:w \__exp_eval_register:c {#2} }
2556 }
2557 \cs_new:Npn \exp_args:NV #1#2
2558 {
2559 \exp_after:wN #1 \exp_after:wN
2560 { \exp:w \__exp_eval_register:N #2 }
2561 }
2562 \cs_new:Npn \exp_args:NNV #1#2#3
2563 {
2564 \exp_after:wN #1
2565 \exp_after:wN #2
2566 \exp_after:wN { \exp:w \__exp_eval_register:N #3 }
2567 }
2568 \cs_new:Npn \exp_args:NNv #1#2#3
2569 {
2570 \exp_after:wN #1
2571 \exp_after:wN #2
2572 \exp_after:wN { \exp:w \__exp_eval_register:c {#3} }
2573 }
2574 \cs_new:Npn \exp_args:NNe #1#2#3
2575 {
2576 \exp_after:wN #1
2577 \exp_after:wN #2
2578 \tex_expanded:D { {#3} }
2579 }
2580 \cs_new:Npn \exp_args:NNf #1#2#3
2581 {
2582 \exp_after:wN #1
2583 \exp_after:wN #2
2584 \exp_after:wN { \exp:w \exp_end_continue_f:w #3 }
2585 }
2586 \cs_new:Npn \exp_args:Nco #1#2#3
2587 {
2588 \exp_after:wN #1
2589 \cs:w #2 \exp_after:wN \cs_end:
2590 \exp_after:wN {#3}
2591 }
2592 \cs_new:Npn \exp_args:NcV #1#2#3
2593 {
2594 \exp_after:wN #1
2595 \cs:w #2 \exp_after:wN \cs_end:
2596 \exp_after:wN { \exp:w \__exp_eval_register:N #3 }
2597 }
2598 \cs_new:Npn \exp_args:Ncv #1#2#3
2599 {
2600 \exp_after:wN #1
2601 \cs:w #2 \exp_after:wN \cs_end:
2602 \exp_after:wN { \exp:w \__exp_eval_register:c {#3} }
2603 }
2604 \cs_new:Npn \exp_args:Ncf #1#2#3
2605 {
2606 \exp_after:wN #1
2607 \cs:w #2 \exp_after:wN \cs_end:
2608 \exp_after:wN { \exp:w \exp_end_continue_f:w #3 }
2609 }
2610 \cs_new:Npn \exp_args:NVV #1#2#3
2611 {
2612 \exp_after:wN #1
2613 \exp_after:wN { \exp:w \exp_after:wN
2614 \__exp_eval_register:N \exp_after:wN #2 \exp_after:wN }
2615 \exp_after:wN { \exp:w \__exp_eval_register:N #3 }
2616 }
2617 \cs_new:Npn \exp_args:NNNV #1#2#3#4
2618 {
2619 \exp_after:wN #1
2620 \exp_after:wN #2
2621 \exp_after:wN #3
2622 \exp_after:wN { \exp:w \__exp_eval_register:N #4 }
2623 }
2624 \cs_new:Npn \exp_args:NNNv #1#2#3#4
2625 {
2626 \exp_after:wN #1
2627 \exp_after:wN #2
2628 \exp_after:wN #3
2629 \exp_after:wN { \exp:w \__exp_eval_register:c {#4} }
2630 }
2631 \cs_new:Npn \exp_args:NNNe #1#2#3#4
2632 {
2633 \exp_after:wN #1
2634 \exp_after:wN #2
2635 \exp_after:wN #3
2636 \tex_expanded:D { {#4} }
2637 }
2638 \cs_new:Npn \exp_args:NcNc #1#2#3#4
2639 {
2640 \exp_after:wN #1
2641 \cs:w #2 \exp_after:wN \cs_end:
2642 \exp_after:wN #3
2643 \cs:w #4 \cs_end:
2644 }
2645 \cs_new:Npn \exp_args:NcNo #1#2#3#4
2646 {
2647 \exp_after:wN #1
2648 \cs:w #2 \exp_after:wN \cs_end:
2649 \exp_after:wN #3
2650 \exp_after:wN {#4}
2651 }
2652 \cs_new:Npn \exp_args:Ncco #1#2#3#4
2653 {
2654 \exp_after:wN #1
2655 \cs:w #2 \exp_after:wN \cs_end:
2656 \cs:w #3 \exp_after:wN \cs_end:
2657 \exp_after:wN {#4}
2658 }
2659 \cs_new_protected:Npn \exp_args:Nx #1#2
2660 { \use:x { \exp_not:N #1 {#2} } }
2661 \cs_new:Npn \__exp_arg_last_unbraced:nn #1#2 { #2#1 }
2662 \cs_new:Npn \::o_unbraced \::: #1#2
2663 { \exp_after:wN \__exp_arg_last_unbraced:nn \exp_after:wN {#2} {#1} }
2664 \cs_new:Npn \::V_unbraced \::: #1#2
2665 {
2666 \exp_after:wN \__exp_arg_last_unbraced:nn
2667 \exp_after:wN { \exp:w \__exp_eval_register:N #2 } {#1}
2668 }
2669 \cs_new:Npn \::v_unbraced \::: #1#2
2670 {
2671 \exp_after:wN \__exp_arg_last_unbraced:nn
2672 \exp_after:wN { \exp:w \__exp_eval_register:c {#2} } {#1}
2673 }
2674 \cs_new:Npn \::e_unbraced \::: #1#2
2675 { \tex_expanded:D { \exp_not:n {#1} #2 } }
2676 \cs_new:Npn \::f_unbraced \::: #1#2
2677 {
2678 \exp_after:wN \__exp_arg_last_unbraced:nn
2679 \exp_after:wN { \exp:w \exp_end_continue_f:w #2 } {#1}
2680 }
2681 \cs_new_protected:Npn \::x_unbraced \::: #1#2
2682 {
2683 \cs_set_nopar:Npe \l__exp_tmp_tl { \exp_not:n {#1} #2 }
2684 \l__exp_tmp_tl
2685 }
2686 \cs_new:Npn \exp_last_unbraced:No #1#2 { \exp_after:wN #1 #2 }
2687 \cs_new:Npn \exp_last_unbraced:NV #1#2
2688 { \exp_after:wN #1 \exp:w \__exp_eval_register:N #2 }
2689 \cs_new:Npn \exp_last_unbraced:Nv #1#2
2690 { \exp_after:wN #1 \exp:w \__exp_eval_register:c {#2} }
2691 \cs_new:Npn \exp_last_unbraced:Ne #1#2
2692 { \exp_after:wN #1 \tex_expanded:D {#2} }
2693 \cs_new:Npn \exp_last_unbraced:Nf #1#2
2694 { \exp_after:wN #1 \exp:w \exp_end_continue_f:w #2 }
2695 \cs_new:Npn \exp_last_unbraced:NNo #1#2#3
2696 { \exp_after:wN #1 \exp_after:wN #2 #3 }
2697 \cs_new:Npn \exp_last_unbraced:NNV #1#2#3
2698 {
2699 \exp_after:wN #1
2700 \exp_after:wN #2
2701 \exp:w \__exp_eval_register:N #3
2702 }
2703 \cs_new:Npn \exp_last_unbraced:NNf #1#2#3
2704 {
2705 \exp_after:wN #1
2706 \exp_after:wN #2
2707 \exp:w \exp_end_continue_f:w #3
2708 }
2709 \cs_new:Npn \exp_last_unbraced:Nco #1#2#3
2710 { \exp_after:wN #1 \cs:w #2 \exp_after:wN \cs_end: #3 }
2711 \cs_new:Npn \exp_last_unbraced:NcV #1#2#3
2712 {
2713 \exp_after:wN #1
2714 \cs:w #2 \exp_after:wN \cs_end:
2715 \exp:w \__exp_eval_register:N #3
2716 }
2717 \cs_new:Npn \exp_last_unbraced:NNNo #1#2#3#4
2718 { \exp_after:wN #1 \exp_after:wN #2 \exp_after:wN #3 #4 }
2719 \cs_new:Npn \exp_last_unbraced:NNNV #1#2#3#4
2720 {
2721 \exp_after:wN #1
2722 \exp_after:wN #2
2723 \exp_after:wN #3
2724 \exp:w \__exp_eval_register:N #4
2725 }
2726 \cs_new:Npn \exp_last_unbraced:NNNf #1#2#3#4
2727 {
2728 \exp_after:wN #1
2729 \exp_after:wN #2
2730 \exp_after:wN #3
2731 \exp:w \exp_end_continue_f:w #4
2732 }
2733 \cs_new:Npn \exp_last_unbraced:Nno { \::n \::o_unbraced \::: }
2734 \cs_new:Npn \exp_last_unbraced:Nnf { \::n \::f_unbraced \::: }
2735 \cs_new:Npn \exp_last_unbraced:Noo { \::o \::o_unbraced \::: }
2736 \cs_new:Npn \exp_last_unbraced:Nfo { \::f \::o_unbraced \::: }
2737 \cs_new:Npn \exp_last_unbraced:NnNo { \::n \::N \::o_unbraced \::: }
2738 \cs_new:Npn \exp_last_unbraced:NNNNo #1#2#3#4#5
2739 { \exp_after:wN #1 \exp_after:wN #2 \exp_after:wN #3 \exp_after:wN #4 #5 }
2740 \cs_new:Npn \exp_last_unbraced:NNNNf #1#2#3#4#5
2741 {
2742 \exp_after:wN #1
2743 \exp_after:wN #2
2744 \exp_after:wN #3
2745 \exp_after:wN #4
2746 \exp:w \exp_end_continue_f:w #5
2747 }
2748 \cs_new_protected:Npn \exp_last_unbraced:Nx { \::x_unbraced \::: }
2749 \cs_new:Npn \exp_last_two_unbraced:Noo #1#2#3
2750 { \exp_after:wN \__exp_last_two_unbraced:noN \exp_after:wN {#3} {#2} #1 }
2751 \cs_new:Npn \__exp_last_two_unbraced:noN #1#2#3
2752 { \exp_after:wN #3 #2 #1 }
2753 \cs_new_eq:NN \__kernel_exp_not:w \tex_unexpanded:D
2754 \cs_new:Npn \exp_not:c #1 { \exp_after:wN \exp_not:N \cs:w #1 \cs_end: }
2755 \cs_new:Npn \exp_not:o #1 { \__kernel_exp_not:w \exp_after:wN {#1} }
2756 \cs_new:Npn \exp_not:e #1
2757 { \__kernel_exp_not:w \tex_expanded:D { {#1} } }
2758 \cs_new:Npn \exp_not:f #1
2759 { \__kernel_exp_not:w \exp_after:wN { \exp:w \exp_end_continue_f:w #1 } }
2760 \cs_new:Npn \exp_not:V #1
2761 {
2762 \__kernel_exp_not:w \exp_after:wN
2763 { \exp:w \__exp_eval_register:N #1 }
2764 }
2765 \cs_new:Npn \exp_not:v #1
2766 {
2767 \__kernel_exp_not:w \exp_after:wN
2768 { \exp:w \__exp_eval_register:c {#1} }
2769 }
2770 \group_begin:
2771 \tex_catcode:D `\^^@ = 13
2772 \cs_new_protected:Npn \exp_end_continue_f:w { `^^@ }
2773 \if_cs_exist:N ^^@
2774 \else:
2775 \cs_new:Npn ^^@
2776 { \msg_expandable_error:nn { kernel } { bad-exp-end-f } }
2777 \fi:
2778 \cs_new:Npn \exp_end_continue_f:nw #1 { `^^@ #1 }
2779 \group_end:
2780 \cs_new_eq:NN \s__cs_mark \scan_stop:
2781 \cs_new_eq:NN \s__cs_stop \scan_stop:
2782 \cs_new:Npn \q__cs_recursion_stop { \q__cs_recursion_stop }
2783 \cs_new:Npn \__cs_use_none_delimit_by_s_stop:w #1 \s__cs_stop { }
2784 \cs_new:Npn \__cs_use_i_delimit_by_s_stop:nw #1 #2 \s__cs_stop {#1}
2785 \cs_new:Npn \__cs_use_none_delimit_by_q_recursion_stop:w
2786 #1 \q__cs_recursion_stop { }
2787 \cs_new_protected:Npn \cs_generate_variant:Nn #1#2
2788 {
2789 \__cs_generate_variant:N #1
2790 \use:e
2791 {
2792 \__cs_generate_variant:nnNN
2793 \cs_split_function:N #1
2794 \exp_not:N #1
2795 \tl_to_str:n {#2} ,
2796 \exp_not:N \scan_stop: ,
2797 \exp_not:N \q__cs_recursion_stop
2798 }
2799 }
2800 \cs_new_protected:Npn \cs_generate_variant:cn
2801 { \exp_args:Nc \cs_generate_variant:Nn }
2802 \cs_new_protected:Npe \__cs_generate_variant:N #1
2803 {
2804 \exp_not:N \exp_after:wN \exp_not:N \if_meaning:w
2805 \exp_not:N \exp_not:N #1 #1
2806 \cs_set_eq:NN \exp_not:N \__cs_tmp:w \cs_new_protected:Npe
2807 \exp_not:N \else:
2808 \exp_not:N \exp_after:wN \exp_not:N \__cs_generate_variant:ww
2809 \exp_not:N \token_to_meaning:N #1 \tl_to_str:n { ma }
2810 \s__cs_mark
2811 \s__cs_mark \cs_new_protected:Npe
2812 \tl_to_str:n { pr }
2813 \s__cs_mark \cs_new:Npe
2814 \s__cs_stop
2815 \exp_not:N \fi:
2816 }
2817 \exp_last_unbraced:NNNNo
2818 \cs_new_protected:Npn \__cs_generate_variant:ww
2819 #1 { \tl_to_str:n { ma } } #2 \s__cs_mark
2820 { \__cs_generate_variant:wwNw #1 }
2821 \exp_last_unbraced:NNNNo
2822 \cs_new_protected:Npn \__cs_generate_variant:wwNw
2823 #1 { \tl_to_str:n { pr } } #2 \s__cs_mark #3 #4 \s__cs_stop
2824 { \cs_set_eq:NN \__cs_tmp:w #3 }
2825 \cs_new_protected:Npn \__cs_generate_variant:nnNN #1#2#3#4
2826 {
2827 \if_meaning:w \c_false_bool #3
2828 \msg_error:nne { kernel } { missing-colon }
2829 { \token_to_str:c {#1} }
2830 \exp_after:wN \__cs_use_none_delimit_by_q_recursion_stop:w
2831 \fi:
2832 \__cs_generate_variant:Nnnw #4 {#1}{#2}
2833 }
2834 \cs_new_protected:Npn \__cs_generate_variant:Nnnw #1#2#3#4 ,
2835 {
2836 \if_meaning:w \scan_stop: #4
2837 \exp_after:wN \__cs_use_none_delimit_by_q_recursion_stop:w
2838 \fi:
2839 \__cs_generate_variant_chk:nnTF {#3} {#4}
2840 {
2841 \msg_error:nne { kernel } { variant-same-as-base }
2842 { \token_to_str:N #1 }
2843 \str_map_inline:nn {#4}
2844 {
2845 \str_if_in:nnF { NnpcofeVvx } {##1}
2846 {
2847 \msg_error:nneeee { kernel } { invalid-variant }
2848 {#4} { \token_to_str:N #1 } {##1} {##1}
2849 \str_map_break:
2850 }
2851 }
2852 }
2853 {
2854 \use:e
2855 {
2856 \exp_not:N \__cs_generate_variant:wwNN
2857 \__cs_generate_variant_loop:nNwN { }
2858 #4
2859 \__cs_generate_variant_loop_end:nwwwNNnn
2860 \s__cs_mark
2861 #3 ~
2862 { ~ { } \fi: \__cs_generate_variant_loop_long:wNNnn } ~
2863 { }
2864 \s__cs_stop
2865 \exp_not:N #1 {#2} {#4}
2866 }
2867 }
2868 \__cs_generate_variant:Nnnw #1 {#2} {#3}
2869 }
2870 \cs_new:Npn \__cs_generate_variant_chk:nnTF #1#2 { \use_ii:nn }
2871 \cs_new:Npn \__cs_generate_variant_loop:nNwN #1#2#3 \s__cs_mark #4
2872 {
2873 \if:w #2 #4
2874 \exp_after:wN \__cs_generate_variant_loop_same:w
2875 \else:
2876 \if:w #4 \__cs_generate_variant_loop_base:N #2 \else:
2877 \if:w 0
2878 \if:w N #4 \else: \if:w n #4 \else: 1 \fi: \fi:
2879 \if:w \scan_stop: \__cs_generate_variant_loop_base:N #2 1 \fi:
2880 0
2881 \__cs_generate_variant_loop_special:NNwNNnn #4#2
2882 \else:
2883 \__cs_generate_variant_loop_invalid:NNwNNnn #4#2
2884 \fi:
2885 \fi:
2886 \fi:
2887 #1
2888 \prg_do_nothing:
2889 #2
2890 \__cs_generate_variant_loop:nNwN { } #3 \s__cs_mark
2891 }
2892 \cs_new:Npn \__cs_generate_variant_loop_base:N #1
2893 {
2894 \if:w c #1 N \else:
2895 \if:w o #1 n \else:
2896 \if:w V #1 n \else:
2897 \if:w v #1 n \else:
2898 \if:w f #1 n \else:
2899 \if:w e #1 n \else:
2900 \if:w x #1 n \else:
2901 \if:w n #1 n \else:
2902 \if:w N #1 N \else:
2903 \scan_stop:
2904 \fi:
2905 \fi:
2906 \fi:
2907 \fi:
2908 \fi:
2909 \fi:
2910 \fi:
2911 \fi:
2912 \fi:
2913 }
2914 \cs_new:Npn \__cs_generate_variant_loop_same:w
2915 #1 \prg_do_nothing: #2#3#4
2916 { #3 { #1 \__cs_generate_variant_same:N #2 } }
2917 \cs_new:Npn \__cs_generate_variant_loop_end:nwwwNNnn
2918 #1#2 \s__cs_mark #3 ~ #4 \s__cs_stop #5#6#7#8
2919 {
2920 \scan_stop: \scan_stop: \fi:
2921 \s__cs_mark \s__cs_stop
2922 \exp_not:N #6
2923 \exp_not:c { #7 : #8 #1 #3 }
2924 }
2925 \cs_new:Npn \__cs_generate_variant_loop_long:wNNnn #1 \s__cs_stop #2#3#4#5
2926 {
2927 \exp_not:n
2928 {
2929 \s__cs_mark
2930 \msg_error:nnee { kernel } { variant-too-long }
2931 {#5} { \token_to_str:N #3 }
2932 \use_none:nnn
2933 \s__cs_stop
2934 #3
2935 #3
2936 }
2937 }
2938 \cs_new:Npn \__cs_generate_variant_loop_invalid:NNwNNnn
2939 #1#2 \fi: \fi: \fi: #3 \s__cs_stop #4#5#6#7
2940 {
2941 \fi: \fi: \fi:
2942 \exp_not:n
2943 {
2944 \s__cs_mark
2945 \msg_error:nneeee { kernel } { invalid-variant }
2946 {#7} { \token_to_str:N #5 } {#1} {#2}
2947 \use_none:nnn
2948 \s__cs_stop
2949 #5
2950 #5
2951 }
2952 }
2953 \cs_new:Npn \__cs_generate_variant_loop_special:NNwNNnn
2954 #1#2#3 \s__cs_stop #4#5#6#7
2955 {
2956 #3 \s__cs_stop #4 #5 {#6} {#7}
2957 \exp_not:n
2958 {
2959 \msg_error:nneeee
2960 { kernel } { deprecated-variant }
2961 {#7} { \token_to_str:N #5 } {#1} {#2}
2962 }
2963 }
2964 \cs_new:Npn \__cs_generate_variant_same:N #1
2965 {
2966 \if:w N #1 #1 \else:
2967 \if:w p #1 #1 \else:
2968 \token_to_str:N n
2969 \if:w n #1 \else:
2970 \__cs_generate_variant_loop_special:NNwNNnn #1#1
2971 \fi:
2972 \fi:
2973 \fi:
2974 }
2975 \cs_new_protected:Npn \__cs_generate_variant:wwNN
2976 #1 \s__cs_mark #2 \s__cs_stop #3#4
2977 {
2978 #2
2979 \use_ii:nn #4
2980 {
2981 \if_meaning:w #3 #4
2982 \msg_error:nne { kernel } { variant-same-as-base }
2983 { \token_to_str:N #3 }
2984 \else:
2985 \cs_if_free:NT #4
2986 {
2987 \group_begin:
2988 \__cs_generate_internal_variant:n {#1}
2989 \__cs_tmp:w #4 { \exp_not:c { exp_args:N #1 } \exp_not:N #3 }
2990 \group_end:
2991 }
2992 \fi:
2993 }
2994 }
2995 \cs_new_protected:Npe \__cs_generate_internal_variant:n #1
2996 {
2997 \exp_not:N \__cs_generate_internal_variant:wwnNwn
2998 #1 \s__cs_mark
2999 { \cs_set_eq:NN \exp_not:N \__cs_tmp:w \cs_new_protected:Npe }
3000 \cs_new_protected:cpn
3001 \use:x
3002 \token_to_str:N x \s__cs_mark
3003 { }
3004 \cs_new:cpn
3005 \exp_not:N \tex_expanded:D
3006 \s__cs_stop
3007 {#1}
3008 }
3009 \exp_last_unbraced:NNNNo
3010 \cs_new_protected:Npn \__cs_generate_internal_variant:wwnNwn #1
3011 { \token_to_str:N x } #2 \s__cs_mark #3#4#5#6 \s__cs_stop #7
3012 {
3013 #3
3014 \cs_if_free:cT { exp_args:N #7 }
3015 { \__cs_generate_internal_variant:NNn #4 #5 {#7} }
3016 }
3017 \cs_set_protected:Npn \__cs_tmp:w #1
3018 {
3019 \cs_new_protected:Npn \__cs_generate_internal_variant:NNn ##1##2##3
3020 {
3021 \if_catcode:w X \use_none:nnnnnnnn ##3
3022 \prg_do_nothing: \prg_do_nothing: \prg_do_nothing:
3023 \prg_do_nothing: \prg_do_nothing: \prg_do_nothing:
3024 \prg_do_nothing: \prg_do_nothing: X
3025 \exp_after:wN \__cs_generate_internal_test:Nw \exp_after:wN ##2
3026 \else:
3027 \exp_after:wN \__cs_generate_internal_test_aux:w \exp_after:wN #1
3028 \fi:
3029 ##3
3030 \s__cs_mark
3031 {
3032 \use:e
3033 {
3034 ##1 { exp_args:N ##3 }
3035 { \__cs_generate_internal_variant_loop:n ##3 { : \use_i:nn } }
3036 }
3037 }
3038 #1
3039 \s__cs_mark
3040 { \exp_not:n { \__cs_generate_internal_one_go:NNn ##1 ##2 {##3} } }
3041 \s__cs_stop
3042 }
3043 \cs_new_protected:Npn \__cs_generate_internal_test_aux:w
3044 ##1 #1 ##2 \s__cs_mark ##3 ##4 \s__cs_stop {##3}
3045 \cs_new_eq:NN \__cs_generate_internal_test:Nw
3046 \__cs_generate_internal_test_aux:w
3047 }
3048 \exp_args:No \__cs_tmp:w { \token_to_str:N p }
3049 \cs_new_protected:Npn \__cs_generate_internal_one_go:NNn #1#2#3
3050 {
3051 \__cs_generate_internal_loop:nwnnw
3052 { \exp_not:N ##1 } 1 . { } { }
3053 #3 { ? \__cs_generate_internal_end:w } X ;
3054 23456789 { ? \__cs_generate_internal_long:w } ;
3055 #1 #2 {#3}
3056 }
3057 \cs_new_protected:Npn \__cs_generate_internal_loop:nwnnw #1#2 . #3#4#5#6 ; #7
3058 {
3059 \use_none:n #5
3060 \use_none:n #7
3061 \cs_if_exist_use:cF { __cs_generate_internal_#5:NN }
3062 { \__cs_generate_internal_other:NN }
3063 #5 #7
3064 #7 .
3065 { #3 #1 } { #4 ## #2 }
3066 #6 ;
3067 }
3068 \cs_new_protected:Npn \__cs_generate_internal_N:NN #1#2
3069 { \__cs_generate_internal_loop:nwnnw { \exp_not:N ###2 } }
3070 \cs_new_protected:Npn \__cs_generate_internal_c:NN #1#2
3071 { \exp_args:No \__cs_generate_internal_loop:nwnnw { \exp_not:c {###2} } }
3072 \cs_new_protected:Npn \__cs_generate_internal_n:NN #1#2
3073 { \__cs_generate_internal_loop:nwnnw { { \exp_not:n {###2} } } }
3074 \cs_new_protected:Npn \__cs_generate_internal_x:NN #1#2
3075 { \__cs_generate_internal_loop:nwnnw { {###2} } }
3076 \cs_new_protected:Npn \__cs_generate_internal_other:NN #1#2
3077 {
3078 \exp_args:No \__cs_generate_internal_loop:nwnnw
3079 {
3080 \exp_after:wN
3081 {
3082 \exp:w \exp_args:NNc \exp_after:wN \exp_end:
3083 { exp_not:#1 } {###2}
3084 }
3085 }
3086 }
3087 \cs_new_protected:Npn \__cs_generate_internal_end:w #1 . #2#3#4 ; #5 ; #6#7#8
3088 { #6 { exp_args:N #8 } #3 { #7 {#2} } }
3089 \cs_new_protected:Npn \__cs_generate_internal_long:w #1 N #2#3 . #4#5#6#
3090 {
3091 \exp_args:Nx \__cs_generate_internal_long:nnnNNn
3092 { \__cs_generate_internal_variant_loop:n #2 #6 { : \use_i:nn } }
3093 {#4} {#5}
3094 }
3095 \cs_new:Npn \__cs_generate_internal_long:nnnNNn #1#2#3#4 ; ; #5#6#7
3096 { #5 { exp_args:N #7 } #3 { #6 { \exp_not:n {#1} {#2} } } }
3097 \cs_new:Npn \__cs_generate_internal_variant_loop:n #1
3098 {
3099 \exp_after:wN \exp_not:N \cs:w :: #1 \cs_end:
3100 \__cs_generate_internal_variant_loop:n
3101 }
3102 \cs_new_protected:Npn \prg_generate_conditional_variant:Nnn #1
3103 {
3104 \use:e
3105 {
3106 \__cs_generate_variant:nnNnn
3107 \cs_split_function:N #1
3108 }
3109 }
3110 \cs_new_protected:Npn \__cs_generate_variant:nnNnn #1#2#3#4#5
3111 {
3112 \if_meaning:w \c_false_bool #3
3113 \msg_error:nne { kernel } { missing-colon }
3114 { \token_to_str:c {#1} }
3115 \__cs_use_i_delimit_by_s_stop:nw
3116 \fi:
3117 \exp_after:wN \__cs_generate_variant:w
3118 \tl_to_str:n {#5} , \scan_stop: , \q__cs_recursion_stop
3119 \__cs_use_none_delimit_by_s_stop:w \s__cs_mark {#1} {#2} {#4} \s__cs_stop
3120 }
3121 \cs_new_protected:Npn \__cs_generate_variant:w
3122 #1 , #2 \s__cs_mark #3#4#5
3123 {
3124 \if_meaning:w \scan_stop: #1 \scan_stop:
3125 \if_meaning:w \q__cs_nil #1 \q__cs_nil
3126 \use_i:nnn
3127 \fi:
3128 \exp_after:wN \__cs_use_none_delimit_by_q_recursion_stop:w
3129 \else:
3130 \cs_if_exist_use:cTF { __cs_generate_variant_#1_form:nnn }
3131 { {#3} {#4} {#5} }
3132 {
3133 \msg_error:nnee
3134 { kernel } { conditional-form-unknown }
3135 {#1} { \token_to_str:c { #3 : #4 } }
3136 }
3137 \fi:
3138 \__cs_generate_variant:w #2 \s__cs_mark {#3} {#4} {#5}
3139 }
3140 \cs_new_protected:Npn \__cs_generate_variant_p_form:nnn #1#2
3141 { \__cs_generate_variant_check:nn { #1 _p : #2 } }
3142 \cs_new_protected:Npn \__cs_generate_variant_T_form:nnn #1#2
3143 { \__cs_generate_variant_check:nn { #1 : #2 T } }
3144 \cs_new_protected:Npn \__cs_generate_variant_F_form:nnn #1#2
3145 { \__cs_generate_variant_check:nn { #1 : #2 F } }
3146 \cs_new_protected:Npn \__cs_generate_variant_TF_form:nnn #1#2
3147 { \__cs_generate_variant_check:nn { #1 : #2 TF } }
3148 \cs_new_protected:Npn \__cs_generate_variant_check:nn #1#2
3149 {
3150 \cs_if_exist:cTF {#1}
3151 { \cs_generate_variant:cn {#1} {#2} }
3152 {
3153 \msg_error:nne
3154 { kernel } { conditional-base-undefined }
3155 { \token_to_str:c {#1} }
3156 }
3157 }
3158 \cs_new_protected:Npn \exp_args_generate:n #1
3159 {
3160 \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#1} }
3161 {
3162 \str_map_inline:nn {##1}
3163 {
3164 \str_if_in:nnF { NnpcofeVvx } {####1}
3165 {
3166 \msg_error:nnnn { kernel } { invalid-exp-args }
3167 {####1} {##1}
3168 \str_map_break:n { \use_none:nn }
3169 }
3170 }
3171 \__cs_generate_internal_variant:n {##1}
3172 }
3173 }
3174 \cs_set_protected:Npn \__cs_tmp:w #1
3175 {
3176 \group_begin:
3177 \exp_args:No \__cs_generate_internal_variant:n
3178 { \tl_to_str:n {#1} }
3179 \group_end:
3180 }
3181 \__cs_tmp:w { nc }
3182 \__cs_tmp:w { no }
3183 \__cs_tmp:w { nV }
3184 \__cs_tmp:w { nv }
3185 \__cs_tmp:w { ne }
3186 \__cs_tmp:w { nf }
3187 \__cs_tmp:w { oc }
3188 \__cs_tmp:w { oo }
3189 \__cs_tmp:w { of }
3190 \__cs_tmp:w { Vo }
3191 \__cs_tmp:w { fo }
3192 \__cs_tmp:w { ff }
3193 \__cs_tmp:w { ee }
3194 \__cs_tmp:w { Nx }
3195 \__cs_tmp:w { cx }
3196 \__cs_tmp:w { nx }
3197 \__cs_tmp:w { ox }
3198 \__cs_tmp:w { xo }
3199 \__cs_tmp:w { xx }
3200 \__cs_tmp:w { Ncf }
3201 \__cs_tmp:w { Nno }
3202 \__cs_tmp:w { NnV }
3203 \__cs_tmp:w { Noo }
3204 \__cs_tmp:w { NVV }
3205 \__cs_tmp:w { cno }
3206 \__cs_tmp:w { cnV }
3207 \__cs_tmp:w { coo }
3208 \__cs_tmp:w { cVV }
3209 \__cs_tmp:w { nnc }
3210 \__cs_tmp:w { nno }
3211 \__cs_tmp:w { nnf }
3212 \__cs_tmp:w { nff }
3213 \__cs_tmp:w { ooo }
3214 \__cs_tmp:w { oof }
3215 \__cs_tmp:w { ffo }
3216 \__cs_tmp:w { eee }
3217 \__cs_tmp:w { NNx }
3218 \__cs_tmp:w { Nnx }
3219 \__cs_tmp:w { Nox }
3220 \__cs_tmp:w { nnx }
3221 \__cs_tmp:w { nox }
3222 \__cs_tmp:w { ccx }
3223 \__cs_tmp:w { cnx }
3224 \__cs_tmp:w { oox }
3225 \cs_generate_variant:Nn \cs_generate_from_arg_count:NNnn { NNno }
3226 \cs_generate_variant:Nn \cs_replacement_spec:N { c }
3227 \cs_generate_variant:Nn \debug_assert:nNn { nNe }
3228 \cs_generate_variant:Nn \debug_assert:nnn { nne }
3229 %% File: l3quark.dtx
3230 \cs_new_protected:Npn \quark_new:N #1
3231 {
3232 \__kernel_chk_if_free_cs:N #1
3233 \cs_gset_nopar:Npn #1 {#1}
3234 }
3235 \quark_new:N \q_nil
3236 \quark_new:N \q_mark
3237 \quark_new:N \q_no_value
3238 \quark_new:N \q_stop
3239 \quark_new:N \q_recursion_tail
3240 \quark_new:N \q_recursion_stop
3241 \cs_new_eq:NN \s__quark \scan_stop:
3242 \quark_new:N \q__quark_nil
3243 \cs_new:Npn \quark_if_recursion_tail_stop:N #1
3244 {
3245 \if_meaning:w \q_recursion_tail #1
3246 \exp_after:wN \use_none_delimit_by_q_recursion_stop:w
3247 \fi:
3248 }
3249 \cs_new:Npn \quark_if_recursion_tail_stop_do:Nn #1
3250 {
3251 \if_meaning:w \q_recursion_tail #1
3252 \exp_after:wN \use_i_delimit_by_q_recursion_stop:nw
3253 \else:
3254 \exp_after:wN \use_none:n
3255 \fi:
3256 }
3257 \cs_new:Npn \quark_if_recursion_tail_stop:n #1
3258 {
3259 \tl_if_empty:oTF
3260 { \__quark_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! }
3261 { \use_none_delimit_by_q_recursion_stop:w }
3262 { }
3263 }
3264 \cs_new:Npn \quark_if_recursion_tail_stop_do:nn #1
3265 {
3266 \tl_if_empty:oTF
3267 { \__quark_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! }
3268 { \use_i_delimit_by_q_recursion_stop:nw }
3269 { \use_none:n }
3270 }
3271 \cs_new:Npn \__quark_if_recursion_tail:w
3272 #1 \q_recursion_tail #2 ? #3 ?! { #1 #2 }
3273 \cs_generate_variant:Nn \quark_if_recursion_tail_stop:n { o }
3274 \cs_generate_variant:Nn \quark_if_recursion_tail_stop_do:nn { o }
3275 \cs_new:Npn \quark_if_recursion_tail_break:NN #1#2
3276 {
3277 \if_meaning:w \q_recursion_tail #1
3278 \exp_after:wN #2
3279 \fi:
3280 }
3281 \cs_new:Npn \quark_if_recursion_tail_break:nN #1#2
3282 {
3283 \tl_if_empty:oT
3284 { \__quark_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! }
3285 {#2}
3286 }
3287 \prg_new_conditional:Npnn \quark_if_nil:N #1 { p, T , F , TF }
3288 {
3289 \if_meaning:w \q_nil #1
3290 \prg_return_true:
3291 \else:
3292 \prg_return_false:
3293 \fi:
3294 }
3295 \prg_new_conditional:Npnn \quark_if_no_value:N #1 { p, T , F , TF }
3296 {
3297 \if_meaning:w \q_no_value #1
3298 \prg_return_true:
3299 \else:
3300 \prg_return_false:
3301 \fi:
3302 }
3303 \prg_generate_conditional_variant:Nnn \quark_if_no_value:N
3304 { c } { p , T , F , TF }
3305 \prg_new_conditional:Npnn \quark_if_nil:n #1 { p, T , F , TF }
3306 {
3307 \__quark_if_empty_if:o
3308 { \__quark_if_nil:w {} #1 {} ? ! \q_nil ? ? ! }
3309 \prg_return_true:
3310 \else:
3311 \prg_return_false:
3312 \fi:
3313 }
3314 \cs_new:Npn \__quark_if_nil:w #1 \q_nil #2 ? #3 ? ! { #1 #2 }
3315 \prg_new_conditional:Npnn \quark_if_no_value:n #1 { p, T , F , TF }
3316 {
3317 \__quark_if_empty_if:o
3318 { \__quark_if_no_value:w {} #1 {} ? ! \q_no_value ? ? ! }
3319 \prg_return_true:
3320 \else:
3321 \prg_return_false:
3322 \fi:
3323 }
3324 \cs_new:Npn \__quark_if_no_value:w #1 \q_no_value #2 ? #3 ? ! { #1 #2 }
3325 \prg_generate_conditional_variant:Nnn \quark_if_nil:n
3326 { V , o } { p , TF , T , F }
3327 \cs_new:Npn \__quark_if_empty_if:o #1
3328 {
3329 \exp_after:wN \if_meaning:w \exp_after:wN \q_nil
3330 \__kernel_tl_to_str:w \exp_after:wN {#1} \q_nil
3331 }
3332 \cs_new_protected:Npn \__kernel_quark_new_test:N #1
3333 { \__quark_new_test_aux:Ne #1 { \__quark_module_name:N #1 } }
3334 \cs_new_protected:Npn \__quark_new_test_aux:Nn #1 #2
3335 {
3336 \if_meaning:w \q_nil #2 \q_nil
3337 \msg_error:nne { quark } { invalid-function }
3338 { \token_to_str:N #1 }
3339 \else:
3340 \__quark_new_test:Nccn #1
3341 { q__#2_recursion_tail } { q__#2_recursion_stop } { __#2 }
3342 \fi:
3343 }
3344 \cs_generate_variant:Nn \__quark_new_test_aux:Nn { Ne }
3345 \cs_new_protected:Npn \__quark_new_test:NNNn #1
3346 {
3347 \exp_last_unbraced:Nf \__quark_new_test_aux:nnNNnnnn
3348 { \cs_split_function:N #1 }
3349 #1 { test }
3350 }
3351 \cs_generate_variant:Nn \__quark_new_test:NNNn { Ncc }
3352 \cs_new_protected:Npn \__kernel_quark_new_conditional:Nn #1
3353 {
3354 \__quark_new_conditional:Neen #1
3355 { \__quark_quark_conditional_name:N #1 }
3356 { \__quark_module_name:N #1 }
3357 }
3358 \cs_new_protected:Npn \__quark_new_conditional:Nnnn #1#2#3#4
3359 {
3360 \if_meaning:w \q_nil #2 \q_nil
3361 \msg_error:nne { quark } { invalid-function }
3362 { \token_to_str:N #1 }
3363 \else:
3364 \if_meaning:w \q_nil #3 \q_nil
3365 \msg_error:nne { quark } { invalid-function }
3366 { \token_to_str:N #1 }
3367 \else:
3368 \exp_last_unbraced:Nf \__quark_new_test_aux:nnNNnnnn
3369 { \cs_split_function:N #1 }
3370 #1 { conditional }
3371 {#2} {#3} {#4}
3372 \fi:
3373 \fi:
3374 }
3375 \cs_generate_variant:Nn \__quark_new_conditional:Nnnn { Nee }
3376 \cs_new_protected:Npn \__quark_new_test_aux:nnNNnnnn #1 #2 #3 #4 #5
3377 {
3378 \cs_if_exist_use:cTF { __quark_new_#5_#2:Nnnn } { #4 }
3379 {
3380 \msg_error:nnee { quark } { invalid-function }
3381 { \token_to_str:N #4 } {#2}
3382 \use_none:nnn
3383 }
3384 }
3385 \cs_new_protected:Npn \__quark_new_test_n:Nnnn #1 #2 #3 #4
3386 {
3387 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { none } { } { } { }
3388 \__quark_new_test_define_tl:nNnNNn #1 { }
3389 }
3390 \cs_new_protected:Npn \__quark_new_test_nn:Nnnn #1 #2 #3 #4
3391 {
3392 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { i } { n } {##1} {##2}
3393 \__quark_new_test_define_tl:nNnNNn #1 { \use_none:n }
3394 }
3395 \cs_new_protected:Npn \__quark_new_test_nN:Nnnn #1 #2 #3 #4
3396 {
3397 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { i } { n } {##1} {##2}
3398 \__quark_new_test_define_break_tl:nNNNNn #1 { }
3399 }
3400 \cs_new_protected:Npn \__quark_new_test_N:Nnnn #1 #2 #3 #4
3401 {
3402 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { none } { } { } { }
3403 \__quark_new_test_define_ifx:nNnNNn #1 { }
3404 }
3405 \cs_new_protected:Npn \__quark_new_test_Nn:Nnnn #1 #2 #3 #4
3406 {
3407 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { i } { n } {##1} {##2}
3408 \__quark_new_test_define_ifx:nNnNNn #1
3409 { \else: \exp_after:wN \use_none:n }
3410 }
3411 \cs_new_protected:Npn \__quark_new_test_NN:Nnnn #1 #2 #3 #4
3412 {
3413 \__quark_new_test_aux_do:nNNnnnnNNn {#4} #2 #3 { i } { n } {##1} {##2}
3414 \__quark_new_test_define_break_ifx:nNNNNn #1 { }
3415 }
3416 \cs_new_protected:Npn \__quark_new_test_aux_do:nNNnnnnNNn #1 #2 #3 #4 #5
3417 {
3418 \exp_args:Ncc \__quark_test_define_aux:NNNNnnNNn
3419 { #1 _quark_recursion_tail:w }
3420 { #1 _use_ #4 _delimit_by_q_recursion_stop: #5 w }
3421 #2 #3
3422 }
3423 \cs_new_protected:Npn \__quark_test_define_aux:NNNNnnNNn #1 #2 #3 #4 #5 #6 #7
3424 {
3425 \cs_gset:Npn #1 ##1 #3 ##2 ? ##3 ?! { ##1 ##2 }
3426 \cs_gset:Npn #2 ##1 #6 #4 {#5}
3427 #7 {##1} #1 #2 #3
3428 }
3429 \cs_new_protected:Npn \__quark_new_test_define_tl:nNnNNn #1 #2 #3 #4 #5 #6
3430 {
3431 \cs_new:Npn #5 #1
3432 {
3433 \tl_if_empty:oTF
3434 { #2 {} ##1 {} ?! #4 ??! }
3435 {#3} {#6}
3436 }
3437 }
3438 \cs_new_protected:Npn \__quark_new_test_define_ifx:nNnNNn #1 #2 #3 #4 #5 #6
3439 {
3440 \cs_new:Npn #5 #1
3441 {
3442 \if_meaning:w #4 ##1
3443 \exp_after:wN #3
3444 #6
3445 \fi:
3446 }
3447 }
3448 \cs_new_protected:Npn \__quark_new_test_define_break_tl:nNNNNn #1 #2 #3
3449 { \__quark_new_test_define_tl:nNnNNn {##1##2} #2 {##2} }
3450 \cs_new_protected:Npn \__quark_new_test_define_break_ifx:nNNNNn #1 #2 #3
3451 { \__quark_new_test_define_ifx:nNnNNn {##1##2} #2 {##2} }
3452 \cs_new_protected:Npn \__quark_new_conditional_n:Nnnn #1 #2 #3
3453 {
3454 \exp_args:Ncc \__quark_new_conditional_n_aux:NNNn
3455 { __ #3 _if_quark_ #2 :w } { q__ #3 _ #2 } #1
3456 }
3457 \cs_new_protected:Npn \__quark_new_conditional_N:Nnnn #1 #2 #3
3458 {
3459 \exp_args:NNc \__quark_new_conditional_N_aux:NNNn
3460 \prg_do_nothing: { q__ #3 _ #2 } #1
3461 }
3462 \cs_new_protected:Npn \__quark_new_conditional_n_aux:NNNn #1 #2 #3 #4
3463 {
3464 \cs_gset:Npn #1 ##1 #2 ##2 ? ##3 ?! { ##1##2 }
3465 \prg_new_conditional:Npnn #3 ##1 {#4}
3466 {
3467 \__quark_if_empty_if:o { #1 {} ##1 {} ?! #2 ??! }
3468 \prg_return_true:
3469 \else:
3470 \prg_return_false:
3471 \fi:
3472 }
3473 }
3474 \cs_new_protected:Npn \__quark_new_conditional_N_aux:NNNn #1 #2 #3 #4
3475 {
3476 \prg_new_conditional:Npnn #3 ##1 {#4}
3477 {
3478 \if_meaning:w #2 ##1
3479 \prg_return_true:
3480 \else:
3481 \prg_return_false:
3482 \fi:
3483 }
3484 }
3485 \cs_set:Npn \__quark_tmp:w #1#2
3486 {
3487 \cs_new:Npn \__quark_module_name:N ##1
3488 {
3489 \exp_last_unbraced:Nf \__quark_module_name:w
3490 { \cs_to_str:N ##1 } #1 \s__quark
3491 }
3492 \cs_new:Npn \__quark_module_name:w ##1 #1 ##2 \s__quark
3493 { \__quark_module_name_loop:w ##1 #2 \use_none:n { } #2 \s__quark }
3494 \cs_new:Npn \__quark_module_name_loop:w ##1 #2
3495 {
3496 \use_i_ii:nnn \if_meaning:w \prg_do_nothing:
3497 ##1 \prg_do_nothing: \prg_do_nothing:
3498 \exp_after:wN \__quark_module_name_loop:w
3499 \else:
3500 \__quark_module_name_end:w ##1
3501 \fi:
3502 }
3503 \cs_new:Npn \__quark_module_name_end:w
3504 ##1 \fi: ##2 \s__quark { \fi: ##1 }
3505 }
3506 \exp_after:wN \__quark_tmp:w \tl_to_str:n { : _ }
3507 \cs_set:Npn \__quark_tmp:w #1 #2 \s__quark
3508 {
3509 \cs_new:Npn \__quark_quark_conditional_name:N ##1
3510 {
3511 \exp_last_unbraced:Nf \__quark_quark_conditional_name:w
3512 { \cs_to_str:N ##1 } #1 #2 #1 \s__quark
3513 }
3514 \cs_new:Npn \__quark_quark_conditional_name:w
3515 ##1 #2 ##2 #1 ##3 \s__quark {##2}
3516 }
3517 \exp_after:wN \__quark_tmp:w \tl_to_str:n { : _quark_if_ } \s__quark
3518 \cs_new_protected:Npn \scan_new:N #1
3519 {
3520 \tl_if_in:NnTF \g__scan_marks_tl { #1 }
3521 {
3522 \msg_error:nne { scanmark } { already-defined }
3523 { \token_to_str:N #1 }
3524 }
3525 {
3526 \tl_gput_right:Nn \g__scan_marks_tl {#1}
3527 \cs_new_eq:NN #1 \scan_stop:
3528 }
3529 }
3530 \cs_new_eq:NN \s_stop \scan_stop:
3531 \cs_gset_nopar:Npn \g__scan_marks_tl
3532 {
3533 \s_stop
3534 \s__quark
3535 \s__cs_mark
3536 \s__cs_stop
3537 }
3538 \cs_new:Npn \use_none_delimit_by_s_stop:w #1 \s_stop { }
3539 %% File: l3tl.dtx
3540 \cs_new_eq:NN \__kernel_tl_set:Nx \cs_set_nopar:Npe
3541 \cs_new_eq:NN \__kernel_tl_gset:Nx \cs_gset_nopar:Npe
3542 \cs_new_protected:Npn \tl_new:N #1
3543 {
3544 \__kernel_chk_if_free_cs:N #1
3545 \cs_gset_eq:NN #1 \c_empty_tl
3546 }
3547 \cs_generate_variant:Nn \tl_new:N { c }
3548 \cs_new_protected:Npn \tl_const:Nn #1#2
3549 {
3550 \__kernel_chk_if_free_cs:N #1
3551 \cs_gset_nopar:Npe #1 { \__kernel_exp_not:w {#2} }
3552 }
3553 \cs_generate_variant:Nn \tl_const:Nn { NV , Ne , c , cV , ce }
3554 \cs_generate_variant:Nn \tl_const:Nn { Nx , cx }
3555 \cs_new_protected:Npn \tl_clear:N #1
3556 { \tex_let:D #1 = ~ \c_empty_tl }
3557 \cs_new_protected:Npn \tl_gclear:N #1
3558 { \tex_global:D \tex_let:D #1 ~ \c_empty_tl }
3559 \cs_generate_variant:Nn \tl_clear:N { c }
3560 \cs_generate_variant:Nn \tl_gclear:N { c }
3561 \cs_new_protected:Npn \tl_clear_new:N #1
3562 { \tl_if_exist:NTF #1 { \tl_clear:N #1 } { \tl_new:N #1 } }
3563 \cs_new_protected:Npn \tl_gclear_new:N #1
3564 { \tl_if_exist:NTF #1 { \tl_gclear:N #1 } { \tl_new:N #1 } }
3565 \cs_generate_variant:Nn \tl_clear_new:N { c }
3566 \cs_generate_variant:Nn \tl_gclear_new:N { c }
3567 \cs_new_protected:Npn \tl_set_eq:NN #1#2
3568 { \tex_let:D #1 = ~ #2 }
3569 \cs_new_protected:Npn \tl_gset_eq:NN #1#2
3570 { \tex_global:D \tex_let:D #1 = ~ #2 }
3571 \cs_generate_variant:Nn \tl_set_eq:NN { cN, Nc, cc }
3572 \cs_generate_variant:Nn \tl_gset_eq:NN { cN, Nc, cc }
3573 \cs_new_protected:Npn \tl_concat:NNN #1#2#3
3574 {
3575 \__kernel_tl_set:Nx #1
3576 {
3577 \__kernel_exp_not:w \exp_after:wN {#2}
3578 \__kernel_exp_not:w \exp_after:wN {#3}
3579 }
3580 }
3581 \cs_new_protected:Npn \tl_gconcat:NNN #1#2#3
3582 {
3583 \__kernel_tl_gset:Nx #1
3584 {
3585 \__kernel_exp_not:w \exp_after:wN {#2}
3586 \__kernel_exp_not:w \exp_after:wN {#3}
3587 }
3588 }
3589 \cs_generate_variant:Nn \tl_concat:NNN { ccc }
3590 \cs_generate_variant:Nn \tl_gconcat:NNN { ccc }
3591 \prg_new_eq_conditional:NNn \tl_if_exist:N \cs_if_exist:N { TF , T , F , p }
3592 \prg_new_eq_conditional:NNn \tl_if_exist:c \cs_if_exist:c { TF , T , F , p }
3593 \tl_const:Nn \c_empty_tl { }
3594 \group_begin:
3595 \tex_catcode:D `- = 11 ~
3596 \tl_const:Ne \c_novalue_tl { - NoValue \token_to_str:N - }
3597 \group_end:
3598 \tl_const:Nn \c_space_tl { ~ }
3599 \cs_new_protected:Npn \tl_set:Nn #1#2
3600 { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w {#2} } }
3601 \cs_new_protected:Npn \tl_set:No #1#2
3602 { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#2} } }
3603 \cs_new_protected:Npn \tl_gset:Nn #1#2
3604 { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w {#2} } }
3605 \cs_new_protected:Npn \tl_gset:No #1#2
3606 { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w \exp_after:wN {#2} } }
3607 \cs_generate_variant:Nn \tl_set:Nn { NV , Nv , Ne , Nf }
3608 \cs_generate_variant:Nn \tl_set:Nn { c, cV , cv , ce , cf }
3609 \cs_generate_variant:Nn \tl_set:No { c }
3610 \cs_generate_variant:Nn \tl_set:Nn { Nx , cx }
3611 \cs_generate_variant:Nn \tl_gset:Nn { NV , Nv , Ne , Nf }
3612 \cs_generate_variant:Nn \tl_gset:Nn { c, cV , cv , ce , cf }
3613 \cs_generate_variant:Nn \tl_gset:No { c }
3614 \cs_generate_variant:Nn \tl_gset:Nn { Nx , cx }
3615 \cs_new_protected:Npn \tl_put_left:Nn #1#2
3616 {
3617 \__kernel_tl_set:Nx #1
3618 { \__kernel_exp_not:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
3619 }
3620 \cs_new_protected:Npn \tl_put_left:NV #1#2
3621 {
3622 \__kernel_tl_set:Nx #1
3623 { \exp_not:V #2 \__kernel_exp_not:w \exp_after:wN {#1} }
3624 }
3625 \cs_new_protected:Npn \tl_put_left:Nv #1#2
3626 {
3627 \__kernel_tl_set:Nx #1
3628 { \exp_not:v {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
3629 }
3630 \cs_new_protected:Npn \tl_put_left:Ne #1#2
3631 {
3632 \__kernel_tl_set:Nx #1
3633 {
3634 \__kernel_exp_not:w \tex_expanded:D { {#2} }
3635 \__kernel_exp_not:w \exp_after:wN {#1}
3636 }
3637 }
3638 \cs_new_protected:Npn \tl_put_left:No #1#2
3639 {
3640 \__kernel_tl_set:Nx #1
3641 {
3642 \__kernel_exp_not:w \exp_after:wN {#2}
3643 \__kernel_exp_not:w \exp_after:wN {#1}
3644 }
3645 }
3646 \cs_new_protected:Npn \tl_gput_left:Nn #1#2
3647 {
3648 \__kernel_tl_gset:Nx #1
3649 { \__kernel_exp_not:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
3650 }
3651 \cs_new_protected:Npn \tl_gput_left:NV #1#2
3652 {
3653 \__kernel_tl_gset:Nx #1
3654 { \exp_not:V #2 \__kernel_exp_not:w \exp_after:wN {#1} }
3655 }
3656 \cs_new_protected:Npn \tl_gput_left:Nv #1#2
3657 {
3658 \__kernel_tl_gset:Nx #1
3659 { \exp_not:v {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
3660 }
3661 \cs_new_protected:Npn \tl_gput_left:Ne #1#2
3662 {
3663 \__kernel_tl_gset:Nx #1
3664 {
3665 \__kernel_exp_not:w \tex_expanded:D { {#2} }
3666 \__kernel_exp_not:w \exp_after:wN {#1}
3667 }
3668 }
3669 \cs_new_protected:Npn \tl_gput_left:No #1#2
3670 {
3671 \__kernel_tl_gset:Nx #1
3672 {
3673 \__kernel_exp_not:w \exp_after:wN {#2}
3674 \__kernel_exp_not:w \exp_after:wN {#1}
3675 }
3676 }
3677 \cs_generate_variant:Nn \tl_put_left:Nn { c }
3678 \cs_generate_variant:Nn \tl_put_left:NV { c }
3679 \cs_generate_variant:Nn \tl_put_left:Nv { c }
3680 \cs_generate_variant:Nn \tl_put_left:Ne { c }
3681 \cs_generate_variant:Nn \tl_put_left:No { c }
3682 \cs_generate_variant:Nn \tl_put_left:Nn { Nx, cx }
3683 \cs_generate_variant:Nn \tl_gput_left:Nn { c }
3684 \cs_generate_variant:Nn \tl_gput_left:NV { c }
3685 \cs_generate_variant:Nn \tl_gput_left:Nv { c }
3686 \cs_generate_variant:Nn \tl_gput_left:Ne { c }
3687 \cs_generate_variant:Nn \tl_gput_left:No { c }
3688 \cs_generate_variant:Nn \tl_gput_left:Nn { Nx , cx }
3689 \cs_new_protected:Npn \tl_put_right:Nn #1#2
3690 { \__kernel_tl_set:Nx #1 { \__kernel_exp_not:w \exp_after:wN { #1 #2 } } }
3691 \cs_new_protected:Npn \tl_put_right:NV #1#2
3692 {
3693 \__kernel_tl_set:Nx #1
3694 { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:V #2 }
3695 }
3696 \cs_new_protected:Npn \tl_put_right:Nv #1#2
3697 {
3698 \__kernel_tl_set:Nx #1
3699 { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:v {#2} }
3700 }
3701 \cs_new_protected:Npn \tl_put_right:Ne #1#2
3702 {
3703 \__kernel_tl_set:Nx #1
3704 {
3705 \__kernel_exp_not:w \exp_after:wN {#1}
3706 \__kernel_exp_not:w \tex_expanded:D { {#2} }
3707 }
3708 }
3709 \cs_new_protected:Npn \tl_put_right:No #1#2
3710 {
3711 \__kernel_tl_set:Nx #1
3712 {
3713 \__kernel_exp_not:w \exp_after:wN {#1}
3714 \__kernel_exp_not:w \exp_after:wN {#2}
3715 }
3716 }
3717 \cs_new_protected:Npn \tl_gput_right:Nn #1#2
3718 { \__kernel_tl_gset:Nx #1 { \__kernel_exp_not:w \exp_after:wN { #1 #2 } } }
3719 \cs_new_protected:Npn \tl_gput_right:NV #1#2
3720 {
3721 \__kernel_tl_gset:Nx #1
3722 { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:V #2 }
3723 }
3724 \cs_new_protected:Npn \tl_gput_right:Nv #1#2
3725 {
3726 \__kernel_tl_gset:Nx #1
3727 { \__kernel_exp_not:w \exp_after:wN {#1} \exp_not:v {#2} }
3728 }
3729 \cs_new_protected:Npn \tl_gput_right:Ne #1#2
3730 {
3731 \__kernel_tl_gset:Nx #1
3732 {
3733 \__kernel_exp_not:w \exp_after:wN {#1}
3734 \__kernel_exp_not:w \tex_expanded:D { {#2} }
3735 }
3736 }
3737 \cs_new_protected:Npn \tl_gput_right:No #1#2
3738 {
3739 \__kernel_tl_gset:Nx #1
3740 {
3741 \__kernel_exp_not:w \exp_after:wN {#1}
3742 \__kernel_exp_not:w \exp_after:wN {#2}
3743 }
3744 }
3745 \cs_generate_variant:Nn \tl_put_right:Nn { c }
3746 \cs_generate_variant:Nn \tl_put_right:NV { c }
3747 \cs_generate_variant:Nn \tl_put_right:Nv { c }
3748 \cs_generate_variant:Nn \tl_put_right:Ne { c }
3749 \cs_generate_variant:Nn \tl_put_right:No { c }
3750 \cs_generate_variant:Nn \tl_put_right:Nn { Nx , cx }
3751 \cs_generate_variant:Nn \tl_gput_right:Nn { c }
3752 \cs_generate_variant:Nn \tl_gput_right:NV { c }
3753 \cs_generate_variant:Nn \tl_gput_right:Nv { c }
3754 \cs_generate_variant:Nn \tl_gput_right:Ne { c }
3755 \cs_generate_variant:Nn \tl_gput_right:No { c }
3756 \cs_generate_variant:Nn \tl_gput_right:Nn { Nx, cx }
3757 \quark_new:N \q__tl_nil
3758 \quark_new:N \q__tl_mark
3759 \quark_new:N \q__tl_stop
3760 \quark_new:N \q__tl_recursion_tail
3761 \quark_new:N \q__tl_recursion_stop
3762 \__kernel_quark_new_test:N \__tl_if_recursion_tail_break:nN
3763 \__kernel_quark_new_conditional:Nn \__tl_quark_if_nil:n { TF }
3764 \tl_const:Ne \c__tl_rescan_marker_tl { : \token_to_str:N : }
3765 \cs_new_protected:Npn \tl_rescan:nn #1#2
3766 {
3767 \tl_set_rescan:Nnn \l__tl_tmpa_tl {#1} {#2}
3768 \exp_after:wN \__tl_rescan_aux:
3769 \l__tl_tmpa_tl
3770 }
3771 \cs_generate_variant:Nn \tl_rescan:nn { nV }
3772 \exp_args:NNo \cs_new_protected:Npn \__tl_rescan_aux:
3773 { \tl_clear:N \l__tl_tmpa_tl }
3774 \cs_new_protected:Npn \tl_set_rescan:Nnn
3775 { \__tl_set_rescan:NNnn \tl_set:No }
3776 \cs_new_protected:Npn \tl_gset_rescan:Nnn
3777 { \__tl_set_rescan:NNnn \tl_gset:No }
3778 \cs_new_protected:Npn \__tl_set_rescan:NNnn #1#2#3#4
3779 {
3780 \group_begin:
3781 \if_false: { \fi:
3782 \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
3783 \int_compare:nNnT \tex_endlinechar:D = { 32 }
3784 { \int_set:Nn \tex_endlinechar:D { -1 } }
3785 \int_set_eq:NN \tex_newlinechar:D \tex_endlinechar:D
3786 #3 \scan_stop:
3787 \exp_args:No \__tl_set_rescan:nNN { \tl_to_str:n {#4} } #1 #2
3788 \if_false: } \fi:
3789 }
3790 \cs_new_protected:Npn \__tl_set_rescan_multi:nNN #1#2#3
3791 {
3792 \tex_everyeof:D \exp_after:wN { \c__tl_rescan_marker_tl }
3793 \exp_after:wN \__tl_rescan:NNw
3794 \exp_after:wN #2
3795 \exp_after:wN #3
3796 \exp_after:wN \prg_do_nothing:
3797 \tex_scantokens:D {#1}
3798 }
3799 \exp_args:Nno \use:nn
3800 { \cs_new:Npn \__tl_rescan:NNw #1#2#3 } \c__tl_rescan_marker_tl
3801 {
3802 \group_end:
3803 #1 #2 {#3}
3804 }
3805 \cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV , Nne , c , cnV , cne }
3806 \cs_generate_variant:Nn \tl_set_rescan:Nnn { Nno , Nnx , cno , cnx }
3807 \cs_generate_variant:Nn \tl_gset_rescan:Nnn { NnV , Nne , c , cnV , cne }
3808 \cs_generate_variant:Nn \tl_gset_rescan:Nnn { Nno , Nnx , cno , cnx }
3809 \cs_new_protected:Npn \__tl_set_rescan:nNN #1
3810 {
3811 \int_compare:nNnTF \tex_newlinechar:D < 0
3812 { \use_ii:nn }
3813 {
3814 \exp_args:Nnf \tl_if_in:nnTF {#1}
3815 { \char_generate:nn { \tex_newlinechar:D } { 12 } }
3816 }
3817 { \__tl_set_rescan_multi:nNN }
3818 {
3819 \int_set:Nn \tex_endlinechar:D { -1 }
3820 \__tl_set_rescan_single:nnNN { `' }
3821 }
3822 {#1}
3823 }
3824 \cs_new_protected:Npn \__tl_set_rescan_single:nnNN #1
3825 {
3826 \int_compare:nNnTF
3827 { \char_value_catcode:n {#1} / 2 } = 6
3828 {
3829 \exp_args:Nof \__tl_set_rescan_single_aux:nnnNN
3830 \c__tl_rescan_marker_tl
3831 { \char_generate:nn {#1} { \char_value_catcode:n {#1} } }
3832 }
3833 {
3834 \int_compare:nNnTF {#1} < { `\~ }
3835 {
3836 \exp_args:Nf \__tl_set_rescan_single:nnNN
3837 { \int_eval:n { #1 + 1 } }
3838 }
3839 { \__tl_set_rescan_multi:nNN }
3840 }
3841 }
3842 \cs_new_protected:Npn \__tl_set_rescan_single_aux:nnnNN #1#2#3#4#5
3843 {
3844 \tex_everyeof:D
3845 {
3846 #1 \use_none:n
3847 #2 #1 { \exp:w \__tl_set_rescan_single_aux:w }
3848 \s__tl_stop
3849 }
3850 \cs_set:Npn \__tl_rescan:NNw ##1##2##3 #2 #1 ##4 ##5 \s__tl_stop
3851 {
3852 \group_end:
3853 ##1 ##2 { ##4 ##3 }
3854 }
3855 \exp_after:wN \__tl_rescan:NNw
3856 \exp_after:wN #4
3857 \exp_after:wN #5
3858 \tex_scantokens:D { #2 #3 #2 }
3859 }
3860 \exp_args:Nno \use:nn
3861 { \cs_new:Npn \__tl_set_rescan_single_aux:w #1 }
3862 \c__tl_rescan_marker_tl #2
3863 { \use_i:nn \exp_end: #1 }
3864 \cs_if_exist:NT \tex_scantextokens:D
3865 {
3866 \cs_gset_protected:Npn \tl_set_rescan:Nnn
3867 { \__tl_set_rescan:NNnn \tl_set:Nn }
3868 \cs_gset_protected:Npn \tl_gset_rescan:Nnn
3869 { \__tl_set_rescan:NNnn \tl_gset:Nn }
3870 \cs_gset_protected:Npn \__tl_set_rescan_single:nnNN #1
3871 {
3872 \int_compare:nNnTF
3873 { \char_value_catcode:n {#1} / 2 } = 6
3874 {
3875 \exp_args:Nf \__tl_set_rescan_single_aux:nnNN
3876 { \char_generate:nn {#1} { \char_value_catcode:n {#1} } }
3877 }
3878 {
3879 \int_compare:nNnTF {#1} < { `\~ }
3880 {
3881 \exp_args:Nf \__tl_set_rescan_single:nnNN
3882 { \int_eval:n { #1 + 1 } }
3883 }
3884 { \__tl_set_rescan_multi:nNN }
3885 }
3886 }
3887 \cs_new_protected:Npn \__tl_set_rescan_aux:w #1
3888 {
3889 \cs_new_protected:Npn \__tl_set_rescan_single_aux:nnNN ##1##2##3##4
3890 {
3891 \tl_set:No \l__tl_tmpa_tl { \tex_scantextokens:D { ##1 ##2 ##1 } }
3892 \cs_set_protected:Npn \__tl_set_rescan:w
3893 ####1 ##1 #1 ####2 #1 ####3 \s__tl_stop
3894 {
3895 \tl_if_blank:nTF {####3}
3896 { \__tl_set_rescan_aux:w ####1 \s__tl_stop }
3897 { \tl_set:No \l__tl_tmpa_tl { \use_none:n ####1 } }
3898 }
3899 \exp_after:wN \__tl_set_rescan:w \l__tl_tmpa_tl #1 ##1 #1 #1 \s__tl_stop
3900 \exp_args:NNNo \group_end:
3901 ##3 ##4 \l__tl_tmpa_tl
3902 }
3903 \cs_gset_protected:Npn \__tl_set_rescan_aux:w ##1 #1 ##2 \s__tl_stop
3904 { \tl_set:No \l__tl_tmpa_tl { \use_none:n ##1 } }
3905 }
3906 \exp_args:NV \__tl_set_rescan_aux:w \c__tl_rescan_marker_tl
3907 \cs_gset_protected:Npn \__tl_set_rescan_multi:nNN #1#2#3
3908 {
3909 \str_if_eq:eeTF { \tl_head:e { \tl_reverse:n {#1} } }
3910 { \char_generate:nn { \tex_endlinechar:D } { 12 } }
3911 { \__tl_set_rescan_multi_aux:nNN {#1} }
3912 {
3913 \exp_args:Ne \__tl_set_rescan_multi_aux:nNN
3914 { #1 \char_generate:nn { \tex_endlinechar:D } { 12 } }
3915 }
3916 #2 #3
3917 }
3918 \cs_new_protected:Npn \__tl_set_rescan_multi_aux:nNN #1#2#3
3919 {
3920 \tex_expanded:D
3921 {
3922 \exp_not:N \exp_args:NNNo \group_end:
3923 #2 \exp_not:N #3
3924 {
3925 \exp_not:N \tex_scantextokens:D
3926 {
3927 #1
3928 \char_generate:nn { 13 } { 12 }
3929 }
3930 }
3931 }
3932 }
3933 }
3934 \group_begin:
3935 \tex_catcode:D `\^^M = 12 \scan_stop: %
3936 \cs_new_protected:Npn \tl_retokenize:n #1 %
3937 { %
3938 \group_begin: %
3939 \int_set:Nn \tex_newlinechar:D { `^^J } %
3940 \int_set:Nn \tex_endlinechar:D { `^^M } %
3941 \exp_after:wN \group_end: %
3942 \tex_scantokens:D \exp_after:wN %
3943 { \tl_to_str:n {#1} } %
3944 } %
3945 \group_end: %
3946 \cs_generate_variant:Nn \tl_retokenize:n { V }
3947 \cs_new_protected:Npn \tl_replace_once:Nnn
3948 { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \__kernel_tl_set:Nx }
3949 \cs_new_protected:Npn \tl_greplace_once:Nnn
3950 { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_wrap:w \__kernel_tl_gset:Nx }
3951 \cs_new_protected:Npn \tl_replace_all:Nnn
3952 { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \__kernel_tl_set:Nx }
3953 \cs_new_protected:Npn \tl_greplace_all:Nnn
3954 { \__tl_replace:NnNNNnn \q__tl_mark ? \__tl_replace_next:w \__kernel_tl_gset:Nx }
3955 \cs_generate_variant:Nn \tl_replace_once:Nnn
3956 { NnV , Nne , NV , Ne , Nee , c , cnV , cne , cV , ce , cee }
3957 \cs_generate_variant:Nn \tl_replace_once:Nnn
3958 { Nx , Nnx , Nxx , cxn , cnx , cxx }
3959 \cs_generate_variant:Nn \tl_greplace_once:Nnn
3960 { NnV , Nne , NV , Ne , Nee , c , cnV , cne , cV , ce , cee }
3961 \cs_generate_variant:Nn \tl_greplace_once:Nnn
3962 { Nx , Nnx , Nxx , cxn , cnx , cxx }
3963 \cs_generate_variant:Nn \tl_replace_all:Nnn
3964 { NnV , Nne , NV , Ne , Nee , c , cnV , cne , cV , ce , cee }
3965 \cs_generate_variant:Nn \tl_replace_all:Nnn
3966 { Nx , Nnx , Nxx , cxn , cnx , cxx }
3967 \cs_generate_variant:Nn \tl_greplace_all:Nnn
3968 { NnV , Nne , NV , Ne , Nee , c , cnV , cne , cV , ce , cee }
3969 \cs_generate_variant:Nn \tl_greplace_all:Nnn
3970 { Nx , Nnx , Nxx , cxn , cnx , cxx }
3971 \cs_new_protected:Npn \__tl_replace:NnNNNnn #1#2#3#4#5#6#7
3972 {
3973 \tl_if_empty:nTF {#6}
3974 {
3975 \msg_error:nne { kernel } { empty-search-pattern }
3976 { \tl_to_str:n {#7} }
3977 }
3978 {
3979 \tl_if_in:onTF { #5 #6 } {#1}
3980 {
3981 \tl_if_in:nnTF {#6} {#1}
3982 { \exp_args:Nc \__tl_replace:NnNNNnn {#2} {#2?} }
3983 {
3984 \__tl_quark_if_nil:nTF {#6}
3985 { \__tl_replace_auxi:NnnNNNnn #5 {#1} { #1 \q__tl_stop } }
3986 { \__tl_replace_auxi:NnnNNNnn #5 {#1} { #1 \q__tl_nil } }
3987 }
3988 }
3989 { \__tl_replace_auxii:nNNNnn {#1} }
3990 #3#4#5 {#6} {#7}
3991 }
3992 }
3993 \cs_new_protected:Npn \__tl_replace_auxi:NnnNNNnn #1#2#3
3994 {
3995 \tl_if_in:NnTF #1 { #2 #3 #3 }
3996 { \__tl_replace_auxi:NnnNNNnn #1 { #2 #3 } {#2} }
3997 { \__tl_replace_auxii:nNNNnn { #2 #3 #3 } }
3998 }
3999 \cs_new_protected:Npn \__tl_replace_auxii:nNNNnn #1#2#3#4#5#6
4000 {
4001 \group_align_safe_begin:
4002 \cs_set:Npn \__tl_replace_wrap:w ##1 #1 ##2
4003 { \__kernel_exp_not:w \exp_after:wN { \use_none:nn ##1 } ##2 }
4004 \cs_set:Npe \__tl_replace_next:w ##1 #5
4005 {
4006 \exp_not:N \__tl_replace_wrap:w ##1
4007 \exp_not:n { #1 }
4008 \exp_not:n { \exp_not:n {#6} }
4009 \exp_not:n { #2 { } { } }
4010 }
4011 #3 #4
4012 {
4013 \exp_after:wN \__tl_replace_next_aux:w
4014 #4
4015 #1
4016 {
4017 \if_false: { \fi: }
4018 \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
4019 }
4020 #5
4021 }
4022 \group_align_safe_end:
4023 }
4024 \cs_new:Npn \__tl_replace_next_aux:w { \__tl_replace_next:w { } { } }
4025 \cs_new_eq:NN \__tl_replace_wrap:w ?
4026 \cs_new_eq:NN \__tl_replace_next:w ?
4027 \cs_new_protected:Npn \tl_regex_replace_once:Nnn #1#2#3
4028 { \regex_replace_once:nnN {#2} {#3} #1 }
4029 \cs_generate_variant:Nn \tl_regex_replace_once:Nnn { c }
4030 \cs_new_protected:Npn \tl_regex_replace_once:NNn #1#2#3
4031 { \regex_replace_once:NnN #2 {#3} #1 }
4032 \cs_generate_variant:Nn \tl_regex_replace_once:NNn { c }
4033 \cs_new_protected:Npn \tl_regex_replace_all:Nnn #1#2#3
4034 { \regex_replace_all:nnN {#2} {#3} #1 }
4035 \cs_generate_variant:Nn \tl_regex_replace_all:Nnn { c }
4036 \cs_new_protected:Npn \tl_regex_replace_all:NNn #1#2#3
4037 { \regex_replace_all:NnN #2 {#3} #1 }
4038 \cs_generate_variant:Nn \tl_regex_replace_all:NNn { c }
4039 \group_begin:
4040 \cs_set_protected:Npn \__tl_tmp:w #1#2#3
4041 {
4042 \cs_new_protected:cpe { tl_regex_greplace_ #1 :N #2 n } ##1##2##3
4043 {
4044 \group_begin:
4045 \tl_set_eq:NN \exp_not:N \l__tl_tmpa_tl ##1
4046 \exp_not:c { regex_replace_ #1 :Nn #2 }
4047 #3 {##2} {##3} \exp_not:N \l__tl_tmpa_tl
4048 \tl_gset_eq:NN ##1 \exp_not:N \l__tl_tmpa_tl
4049 \group_end:
4050 }
4051 \cs_generate_variant:cn { tl_regex_greplace_ #1 :N #2 n } { c }
4052 }
4053 \__tl_tmp:w { once } n { }
4054 \__tl_tmp:w { once } N \use:n
4055 \__tl_tmp:w { all } n { }
4056 \__tl_tmp:w { all } N \use:n
4057 \group_end:
4058 \cs_new_protected:Npn \tl_remove_once:Nn #1#2
4059 { \tl_replace_once:Nnn #1 {#2} { } }
4060 \cs_new_protected:Npn \tl_gremove_once:Nn #1#2
4061 { \tl_greplace_once:Nnn #1 {#2} { } }
4062 \cs_generate_variant:Nn \tl_remove_once:Nn { NV , Ne , c , cV , ce }
4063 \cs_generate_variant:Nn \tl_gremove_once:Nn { NV , Ne , c , cV , ce }
4064 \cs_new_protected:Npn \tl_remove_all:Nn #1#2
4065 { \tl_replace_all:Nnn #1 {#2} { } }
4066 \cs_new_protected:Npn \tl_gremove_all:Nn #1#2
4067 { \tl_greplace_all:Nnn #1 {#2} { } }
4068 \cs_generate_variant:Nn \tl_remove_all:Nn { NV , Ne , c , cV , ce }
4069 \cs_generate_variant:Nn \tl_remove_all:Nn { Nx , cx }
4070 \cs_generate_variant:Nn \tl_gremove_all:Nn { NV , Ne , c , cV , ce }
4071 \cs_generate_variant:Nn \tl_gremove_all:Nn { Nx , cx }
4072 \prg_new_conditional:Npnn \tl_if_empty:N #1 { p , T , F , TF }
4073 {
4074 \if_meaning:w #1 \c_empty_tl
4075 \prg_return_true:
4076 \else:
4077 \prg_return_false:
4078 \fi:
4079 }
4080 \prg_generate_conditional_variant:Nnn \tl_if_empty:N
4081 { c } { p , T , F , TF }
4082 \prg_new_conditional:Npnn \tl_if_empty:n #1 { p , TF , T , F }
4083 {
4084 \if:w \scan_stop: \tl_to_str:n {#1} \scan_stop:
4085 \prg_return_true:
4086 \else:
4087 \prg_return_false:
4088 \fi:
4089 }
4090 \prg_generate_conditional_variant:Nnn \tl_if_empty:n
4091 { V , e } { p , TF , T , F }
4092 \cs_new:Npn \__tl_if_empty_if:o #1
4093 {
4094 \if:w \scan_stop: \__kernel_tl_to_str:w \exp_after:wN {#1} \scan_stop:
4095 }
4096 \exp_args:Nno \use:n
4097 { \prg_new_conditional:Npnn \tl_if_empty:o #1 { p , TF , T , F } }
4098 {
4099 \__tl_if_empty_if:o {#1}
4100 \prg_return_true:
4101 \else:
4102 \prg_return_false:
4103 \fi:
4104 }
4105 \exp_args:Nno \use:n
4106 { \prg_new_conditional:Npnn \tl_if_blank:n #1 { p , T , F , TF } }
4107 {
4108 \__tl_if_empty_if:o { \use_none:n #1 ? }
4109 \prg_return_true:
4110 \else:
4111 \prg_return_false:
4112 \fi:
4113 }
4114 \prg_generate_conditional_variant:Nnn \tl_if_blank:n
4115 { e , V , o } { p , T , F , TF }
4116 \prg_new_eq_conditional:NNn \tl_if_eq:NN \cs_if_eq:NN { p , T , F , TF }
4117 \prg_generate_conditional_variant:Nnn \tl_if_eq:NN
4118 { Nc , c , cc } { p , TF , T , F }
4119 \tl_new:N \l__tl_tmpa_tl
4120 \tl_new:N \l__tl_tmpb_tl
4121 \prg_new_protected_conditional:Npnn \tl_if_eq:Nn #1#2 { T , F , TF }
4122 {
4123 \group_begin:
4124 \tl_set:Nn \l__tl_tmpb_tl {#2}
4125 \exp_after:wN
4126 \group_end:
4127 \if_meaning:w #1 \l__tl_tmpb_tl
4128 \prg_return_true:
4129 \else:
4130 \prg_return_false:
4131 \fi:
4132 }
4133 \prg_generate_conditional_variant:Nnn \tl_if_eq:Nn { c } { TF , T , F }
4134 \prg_new_protected_conditional:Npnn \tl_if_eq:nn #1#2 { T , F , TF }
4135 {
4136 \group_begin:
4137 \tl_set:Nn \l__tl_tmpa_tl {#1}
4138 \tl_set:Nn \l__tl_tmpb_tl {#2}
4139 \exp_after:wN
4140 \group_end:
4141 \if_meaning:w \l__tl_tmpa_tl \l__tl_tmpb_tl
4142 \prg_return_true:
4143 \else:
4144 \prg_return_false:
4145 \fi:
4146 }
4147 \prg_generate_conditional_variant:Nnn \tl_if_eq:nn
4148 { nV , ne , nx , V, e , ee , x , xx }
4149 { TF , T , F }
4150 \cs_new_protected:Npn \tl_if_in:NnT { \exp_args:No \tl_if_in:nnT }
4151 \cs_new_protected:Npn \tl_if_in:NnF { \exp_args:No \tl_if_in:nnF }
4152 \cs_new_protected:Npn \tl_if_in:NnTF { \exp_args:No \tl_if_in:nnTF }
4153 \prg_generate_conditional_variant:Nnn \tl_if_in:Nn
4154 { NV , No , c , cV , co } { T , F , TF }
4155 \prg_new_protected_conditional:Npnn \tl_if_in:nn #1#2 { T , F , TF }
4156 {
4157 \scan_stop:
4158 \if_false: { \fi:
4159 \cs_set:Npn \__tl_tmp:w ##1 #2 { }
4160 \tl_if_empty:oTF { \__tl_tmp:w #1 {} {} #2 }
4161 { \prg_return_false: } { \prg_return_true: }
4162 \if_false: } \fi:
4163 }
4164 \prg_generate_conditional_variant:Nnn \tl_if_in:nn
4165 { V , VV , o , oo , nV , no } { T , F , TF }
4166 \cs_set_protected:Npn \__tl_tmp:w #1
4167 {
4168 \prg_new_conditional:Npnn \tl_if_novalue:n ##1
4169 { p , T , F , TF }
4170 {
4171 \__tl_if_empty_if:o { \__tl_if_novalue:w {} ##1 {} ? ! #1 ? ? ! }
4172 \prg_return_true:
4173 \else:
4174 \prg_return_false:
4175 \fi:
4176 }
4177 \cs_new:Npn \__tl_if_novalue:w ##1 #1 ##2 ? ##3 ? ! { ##1 ##2 }
4178 }
4179 \exp_args:No \__tl_tmp:w { \c_novalue_tl }
4180 \cs_new:Npn \tl_if_single_p:N { \exp_args:No \tl_if_single_p:n }
4181 \cs_new:Npn \tl_if_single:NT { \exp_args:No \tl_if_single:nT }
4182 \cs_new:Npn \tl_if_single:NF { \exp_args:No \tl_if_single:nF }
4183 \cs_new:Npn \tl_if_single:NTF { \exp_args:No \tl_if_single:nTF }
4184 \prg_generate_conditional_variant:Nnn \tl_if_single:N {c} { p , T , F , TF }
4185 \prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF }
4186 {
4187 \if:w \scan_stop: \exp_after:wN \__tl_if_single:nnw
4188 \__kernel_tl_to_str:w
4189 \exp_after:wN { \use_none:nn #1 ?? } \scan_stop: ? \s__tl_stop
4190 \prg_return_true:
4191 \else:
4192 \prg_return_false:
4193 \fi:
4194 }
4195 \cs_new:Npn \__tl_if_single:nnw #1#2#3 \s__tl_stop {#2}
4196 \prg_new_conditional:Npnn \tl_if_single_token:n #1 { p , T , F , TF }
4197 {
4198 \tl_if_head_is_N_type:nTF {#1}
4199 { \__tl_if_empty_if:o { \use_none:n #1 } }
4200 {
4201 \tl_if_empty:nTF {#1}
4202 { \if_false: }
4203 { \__tl_if_empty_if:o { \exp:w \exp_end_continue_f:w #1 } }
4204 }
4205 \prg_return_true:
4206 \else:
4207 \prg_return_false:
4208 \fi:
4209 }
4210 \prg_new_protected_conditional:Npnn \tl_if_regex_match:nn #1#2 { TF , T , F }
4211 {
4212 \regex_if_match:nnTF {#2} {#1}
4213 \prg_return_true: \prg_return_false:
4214 }
4215 \prg_generate_conditional_variant:Nnn \tl_if_regex_match:nn
4216 { V } { TF , T , F }
4217 \prg_new_protected_conditional:Npnn \tl_if_regex_match:nN #1#2 { TF , T , F }
4218 {
4219 \regex_if_match:NnTF #2 {#1}
4220 \prg_return_true: \prg_return_false:
4221 }
4222 \prg_generate_conditional_variant:Nnn \tl_if_regex_match:nN
4223 { V } { TF , T , F }
4224 \cs_new:Npn \tl_map_function:nN #1#2
4225 {
4226 \__tl_map_function:Nnnnnnnnn #2 #1
4227 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4228 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4229 \prg_break_point:Nn \tl_map_break: { }
4230 }
4231 \cs_generate_variant:Nn \tl_map_function:nN { e }
4232 \cs_new:Npn \tl_map_function:NN
4233 { \exp_args:No \tl_map_function:nN }
4234 \cs_generate_variant:Nn \tl_map_function:NN { c }
4235 \cs_new:Npn \__tl_map_function:Nnnnnnnnn #1#2#3#4#5#6#7#8#9
4236 {
4237 \__tl_use_none_delimit_by_s_stop:w
4238 #9 \__tl_map_function_end:w \s__tl_stop
4239 #1 {#2} #1 {#3} #1 {#4} #1 {#5} #1 {#6} #1 {#7} #1 {#8} #1 {#9}
4240 \__tl_map_function:Nnnnnnnnn #1
4241 }
4242 \cs_new:Npn \__tl_map_function_end:w \s__tl_stop #1#2
4243 {
4244 \__tl_use_none_delimit_by_s_stop:w #2 \tl_map_break: \s__tl_stop
4245 #1 {#2}
4246 \__tl_map_function_end:w \s__tl_stop
4247 }
4248 \cs_new:Npn \__tl_use_none_delimit_by_s_stop:w #1 \s__tl_stop { }
4249 \cs_new_protected:Npn \tl_map_inline:nn #1#2
4250 {
4251 \int_gincr:N \g__kernel_prg_map_int
4252 \cs_gset_protected:cpn
4253 { __tl_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
4254 \exp_args:Nc \__tl_map_function:Nnnnnnnnn
4255 { __tl_map_ \int_use:N \g__kernel_prg_map_int :w }
4256 #1
4257 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4258 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4259 \prg_break_point:Nn \tl_map_break:
4260 { \int_gdecr:N \g__kernel_prg_map_int }
4261 }
4262 \cs_new_protected:Npn \tl_map_inline:Nn
4263 { \exp_args:No \tl_map_inline:nn }
4264 \cs_generate_variant:Nn \tl_map_inline:Nn { c }
4265 \cs_new:Npn \tl_map_tokens:nn #1#2
4266 {
4267 \__tl_map_tokens:nnnnnnnnn {#2} #1
4268 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4269 \s__tl_stop \s__tl_stop \s__tl_stop \s__tl_stop
4270 \prg_break_point:Nn \tl_map_break: { }
4271 }
4272 \cs_new:Npn \tl_map_tokens:Nn
4273 { \exp_args:No \tl_map_tokens:nn }
4274 \cs_generate_variant:Nn \tl_map_tokens:Nn { c }
4275 \cs_new:Npn \__tl_map_tokens:nnnnnnnnn #1#2#3#4#5#6#7#8#9
4276 {
4277 \__tl_use_none_delimit_by_s_stop:w
4278 #9 \__tl_map_tokens_end:w \s__tl_stop
4279 \use:n {#1} {#2} \use:n {#1} {#3} \use:n {#1} {#4} \use:n {#1} {#5}
4280 \use:n {#1} {#6} \use:n {#1} {#7} \use:n {#1} {#8} \use:n {#1} {#9}
4281 \__tl_map_tokens:nnnnnnnnn {#1}
4282 }
4283 \cs_new:Npn \__tl_map_tokens_end:w \s__tl_stop \use:n #1#2
4284 {
4285 \__tl_use_none_delimit_by_s_stop:w #2 \tl_map_break: \s__tl_stop
4286 #1 {#2}
4287 \__tl_map_tokens_end:w \s__tl_stop
4288 }
4289 \cs_new_protected:Npn \tl_map_variable:nNn #1#2#3
4290 { \tl_map_tokens:nn {#1} { \__tl_map_variable:Nnn #2 {#3} } }
4291 \cs_new_protected:Npn \__tl_map_variable:Nnn #1#2#3
4292 { \tl_set:Nn #1 {#3} #2 }
4293 \cs_new_protected:Npn \tl_map_variable:NNn
4294 { \exp_args:No \tl_map_variable:nNn }
4295 \cs_generate_variant:Nn \tl_map_variable:NNn { c }
4296 \cs_new:Npn \tl_map_break:
4297 { \prg_map_break:Nn \tl_map_break: { } }
4298 \cs_new:Npn \tl_map_break:n
4299 { \prg_map_break:Nn \tl_map_break: }
4300 \cs_generate_variant:Nn \tl_to_str:n { o , V , v , e }
4301 \cs_new:Npn \tl_to_str:N #1 { \__kernel_tl_to_str:w \exp_after:wN {#1} }
4302 \cs_generate_variant:Nn \tl_to_str:N { c }
4303 \cs_new:Npn \tl_use:N #1
4304 {
4305 \tl_if_exist:NTF #1 {#1}
4306 {
4307 \msg_expandable_error:nnn
4308 { kernel } { bad-variable } {#1}
4309 }
4310 }
4311 \cs_generate_variant:Nn \tl_use:N { c }
4312 \cs_new:Npn \tl_count:n #1
4313 {
4314 \int_eval:n
4315 { 0 \tl_map_function:nN {#1} \__tl_count:n }
4316 }
4317 \cs_new:Npn \tl_count:N #1
4318 {
4319 \int_eval:n
4320 { 0 \tl_map_function:NN #1 \__tl_count:n }
4321 }
4322 \cs_new:Npn \__tl_count:n #1 { + 1 }
4323 \cs_generate_variant:Nn \tl_count:n { V , v , e , o }
4324 \cs_generate_variant:Nn \tl_count:N { c }
4325 \cs_new:Npn \tl_count_tokens:n #1
4326 {
4327 \int_eval:n
4328 {
4329 \__tl_act:NNNn
4330 \__tl_act_count_normal:N
4331 \__tl_act_count_group:n
4332 \__tl_act_count_space:
4333 {#1}
4334 }
4335 }
4336 \cs_new:Npn \__tl_act_count_normal:N #1 { 1 + }
4337 \cs_new:Npn \__tl_act_count_space: { 1 + }
4338 \cs_new:Npn \__tl_act_count_group:n #1 { 2 + \tl_count_tokens:n {#1} + }
4339 \cs_new:Npn \tl_reverse_items:n #1
4340 {
4341 \__tl_reverse_items:nwNwn #1 ?
4342 \s__tl_mark \__tl_reverse_items:nwNwn
4343 \s__tl_mark \__tl_reverse_items:wn
4344 \s__tl_stop { }
4345 }
4346 \cs_new:Npn \__tl_reverse_items:nwNwn #1 #2 \s__tl_mark #3 #4 \s__tl_stop #5
4347 {
4348 #3 #2
4349 \s__tl_mark \__tl_reverse_items:nwNwn
4350 \s__tl_mark \__tl_reverse_items:wn
4351 \s__tl_stop { {#1} #5 }
4352 }
4353 \cs_new:Npn \__tl_reverse_items:wn #1 \s__tl_stop #2
4354 { \__kernel_exp_not:w \exp_after:wN { \use_none:nn #2 } }
4355 \cs_new:Npn \tl_trim_spaces:n
4356 { \__tl_trim_spaces:nn { \__kernel_exp_not:w \exp_after:wN } }
4357 \cs_new:Npn \tl_trim_left_spaces:n
4358 { \__tl_trim_left_spaces:nn { \__kernel_exp_not:w \exp_after:wN } }
4359 \cs_new:Npn \tl_trim_right_spaces:n
4360 { \__tl_trim_right_spaces:nn { \__kernel_exp_not:w \exp_after:wN } }
4361 \cs_generate_variant:Nn \tl_trim_spaces:n { V , v , e , o }
4362 \cs_generate_variant:Nn \tl_trim_left_spaces:n { V , v , e , o }
4363 \cs_generate_variant:Nn \tl_trim_right_spaces:n { V , v , e , o }
4364 \cs_new:Npn \tl_trim_spaces_apply:nN #1#2
4365 { \__tl_trim_spaces:nn { \exp_args:No #2 } { #1 } }
4366 \cs_new:Npn \tl_trim_left_spaces_apply:nN #1#2
4367 { \__tl_trim_left_spaces:nn { \exp_args:No #2 } { #1 } }
4368 \cs_new:Npn \tl_trim_right_spaces_apply:nN #1#2
4369 { \__tl_trim_right_spaces:nn { \exp_args:No #2 } { #1 } }
4370 \cs_generate_variant:Nn \tl_trim_spaces_apply:nN { o }
4371 \cs_generate_variant:Nn \tl_trim_left_spaces_apply:nN { o }
4372 \cs_generate_variant:Nn \tl_trim_right_spaces_apply:nN { o }
4373 \cs_new_protected:Npn \tl_trim_spaces:N #1
4374 { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
4375 \cs_new_protected:Npn \tl_trim_left_spaces:N #1
4376 { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_trim_left_spaces:n {#1} } }
4377 \cs_new_protected:Npn \tl_trim_right_spaces:N #1
4378 { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_trim_right_spaces:n {#1} } }
4379 \cs_new_protected:Npn \tl_gtrim_spaces:N #1
4380 { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
4381 \cs_new_protected:Npn \tl_gtrim_left_spaces:N #1
4382 { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_trim_left_spaces:n {#1} } }
4383 \cs_new_protected:Npn \tl_gtrim_right_spaces:N #1
4384 { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_trim_right_spaces:n {#1} } }
4385 \cs_generate_variant:Nn \tl_trim_spaces:N { c }
4386 \cs_generate_variant:Nn \tl_trim_left_spaces:N { c }
4387 \cs_generate_variant:Nn \tl_trim_right_spaces:N { c }
4388 \cs_generate_variant:Nn \tl_gtrim_spaces:N { c }
4389 \cs_generate_variant:Nn \tl_gtrim_left_spaces:N { c }
4390 \cs_generate_variant:Nn \tl_gtrim_right_spaces:N { c }
4391 \cs_set_protected:Npn \__tl_tmp:w #1
4392 {
4393 \cs_new:Npn \__tl_trim_spaces:nn ##1##2
4394 {
4395 \__tl_trim_spaces_auxi:w
4396 \__tl_trim_mark: ##2 \s__tl_nil
4397 \__tl_trim_mark: \__tl_trim_spaces_auxi:w
4398 \__tl_trim_mark: #1
4399 \__tl_trim_mark: \__tl_trim_spaces_auxii:w
4400 {##1}
4401 }
4402 \cs_new:Npn \__tl_trim_left_spaces:nn ##1##2
4403 {
4404 \__tl_trim_spaces_auxi:w
4405 \__tl_trim_mark: ##2 \s__tl_nil
4406 \__tl_trim_mark: \__tl_trim_spaces_auxi:w
4407 \__tl_trim_mark: #1
4408 \__tl_trim_mark: \__tl_trim_spaces_auxv:w
4409 {##1}
4410 }
4411 \cs_new:Npn \__tl_trim_right_spaces:nn ##1##2
4412 {
4413 \__tl_trim_spaces_auxiii:w
4414 \__tl_trim_mark: ##2 \s__tl_nil \__tl_trim_spaces_auxiii:w
4415 #1 \s__tl_nil \__tl_trim_spaces_auxiv:w
4416 {##1}
4417 }
4418 \cs_new:Npn \__tl_trim_spaces_auxi:w
4419 ##1 \__tl_trim_mark: #1 ##2 \__tl_trim_mark: ##3
4420 { ##3 ##1 \__tl_trim_mark: ##2 \__tl_trim_mark: \__tl_trim_spaces_auxi:w }
4421 \cs_new:Npn \__tl_trim_spaces_auxii:w
4422 \__tl_trim_mark: ##1 \__tl_trim_mark: ##2 \__tl_trim_spaces_auxi:w
4423 \__tl_trim_mark: \__tl_trim_mark: \__tl_trim_spaces_auxi:w
4424 {
4425 \__tl_trim_spaces_auxiii:w
4426 \__tl_trim_mark: ##1 \__tl_trim_spaces_auxiii:w
4427 #1 \s__tl_nil \__tl_trim_spaces_auxiv:w
4428 }
4429 \cs_new:Npn \__tl_trim_spaces_auxiii:w ##1 #1 \s__tl_nil ##2
4430 { ##2 ##1 \s__tl_nil \__tl_trim_spaces_auxiii:w }
4431 \cs_new:Npn \__tl_trim_spaces_auxiv:w
4432 ##1 \s__tl_nil
4433 \__tl_trim_spaces_auxiii:w \s__tl_nil \__tl_trim_spaces_auxiii:w
4434 ##2
4435 { ##2 {##1} }
4436 \cs_new:Npn \__tl_trim_spaces_auxv:w
4437 ##1 \s__tl_nil
4438 \__tl_trim_mark: \__tl_trim_spaces_auxi:w \__tl_trim_mark:
4439 \__tl_trim_mark: \__tl_trim_spaces_auxi:w ##2
4440 { ##2 {##1} }
4441 \cs_new:Npn \__tl_trim_mark: {}
4442 }
4443 \__tl_tmp:w { ~ }
4444 \cs_new:Npn \tl_head:n #1
4445 {
4446 \__kernel_exp_not:w \tex_expanded:D
4447 { { \if_false: { \fi: \__tl_head_aux:n #1 { } } } }
4448 }
4449 \cs_new:Npn \__tl_head_aux:n #1
4450 {
4451 \__kernel_exp_not:w {#1}
4452 \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
4453 }
4454 \cs_generate_variant:Nn \tl_head:n { V , v , f , e }
4455 \cs_new:Npn \tl_head:w #1#2 \q_stop {#1}
4456 \cs_new:Npn \__tl_tl_head:w #1#2 \s__tl_stop {#1}
4457 \cs_new:Npn \tl_head:N { \exp_args:No \tl_head:n }
4458 \exp_args:Nno \use:n { \cs_new:Npn \tl_tail:n #1 }
4459 {
4460 \exp_after:wN \__kernel_exp_not:w
4461 \tl_if_blank:nTF {#1}
4462 { { } }
4463 { \exp_after:wN { \use_none:n #1 } }
4464 }
4465 \cs_generate_variant:Nn \tl_tail:n { V , v , f , e }
4466 \cs_new:Npn \tl_tail:N { \exp_args:No \tl_tail:n }
4467 \prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 { p , T , F , TF }
4468 {
4469 \if_charcode:w
4470 \tl_if_head_is_N_type:nTF { #1 ? }
4471 { \__tl_head_exp_not:w #1 { ^ \__tl_if_head_eq_empty_arg:w } \s__tl_stop }
4472 { \str_head:n {#1} }
4473 \exp_not:N #2
4474 \prg_return_true:
4475 \else:
4476 \prg_return_false:
4477 \fi:
4478 }
4479 \prg_generate_conditional_variant:Nnn \tl_if_head_eq_charcode:nN
4480 { V , e , f } { p , TF , T , F }
4481 \prg_new_conditional:Npnn \tl_if_head_eq_catcode:nN #1 #2 { p , T , F , TF }
4482 {
4483 \if_catcode:w
4484 \tl_if_head_is_N_type:nTF { #1 ? }
4485 { \__tl_head_exp_not:w #1 { ^ \__tl_if_head_eq_empty_arg:w } \s__tl_stop }
4486 {
4487 \tl_if_head_is_group:nTF {#1}
4488 \c_group_begin_token
4489 \c_space_token
4490 }
4491 \exp_not:N #2
4492 \prg_return_true:
4493 \else:
4494 \prg_return_false:
4495 \fi:
4496 }
4497 \prg_generate_conditional_variant:Nnn \tl_if_head_eq_catcode:nN
4498 { V , e , o } { p , TF , T , F }
4499 \prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF }
4500 {
4501 \tl_if_head_is_N_type:nTF { #1 ? }
4502 \__tl_if_head_eq_meaning_normal:nN
4503 \__tl_if_head_eq_meaning_special:nN
4504 {#1} #2
4505 }
4506 \prg_generate_conditional_variant:Nnn \tl_if_head_eq_meaning:nN
4507 { V , e } { p , TF , T , F }
4508 \cs_new:Npn \__tl_if_head_eq_meaning_normal:nN #1 #2
4509 {
4510 \exp_after:wN \if_meaning:w
4511 \__tl_tl_head:w #1 { ?? \use_none:nnn } \s__tl_stop #2
4512 \prg_return_true:
4513 \else:
4514 \prg_return_false:
4515 \fi:
4516 }
4517 \cs_new:Npn \__tl_if_head_eq_meaning_special:nN #1 #2
4518 {
4519 \if_charcode:w \str_head:n {#1} \exp_not:N #2
4520 \exp_after:wN \use_ii:nn
4521 \else:
4522 \prg_return_false:
4523 \fi:
4524 \use_none:n
4525 {
4526 \if_catcode:w \exp_not:N #2
4527 \tl_if_head_is_group:nTF {#1}
4528 { \c_group_begin_token }
4529 { \c_space_token }
4530 \prg_return_true:
4531 \else:
4532 \prg_return_false:
4533 \fi:
4534 }
4535 }
4536 \cs_new:Npn \__tl_head_exp_not:w #1 #2 \s__tl_stop
4537 { \exp_not:N #1 }
4538 \cs_new:Npn \__tl_if_head_eq_empty_arg:w \exp_not:N #1
4539 { ? }
4540 \prg_new_conditional:Npnn \tl_if_head_is_N_type:n #1 { p , T , F , TF }
4541 {
4542 \if:w
4543 \if_false: { \fi: \__tl_if_head_is_N_type_auxi:w #1 ~ }
4544 { \exp_after:wN { \token_to_str:N #1 } }
4545 \scan_stop: \scan_stop:
4546 \prg_return_true:
4547 \else:
4548 \prg_return_false:
4549 \fi:
4550 }
4551 \exp_args:Nno \use:n { \cs_new:Npn \__tl_if_head_is_N_type_auxi:w #1 ~ }
4552 {
4553 \tl_if_empty:nTF {#1}
4554 { f \exp_after:wN \use_none:nn }
4555 { \exp_after:wN \__tl_if_head_is_N_type_auxii:n }
4556 \exp_after:wN { \if_false: } \fi:
4557 }
4558 \cs_new:Npn \__tl_if_head_is_N_type_auxii:n #1
4559 { \exp_after:wN \use_none:n \exp_after:wN }
4560 \prg_new_conditional:Npnn \tl_if_head_is_group:n #1 { p , T , F , TF }
4561 {
4562 \if:w
4563 \exp_after:wN \use_none:n
4564 \exp_after:wN { \exp_after:wN { \token_to_str:N #1 ? } }
4565 \scan_stop: \scan_stop:
4566 \__tl_if_head_is_group_fi_false:w
4567 \fi:
4568 \if_true:
4569 \prg_return_true:
4570 \else:
4571 \prg_return_false:
4572 \fi:
4573 }
4574 \cs_new:Npn \__tl_if_head_is_group_fi_false:w \fi: \if_true: { \fi: \if_false: }
4575 \prg_new_conditional:Npnn \tl_if_head_is_space:n #1 { p , T , F , TF }
4576 {
4577 \if:w
4578 \if_false: { \fi: \__tl_if_head_is_space:w \prg_do_nothing: #1 ? ~ }
4579 \scan_stop: \scan_stop:
4580 \prg_return_true:
4581 \else:
4582 \prg_return_false:
4583 \fi:
4584 }
4585 \exp_args:Nno \use:n { \cs_new:Npn \__tl_if_head_is_space:w #1 ~ }
4586 {
4587 \__tl_if_empty_if:o {#1} \else: f \fi:
4588 \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
4589 }
4590 \scan_new:N \s__tl_act_stop
4591 \cs_set_protected:Npn \__tl_tmp:w #1
4592 {
4593 \cs_new:Npn \__tl_act_if_head_is_space:nTF ##1
4594 {
4595 \__tl_act_if_head_is_space:w
4596 \s__tl_act_stop ##1 \s__tl_act_stop \__tl_act_if_head_is_space_true:w
4597 \s__tl_act_stop #1 \s__tl_act_stop \use_ii:nn
4598 }
4599 \cs_new:Npn \__tl_act_if_head_is_space:w
4600 ##1 \s__tl_act_stop #1 ##2 \s__tl_act_stop
4601 {}
4602 \cs_new:Npn \__tl_act_if_head_is_space_true:w
4603 \s__tl_act_stop #1 \s__tl_act_stop \use_ii:nn ##1 ##2
4604 {##1}
4605 }
4606 \__tl_tmp:w { ~ }
4607 \exp_args:Nne \use:n { \cs_new:Npn \__tl_act_loop:w #1 \s__tl_act_stop }
4608 {
4609 \exp_not:o { \__tl_act_if_head_is_space:nTF {#1} }
4610 \exp_not:N \__tl_act_space:wwNNN
4611 {
4612 \exp_not:o { \tl_if_head_is_group:nTF {#1} }
4613 \exp_not:N \__tl_act_group:nwNNN
4614 \exp_not:N \__tl_act_normal:NwNNN
4615 }
4616 \exp_not:n {#1} \s__tl_act_stop
4617 }
4618 \cs_undefine:N \__tl_act_if_head_is_space:nTF
4619 \cs_new:Npn \__tl_act_normal:NwNNN #1 #2 \s__tl_act_stop #3
4620 {
4621 #3 #1
4622 \__tl_act_loop:w #2 \s__tl_act_stop
4623 #3
4624 }
4625 \cs_new:Npn \__tl_use_none_delimit_by_s_act_stop:w #1 \s__tl_act_stop { }
4626 \cs_new:Npn \__tl_act_end:wn #1 \__tl_act_result:n #2
4627 { \group_align_safe_end: \exp_end: #2 }
4628 \cs_new:Npn \__tl_act_group:nwNNN #1 #2 \s__tl_act_stop #3#4#5
4629 {
4630 \__tl_use_none_delimit_by_s_act_stop:w #1 \__tl_act_end:wn \s__tl_act_stop
4631 #5 {#1}
4632 \__tl_act_loop:w #2 \s__tl_act_stop
4633 #3 #4 #5
4634 }
4635 \exp_last_unbraced:NNo
4636 \cs_new:Npn \__tl_act_space:wwNNN \c_space_tl #1 \s__tl_act_stop #2#3
4637 {
4638 #3
4639 \__tl_act_loop:w #1 \s__tl_act_stop
4640 #2 #3
4641 }
4642 \cs_new:Npn \__tl_act:NNNn #1#2#3#4
4643 {
4644 \group_align_safe_begin:
4645 \__tl_act_loop:w #4 { \s__tl_act_stop } ? \s__tl_act_stop
4646 #1 #3 #2
4647 \__tl_act_result:n { }
4648 }
4649 \cs_new:Npn \__tl_act_output:n #1 #2 \__tl_act_result:n #3
4650 { #2 \__tl_act_result:n { #3 #1 } }
4651 \cs_new:Npn \__tl_act_reverse_output:n #1 #2 \__tl_act_result:n #3
4652 { #2 \__tl_act_result:n { #1 #3 } }
4653 \cs_new:Npn \tl_reverse:n #1
4654 {
4655 \__kernel_exp_not:w \exp_after:wN
4656 {
4657 \exp:w
4658 \__tl_act:NNNn
4659 \__tl_reverse_normal:N
4660 \__tl_reverse_group_preserve:n
4661 \__tl_reverse_space:
4662 {#1}
4663 }
4664 }
4665 \cs_generate_variant:Nn \tl_reverse:n { o , V , f , e }
4666 \cs_new:Npn \__tl_reverse_normal:N
4667 { \__tl_act_reverse_output:n }
4668 \cs_new:Npn \__tl_reverse_group_preserve:n #1
4669 { \__tl_act_reverse_output:n { {#1} } }
4670 \cs_new:Npn \__tl_reverse_space:
4671 { \__tl_act_reverse_output:n { ~ } }
4672 \cs_new_protected:Npn \tl_reverse:N #1
4673 { \__kernel_tl_set:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
4674 \cs_new_protected:Npn \tl_greverse:N #1
4675 { \__kernel_tl_gset:Nx #1 { \exp_args:No \tl_reverse:n { #1 } } }
4676 \cs_generate_variant:Nn \tl_reverse:N { c }
4677 \cs_generate_variant:Nn \tl_greverse:N { c }
4678 \cs_new:Npn \tl_item:nn #1#2
4679 {
4680 \exp_args:Nf \__tl_item:nn
4681 { \exp_args:Nf \__tl_item_aux:nn { \int_eval:n {#2} } {#1} }
4682 #1
4683 \q__tl_recursion_tail
4684 \prg_break_point:
4685 }
4686 \cs_new:Npn \__tl_item_aux:nn #1#2
4687 {
4688 \int_compare:nNnTF {#1} < 0
4689 { \int_eval:n { \tl_count:n {#2} + 1 + #1 } }
4690 {#1}
4691 }
4692 \cs_new:Npn \__tl_item:nn #1#2
4693 {
4694 \__tl_if_recursion_tail_break:nN {#2} \prg_break:
4695 \int_compare:nNnTF {#1} = 1
4696 { \prg_break:n { \exp_not:n {#2} } }
4697 { \exp_args:Nf \__tl_item:nn { \int_eval:n { #1 - 1 } } }
4698 }
4699 \cs_new:Npn \tl_item:Nn { \exp_args:No \tl_item:nn }
4700 \cs_generate_variant:Nn \tl_item:Nn { c }
4701 \cs_new:Npn \tl_rand_item:n #1
4702 {
4703 \tl_if_blank:nF {#1}
4704 { \tl_item:nn {#1} { \int_rand:nn { 1 } { \tl_count:n {#1} } } }
4705 }
4706 \cs_new:Npn \tl_rand_item:N { \exp_args:No \tl_rand_item:n }
4707 \cs_generate_variant:Nn \tl_rand_item:N { c }
4708 \cs_new_eq:NN \__kernel_int_sep: \tex_let:D
4709 \cs_new_eq:NN \__tl_sep: \__kernel_int_sep:
4710 \cs_new:Npn \tl_range:Nnn { \exp_args:No \tl_range:nnn }
4711 \cs_generate_variant:Nn \tl_range:Nnn { c }
4712 \cs_new:Npn \tl_range:nnn { \__tl_range:Nnnn \__tl_range:w }
4713 \cs_new:Npn \__tl_range:Nnnn #1#2#3#4
4714 {
4715 \tl_head:f
4716 {
4717 \exp_args:Nf \__tl_range:nnnNn
4718 { \tl_count:n {#2} } {#3} {#4} #1 {#2}
4719 }
4720 }
4721 \cs_new:Npn \__tl_range:nnnNn #1#2#3
4722 {
4723 \exp_args:Nff \__tl_range:nnNn
4724 {
4725 \exp_args:Nf \__tl_range_normalize:nn
4726 { \int_eval:n { #2 - 1 } } {#1}
4727 }
4728 {
4729 \exp_args:Nf \__tl_range_normalize:nn
4730 { \int_eval:n {#3} } {#1}
4731 }
4732 }
4733 \cs_new:Npn \__tl_range:nnNn #1#2#3#4
4734 {
4735 \if_int_compare:w #2 > #1 \exp_stop_f: \else:
4736 \exp_after:wN { \exp_after:wN }
4737 \fi:
4738 \exp_after:wN #3
4739 \int_value:w \int_eval:n { #2 - #1 } \exp_after:wN \__tl_sep:
4740 \exp_after:wN { \exp:w \__tl_range_skip:w #1 \__tl_sep: { } #4 }
4741 }
4742 \cs_new:Npn \__tl_range_skip:w #1 \__tl_sep: #2
4743 {
4744 \if_int_compare:w #1 > \c_zero_int
4745 \exp_after:wN \__tl_range_skip:w
4746 \int_value:w \int_eval:n { #1 - 1 } \exp_after:wN \__tl_sep:
4747 \else:
4748 \exp_after:wN \exp_end:
4749 \fi:
4750 }
4751 \cs_new:Npn \__tl_range:w #1 \__tl_sep: #2
4752 {
4753 \exp_args:Nf \__tl_range_collect:nn
4754 { \__tl_range_skip_spaces:n {#2} } {#1}
4755 }
4756 \cs_new:Npn \__tl_range_skip_spaces:n #1
4757 {
4758 \tl_if_head_is_space:nTF {#1}
4759 { \exp_args:Nf \__tl_range_skip_spaces:n {#1} }
4760 { { } #1 }
4761 }
4762 \cs_new:Npn \__tl_range_collect:nn #1#2
4763 {
4764 \int_compare:nNnTF {#2} = 0
4765 {#1}
4766 {
4767 \exp_args:No \tl_if_head_is_space:nTF { \use_none:n #1 }
4768 {
4769 \exp_args:Nf \__tl_range_collect:nn
4770 { \__tl_range_collect_space:nw #1 }
4771 {#2}
4772 }
4773 {
4774 \__tl_range_collect:ff
4775 {
4776 \exp_args:No \tl_if_head_is_N_type:nTF { \use_none:n #1 }
4777 { \__tl_range_collect_N:nN }
4778 { \__tl_range_collect_group:nn }
4779 #1
4780 }
4781 { \int_eval:n { #2 - 1 } }
4782 }
4783 }
4784 }
4785 \cs_new:Npn \__tl_range_collect_space:nw #1 ~ { { #1 ~ } }
4786 \cs_new:Npn \__tl_range_collect_N:nN #1#2 { { #1 #2 } }
4787 \cs_new:Npn \__tl_range_collect_group:nn #1#2 { { #1 {#2} } }
4788 \cs_generate_variant:Nn \__tl_range_collect:nn { ff }
4789 \cs_new:Npn \__tl_range_normalize:nn #1#2
4790 {
4791 \int_eval:n
4792 {
4793 \if_int_compare:w #1 < \c_zero_int
4794 \if_int_compare:w #1 < -#2 \exp_stop_f:
4795 0
4796 \else:
4797 #1 + #2 + 1
4798 \fi:
4799 \else:
4800 \if_int_compare:w #1 < #2 \exp_stop_f:
4801 #1
4802 \else:
4803 #2
4804 \fi:
4805 \fi:
4806 }
4807 }
4808 \cs_new_protected:Npn \tl_show:N { \__tl_show:NN \tl_show:n }
4809 \cs_generate_variant:Nn \tl_show:N { c }
4810 \cs_new_protected:Npn \tl_log:N { \__tl_show:NN \tl_log:n }
4811 \cs_generate_variant:Nn \tl_log:N { c }
4812 \cs_new_protected:Npn \__tl_show:NN #1#2
4813 {
4814 \__kernel_chk_defined:NT #2
4815 {
4816 \exp_args:Nf \tl_if_empty:nTF
4817 { \cs_prefix_spec:N #2 \cs_parameter_spec:N #2 }
4818 {
4819 \exp_args:Ne #1
4820 { \token_to_str:N #2 = \__kernel_exp_not:w \exp_after:wN {#2} }
4821 }
4822 {
4823 \msg_error:nneee { kernel } { bad-type }
4824 { \token_to_str:N #2 } { \token_to_meaning:N #2 } { tl }
4825 }
4826 }
4827 }
4828 \cs_new_protected:Npn \tl_show:n #1
4829 { \iow_wrap:nnnN { >~ \tl_to_str:n {#1} . } { } { } \__tl_show:n }
4830 \cs_generate_variant:Nn \tl_show:n { e , x }
4831 \cs_new_protected:Npn \__tl_show:n #1
4832 {
4833 \tl_set:Nf \l__tl_tmpa_tl { \__tl_show:w #1 \s__tl_stop }
4834 \__kernel_iow_with:Nnn \tex_newlinechar:D { 10 }
4835 {
4836 \__kernel_iow_with:Nnn \tex_errorcontextlines:D { -1 }
4837 {
4838 \tex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN
4839 { \exp_after:wN \l__tl_tmpa_tl }
4840 }
4841 }
4842 }
4843 \cs_new:Npn \__tl_show:w #1 > #2 . \s__tl_stop {#2}
4844 \cs_new_protected:Npn \tl_log:n #1
4845 { \iow_wrap:nnnN { > ~ \tl_to_str:n {#1} . } { } { } \iow_log:n }
4846 \cs_generate_variant:Nn \tl_log:n { e , x }
4847 \cs_new_protected:Npn \__kernel_chk_tl_type:NnnT #1#2#3#4
4848 {
4849 \__kernel_chk_defined:NT #1
4850 {
4851 \exp_args:Nf \tl_if_empty:nTF
4852 { \cs_prefix_spec:N #1 \cs_parameter_spec:N #1 }
4853 {
4854 \tl_set:Ne \l__tl_tmpa_tl {#3}
4855 \tl_if_eq:NNTF #1 \l__tl_tmpa_tl
4856 {#4}
4857 {
4858 \msg_error:nneeee { kernel } { bad-type }
4859 { \token_to_str:N #1 } { \tl_to_str:N #1 }
4860 {#2} { \tl_to_str:N \l__tl_tmpa_tl }
4861 }
4862 }
4863 {
4864 \msg_error:nneee { kernel } { bad-type }
4865 { \token_to_str:N #1 } { \token_to_meaning:N #1 } {#2}
4866 }
4867 }
4868 }
4869 \scan_new:N \s__tl_nil
4870 \scan_new:N \s__tl_mark
4871 \scan_new:N \s__tl_stop
4872 \tl_new:N \g_tmpa_tl
4873 \tl_new:N \g_tmpb_tl
4874 \tl_new:N \l_tmpa_tl
4875 \tl_new:N \l_tmpb_tl
4876 \cs_undefine:N \__tl_tmp:w
4877 %% File: l3tl-build.dtx
4878 \cs_new_protected:Npn \tl_build_begin:N #1
4879 { \__tl_build_begin:NN \cs_set_nopar:Npe #1 }
4880 \cs_new_protected:Npn \tl_build_gbegin:N #1
4881 { \__tl_build_begin:NN \cs_gset_nopar:Npe #1 }
4882 \cs_new_protected:Npn \__tl_build_begin:NN #1#2
4883 { \exp_args:Nc \__tl_build_begin:NNN { \cs_to_str:N #2 ' } #2 #1 }
4884 \cs_new_protected:Npn \__tl_build_begin:NNN #1#2#3
4885 {
4886 #3 #1 { }
4887 #3 #2
4888 {
4889 \exp_not:n { \exp_end: \exp_end: \exp_end: \exp_end: }
4890 \exp_not:n { \__tl_build_last:NNn #3 #1 { } }
4891 }
4892 }
4893 \cs_new_protected:Npn \tl_build_put_right:Nn #1#2
4894 {
4895 \cs_set_nopar:Npe #1
4896 { \__kernel_exp_not:w \exp_after:wN { \exp:w #1 #2 } }
4897 }
4898 \cs_generate_variant:Nn \tl_build_put_right:Nn { Ne , Nx }
4899 \cs_new_protected:Npn \tl_build_gput_right:Nn #1#2
4900 {
4901 \cs_gset_nopar:Npe #1
4902 { \__kernel_exp_not:w \exp_after:wN { \exp:w #1 #2 } }
4903 }
4904 \cs_generate_variant:Nn \tl_build_gput_right:Nn { Ne , Nx }
4905 \cs_new_protected:Npn \__tl_build_last:NNn #1#2
4906 {
4907 \if_false: { { \fi:
4908 \exp_end: \exp_end: \exp_end: \exp_end: \exp_end:
4909 \__tl_build_last:NNn #1 #2 { }
4910 }
4911 }
4912 \if_meaning:w \c_empty_tl #2
4913 \__tl_build_begin:NN #1 #2
4914 \fi:
4915 #1 #2
4916 {
4917 \__kernel_exp_not:w \exp_after:wN
4918 {
4919 \exp:w \if_false: } } \fi:
4920 \exp_after:wN \__tl_build_put:nn \exp_after:wN {#2}
4921 }
4922 \cs_new_protected:Npn \__tl_build_put:nn #1#2 { \__tl_build_put:nw {#2} #1 }
4923 \cs_new_protected:Npn \__tl_build_put:nw #1#2 \__tl_build_last:NNn #3#4#5
4924 { #2 \__tl_build_last:NNn #3 #4 { #1 #5 } }
4925 \cs_new_protected:Npn \tl_build_put_left:Nn #1
4926 { \__tl_build_put_left:NNn \cs_set_nopar:Npe #1 }
4927 \cs_generate_variant:Nn \tl_build_put_left:Nn { Ne , Nx }
4928 \cs_new_protected:Npn \tl_build_gput_left:Nn #1
4929 { \__tl_build_put_left:NNn \cs_gset_nopar:Npe #1 }
4930 \cs_generate_variant:Nn \tl_build_gput_left:Nn { Ne , Nx }
4931 \cs_new_protected:Npn \__tl_build_put_left:NNn #1#2#3
4932 {
4933 #1 #2
4934 {
4935 \__kernel_exp_not:w \exp_after:wN
4936 {
4937 \exp:w \exp_after:wN \__tl_build_put:nn
4938 \exp_after:wN {#2} {#3}
4939 }
4940 }
4941 }
4942 \cs_new_protected:Npn \tl_build_end:N #1
4943 {
4944 \__tl_build_get:NNN \__kernel_tl_set:Nx #1 #1
4945 \exp_args:Nc \__tl_build_end_loop:NN { \cs_to_str:N #1 ' } \tl_clear:N
4946 }
4947 \cs_new_protected:Npn \tl_build_gend:N #1
4948 {
4949 \__tl_build_get:NNN \__kernel_tl_gset:Nx #1 #1
4950 \exp_args:Nc \__tl_build_end_loop:NN { \cs_to_str:N #1 ' } \tl_gclear:N
4951 }
4952 \cs_new_protected:Npn \__tl_build_end_loop:NN #1#2
4953 {
4954 \if_meaning:w \c_empty_tl #1
4955 \exp_after:wN \use_none:nnnnnn
4956 \fi:
4957 #2 #1
4958 \exp_args:Nc \__tl_build_end_loop:NN { \cs_to_str:N #1 ' } #2
4959 }
4960 \cs_new_protected:Npn \tl_build_get_intermediate:NN
4961 { \__tl_build_get:NNN \__kernel_tl_set:Nx }
4962 \cs_new_protected:Npn \__tl_build_get:NNN #1#2#3
4963 { #1 #3 { \if_false: { \fi: \exp_after:wN \__tl_build_get:w #2 } } }
4964 \cs_new:Npn \__tl_build_get:w #1 \__tl_build_last:NNn #2#3#4
4965 {
4966 \exp_not:n {#4}
4967 \if_meaning:w \c_empty_tl #3
4968 \exp_after:wN \__tl_build_get_end:w
4969 \fi:
4970 \exp_after:wN \__tl_build_get:w #3
4971 }
4972 \cs_new:Npn \__tl_build_get_end:w #1#2#3
4973 { \__kernel_exp_not:w \exp_after:wN { \if_false: } \fi: }
4974 %% File: l3str.dtx
4975 \scan_new:N \s__str_mark
4976 \scan_new:N \s__str_stop
4977 \cs_new:Npn \__str_use_none_delimit_by_s_stop:w #1 \s__str_stop { }
4978 \cs_new:Npn \__str_use_i_delimit_by_s_stop:nw #1 #2 \s__str_stop {#1}
4979 \quark_new:N \q__str_recursion_tail
4980 \quark_new:N \q__str_recursion_stop
4981 \__kernel_quark_new_test:N \__str_if_recursion_tail_break:NN
4982 \__kernel_quark_new_test:N \__str_if_recursion_tail_stop_do:Nn
4983 \group_begin:
4984 \cs_set_protected:Npn \__str_tmp:n #1
4985 {
4986 \tl_if_blank:nF {#1}
4987 {
4988 \cs_new_eq:cc { str_ #1 :N } { tl_ #1 :N }
4989 \exp_args:Nc \cs_generate_variant:Nn { str_ #1 :N } { c }
4990 \__str_tmp:n
4991 }
4992 }
4993 \__str_tmp:n
4994 { new }
4995 { use }
4996 { clear }
4997 { gclear }
4998 { clear_new }
4999 { gclear_new }
5000 { }
5001 \group_end:
5002 \cs_new_eq:NN \str_set_eq:NN \tl_set_eq:NN
5003 \cs_new_eq:NN \str_gset_eq:NN \tl_gset_eq:NN
5004 \cs_generate_variant:Nn \str_set_eq:NN { c , Nc , cc }
5005 \cs_generate_variant:Nn \str_gset_eq:NN { c , Nc , cc }
5006 \cs_new_eq:NN \str_concat:NNN \tl_concat:NNN
5007 \cs_new_eq:NN \str_gconcat:NNN \tl_gconcat:NNN
5008 \cs_generate_variant:Nn \str_concat:NNN { ccc }
5009 \cs_generate_variant:Nn \str_gconcat:NNN { ccc }
5010 \cs_new_protected:Npn \str_set:Nn #1#2
5011 { \__kernel_tl_set:Nx #1 { \__kernel_tl_to_str:w {#2} } }
5012 \cs_gset_protected:Npn \str_gset:Nn #1#2
5013 { \__kernel_tl_gset:Nx #1 { \__kernel_tl_to_str:w {#2} } }
5014 \cs_new_protected:Npn \str_const:Nn #1#2
5015 {
5016 \__kernel_chk_if_free_cs:N #1
5017 \cs_gset_nopar:Npe #1 { \__kernel_tl_to_str:w {#2} }
5018 }
5019 \cs_new_protected:Npn \str_put_left:Nn #1#2
5020 {
5021 \__kernel_tl_set:Nx #1
5022 { \__kernel_tl_to_str:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
5023 }
5024 \cs_new_protected:Npn \str_gput_left:Nn #1#2
5025 {
5026 \__kernel_tl_gset:Nx #1
5027 { \__kernel_tl_to_str:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} }
5028 }
5029 \cs_new_protected:Npn \str_put_right:Nn #1#2
5030 {
5031 \__kernel_tl_set:Nx #1
5032 { \__kernel_exp_not:w \exp_after:wN {#1} \__kernel_tl_to_str:w {#2} }
5033 }
5034 \cs_new_protected:Npn \str_gput_right:Nn #1#2
5035 {
5036 \__kernel_tl_gset:Nx #1
5037 { \__kernel_exp_not:w \exp_after:wN {#1} \__kernel_tl_to_str:w {#2} }
5038 }
5039 \cs_generate_variant:Nn \str_set:Nn { NV , Ne , Nx , c , cV , ce , cx }
5040 \cs_generate_variant:Nn \str_gset:Nn { NV , Ne , Nx , c , cV , ce , cx }
5041 \cs_generate_variant:Nn \str_const:Nn { NV , Ne , Nx , c , cV , ce , cx }
5042 \cs_generate_variant:Nn \str_put_left:Nn { NV , Ne , Nx , c , cV , ce , cx }
5043 \cs_generate_variant:Nn \str_gput_left:Nn { NV , Ne , Nx , c , cV , ce , cx }
5044 \cs_generate_variant:Nn \str_put_right:Nn { NV , Ne , Nx , c , cV , ce , cx }
5045 \cs_generate_variant:Nn \str_gput_right:Nn { NV , Ne , Nx , c , cV , ce , cx }
5046 \cs_new_protected:Npn \str_replace_once:Nnn
5047 { \__str_replace:NNNnn \prg_do_nothing: \__kernel_tl_set:Nx }
5048 \cs_new_protected:Npn \str_greplace_once:Nnn
5049 { \__str_replace:NNNnn \prg_do_nothing: \__kernel_tl_gset:Nx }
5050 \cs_new_protected:Npn \str_replace_all:Nnn
5051 { \__str_replace:NNNnn \__str_replace_next:w \__kernel_tl_set:Nx }
5052 \cs_new_protected:Npn \str_greplace_all:Nnn
5053 { \__str_replace:NNNnn \__str_replace_next:w \__kernel_tl_gset:Nx }
5054 \cs_generate_variant:Nn \str_replace_once:Nnn { c }
5055 \cs_generate_variant:Nn \str_greplace_once:Nnn { c }
5056 \cs_generate_variant:Nn \str_replace_all:Nnn { c }
5057 \cs_generate_variant:Nn \str_greplace_all:Nnn { c }
5058 \cs_new_protected:Npn \__str_replace:NNNnn #1#2#3#4#5
5059 {
5060 \tl_if_empty:nTF {#4}
5061 {
5062 \msg_error:nne { kernel } { empty-search-pattern } {#5}
5063 }
5064 {
5065 \use:e
5066 {
5067 \exp_not:n { \__str_replace_aux:NNNnnn #1 #2 #3 }
5068 { \tl_to_str:N #3 }
5069 { \tl_to_str:n {#4} } { \tl_to_str:n {#5} }
5070 }
5071 }
5072 }
5073 \cs_new_protected:Npn \__str_replace_aux:NNNnnn #1#2#3#4#5#6
5074 {
5075 \cs_set:Npn \__str_replace_next:w ##1 #5 { ##1 #6 #1 }
5076 #2 #3
5077 {
5078 \__str_replace_next:w
5079 #4
5080 \__str_use_none_delimit_by_s_stop:w
5081 #5
5082 \s__str_stop
5083 }
5084 }
5085 \cs_new_eq:NN \__str_replace_next:w ?
5086 \cs_new_protected:Npn \str_remove_once:Nn #1#2
5087 { \str_replace_once:Nnn #1 {#2} { } }
5088 \cs_new_protected:Npn \str_gremove_once:Nn #1#2
5089 { \str_greplace_once:Nnn #1 {#2} { } }
5090 \cs_generate_variant:Nn \str_remove_once:Nn { c }
5091 \cs_generate_variant:Nn \str_gremove_once:Nn { c }
5092 \cs_new_protected:Npn \str_remove_all:Nn #1#2
5093 { \str_replace_all:Nnn #1 {#2} { } }
5094 \cs_new_protected:Npn \str_gremove_all:Nn #1#2
5095 { \str_greplace_all:Nnn #1 {#2} { } }
5096 \cs_generate_variant:Nn \str_remove_all:Nn { c }
5097 \cs_generate_variant:Nn \str_gremove_all:Nn { c }
5098 \prg_new_eq_conditional:NNn \str_if_exist:N \tl_if_exist:N
5099 { p , T , F , TF }
5100 \prg_new_eq_conditional:NNn \str_if_exist:c \tl_if_exist:c
5101 { p , T , F , TF }
5102 \prg_new_eq_conditional:NNn \str_if_empty:N \tl_if_empty:N
5103 { p , T , F , TF }
5104 \prg_new_eq_conditional:NNn \str_if_empty:c \tl_if_empty:c
5105 { p , T , F , TF }
5106 \prg_new_eq_conditional:NNn \str_if_empty:n \tl_if_empty:n
5107 { p , T , F , TF }
5108 \cs_new_eq:NN \__str_if_eq:nn \tex_strcmp:D
5109 \prg_new_conditional:Npnn \str_compare:nNn #1#2#3 { p , T , F , TF }
5110 {
5111 \if_int_compare:w
5112 \__str_if_eq:nn { \exp_not:n {#1} } { \exp_not:n {#3} }
5113 #2 \c_zero_int
5114 \prg_return_true: \else: \prg_return_false: \fi:
5115 }
5116 \prg_new_conditional:Npnn \str_compare:eNe #1#2#3 { p , T , F , TF }
5117 {
5118 \if_int_compare:w \__str_if_eq:nn {#1} {#3} #2 \c_zero_int
5119 \prg_return_true: \else: \prg_return_false: \fi:
5120 }
5121 \prg_new_conditional:Npnn \str_if_eq:nn #1#2 { p , T , F , TF }
5122 {
5123 \if:w 0 \__str_if_eq:nn { \exp_not:n {#1} } { \exp_not:n {#2} }
5124 \prg_return_true: \else: \prg_return_false: \fi:
5125 }
5126 \prg_generate_conditional_variant:Nnn \str_if_eq:nn
5127 { V , v , o , nV , no , VV , nv } { p , T , F , TF }
5128 \prg_new_conditional:Npnn \str_if_eq:ee #1#2 { p , T , F , TF }
5129 {
5130 \if:w 0 \__str_if_eq:nn {#1} {#2}
5131 \prg_return_true: \else: \prg_return_false: \fi:
5132 }
5133 \prg_new_conditional:Npnn \str_if_eq:NN #1#2 { p , TF , T , F }
5134 {
5135 \if:w 0 \__str_if_eq:nn { \tl_to_str:N #1 } { \tl_to_str:N #2 }
5136 \prg_return_true: \else: \prg_return_false: \fi:
5137 }
5138 \prg_generate_conditional_variant:Nnn \str_if_eq:NN
5139 { c , Nc , cc } { T , F , TF , p }
5140 \prg_new_protected_conditional:Npnn \str_if_in:Nn #1#2 { T , F , TF }
5141 {
5142 \use:e
5143 { \tl_if_in:nnTF { \tl_to_str:N #1 } { \tl_to_str:n {#2} } }
5144 { \prg_return_true: } { \prg_return_false: }
5145 }
5146 \prg_generate_conditional_variant:Nnn \str_if_in:Nn
5147 { c } { T , F , TF }
5148 \prg_new_protected_conditional:Npnn \str_if_in:nn #1#2 { T , F , TF }
5149 {
5150 \use:e
5151 { \tl_if_in:nnTF { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } }
5152 { \prg_return_true: } { \prg_return_false: }
5153 }
5154 \cs_new:Npn \str_case:nn #1#2
5155 {
5156 \exp:w
5157 \__str_case:nnTF {#1} {#2} { } { }
5158 }
5159 \cs_new:Npn \str_case:nnT #1#2#3
5160 {
5161 \exp:w
5162 \__str_case:nnTF {#1} {#2} {#3} { }
5163 }
5164 \cs_new:Npn \str_case:nnF #1#2
5165 {
5166 \exp:w
5167 \__str_case:nnTF {#1} {#2} { }
5168 }
5169 \cs_new:Npn \str_case:nnTF #1#2
5170 {
5171 \exp:w
5172 \__str_case:nnTF {#1} {#2}
5173 }
5174 \cs_new:Npn \__str_case:nnTF #1#2#3#4
5175 { \__str_case:nw {#1} #2 {#1} { } \s__str_mark {#3} \s__str_mark {#4} \s__str_stop }
5176 \cs_generate_variant:Nn \str_case:nn { V , o , e , nV , nv , ne }
5177 \prg_generate_conditional_variant:Nnn \str_case:nn
5178 { V , o , e , nV , nv , ne } { T , F , TF }
5179 \cs_new_eq:NN \str_case:Nn \str_case:Vn
5180 \cs_new_eq:NN \str_case:NnT \str_case:VnT
5181 \cs_new_eq:NN \str_case:NnF \str_case:VnF
5182 \cs_new_eq:NN \str_case:NnTF \str_case:VnTF
5183 \cs_new:Npn \__str_case:nw #1#2#3
5184 {
5185 \str_if_eq:nnTF {#1} {#2}
5186 { \__str_case_end:nw {#3} }
5187 { \__str_case:nw {#1} }
5188 }
5189 \cs_new:Npn \str_case_e:nn #1#2
5190 {
5191 \exp:w
5192 \__str_case_e:nnTF {#1} {#2} { } { }
5193 }
5194 \cs_new:Npn \str_case_e:nnT #1#2#3
5195 {
5196 \exp:w
5197 \__str_case_e:nnTF {#1} {#2} {#3} { }
5198 }
5199 \cs_new:Npn \str_case_e:nnF #1#2
5200 {
5201 \exp:w
5202 \__str_case_e:nnTF {#1} {#2} { }
5203 }
5204 \cs_new:Npn \str_case_e:nnTF #1#2
5205 {
5206 \exp:w
5207 \__str_case_e:nnTF {#1} {#2}
5208 }
5209 \cs_new:Npn \__str_case_e:nnTF #1#2#3#4
5210 { \__str_case_e:nw {#1} #2 {#1} { } \s__str_mark {#3} \s__str_mark {#4} \s__str_stop }
5211 \cs_generate_variant:Nn \str_case_e:nn { e }
5212 \prg_generate_conditional_variant:Nnn \str_case_e:nn { e } { T , F , TF }
5213 \cs_new:Npn \__str_case_e:nw #1#2#3
5214 {
5215 \str_if_eq:eeTF {#1} {#2}
5216 { \__str_case_end:nw {#3} }
5217 { \__str_case_e:nw {#1} }
5218 }
5219 \cs_new:Npn \__str_case_end:nw #1#2#3 \s__str_mark #4#5 \s__str_stop
5220 { \exp_end: #1 #4 }
5221 \cs_new:Npn \str_map_function:nN #1#2
5222 {
5223 \exp_after:wN \__str_map_function:w
5224 \exp_after:wN \__str_map_function:nn \exp_after:wN #2
5225 \__kernel_tl_to_str:w {#1}
5226 \q__str_recursion_tail ? ~
5227 \prg_break_point:Nn \str_map_break: { }
5228 }
5229 \cs_new:Npn \str_map_function:NN
5230 { \exp_args:No \str_map_function:nN }
5231 \cs_new:Npn \__str_map_function:w #1 ~
5232 { #1 { ~ { ~ } \__str_map_function:w } }
5233 \cs_new:Npn \__str_map_function:nn #1#2
5234 {
5235 \if_meaning:w \q__str_recursion_tail #2
5236 \exp_after:wN \str_map_break:
5237 \fi:
5238 #1 #2 \__str_map_function:nn {#1}
5239 }
5240 \cs_generate_variant:Nn \str_map_function:NN { c }
5241 \cs_new_protected:Npn \str_map_inline:nn #1#2
5242 {
5243 \int_gincr:N \g__kernel_prg_map_int
5244 \cs_gset_protected:cpn
5245 { __str_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
5246 \use:e
5247 {
5248 \exp_not:N \__str_map_inline:NN
5249 \exp_not:c { __str_map_ \int_use:N \g__kernel_prg_map_int :w }
5250 \__kernel_str_to_other_fast:n {#1}
5251 }
5252 \q__str_recursion_tail
5253 \prg_break_point:Nn \str_map_break:
5254 { \int_gdecr:N \g__kernel_prg_map_int }
5255 }
5256 \cs_new_protected:Npn \str_map_inline:Nn
5257 { \exp_args:No \str_map_inline:nn }
5258 \cs_generate_variant:Nn \str_map_inline:Nn { c }
5259 \cs_new:Npn \__str_map_inline:NN #1#2
5260 {
5261 \__str_if_recursion_tail_break:NN #2 \str_map_break:
5262 \exp_args:No #1 { \token_to_str:N #2 }
5263 \__str_map_inline:NN #1
5264 }
5265 \cs_new_protected:Npn \str_map_variable:nNn #1#2#3
5266 {
5267 \use:e
5268 {
5269 \exp_not:n { \__str_map_variable:NnN #2 {#3} }
5270 \__kernel_str_to_other_fast:n {#1}
5271 }
5272 \q__str_recursion_tail
5273 \prg_break_point:Nn \str_map_break: { }
5274 }
5275 \cs_new_protected:Npn \str_map_variable:NNn
5276 { \exp_args:No \str_map_variable:nNn }
5277 \cs_new_protected:Npn \__str_map_variable:NnN #1#2#3
5278 {
5279 \__str_if_recursion_tail_break:NN #3 \str_map_break:
5280 \str_set:Nn #1 {#3}
5281 \use:n {#2}
5282 \__str_map_variable:NnN #1 {#2}
5283 }
5284 \cs_generate_variant:Nn \str_map_variable:NNn { c }
5285 \cs_new:Npn \str_map_break:
5286 { \prg_map_break:Nn \str_map_break: { } }
5287 \cs_new:Npn \str_map_break:n
5288 { \prg_map_break:Nn \str_map_break: }
5289 \cs_new:Npn \str_map_tokens:nn #1#2
5290 {
5291 \exp_args:Nno \use:nn
5292 { \__str_map_function:w \__str_map_function:nn {#2} }
5293 { \__kernel_tl_to_str:w {#1} }
5294 \q__str_recursion_tail ? ~
5295 \prg_break_point:Nn \str_map_break: { }
5296 }
5297 \cs_new:Npn \str_map_tokens:Nn { \exp_args:No \str_map_tokens:nn }
5298 \cs_generate_variant:Nn \str_map_tokens:Nn { c }
5299 \cs_new:Npn \__kernel_str_to_other:n #1
5300 {
5301 \exp_after:wN \__str_to_other_loop:w
5302 \tl_to_str:n {#1} ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \s__str_mark \s__str_stop
5303 }
5304 \group_begin:
5305 \tex_lccode:D `\* = `\ %
5306 \tex_lccode:D `\A = `\A %
5307 \tex_lowercase:D
5308 {
5309 \group_end:
5310 \cs_new:Npn \__str_to_other_loop:w
5311 #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 \s__str_stop
5312 {
5313 \if_meaning:w A #8
5314 \__str_to_other_end:w
5315 \fi:
5316 \__str_to_other_loop:w
5317 #9 #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * \s__str_stop
5318 }
5319 \cs_new:Npn \__str_to_other_end:w \fi: #1 \s__str_mark #2 * A #3 \s__str_stop
5320 { \fi: #2 }
5321 }
5322 \cs_new:Npn \__kernel_str_to_other_fast:n #1
5323 {
5324 \exp_after:wN \__str_to_other_fast_loop:w \tl_to_str:n {#1} ~
5325 A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \s__str_stop
5326 }
5327 \group_begin:
5328 \tex_lccode:D `\* = `\ %
5329 \tex_lccode:D `\A = `\A %
5330 \tex_lowercase:D
5331 {
5332 \group_end:
5333 \cs_new:Npn \__str_to_other_fast_loop:w
5334 #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 ~
5335 {
5336 \if_meaning:w A #9
5337 \__str_to_other_fast_end:w
5338 \fi:
5339 #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * #9
5340 \__str_to_other_fast_loop:w *
5341 }
5342 \cs_new:Npn \__str_to_other_fast_end:w #1 * A #2 \s__str_stop {#1}
5343 }
5344 \cs_new_eq:NN \__str_sep: \__kernel_int_sep:
5345 \cs_new:Npn \str_item:Nn { \exp_args:No \str_item:nn }
5346 \cs_generate_variant:Nn \str_item:Nn { c }
5347 \cs_new:Npn \str_item:nn #1#2
5348 {
5349 \exp_args:Nf \tl_to_str:n
5350 {
5351 \exp_args:Nf \__str_item:nn
5352 { \__kernel_str_to_other:n {#1} } {#2}
5353 }
5354 }
5355 \cs_new:Npn \str_item_ignore_spaces:nn #1
5356 { \exp_args:No \__str_item:nn { \tl_to_str:n {#1} } }
5357 \cs_new:Npn \__str_item:nn #1#2
5358 {
5359 \exp_after:wN \__str_item:w
5360 \int_value:w \int_eval:n {#2} \exp_after:wN \__str_sep:
5361 \int_value:w \__str_count:n {#1} \__str_sep:
5362 #1 \s__str_stop
5363 }
5364 \cs_new:Npn \__str_item:w #1 \__str_sep: #2 \__str_sep:
5365 {
5366 \int_compare:nNnTF {#1} < 0
5367 {
5368 \int_compare:nNnTF {#1} < {-#2}
5369 { \__str_use_none_delimit_by_s_stop:w }
5370 {
5371 \exp_after:wN \__str_use_i_delimit_by_s_stop:nw
5372 \exp:w \exp_after:wN \__str_skip_exp_end:w
5373 \int_value:w \int_eval:n { #1 + #2 } \__str_sep:
5374 }
5375 }
5376 {
5377 \int_compare:nNnTF {#1} > {#2}
5378 { \__str_use_none_delimit_by_s_stop:w }
5379 {
5380 \exp_after:wN \__str_use_i_delimit_by_s_stop:nw
5381 \exp:w \__str_skip_exp_end:w #1 \__str_sep: { }
5382 }
5383 }
5384 }
5385 \cs_new:Npn \__str_skip_exp_end:w #1 \__str_sep:
5386 {
5387 \if_int_compare:w #1 > 8 \exp_stop_f:
5388 \exp_after:wN \__str_skip_loop:wNNNNNNNN
5389 \else:
5390 \exp_after:wN \__str_skip_end:w
5391 \int_value:w \int_eval:w
5392 \fi:
5393 #1 \__str_sep:
5394 }
5395 \cs_new:Npn \__str_skip_loop:wNNNNNNNN #1 \__str_sep: #2#3#4#5#6#7#8#9
5396 {
5397 \exp_after:wN \__str_skip_exp_end:w
5398 \int_value:w \int_eval:n { #1 - 8 } \__str_sep:
5399 }
5400 \cs_new:Npn \__str_skip_end:w #1 \__str_sep:
5401 {
5402 \exp_after:wN \__str_skip_end:NNNNNNNN
5403 \if_case:w #1 \exp_stop_f: \or: \or: \or: \or: \or: \or: \or: \or:
5404 }
5405 \cs_new:Npn \__str_skip_end:NNNNNNNN #1#2#3#4#5#6#7#8 { \fi: \exp_end: }
5406 \cs_new:Npn \str_range:Nnn { \exp_args:No \str_range:nnn }
5407 \cs_generate_variant:Nn \str_range:Nnn { c }
5408 \cs_new:Npn \str_range:nnn #1#2#3
5409 {
5410 \exp_args:Nf \tl_to_str:n
5411 {
5412 \exp_args:Nf \__str_range:nnn
5413 { \__kernel_str_to_other:n {#1} } {#2} {#3}
5414 }
5415 }
5416 \cs_new:Npn \str_range_ignore_spaces:nnn #1
5417 { \exp_args:No \__str_range:nnn { \tl_to_str:n {#1} } }
5418 \cs_new:Npn \__str_range:nnn #1#2#3
5419 {
5420 \exp_after:wN \__str_range:w
5421 \int_value:w \__str_count:n {#1} \exp_after:wN \__str_sep:
5422 \int_value:w \int_eval:n { (#2) - 1 } \exp_after:wN \__str_sep:
5423 \int_value:w \int_eval:n {#3} \__str_sep:
5424 #1 \s__str_stop
5425 }
5426 \cs_new:Npn \__str_range:w #1 \__str_sep: #2 \__str_sep: #3 \__str_sep:
5427 {
5428 \exp_args:Nf \__str_range:nnw
5429 { \__str_range_normalize:nn {#2} {#1} }
5430 { \__str_range_normalize:nn {#3} {#1} }
5431 }
5432 \cs_new:Npn \__str_range:nnw #1#2
5433 {
5434 \exp_after:wN \__str_collect_delimit_by_q_stop:w
5435 \int_value:w \int_eval:n { #2 - #1 } \exp_after:wN \__str_sep:
5436 \exp:w \__str_skip_exp_end:w #1 \__str_sep:
5437 }
5438 \cs_new:Npn \__str_range_normalize:nn #1#2
5439 {
5440 \int_eval:n
5441 {
5442 \if_int_compare:w #1 < \c_zero_int
5443 \if_int_compare:w #1 < -#2 \exp_stop_f:
5444 0
5445 \else:
5446 #1 + #2 + 1
5447 \fi:
5448 \else:
5449 \if_int_compare:w #1 < #2 \exp_stop_f:
5450 #1
5451 \else:
5452 #2
5453 \fi:
5454 \fi:
5455 }
5456 }
5457 \cs_new:Npn \__str_collect_delimit_by_q_stop:w #1 \__str_sep:
5458 { \__str_collect_loop:wn #1 \__str_sep: { } }
5459 \cs_new:Npn \__str_collect_loop:wn #1 \__str_sep:
5460 {
5461 \if_int_compare:w #1 > 7 \exp_stop_f:
5462 \exp_after:wN \__str_collect_loop:wnNNNNNNN
5463 \else:
5464 \exp_after:wN \__str_collect_end:wn
5465 \fi:
5466 #1 \__str_sep:
5467 }
5468 \cs_new:Npn \__str_collect_loop:wnNNNNNNN #1 \__str_sep: #2 #3#4#5#6#7#8#9
5469 {
5470 \exp_after:wN \__str_collect_loop:wn
5471 \int_value:w \int_eval:n { #1 - 7 } \__str_sep:
5472 { #2 #3#4#5#6#7#8#9 }
5473 }
5474 \cs_new:Npn \__str_collect_end:wn #1 \__str_sep:
5475 {
5476 \exp_after:wN \__str_collect_end:nnnnnnnnw
5477 \if_case:w \if_int_compare:w #1 > \c_zero_int
5478 #1 \else: 0 \fi: \exp_stop_f:
5479 \or: \or: \or: \or: \or: \or: \fi:
5480 }
5481 \cs_new:Npn \__str_collect_end:nnnnnnnnw #1#2#3#4#5#6#7#8 #9 \s__str_stop
5482 { #1#2#3#4#5#6#7#8 }
5483 \cs_new:Npn \str_count_spaces:N
5484 { \exp_args:No \str_count_spaces:n }
5485 \cs_generate_variant:Nn \str_count_spaces:N { c }
5486 \cs_new:Npn \str_count_spaces:n #1
5487 {
5488 \int_eval:n
5489 {
5490 \exp_after:wN \__str_count_spaces_loop:w
5491 \tl_to_str:n {#1} ~
5492 X 7 ~ X 6 ~ X 5 ~ X 4 ~ X 3 ~ X 2 ~ X 1 ~ X 0 ~ X -1 ~
5493 \s__str_stop
5494 }
5495 }
5496 \cs_new:Npn \__str_count_spaces_loop:w #1~#2~#3~#4~#5~#6~#7~#8~#9~
5497 {
5498 \if_meaning:w X #9
5499 \__str_use_i_delimit_by_s_stop:nw
5500 \fi:
5501 9 + \__str_count_spaces_loop:w
5502 }
5503 \cs_new:Npn \str_count:N { \exp_args:No \str_count:n }
5504 \cs_generate_variant:Nn \str_count:N { c }
5505 \cs_new:Npn \str_count:n #1
5506 {
5507 \__str_count_aux:n
5508 {
5509 \str_count_spaces:n {#1}
5510 + \exp_after:wN \__str_count_loop:NNNNNNNNN \tl_to_str:n {#1}
5511 }
5512 }
5513 \cs_generate_variant:Nn \str_count:n { e }
5514 \cs_new:Npn \__str_count:n #1
5515 {
5516 \__str_count_aux:n
5517 { \__str_count_loop:NNNNNNNNN #1 }
5518 }
5519 \cs_new:Npn \str_count_ignore_spaces:n #1
5520 {
5521 \__str_count_aux:n
5522 { \exp_after:wN \__str_count_loop:NNNNNNNNN \tl_to_str:n {#1} }
5523 }
5524 \cs_generate_variant:Nn \str_ignore_spaces:n { e }
5525 \cs_new:Npn \__str_count_aux:n #1
5526 {
5527 \int_eval:n
5528 {
5529 #1
5530 { X 8 } { X 7 } { X 6 }
5531 { X 5 } { X 4 } { X 3 }
5532 { X 2 } { X 1 } { X 0 }
5533 \s__str_stop
5534 }
5535 }
5536 \cs_new:Npn \__str_count_loop:NNNNNNNNN #1#2#3#4#5#6#7#8#9
5537 {
5538 \if_meaning:w X #9
5539 \exp_after:wN \__str_use_none_delimit_by_s_stop:w
5540 \fi:
5541 9 + \__str_count_loop:NNNNNNNNN
5542 }
5543 \cs_new:Npn \str_head:N { \exp_args:No \str_head:n }
5544 \cs_generate_variant:Nn \str_head:N { c }
5545 \cs_new:Npn \str_head:n #1
5546 {
5547 \exp_after:wN \__str_head:w
5548 \tl_to_str:n {#1}
5549 { { } } ~ \s__str_stop
5550 }
5551 \cs_new:Npn \__str_head:w #1 ~ %
5552 { \__str_use_i_delimit_by_s_stop:nw #1 { ~ } }
5553 \cs_new:Npn \str_head_ignore_spaces:n #1
5554 {
5555 \exp_after:wN \__str_use_i_delimit_by_s_stop:nw
5556 \tl_to_str:n {#1} { } \s__str_stop
5557 }
5558 \cs_new:Npn \str_tail:N { \exp_args:No \str_tail:n }
5559 \cs_generate_variant:Nn \str_tail:N { c }
5560 \cs_new:Npn \str_tail:n #1
5561 {
5562 \exp_after:wN \__str_tail_auxi:w
5563 \reverse_if:N \if_charcode:w
5564 \scan_stop: \tl_to_str:n {#1} X X \s__str_stop
5565 }
5566 \cs_new:Npn \__str_tail_auxi:w #1 X #2 \s__str_stop { \fi: #1 }
5567 \cs_new:Npn \str_tail_ignore_spaces:n #1
5568 {
5569 \exp_after:wN \__str_tail_auxii:w
5570 \tl_to_str:n {#1} \s__str_mark \s__str_mark \s__str_stop
5571 }
5572 \cs_new:Npn \__str_tail_auxii:w #1 #2 \s__str_mark #3 \s__str_stop { #2 }
5573 \cs_new:Npn \str_casefold:n #1 { \__str_change_case:nn {#1} { casefold } }
5574 \cs_new:Npn \str_lowercase:n #1 { \__str_change_case:nn {#1} { lowercase } }
5575 \cs_new:Npn \str_uppercase:n #1 { \__str_change_case:nn {#1} { uppercase } }
5576 \cs_generate_variant:Nn \str_casefold:n { V }
5577 \cs_generate_variant:Nn \str_lowercase:n { f }
5578 \cs_generate_variant:Nn \str_uppercase:n { f }
5579 \cs_new:Npn \__str_change_case:nn #1
5580 {
5581 \exp_after:wN \__str_change_case_aux:nn \exp_after:wN
5582 { \tl_to_str:n {#1} }
5583 }
5584 \cs_new:Npn \__str_change_case_aux:nn #1#2
5585 {
5586 \__str_change_case_loop:nw {#2} #1 \q__str_recursion_tail \q__str_recursion_stop
5587 \__str_change_case_result:n { }
5588 }
5589 \cs_new:Npn \__str_change_case_output:nw #1#2 \__str_change_case_result:n #3
5590 { #2 \__str_change_case_result:n { #3 #1 } }
5591 \cs_generate_variant:Nn \__str_change_case_output:nw { f }
5592 \cs_new:Npn \__str_change_case_end:wn #1 \__str_change_case_result:n #2
5593 { \tl_to_str:n {#2} }
5594 \cs_new:Npn \__str_change_case_loop:nw #1#2 \q__str_recursion_stop
5595 {
5596 \tl_if_head_is_space:nTF {#2}
5597 { \__str_change_case_space:n }
5598 { \__str_change_case_char:nN }
5599 {#1} #2 \q__str_recursion_stop
5600 }
5601 \exp_last_unbraced:NNNNo
5602 \cs_new:Npn \__str_change_case_space:n #1 \c_space_tl
5603 {
5604 \__str_change_case_output:nw { ~ }
5605 \__str_change_case_loop:nw {#1}
5606 }
5607 \cs_new:Npn \__str_change_case_char:nN #1#2
5608 {
5609 \__str_if_recursion_tail_stop_do:Nn #2
5610 { \__str_change_case_end:wn }
5611 \__str_change_case_codepoint:nN {#1} #2
5612 }
5613 \if_int_compare:w 0
5614 \cs_if_exist:NT \tex_XeTeXversion:D { 1 }
5615 \cs_if_exist:NT \tex_luatexversion:D { 1 }
5616 > 0 \exp_stop_f:
5617 \cs_new:Npn \__str_change_case_codepoint:nN #1#2
5618 { \__str_change_case_char:fnn { \int_eval:n {`#2} } {#1} {#2} }
5619 \else:
5620 \cs_new:Npe \__str_change_case_codepoint:nN #1#2
5621 {
5622 \exp_not:N \int_compare:nNnTF {`#2} > { "80 }
5623 {
5624 \cs_if_exist:NTF \tex_pdftexversion:D
5625 { \exp_not:N \__str_change_case_char_auxi:nN }
5626 {
5627 \exp_not:N \int_compare:nNnTF {`#2} > { "FF }
5628 { \exp_not:N \__str_change_case_char_auxii:nN }
5629 { \exp_not:N \__str_change_case_char_auxi:nN }
5630 }
5631 }
5632 { \exp_not:N \__str_change_case_char_auxii:nN }
5633 {#1} #2
5634 }
5635 \cs_new:Npn \__str_change_case_char_auxi:nN #1#2
5636 {
5637 \int_compare:nNnTF {`#2} < { "E0 }
5638 { \__str_change_case_codepoint:nNN }
5639 {
5640 \int_compare:nNnTF {`#2} < { "F0 }
5641 { \__str_change_case_codepoint:nNNN }
5642 { \__str_change_case_codepoint:nNNNNN }
5643 }
5644 {#1} #2
5645 }
5646 \cs_new:Npn \__str_change_case_char_auxii:nN #1#2
5647 { \__str_change_case_char:fnn { \int_eval:n {`#2} } {#1} {#2} }
5648 \cs_new:Npn \__str_change_case_codepoint:nNN #1#2#3
5649 {
5650 \__str_change_case_char:fnn
5651 { \int_eval:n { (`#2 - "C0) * "40 + `#3 - "80 } }
5652 {#1} {#2#3}
5653 }
5654 \cs_new:Npn \__str_change_case_codepoint:nNNN #1#2#3#4
5655 {
5656 \__str_change_case_char:fnn
5657 {
5658 \int_eval:n
5659 { (`#2 - "E0) * "1000 + (`#3 - "80) * "40 + `#4 - "80 }
5660 }
5661 {#1} {#2#3#4}
5662 }
5663 \cs_new:Npn \__str_change_case_codepoint:nNNNN #1#2#3#4#5
5664 {
5665 \__str_change_case_char:fnn
5666 {
5667 \int_eval:n
5668 {
5669 (`#2 - "F0) * "40000
5670 + (`#3 - "80) * "1000
5671 + (`#4 - "80) * "40
5672 + `#5 - "80
5673 }
5674 }
5675 {#1} {#2#3#4#5}
5676 }
5677 \fi:
5678 \cs_new:Npn \__str_change_case_char:nnn #1#2#3
5679 {
5680 \__str_change_case_output:fw
5681 {
5682 \exp_args:Ne \__str_change_case_char_aux:nnn
5683 { \__kernel_codepoint_case:nn {#2} {#1} } {#1} {#3}
5684 }
5685 \__str_change_case_loop:nw {#2}
5686 }
5687 \cs_generate_variant:Nn \__str_change_case_char:nnn { f }
5688 \cs_new:Npn \__str_change_case_char_aux:nnn #1#2#3
5689 {
5690 \use:e { \__str_change_case_char:nnnnn #1 {#2} {#3} }
5691 }
5692 \cs_new:Npn \__str_change_case_char:nnnnn #1#2#3#4#5
5693 {
5694 \int_compare:nNnTF {#1} = {#4}
5695 { \tl_to_str:n {#5} }
5696 {
5697 \codepoint_str_generate:n {#1}
5698 \tl_if_blank:nF {#2}
5699 {
5700 \codepoint_str_generate:n {#2}
5701 \tl_if_blank:nF {#3}
5702 { \codepoint_str_generate:n {#3} }
5703 }
5704 }
5705 }
5706 \cs_new:Npn \str_mdfive_hash:n #1 { \tex_mdfivesum:D { \tl_to_str:n {#1} } }
5707 \cs_generate_variant:Nn \str_mdfive_hash:n { V , v , o }
5708 \cs_new:Npn \str_mdfive_hash:e #1 { \tex_mdfivesum:D {#1} }
5709 \str_const:Ne \c_ampersand_str { \cs_to_str:N \& }
5710 \str_const:Ne \c_atsign_str { \cs_to_str:N \@ }
5711 \str_const:Ne \c_backslash_str { \cs_to_str:N \\ }
5712 \str_const:Ne \c_left_brace_str { \cs_to_str:N \{ }
5713 \str_const:Ne \c_right_brace_str { \cs_to_str:N \} }
5714 \str_const:Ne \c_circumflex_str { \cs_to_str:N \^ }
5715 \str_const:Ne \c_colon_str { \cs_to_str:N \: }
5716 \str_const:Ne \c_dollar_str { \cs_to_str:N \$ }
5717 \str_const:Ne \c_hash_str { \cs_to_str:N \# }
5718 \str_const:Ne \c_percent_str { \cs_to_str:N \% }
5719 \str_const:Ne \c_tilde_str { \cs_to_str:N \~ }
5720 \str_const:Ne \c_underscore_str { \cs_to_str:N \_ }
5721 \str_const:Ne \c_zero_str { 0 }
5722 \cs_new_eq:NN \c_empty_str \c_empty_tl
5723 \str_new:N \l_tmpa_str
5724 \str_new:N \l_tmpb_str
5725 \str_new:N \g_tmpa_str
5726 \str_new:N \g_tmpb_str
5727 \cs_new_eq:NN \str_show:n \tl_show:n
5728 \cs_new_protected:Npn \str_show:N #1
5729 {
5730 \__kernel_chk_tl_type:NnnT #1 { str } { \tl_to_str:N #1 }
5731 { \tl_show:N #1 }
5732 }
5733 \cs_generate_variant:Nn \str_show:N { c }
5734 \cs_new_eq:NN \str_log:n \tl_log:n
5735 \cs_new_protected:Npn \str_log:N #1
5736 {
5737 \__kernel_chk_tl_type:NnnT #1 { str } { \tl_to_str:N #1 }
5738 { \tl_log:N #1 }
5739 }
5740 \cs_generate_variant:Nn \str_log:N { c }
5741 \cs_gset_eq:NN \__cs_generate_variant_chk:nnTF \str_if_eq:nnTF
5742 %% File: l3seq.dtx
5743 \scan_new:N \s__seq
5744 \scan_new:N \s__seq_mark
5745 \scan_new:N \s__seq_stop
5746 \cs_new:Npn \__seq_item:n
5747 {
5748 \msg_expandable_error:nn { seq } { misused }
5749 \use_none:n
5750 }
5751 \tl_new:N \l__seq_tmpa_tl
5752 \tl_new:N \l__seq_tmpb_tl
5753 \cs_new_eq:NN \__seq_tmp:w ?
5754 \tl_const:Nn \c_empty_seq { \s__seq }
5755 \cs_new_protected:Npn \seq_new:N #1
5756 {
5757 \__kernel_chk_if_free_cs:N #1
5758 \cs_gset_eq:NN #1 \c_empty_seq
5759 }
5760 \cs_generate_variant:Nn \seq_new:N { c }
5761 \cs_new_protected:Npn \seq_clear:N #1
5762 { \seq_set_eq:NN #1 \c_empty_seq }
5763 \cs_generate_variant:Nn \seq_clear:N { c }
5764 \cs_new_protected:Npn \seq_gclear:N #1
5765 { \seq_gset_eq:NN #1 \c_empty_seq }
5766 \cs_generate_variant:Nn \seq_gclear:N { c }
5767 \cs_new_protected:Npn \seq_clear_new:N #1
5768 { \seq_if_exist:NTF #1 { \seq_clear:N #1 } { \seq_new:N #1 } }
5769 \cs_generate_variant:Nn \seq_clear_new:N { c }
5770 \cs_new_protected:Npn \seq_gclear_new:N #1
5771 { \seq_if_exist:NTF #1 { \seq_gclear:N #1 } { \seq_new:N #1 } }
5772 \cs_generate_variant:Nn \seq_gclear_new:N { c }
5773 \cs_new_eq:NN \seq_set_eq:NN \tl_set_eq:NN
5774 \cs_new_eq:NN \seq_set_eq:Nc \tl_set_eq:Nc
5775 \cs_new_eq:NN \seq_set_eq:cN \tl_set_eq:cN
5776 \cs_new_eq:NN \seq_set_eq:cc \tl_set_eq:cc
5777 \cs_new_eq:NN \seq_gset_eq:NN \tl_gset_eq:NN
5778 \cs_new_eq:NN \seq_gset_eq:Nc \tl_gset_eq:Nc
5779 \cs_new_eq:NN \seq_gset_eq:cN \tl_gset_eq:cN
5780 \cs_new_eq:NN \seq_gset_eq:cc \tl_gset_eq:cc
5781 \cs_new_protected:Npn \seq_set_from_clist:NN #1#2
5782 {
5783 \__kernel_tl_set:Nx #1
5784 { \s__seq \clist_map_function:NN #2 \__seq_wrap_item:n }
5785 }
5786 \cs_new_protected:Npn \seq_set_from_clist:Nn #1#2
5787 {
5788 \__kernel_tl_set:Nx #1
5789 { \s__seq \clist_map_function:nN {#2} \__seq_wrap_item:n }
5790 }
5791 \cs_new_protected:Npn \seq_gset_from_clist:NN #1#2
5792 {
5793 \__kernel_tl_gset:Nx #1
5794 { \s__seq \clist_map_function:NN #2 \__seq_wrap_item:n }
5795 }
5796 \cs_new_protected:Npn \seq_gset_from_clist:Nn #1#2
5797 {
5798 \__kernel_tl_gset:Nx #1
5799 { \s__seq \clist_map_function:nN {#2} \__seq_wrap_item:n }
5800 }
5801 \cs_generate_variant:Nn \seq_set_from_clist:NN { Nc }
5802 \cs_generate_variant:Nn \seq_set_from_clist:NN { c , cc }
5803 \cs_generate_variant:Nn \seq_set_from_clist:Nn { c }
5804 \cs_generate_variant:Nn \seq_gset_from_clist:NN { Nc }
5805 \cs_generate_variant:Nn \seq_gset_from_clist:NN { c , cc }
5806 \cs_generate_variant:Nn \seq_gset_from_clist:Nn { c }
5807 \cs_new_protected:Npn \seq_const_from_clist:Nn #1#2
5808 {
5809 \tl_const:Ne #1
5810 { \s__seq \clist_map_function:nN {#2} \__seq_wrap_item:n }
5811 }
5812 \cs_generate_variant:Nn \seq_const_from_clist:Nn { c }
5813 \cs_new_protected:Npn \seq_set_split:Nnn
5814 { \__seq_set_split:NNNnn \__kernel_tl_set:Nx \tl_trim_spaces:n }
5815 \cs_new_protected:Npn \seq_gset_split:Nnn
5816 { \__seq_set_split:NNNnn \__kernel_tl_gset:Nx \tl_trim_spaces:n }
5817 \cs_new_protected:Npn \seq_set_split_keep_spaces:Nnn
5818 { \__seq_set_split:NNNnn \__kernel_tl_set:Nx \exp_not:n }
5819 \cs_new_protected:Npn \seq_gset_split_keep_spaces:Nnn
5820 { \__seq_set_split:NNNnn \__kernel_tl_gset:Nx \exp_not:n }
5821 \cs_new_protected:Npn \__seq_set_split:NNNnn #1#2#3#4#5
5822 {
5823 \tl_if_empty:nTF {#4}
5824 {
5825 \tl_set:Nn \l__seq_tmpa_tl
5826 { \tl_map_function:nN {#5} \__seq_wrap_item:n }
5827 }
5828 {
5829 \tl_set:Nn \l__seq_tmpa_tl
5830 {
5831 \__seq_set_split:Nw #2 \prg_do_nothing:
5832 #5
5833 \__seq_set_split_end:
5834 }
5835 \tl_replace_all:Nnn \l__seq_tmpa_tl {#4}
5836 {
5837 \__seq_set_split_end:
5838 \__seq_set_split:Nw #2 \prg_do_nothing:
5839 }
5840 \__kernel_tl_set:Nx \l__seq_tmpa_tl { \l__seq_tmpa_tl }
5841 }
5842 #1 #3 { \s__seq \l__seq_tmpa_tl }
5843 }
5844 \cs_new:Npn \__seq_set_split:Nw #1#2 \__seq_set_split_end:
5845 {
5846 \exp_not:N \__seq_set_split:w
5847 \exp_args:No #1 {#2}
5848 \exp_not:N \__seq_set_split_end:
5849 }
5850 \cs_new:Npn \__seq_set_split:w #1 \__seq_set_split_end:
5851 { \__seq_wrap_item:n {#1} }
5852 \cs_generate_variant:Nn \seq_set_split:Nnn { NV , NnV , NVV , Nne , Nee }
5853 \cs_generate_variant:Nn \seq_set_split:Nnn { Nnx , Nxx }
5854 \cs_generate_variant:Nn \seq_gset_split:Nnn { NV , NnV , NVV , Nne , Nee }
5855 \cs_generate_variant:Nn \seq_gset_split:Nnn { Nnx , Nxx }
5856 \cs_generate_variant:Nn \seq_set_split_keep_spaces:Nnn { NnV }
5857 \cs_generate_variant:Nn \seq_gset_split_keep_spaces:Nnn { NnV }
5858 \cs_new_protected:Npn \seq_set_filter:NNn
5859 { \__seq_set_filter:NNNn \__kernel_tl_set:Nx }
5860 \cs_new_protected:Npn \seq_gset_filter:NNn
5861 { \__seq_set_filter:NNNn \__kernel_tl_gset:Nx }
5862 \cs_new_protected:Npn \__seq_set_filter:NNNn #1#2#3#4
5863 {
5864 \__seq_push_item_def:n { \bool_if:nT {#4} { \__seq_wrap_item:n {##1} } }
5865 #1 #2 { #3 }
5866 \__seq_pop_item_def:
5867 }
5868 \cs_new_protected:Npn \seq_set_regex_extract_once:Nnn #1#2#3
5869 { \regex_extract_once:nnN {#2} {#3} #1 }
5870 \cs_generate_variant:Nn \seq_set_regex_extract_once:Nnn { c }
5871 \cs_new_protected:Npn \seq_set_regex_extract_once:NNn #1#2#3
5872 { \regex_extract_once:NnN #2 {#3} #1 }
5873 \cs_generate_variant:Nn \seq_set_regex_extract_once:NNn { c }
5874 \cs_new_protected:Npn \seq_set_regex_extract_all:Nnn #1#2#3
5875 { \regex_extract_all:nnN {#2} {#3} #1 }
5876 \cs_generate_variant:Nn \seq_set_regex_extract_all:Nnn { c }
5877 \cs_new_protected:Npn \seq_set_regex_extract_all:NNn #1#2#3
5878 { \regex_extract_all:NnN #2 {#3} #1 }
5879 \cs_generate_variant:Nn \seq_set_regex_extract_all:NNn { c }
5880 \cs_new_protected:Npn \seq_set_regex_split:Nnn #1#2#3
5881 { \regex_split:nnN {#2} {#3} #1 }
5882 \cs_generate_variant:Nn \seq_set_regex_split:Nnn { c }
5883 \cs_new_protected:Npn \seq_set_regex_split:NNn #1#2#3
5884 { \regex_split:NnN #2 {#3} #1 }
5885 \cs_generate_variant:Nn \seq_set_regex_split:NNn { c }
5886 \group_begin:
5887 \cs_set_protected:Npn \__seq_tmp:w #1#2#3
5888 {
5889 \cs_new_protected:cpe { seq_gset_regex_ #1 :N #2 n } ##1##2##3
5890 {
5891 \group_begin:
5892 \seq_set_eq:NN \exp_not:N \l__seq_tmp_seq ##1
5893 \exp_not:c { regex_ #1 :Nn #2 }
5894 #3 {##2} {##3} \exp_not:N \l__seq_tmp_seq
5895 \seq_gset_eq:NN ##1 \exp_not:N \l__seq_tmp_seq
5896 \group_end:
5897 }
5898 \cs_generate_variant:cn { seq_gset_regex_ #1 :N #2 n } { c }
5899 }
5900 \__seq_tmp:w { extract_once } n { }
5901 \__seq_tmp:w { extract_once } N \use:n
5902 \__seq_tmp:w { extract_all } n { }
5903 \__seq_tmp:w { extract_all } N \use:n
5904 \__seq_tmp:w { split } n { }
5905 \__seq_tmp:w { split } N \use:n
5906 \group_end:
5907 \cs_new_protected:Npn \seq_concat:NNN #1#2#3
5908 { \tl_set:Nf #1 { \exp_after:wN \use_i:nn \exp_after:wN #2 #3 } }
5909 \cs_new_protected:Npn \seq_gconcat:NNN #1#2#3
5910 { \tl_gset:Nf #1 { \exp_after:wN \use_i:nn \exp_after:wN #2 #3 } }
5911 \cs_generate_variant:Nn \seq_concat:NNN { ccc }
5912 \cs_generate_variant:Nn \seq_gconcat:NNN { ccc }
5913 \prg_new_eq_conditional:NNn \seq_if_exist:N \cs_if_exist:N
5914 { TF , T , F , p }
5915 \prg_new_eq_conditional:NNn \seq_if_exist:c \cs_if_exist:c
5916 { TF , T , F , p }
5917 \cs_new_protected:Npn \seq_put_left:Nn #1#2
5918 {
5919 \__kernel_tl_set:Nx #1
5920 {
5921 \exp_not:n { \s__seq \__seq_item:n {#2} }
5922 \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 }
5923 }
5924 }
5925 \cs_new_protected:Npn \seq_gput_left:Nn #1#2
5926 {
5927 \__kernel_tl_gset:Nx #1
5928 {
5929 \exp_not:n { \s__seq \__seq_item:n {#2} }
5930 \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 }
5931 }
5932 }
5933 \cs_new:Npn \__seq_put_left_aux:w \s__seq { \exp_stop_f: }
5934 \cs_generate_variant:Nn \seq_put_left:Nn { NV , Nv , Ne , No , Nx }
5935 \cs_generate_variant:Nn \seq_put_left:Nn { c , cV , cv , ce , co ,cx }
5936 \cs_generate_variant:Nn \seq_gput_left:Nn { NV , Nv , Ne , No , Nx }
5937 \cs_generate_variant:Nn \seq_gput_left:Nn { c , cV , cv , ce , co , cx }
5938 \cs_new_protected:Npn \seq_put_right:Nn #1#2
5939 { \tl_put_right:Nn #1 { \__seq_item:n {#2} } }
5940 \cs_new_protected:Npn \seq_gput_right:Nn #1#2
5941 { \tl_gput_right:Nn #1 { \__seq_item:n {#2} } }
5942 \cs_generate_variant:Nn \seq_put_right:Nn { NV , Nv , Ne , No , Nx }
5943 \cs_generate_variant:Nn \seq_put_right:Nn { c , cV , cv , ce , co , cx }
5944 \cs_generate_variant:Nn \seq_gput_right:Nn { NV , Nv , Ne , No , Nx }
5945 \cs_generate_variant:Nn \seq_gput_right:Nn { c , cV , cv , ce , co , cx }
5946 \cs_new:Npn \__seq_wrap_item:n #1 { \exp_not:n { \__seq_item:n {#1} } }
5947 \seq_new:N \l__seq_tmp_seq
5948 \cs_new_protected:Npn \seq_remove_duplicates:N
5949 { \__seq_remove_duplicates:NN \seq_set_eq:NN }
5950 \cs_new_protected:Npn \seq_gremove_duplicates:N
5951 { \__seq_remove_duplicates:NN \seq_gset_eq:NN }
5952 \cs_new_protected:Npn \__seq_remove_duplicates:NN #1#2
5953 {
5954 \seq_clear:N \l__seq_tmp_seq
5955 \seq_map_inline:Nn #2
5956 {
5957 \seq_if_in:NnF \l__seq_tmp_seq {##1}
5958 { \seq_put_right:Nn \l__seq_tmp_seq {##1} }
5959 }
5960 #1 #2 \l__seq_tmp_seq
5961 }
5962 \cs_generate_variant:Nn \seq_remove_duplicates:N { c }
5963 \cs_generate_variant:Nn \seq_gremove_duplicates:N { c }
5964 \cs_new_protected:Npn \seq_remove_all:Nn
5965 { \__seq_remove_all_aux:NNn \__kernel_tl_set:Nx }
5966 \cs_new_protected:Npn \seq_gremove_all:Nn
5967 { \__seq_remove_all_aux:NNn \__kernel_tl_gset:Nx }
5968 \cs_new_protected:Npn \__seq_remove_all_aux:NNn #1#2#3
5969 {
5970 \__seq_push_item_def:n
5971 {
5972 \str_if_eq:nnT {##1} {#3}
5973 {
5974 \if_false: { \fi: }
5975 \tl_set:Nn \l__seq_tmpb_tl {##1}
5976 #1 #2
5977 { \if_false: } \fi:
5978 \exp_not:o {#2}
5979 \tl_if_eq:NNT \l__seq_tmpa_tl \l__seq_tmpb_tl
5980 { \use_none:nn }
5981 }
5982 \__seq_wrap_item:n {##1}
5983 }
5984 \tl_set:Nn \l__seq_tmpa_tl {#3}
5985 #1 #2 {#2}
5986 \__seq_pop_item_def:
5987 }
5988 \cs_generate_variant:Nn \seq_remove_all:Nn { NV , Ne , c , cV , ce }
5989 \cs_generate_variant:Nn \seq_remove_all:Nn { Nx , cx }
5990 \cs_generate_variant:Nn \seq_gremove_all:Nn { NV , Ne , c , cV , ce }
5991 \cs_generate_variant:Nn \seq_gremove_all:Nn { Nx , cx }
5992 \cs_new_eq:NN \__seq_int_eval:w \tex_numexpr:D
5993 \cs_new_protected:Npn \seq_set_item:Nnn #1#2#3
5994 { \__seq_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_i:nn }
5995 \cs_new_protected:Npn \seq_gset_item:Nnn #1#2#3
5996 { \__seq_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_i:nn }
5997 \cs_generate_variant:Nn \seq_set_item:Nnn { c }
5998 \cs_generate_variant:Nn \seq_gset_item:Nnn { c }
5999 \prg_new_protected_conditional:Npnn \seq_set_item:Nnn #1#2#3 { TF , T , F }
6000 { \__seq_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_set:Nx \use_ii:nn }
6001 \prg_new_protected_conditional:Npnn \seq_gset_item:Nnn #1#2#3 { TF , T , F }
6002 { \__seq_set_item:NnnNN #1 {#2} {#3} \__kernel_tl_gset:Nx \use_ii:nn }
6003 \prg_generate_conditional_variant:Nnn \seq_set_item:Nnn { c } { TF , T , F }
6004 \prg_generate_conditional_variant:Nnn \seq_gset_item:Nnn { c } { TF , T , F }
6005 \cs_new_protected:Npn \__seq_set_item:NnnNN #1#2#3
6006 {
6007 \tl_set:Nn \l__seq_tmpa_tl { \__seq_item:n {#3} }
6008 \exp_args:Nff \__seq_set_item:nnNNNN
6009 { \int_eval:n {#2} } { \seq_count:N #1 } #1 \use_none:nn
6010 }
6011 \cs_new_protected:Npn \__seq_set_item:nnNNNN #1#2
6012 {
6013 \int_compare:nNnTF {#1} > 0
6014 { \int_compare:nNnF {#1} > {#2} { \__seq_set_item:nNnnNNNN { #1 - 1 } } }
6015 {
6016 \int_compare:nNnF {#1} < {-#2}
6017 {
6018 \int_compare:nNnF {#1} = 0
6019 { \__seq_set_item:nNnnNNNN { #2 + #1 } }
6020 }
6021 }
6022 \__seq_set_item_false:nnNNNN {#1} {#2}
6023 }
6024 \cs_new_protected:Npn \__seq_set_item_false:nnNNNN #1#2#3#4#5#6
6025 {
6026 #6
6027 {
6028 \msg_error:nneee { seq } { item-too-large }
6029 { \token_to_str:N #3 } {#2} {#1}
6030 }
6031 { \prg_return_false: }
6032 }
6033 \cs_new_protected:Npn \__seq_set_item:nNnnNNNN #1#2#3#4#5#6#7#8
6034 {
6035 #7 #5
6036 {
6037 \s__seq
6038 \exp_after:wN \__seq_set_item:wn
6039 \int_value:w \__seq_int_eval:w #1
6040 #5 \s__seq_stop #6
6041 }
6042 #8 { } { \prg_return_true: }
6043 }
6044 \cs_new:Npn \__seq_set_item:wn #1 \__seq_item:n #2
6045 {
6046 \if_meaning:w 0 #1 \__seq_set_item_end:w \fi:
6047 \exp_not:n { \__seq_item:n {#2} }
6048 \exp_after:wN \__seq_set_item:wn
6049 \int_value:w \__seq_int_eval:w #1 - 1 \s__seq
6050 }
6051 \cs_new:Npn \__seq_set_item_end:w #1 \exp_not:n #2 #3 \s__seq #4 \s__seq_stop #5
6052 {
6053 #1
6054 \exp_not:o \l__seq_tmpa_tl
6055 \exp_not:n {#4}
6056 #5 #2
6057 }
6058 \cs_new_protected:Npn \seq_reverse:N
6059 { \__seq_reverse:NN \__kernel_tl_set:Nx }
6060 \cs_new_protected:Npn \seq_greverse:N
6061 { \__seq_reverse:NN \__kernel_tl_gset:Nx }
6062 \cs_new_protected:Npn \__seq_reverse:NN #1 #2
6063 {
6064 \cs_set_eq:NN \__seq_tmp:w \__seq_item:n
6065 \cs_set_eq:NN \__seq_item:n \__seq_reverse_item:nwn
6066 #1 #2 { #2 \exp_not:n { } }
6067 \cs_set_eq:NN \__seq_item:n \__seq_tmp:w
6068 }
6069 \cs_new:Npn \__seq_reverse_item:nwn #1 #2 \exp_not:n #3
6070 {
6071 #2
6072 \exp_not:n { \__seq_item:n {#1} #3 }
6073 }
6074 \cs_generate_variant:Nn \seq_reverse:N { c }
6075 \cs_generate_variant:Nn \seq_greverse:N { c }
6076 \prg_new_conditional:Npnn \seq_if_empty:N #1 { p , T , F , TF }
6077 {
6078 \if_meaning:w #1 \c_empty_seq
6079 \prg_return_true:
6080 \else:
6081 \prg_return_false:
6082 \fi:
6083 }
6084 \prg_generate_conditional_variant:Nnn \seq_if_empty:N
6085 { c } { p , T , F , TF }
6086 \seq_new:N \g__seq_tmp_seq
6087 \cs_new_protected:Npn \seq_shuffle:N { \__seq_shuffle:NN \seq_set_eq:NN }
6088 \cs_new_protected:Npn \seq_gshuffle:N { \__seq_shuffle:NN \seq_gset_eq:NN }
6089 \cs_new_protected:Npn \__seq_shuffle:NN #1#2
6090 {
6091 \int_compare:nNnTF { \seq_count:N #2 } > \c_max_register_int
6092 {
6093 \msg_error:nne { seq } { shuffle-too-large }
6094 { \token_to_str:N #2 }
6095 }
6096 {
6097 \group_begin:
6098 \int_zero:N \l__seq_tmpa_int
6099 \__seq_push_item_def:
6100 \cs_gset_eq:NN \__seq_item:n \__seq_shuffle_item:n
6101 #2
6102 \__seq_pop_item_def:
6103 \seq_gclear:N \g__seq_tmp_seq
6104 \int_step_inline:nn \l__seq_tmpa_int
6105 {
6106 \seq_gput_right:Ne \g__seq_tmp_seq
6107 { \tex_the:D \tex_toks:D ##1 }
6108 }
6109 \group_end:
6110 #1 #2 \g__seq_tmp_seq
6111 \seq_gclear:N \g__seq_tmp_seq
6112 }
6113 }
6114 \cs_new_protected:Npn \__seq_shuffle_item:n
6115 {
6116 \int_incr:N \l__seq_tmpa_int
6117 \int_set:Nn \l__seq_tmpb_int
6118 { 1 + \tex_uniformdeviate:D \l__seq_tmpa_int }
6119 \tex_toks:D \l__seq_tmpa_int
6120 = \tex_toks:D \l__seq_tmpb_int
6121 \tex_toks:D \l__seq_tmpb_int
6122 }
6123 \cs_generate_variant:Nn \seq_shuffle:N { c }
6124 \cs_generate_variant:Nn \seq_gshuffle:N { c }
6125 \prg_new_protected_conditional:Npnn \seq_if_in:Nn #1#2
6126 { T , F , TF }
6127 {
6128 \group_begin:
6129 \tl_set:Nn \l__seq_tmpa_tl {#2}
6130 \cs_set_protected:Npn \__seq_item:n ##1
6131 {
6132 \tl_set:Nn \l__seq_tmpb_tl {##1}
6133 \if_meaning:w \l__seq_tmpa_tl \l__seq_tmpb_tl
6134 \exp_after:wN \__seq_if_in:
6135 \fi:
6136 }
6137 #1
6138 \group_end:
6139 \prg_return_false:
6140 \prg_break_point:
6141 }
6142 \cs_new:Npn \__seq_if_in:
6143 { \prg_break:n { \group_end: \prg_return_true: } }
6144 \prg_generate_conditional_variant:Nnn \seq_if_in:Nn
6145 { NV , Nv , Ne , No , Nx , c , cV , cv , ce , co , cx } { T , F , TF }
6146 \cs_new_protected:Npn \__seq_pop:NNNN #1#2#3#4
6147 {
6148 \if_meaning:w #3 \c_empty_seq
6149 \tl_set:Nn #4 { \q_no_value }
6150 \else:
6151 #1#2#3#4
6152 \fi:
6153 }
6154 \cs_new_protected:Npn \__seq_pop_TF:NNNN #1#2#3#4
6155 {
6156 \if_meaning:w #3 \c_empty_seq
6157 % \tl_set:Nn #4 { \q_no_value }
6158 \prg_return_false:
6159 \else:
6160 #1#2#3#4
6161 \prg_return_true:
6162 \fi:
6163 }
6164 \cs_new_protected:Npn \seq_get_left:NN #1#2
6165 {
6166 \__kernel_tl_set:Nx #2
6167 {
6168 \exp_after:wN \__seq_get_left:wnw
6169 #1 \__seq_item:n { \q_no_value } \s__seq_stop
6170 }
6171 }
6172 \cs_new:Npn \__seq_get_left:wnw #1 \__seq_item:n #2#3 \s__seq_stop
6173 { \exp_not:n {#2} }
6174 \cs_generate_variant:Nn \seq_get_left:NN { c }
6175 \cs_new_protected:Npn \seq_pop_left:NN
6176 { \__seq_pop:NNNN \__seq_pop_left:NNN \tl_set:Nn }
6177 \cs_new_protected:Npn \seq_gpop_left:NN
6178 { \__seq_pop:NNNN \__seq_pop_left:NNN \tl_gset:Nn }
6179 \cs_new_protected:Npn \__seq_pop_left:NNN #1#2#3
6180 { \exp_after:wN \__seq_pop_left:wnwNNN #2 \s__seq_stop #1#2#3 }
6181 \cs_new_protected:Npn \__seq_pop_left:wnwNNN
6182 #1 \__seq_item:n #2#3 \s__seq_stop #4#5#6
6183 {
6184 #4 #5 { #1 #3 }
6185 \tl_set:Nn #6 {#2}
6186 }
6187 \cs_generate_variant:Nn \seq_pop_left:NN { c }
6188 \cs_generate_variant:Nn \seq_gpop_left:NN { c }
6189 \cs_new_protected:Npn \seq_get_right:NN #1#2
6190 {
6191 \__kernel_tl_set:Nx #2
6192 {
6193 \exp_after:wN \use_i_ii:nnn
6194 \exp_after:wN \__seq_get_right_loop:nw
6195 \exp_after:wN \q_no_value
6196 #1
6197 \__seq_get_right_end:NnN \__seq_item:n
6198 }
6199 }
6200 \cs_new:Npn \__seq_get_right_loop:nw #1#2 \__seq_item:n
6201 {
6202 #2 \use_none:n {#1}
6203 \__seq_get_right_loop:nw
6204 }
6205 \cs_new:Npn \__seq_get_right_end:NnN #1#2#3 { \exp_not:n {#2} }
6206 \cs_generate_variant:Nn \seq_get_right:NN { c }
6207 \cs_new_protected:Npn \seq_pop_right:NN
6208 { \__seq_pop:NNNN \__seq_pop_right:NNN \__kernel_tl_set:Nx }
6209 \cs_new_protected:Npn \seq_gpop_right:NN
6210 { \__seq_pop:NNNN \__seq_pop_right:NNN \__kernel_tl_gset:Nx }
6211 \cs_new_protected:Npn \__seq_pop_right:NNN #1#2#3
6212 {
6213 \cs_set_eq:NN \__seq_tmp:w \__seq_item:n
6214 \cs_set_eq:NN \__seq_item:n \scan_stop:
6215 #1 #2
6216 { \if_false: } \fi: \s__seq
6217 \exp_after:wN \use_i:nnn
6218 \exp_after:wN \__seq_pop_right_loop:nn
6219 #2
6220 {
6221 \if_false: { \fi: }
6222 \__kernel_tl_set:Nx #3
6223 }
6224 { } \use_none:nn
6225 \cs_set_eq:NN \__seq_item:n \__seq_tmp:w
6226 }
6227 \cs_new:Npn \__seq_pop_right_loop:nn #1#2
6228 {
6229 #2 { \exp_not:n {#1} }
6230 \__seq_pop_right_loop:nn
6231 }
6232 \cs_generate_variant:Nn \seq_pop_right:NN { c }
6233 \cs_generate_variant:Nn \seq_gpop_right:NN { c }
6234 \prg_new_protected_conditional:Npnn \seq_get_left:NN #1#2 { T , F , TF }
6235 { \__seq_pop_TF:NNNN \prg_do_nothing: \seq_get_left:NN #1#2 }
6236 \prg_new_protected_conditional:Npnn \seq_get_right:NN #1#2 { T , F , TF }
6237 { \__seq_pop_TF:NNNN \prg_do_nothing: \seq_get_right:NN #1#2 }
6238 \prg_generate_conditional_variant:Nnn \seq_get_left:NN
6239 { c } { T , F , TF }
6240 \prg_generate_conditional_variant:Nnn \seq_get_right:NN
6241 { c } { T , F , TF }
6242 \prg_new_protected_conditional:Npnn \seq_pop_left:NN #1#2
6243 { T , F , TF }
6244 { \__seq_pop_TF:NNNN \__seq_pop_left:NNN \tl_set:Nn #1 #2 }
6245 \prg_new_protected_conditional:Npnn \seq_gpop_left:NN #1#2
6246 { T , F , TF }
6247 { \__seq_pop_TF:NNNN \__seq_pop_left:NNN \tl_gset:Nn #1 #2 }
6248 \prg_new_protected_conditional:Npnn \seq_pop_right:NN #1#2
6249 { T , F , TF }
6250 { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \__kernel_tl_set:Nx #1 #2 }
6251 \prg_new_protected_conditional:Npnn \seq_gpop_right:NN #1#2
6252 { T , F , TF }
6253 { \__seq_pop_TF:NNNN \__seq_pop_right:NNN \__kernel_tl_gset:Nx #1 #2 }
6254 \prg_generate_conditional_variant:Nnn \seq_pop_left:NN { c }
6255 { T , F , TF }
6256 \prg_generate_conditional_variant:Nnn \seq_gpop_left:NN { c }
6257 { T , F , TF }
6258 \prg_generate_conditional_variant:Nnn \seq_pop_right:NN { c }
6259 { T , F , TF }
6260 \prg_generate_conditional_variant:Nnn \seq_gpop_right:NN { c }
6261 { T , F , TF }
6262 \cs_new:Npn \seq_item:Nn #1
6263 { \exp_after:wN \__seq_item:wNn #1 \s__seq_stop #1 }
6264 \cs_new:Npn \__seq_item:wNn \s__seq #1 \s__seq_stop #2#3
6265 {
6266 \exp_args:Nf \__seq_item:nwn
6267 { \exp_args:Nf \__seq_item:nN { \int_eval:n {#3} } #2 }
6268 #1
6269 \prg_break: \__seq_item:n { }
6270 \prg_break_point:
6271 }
6272 \cs_new:Npn \__seq_item:nN #1#2
6273 {
6274 \int_compare:nNnTF {#1} < 0
6275 { \int_eval:n { \seq_count:N #2 + 1 + #1 } }
6276 {#1}
6277 }
6278 \cs_new:Npn \__seq_item:nwn #1#2 \__seq_item:n #3
6279 {
6280 #2
6281 \int_compare:nNnTF {#1} = 1
6282 { \prg_break:n { \exp_not:n {#3} } }
6283 { \exp_args:Nf \__seq_item:nwn { \int_eval:n { #1 - 1 } } }
6284 }
6285 \cs_generate_variant:Nn \seq_item:Nn { NV , Ne , c , cV , ce }
6286 \cs_new:Npn \seq_rand_item:N #1
6287 {
6288 \seq_if_empty:NF #1
6289 { \seq_item:Nn #1 { \int_rand:nn { 1 } { \seq_count:N #1 } } }
6290 }
6291 \cs_generate_variant:Nn \seq_rand_item:N { c }
6292 \cs_new:Npn \seq_map_break:
6293 { \prg_map_break:Nn \seq_map_break: { } }
6294 \cs_new:Npn \seq_map_break:n
6295 { \prg_map_break:Nn \seq_map_break: }
6296 \cs_new:Npn \seq_map_function:NN #1#2
6297 {
6298 \exp_after:wN \use_i_ii:nnn
6299 \exp_after:wN \__seq_map_function:Nw
6300 \exp_after:wN #2
6301 #1
6302 \prg_break:
6303 \__seq_item:n { } \__seq_item:n { } \__seq_item:n { } \__seq_item:n { }
6304 \prg_break_point:
6305 \prg_break_point:Nn \seq_map_break: { }
6306 }
6307 \cs_new:Npn \__seq_map_function:Nw #1
6308 #2 \__seq_item:n #3
6309 #4 \__seq_item:n #5
6310 #6 \__seq_item:n #7
6311 #8 \__seq_item:n #9
6312 {
6313 #2 #1 {#3}
6314 #4 #1 {#5}
6315 #6 #1 {#7}
6316 #8 #1 {#9}
6317 \__seq_map_function:Nw #1
6318 }
6319 \cs_generate_variant:Nn \seq_map_function:NN { c }
6320 \cs_new_protected:Npn \__seq_push_item_def:n
6321 {
6322 \__seq_push_item_def:
6323 \cs_gset:Npn \__seq_item:n ##1
6324 }
6325 \cs_new_protected:Npn \__seq_push_item_def:e
6326 {
6327 \__seq_push_item_def:
6328 \cs_gset:Npe \__seq_item:n ##1
6329 }
6330 \cs_new_protected:Npn \__seq_push_item_def:
6331 {
6332 \int_gincr:N \g__kernel_prg_map_int
6333 \cs_gset_eq:cN { __seq_map_ \int_use:N \g__kernel_prg_map_int :w }
6334 \__seq_item:n
6335 }
6336 \cs_new_protected:Npn \__seq_pop_item_def:
6337 {
6338 \cs_gset_eq:Nc \__seq_item:n
6339 { __seq_map_ \int_use:N \g__kernel_prg_map_int :w }
6340 \int_gdecr:N \g__kernel_prg_map_int
6341 }
6342 \cs_new_protected:Npn \seq_map_inline:Nn #1#2
6343 {
6344 \__seq_push_item_def:n {#2}
6345 #1
6346 \prg_break_point:Nn \seq_map_break: { \__seq_pop_item_def: }
6347 }
6348 \cs_generate_variant:Nn \seq_map_inline:Nn { c }
6349 \cs_new:Npn \seq_map_tokens:Nn #1#2
6350 {
6351 \exp_last_unbraced:Nno
6352 \use_i:nn { \__seq_map_tokens:nw {#2} } #1
6353 \prg_break:
6354 \__seq_item:n { } \__seq_item:n { } \__seq_item:n { } \__seq_item:n { }
6355 \prg_break_point:
6356 \prg_break_point:Nn \seq_map_break: { }
6357 }
6358 \cs_generate_variant:Nn \seq_map_tokens:Nn { c }
6359 \cs_new:Npn \__seq_map_tokens:nw #1
6360 #2 \__seq_item:n #3
6361 #4 \__seq_item:n #5
6362 #6 \__seq_item:n #7
6363 #8 \__seq_item:n #9
6364 {
6365 #2 \use:n {#1} {#3}
6366 #4 \use:n {#1} {#5}
6367 #6 \use:n {#1} {#7}
6368 #8 \use:n {#1} {#9}
6369 \__seq_map_tokens:nw {#1}
6370 }
6371 \cs_new_protected:Npn \seq_map_variable:NNn #1#2#3
6372 {
6373 \__seq_push_item_def:e
6374 {
6375 \tl_set:Nn \exp_not:N #2 {##1}
6376 \exp_not:n {#3}
6377 }
6378 #1
6379 \prg_break_point:Nn \seq_map_break: { \__seq_pop_item_def: }
6380 }
6381 \cs_generate_variant:Nn \seq_map_variable:NNn { Nc }
6382 \cs_generate_variant:Nn \seq_map_variable:NNn { c , cc }
6383 \cs_new_eq:NN \__seq_sep: \__kernel_int_sep:
6384 \cs_new:Npn \seq_map_indexed_function:NN #1#2
6385 {
6386 \__seq_map_indexed:NN #1#2
6387 \prg_break_point:Nn \seq_map_break: { }
6388 }
6389 \cs_new_protected:Npn \seq_map_indexed_inline:Nn #1#2
6390 {
6391 \int_gincr:N \g__kernel_prg_map_int
6392 \cs_gset_protected:cpn
6393 { __seq_map_ \int_use:N \g__kernel_prg_map_int :w } ##1##2 {#2}
6394 \exp_args:NNc \__seq_map_indexed:NN #1
6395 { __seq_map_ \int_use:N \g__kernel_prg_map_int :w }
6396 \prg_break_point:Nn \seq_map_break:
6397 { \int_gdecr:N \g__kernel_prg_map_int }
6398 }
6399 \cs_new:Npn \__seq_map_indexed:NN #1#2
6400 {
6401 \exp_after:wN \__seq_map_indexed:Nw
6402 \exp_after:wN #2
6403 \int_value:w 1
6404 \exp_after:wN \use_i:nn
6405 \exp_after:wN \__seq_sep:
6406 #1
6407 \prg_break: \__seq_item:n { } \prg_break_point:
6408 }
6409 \cs_new:Npn \__seq_map_indexed:Nw #1#2 \__seq_sep: #3 \__seq_item:n #4
6410 {
6411 #3
6412 #1 {#2} {#4}
6413 \exp_after:wN \__seq_map_indexed:Nw
6414 \exp_after:wN #1
6415 \int_value:w \int_eval:w 1 + #2 \__seq_sep:
6416 }
6417 \cs_new:Npn \seq_map_pairwise_function:NNN #1#2#3
6418 { \exp_after:wN \__seq_map_pairwise_function:wNN #2 \s__seq_stop #1 #3 }
6419 \cs_new:Npn \__seq_map_pairwise_function:wNN \s__seq #1 \s__seq_stop #2#3
6420 {
6421 \exp_after:wN \__seq_map_pairwise_function:wNw #2 \s__seq_stop #3
6422 #1 { ? \prg_break: } { }
6423 \prg_break_point:
6424 \prg_break_point:Nn \seq_map_break: { }
6425 }
6426 \cs_new:Npn \__seq_map_pairwise_function:wNw \s__seq #1 \s__seq_stop #2
6427 {
6428 \__seq_map_pairwise_function:Nnnwnn #2
6429 #1 { ? \prg_break: } { }
6430 \s__seq_stop
6431 }
6432 \cs_new:Npn \__seq_map_pairwise_function:Nnnwnn #1#2#3#4 \s__seq_stop #5#6
6433 {
6434 \use_none:n #2
6435 \use_none:n #5
6436 #1 {#3} {#6}
6437 \__seq_map_pairwise_function:Nnnwnn #1 #4 \s__seq_stop
6438 }
6439 \cs_generate_variant:Nn \seq_map_pairwise_function:NNN { Nc , c , cc }
6440 \cs_new_protected:Npn \seq_set_map_e:NNn
6441 { \__seq_set_map_e:NNNn \__kernel_tl_set:Nx }
6442 \cs_new_protected:Npn \seq_gset_map_e:NNn
6443 { \__seq_set_map_e:NNNn \__kernel_tl_gset:Nx }
6444 \cs_new_protected:Npn \__seq_set_map_e:NNNn #1#2#3#4
6445 {
6446 \__seq_push_item_def:n { \exp_not:N \__seq_item:n {#4} }
6447 #1 #2 { #3 }
6448 \__seq_pop_item_def:
6449 }
6450 \cs_new_protected:Npn \seq_set_map:NNn
6451 { \__seq_set_map:NNNn \__kernel_tl_set:Nx }
6452 \cs_new_protected:Npn \seq_gset_map:NNn
6453 { \__seq_set_map:NNNn \__kernel_tl_gset:Nx }
6454 \cs_new_protected:Npn \__seq_set_map:NNNn #1#2#3#4
6455 {
6456 \__seq_push_item_def:n { \exp_not:n { \__seq_item:n {#4} } }
6457 #1 #2 { #3 }
6458 \__seq_pop_item_def:
6459 }
6460 \cs_new:Npn \seq_count:N #1
6461 {
6462 \int_eval:n
6463 {
6464 \exp_after:wN \use_i:nn
6465 \exp_after:wN \__seq_count:w
6466 #1
6467 \__seq_count_end:w \__seq_item:n 7
6468 \__seq_count_end:w \__seq_item:n 6
6469 \__seq_count_end:w \__seq_item:n 5
6470 \__seq_count_end:w \__seq_item:n 4
6471 \__seq_count_end:w \__seq_item:n 3
6472 \__seq_count_end:w \__seq_item:n 2
6473 \__seq_count_end:w \__seq_item:n 1
6474 \__seq_count_end:w \__seq_item:n 0
6475 \prg_break_point:
6476 }
6477 }
6478 \cs_new:Npn \__seq_count:w
6479 #1 \__seq_item:n #2 \__seq_item:n #3 \__seq_item:n #4 \__seq_item:n
6480 #5 \__seq_item:n #6 \__seq_item:n #7 \__seq_item:n #8 #9 \__seq_item:n
6481 { #9 8 + \__seq_count:w }
6482 \cs_new:Npn \__seq_count_end:w 8 + \__seq_count:w #1#2 \prg_break_point: {#1}
6483 \cs_generate_variant:Nn \seq_count:N { c }
6484 \cs_new:Npn \seq_use:Nnnn #1#2#3#4
6485 {
6486 \seq_if_exist:NTF #1
6487 {
6488 \int_case:nnF { \seq_count:N #1 }
6489 {
6490 { 0 } { }
6491 { 1 } { \exp_after:wN \__seq_use:NNnNnn #1 ? { } { } }
6492 { 2 } { \exp_after:wN \__seq_use:NNnNnn #1 {#2} }
6493 }
6494 {
6495 \exp_after:wN \__seq_use_setup:w #1 \__seq_item:n
6496 \s__seq_mark { \__seq_use:nwwwwnwn {#3} }
6497 \s__seq_mark { \__seq_use:nwwn {#4} }
6498 \s__seq_stop { }
6499 }
6500 }
6501 {
6502 \msg_expandable_error:nnn
6503 { kernel } { bad-variable } {#1}
6504 }
6505 }
6506 \cs_generate_variant:Nn \seq_use:Nnnn { c }
6507 \cs_new:Npn \__seq_use:NNnNnn #1#2#3#4#5#6 { \exp_not:n { #3 #6 #5 } }
6508 \cs_new:Npn \__seq_use_setup:w \s__seq { \__seq_use:nwwwwnwn { } }
6509 \cs_new:Npn \__seq_use:nwwwwnwn
6510 #1 \__seq_item:n #2 \__seq_item:n #3 \__seq_item:n #4#5
6511 \s__seq_mark #6#7 \s__seq_stop #8
6512 {
6513 #6 \__seq_item:n {#3} \__seq_item:n {#4} #5
6514 \s__seq_mark {#6} #7 \s__seq_stop { #8 #1 #2 }
6515 }
6516 \cs_new:Npn \__seq_use:nwwn #1 \__seq_item:n #2 #3 \s__seq_stop #4
6517 { \exp_not:n { #4 #1 #2 } }
6518 \cs_new:Npn \seq_use:Nn #1#2
6519 { \seq_use:Nnnn #1 {#2} {#2} {#2} }
6520 \cs_generate_variant:Nn \seq_use:Nn { c }
6521 \cs_new_eq:NN \seq_push:Nn \seq_put_left:Nn
6522 \cs_generate_variant:Nn \seq_push:Nn { NV , Nv , Ne , c , cV , cv , ce }
6523 \cs_generate_variant:Nn \seq_push:Nn { No , Nx , co , cx }
6524 \cs_new_eq:NN \seq_gpush:Nn \seq_gput_left:Nn
6525 \cs_generate_variant:Nn \seq_gpush:Nn { NV , Nv , Ne , c , cV , cv , ce }
6526 \cs_generate_variant:Nn \seq_gpush:Nn { No , Nx , co , cx }
6527 \cs_new_eq:NN \seq_get:NN \seq_get_left:NN
6528 \cs_new_eq:NN \seq_get:cN \seq_get_left:cN
6529 \cs_new_eq:NN \seq_pop:NN \seq_pop_left:NN
6530 \cs_new_eq:NN \seq_pop:cN \seq_pop_left:cN
6531 \cs_new_eq:NN \seq_gpop:NN \seq_gpop_left:NN
6532 \cs_new_eq:NN \seq_gpop:cN \seq_gpop_left:cN
6533 \prg_new_eq_conditional:NNn \seq_get:NN \seq_get_left:NN { T , F , TF }
6534 \prg_new_eq_conditional:NNn \seq_get:cN \seq_get_left:cN { T , F , TF }
6535 \prg_new_eq_conditional:NNn \seq_pop:NN \seq_pop_left:NN { T , F , TF }
6536 \prg_new_eq_conditional:NNn \seq_pop:cN \seq_pop_left:cN { T , F , TF }
6537 \prg_new_eq_conditional:NNn \seq_gpop:NN \seq_gpop_left:NN { T , F , TF }
6538 \prg_new_eq_conditional:NNn \seq_gpop:cN \seq_gpop_left:cN { T , F , TF }
6539 \cs_new_protected:Npn \seq_show:N { \__seq_show:NN \msg_show:nneeee }
6540 \cs_generate_variant:Nn \seq_show:N { c }
6541 \cs_new_protected:Npn \seq_log:N { \__seq_show:NN \msg_log:nneeee }
6542 \cs_generate_variant:Nn \seq_log:N { c }
6543 \cs_new_protected:Npn \__seq_show:NN #1#2
6544 {
6545 \__kernel_chk_tl_type:NnnT #2 { seq }
6546 {
6547 \s__seq
6548 \exp_after:wN \use_i:nn \exp_after:wN \__seq_show_validate:nn #2
6549 \q_recursion_tail \q_recursion_tail \q_recursion_stop
6550 }
6551 {
6552 #1 { seq } { show }
6553 { \token_to_str:N #2 }
6554 { \seq_map_function:NN #2 \msg_show_item:n }
6555 { } { }
6556 }
6557 }
6558 \cs_new:Npn \__seq_show_validate:nn #1#2
6559 {
6560 \quark_if_recursion_tail_stop:n {#2}
6561 \__seq_wrap_item:n {#2}
6562 \__seq_show_validate:nn
6563 }
6564 \seq_new:N \l_tmpa_seq
6565 \seq_new:N \l_tmpb_seq
6566 \seq_new:N \g_tmpa_seq
6567 \seq_new:N \g_tmpb_seq
6568 %% File: l3int.dtx
6569 \cs_new_eq:NN \int_value:w \tex_number:D
6570 \cs_new_eq:NN \__int_eval:w \tex_numexpr:D
6571 \cs_new_eq:NN \__int_eval_end: \tex_relax:D
6572 \cs_new_eq:NN \if_int_odd:w \tex_ifodd:D
6573 \cs_new_eq:NN \if_case:w \tex_ifcase:D
6574 \scan_new:N \s__int_mark
6575 \scan_new:N \s__int_stop
6576 \cs_new:Npn \__int_use_none_delimit_by_s_stop:w #1 \s__int_stop { }
6577 \quark_new:N \q__int_recursion_tail
6578 \quark_new:N \q__int_recursion_stop
6579 \__kernel_quark_new_test:N \__int_if_recursion_tail_stop_do:Nn
6580 \__kernel_quark_new_test:N \__int_if_recursion_tail_stop:N
6581 \cs_new:Npn \int_eval:n #1
6582 { \tex_the:D \__int_eval:w #1 \__int_eval_end: }
6583 \cs_new:Npn \int_eval:w { \tex_the:D \__int_eval:w }
6584 \cs_new_eq:NN \__int_sep: \__kernel_int_sep:
6585 \cs_new:Npn \int_sign:n #1
6586 {
6587 \int_value:w \exp_after:wN \__int_sign:Nw
6588 \int_value:w \__int_eval:w #1 \__int_eval_end: \__int_sep:
6589 \exp_stop_f:
6590 }
6591 \cs_new:Npn \__int_sign:Nw #1#2 \__int_sep:
6592 {
6593 \if_meaning:w 0 #1
6594 0
6595 \else:
6596 \if_meaning:w - #1 - \fi: 1
6597 \fi:
6598 }
6599 \cs_new:Npn \int_abs:n #1
6600 {
6601 \int_value:w \exp_after:wN \__int_abs:N
6602 \int_value:w \__int_eval:w #1 \__int_eval_end:
6603 \exp_stop_f:
6604 }
6605 \cs_new:Npn \__int_abs:N #1
6606 { \if_meaning:w - #1 \else: \exp_after:wN #1 \fi: }
6607 \cs_new:Npn \int_max:nn #1#2
6608 {
6609 \int_value:w \exp_after:wN \__int_maxmin:wwN
6610 \int_value:w \__int_eval:w #1 \exp_after:wN \__int_sep:
6611 \int_value:w \__int_eval:w #2 \__int_sep:
6612 >
6613 \exp_stop_f:
6614 }
6615 \cs_new:Npn \int_min:nn #1#2
6616 {
6617 \int_value:w \exp_after:wN \__int_maxmin:wwN
6618 \int_value:w \__int_eval:w #1 \exp_after:wN \__int_sep:
6619 \int_value:w \__int_eval:w #2 \__int_sep:
6620 <
6621 \exp_stop_f:
6622 }
6623 \cs_new:Npn \__int_maxmin:wwN #1 \__int_sep: #2 \__int_sep: #3
6624 {
6625 \if_int_compare:w #1 #3 #2 ~
6626 #1
6627 \else:
6628 #2
6629 \fi:
6630 }
6631 \cs_new:Npn \int_div_truncate:nn #1#2
6632 {
6633 \int_value:w \__int_eval:w
6634 \exp_after:wN \__int_div_truncate:NwNw
6635 \int_value:w \__int_eval:w #1 \exp_after:wN \__int_sep:
6636 \int_value:w \__int_eval:w #2 \__int_sep:
6637 \__int_eval_end:
6638 }
6639 \cs_new:Npn \__int_div_truncate:NwNw #1#2 \__int_sep: #3#4 \__int_sep:
6640 {
6641 \if_meaning:w 0 #1
6642 0
6643 \else:
6644 (
6645 #1#2
6646 \if_meaning:w - #1 + \else: - \fi:
6647 ( \if_meaning:w - #3 - \fi: #3#4 - 1 ) / 2
6648 )
6649 \fi:
6650 / #3#4
6651 }
6652 \cs_new:Npn \int_div_round:nn #1#2
6653 { \int_value:w \__int_eval:w ( #1 ) / ( #2 ) \__int_eval_end: }
6654 \cs_new:Npn \int_mod:nn #1#2
6655 {
6656 \int_value:w \__int_eval:w \exp_after:wN \__int_mod:ww
6657 \int_value:w \__int_eval:w #1 \exp_after:wN \__int_sep:
6658 \int_value:w \__int_eval:w #2 \__int_sep:
6659 \__int_eval_end:
6660 }
6661 \cs_new:Npn \__int_mod:ww #1 \__int_sep: #2 \__int_sep:
6662 { #1 - ( \__int_div_truncate:NwNw #1 \__int_sep: #2 \__int_sep: ) * #2 }
6663 \cs_new:Npn \__kernel_int_add:nnn #1#2#3
6664 {
6665 \int_value:w \__int_eval:w #1
6666 \if_int_compare:w #2 < \c_zero_int \exp_after:wN \reverse_if:N \fi:
6667 \if_int_compare:w #1 < \c_zero_int + #2 + #3 \else: + #3 + #2 \fi:
6668 \__int_eval_end:
6669 }
6670 \cs_new_protected:Npn \int_new:N #1
6671 {
6672 \__kernel_chk_if_free_cs:N #1
6673 \cs:w newcount \cs_end: #1
6674 }
6675 \cs_generate_variant:Nn \int_new:N { c }
6676 \cs_new_protected:Npn \int_const:Nn #1#2
6677 { \__int_const:eN { \int_eval:n {#2} } #1 }
6678 \cs_generate_variant:Nn \int_const:Nn { c }
6679 \cs_new_protected:Npn \__int_const:nN #1#2
6680 {
6681 \int_compare:nNnTF {#1} < \c_zero_int
6682 {
6683 \int_new:N #2
6684 \tex_global:D
6685 }
6686 {
6687 \int_compare:nNnTF {#1} > \c__int_max_constdef_int
6688 {
6689 \int_new:N #2
6690 \tex_global:D
6691 }
6692 {
6693 \__kernel_chk_if_free_cs:N #2
6694 \tex_global:D \__int_constdef:Nw
6695 }
6696 }
6697 #2 = \__int_eval:w #1 \__int_eval_end:
6698 }
6699 \cs_generate_variant:Nn \__int_const:nN { e }
6700 \if_int_odd:w 0
6701 \cs_if_exist:NT \tex_luatexversion:D { 1 }
6702 \cs_if_exist:NT \tex_omathchardef:D { 1 }
6703 \cs_if_exist:NT \tex_XeTeXversion:D { 1 } ~
6704 \cs_if_exist:NTF \tex_omathchardef:D
6705 { \cs_new_eq:NN \__int_constdef:Nw \tex_omathchardef:D }
6706 { \cs_new_eq:NN \__int_constdef:Nw \tex_chardef:D }
6707 \tex_global:D \__int_constdef:Nw \c__int_max_constdef_int 1114111 ~
6708 \else:
6709 \cs_new_eq:NN \__int_constdef:Nw \tex_mathchardef:D
6710 \tex_global:D \__int_constdef:Nw \c__int_max_constdef_int 32767 ~
6711 \fi:
6712 \cs_new_protected:Npn \int_zero:N #1 { #1 = \c_zero_int }
6713 \cs_new_protected:Npn \int_gzero:N #1 { \tex_global:D #1 = \c_zero_int }
6714 \cs_generate_variant:Nn \int_zero:N { c }
6715 \cs_generate_variant:Nn \int_gzero:N { c }
6716 \cs_new_protected:Npn \int_zero_new:N #1
6717 { \int_if_exist:NTF #1 { \int_zero:N #1 } { \int_new:N #1 } }
6718 \cs_new_protected:Npn \int_gzero_new:N #1
6719 { \int_if_exist:NTF #1 { \int_gzero:N #1 } { \int_new:N #1 } }
6720 \cs_generate_variant:Nn \int_zero_new:N { c }
6721 \cs_generate_variant:Nn \int_gzero_new:N { c }
6722 \cs_new_protected:Npn \int_set_eq:NN #1#2 { #1 = #2 }
6723 \cs_generate_variant:Nn \int_set_eq:NN { c , Nc , cc }
6724 \cs_new_protected:Npn \int_gset_eq:NN #1#2 { \tex_global:D #1 = #2 }
6725 \cs_generate_variant:Nn \int_gset_eq:NN { c , Nc , cc }
6726 \prg_new_eq_conditional:NNn \int_if_exist:N \cs_if_exist:N
6727 { TF , T , F , p }
6728 \prg_new_eq_conditional:NNn \int_if_exist:c \cs_if_exist:c
6729 { TF , T , F , p }
6730 \cs_new_protected:Npn \int_add:Nn #1#2
6731 { \tex_advance:D #1 \__int_eval:w #2 \__int_eval_end: }
6732 \cs_new_protected:Npn \int_sub:Nn #1#2
6733 { \tex_advance:D #1 - \__int_eval:w #2 \__int_eval_end: }
6734 \cs_new_protected:Npn \int_gadd:Nn #1#2
6735 { \tex_global:D \tex_advance:D #1 \__int_eval:w #2 \__int_eval_end: }
6736 \cs_new_protected:Npn \int_gsub:Nn #1#2
6737 { \tex_global:D \tex_advance:D #1 - \__int_eval:w #2 \__int_eval_end: }
6738 \cs_generate_variant:Nn \int_add:Nn { c }
6739 \cs_generate_variant:Nn \int_gadd:Nn { c }
6740 \cs_generate_variant:Nn \int_sub:Nn { c }
6741 \cs_generate_variant:Nn \int_gsub:Nn { c }
6742 \cs_new_protected:Npn \int_incr:N #1
6743 { \tex_advance:D #1 \c_one_int }
6744 \cs_new_protected:Npn \int_decr:N #1
6745 { \tex_advance:D #1 - \c_one_int }
6746 \cs_new_protected:Npn \int_gincr:N #1
6747 { \tex_global:D \tex_advance:D #1 \c_one_int }
6748 \cs_new_protected:Npn \int_gdecr:N #1
6749 { \tex_global:D \tex_advance:D #1 - \c_one_int }
6750 \cs_generate_variant:Nn \int_incr:N { c }
6751 \cs_generate_variant:Nn \int_decr:N { c }
6752 \cs_generate_variant:Nn \int_gincr:N { c }
6753 \cs_generate_variant:Nn \int_gdecr:N { c }
6754 \cs_new_protected:Npn \int_set:Nn #1#2
6755 { #1 = \__int_eval:w #2 \__int_eval_end: }
6756 \cs_new_protected:Npn \int_gset:Nn #1#2
6757 { \tex_global:D #1 = \__int_eval:w #2 \__int_eval_end: }
6758 \cs_generate_variant:Nn \int_set:Nn { NV , c , cV }
6759 \cs_generate_variant:Nn \int_gset:Nn { NV , c , cV }
6760 \cs_new_protected:Npn \int_set_regex_count:Nnn #1#2#3
6761 { \regex_count:nnN {#2} {#3} #1 }
6762 \cs_generate_variant:Nn \int_set_regex_count:Nnn { c }
6763 \cs_new_protected:Npn \int_gset_regex_count:Nnn #1#2#3
6764 {
6765 \group_begin:
6766 \int_set_eq:NN \l__int_tmpa_int #1
6767 \regex_count:nnN {#2} {#3} \l__int_tmpa_int
6768 \int_gset_eq:NN #1 \l__int_tmpa_int
6769 \group_end:
6770 }
6771 \cs_generate_variant:Nn \int_gset_regex_count:Nnn { c }
6772 \cs_new_protected:Npn \int_set_regex_count:NNn #1#2#3
6773 { \regex_count:NnN #2 {#3} #1 }
6774 \cs_generate_variant:Nn \int_set_regex_count:Nnn { c }
6775 \cs_new_protected:Npn \int_gset_regex_count:NNn #1#2#3
6776 {
6777 \group_begin:
6778 \int_set_eq:NN \l__int_tmpa_int #1
6779 \regex_count:NnN #2 {#3} \l__int_tmpa_int
6780 \int_gset_eq:NN #1 \l__int_tmpa_int
6781 \group_end:
6782 }
6783 \cs_generate_variant:Nn \int_gset_regex_count:NNn { c }
6784 \cs_new_eq:NN \int_use:N \tex_the:D
6785 \cs_new:Npn \int_use:c #1 { \tex_the:D \cs:w #1 \cs_end: }
6786 \cs_new_protected:Npn \__int_compare_error:
6787 {
6788 \if_int_compare:w \c_zero_int \c_zero_int \fi:
6789 =
6790 \__int_compare_error:
6791 }
6792 \cs_new:Npn \__int_compare_error:Nw
6793 #1#2 \s__int_stop
6794 {
6795 { }
6796 \c_zero_int \fi:
6797 \msg_expandable_error:nnn
6798 { kernel } { unknown-comparison } {#1}
6799 \prg_return_false:
6800 }
6801 \prg_new_conditional:Npnn \int_compare:n #1 { p , T , F , TF }
6802 {
6803 \exp_after:wN \__int_compare:w
6804 \int_value:w \__int_eval:w #1 \__int_compare_error:
6805 }
6806 \cs_new:Npn \__int_compare:w #1 \__int_compare_error:
6807 {
6808 \exp_after:wN \if_false: \int_value:w
6809 \__int_compare:Nw #1 e { = nd_ } \s__int_stop
6810 }
6811 \cs_new:Npn \__int_compare:Nw #1#2 \s__int_stop
6812 {
6813 \exp_after:wN \__int_compare:NNw
6814 \__int_to_roman:w - 0 #2 \s__int_mark
6815 #1#2 \s__int_stop
6816 }
6817 \cs_new:Npn \__int_compare:NNw #1#2#3 \s__int_mark
6818 {
6819 \__kernel_exp_not:w
6820 \use:c
6821 {
6822 __int_compare_ \token_to_str:N #1
6823 \if_meaning:w = #2 = \fi:
6824 :NNw
6825 }
6826 \__int_compare_error:Nw #1
6827 }
6828 \cs_new:cpn { __int_compare_end_=:NNw } #1#2#3 e #4 \s__int_stop
6829 {
6830 {#3} \exp_stop_f:
6831 \prg_return_false: \else: \prg_return_true: \fi:
6832 }
6833 \cs_new:Npn \__int_compare:nnN #1#2#3
6834 {
6835 {#2} \exp_stop_f:
6836 \prg_return_false: \exp_after:wN \__int_use_none_delimit_by_s_stop:w
6837 \fi:
6838 #1 #2 #3 \exp_after:wN \__int_compare:Nw \int_value:w \__int_eval:w
6839 }
6840 \cs_new:cpn { __int_compare_=:NNw } #1#2#3 =
6841 { \__int_compare:nnN { \reverse_if:N \if_int_compare:w } {#3} = }
6842 \cs_new:cpn { __int_compare_<:NNw } #1#2#3 <
6843 { \__int_compare:nnN { \reverse_if:N \if_int_compare:w } {#3} < }
6844 \cs_new:cpn { __int_compare_>:NNw } #1#2#3 >
6845 { \__int_compare:nnN { \reverse_if:N \if_int_compare:w } {#3} > }
6846 \cs_new:cpn { __int_compare_==:NNw } #1#2#3 ==
6847 { \__int_compare:nnN { \reverse_if:N \if_int_compare:w } {#3} = }
6848 \cs_new:cpn { __int_compare_!=:NNw } #1#2#3 !=
6849 { \__int_compare:nnN { \if_int_compare:w } {#3} = }
6850 \cs_new:cpn { __int_compare_<=:NNw } #1#2#3 <=
6851 { \__int_compare:nnN { \if_int_compare:w } {#3} > }
6852 \cs_new:cpn { __int_compare_>=:NNw } #1#2#3 >=
6853 { \__int_compare:nnN { \if_int_compare:w } {#3} < }
6854 \prg_new_conditional:Npnn \int_compare:nNn #1#2#3 { p , T , F , TF }
6855 {
6856 \if_int_compare:w \__int_eval:w #1 #2 \__int_eval:w #3 \__int_eval_end:
6857 \prg_return_true:
6858 \else:
6859 \prg_return_false:
6860 \fi:
6861 }
6862 \cs_new:Npn \int_compare_p:vNn #1#2#3
6863 { \int_compare_p:nNn { \use:c {#1} } #2 {#3} }
6864 \cs_new:Npn \int_compare_p:nNv #1#2#3
6865 { \int_compare_p:nNn {#1} #2 { \use:c {#3} } }
6866 \cs_new:Npn \int_compare_p:vNv #1#2#3
6867 { \int_compare_p:nNn { \use:c {#1} } #2 { \use:c {#3} } }
6868 \cs_new:Npn \int_compare:vNnT #1#2#3
6869 { \int_compare:nNnT { \use:c {#1} } #2 {#3} }
6870 \cs_new:Npn \int_compare:nNvT #1#2#3
6871 { \int_compare:nNnT {#1} #2 { \use:c {#3} } }
6872 \cs_new:Npn \int_compare:vNvT #1#2#3
6873 { \int_compare:nNnT { \use:c {#1} } #2 { \use:c {#3} } }
6874 \cs_new:Npn \int_compare:vNnF #1#2#3
6875 { \int_compare:nNnF { \use:c {#1} } #2 {#3} }
6876 \cs_new:Npn \int_compare:nNvF #1#2#3
6877 { \int_compare:nNnF {#1} #2 { \use:c {#3} } }
6878 \cs_new:Npn \int_compare:vNvF #1#2#3
6879 { \int_compare:nNnF { \use:c {#1} } #2 { \use:c {#3} } }
6880 \cs_new:Npn \int_compare:vNnTF #1#2#3
6881 { \int_compare:nNnTF { \use:c {#1} } #2 {#3} }
6882 \cs_new:Npn \int_compare:nNvTF #1#2#3
6883 { \int_compare:nNnTF {#1} #2 { \use:c {#3} } }
6884 \cs_new:Npn \int_compare:vNvTF #1#2#3
6885 { \int_compare:nNnTF { \use:c {#1} } #2 { \use:c {#3} } }
6886 \prg_new_conditional:Npnn \int_if_zero:n #1 { p , T , F , TF }
6887 {
6888 \if_int_compare:w \__int_eval:w #1 = \c_zero_int
6889 \prg_return_true:
6890 \else:
6891 \prg_return_false:
6892 \fi:
6893 }
6894 \cs_new:Npn \int_case:nnTF #1
6895 {
6896 \exp:w
6897 \exp_args:Nf \__int_case:nnTF { \int_eval:n {#1} }
6898 }
6899 \cs_new:Npn \int_case:nnT #1#2#3
6900 {
6901 \exp:w
6902 \exp_args:Nf \__int_case:nnTF { \int_eval:n {#1} } {#2} {#3} { }
6903 }
6904 \cs_new:Npn \int_case:nnF #1#2
6905 {
6906 \exp:w
6907 \exp_args:Nf \__int_case:nnTF { \int_eval:n {#1} } {#2} { }
6908 }
6909 \cs_new:Npn \int_case:nn #1#2
6910 {
6911 \exp:w
6912 \exp_args:Nf \__int_case:nnTF { \int_eval:n {#1} } {#2} { } { }
6913 }
6914 \cs_new:Npn \__int_case:nnTF #1#2#3#4
6915 { \__int_case:nw {#1} #2 {#1} { } \s__int_mark {#3} \s__int_mark {#4} \s__int_stop }
6916 \cs_new:Npn \__int_case:nw #1#2#3
6917 {
6918 \int_compare:nNnTF {#1} = {#2}
6919 { \__int_case_end:nw {#3} }
6920 { \__int_case:nw {#1} }
6921 }
6922 \cs_new:Npn \__int_case_end:nw #1#2#3 \s__int_mark #4#5 \s__int_stop
6923 { \exp_end: #1 #4 }
6924 \prg_new_conditional:Npnn \int_if_odd:n #1 { p , T , F , TF}
6925 {
6926 \if_int_odd:w \__int_eval:w #1 \__int_eval_end:
6927 \prg_return_true:
6928 \else:
6929 \prg_return_false:
6930 \fi:
6931 }
6932 \prg_new_conditional:Npnn \int_if_even:n #1 { p , T , F , TF}
6933 {
6934 \reverse_if:N \if_int_odd:w \__int_eval:w #1 \__int_eval_end:
6935 \prg_return_true:
6936 \else:
6937 \prg_return_false:
6938 \fi:
6939 }
6940 \cs_new:Npn \int_while_do:nn #1#2
6941 {
6942 \int_compare:nT {#1}
6943 {
6944 #2
6945 \int_while_do:nn {#1} {#2}
6946 }
6947 }
6948 \cs_new:Npn \int_until_do:nn #1#2
6949 {
6950 \int_compare:nF {#1}
6951 {
6952 #2
6953 \int_until_do:nn {#1} {#2}
6954 }
6955 }
6956 \cs_new:Npn \int_do_while:nn #1#2
6957 {
6958 #2
6959 \int_compare:nT {#1}
6960 { \int_do_while:nn {#1} {#2} }
6961 }
6962 \cs_new:Npn \int_do_until:nn #1#2
6963 {
6964 #2
6965 \int_compare:nF {#1}
6966 { \int_do_until:nn {#1} {#2} }
6967 }
6968 \cs_new:Npn \int_while_do:nNnn #1#2#3#4
6969 {
6970 \int_compare:nNnT {#1} #2 {#3}
6971 {
6972 #4
6973 \int_while_do:nNnn {#1} #2 {#3} {#4}
6974 }
6975 }
6976 \cs_new:Npn \int_until_do:nNnn #1#2#3#4
6977 {
6978 \int_compare:nNnF {#1} #2 {#3}
6979 {
6980 #4
6981 \int_until_do:nNnn {#1} #2 {#3} {#4}
6982 }
6983 }
6984 \cs_new:Npn \int_do_while:nNnn #1#2#3#4
6985 {
6986 #4
6987 \int_compare:nNnT {#1} #2 {#3}
6988 { \int_do_while:nNnn {#1} #2 {#3} {#4} }
6989 }
6990 \cs_new:Npn \int_do_until:nNnn #1#2#3#4
6991 {
6992 #4
6993 \int_compare:nNnF {#1} #2 {#3}
6994 { \int_do_until:nNnn {#1} #2 {#3} {#4} }
6995 }
6996 \cs_new:Npn \int_step_function:nnnN #1#2#3
6997 {
6998 \exp_after:wN \__int_step:w
6999 \int_value:w \__int_eval:w #1 \exp_after:wN \__int_sep:
7000 \int_value:w \__int_eval:w #2 \exp_after:wN \__int_sep:
7001 \int_value:w \__int_eval:w #3 \__int_sep:
7002 }
7003 \cs_new:Npn \__int_step:w #1 \__int_sep: #2 \__int_sep: #3 \__int_sep: #4
7004 {
7005 \int_compare:nNnTF {#2} > \c_zero_int
7006 { \__int_step:Nw > }
7007 {
7008 \if_meaning:w 0 #2
7009 \exp_after:wN \use_ii:nn
7010 \fi:
7011 \use_none:n
7012 {
7013 \msg_expandable_error:nnn
7014 { kernel } { zero-step } {#4}
7015 \prg_break:
7016 }
7017 \__int_step:Nw <
7018 }
7019 #1 \__int_sep: {#2} {#3} {#4}
7020 \prg_break_point:
7021 }
7022 \cs_new:Npn \__int_step:Nw #1#2 \__int_sep: #3#4#5
7023 {
7024 \if_int_compare:w #2 #1 #4 \exp_stop_f:
7025 \prg_break:n
7026 \fi:
7027 #5 {#2}
7028 \exp_after:wN \__int_step:Nw
7029 \exp_after:wN #1
7030 \int_value:w \__int_eval:w #2 + #3 \__int_sep: {#3} {#4} {#5}
7031 }
7032 \cs_new:Npn \int_step_function:nN
7033 { \int_step_function:nnnN \c_one_int \c_one_int }
7034 \cs_new:Npn \int_step_function:nnN #1
7035 { \int_step_function:nnnN {#1} \c_one_int }
7036 \cs_new_eq:NN \int_step_tokens:nn \int_step_function:nN
7037 \cs_new_eq:NN \int_step_tokens:nnn \int_step_function:nnN
7038 \cs_new_eq:NN \int_step_tokens:nnnn \int_step_function:nnnN
7039 \cs_new_protected:Npn \int_step_inline:nn
7040 { \int_step_inline:nnnn { 1 } { 1 } }
7041 \cs_new_protected:Npn \int_step_inline:nnn #1
7042 { \int_step_inline:nnnn {#1} { 1 } }
7043 \cs_new_protected:Npn \int_step_inline:nnnn
7044 {
7045 \int_gincr:N \g__kernel_prg_map_int
7046 \exp_args:NNc \__int_step:NNnnnn
7047 \cs_gset_protected:Npn
7048 { __int_map_ \int_use:N \g__kernel_prg_map_int :w }
7049 }
7050 \cs_new_protected:Npn \int_step_variable:nNn
7051 { \int_step_variable:nnnNn { 1 } { 1 } }
7052 \cs_new_protected:Npn \int_step_variable:nnNn #1
7053 { \int_step_variable:nnnNn {#1} { 1 } }
7054 \cs_new_protected:Npn \int_step_variable:nnnNn #1#2#3#4#5
7055 {
7056 \int_gincr:N \g__kernel_prg_map_int
7057 \exp_args:NNc \__int_step:NNnnnn
7058 \cs_gset_protected:Npe
7059 { __int_map_ \int_use:N \g__kernel_prg_map_int :w }
7060 {#1}{#2}{#3}
7061 {
7062 \tl_set:Nn \exp_not:N #4 {##1}
7063 \exp_not:n {#5}
7064 }
7065 }
7066 \cs_new_protected:Npn \__int_step:NNnnnn #1#2#3#4#5#6
7067 {
7068 #1 #2 ##1 {#6}
7069 \int_step_function:nnnN {#3} {#4} {#5} #2
7070 \prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__kernel_prg_map_int }
7071 }
7072 \cs_new_eq:NN \int_to_arabic:n \int_eval:n
7073 \cs_generate_variant:Nn \int_to_arabic:n { v }
7074 \cs_new:Npn \int_to_symbols:nnn #1#2#3
7075 {
7076 \int_compare:nNnTF {#1} > {#2}
7077 {
7078 \__int_to_symbols:ennn
7079 {
7080 \int_case:nn
7081 { 1 + \int_mod:nn { #1 - 1 } {#2} }
7082 {#3}
7083 }
7084 {#1} {#2} {#3}
7085 }
7086 { \int_case:nn {#1} {#3} }
7087 }
7088 \cs_new:Npn \__int_to_symbols:nnnn #1#2#3#4
7089 {
7090 \exp_args:Nf \int_to_symbols:nnn
7091 { \int_div_truncate:nn { #2 - 1 } {#3} } {#3} {#4}
7092 #1
7093 }
7094 \cs_generate_variant:Nn \__int_to_symbols:nnnn { e }
7095 \cs_new:Npn \int_to_alph:n #1
7096 {
7097 \int_to_symbols:nnn {#1} { 26 }
7098 {
7099 { 1 } { a }
7100 { 2 } { b }
7101 { 3 } { c }
7102 { 4 } { d }
7103 { 5 } { e }
7104 { 6 } { f }
7105 { 7 } { g }
7106 { 8 } { h }
7107 { 9 } { i }
7108 { 10 } { j }
7109 { 11 } { k }
7110 { 12 } { l }
7111 { 13 } { m }
7112 { 14 } { n }
7113 { 15 } { o }
7114 { 16 } { p }
7115 { 17 } { q }
7116 { 18 } { r }
7117 { 19 } { s }
7118 { 20 } { t }
7119 { 21 } { u }
7120 { 22 } { v }
7121 { 23 } { w }
7122 { 24 } { x }
7123 { 25 } { y }
7124 { 26 } { z }
7125 }
7126 }
7127 \cs_new:Npn \int_to_Alph:n #1
7128 {
7129 \int_to_symbols:nnn {#1} { 26 }
7130 {
7131 { 1 } { A }
7132 { 2 } { B }
7133 { 3 } { C }
7134 { 4 } { D }
7135 { 5 } { E }
7136 { 6 } { F }
7137 { 7 } { G }
7138 { 8 } { H }
7139 { 9 } { I }
7140 { 10 } { J }
7141 { 11 } { K }
7142 { 12 } { L }
7143 { 13 } { M }
7144 { 14 } { N }
7145 { 15 } { O }
7146 { 16 } { P }
7147 { 17 } { Q }
7148 { 18 } { R }
7149 { 19 } { S }
7150 { 20 } { T }
7151 { 21 } { U }
7152 { 22 } { V }
7153 { 23 } { W }
7154 { 24 } { X }
7155 { 25 } { Y }
7156 { 26 } { Z }
7157 }
7158 }
7159 \cs_new:Npn \int_to_base:nn #1
7160 { \exp_args:Nf \__int_to_base:nn { \int_eval:n {#1} } }
7161 \cs_new:Npn \int_to_Base:nn #1
7162 { \exp_args:Nf \__int_to_Base:nn { \int_eval:n {#1} } }
7163 \cs_new:Npn \__int_to_base:nn #1#2
7164 {
7165 \int_compare:nNnTF {#1} < 0
7166 { \exp_args:No \__int_to_base:nnN { \use_none:n #1 } {#2} - }
7167 { \__int_to_base:nnN {#1} {#2} \c_empty_tl }
7168 }
7169 \cs_new:Npn \__int_to_Base:nn #1#2
7170 {
7171 \int_compare:nNnTF {#1} < 0
7172 { \exp_args:No \__int_to_Base:nnN { \use_none:n #1 } {#2} - }
7173 { \__int_to_Base:nnN {#1} {#2} \c_empty_tl }
7174 }
7175 \cs_new:Npn \__int_to_base:nnN #1#2#3
7176 {
7177 \int_compare:nNnTF {#1} < {#2}
7178 { \exp_last_unbraced:Nf #3 { \__int_to_letter:n {#1} } }
7179 {
7180 \exp_args:Nf \__int_to_base:nnnN
7181 { \__int_to_letter:n { \int_mod:nn {#1} {#2} } }
7182 {#1}
7183 {#2}
7184 #3
7185 }
7186 }
7187 \cs_new:Npn \__int_to_base:nnnN #1#2#3#4
7188 {
7189 \exp_args:Nf \__int_to_base:nnN
7190 { \int_div_truncate:nn {#2} {#3} }
7191 {#3}
7192 #4
7193 #1
7194 }
7195 \cs_new:Npn \__int_to_Base:nnN #1#2#3
7196 {
7197 \int_compare:nNnTF {#1} < {#2}
7198 { \exp_last_unbraced:Nf #3 { \__int_to_Letter:n {#1} } }
7199 {
7200 \exp_args:Nf \__int_to_Base:nnnN
7201 { \__int_to_Letter:n { \int_mod:nn {#1} {#2} } }
7202 {#1}
7203 {#2}
7204 #3
7205 }
7206 }
7207 \cs_new:Npn \__int_to_Base:nnnN #1#2#3#4
7208 {
7209 \exp_args:Nf \__int_to_Base:nnN
7210 { \int_div_truncate:nn {#2} {#3} }
7211 {#3}
7212 #4
7213 #1
7214 }
7215 \cs_new:Npn \__int_to_letter:n #1
7216 {
7217 \exp_after:wN \exp_after:wN
7218 \if_case:w \__int_eval:w #1 - 10 \__int_eval_end:
7219 a
7220 \or: b
7221 \or: c
7222 \or: d
7223 \or: e
7224 \or: f
7225 \or: g
7226 \or: h
7227 \or: i
7228 \or: j
7229 \or: k
7230 \or: l
7231 \or: m
7232 \or: n
7233 \or: o
7234 \or: p
7235 \or: q
7236 \or: r
7237 \or: s
7238 \or: t
7239 \or: u
7240 \or: v
7241 \or: w
7242 \or: x
7243 \or: y
7244 \or: z
7245 \else: \int_value:w \__int_eval:w #1 \exp_after:wN \__int_eval_end:
7246 \fi:
7247 }
7248 \cs_new:Npn \__int_to_Letter:n #1
7249 {
7250 \exp_after:wN \exp_after:wN
7251 \if_case:w \__int_eval:w #1 - 10 \__int_eval_end:
7252 A
7253 \or: B
7254 \or: C
7255 \or: D
7256 \or: E
7257 \or: F
7258 \or: G
7259 \or: H
7260 \or: I
7261 \or: J
7262 \or: K
7263 \or: L
7264 \or: M
7265 \or: N
7266 \or: O
7267 \or: P
7268 \or: Q
7269 \or: R
7270 \or: S
7271 \or: T
7272 \or: U
7273 \or: V
7274 \or: W
7275 \or: X
7276 \or: Y
7277 \or: Z
7278 \else: \int_value:w \__int_eval:w #1 \exp_after:wN \__int_eval_end:
7279 \fi:
7280 }
7281 \cs_new:Npn \int_to_bin:n #1
7282 { \int_to_base:nn {#1} { 2 } }
7283 \cs_new:Npn \int_to_hex:n #1
7284 { \int_to_base:nn {#1} { 16 } }
7285 \cs_new:Npn \int_to_Hex:n #1
7286 { \int_to_Base:nn {#1} { 16 } }
7287 \cs_new:Npn \int_to_oct:n #1
7288 { \int_to_base:nn {#1} { 8 } }
7289 \cs_new:Npn \int_to_roman:n #1
7290 {
7291 \exp_after:wN \__int_to_roman:N
7292 \__int_to_roman:w \int_eval:n {#1} Q
7293 }
7294 \cs_new:Npn \__int_to_roman:N #1
7295 {
7296 \use:c { __int_to_roman_ #1 :w }
7297 \__int_to_roman:N
7298 }
7299 \cs_new:Npn \int_to_Roman:n #1
7300 {
7301 \exp_after:wN \__int_to_Roman_aux:N
7302 \__int_to_roman:w \int_eval:n {#1} Q
7303 }
7304 \cs_new:Npn \__int_to_Roman_aux:N #1
7305 {
7306 \use:c { __int_to_Roman_ #1 :w }
7307 \__int_to_Roman_aux:N
7308 }
7309 \cs_new:Npn \__int_to_roman_i:w { i }
7310 \cs_new:Npn \__int_to_roman_v:w { v }
7311 \cs_new:Npn \__int_to_roman_x:w { x }
7312 \cs_new:Npn \__int_to_roman_l:w { l }
7313 \cs_new:Npn \__int_to_roman_c:w { c }
7314 \cs_new:Npn \__int_to_roman_d:w { d }
7315 \cs_new:Npn \__int_to_roman_m:w { m }
7316 \cs_new:Npn \__int_to_roman_Q:w #1 { }
7317 \cs_new:Npn \__int_to_Roman_i:w { I }
7318 \cs_new:Npn \__int_to_Roman_v:w { V }
7319 \cs_new:Npn \__int_to_Roman_x:w { X }
7320 \cs_new:Npn \__int_to_Roman_l:w { L }
7321 \cs_new:Npn \__int_to_Roman_c:w { C }
7322 \cs_new:Npn \__int_to_Roman_d:w { D }
7323 \cs_new:Npn \__int_to_Roman_m:w { M }
7324 \cs_new:Npn \__int_to_Roman_Q:w #1 { }
7325 \cs_new:Npn \__int_pass_signs:wn #1
7326 {
7327 \if:w + \if:w - \exp_not:N #1 + \fi: \exp_not:N #1
7328 \exp_after:wN \__int_pass_signs:wn
7329 \else:
7330 \exp_after:wN \__int_pass_signs_end:wn
7331 \exp_after:wN #1
7332 \fi:
7333 }
7334 \cs_new:Npn \__int_pass_signs_end:wn #1 \s__int_stop #2 { #2 #1 }
7335 \cs_new:Npn \int_from_alph:n #1
7336 {
7337 \int_eval:n
7338 {
7339 \exp_after:wN \__int_pass_signs:wn \tl_to_str:n {#1}
7340 \s__int_stop { \__int_from_alph:nN { 0 } }
7341 \q__int_recursion_tail \q__int_recursion_stop
7342 }
7343 }
7344 \cs_new:Npn \__int_from_alph:nN #1#2
7345 {
7346 \__int_if_recursion_tail_stop_do:Nn #2 {#1}
7347 \exp_args:Nf \__int_from_alph:nN
7348 { \int_eval:n { #1 * 26 + \__int_from_alph:N #2 } }
7349 }
7350 \cs_new:Npn \__int_from_alph:N #1
7351 { `#1 - \int_compare:nNnTF { `#1 } < { 91 } { 64 } { 96 } }
7352 \cs_new:Npn \int_from_base:nn #1#2
7353 {
7354 \int_eval:n
7355 {
7356 \exp_after:wN \__int_pass_signs:wn \tl_to_str:n {#1}
7357 \s__int_stop { \__int_from_base:nnN { 0 } {#2} }
7358 \q__int_recursion_tail \q__int_recursion_stop
7359 }
7360 }
7361 \cs_new:Npn \__int_from_base:nnN #1#2#3
7362 {
7363 \__int_if_recursion_tail_stop_do:Nn #3 {#1}
7364 \exp_args:Nf \__int_from_base:nnN
7365 { \int_eval:n { #1 * #2 + \__int_from_base:N #3 } }
7366 {#2}
7367 }
7368 \cs_new:Npn \__int_from_base:N #1
7369 {
7370 \int_compare:nNnTF { `#1 } < { 58 }
7371 {#1}
7372 { `#1 - \int_compare:nNnTF { `#1 } < { 91 } { 55 } { 87 } }
7373 }
7374 \cs_new:Npn \int_from_bin:n #1
7375 { \int_from_base:nn {#1} { 2 } }
7376 \cs_new:Npn \int_from_hex:n #1
7377 { \int_from_base:nn {#1} { 16 } }
7378 \cs_new:Npn \int_from_oct:n #1
7379 { \int_from_base:nn {#1} { 8 } }
7380 \int_const:cn { c__int_from_roman_i_int } { 1 }
7381 \int_const:cn { c__int_from_roman_v_int } { 5 }
7382 \int_const:cn { c__int_from_roman_x_int } { 10 }
7383 \int_const:cn { c__int_from_roman_l_int } { 50 }
7384 \int_const:cn { c__int_from_roman_c_int } { 100 }
7385 \int_const:cn { c__int_from_roman_d_int } { 500 }
7386 \int_const:cn { c__int_from_roman_m_int } { 1000 }
7387 \int_const:cn { c__int_from_roman_I_int } { 1 }
7388 \int_const:cn { c__int_from_roman_V_int } { 5 }
7389 \int_const:cn { c__int_from_roman_X_int } { 10 }
7390 \int_const:cn { c__int_from_roman_L_int } { 50 }
7391 \int_const:cn { c__int_from_roman_C_int } { 100 }
7392 \int_const:cn { c__int_from_roman_D_int } { 500 }
7393 \int_const:cn { c__int_from_roman_M_int } { 1000 }
7394 \cs_new:Npn \int_from_roman:n #1
7395 {
7396 \int_eval:n
7397 {
7398 (
7399 0
7400 \exp_after:wN \__int_from_roman:NN \tl_to_str:n {#1}
7401 \q__int_recursion_tail \q__int_recursion_tail \q__int_recursion_stop
7402 )
7403 }
7404 }
7405 \cs_new:Npn \__int_from_roman:NN #1#2
7406 {
7407 \__int_if_recursion_tail_stop:N #1
7408 \int_if_exist:cF { c__int_from_roman_ #1 _int }
7409 { \__int_from_roman_error:w }
7410 \__int_if_recursion_tail_stop_do:Nn #2
7411 { + \use:c { c__int_from_roman_ #1 _int } }
7412 \int_if_exist:cF { c__int_from_roman_ #2 _int }
7413 { \__int_from_roman_error:w }
7414 \int_compare:nNnTF
7415 { \use:c { c__int_from_roman_ #1 _int } }
7416 <
7417 { \use:c { c__int_from_roman_ #2 _int } }
7418 {
7419 + \use:c { c__int_from_roman_ #2 _int }
7420 - \use:c { c__int_from_roman_ #1 _int }
7421 \__int_from_roman:NN
7422 }
7423 {
7424 + \use:c { c__int_from_roman_ #1 _int }
7425 \__int_from_roman:NN #2
7426 }
7427 }
7428 \cs_new:Npn \__int_from_roman_error:w #1 \q__int_recursion_stop #2
7429 { #2 * 0 - 1 }
7430 \cs_new_eq:NN \int_show:N \__kernel_register_show:N
7431 \cs_generate_variant:Nn \int_show:N { c }
7432 \cs_new_protected:Npn \int_show:n
7433 { \__kernel_msg_show_eval:Nn \int_eval:n }
7434 \cs_new_eq:NN \int_log:N \__kernel_register_log:N
7435 \cs_generate_variant:Nn \int_log:N { c }
7436 \cs_new_protected:Npn \int_log:n
7437 { \__kernel_msg_log_eval:Nn \int_eval:n }
7438 \int_const:Nn \c_one_int { 1 }
7439 \int_const:Nn \c_max_int { 2 147 483 647 }
7440 \int_const:Nn \c_max_char_int
7441 {
7442 \if_int_odd:w 0
7443 \cs_if_exist:NT \tex_luatexversion:D { 1 }
7444 \cs_if_exist:NT \tex_XeTeXversion:D { 1 } ~
7445 "10FFFF
7446 \else:
7447 "FF
7448 \fi:
7449 }
7450 \int_const:Nn \c_max_intarrray_int { 1 073 741 823 }
7451 \int_new:N \l_tmpa_int
7452 \int_new:N \l_tmpb_int
7453 \int_new:N \g_tmpa_int
7454 \int_new:N \g_tmpb_int
7455 \int_new:N \l__seq_tmpa_int
7456 \int_new:N \l__seq_tmpb_int
7457 %% File: l3flag.dtx
7458 \cs_new_eq:NN \__flag_sep: \__kernel_int_sep:
7459 \cs_new_protected:Npn \flag_new:N #1
7460 { \cs_new_protected:Npe #1 { \cs_to_str:N #1 } }
7461 \cs_generate_variant:Nn \flag_new:N { c }
7462 \flag_new:N \l_tmpa_flag
7463 \flag_new:N \l_tmpb_flag
7464 \cs_new_protected:Npn \flag_clear:N #1
7465 {
7466 \__flag_clear:wN 0 \__flag_sep: #1
7467 \prg_break_point:
7468 }
7469 \cs_generate_variant:Nn \flag_clear:N { c }
7470 \cs_new_protected:Npn \__flag_clear:wN #1 \__flag_sep: #2
7471 {
7472 \if_cs_exist:w #2 #1 \cs_end: \else:
7473 \prg_break:n
7474 \fi:
7475 \cs_set_eq:cN { #2 #1 } \tex_undefined:D
7476 \exp_after:wN \__flag_clear:wN
7477 \int_value:w \int_eval:w \c_one_int + #1 \__flag_sep: #2
7478 }
7479 \cs_new_protected:Npn \flag_clear_new:N #1
7480 { \flag_if_exist:NTF #1 { \flag_clear:N } { \flag_new:N } #1 }
7481 \cs_generate_variant:Nn \flag_clear_new:N { c }
7482 \cs_new_protected:Npn \flag_show:N { \__flag_show:NN \tl_show:n }
7483 \cs_generate_variant:Nn \flag_show:N { c }
7484 \cs_new_protected:Npn \flag_log:N { \__flag_show:NN \tl_log:n }
7485 \cs_generate_variant:Nn \flag_log:N { c }
7486 \cs_new_protected:Npn \__flag_show:NN #1#2
7487 {
7488 \__kernel_chk_defined:NT #2
7489 { \exp_args:Ne #1 { \tl_to_str:n { #2 height } = \flag_height:N #2 } }
7490 }
7491 \prg_new_eq_conditional:NNn \flag_if_exist:N \cs_if_exist:N
7492 { TF , T , F , p }
7493 \prg_new_eq_conditional:NNn \flag_if_exist:c \cs_if_exist:c
7494 { TF , T , F , p }
7495 \prg_new_conditional:Npnn \flag_if_raised:N #1 { p , T , F , TF }
7496 {
7497 \if_cs_exist:w #1 0 \cs_end:
7498 \prg_return_true:
7499 \else:
7500 \prg_return_false:
7501 \fi:
7502 }
7503 \prg_generate_conditional_variant:Nnn \flag_if_raised:N
7504 { c } { p , T , F , TF }
7505 \cs_new:Npn \flag_height:N #1 { \__flag_height_loop:wN 0 \__flag_sep: #1 }
7506 \cs_new:Npn \__flag_height_loop:wN #1 \__flag_sep: #2
7507 {
7508 \if_cs_exist:w #2 #1 \cs_end: \else:
7509 \exp_after:wN \__flag_height_end:wN
7510 \fi:
7511 \exp_after:wN \__flag_height_loop:wN
7512 \int_value:w \int_eval:w \c_one_int + #1 \__flag_sep: #2
7513 }
7514 \cs_new:Npn \__flag_height_end:wN #1 + #2 \__flag_sep: #3 {#2}
7515 \cs_generate_variant:Nn \flag_height:N { c }
7516 \cs_new:Npn \flag_raise:N #1
7517 { \exp_after:wN \use_none:n \cs:w #1 \flag_height:N #1 \cs_end: }
7518 \cs_generate_variant:Nn \flag_raise:N { c }
7519 \cs_new:Npn \flag_ensure_raised:N #1
7520 { \exp_after:wN \use_none:n \cs:w #1 0 \cs_end: }
7521 \cs_generate_variant:Nn \flag_ensure_raised:N { c }
7522 \cs_new_protected:Npn \flag_new:n #1 { \flag_new:c { l_#1_flag } }
7523 \cs_new_protected:Npn \flag_clear:n #1 { \flag_clear:c { l_#1_flag } }
7524 \cs_new_protected:Npn \flag_clear_new:n #1 { \flag_clear_new:c { l_#1_flag } }
7525 \cs_new:Npn \flag_if_exist_p:n #1 { \flag_if_exist_p:c { l_#1_flag } }
7526 \cs_new:Npn \flag_if_exist:nT #1 { \flag_if_exist:cT { l_#1_flag } }
7527 \cs_new:Npn \flag_if_exist:nF #1 { \flag_if_exist:cF { l_#1_flag } }
7528 \cs_new:Npn \flag_if_exist:nTF #1 { \flag_if_exist:cTF { l_#1_flag } }
7529 \cs_new:Npn \flag_if_raised_p:n #1 { \flag_if_raised_p:c { l_#1_flag } }
7530 \cs_new:Npn \flag_if_raised:nT #1 { \flag_if_raised:cT { l_#1_flag } }
7531 \cs_new:Npn \flag_if_raised:nF #1 { \flag_if_raised:cF { l_#1_flag } }
7532 \cs_new:Npn \flag_if_raised:nTF #1 { \flag_if_raised:cTF { l_#1_flag } }
7533 \cs_new:Npn \flag_height:n #1 { \flag_height:c { l_#1_flag } }
7534 \cs_new:Npn \flag_raise:n #1 { \flag_raise:c { l_#1_flag } }
7535 \cs_new:Npn \flag_ensure_raised:n #1 { \flag_ensure_raised:c { l_#1_flag } }
7536 \cs_new_protected:Npn \flag_show:n { \__flag_show:Nn \tl_show:n }
7537 \cs_new_protected:Npn \flag_log:n { \__flag_show:Nn \tl_log:n }
7538 \cs_new_protected:Npn \__flag_show:Nn #1#2
7539 {
7540 \exp_args:Nc \__kernel_chk_defined:NT { l_#2_flag }
7541 {
7542 \exp_args:Ne #1
7543 { \tl_to_str:n { flag~#2~height } = \flag_height:n {#2} }
7544 }
7545 }
7546 %% File: l3prg.dtx
7547 \cs_new_eq:NN \if_predicate:w \tex_ifodd:D
7548 \cs_new_protected:Npn \bool_new:N #1 { \cs_new_eq:NN #1 \c_false_bool }
7549 \cs_generate_variant:Nn \bool_new:N { c }
7550 \cs_new_protected:Npn \bool_const:Nn #1#2
7551 {
7552 \__kernel_chk_if_free_cs:N #1
7553 \tex_global:D \tex_chardef:D #1 = \bool_if_p:n {#2}
7554 }
7555 \cs_generate_variant:Nn \bool_const:Nn { c }
7556 \cs_new_protected:Npn \bool_set_true:N #1
7557 { \cs_set_eq:NN #1 \c_true_bool }
7558 \cs_new_protected:Npn \bool_set_false:N #1
7559 { \cs_set_eq:NN #1 \c_false_bool }
7560 \cs_new_protected:Npn \bool_gset_true:N #1
7561 { \cs_gset_eq:NN #1 \c_true_bool }
7562 \cs_new_protected:Npn \bool_gset_false:N #1
7563 { \cs_gset_eq:NN #1 \c_false_bool }
7564 \cs_generate_variant:Nn \bool_set_true:N { c }
7565 \cs_generate_variant:Nn \bool_set_false:N { c }
7566 \cs_generate_variant:Nn \bool_gset_true:N { c }
7567 \cs_generate_variant:Nn \bool_gset_false:N { c }
7568 \cs_new_eq:NN \bool_set_eq:NN \tl_set_eq:NN
7569 \cs_new_eq:NN \bool_gset_eq:NN \tl_gset_eq:NN
7570 \cs_generate_variant:Nn \bool_set_eq:NN { Nc, cN, cc }
7571 \cs_generate_variant:Nn \bool_gset_eq:NN { Nc, cN, cc }
7572 \cs_new_protected:Npn \bool_set:Nn #1#2
7573 {
7574 \exp_last_unbraced:NNNf
7575 \tex_chardef:D #1 = { \bool_if_p:n {#2} }
7576 }
7577 \cs_new_protected:Npn \bool_gset:Nn #1#2
7578 {
7579 \exp_last_unbraced:NNNNf
7580 \tex_global:D \tex_chardef:D #1 = { \bool_if_p:n {#2} }
7581 }
7582 \cs_generate_variant:Nn \bool_set:Nn { c }
7583 \cs_generate_variant:Nn \bool_gset:Nn { c }
7584 \cs_new_protected:Npn \bool_set_inverse:N #1
7585 { \bool_if:NTF #1 { \bool_set_false:N } { \bool_set_true:N } #1 }
7586 \cs_generate_variant:Nn \bool_set_inverse:N { c }
7587 \cs_new_protected:Npn \bool_gset_inverse:N #1
7588 { \bool_if:NTF #1 { \bool_gset_false:N } { \bool_gset_true:N } #1 }
7589 \cs_generate_variant:Nn \bool_gset_inverse:N { c }
7590 \quark_new:N \q__bool_recursion_tail
7591 \quark_new:N \q__bool_recursion_stop
7592 \cs_new:Npn \__bool_use_i_delimit_by_q_recursion_stop:nw
7593 #1 #2 \q__bool_recursion_stop {#1}
7594 \__kernel_quark_new_test:N \__bool_if_recursion_tail_stop_do:nn
7595 \prg_new_conditional:Npnn \bool_if:N #1 { p , T , F , TF }
7596 {
7597 \if_bool:N #1
7598 \prg_return_true:
7599 \else:
7600 \prg_return_false:
7601 \fi:
7602 }
7603 \prg_generate_conditional_variant:Nnn \bool_if:N { c } { p , T , F , TF }
7604 \cs_new:Npe \bool_to_str:N #1
7605 {
7606 \exp_not:N \bool_if:NTF #1
7607 { \tl_to_str:n { true } } { \tl_to_str:n { false } }
7608 }
7609 \cs_generate_variant:Nn \bool_to_str:N { c }
7610 \cs_new:Npe \bool_to_str:n #1
7611 {
7612 \exp_not:N \bool_if:nTF {#1}
7613 { \tl_to_str:n { true } } { \tl_to_str:n { false } }
7614 }
7615 \cs_new_protected:Npn \bool_show:n
7616 { \__kernel_msg_show_eval:Nn \bool_to_str:n }
7617 \cs_new_protected:Npn \bool_log:n
7618 { \__kernel_msg_log_eval:Nn \bool_to_str:n }
7619 \cs_new_protected:Npn \bool_show:N { \__bool_show:NN \tl_show:n }
7620 \cs_generate_variant:Nn \bool_show:N { c }
7621 \cs_new_protected:Npn \bool_log:N { \__bool_show:NN \tl_log:n }
7622 \cs_generate_variant:Nn \bool_log:N { c }
7623 \cs_new_protected:Npn \__bool_show:NN #1#2
7624 {
7625 \__kernel_chk_defined:NT #2
7626 {
7627 \token_case_meaning:NnF #2
7628 {
7629 \c_true_bool { \exp_args:Ne #1 { \token_to_str:N #2 = true } }
7630 \c_false_bool { \exp_args:Ne #1 { \token_to_str:N #2 = false } }
7631 }
7632 {
7633 \msg_error:nneee { kernel } { bad-type }
7634 { \token_to_str:N #2 } { \token_to_meaning:N #2 } { bool }
7635 }
7636 }
7637 }
7638 \bool_new:N \l_tmpa_bool
7639 \bool_new:N \l_tmpb_bool
7640 \bool_new:N \g_tmpa_bool
7641 \bool_new:N \g_tmpb_bool
7642 \prg_new_eq_conditional:NNn \bool_if_exist:N \cs_if_exist:N
7643 { TF , T , F , p }
7644 \prg_new_eq_conditional:NNn \bool_if_exist:c \cs_if_exist:c
7645 { TF , T , F , p }
7646 \prg_new_conditional:Npnn \bool_if:n #1 { T , F , TF }
7647 {
7648 \if_predicate:w \bool_if_p:n {#1}
7649 \prg_return_true:
7650 \else:
7651 \prg_return_false:
7652 \fi:
7653 }
7654 \cs_new:Npn \bool_if_p:n { \exp_args:Nf \__bool_if_p:n }
7655 \cs_new:Npn \__bool_if_p:n #1
7656 {
7657 \tl_if_empty:oT { \use_none:nn #1 . } { \__bool_if_p_aux:w }
7658 \group_align_safe_begin:
7659 \exp_after:wN
7660 \group_align_safe_end:
7661 \exp:w \exp_end_continue_f:w % (
7662 \__bool_get_next:NN \use_i:nnnn #1 )
7663 }
7664 \cs_new:Npn \__bool_if_p_aux:w #1 \use_i:nnnn #2#3
7665 { \bool_if:NTF #2 \c_true_bool \c_false_bool }
7666 \cs_new:Npn \__bool_get_next:NN #1#2
7667 {
7668 \use:c
7669 {
7670 __bool_
7671 \if_meaning:w !#2 ! \else: \if_meaning:w (#2 ( \else: p \fi: \fi:
7672 :Nw
7673 }
7674 #1 #2
7675 }
7676 \cs_new:cpn { __bool_!:Nw } #1#2
7677 {
7678 \exp_after:wN \__bool_get_next:NN
7679 #1 \use_ii:nnnn \use_i:nnnn \use_iii:nnnn \use_iv:nnnn
7680 }
7681 \cs_new:cpn { __bool_(:Nw } #1#2
7682 {
7683 \exp_after:wN \__bool_choose:NNN \exp_after:wN #1
7684 \int_value:w \__bool_get_next:NN \use_i:nnnn
7685 }
7686 \cs_new:cpn { __bool_p:Nw } #1
7687 { \exp_after:wN \__bool_choose:NNN \exp_after:wN #1 \int_value:w }
7688 \cs_new:Npn \__bool_choose:NNN #1#2#3
7689 {
7690 \use:c
7691 {
7692 __bool_ \token_to_str:N #3 _
7693 #1 #2 { \if_meaning:w 0 #2 1 \else: 0 \fi: } 2 0 :
7694 }
7695 }
7696 \cs_new:cpn { __bool_)_0: } { \c_false_bool }
7697 \cs_new:cpn { __bool_)_1: } { \c_true_bool }
7698 \cs_new:cpn { __bool_)_2: } { \c_true_bool }
7699 \cs_new:cpn { __bool_&_0: } & { \__bool_get_next:NN \use_iv:nnnn }
7700 \cs_new:cpn { __bool_&_1: } & { \__bool_get_next:NN \use_i:nnnn }
7701 \cs_new:cpn { __bool_&_2: } & { \__bool_get_next:NN \use_iii:nnnn }
7702 \cs_new:cpn { __bool_|_0: } | { \__bool_get_next:NN \use_i:nnnn }
7703 \cs_new:cpn { __bool_|_1: } | { \__bool_get_next:NN \use_iii:nnnn }
7704 \cs_new:cpn { __bool_|_2: } | { \__bool_get_next:NN \use_iii:nnnn }
7705 \cs_new:Npn \bool_lazy_all_p:n #1
7706 { \__bool_lazy_all:n #1 \q__bool_recursion_tail \q__bool_recursion_stop }
7707 \prg_new_conditional:Npnn \bool_lazy_all:n #1 { T , F , TF }
7708 {
7709 \if_predicate:w \bool_lazy_all_p:n {#1}
7710 \prg_return_true:
7711 \else:
7712 \prg_return_false:
7713 \fi:
7714 }
7715 \cs_new:Npn \__bool_lazy_all:n #1
7716 {
7717 \__bool_if_recursion_tail_stop_do:nn {#1} { \c_true_bool }
7718 \bool_if:nF {#1}
7719 { \__bool_use_i_delimit_by_q_recursion_stop:nw { \c_false_bool } }
7720 \__bool_lazy_all:n
7721 }
7722 \prg_new_conditional:Npnn \bool_lazy_and:nn #1#2 { p , T , F , TF }
7723 {
7724 \if_predicate:w
7725 \bool_if:nTF {#1} { \bool_if_p:n {#2} } { \c_false_bool }
7726 \prg_return_true:
7727 \else:
7728 \prg_return_false:
7729 \fi:
7730 }
7731 \cs_new:Npn \bool_lazy_any_p:n #1
7732 { \__bool_lazy_any:n #1 \q__bool_recursion_tail \q__bool_recursion_stop }
7733 \prg_new_conditional:Npnn \bool_lazy_any:n #1 { T , F , TF }
7734 {
7735 \if_predicate:w \bool_lazy_any_p:n {#1}
7736 \prg_return_true:
7737 \else:
7738 \prg_return_false:
7739 \fi:
7740 }
7741 \cs_new:Npn \__bool_lazy_any:n #1
7742 {
7743 \__bool_if_recursion_tail_stop_do:nn {#1} { \c_false_bool }
7744 \bool_if:nT {#1}
7745 { \__bool_use_i_delimit_by_q_recursion_stop:nw { \c_true_bool } }
7746 \__bool_lazy_any:n
7747 }
7748 \prg_new_conditional:Npnn \bool_lazy_or:nn #1#2 { p , T , F , TF }
7749 {
7750 \if_predicate:w
7751 \bool_if:nTF {#1} { \c_true_bool } { \bool_if_p:n {#2} }
7752 \prg_return_true:
7753 \else:
7754 \prg_return_false:
7755 \fi:
7756 }
7757 \cs_new:Npn \bool_not_p:n #1 { \bool_if_p:n { ! ( #1 ) } }
7758 \prg_new_conditional:Npnn \bool_xor:nn #1#2 { p , T , F , TF }
7759 {
7760 \bool_if:nT {#1} \reverse_if:N
7761 \if_predicate:w \bool_if_p:n {#2}
7762 \prg_return_true:
7763 \else:
7764 \prg_return_false:
7765 \fi:
7766 }
7767 \cs_new:Npn \bool_while_do:Nn #1#2
7768 { \bool_if:NT #1 { #2 \bool_while_do:Nn #1 {#2} } }
7769 \cs_new:Npn \bool_until_do:Nn #1#2
7770 { \bool_if:NF #1 { #2 \bool_until_do:Nn #1 {#2} } }
7771 \cs_generate_variant:Nn \bool_while_do:Nn { c }
7772 \cs_generate_variant:Nn \bool_until_do:Nn { c }
7773 \cs_new:Npn \bool_do_while:Nn #1#2
7774 { #2 \bool_if:NT #1 { \bool_do_while:Nn #1 {#2} } }
7775 \cs_new:Npn \bool_do_until:Nn #1#2
7776 { #2 \bool_if:NF #1 { \bool_do_until:Nn #1 {#2} } }
7777 \cs_generate_variant:Nn \bool_do_while:Nn { c }
7778 \cs_generate_variant:Nn \bool_do_until:Nn { c }
7779 \cs_new:Npn \bool_while_do:nn #1#2
7780 {
7781 \bool_if:nT {#1}
7782 {
7783 #2
7784 \bool_while_do:nn {#1} {#2}
7785 }
7786 }
7787 \cs_new:Npn \bool_do_while:nn #1#2
7788 {
7789 #2
7790 \bool_if:nT {#1} { \bool_do_while:nn {#1} {#2} }
7791 }
7792 \cs_new:Npn \bool_until_do:nn #1#2
7793 {
7794 \bool_if:nF {#1}
7795 {
7796 #2
7797 \bool_until_do:nn {#1} {#2}
7798 }
7799 }
7800 \cs_new:Npn \bool_do_until:nn #1#2
7801 {
7802 #2
7803 \bool_if:nF {#1} { \bool_do_until:nn {#1} {#2} }
7804 }
7805 \scan_new:N \s__bool_mark
7806 \scan_new:N \s__bool_stop
7807 \cs_new:Npn \bool_case:nTF
7808 { \exp:w \__bool_case:nTF }
7809 \cs_new:Npn \bool_case:nT #1#2
7810 { \exp:w \__bool_case:nTF {#1} {#2} { } }
7811 \cs_new:Npn \bool_case:nF #1
7812 { \exp:w \__bool_case:nTF {#1} { } }
7813 \cs_new:Npn \bool_case:n #1
7814 { \exp:w \__bool_case:nTF {#1} { } { } }
7815 \cs_new:Npn \__bool_case:nTF #1#2#3
7816 {
7817 \__bool_case:w
7818 #1 \c_true_bool { } \s__bool_mark {#2} \s__bool_mark {#3} \s__bool_stop
7819 }
7820 \cs_new:Npn \__bool_case:w #1#2
7821 {
7822 \bool_if:nTF {#1}
7823 { \__bool_case_end:nw {#2} }
7824 { \__bool_case:w }
7825 }
7826 \cs_new:Npn \__bool_case_end:nw #1#2#3 \s__bool_mark #4#5 \s__bool_stop
7827 { \exp_end: #1 #4 }
7828 \cs_new:Npn \prg_replicate:nn #1
7829 {
7830 \exp:w
7831 \exp_after:wN \__prg_replicate_first:N
7832 \int_value:w \int_eval:n {#1}
7833 \cs_end:
7834 }
7835 \cs_new:Npn \__prg_replicate:N #1
7836 { \cs:w __prg_replicate_#1 :n \__prg_replicate:N }
7837 \cs_new:Npn \__prg_replicate_first:N #1
7838 { \cs:w __prg_replicate_first_ #1 :n \__prg_replicate:N }
7839 \cs_new:Npn \__prg_replicate_ :n #1 { \cs_end: }
7840 \cs_new:cpn { __prg_replicate_0:n } #1
7841 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} }
7842 \cs_new:cpn { __prg_replicate_1:n } #1
7843 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1 }
7844 \cs_new:cpn { __prg_replicate_2:n } #1
7845 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1 }
7846 \cs_new:cpn { __prg_replicate_3:n } #1
7847 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1 }
7848 \cs_new:cpn { __prg_replicate_4:n } #1
7849 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1 }
7850 \cs_new:cpn { __prg_replicate_5:n } #1
7851 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1 }
7852 \cs_new:cpn { __prg_replicate_6:n } #1
7853 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1 }
7854 \cs_new:cpn { __prg_replicate_7:n } #1
7855 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1 }
7856 \cs_new:cpn { __prg_replicate_8:n } #1
7857 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1#1 }
7858 \cs_new:cpn { __prg_replicate_9:n } #1
7859 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1#1#1 }
7860 \cs_new:cpn { __prg_replicate_first_-:n } #1
7861 {
7862 \exp_end:
7863 \msg_expandable_error:nn { prg } { negative-replication }
7864 }
7865 \cs_new:cpn { __prg_replicate_first_0:n } #1 { \exp_end: }
7866 \cs_new:cpn { __prg_replicate_first_1:n } #1 { \exp_end: #1 }
7867 \cs_new:cpn { __prg_replicate_first_2:n } #1 { \exp_end: #1#1 }
7868 \cs_new:cpn { __prg_replicate_first_3:n } #1 { \exp_end: #1#1#1 }
7869 \cs_new:cpn { __prg_replicate_first_4:n } #1 { \exp_end: #1#1#1#1 }
7870 \cs_new:cpn { __prg_replicate_first_5:n } #1 { \exp_end: #1#1#1#1#1 }
7871 \cs_new:cpn { __prg_replicate_first_6:n } #1 { \exp_end: #1#1#1#1#1#1 }
7872 \cs_new:cpn { __prg_replicate_first_7:n } #1 { \exp_end: #1#1#1#1#1#1#1 }
7873 \cs_new:cpn { __prg_replicate_first_8:n } #1 { \exp_end: #1#1#1#1#1#1#1#1 }
7874 \cs_new:cpn { __prg_replicate_first_9:n } #1
7875 { \exp_end: #1#1#1#1#1#1#1#1#1 }
7876 \prg_new_conditional:Npnn \mode_if_vertical: { p , T , F , TF }
7877 { \if_mode_vertical: \prg_return_true: \else: \prg_return_false: \fi: }
7878 \prg_new_conditional:Npnn \mode_if_horizontal: { p , T , F , TF }
7879 { \if_mode_horizontal: \prg_return_true: \else: \prg_return_false: \fi: }
7880 \prg_new_conditional:Npnn \mode_if_inner: { p , T , F , TF }
7881 { \if_mode_inner: \prg_return_true: \else: \prg_return_false: \fi: }
7882 \prg_new_conditional:Npnn \mode_if_math: { p , T , F , TF }
7883 { \if_mode_math: \prg_return_true: \else: \prg_return_false: \fi: }
7884 \group_begin:
7885 \tex_catcode:D `\^^@ = 2 \exp_stop_f:
7886 \cs_new:Npn \group_align_safe_begin:
7887 { \exp:w \if_false: { \fi: `^^@ \exp_stop_f: }
7888 \tex_catcode:D `\^^@ = 1 \exp_stop_f:
7889 \cs_new:Npn \group_align_safe_end:
7890 { \exp:w `^^@ \if_false: } \fi: \exp_stop_f: }
7891 \group_end:
7892 \int_new:N \g__kernel_prg_map_int
7893 %% File: l3sys.dtx
7894 \tl_new:N \l__sys_tmp_tl
7895 \cs_new_protected:Npn \__sys_const:nn #1#2
7896 {
7897 \bool_if:nTF {#2}
7898 {
7899 \cs_new_eq:cN { #1 :T } \use:n
7900 \cs_new_eq:cN { #1 :F } \use_none:n
7901 \cs_new_eq:cN { #1 :TF } \use_i:nn
7902 \cs_new_eq:cN { #1 _p: } \c_true_bool
7903 }
7904 {
7905 \cs_new_eq:cN { #1 :T } \use_none:n
7906 \cs_new_eq:cN { #1 :F } \use:n
7907 \cs_new_eq:cN { #1 :TF } \use_ii:nn
7908 \cs_new_eq:cN { #1 _p: } \c_false_bool
7909 }
7910 }
7911 \str_const:Ne \c_sys_engine_str
7912 {
7913 \cs_if_exist:NT \tex_luatexversion:D { luatex }
7914 \cs_if_exist:NT \tex_pdftexversion:D { pdftex }
7915 \cs_if_exist:NT \tex_kanjiskip:D
7916 {
7917 \cs_if_exist:NTF \tex_enablecjktoken:D
7918 { uptex }
7919 { ptex }
7920 }
7921 \cs_if_exist:NT \tex_XeTeXversion:D { xetex }
7922 }
7923 \tl_map_inline:nn { { luatex } { pdftex } { ptex } { uptex } { xetex } }
7924 {
7925 \__sys_const:nn { sys_if_engine_ #1 }
7926 { \str_if_eq_p:Vn \c_sys_engine_str {#1} }
7927 }
7928 \__sys_const:nn
7929 { sys_if_engine_opentype }
7930 { \cs_if_exist_p:N \tex_Umathcode:D }
7931 \group_begin:
7932 \cs_set_eq:NN \lua_now:e \tex_directlua:D
7933 \str_const:Ne \c_sys_engine_exec_str
7934 {
7935 \sys_if_engine_pdftex:T { pdf }
7936 \sys_if_engine_xetex:T { xe }
7937 \sys_if_engine_ptex:T { ep }
7938 \sys_if_engine_uptex:T { eup }
7939 \sys_if_engine_luatex:T
7940 {
7941 lua \lua_now:e
7942 {
7943 if (pcall(require, 'luaharfbuzz')) then ~
7944 tex.print("hb") ~
7945 end
7946 }
7947 }
7948 tex
7949 }
7950 \group_end:
7951 \str_const:Ne \c_sys_engine_format_str
7952 {
7953 \cs_if_exist:NTF \fmtname
7954 {
7955 \bool_lazy_or:nnTF
7956 { \str_if_eq_p:Vn \fmtname { plain } }
7957 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
7958 {
7959 \sys_if_engine_pdftex:T
7960 { \int_compare:nNnT { \tex_pdfoutput:D } = { 1 } { pdf } }
7961 \sys_if_engine_xetex:T { xe }
7962 \sys_if_engine_ptex:T { p }
7963 \sys_if_engine_uptex:T { up }
7964 \sys_if_engine_luatex:T
7965 {
7966 \int_compare:nNnT { \tex_pdfoutput:D } = { 0 } { dvi }
7967 lua
7968 }
7969 \str_if_eq:VnTF \fmtname { LaTeX2e }
7970 { latex }
7971 {
7972 \bool_lazy_and:nnT
7973 { \sys_if_engine_pdftex_p: }
7974 { \int_compare_p:nNn { \tex_pdfoutput:D } = { 0 } }
7975 { e }
7976 tex
7977 }
7978 }
7979 { \fmtname }
7980 }
7981 { unknown }
7982 }
7983 \str_const:Ne \c_sys_engine_version_str
7984 {
7985 \str_case:on \c_sys_engine_str
7986 {
7987 { pdftex }
7988 {
7989 \int_div_truncate:nn { \tex_pdftexversion:D } { 100 }
7990 .
7991 \int_mod:nn { \tex_pdftexversion:D } { 100 }
7992 .
7993 \tex_pdftexrevision:D
7994 }
7995 { ptex }
7996 {
7997 \cs_if_exist:NT \tex_ptexversion:D
7998 {
7999 p
8000 \int_use:N \tex_ptexversion:D
8001 .
8002 \int_use:N \tex_ptexminorversion:D
8003 \tex_ptexrevision:D
8004 -
8005 \int_use:N \tex_epTeXversion:D
8006 }
8007 }
8008 { luatex }
8009 {
8010 \int_div_truncate:nn { \tex_luatexversion:D } { 100 }
8011 .
8012 \int_mod:nn { \tex_luatexversion:D } { 100 }
8013 .
8014 \tex_luatexrevision:D
8015 }
8016 { uptex }
8017 {
8018 \cs_if_exist:NT \tex_ptexversion:D
8019 {
8020 p
8021 \int_use:N \tex_ptexversion:D
8022 .
8023 \int_use:N \tex_ptexminorversion:D
8024 \tex_ptexrevision:D
8025 -
8026 u
8027 \int_use:N \tex_uptexversion:D
8028 \tex_uptexrevision:D
8029 -
8030 \int_use:N \tex_epTeXversion:D
8031 }
8032 }
8033 { xetex }
8034 {
8035 \int_use:N \tex_XeTeXversion:D
8036 \tex_XeTeXrevision:D
8037 }
8038 }
8039 }
8040 \cs_new_protected:Npn \sys_load_backend:n #1
8041 {
8042 \sys_finalize:
8043 \str_if_exist:NTF \c_sys_backend_str
8044 {
8045 \str_if_eq:VnF \c_sys_backend_str {#1}
8046 { \msg_error:nn { sys } { backend-set } }
8047 }
8048 {
8049 \tl_if_blank:nF {#1}
8050 { \tl_gset:Nn \g__sys_backend_tl {#1} }
8051 \__sys_load_backend_check:N \g__sys_backend_tl
8052 \str_const:Ne \c_sys_backend_str { \g__sys_backend_tl }
8053 \__kernel_sys_configuration_load:n
8054 { l3backend- \c_sys_backend_str }
8055 }
8056 }
8057 \cs_new_protected:Npn \__sys_load_backend_check:N #1
8058 {
8059 \sys_if_engine_xetex:TF
8060 {
8061 \str_case:VnF #1
8062 {
8063 { dvisvgm } { }
8064 { xdvipdfmx } { \tl_gset:Nn #1 { xetex } }
8065 { xetex } { }
8066 }
8067 {
8068 \msg_error:nnee { sys } { wrong-backend }
8069 #1 { xetex }
8070 \tl_gset:Nn #1 { xetex }
8071 }
8072 }
8073 {
8074 \sys_if_output_pdf:TF
8075 {
8076 \str_if_eq:VnTF #1 { pdfmode }
8077 {
8078 \sys_if_engine_luatex:TF
8079 { \tl_gset:Nn #1 { luatex } }
8080 { \tl_gset:Nn #1 { pdftex } }
8081 }
8082 {
8083 \bool_lazy_or:nnF
8084 { \str_if_eq_p:Vn #1 { luatex } }
8085 { \str_if_eq_p:Vn #1 { pdftex } }
8086 {
8087 \msg_error:nnee { sys } { wrong-backend }
8088 #1 { \sys_if_engine_luatex:TF { luatex } { pdftex } }
8089 \sys_if_engine_luatex:TF
8090 { \tl_gset:Nn #1 { luatex } }
8091 { \tl_gset:Nn #1 { pdftex } }
8092 }
8093 }
8094 }
8095 {
8096 \str_case:VnF #1
8097 {
8098 { dvipdfmx } { }
8099 { dvips } { }
8100 { dvisvgm } { }
8101 }
8102 {
8103 \msg_error:nnee { sys } { wrong-backend }
8104 #1 { dvips }
8105 \tl_gset:Nn #1 { dvips }
8106 }
8107 }
8108 }
8109 }
8110 \cs_new_protected:Npn \sys_ensure_backend:
8111 {
8112 \str_if_exist:NF \c_sys_backend_str
8113 { \sys_load_backend:n { } }
8114 }
8115 \bool_new:N \g__sys_debug_bool
8116 \cs_new_protected:Npn \sys_load_debug:
8117 {
8118 \bool_if:NF \g__sys_debug_bool
8119 { \__kernel_sys_configuration_load:n { l3debug } }
8120 \bool_gset_true:N \g__sys_debug_bool
8121 }
8122 \cs_if_exist:NT \@expl@finalise@setup@@
8123 {
8124 \tl_gput_right:Nn \@expl@finalise@setup@@
8125 {
8126 \tl_gput_right:Nn \@kernel@after@begindocument
8127 {
8128 \cs_gset_protected:Npn \sys_load_debug:
8129 { \msg_error:nn { sys } { load-debug-in-preamble } }
8130 }
8131 }
8132 }
8133 \tl_const:Ne \c__sys_marker_tl { : \token_to_str:N : }
8134 \cs_new_protected:Npn \sys_get_shell:nnN #1#2#3
8135 {
8136 \sys_get_shell:nnNF {#1} {#2} #3
8137 { \tl_set:Nn #3 { \q_no_value } }
8138 }
8139 \prg_new_protected_conditional:Npnn \sys_get_shell:nnN #1#2#3 { T , F , TF }
8140 {
8141 \sys_if_shell:TF
8142 { \exp_args:No \__sys_get:nnN { \tl_to_str:n {#1} } {#2} #3 }
8143 { \prg_return_false: }
8144 }
8145 \cs_new_protected:Npn \__sys_get:nnN #1#2#3
8146 {
8147 \tl_if_in:nnTF {#1} { " }
8148 {
8149 \msg_error:nne
8150 { kernel } { quote-in-shell } {#1}
8151 \prg_return_false:
8152 }
8153 {
8154 \group_begin:
8155 \if_false: { \fi:
8156 \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
8157 \exp_args:No \tex_everyeof:D { \c__sys_marker_tl }
8158 #2 \scan_stop:
8159 \exp_after:wN \__sys_get_do:Nw
8160 \exp_after:wN #3
8161 \exp_after:wN \prg_do_nothing:
8162 \tex_input:D | "#1" \scan_stop:
8163 \if_false: } \fi:
8164 \prg_return_true:
8165 }
8166 }
8167 \exp_args:Nno \use:nn
8168 { \cs_new_protected:Npn \__sys_get_do:Nw #1#2 }
8169 { \c__sys_marker_tl }
8170 {
8171 \group_end:
8172 \tl_set:No #1 {#2}
8173 }
8174 \sys_if_engine_luatex:F
8175 { \int_const:Nn \c__sys_shell_stream_int { 18 } }
8176 \sys_if_engine_luatex:TF
8177 {
8178 \cs_new_protected:Npn \sys_shell_now:n #1
8179 { \__sys_shell_now:e { \exp_not:n {#1} } }
8180 }
8181 {
8182 \cs_new_protected:Npn \sys_shell_now:n #1
8183 { \iow_now:Nn \c__sys_shell_stream_int {#1} }
8184 }
8185 \cs_generate_variant:Nn \sys_shell_now:n { e, x }
8186 \sys_if_engine_luatex:TF
8187 {
8188 \cs_new_protected:Npn \sys_shell_shipout:n #1
8189 { \__sys_shell_shipout:e { \exp_not:n {#1} } }
8190 }
8191 {
8192 \cs_new_protected:Npn \sys_shell_shipout:n #1
8193 { \iow_shipout:Nn \c__sys_shell_stream_int {#1} }
8194 }
8195 \cs_generate_variant:Nn \sys_shell_shipout:n { e , x }
8196 \cs_new_protected:Npn \__kernel_sys_everyjob:
8197 {
8198 \tl_use:N \g__sys_everyjob_tl
8199 \tl_gclear:N \g__sys_everyjob_tl
8200 }
8201 \cs_new_protected:Npn \__sys_everyjob:n #1
8202 { \tl_gput_right:Nn \g__sys_everyjob_tl {#1} }
8203 \tl_new:N \g__sys_everyjob_tl
8204 \__sys_everyjob:n
8205 { \cs_new_eq:NN \c_sys_jobname_str \tex_jobname:D }
8206 \__sys_everyjob:n
8207 {
8208 \group_begin:
8209 \cs_set:Npn \__sys_tmp:w #1
8210 {
8211 \str_if_eq:eeTF { \cs_meaning:N #1 } { \token_to_str:N #1 }
8212 { #1 }
8213 {
8214 \cs_if_exist:NTF \tex_primitive:D
8215 {
8216 \bool_lazy_and:nnTF
8217 { \sys_if_engine_xetex_p: }
8218 {
8219 \int_compare_p:nNn
8220 { \exp_after:wN \use_none:n \tex_XeTeXrevision:D }
8221 < { 99999 }
8222 }
8223 { 0 }
8224 { \tex_primitive:D #1 }
8225 }
8226 { 0 }
8227 }
8228 }
8229 \int_const:Nn \c_sys_minute_int
8230 { \int_mod:nn { \__sys_tmp:w \time } { 60 } }
8231 \int_const:Nn \c_sys_hour_int
8232 { \int_div_truncate:nn { \__sys_tmp:w \time } { 60 } }
8233 \int_const:Nn \c_sys_day_int { \__sys_tmp:w \day }
8234 \int_const:Nn \c_sys_month_int { \__sys_tmp:w \month }
8235 \int_const:Nn \c_sys_year_int { \__sys_tmp:w \year }
8236 \group_end:
8237 }
8238 \__sys_everyjob:n
8239 {
8240 \str_const:Ne \c_sys_timestamp_str
8241 {
8242 \cs_if_exist:NTF \tex_directlua:D
8243 { \tex_directlua:D { tex.print(pdf.getcreationdate()) } }
8244 { \tex_creationdate:D }
8245 }
8246 }
8247 \__sys_everyjob:n
8248 {
8249 \cs_new:Npn \sys_rand_seed: { \tex_the:D \tex_randomseed:D }
8250 }
8251 \__sys_everyjob:n
8252 {
8253 \cs_new_protected:Npn \sys_gset_rand_seed:n #1
8254 { \tex_setrandomseed:D \int_eval:n {#1} \exp_stop_f: }
8255 }
8256 \cs_new:Npe \sys_timer:
8257 {
8258 \sys_if_engine_luatex:TF
8259 { \exp_not:N \__sys_elapsedtime: }
8260 { \exp_not:N \int_value:w \exp_not:N \tex_elapsedtime:D }
8261 }
8262 \__sys_everyjob:n
8263 {
8264 \int_const:Nn \c_sys_shell_escape_int
8265 {
8266 \sys_if_engine_luatex:TF
8267 {
8268 \tex_directlua:D
8269 { tex.sprint(status.shell_escape~or~os.execute()) }
8270 }
8271 { \tex_shellescape:D }
8272 }
8273 }
8274 \__sys_everyjob:n
8275 {
8276 \__sys_const:nn { sys_if_shell }
8277 { \int_compare_p:nNn \c_sys_shell_escape_int > 0 }
8278 \__sys_const:nn { sys_if_shell_unrestricted }
8279 { \int_compare_p:nNn \c_sys_shell_escape_int = 1 }
8280 \__sys_const:nn { sys_if_shell_restricted }
8281 { \int_compare_p:nNn \c_sys_shell_escape_int = 2 }
8282 }
8283 \cs_new_protected:Npn \sys_get_query:nN #1#2
8284 { \sys_get_query:nnnN {#1} { } { } #2 }
8285 \cs_new_protected:Npn \sys_get_query:nnN #1#2#3
8286 { \sys_get_query:nnnN {#1} { } {#2} #3 }
8287 \cs_new_protected:Npn \sys_get_query:nnnN #1#2#3#4
8288 {
8289 \tl_clear:N #4
8290 \__sys_get_query_auxi:neeN {#1} {#2} {#3} #4
8291 }
8292 \cs_new:Npn \__sys_get_query_auxi:nnnN #1#2#3#4
8293 {
8294 \__sys_get_query_auxii:neeN {#1}
8295 { \tl_if_blank:nF {#2} { \tl_to_str:n { ~ #2 } } }
8296 {
8297 \tl_if_blank:nF {#3}
8298 {
8299 \c_space_tl
8300 \sys_if_shell_restricted:F '
8301 \tl_to_str:n {#3}
8302 \sys_if_shell_restricted:F '
8303 }
8304 }
8305 #4
8306 }
8307 \cs_generate_variant:Nn \__sys_get_query_auxi:nnnN { nee }
8308 \cs_new_protected:Npn \__sys_get_query_auxii:nnnN #1#2#3#4
8309 {
8310 \sys_if_shell:T
8311 {
8312 \sys_get_shell:nnN
8313 { l3sys-query~#1 #2 #3 }
8314 {
8315 \int_step_inline:nnn { 0 } { `A - 1 }
8316 { \char_set_catcode_other:n {##1} }
8317 \int_step_inline:nnn { `Z + 1 } { `a - 1 }
8318 { \char_set_catcode_other:n {##1} }
8319 \int_step_inline:nnn { `z + 1 } { 127 }
8320 { \char_set_catcode_other:n {##1} }
8321 \char_set_catcode_active:n { `\ }
8322 \tex_endlinechar:D 13 \scan_stop:
8323 }
8324 \l__sys_tmp_tl
8325 \tl_if_empty:NF \l__sys_tmp_tl
8326 {
8327 \exp_after:wN \__sys_get_query:Nw \exp_after:wN #4
8328 \l__sys_tmp_tl \q_stop
8329 }
8330 }
8331 }
8332 \cs_generate_variant:Nn \__sys_get_query_auxii:nnnN { nee }
8333 \group_begin:
8334 \tex_lccode:D `\* = 13 \scan_stop:
8335 \tex_lowercase:D
8336 {
8337 \group_end:
8338 \cs_new_protected:Npn \__sys_get_query:Nw #1#2 * \q_stop
8339 }
8340 { \tl_set:Nn #1 {#2} }
8341 \cs_new_protected:Npn \sys_split_query:nN #1#2
8342 { \sys_split_query:nnnN {#1} { } { } #2 }
8343 \cs_new_protected:Npn \sys_split_query:nnN #1#2#3
8344 { \sys_split_query:nnnN {#1} { } {#2} #3 }
8345 \group_begin:
8346 \tex_lccode:D `\* = 13 \scan_stop:
8347 \tex_lowercase:D
8348 {
8349 \group_end:
8350 \cs_new_protected:Npn \sys_split_query:nnnN #1#2#3#4
8351 {
8352 \seq_clear:N #4
8353 \sys_get_query:nnnN {#1} {#2} {#3} \l__sys_tmp_tl
8354 \tl_if_empty:NF \l__sys_tmp_tl
8355 { \seq_set_split:NnV #4 * \l__sys_tmp_tl }
8356 }
8357 }
8358 \__sys_everyjob:n
8359 { \cs_gset_eq:NN \g_file_curr_name_str \tex_jobname:D }
8360 \cs_new_protected:Npn \sys_finalize:
8361 {
8362 \__kernel_sys_everyjob:
8363 \tl_use:N \g__sys_finalize_tl
8364 \tl_gclear:N \g__sys_finalize_tl
8365 }
8366 \cs_new_protected:Npn \__sys_finalize:n #1
8367 { \tl_gput_right:Nn \g__sys_finalize_tl {#1} }
8368 \tl_new:N \g__sys_finalize_tl
8369 \__sys_finalize:n
8370 {
8371 \str_const:Ne \c_sys_output_str
8372 {
8373 \int_compare:nNnTF
8374 { \cs_if_exist_use:NF \tex_pdfoutput:D { 0 } } > { 0 }
8375 { pdf }
8376 { dvi }
8377 }
8378 \__sys_const:nn { sys_if_output_dvi }
8379 { \str_if_eq_p:Vn \c_sys_output_str { dvi } }
8380 \__sys_const:nn { sys_if_output_pdf }
8381 { \str_if_eq_p:Vn \c_sys_output_str { pdf } }
8382 }
8383 \tl_new:N \g__sys_backend_tl
8384 \__sys_finalize:n
8385 {
8386 \__kernel_tl_gset:Nx \g__sys_backend_tl
8387 {
8388 \sys_if_engine_xetex:TF
8389 { xetex }
8390 {
8391 \sys_if_output_pdf:TF
8392 {
8393 \sys_if_engine_pdftex:TF
8394 { pdftex }
8395 { luatex }
8396 }
8397 { dvips }
8398 }
8399 }
8400 }
8401 \__sys_finalize:n
8402 {
8403 \cs_if_exist:NT \@classoptionslist
8404 {
8405 \cs_if_eq:NNF \@classoptionslist \scan_stop:
8406 {
8407 \clist_map_inline:Nn \@classoptionslist
8408 {
8409 \str_case:nnT {#1}
8410 {
8411 { dvipdfmx }
8412 { \tl_gset:Nn \g__sys_backend_tl { dvipdfmx } }
8413 { dvips }
8414 { \tl_gset:Nn \g__sys_backend_tl { dvips } }
8415 { dvisvgm }
8416 { \tl_gset:Nn \g__sys_backend_tl { dvisvgm } }
8417 { pdftex }
8418 { \tl_gset:Nn \g__sys_backend_tl { pdfmode } }
8419 { xetex }
8420 { \tl_gset:Nn \g__sys_backend_tl { xdvipdfmx } }
8421 }
8422 { \clist_remove_all:Nn \@unusedoptionlist {#1} }
8423 }
8424 }
8425 }
8426 }
8427 %% File: l3clist.dtx
8428 \cs_new_eq:NN \c_empty_clist \c_empty_tl
8429 \tl_new:N \l__clist_tmp_clist
8430 \scan_new:N \s__clist_mark
8431 \scan_new:N \s__clist_stop
8432 \cs_new:Npn \__clist_use_none_delimit_by_s_mark:w #1 \s__clist_mark { }
8433 \cs_new:Npn \__clist_use_none_delimit_by_s_stop:w #1 \s__clist_stop { }
8434 \cs_new:Npn \__clist_use_i_delimit_by_s_stop:nw #1 #2 \s__clist_stop {#1}
8435 \cs_new_protected:Npn \__clist_tmp:w { }
8436 \cs_new:Npn \__clist_trim_next:w #1 ,
8437 {
8438 \tl_if_empty:oTF { \use_none:nn #1 ? }
8439 { \__clist_trim_next:w \prg_do_nothing: }
8440 { \tl_trim_spaces_apply:oN {#1} \exp_end: }
8441 }
8442 \cs_new:Npn \__clist_sanitize:n #1
8443 {
8444 \exp_after:wN \__clist_sanitize:Nn \exp_after:wN \c_empty_tl
8445 \exp:w \__clist_trim_next:w \prg_do_nothing:
8446 #1 , \s__clist_stop \prg_break: , \prg_break_point:
8447 }
8448 \cs_new:Npn \__clist_sanitize:Nn #1#2
8449 {
8450 \__clist_use_none_delimit_by_s_stop:w #2 \s__clist_stop
8451 #1 \__clist_wrap_item:w #2 ,
8452 \exp_after:wN \__clist_sanitize:Nn \exp_after:wN ,
8453 \exp:w \__clist_trim_next:w \prg_do_nothing:
8454 }
8455 \prg_new_conditional:Npnn \__clist_if_wrap:n #1 { TF }
8456 {
8457 \tl_if_empty:oTF
8458 {
8459 \__clist_if_wrap:w
8460 \s__clist_mark ? #1 ~ \s__clist_mark ? ~ #1
8461 \s__clist_mark , ~ \s__clist_mark #1 ,
8462 }
8463 {
8464 \tl_if_head_is_group:nTF { #1 { } }
8465 {
8466 \tl_if_empty:nTF {#1}
8467 { \prg_return_true: }
8468 {
8469 \tl_if_empty:oTF { \use_none:n #1}
8470 { \prg_return_true: }
8471 { \prg_return_false: }
8472 }
8473 }
8474 { \prg_return_false: }
8475 }
8476 { \prg_return_true: }
8477 }
8478 \cs_new:Npn \__clist_if_wrap:w #1 \s__clist_mark ? ~ #2 ~ \s__clist_mark #3 , { }
8479 \cs_new:Npn \__clist_wrap_item:w #1 ,
8480 { \__clist_if_wrap:nTF {#1} { \exp_not:n { {#1} } } { \exp_not:n {#1} } }
8481 \cs_new_eq:NN \clist_new:N \tl_new:N
8482 \cs_new_eq:NN \clist_new:c \tl_new:c
8483 \cs_new_protected:Npn \clist_const:Nn #1#2
8484 { \tl_const:Ne #1 { \__clist_sanitize:n {#2} } }
8485 \cs_generate_variant:Nn \clist_const:Nn { Ne , c , ce }
8486 \cs_generate_variant:Nn \clist_const:Nn { Nx , cx }
8487 \cs_new_eq:NN \clist_clear:N \tl_clear:N
8488 \cs_new_eq:NN \clist_clear:c \tl_clear:c
8489 \cs_new_eq:NN \clist_gclear:N \tl_gclear:N
8490 \cs_new_eq:NN \clist_gclear:c \tl_gclear:c
8491 \cs_new_eq:NN \clist_clear_new:N \tl_clear_new:N
8492 \cs_new_eq:NN \clist_clear_new:c \tl_clear_new:c
8493 \cs_new_eq:NN \clist_gclear_new:N \tl_gclear_new:N
8494 \cs_new_eq:NN \clist_gclear_new:c \tl_gclear_new:c
8495 \cs_new_eq:NN \clist_set_eq:NN \tl_set_eq:NN
8496 \cs_new_eq:NN \clist_set_eq:Nc \tl_set_eq:Nc
8497 \cs_new_eq:NN \clist_set_eq:cN \tl_set_eq:cN
8498 \cs_new_eq:NN \clist_set_eq:cc \tl_set_eq:cc
8499 \cs_new_eq:NN \clist_gset_eq:NN \tl_gset_eq:NN
8500 \cs_new_eq:NN \clist_gset_eq:Nc \tl_gset_eq:Nc
8501 \cs_new_eq:NN \clist_gset_eq:cN \tl_gset_eq:cN
8502 \cs_new_eq:NN \clist_gset_eq:cc \tl_gset_eq:cc
8503 \cs_new_protected:Npn \clist_set_from_seq:NN
8504 { \__clist_set_from_seq:NNNN \clist_clear:N \__kernel_tl_set:Nx }
8505 \cs_new_protected:Npn \clist_gset_from_seq:NN
8506 { \__clist_set_from_seq:NNNN \clist_gclear:N \__kernel_tl_gset:Nx }
8507 \cs_new_protected:Npn \__clist_set_from_seq:NNNN #1#2#3#4
8508 {
8509 \seq_if_empty:NTF #4
8510 { #1 #3 }
8511 {
8512 #2 #3
8513 {
8514 \exp_after:wN \use_none:n \exp:w \exp_end_continue_f:w
8515 \seq_map_function:NN #4 \__clist_set_from_seq:n
8516 }
8517 }
8518 }
8519 \cs_new:Npn \__clist_set_from_seq:n #1
8520 {
8521 ,
8522 \__clist_if_wrap:nTF {#1}
8523 { \exp_not:n { {#1} } }
8524 { \exp_not:n {#1} }
8525 }
8526 \cs_generate_variant:Nn \clist_set_from_seq:NN { Nc }
8527 \cs_generate_variant:Nn \clist_set_from_seq:NN { c , cc }
8528 \cs_generate_variant:Nn \clist_gset_from_seq:NN { Nc }
8529 \cs_generate_variant:Nn \clist_gset_from_seq:NN { c , cc }
8530 \cs_new_protected:Npn \clist_concat:NNN
8531 { \__clist_concat:NNNN \__kernel_tl_set:Nx }
8532 \cs_new_protected:Npn \clist_gconcat:NNN
8533 { \__clist_concat:NNNN \__kernel_tl_gset:Nx }
8534 \cs_new_protected:Npn \__clist_concat:NNNN #1#2#3#4
8535 {
8536 #1 #2
8537 {
8538 \exp_not:o #3
8539 \clist_if_empty:NF #3 { \clist_if_empty:NF #4 { , } }
8540 \exp_not:o #4
8541 }
8542 }
8543 \cs_generate_variant:Nn \clist_concat:NNN { ccc }
8544 \cs_generate_variant:Nn \clist_gconcat:NNN { ccc }
8545 \prg_new_eq_conditional:NNn \clist_if_exist:N \cs_if_exist:N
8546 { TF , T , F , p }
8547 \prg_new_eq_conditional:NNn \clist_if_exist:c \cs_if_exist:c
8548 { TF , T , F , p }
8549 \cs_new_protected:Npn \clist_set:Nn #1#2
8550 { \__kernel_tl_set:Nx #1 { \__clist_sanitize:n {#2} } }
8551 \cs_new_protected:Npn \clist_gset:Nn #1#2
8552 { \__kernel_tl_gset:Nx #1 { \__clist_sanitize:n {#2} } }
8553 \cs_generate_variant:Nn \clist_set:Nn { NV , Nv , Ne , c , cV , cv , ce }
8554 \cs_generate_variant:Nn \clist_set:Nn { No , Nx , co , cx }
8555 \cs_generate_variant:Nn \clist_gset:Nn { NV , Nv , Ne , c , cV , cv , ce }
8556 \cs_generate_variant:Nn \clist_gset:Nn { No , Nx , co , cx }
8557 \cs_new_protected:Npn \clist_put_left:Nn
8558 { \__clist_put_left:NNNn \clist_concat:NNN \clist_set:Nn }
8559 \cs_new_protected:Npn \clist_gput_left:Nn
8560 { \__clist_put_left:NNNn \clist_gconcat:NNN \clist_set:Nn }
8561 \cs_new_protected:Npn \__clist_put_left:NNNn #1#2#3#4
8562 {
8563 #2 \l__clist_tmp_clist {#4}
8564 #1 #3 \l__clist_tmp_clist #3
8565 }
8566 \cs_generate_variant:Nn \clist_put_left:Nn { NV , Nv , Ne , c , cV , cv , ce }
8567 \cs_generate_variant:Nn \clist_put_left:Nn { No , Nx , co , cx }
8568 \cs_generate_variant:Nn \clist_gput_left:Nn { NV , Nv , Ne , c , cV , cv , ce }
8569 \cs_generate_variant:Nn \clist_gput_left:Nn { No , Nx , co , cx }
8570 \cs_new_protected:Npn \clist_put_right:Nn
8571 { \__clist_put_right:NNNn \clist_concat:NNN \clist_set:Nn }
8572 \cs_new_protected:Npn \clist_gput_right:Nn
8573 { \__clist_put_right:NNNn \clist_gconcat:NNN \clist_set:Nn }
8574 \cs_new_protected:Npn \__clist_put_right:NNNn #1#2#3#4
8575 {
8576 #2 \l__clist_tmp_clist {#4}
8577 #1 #3 #3 \l__clist_tmp_clist
8578 }
8579 \cs_generate_variant:Nn \clist_put_right:Nn
8580 { NV , Nv , Ne , c , cV , cv , ce }
8581 \cs_generate_variant:Nn \clist_put_right:Nn
8582 { No , Nx , co , cx }
8583 \cs_generate_variant:Nn \clist_gput_right:Nn
8584 { NV , Nv , Ne , c , cV , cv , ce }
8585 \cs_generate_variant:Nn \clist_gput_right:Nn
8586 { No , Nx , co , cx }
8587 \cs_new_protected:Npn \clist_get:NN #1#2
8588 {
8589 \if_meaning:w #1 \c_empty_clist
8590 \tl_set:Nn #2 { \q_no_value }
8591 \else:
8592 \exp_after:wN \__clist_get:wN #1 , \s__clist_stop #2
8593 \fi:
8594 }
8595 \cs_new_protected:Npn \__clist_get:wN #1 , #2 \s__clist_stop #3
8596 { \tl_set:Nn #3 {#1} }
8597 \cs_generate_variant:Nn \clist_get:NN { c }
8598 \cs_new_protected:Npn \clist_pop:NN
8599 { \__clist_pop:NNN \__kernel_tl_set:Nx }
8600 \cs_new_protected:Npn \clist_gpop:NN
8601 { \__clist_pop:NNN \__kernel_tl_gset:Nx }
8602 \cs_new_protected:Npn \__clist_pop:NNN #1#2#3
8603 {
8604 \if_meaning:w #2 \c_empty_clist
8605 \tl_set:Nn #3 { \q_no_value }
8606 \else:
8607 \exp_after:wN \__clist_pop:wwNNN #2 , \s__clist_mark \s__clist_stop #1#2#3
8608 \fi:
8609 }
8610 \cs_new_protected:Npn \__clist_pop:wwNNN #1 , #2 \s__clist_stop #3#4#5
8611 {
8612 \tl_set:Nn #5 {#1}
8613 #3 #4
8614 {
8615 \__clist_pop:wN \prg_do_nothing:
8616 #2 \exp_not:o
8617 , \s__clist_mark \use_none:n
8618 \s__clist_stop
8619 }
8620 }
8621 \cs_new:Npn \__clist_pop:wN #1 , \s__clist_mark #2 #3 \s__clist_stop { #2 {#1} }
8622 \cs_generate_variant:Nn \clist_pop:NN { c }
8623 \cs_generate_variant:Nn \clist_gpop:NN { c }
8624 \prg_new_protected_conditional:Npnn \clist_get:NN #1#2 { T , F , TF }
8625 {
8626 \if_meaning:w #1 \c_empty_clist
8627 \prg_return_false:
8628 \else:
8629 \exp_after:wN \__clist_get:wN #1 , \s__clist_stop #2
8630 \prg_return_true:
8631 \fi:
8632 }
8633 \prg_generate_conditional_variant:Nnn \clist_get:NN { c } { T , F , TF }
8634 \prg_new_protected_conditional:Npnn \clist_pop:NN #1#2 { T , F , TF }
8635 { \__clist_pop_TF:NNN \__kernel_tl_set:Nx #1 #2 }
8636 \prg_new_protected_conditional:Npnn \clist_gpop:NN #1#2 { T , F , TF }
8637 { \__clist_pop_TF:NNN \__kernel_tl_gset:Nx #1 #2 }
8638 \cs_new_protected:Npn \__clist_pop_TF:NNN #1#2#3
8639 {
8640 \if_meaning:w #2 \c_empty_clist
8641 \prg_return_false:
8642 \else:
8643 \exp_after:wN \__clist_pop:wwNNN #2 , \s__clist_mark \s__clist_stop #1#2#3
8644 \prg_return_true:
8645 \fi:
8646 }
8647 \prg_generate_conditional_variant:Nnn \clist_pop:NN { c } { T , F , TF }
8648 \prg_generate_conditional_variant:Nnn \clist_gpop:NN { c } { T , F , TF }
8649 \cs_new_eq:NN \clist_push:Nn \clist_put_left:Nn
8650 \cs_generate_variant:Nn \clist_push:Nn { NV , No , Nx , c , cV , co , cx }
8651 \cs_new_eq:NN \clist_gpush:Nn \clist_gput_left:Nn
8652 \cs_generate_variant:Nn \clist_gpush:Nn { NV , No , Nx , c , cV , co , cx }
8653 \clist_new:N \l__clist_remove_clist
8654 \seq_new:N \l__clist_remove_seq
8655 \cs_new_protected:Npn \clist_remove_duplicates:N
8656 { \__clist_remove_duplicates:NN \clist_set_eq:NN }
8657 \cs_new_protected:Npn \clist_gremove_duplicates:N
8658 { \__clist_remove_duplicates:NN \clist_gset_eq:NN }
8659 \cs_new_protected:Npn \__clist_remove_duplicates:NN #1#2
8660 {
8661 \clist_clear:N \l__clist_remove_clist
8662 \clist_map_inline:Nn #2
8663 {
8664 \clist_if_in:NnF \l__clist_remove_clist {##1}
8665 {
8666 \tl_put_right:Ne \l__clist_remove_clist
8667 {
8668 \clist_if_empty:NF \l__clist_remove_clist { , }
8669 \__clist_if_wrap:nTF {##1} { \exp_not:n { {##1} } } { \exp_not:n {##1} }
8670 }
8671 }
8672 }
8673 #1 #2 \l__clist_remove_clist
8674 }
8675 \cs_generate_variant:Nn \clist_remove_duplicates:N { c }
8676 \cs_generate_variant:Nn \clist_gremove_duplicates:N { c }
8677 \cs_new_protected:Npn \clist_remove_all:Nn
8678 { \__clist_remove_all:NNNn \clist_set_from_seq:NN \__kernel_tl_set:Nx }
8679 \cs_new_protected:Npn \clist_gremove_all:Nn
8680 { \__clist_remove_all:NNNn \clist_gset_from_seq:NN \__kernel_tl_gset:Nx }
8681 \cs_new_protected:Npn \__clist_remove_all:NNNn #1#2#3#4
8682 {
8683 \__clist_if_wrap:nTF {#4}
8684 {
8685 \seq_set_from_clist:NN \l__clist_remove_seq #3
8686 \seq_remove_all:Nn \l__clist_remove_seq {#4}
8687 #1 #3 \l__clist_remove_seq
8688 }
8689 {
8690 \cs_set:Npn \__clist_tmp:w ##1 , #4 ,
8691 {
8692 ##1
8693 , \s__clist_mark , \__clist_use_none_delimit_by_s_stop:w ,
8694 \__clist_remove_all:
8695 }
8696 #2 #3
8697 {
8698 \exp_after:wN \__clist_remove_all:
8699 #3 , \s__clist_mark , #4 , \s__clist_stop
8700 }
8701 \clist_if_empty:NF #3
8702 {
8703 #2 #3
8704 {
8705 \exp_args:No \exp_not:o
8706 { \exp_after:wN \use_none:n #3 }
8707 }
8708 }
8709 }
8710 }
8711 \cs_new:Npn \__clist_remove_all:
8712 { \exp_after:wN \__clist_remove_all:w \__clist_tmp:w , }
8713 \cs_new:Npn \__clist_remove_all:w #1 , \s__clist_mark , #2 , { \exp_not:n {#1} }
8714 \cs_generate_variant:Nn \clist_remove_all:Nn { c , NV , cV , Ne , ce }
8715 \cs_generate_variant:Nn \clist_gremove_all:Nn { c , NV , cV , Ne , ce }
8716 \cs_new_protected:Npn \clist_reverse:N #1
8717 { \__kernel_tl_set:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
8718 \cs_new_protected:Npn \clist_greverse:N #1
8719 { \__kernel_tl_gset:Nx #1 { \exp_args:No \clist_reverse:n {#1} } }
8720 \cs_generate_variant:Nn \clist_reverse:N { c }
8721 \cs_generate_variant:Nn \clist_greverse:N { c }
8722 \cs_new:Npn \clist_reverse:n #1
8723 {
8724 \__clist_reverse:wwNww ? #1 ,
8725 \s__clist_mark \__clist_reverse:wwNww ! ,
8726 \s__clist_mark \__clist_reverse_end:ww
8727 \s__clist_stop ? \s__clist_mark
8728 }
8729 \cs_new:Npn \__clist_reverse:wwNww
8730 #1 , #2 \s__clist_mark #3 #4 \s__clist_stop ? #5 \s__clist_mark
8731 { #3 ? #2 \s__clist_mark #3 #4 \s__clist_stop #1 , #5 \s__clist_mark }
8732 \cs_new:Npn \__clist_reverse_end:ww #1 ! #2 , \s__clist_mark
8733 { \exp_not:o { \use_none:n #2 } }
8734 \prg_new_eq_conditional:NNn \clist_if_empty:N \tl_if_empty:N
8735 { p , T , F , TF }
8736 \prg_new_eq_conditional:NNn \clist_if_empty:c \tl_if_empty:c
8737 { p , T , F , TF }
8738 \prg_new_conditional:Npnn \clist_if_empty:n #1 { p , T , F , TF }
8739 {
8740 \__clist_if_empty_n:w ? #1
8741 , \s__clist_mark \prg_return_false:
8742 , \s__clist_mark \prg_return_true:
8743 \s__clist_stop
8744 }
8745 \cs_new:Npn \__clist_if_empty_n:w #1 ,
8746 {
8747 \tl_if_empty:oTF { \use_none:nn #1 ? }
8748 { \__clist_if_empty_n:w ? }
8749 { \__clist_if_empty_n:wNw }
8750 }
8751 \cs_new:Npn \__clist_if_empty_n:wNw #1 \s__clist_mark #2#3 \s__clist_stop {#2}
8752 \prg_new_protected_conditional:Npnn \clist_if_in:Nn #1#2 { T , F , TF }
8753 {
8754 \exp_args:No \__clist_if_in_return:nnN #1 {#2} #1
8755 }
8756 \prg_new_protected_conditional:Npnn \clist_if_in:nn #1#2 { T , F , TF }
8757 {
8758 \clist_set:Nn \l__clist_tmp_clist {#1}
8759 \exp_args:No \__clist_if_in_return:nnN \l__clist_tmp_clist {#2}
8760 \l__clist_tmp_clist
8761 }
8762 \cs_new_protected:Npn \__clist_if_in_return:nnN #1#2#3
8763 {
8764 \__clist_if_wrap:nTF {#2}
8765 {
8766 \cs_set:Npe \__clist_tmp:w ##1
8767 {
8768 \exp_not:N \tl_if_eq:nnT {##1}
8769 \exp_not:n
8770 {
8771 {#2}
8772 { \clist_map_break:n { \prg_return_true: \use_none:n } }
8773 }
8774 }
8775 \clist_map_function:NN #3 \__clist_tmp:w
8776 \prg_return_false:
8777 }
8778 {
8779 \cs_set:Npn \__clist_tmp:w ##1 ,#2, { }
8780 \tl_if_empty:oTF
8781 { \__clist_tmp:w ,#1, {} {} ,#2, }
8782 { \prg_return_false: } { \prg_return_true: }
8783 }
8784 }
8785 \prg_generate_conditional_variant:Nnn \clist_if_in:Nn
8786 { NV , No , Ne , c , cV , co , ce } { T , F , TF }
8787 \prg_generate_conditional_variant:Nnn \clist_if_in:nn
8788 { nV , no , ne } { T , F , TF }
8789 \cs_new:Npn \clist_map_function:NN #1#2
8790 {
8791 \clist_if_empty:NF #1
8792 {
8793 \exp_after:wN \__clist_map_function:Nw \exp_after:wN #2 #1 ,
8794 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8795 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8796 \prg_break_point:Nn \clist_map_break: { }
8797 }
8798 }
8799 \cs_new:Npn \__clist_map_function:Nw #1 #2, #3, #4, #5, #6, #7, #8, #9,
8800 {
8801 \__clist_use_none_delimit_by_s_stop:w
8802 #9 \__clist_map_function_end:w \s__clist_stop
8803 #1 {#2} #1 {#3} #1 {#4} #1 {#5} #1 {#6} #1 {#7} #1 {#8} #1 {#9}
8804 \__clist_map_function:Nw #1
8805 }
8806 \cs_new:Npn \__clist_map_function_end:w \s__clist_stop #1#2
8807 {
8808 \__clist_use_none_delimit_by_s_stop:w #2 \clist_map_break: \s__clist_stop
8809 #1 {#2}
8810 \__clist_map_function_end:w \s__clist_stop
8811 }
8812 \cs_generate_variant:Nn \clist_map_function:NN { c }
8813 \cs_new:Npn \clist_map_function:nN #1#2
8814 {
8815 \exp_after:wN \__clist_map_function_n:Nn \exp_after:wN #2
8816 \exp:w \__clist_trim_next:w \prg_do_nothing: #1 ,
8817 \s__clist_stop \clist_map_break: ,
8818 \prg_break_point:Nn \clist_map_break: { }
8819 }
8820 \cs_generate_variant:Nn \clist_map_function:nN { e }
8821 \cs_new:Npn \__clist_map_function_n:Nn #1 #2
8822 {
8823 \__clist_use_none_delimit_by_s_stop:w #2 \s__clist_stop
8824 \__clist_map_unbrace:wn #2 , #1
8825 \exp_after:wN \__clist_map_function_n:Nn \exp_after:wN #1
8826 \exp:w \__clist_trim_next:w \prg_do_nothing:
8827 }
8828 \cs_new:Npn \__clist_map_unbrace:wn #1, #2 { #2 {#1} }
8829 \cs_new_protected:Npn \clist_map_inline:Nn #1#2
8830 {
8831 \clist_if_empty:NF #1
8832 {
8833 \int_gincr:N \g__kernel_prg_map_int
8834 \cs_gset_protected:cpn
8835 { __clist_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
8836 \exp_last_unbraced:Nco \__clist_map_function:Nw
8837 { __clist_map_ \int_use:N \g__kernel_prg_map_int :w }
8838 #1 ,
8839 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8840 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8841 \prg_break_point:Nn \clist_map_break:
8842 { \int_gdecr:N \g__kernel_prg_map_int }
8843 }
8844 }
8845 \cs_new_protected:Npn \clist_map_inline:nn #1
8846 {
8847 \clist_set:Nn \l__clist_tmp_clist {#1}
8848 \clist_map_inline:Nn \l__clist_tmp_clist
8849 }
8850 \cs_generate_variant:Nn \clist_map_inline:Nn { c }
8851 \cs_new_protected:Npn \clist_map_variable:NNn #1#2#3
8852 { \clist_map_tokens:Nn #1 { \__clist_map_variable:Nnn #2 {#3} } }
8853 \cs_generate_variant:Nn \clist_map_variable:NNn { c }
8854 \cs_new_protected:Npn \__clist_map_variable:Nnn #1#2#3
8855 { \tl_set:Nn #1 {#3} #2 }
8856 \cs_new_protected:Npn \clist_map_variable:nNn #1
8857 {
8858 \clist_set:Nn \l__clist_tmp_clist {#1}
8859 \clist_map_variable:NNn \l__clist_tmp_clist
8860 }
8861 \cs_new:Npn \clist_map_tokens:Nn #1#2
8862 {
8863 \clist_if_empty:NF #1
8864 {
8865 \exp_last_unbraced:Nno \__clist_map_tokens:nw {#2} #1 ,
8866 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8867 \s__clist_stop , \s__clist_stop , \s__clist_stop , \s__clist_stop ,
8868 \prg_break_point:Nn \clist_map_break: { }
8869 }
8870 }
8871 \cs_new:Npn \__clist_map_tokens:nw #1 #2, #3, #4, #5, #6, #7, #8, #9,
8872 {
8873 \__clist_use_none_delimit_by_s_stop:w
8874 #9 \__clist_map_tokens_end:w \s__clist_stop
8875 \use:n {#1} {#2} \use:n {#1} {#3} \use:n {#1} {#4} \use:n {#1} {#5}
8876 \use:n {#1} {#6} \use:n {#1} {#7} \use:n {#1} {#8} \use:n {#1} {#9}
8877 \__clist_map_tokens:nw {#1}
8878 }
8879 \cs_new:Npn \__clist_map_tokens_end:w \s__clist_stop \use:n #1#2
8880 {
8881 \__clist_use_none_delimit_by_s_stop:w #2 \clist_map_break: \s__clist_stop
8882 #1 {#2}
8883 \__clist_map_tokens_end:w \s__clist_stop
8884 }
8885 \cs_generate_variant:Nn \clist_map_tokens:Nn { c }
8886 \cs_new:Npn \clist_map_tokens:nn #1#2
8887 {
8888 \__clist_map_tokens_n:nw {#2}
8889 \prg_do_nothing: #1 , \s__clist_stop \clist_map_break: ,
8890 \prg_break_point:Nn \clist_map_break: { }
8891 }
8892 \cs_new:Npn \__clist_map_tokens_n:nw #1#2 ,
8893 {
8894 \tl_if_empty:oF { \use_none:nn #2 ? }
8895 {
8896 \__clist_use_none_delimit_by_s_stop:w #2 \s__clist_stop
8897 \tl_trim_spaces_apply:oN {#2} \use_ii_i:nn
8898 \__clist_map_unbrace:wn , {#1}
8899 }
8900 \__clist_map_tokens_n:nw {#1} \prg_do_nothing:
8901 }
8902 \cs_new:Npn \clist_map_break:
8903 { \prg_map_break:Nn \clist_map_break: { } }
8904 \cs_new:Npn \clist_map_break:n
8905 { \prg_map_break:Nn \clist_map_break: }
8906 \cs_new:Npn \clist_count:N #1
8907 {
8908 \int_eval:n
8909 {
8910 0
8911 \clist_map_function:NN #1 \__clist_count:n
8912 }
8913 }
8914 \cs_generate_variant:Nn \clist_count:N { c }
8915 \cs_new:Npn \__clist_count:n #1 { + 1 }
8916 \cs_set_protected:Npn \__clist_tmp:w #1
8917 {
8918 \cs_new:Npn \clist_count:n ##1
8919 {
8920 \int_eval:n
8921 {
8922 0
8923 \__clist_count:w #1
8924 ##1 , \s__clist_stop \prg_break: , \prg_break_point:
8925 }
8926 }
8927 \cs_new:Npn \__clist_count:w ##1 ,
8928 {
8929 \__clist_use_none_delimit_by_s_stop:w ##1 \s__clist_stop
8930 \tl_if_blank:nF {##1} { + 1 }
8931 \__clist_count:w #1
8932 }
8933 }
8934 \exp_args:No \__clist_tmp:w \c_space_tl
8935 \cs_generate_variant:Nn \clist_count:n { e }
8936 \cs_new:Npn \clist_use:Nnnn #1#2#3#4
8937 {
8938 \clist_if_exist:NTF #1
8939 {
8940 \int_case:nnF { \clist_count:N #1 }
8941 {
8942 { 0 } { }
8943 { 1 } { \exp_after:wN \__clist_use:wwn #1 , , { } }
8944 { 2 } { \exp_after:wN \__clist_use:wwn #1 , {#2} }
8945 }
8946 {
8947 \exp_after:wN \__clist_use:nwwwwnwn
8948 \exp_after:wN { \exp_after:wN } #1 ,
8949 \s__clist_mark , { \__clist_use:nwwwwnwn {#3} }
8950 \s__clist_mark , { \__clist_use:nwwn {#4} }
8951 \s__clist_stop { }
8952 }
8953 }
8954 {
8955 \msg_expandable_error:nnn
8956 { kernel } { bad-variable } {#1}
8957 }
8958 }
8959 \cs_generate_variant:Nn \clist_use:Nnnn { c }
8960 \cs_new:Npn \__clist_use:wwn #1 , #2 , #3 { \exp_not:n { #1 #3 #2 } }
8961 \cs_new:Npn \__clist_use:nwwwwnwn
8962 #1#2 , #3 , #4 , #5 \s__clist_mark , #6#7 \s__clist_stop #8
8963 { #6 {#3} , {#4} , #5 \s__clist_mark , {#6} #7 \s__clist_stop { #8 #1 #2 } }
8964 \cs_new:Npn \__clist_use:nwwn #1#2 , #3 \s__clist_stop #4
8965 { \exp_not:n { #4 #1 #2 } }
8966 \cs_new:Npn \clist_use:Nn #1#2
8967 { \clist_use:Nnnn #1 {#2} {#2} {#2} }
8968 \cs_generate_variant:Nn \clist_use:Nn { c }
8969 \cs_new_eq:NN \clist_use:N \tl_use:N
8970 \cs_generate_variant:Nn \clist_use:N { c }
8971 \cs_new:Npn \clist_use:nnnn #1#2#3#4
8972 {
8973 \__clist_use:Nw \__clist_use_none_delimit_by_s_stop:w
8974 \__clist_use:Nw \__clist_use_one:w
8975 \__clist_use:Nw \__clist_use_end:w
8976 \__clist_use_more:w ;
8977 {#2} {#3} {#4} ;
8978 \prg_do_nothing: #1 , \s__clist_mark ,
8979 \s__clist_stop
8980 }
8981 \cs_new:Npn \__clist_use:Nw #1#2 ; #3 ; #4 ,
8982 {
8983 \tl_if_empty:oTF { \use_none:nn #4 ? }
8984 { \__clist_use:Nw #1#2 ; }
8985 {
8986 \__clist_use_none_delimit_by_s_mark:w #4 #1 \s__clist_mark
8987 \tl_trim_spaces_apply:oN {#4} \use_ii_i:nn
8988 \__clist_map_unbrace:wn , { #2 ; }
8989 }
8990 #3 ; \prg_do_nothing:
8991 }
8992 \cs_new:Npn \__clist_use_one:w \s__clist_mark #1 , #2#3#4 \s__clist_stop
8993 { \exp_not:n {#3} }
8994 \cs_new:Npn \__clist_use_end:w
8995 \s__clist_mark #1 , #2#3#4#5#6 \s__clist_stop
8996 { \exp_not:n { #4 #5 #3 } }
8997 \cs_new:Npn \__clist_use_more:w ; #1#2#3#4#5#6 ;
8998 {
8999 \exp_not:n { #3 #5 }
9000 \__clist_use:Nw \__clist_use_end:w \__clist_use_more:w ;
9001 {#1} {#2} {#6} {#5} {#6} ;
9002 }
9003 \cs_new:Npn \clist_use:nn #1#2 { \clist_use:nnnn {#1} {#2} {#2} {#2} }
9004 \cs_new:Npn \clist_item:Nn #1#2
9005 {
9006 \__clist_item:ffoN
9007 { \clist_count:N #1 }
9008 { \int_eval:n {#2} }
9009 #1
9010 \__clist_item_N_loop:nw
9011 }
9012 \cs_new:Npn \__clist_item:nnnN #1#2#3#4
9013 {
9014 \int_compare:nNnTF {#2} < 0
9015 {
9016 \int_compare:nNnTF {#2} < { - #1 }
9017 { \__clist_use_none_delimit_by_s_stop:w }
9018 { \exp_args:Nf #4 { \int_eval:n { #2 + 1 + #1 } } }
9019 }
9020 {
9021 \int_compare:nNnTF {#2} > {#1}
9022 { \__clist_use_none_delimit_by_s_stop:w }
9023 { #4 {#2} }
9024 }
9025 { } , #3 , \s__clist_stop
9026 }
9027 \cs_generate_variant:Nn \__clist_item:nnnN { ffo, ff }
9028 \cs_new:Npn \__clist_item_N_loop:nw #1 #2,
9029 {
9030 \int_compare:nNnTF {#1} = 0
9031 { \__clist_use_i_delimit_by_s_stop:nw { \exp_not:n {#2} } }
9032 { \exp_args:Nf \__clist_item_N_loop:nw { \int_eval:n { #1 - 1 } } }
9033 }
9034 \cs_generate_variant:Nn \clist_item:Nn { c }
9035 \cs_new:Npn \clist_item:nn #1#2
9036 {
9037 \__clist_item:ffnN
9038 { \clist_count:n {#1} }
9039 { \int_eval:n {#2} }
9040 {#1}
9041 \__clist_item_n:nw
9042 }
9043 \cs_generate_variant:Nn \clist_item:nn { V , v , o , e }
9044 \cs_new:Npn \__clist_item_n:nw #1
9045 { \__clist_item_n_loop:nw {#1} \prg_do_nothing: }
9046 \cs_new:Npn \__clist_item_n_loop:nw #1 #2,
9047 {
9048 \exp_args:No \tl_if_blank:nTF {#2}
9049 { \__clist_item_n_loop:nw {#1} \prg_do_nothing: }
9050 {
9051 \int_compare:nNnTF {#1} = 0
9052 { \exp_args:No \__clist_item_n_end:n {#2} }
9053 {
9054 \exp_args:Nf \__clist_item_n_loop:nw
9055 { \int_eval:n { #1 - 1 } }
9056 \prg_do_nothing:
9057 }
9058 }
9059 }
9060 \cs_new:Npn \__clist_item_n_end:n #1 #2 \s__clist_stop
9061 { \tl_trim_spaces_apply:nN {#1} \__clist_item_n_strip:n }
9062 \cs_new:Npn \__clist_item_n_strip:n #1 { \__clist_item_n_strip:w #1 , }
9063 \cs_new:Npn \__clist_item_n_strip:w #1 , { \exp_not:n {#1} }
9064 \cs_new:Npn \clist_rand_item:n #1
9065 { \exp_args:Nf \__clist_rand_item:nn { \clist_count:n {#1} } {#1} }
9066 \cs_new:Npn \__clist_rand_item:nn #1#2
9067 {
9068 \int_compare:nNnF {#1} = 0
9069 { \clist_item:nn {#2} { \int_rand:nn { 1 } {#1} } }
9070 }
9071 \cs_new:Npn \clist_rand_item:N #1
9072 {
9073 \clist_if_empty:NF #1
9074 { \clist_item:Nn #1 { \int_rand:nn { 1 } { \clist_count:N #1 } } }
9075 }
9076 \cs_generate_variant:Nn \clist_rand_item:N { c }
9077 \cs_new_protected:Npn \clist_show:N { \__clist_show:NN \msg_show:nneeee }
9078 \cs_generate_variant:Nn \clist_show:N { c }
9079 \cs_new_protected:Npn \clist_log:N { \__clist_show:NN \msg_log:nneeee }
9080 \cs_generate_variant:Nn \clist_log:N { c }
9081 \cs_new_protected:Npn \__clist_show:NN #1#2
9082 {
9083 \__kernel_chk_tl_type:NnnT #2 { clist } { \exp_not:o #2 }
9084 {
9085 \int_compare:nNnTF { \clist_count:N #2 }
9086 = { \exp_args:No \clist_count:n #2 }
9087 {
9088 #1 { clist } { show }
9089 { \token_to_str:N #2 }
9090 { \clist_map_function:NN #2 \msg_show_item:n }
9091 { } { }
9092 }
9093 {
9094 \msg_error:nnee { clist } { non-clist }
9095 { \token_to_str:N #2 } { \tl_to_str:N #2 }
9096 }
9097 }
9098 }
9099 \cs_new_protected:Npn \clist_show:n { \__clist_show:Nn \msg_show:nneeee }
9100 \cs_new_protected:Npn \clist_log:n { \__clist_show:Nn \msg_log:nneeee }
9101 \cs_new_protected:Npn \__clist_show:Nn #1#2
9102 {
9103 #1 { clist } { show }
9104 { } { \clist_map_function:nN {#2} \msg_show_item:n } { } { }
9105 }
9106 \clist_new:N \l_tmpa_clist
9107 \clist_new:N \l_tmpb_clist
9108 \clist_new:N \g_tmpa_clist
9109 \clist_new:N \g_tmpb_clist
9110 %% File: l3token.dtx
9111 \scan_new:N \s__char_stop
9112 \quark_new:N \q__char_no_value
9113 \__kernel_quark_new_conditional:Nn \__char_quark_if_no_value:N { TF }
9114 \cs_new_protected:Npn \char_set_catcode:nn #1#2
9115 { \tex_catcode:D \int_eval:n {#1} = \int_eval:n {#2} \exp_stop_f: }
9116 \cs_new:Npn \char_value_catcode:n #1
9117 { \tex_the:D \tex_catcode:D \int_eval:n {#1} \exp_stop_f: }
9118 \cs_new_protected:Npn \char_show_value_catcode:n #1
9119 { \exp_args:Nf \tl_show:n { \char_value_catcode:n {#1} } }
9120 \cs_new_protected:Npn \char_set_catcode_escape:N #1
9121 { \char_set_catcode:nn { `#1 } { 0 } }
9122 \cs_new_protected:Npn \char_set_catcode_group_begin:N #1
9123 { \char_set_catcode:nn { `#1 } { 1 } }
9124 \cs_new_protected:Npn \char_set_catcode_group_end:N #1
9125 { \char_set_catcode:nn { `#1 } { 2 } }
9126 \cs_new_protected:Npn \char_set_catcode_math_toggle:N #1
9127 { \char_set_catcode:nn { `#1 } { 3 } }
9128 \cs_new_protected:Npn \char_set_catcode_alignment:N #1
9129 { \char_set_catcode:nn { `#1 } { 4 } }
9130 \cs_new_protected:Npn \char_set_catcode_end_line:N #1
9131 { \char_set_catcode:nn { `#1 } { 5 } }
9132 \cs_new_protected:Npn \char_set_catcode_parameter:N #1
9133 { \char_set_catcode:nn { `#1 } { 6 } }
9134 \cs_new_protected:Npn \char_set_catcode_math_superscript:N #1
9135 { \char_set_catcode:nn { `#1 } { 7 } }
9136 \cs_new_protected:Npn \char_set_catcode_math_subscript:N #1
9137 { \char_set_catcode:nn { `#1 } { 8 } }
9138 \cs_new_protected:Npn \char_set_catcode_ignore:N #1
9139 { \char_set_catcode:nn { `#1 } { 9 } }
9140 \cs_new_protected:Npn \char_set_catcode_space:N #1
9141 { \char_set_catcode:nn { `#1 } { 10 } }
9142 \cs_new_protected:Npn \char_set_catcode_letter:N #1
9143 { \char_set_catcode:nn { `#1 } { 11 } }
9144 \cs_new_protected:Npn \char_set_catcode_other:N #1
9145 { \char_set_catcode:nn { `#1 } { 12 } }
9146 \cs_new_protected:Npn \char_set_catcode_active:N #1
9147 { \char_set_catcode:nn { `#1 } { 13 } }
9148 \cs_new_protected:Npn \char_set_catcode_comment:N #1
9149 { \char_set_catcode:nn { `#1 } { 14 } }
9150 \cs_new_protected:Npn \char_set_catcode_invalid:N #1
9151 { \char_set_catcode:nn { `#1 } { 15 } }
9152 \cs_new_protected:Npn \char_set_catcode_escape:n #1
9153 { \char_set_catcode:nn {#1} { 0 } }
9154 \cs_new_protected:Npn \char_set_catcode_group_begin:n #1
9155 { \char_set_catcode:nn {#1} { 1 } }
9156 \cs_new_protected:Npn \char_set_catcode_group_end:n #1
9157 { \char_set_catcode:nn {#1} { 2 } }
9158 \cs_new_protected:Npn \char_set_catcode_math_toggle:n #1
9159 { \char_set_catcode:nn {#1} { 3 } }
9160 \cs_new_protected:Npn \char_set_catcode_alignment:n #1
9161 { \char_set_catcode:nn {#1} { 4 } }
9162 \cs_new_protected:Npn \char_set_catcode_end_line:n #1
9163 { \char_set_catcode:nn {#1} { 5 } }
9164 \cs_new_protected:Npn \char_set_catcode_parameter:n #1
9165 { \char_set_catcode:nn {#1} { 6 } }
9166 \cs_new_protected:Npn \char_set_catcode_math_superscript:n #1
9167 { \char_set_catcode:nn {#1} { 7 } }
9168 \cs_new_protected:Npn \char_set_catcode_math_subscript:n #1
9169 { \char_set_catcode:nn {#1} { 8 } }
9170 \cs_new_protected:Npn \char_set_catcode_ignore:n #1
9171 { \char_set_catcode:nn {#1} { 9 } }
9172 \cs_new_protected:Npn \char_set_catcode_space:n #1
9173 { \char_set_catcode:nn {#1} { 10 } }
9174 \cs_new_protected:Npn \char_set_catcode_letter:n #1
9175 { \char_set_catcode:nn {#1} { 11 } }
9176 \cs_new_protected:Npn \char_set_catcode_other:n #1
9177 { \char_set_catcode:nn {#1} { 12 } }
9178 \cs_new_protected:Npn \char_set_catcode_active:n #1
9179 { \char_set_catcode:nn {#1} { 13 } }
9180 \cs_new_protected:Npn \char_set_catcode_comment:n #1
9181 { \char_set_catcode:nn {#1} { 14 } }
9182 \cs_new_protected:Npn \char_set_catcode_invalid:n #1
9183 { \char_set_catcode:nn {#1} { 15 } }
9184 \cs_new_protected:Npn \char_set_mathcode:nn #1#2
9185 { \tex_mathcode:D \int_eval:n {#1} = \int_eval:n {#2} \exp_stop_f: }
9186 \cs_new:Npn \char_value_mathcode:n #1
9187 { \tex_the:D \tex_mathcode:D \int_eval:n {#1} \exp_stop_f: }
9188 \cs_new_protected:Npn \char_show_value_mathcode:n #1
9189 { \exp_args:Nf \tl_show:n { \char_value_mathcode:n {#1} } }
9190 \cs_new_protected:Npn \char_set_lccode:nn #1#2
9191 { \tex_lccode:D \int_eval:n {#1} = \int_eval:n {#2} \exp_stop_f: }
9192 \cs_new:Npn \char_value_lccode:n #1
9193 { \tex_the:D \tex_lccode:D \int_eval:n {#1} \exp_stop_f: }
9194 \cs_new_protected:Npn \char_show_value_lccode:n #1
9195 { \exp_args:Nf \tl_show:n { \char_value_lccode:n {#1} } }
9196 \cs_new_protected:Npn \char_set_uccode:nn #1#2
9197 { \tex_uccode:D \int_eval:n {#1} = \int_eval:n {#2} \exp_stop_f: }
9198 \cs_new:Npn \char_value_uccode:n #1
9199 { \tex_the:D \tex_uccode:D \int_eval:n {#1} \exp_stop_f: }
9200 \cs_new_protected:Npn \char_show_value_uccode:n #1
9201 { \exp_args:Nf \tl_show:n { \char_value_uccode:n {#1} } }
9202 \cs_new_protected:Npn \char_set_sfcode:nn #1#2
9203 { \tex_sfcode:D \int_eval:n {#1} = \int_eval:n {#2} \exp_stop_f: }
9204 \cs_new:Npn \char_value_sfcode:n #1
9205 { \tex_the:D \tex_sfcode:D \int_eval:n {#1} \exp_stop_f: }
9206 \cs_new_protected:Npn \char_show_value_sfcode:n #1
9207 { \exp_args:Nf \tl_show:n { \char_value_sfcode:n {#1} } }
9208 \seq_new:N \l_char_special_seq
9209 \seq_set_split:Nnn \l_char_special_seq { }
9210 { \ \" \# \$ \% \& \\ \^ \_ \{ \} \~ }
9211 \seq_new:N \l_char_active_seq
9212 \seq_set_split:Nnn \l_char_active_seq { }
9213 { \" \$ \& \^ \_ \~ }
9214 \group_begin:
9215 \char_set_catcode_active:N \^^@
9216 \cs_set_protected:Npn \__char_tmp:nN #1#2
9217 {
9218 \cs_new_protected:cpn { #1 :nN } ##1
9219 {
9220 \group_begin:
9221 \char_set_lccode:nn { `\^^@ } { ##1 }
9222 \tex_lowercase:D { \group_end: #2 ^^@ }
9223 }
9224 \cs_new_protected:cpe { #1 :NN } ##1
9225 { \exp_not:c { #1 : nN } { `##1 } }
9226 }
9227 \__char_tmp:nN { char_set_active_eq } \cs_set_eq:NN
9228 \__char_tmp:nN { char_gset_active_eq } \cs_gset_eq:NN
9229 \group_end:
9230 \cs_generate_variant:Nn \char_set_active_eq:NN { Nc }
9231 \cs_generate_variant:Nn \char_gset_active_eq:NN { Nc }
9232 \cs_generate_variant:Nn \char_set_active_eq:nN { nc }
9233 \cs_generate_variant:Nn \char_gset_active_eq:nN { nc }
9234 \cs_new_eq:NN \__char_int_to_roman:w \tex_romannumeral:D
9235 \cs_new_eq:NN \__char_sep: \__kernel_int_sep:
9236 \cs_new:Npn \char_generate:nn #1#2
9237 {
9238 \exp:w \exp_after:wN \__char_generate_aux:w
9239 \int_value:w \int_eval:n {#1} \exp_after:wN \__char_sep:
9240 \int_value:w \int_eval:n {#2} \__char_sep:
9241 }
9242 \cs_new:Npn \__char_generate_aux:w #1 \__char_sep: #2 \__char_sep:
9243 {
9244 \if_int_odd:w 0
9245 \if_int_compare:w #2 < 1 \exp_stop_f: 1 \fi:
9246 \if_int_compare:w #2 = 5 \exp_stop_f: 1 \fi:
9247 \if_int_compare:w #2 = 9 \exp_stop_f: 1 \fi:
9248 \if_int_compare:w #2 > 13 \exp_stop_f: 1 \fi: \exp_stop_f:
9249 \msg_expandable_error:nn { char }
9250 { invalid-catcode }
9251 \else:
9252 \if_int_odd:w 0
9253 \if_int_compare:w #1 < \c_zero_int 1 \fi:
9254 \if_int_compare:w #1 > \c_max_char_int 1 \fi: \exp_stop_f:
9255 \msg_expandable_error:nn { char }
9256 { out-of-range }
9257 \else:
9258 \if_int_compare:w #2#1 = 100 \exp_stop_f:
9259 \msg_expandable_error:nn { char } { null-space }
9260 \else:
9261 \__char_generate_aux:nnw {#1} {#2}
9262 \fi:
9263 \fi:
9264 \fi:
9265 \exp_end:
9266 }
9267 \tl_new:N \l__char_tmp_tl
9268 \group_begin:
9269 \char_set_catcode_active:N \^^L
9270 \cs_set:Npn ^^L { }
9271 \if_cs_exist:N \tex_Ucharcat:D
9272 \cs_new:Npn \__char_generate_aux:nnw #1#2#3 \exp_end:
9273 {
9274 #3
9275 \exp_after:wN \exp_end:
9276 \tex_Ucharcat:D #1 \exp_stop_f: #2 \exp_stop_f:
9277 }
9278 \else:
9279 \char_set_catcode_active:n { 0 }
9280 \tl_set:Nn \l__char_tmp_tl { \exp_not:N ^^@ \exp_not:N \or: }
9281 \char_set_catcode_other:n { 0 }
9282 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9283 \char_set_catcode_letter:n { 0 }
9284 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9285 \tl_put_right:Nn \l__char_tmp_tl { \use:n { ~ } \exp_not:N \or: }
9286 \tl_put_right:Nn \l__char_tmp_tl { \exp_not:N \or: }
9287 \char_set_catcode_math_subscript:n { 0 }
9288 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9289 \char_set_catcode_math_superscript:n { 0 }
9290 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9291 \char_set_catcode_parameter:n { 0 }
9292 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9293 \tl_put_right:Nn \l__char_tmp_tl { { \if_false: } \fi: \exp_not:N \or: }
9294 \char_set_catcode_alignment:n { 0 }
9295 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9296 \char_set_catcode_math_toggle:n { 0 }
9297 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: }
9298 \char_set_catcode_group_end:n { 0 }
9299 \tl_put_right:Nn \l__char_tmp_tl { \if_false: { \fi: ^^@ \exp_not:N \or: } % }
9300 \char_set_catcode_group_begin:n { 0 } % {
9301 \tl_put_right:Nn \l__char_tmp_tl { ^^@ \exp_not:N \or: } }
9302 \cs_set_protected:Npn \__char_tmp:n #1
9303 {
9304 \char_set_lccode:nn { 0 } {#1}
9305 \char_set_lccode:nn { 32 } {#1}
9306 \exp_args:Ne \tex_lowercase:D
9307 {
9308 \tl_const:Ne
9309 \exp_not:c { c__char_ \__char_int_to_roman:w #1 _tl }
9310 { \exp_not:o \l__char_tmp_tl }
9311 }
9312 }
9313 \int_step_function:nnN { 0 } { 255 } \__char_tmp:n
9314 \cs_new:Npn \__char_generate_aux:nnw #1#2#3 \exp_end:
9315 {
9316 #3
9317 \if_false: { \fi:
9318 \exp_after:wN \exp_after:wN \exp_after:wN \exp_end:
9319 \exp_after:wN \exp_after:wN
9320 \if_case:w \tex_numexpr:D 13 - #2
9321 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN
9322 \exp_after:wN \exp_after:wN \exp_after:wN \scan_stop:
9323 \exp_after:wN \exp_after:wN \exp_after:wN \exp_not:N
9324 \cs:w c__char_ \__char_int_to_roman:w #1 _tl \cs_end:
9325 }
9326 \fi:
9327 }
9328 \fi:
9329 \group_end:
9330 \group_begin:
9331 \char_set_catcode_active:N *
9332 \char_set_lccode:nn { `* } { `\ }
9333 \tex_lowercase:D { \tl_const:Nn \c_catcode_active_space_tl { * } }
9334 \group_end:
9335 \tl_const:Ne \c_catcode_other_space_tl { \char_generate:nn { `\ } { 12 } }
9336 \scan_new:N \s__token_mark
9337 \scan_new:N \s__token_stop
9338 \cs_new:Npn \token_to_catcode:N
9339 { \int_value:w \group_align_safe_begin: \__token_to_catcode:N }
9340 \cs_new:Npn \__token_to_catcode:N #1
9341 {
9342 \if_catcode:w \exp_not:N #1 \c_catcode_letter_token
9343 11
9344 \else:
9345 \if_catcode:w \exp_not:N #1 \c_catcode_other_token
9346 12
9347 \else:
9348 \if_catcode:w \exp_not:N #1 \c_math_toggle_token
9349 3
9350 \else:
9351 \if_catcode:w \exp_not:N #1 \c_alignment_token
9352 4
9353 \else:
9354 \if_catcode:w \exp_not:N #1 ##
9355 6
9356 \else:
9357 \if_catcode:w \exp_not:N #1 \c_math_superscript_token
9358 7
9359 \else:
9360 \if_catcode:w \exp_not:N #1 \c_math_subscript_token
9361 8
9362 \else:
9363 \if_catcode:w \exp_not:N #1 \c_group_begin_token
9364 1
9365 \else:
9366 \if_catcode:w \exp_not:N #1 \c_group_end_token
9367 2
9368 \else:
9369 \if_catcode:w \exp_not:N #1 \c_space_token
9370 10
9371 \else:
9372 \token_if_cs:NTF #1 { 16 } { 13 }
9373 \fi:
9374 \fi:
9375 \fi:
9376 \fi:
9377 \fi:
9378 \fi:
9379 \fi:
9380 \fi:
9381 \fi:
9382 \fi:
9383 \group_align_safe_end:
9384 \exp_stop_f:
9385 }
9386 \group_begin:
9387 \__kernel_chk_if_free_cs:N \c_group_begin_token
9388 \tex_global:D \tex_let:D \c_group_begin_token {
9389 \__kernel_chk_if_free_cs:N \c_group_end_token
9390 \tex_global:D \tex_let:D \c_group_end_token }
9391 \char_set_catcode_math_toggle:N \*
9392 \cs_new_eq:NN \c_math_toggle_token *
9393 \char_set_catcode_alignment:N \*
9394 \cs_new_eq:NN \c_alignment_token *
9395 \cs_new_eq:NN \c_parameter_token #
9396 \cs_new_eq:NN \c_math_superscript_token ^
9397 \char_set_catcode_math_subscript:N \*
9398 \cs_new_eq:NN \c_math_subscript_token *
9399 \__kernel_chk_if_free_cs:N \c_space_token
9400 \use:n { \tex_global:D \tex_let:D \c_space_token = ~ } ~
9401 \cs_new_eq:NN \c_catcode_letter_token a
9402 \cs_new_eq:NN \c_catcode_other_token 1
9403 \group_end:
9404 \group_begin:
9405 \char_set_catcode_active:N \*
9406 \tl_const:Nn \c__token_active_tl { \exp_not:N * }
9407 \group_end:
9408 \prg_new_conditional:Npnn \token_if_group_begin:N #1 { p , T , F , TF }
9409 {
9410 \if_catcode:w \exp_not:N #1 \c_group_begin_token
9411 \prg_return_true: \else: \prg_return_false: \fi:
9412 }
9413 \prg_new_conditional:Npnn \token_if_group_end:N #1 { p , T , F , TF }
9414 {
9415 \if_catcode:w \exp_not:N #1 \c_group_end_token
9416 \prg_return_true: \else: \prg_return_false: \fi:
9417 }
9418 \prg_new_conditional:Npnn \token_if_math_toggle:N #1 { p , T , F , TF }
9419 {
9420 \if_catcode:w \exp_not:N #1 \c_math_toggle_token
9421 \prg_return_true: \else: \prg_return_false: \fi:
9422 }
9423 \prg_new_conditional:Npnn \token_if_alignment:N #1 { p , T , F , TF }
9424 {
9425 \if_catcode:w \exp_not:N #1 \c_alignment_token
9426 \prg_return_true: \else: \prg_return_false: \fi:
9427 }
9428 \group_begin:
9429 \cs_set_eq:NN \c_parameter_token \scan_stop:
9430 \prg_new_conditional:Npnn \token_if_parameter:N #1 { p , T , F , TF }
9431 {
9432 \if_catcode:w \exp_not:N #1 \c_parameter_token
9433 \prg_return_true: \else: \prg_return_false: \fi:
9434 }
9435 \group_end:
9436 \prg_new_conditional:Npnn \token_if_math_superscript:N #1
9437 { p , T , F , TF }
9438 {
9439 \if_catcode:w \exp_not:N #1 \c_math_superscript_token
9440 \prg_return_true: \else: \prg_return_false: \fi:
9441 }
9442 \prg_new_conditional:Npnn \token_if_math_subscript:N #1 { p , T , F , TF }
9443 {
9444 \if_catcode:w \exp_not:N #1 \c_math_subscript_token
9445 \prg_return_true: \else: \prg_return_false: \fi:
9446 }
9447 \prg_new_conditional:Npnn \token_if_space:N #1 { p , T , F , TF }
9448 {
9449 \if_catcode:w \exp_not:N #1 \c_space_token
9450 \prg_return_true: \else: \prg_return_false: \fi:
9451 }
9452 \prg_new_conditional:Npnn \token_if_letter:N #1 { p , T , F , TF }
9453 {
9454 \if_catcode:w \exp_not:N #1 \c_catcode_letter_token
9455 \prg_return_true: \else: \prg_return_false: \fi:
9456 }
9457 \prg_new_conditional:Npnn \token_if_other:N #1 { p , T , F , TF }
9458 {
9459 \if_catcode:w \exp_not:N #1 \c_catcode_other_token
9460 \prg_return_true: \else: \prg_return_false: \fi:
9461 }
9462 \prg_new_conditional:Npnn \token_if_active:N #1 { p , T , F , TF }
9463 {
9464 \if_catcode:w \exp_not:N #1 \c__token_active_tl
9465 \prg_return_true: \else: \prg_return_false: \fi:
9466 }
9467 \prg_new_eq_conditional:NNn \token_if_eq_meaning:NN \cs_if_eq:NN
9468 { p , T , F , TF }
9469 \prg_new_conditional:Npnn \token_if_eq_catcode:NN #1#2 { p , T , F , TF }
9470 {
9471 \if_catcode:w \exp_not:N #1 \exp_not:N #2
9472 \prg_return_true: \else: \prg_return_false: \fi:
9473 }
9474 \prg_new_conditional:Npnn \token_if_eq_charcode:NN #1#2 { p , T , F , TF }
9475 {
9476 \if_charcode:w \exp_not:N #1 \exp_not:N #2
9477 \prg_return_true: \else: \prg_return_false: \fi:
9478 }
9479 \use:e
9480 {
9481 \prg_new_conditional:Npnn \exp_not:N \token_if_macro:N #1
9482 { p , T , F , TF }
9483 {
9484 \exp_not:N \exp_after:wN \exp_not:N \__token_if_macro_p:w
9485 \exp_not:N \token_to_meaning:N #1 \tl_to_str:n { ma : }
9486 \s__token_stop
9487 }
9488 \cs_new:Npn \exp_not:N \__token_if_macro_p:w
9489 #1 \tl_to_str:n { ma } #2 \c_colon_str #3 \s__token_stop
9490 }
9491 {
9492 \str_if_eq:nnTF { #2 } { cro }
9493 { \prg_return_true: }
9494 { \prg_return_false: }
9495 }
9496 \prg_new_conditional:Npnn \token_if_cs:N #1 { p , T , F , TF }
9497 {
9498 \if_catcode:w \exp_not:N #1 \scan_stop:
9499 \prg_return_true: \else: \prg_return_false: \fi:
9500 }
9501 \prg_new_conditional:Npnn \token_if_expandable:N #1 { p , T , F , TF }
9502 {
9503 \exp_after:wN \if_meaning:w \exp_not:N #1 #1
9504 \prg_return_false:
9505 \else:
9506 \if_cs_exist:N #1
9507 \prg_return_true:
9508 \else:
9509 \prg_return_false:
9510 \fi:
9511 \fi:
9512 }
9513 \group_begin:
9514 \cs_set_protected:Npn \__token_tmp:w #1
9515 {
9516 \use:e
9517 {
9518 \cs_new:Npn \exp_not:c { __token_delimit_by_ #1 :w }
9519 ##1 \tl_to_str:n {#1} ##2 \s__token_stop
9520 { ##1 \tl_to_str:n {#1} }
9521 }
9522 }
9523 \__token_tmp:w { char" }
9524 \__token_tmp:w { count }
9525 \__token_tmp:w { dimen }
9526 \__token_tmp:w { ~ font }
9527 \__token_tmp:w { macro }
9528 \__token_tmp:w { muskip }
9529 \__token_tmp:w { skip }
9530 \__token_tmp:w { toks }
9531 \group_end:
9532 \group_begin:
9533 \cs_set_protected:Npn \__token_tmp:w #1#2#3
9534 {
9535 \use:e
9536 {
9537 \prg_new_conditional:Npnn \exp_not:c { token_if_ #1 :N } ##1
9538 { p , T , F , TF }
9539 {
9540 \cs_if_exist:cT { tex_ #2 :D }
9541 {
9542 \exp_not:N \if_meaning:w ##1 \exp_not:c { tex_ #2 :D }
9543 \exp_not:N \prg_return_false:
9544 \exp_not:N \else:
9545 \exp_not:N \if_meaning:w ##1 \exp_not:c { tex_ #2 def:D }
9546 \exp_not:N \prg_return_false:
9547 \exp_not:N \else:
9548 }
9549 \exp_not:N \str_if_eq:eeTF
9550 {
9551 \exp_not:N \exp_after:wN
9552 \exp_not:c { __token_delimit_by_ #2 :w }
9553 \exp_not:N \token_to_meaning:N ##1
9554 ? \tl_to_str:n {#2} \s__token_stop
9555 }
9556 { \exp_not:n {#3} }
9557 { \exp_not:N \prg_return_true: }
9558 { \exp_not:N \prg_return_false: }
9559 \cs_if_exist:cT { tex_ #2 :D }
9560 {
9561 \exp_not:N \fi:
9562 \exp_not:N \fi:
9563 }
9564 }
9565 }
9566 }
9567 \__token_tmp:w { chardef } { char" } { \token_to_str:N \char" }
9568 \__token_tmp:w { mathchardef } { char" } { \token_to_str:N \mathchar" }
9569 \__token_tmp:w { long_macro } { macro } { \tl_to_str:n { \long } macro }
9570 \__token_tmp:w { protected_macro } { macro }
9571 { \tl_to_str:n { \protected } macro }
9572 \__token_tmp:w { protected_long_macro } { macro }
9573 { \token_to_str:N \protected \tl_to_str:n { \long } macro }
9574 \__token_tmp:w { font_selection } { ~ font } { select ~ font }
9575 \__token_tmp:w { dim_register } { dimen } { \token_to_str:N \dimen }
9576 \__token_tmp:w { int_register } { count } { \token_to_str:N \count }
9577 \__token_tmp:w { muskip_register } { muskip } { \token_to_str:N \muskip }
9578 \__token_tmp:w { skip_register } { skip } { \token_to_str:N \skip }
9579 \__token_tmp:w { toks_register } { toks } { \token_to_str:N \toks }
9580 \group_end:
9581 \prg_new_conditional:Npnn \token_if_control_word:N #1 { p , T , F , TF }
9582 {
9583 \if:w \exp_not:N #1 \token_to_str:N #1
9584 \__token_if_control_word_false:w
9585 \fi:
9586 \if:w 0 \tex_strcmp:D { \exp_not:N #1 } { \token_to_str:N #1 }
9587 \__token_if_control_word_false:w
9588 \fi:
9589 \if_true:
9590 \prg_return_true:
9591 \else:
9592 \prg_return_false:
9593 \fi:
9594 }
9595 \cs_new:Npn \__token_if_control_word_false:w \fi: #1 \if_true: { \fi: \if_false: }
9596 \prg_new_conditional:Npnn \token_if_control_symbol:N #1 { p , T , F , TF }
9597 {
9598 \if_catcode:w \exp_not:N #1 \scan_stop:
9599 \else:
9600 \__token_if_control_symbol_false:w
9601 \fi:
9602 \if:w 0 \tex_strcmp:D { \exp_not:N #1 } { \token_to_str:N #1 }
9603 \prg_return_true:
9604 \else:
9605 \prg_return_false:
9606 \fi:
9607 }
9608 \cs_new:Npn \__token_if_control_symbol_false:w \fi: \if:w 0 \tex_strcmp:D #1#2
9609 { \fi: \if_false: }
9610 \sys_if_engine_luatex:TF
9611 {
9612 \prg_new_conditional:Npnn \token_if_primitive:N #1 { p , T , F , TF }
9613 {
9614 \__token_if_primitive_lua:N #1
9615 }
9616 }
9617 {
9618 \tex_global:D \tex_chardef:D \c__token_A_int = `A ~ %
9619 \use:e
9620 {
9621 \prg_new_conditional:Npnn \exp_not:N \token_if_primitive:N #1
9622 { p , T , F , TF }
9623 {
9624 \exp_not:N \token_if_macro:NTF #1
9625 \exp_not:N \prg_return_false:
9626 {
9627 \exp_not:N \exp_after:wN \exp_not:N \__token_if_primitive:NNw
9628 \exp_not:N \token_to_meaning:N #1
9629 \tl_to_str:n { : : : } \s__token_stop #1
9630 }
9631 }
9632 \cs_new:Npn \exp_not:N \__token_if_primitive:NNw
9633 #1#2 #3 \c_colon_str #4 \s__token_stop
9634 {
9635 \exp_not:N \tl_if_empty:oTF
9636 { \exp_not:N \__token_if_primitive_space:w #3 ~ }
9637 {
9638 \exp_not:N \__token_if_primitive_loop:N #3
9639 \c_colon_str \s__token_stop
9640 }
9641 { \exp_not:N \__token_if_primitive_nullfont:N }
9642 }
9643 }
9644 \cs_new:Npn \__token_if_primitive_space:w #1 ~ { }
9645 \cs_new:Npn \__token_if_primitive_nullfont:N #1
9646 {
9647 \if_meaning:w \tex_nullfont:D #1
9648 \prg_return_true:
9649 \else:
9650 \prg_return_false:
9651 \fi:
9652 }
9653 \cs_new:Npn \__token_if_primitive_loop:N #1
9654 {
9655 \if_int_compare:w `#1 < \c__token_A_int %
9656 \exp_after:wN \__token_if_primitive:Nw
9657 \exp_after:wN #1
9658 \else:
9659 \exp_after:wN \__token_if_primitive_loop:N
9660 \fi:
9661 }
9662 \cs_new:Npn \__token_if_primitive:Nw #1 #2 \s__token_stop
9663 {
9664 \if:w : #1
9665 \exp_after:wN \__token_if_primitive_undefined:N
9666 \else:
9667 \prg_return_false:
9668 \exp_after:wN \use_none:n
9669 \fi:
9670 }
9671 \cs_new:Npn \__token_if_primitive_undefined:N #1
9672 {
9673 \if_cs_exist:N #1
9674 \prg_return_true:
9675 \else:
9676 \prg_return_false:
9677 \fi:
9678 }
9679 }
9680 \cs_new:Npn \token_case_catcode:Nn #1#2
9681 { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} { } { } }
9682 \cs_new:Npn \token_case_catcode:NnT #1#2#3
9683 { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} {#3} { } }
9684 \cs_new:Npn \token_case_catcode:NnF #1#2
9685 { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF #1 {#2} { } }
9686 \cs_new:Npn \token_case_catcode:NnTF
9687 { \exp:w \__token_case:NNnTF \token_if_eq_catcode:NNTF }
9688 \cs_new:Npn \token_case_charcode:Nn #1#2
9689 { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} { } { } }
9690 \cs_new:Npn \token_case_charcode:NnT #1#2#3
9691 { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} {#3} { } }
9692 \cs_new:Npn \token_case_charcode:NnF #1#2
9693 { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF #1 {#2} { } }
9694 \cs_new:Npn \token_case_charcode:NnTF
9695 { \exp:w \__token_case:NNnTF \token_if_eq_charcode:NNTF }
9696 \cs_new:Npn \token_case_meaning:Nn #1#2
9697 { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} { } { } }
9698 \cs_new:Npn \token_case_meaning:NnT #1#2#3
9699 { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} {#3} { } }
9700 \cs_new:Npn \token_case_meaning:NnF #1#2
9701 { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF #1 {#2} { } }
9702 \cs_new:Npn \token_case_meaning:NnTF
9703 { \exp:w \__token_case:NNnTF \token_if_eq_meaning:NNTF }
9704 \cs_new:Npn \__token_case:NNnTF #1#2#3#4#5
9705 {
9706 \__token_case:NNw #1 #2 #3 #2 { }
9707 \s__token_mark {#4}
9708 \s__token_mark {#5}
9709 \s__token_stop
9710 }
9711 \cs_new:Npn \__token_case:NNw #1#2#3#4
9712 {
9713 #1 #2 #3
9714 { \__token_case_end:nw {#4} }
9715 { \__token_case:NNw #1 #2 }
9716 }
9717 \cs_new:Npn \__token_case_end:nw #1#2#3 \s__token_mark #4#5 \s__token_stop
9718 { \exp_end: #1 #4 }
9719 \cs_new_eq:NN \l_peek_token ?
9720 \cs_new_eq:NN \g_peek_token ?
9721 \cs_new_eq:NN \l__peek_search_token ?
9722 \tl_new:N \l__peek_search_tl
9723 \cs_new:Npn \__peek_true:w { }
9724 \cs_new:Npn \__peek_true_aux:w { }
9725 \cs_new:Npn \__peek_false:w { }
9726 \cs_new:Npn \__peek_tmp:w { }
9727 \scan_new:N \s__peek_mark
9728 \scan_new:N \s__peek_stop
9729 \cs_new:Npn \__peek_use_none_delimit_by_s_stop:w #1 \s__peek_stop { }
9730 \cs_new_protected:Npn \peek_after:Nw
9731 { \tex_futurelet:D \l_peek_token }
9732 \cs_new_protected:Npn \peek_gafter:Nw
9733 { \tex_global:D \tex_futurelet:D \g_peek_token }
9734 \cs_new_protected:Npn \__peek_true_remove:w
9735 {
9736 \tex_afterassignment:D \__peek_true_aux:w
9737 \cs_set_eq:NN \__peek_tmp:w
9738 }
9739 \cs_new_protected:Npn \peek_remove_spaces:n #1
9740 {
9741 \cs_set:Npe \__peek_false:w { \exp_not:n {#1} }
9742 \group_align_safe_begin:
9743 \cs_set:Npn \__peek_true_aux:w { \peek_after:Nw \__peek_remove_spaces: }
9744 \__peek_true_aux:w
9745 }
9746 \cs_new_protected:Npn \__peek_remove_spaces:
9747 {
9748 \if_meaning:w \l_peek_token \c_space_token
9749 \exp_after:wN \__peek_true_remove:w
9750 \else:
9751 \group_align_safe_end:
9752 \exp_after:wN \__peek_false:w
9753 \fi:
9754 }
9755 \cs_new_protected:Npn \peek_remove_filler:n #1
9756 {
9757 \cs_set:Npn \__peek_true_aux:w { \__peek_remove_filler:w }
9758 \cs_set:Npe \__peek_false:w
9759 {
9760 \exp_not:N \group_align_safe_end:
9761 \exp_not:n {#1}
9762 }
9763 \group_align_safe_begin:
9764 \__peek_remove_filler:w
9765 }
9766 \cs_new_protected:Npn \__peek_remove_filler:w
9767 {
9768 \exp_after:wN \peek_after:Nw \exp_after:wN \__peek_remove_filler:
9769 \exp:w \exp_end_continue_f:w
9770 }
9771 \cs_new_protected:Npn \__peek_remove_filler:
9772 {
9773 \if_catcode:w \exp_not:N \l_peek_token \c_space_token
9774 \exp_after:wN \__peek_true_remove:w
9775 \else:
9776 \if_meaning:w \l_peek_token \scan_stop:
9777 \exp_after:wN \exp_after:wN \exp_after:wN
9778 \__peek_true_remove:w
9779 \else:
9780 \exp_after:wN \exp_after:wN \exp_after:wN
9781 \__peek_remove_filler_expand:w
9782 \fi:
9783 \fi:
9784 }
9785 \cs_new_protected:Npn \__peek_remove_filler_expand:w
9786 {
9787 \exp_after:wN \if_meaning:w \exp_not:N \l_peek_token \l_peek_token
9788 \exp_after:wN \__peek_false:w
9789 \else:
9790 \exp_after:wN \__peek_remove_filler:w
9791 \fi:
9792 }
9793 \cs_new_protected:Npn \__peek_token_generic_aux:NNNTF #1#2#3#4#5
9794 {
9795 \group_align_safe_begin:
9796 \cs_set_eq:NN \l__peek_search_token #3
9797 \tl_set:Nn \l__peek_search_tl {#3}
9798 \cs_set:Npe \__peek_true_aux:w
9799 {
9800 \exp_not:N \group_align_safe_end:
9801 \exp_not:n {#4}
9802 }
9803 \cs_set_eq:NN \__peek_true:w #1
9804 \cs_set:Npe \__peek_false:w
9805 {
9806 \exp_not:N \group_align_safe_end:
9807 \exp_not:n {#5}
9808 }
9809 \peek_after:Nw #2
9810 }
9811 \cs_new_protected:Npn \__peek_token_generic:NNTF
9812 { \__peek_token_generic_aux:NNNTF \__peek_true_aux:w }
9813 \cs_new_protected:Npn \__peek_token_generic:NNT #1#2#3
9814 { \__peek_token_generic:NNTF #1 #2 {#3} { } }
9815 \cs_new_protected:Npn \__peek_token_generic:NNF #1#2#3
9816 { \__peek_token_generic:NNTF #1 #2 { } {#3} }
9817 \cs_new_protected:Npn \__peek_token_remove_generic:NNTF
9818 { \__peek_token_generic_aux:NNNTF \__peek_true_remove:w }
9819 \cs_new_protected:Npn \__peek_token_remove_generic:NNT #1#2#3
9820 { \__peek_token_remove_generic:NNTF #1 #2 {#3} { } }
9821 \cs_new_protected:Npn \__peek_token_remove_generic:NNF #1#2#3
9822 { \__peek_token_remove_generic:NNTF #1 #2 { } {#3} }
9823 \cs_new:Npn \__peek_execute_branches_meaning:
9824 {
9825 \if_meaning:w \l_peek_token \l__peek_search_token
9826 \exp_after:wN \__peek_true:w
9827 \else:
9828 \exp_after:wN \__peek_false:w
9829 \fi:
9830 }
9831 \cs_new:Npn \__peek_execute_branches_catcode:
9832 { \if_catcode:w \__peek_execute_branches_catcode_aux: }
9833 \cs_new:Npn \__peek_execute_branches_charcode:
9834 { \if_charcode:w \__peek_execute_branches_catcode_aux: }
9835 \cs_new:Npn \__peek_execute_branches_catcode_aux:
9836 {
9837 \if_catcode:w \exp_not:N \l_peek_token \scan_stop:
9838 \exp_after:wN \exp_after:wN
9839 \exp_after:wN \__peek_execute_branches_catcode_auxii:N
9840 \exp_after:wN \exp_not:N
9841 \else:
9842 \exp_after:wN \__peek_execute_branches_catcode_auxiii:
9843 \fi:
9844 }
9845 \cs_new:Npn \__peek_execute_branches_catcode_auxii:N #1
9846 {
9847 \exp_not:N #1
9848 \exp_after:wN \exp_not:N \l__peek_search_tl
9849 \exp_after:wN \__peek_true:w
9850 \else:
9851 \exp_after:wN \__peek_false:w
9852 \fi:
9853 #1
9854 }
9855 \cs_new:Npn \__peek_execute_branches_catcode_auxiii:
9856 {
9857 \exp_not:N \l_peek_token
9858 \exp_after:wN \exp_not:N \l__peek_search_tl
9859 \exp_after:wN \__peek_true:w
9860 \else:
9861 \exp_after:wN \__peek_false:w
9862 \fi:
9863 }
9864 \tl_map_inline:nn { { catcode } { charcode } { meaning } }
9865 {
9866 \tl_map_inline:nn { { } { _remove } }
9867 {
9868 \tl_map_inline:nn { { TF } { T } { F } }
9869 {
9870 \cs_new_protected:cpe { peek_ #1 ##1 :N ####1 }
9871 {
9872 \exp_not:c { __peek_token ##1 _generic:NN ####1 }
9873 \exp_not:c { __peek_execute_branches_ #1 : }
9874 }
9875 }
9876 }
9877 }
9878 \group_begin:
9879 \cs_set_protected:Npn \__peek_tmp:w #1 \s__peek_stop
9880 {
9881 \cs_new_protected:Npn \__peek_execute_branches_N_type:
9882 {
9883 \if_int_odd:w
9884 \if_catcode:w \exp_not:N \l_peek_token { \c_zero_int \fi:
9885 \if_catcode:w \exp_not:N \l_peek_token } \c_zero_int \fi:
9886 \if_meaning:w \l_peek_token \c_space_token \c_zero_int \fi:
9887 \c_one_int
9888 \exp_after:wN \__peek_N_type:w
9889 \token_to_meaning:N \l_peek_token
9890 \s__peek_mark \__peek_N_type_aux:nnw
9891 #1 \s__peek_mark \__peek_use_none_delimit_by_s_stop:w
9892 \s__peek_stop
9893 \exp_after:wN \__peek_true:w
9894 \else:
9895 \exp_after:wN \__peek_false:w
9896 \fi:
9897 }
9898 \cs_new_protected:Npn \__peek_N_type:w ##1 #1 ##2 \s__peek_mark ##3
9899 { ##3 {##1} {##2} }
9900 }
9901 \exp_after:wN \__peek_tmp:w \tl_to_str:n { outer } \s__peek_stop
9902 \group_end:
9903 \cs_new_protected:Npn \__peek_N_type_aux:nnw #1 #2 #3 \fi:
9904 {
9905 \fi:
9906 \tl_if_in:noTF {#1} { \tl_to_str:n {ma} }
9907 { \__peek_true:w }
9908 { \tl_if_empty:nTF {#2} { \__peek_true:w } { \__peek_false:w } }
9909 }
9910 \cs_new_protected:Npn \peek_N_type:TF
9911 {
9912 \__peek_token_generic:NNTF
9913 \__peek_execute_branches_N_type: \scan_stop:
9914 }
9915 \cs_new_protected:Npn \peek_N_type:T
9916 { \__peek_token_generic:NNT \__peek_execute_branches_N_type: \scan_stop: }
9917 \cs_new_protected:Npn \peek_N_type:F
9918 { \__peek_token_generic:NNF \__peek_execute_branches_N_type: \scan_stop: }
9919 %% File: l3prop.dtx
9920 \cs_new_eq:NN \__prop_tmp:w ?
9921 \tl_new:N \l__prop_tmp_tl
9922 \scan_new:N \s__prop_mark
9923 \scan_new:N \s__prop_stop
9924 \quark_new:N \q__prop_recursion_tail
9925 \quark_new:N \q__prop_recursion_stop
9926 \__kernel_quark_new_test:N \__prop_if_recursion_tail_stop:n
9927 \cs_generate_variant:Nn \__prop_if_recursion_tail_stop:n { o }
9928 \scan_new:N \s__prop
9929 \cs_new_protected:Npn \__prop_chk:w { \__prop_chk_loop:nw { } }
9930 \cs_new_protected:Npn \__prop_chk_loop:nw #1
9931 {
9932 \peek_meaning:NTF \__prop_pair:wn
9933 { \__prop_chk_get:nw {#1} }
9934 { \msg_error:nne { prop } { misused } {#1} }
9935 }
9936 \cs_new_protected:Npn \__prop_chk_get:nw #1 \__prop_pair:wn #2 \s__prop #3
9937 { \__prop_chk_loop:nw { #1 , ~ {#2} = { \tl_to_str:n {#3} } } }
9938 \cs_new:Npn \__prop_pair:wn #1 \s__prop #2 { }
9939 \cs_new_protected:Npn \__prop_flatten:w #1 \s__prop #2#3
9940 { \use:e { \__prop_flatten_aux:N #3 } }
9941 \cs_new:Npn \__prop_flatten:N #1
9942 { \exp_after:wN \__prop_flatten_aux:w #1 }
9943 \cs_new:Npn \__prop_flatten_aux:w #1 \s__prop #2 { \__prop_flatten_aux:N }
9944 \cs_new:Npn \__prop_flatten_aux:N #1
9945 {
9946 \s__prop \__prop_chk:w
9947 \exp_after:wN \__prop_flatten_loop:w #1
9948 \use_none:nnnn \__prop_pair:wn \s__prop { }
9949 }
9950 \cs_new:Npn \__prop_flatten_loop:w #1#2#3 \__prop_pair:wn #4 \s__prop #5
9951 {
9952 #3
9953 \exp_not:n { \__prop_pair:wn #4 \s__prop {#5} }
9954 \exp_after:wN \__prop_flatten_loop:w
9955 }
9956 \int_new:N \g__prop_prefix_int
9957 \int_const:Nn \c__prop_basis_int { \c_max_char_int - `\! }
9958 \cs_new_protected:Npn \__prop_next_prefix:
9959 {
9960 \tl_set:Ne \l__prop_tmp_tl
9961 { \__prop_to_prefix:n { \g__prop_prefix_int } }
9962 \int_gincr:N \g__prop_prefix_int
9963 }
9964 \cs_new:Npn \__prop_to_prefix:n #1
9965 {
9966 \int_compare:nNnTF {#1} > \c__prop_basis_int
9967 {
9968 \exp_args:Nf \__prop_to_prefix:n
9969 { \int_div_truncate:nn {#1} \c__prop_basis_int }
9970 \exp_args:Nf \__prop_to_prefix:n
9971 { \int_mod:nn {#1} \c__prop_basis_int }
9972 }
9973 { \char_generate:nn { `\! + #1 } { 12 } }
9974 }
9975 \cs_new:Npn \__prop_if_flat:NTF #1
9976 {
9977 \prop_if_exist:NT #1
9978 \exp_after:wN \__prop_if_flat_aux:w #1
9979 \s__prop_mark \use_ii:nn
9980 \__prop_flatten:w \s__prop_mark \use_i:nn \s__prop_stop
9981 }
9982 \cs_new:Npn \__prop_if_flat_aux:w
9983 #1 \__prop_flatten:w #2 \s__prop_mark #3 #4 \s__prop_stop {#3}
9984 \tl_const:Nn \c_empty_prop { \s__prop \__prop_chk:w }
9985 \cs_new_protected:Npn \prop_new:N #1
9986 {
9987 \__kernel_chk_if_free_cs:N #1
9988 \cs_gset_eq:NN #1 \c_empty_prop
9989 }
9990 \cs_generate_variant:Nn \prop_new:N { c }
9991 \cs_new_protected:Npn \prop_new_linked:N #1
9992 {
9993 \__kernel_chk_if_free_cs:N #1
9994 \__prop_new_linked:N #1
9995 }
9996 \cs_new_protected:Npn \__prop_new_linked:N #1
9997 {
9998 \__prop_next_prefix:
9999 \cs_gset_nopar:Npe #1
10000 {
10001 \__prop_flatten:w
10002 \exp_not:c { __prop ~ \l__prop_tmp_tl }
10003 \s__prop { \l__prop_tmp_tl }
10004 \exp_not:c { __prop ~ \l__prop_tmp_tl }
10005 }
10006 \cs_gset_nopar:cpe { __prop ~ \l__prop_tmp_tl }
10007 {
10008 \exp_not:N \use_none:n
10009 \exp_not:N #1
10010 }
10011 }
10012 \cs_generate_variant:Nn \prop_new_linked:N { c }
10013 \cs_new_protected:Npn \prop_clear:N
10014 { \__prop_clear:NNN \cs_set_eq:NN \cs_set_nopar:Npe }
10015 \cs_generate_variant:Nn \prop_clear:N { c }
10016 \cs_new_protected:Npn \prop_gclear:N
10017 { \__prop_clear:NNN \cs_gset_eq:NN \cs_gset_nopar:Npe }
10018 \cs_generate_variant:Nn \prop_gclear:N { c }
10019 \cs_new_protected:Npn \__prop_clear:NNN #1#2#3
10020 {
10021 \__prop_if_flat:NTF #3
10022 { #1 #3 \c_empty_prop }
10023 { \exp_after:wN \__prop_clear:wNNN #3 #1 #2 #3 }
10024 }
10025 \cs_new_protected:Npn \__prop_clear:wNNN
10026 \__prop_flatten:w #1 \s__prop #2#3#4#5#6
10027 {
10028 \__prop_clear_entries:NN #4 #3
10029 #5 #6 { \exp_not:n { \__prop_flatten:w #1 \s__prop {#2} #1 } }
10030 #5 #1 { \exp_not:n { \use_none:n #6 } }
10031 }
10032 \cs_new_protected:Npn \__prop_clear_entries:NN #1#2
10033 {
10034 \exp_after:wN \__prop_clear_loop:Nw \exp_after:wN #1 #2
10035 \use_none:nnnn \__prop_pair:wn \s__prop { }
10036 }
10037 \cs_new_protected:Npn \__prop_clear_loop:Nw
10038 #1#2#3#4 \__prop_pair:wn #5 \s__prop #6
10039 {
10040 #1 #3 \tex_undefined:D
10041 #4
10042 \exp_after:wN \__prop_clear_loop:Nw
10043 \exp_after:wN #1
10044 }
10045 \cs_new_protected:Npn \prop_clear_new:N #1
10046 { \prop_if_exist:NTF #1 { \prop_clear:N #1 } { \prop_new:N #1 } }
10047 \cs_generate_variant:Nn \prop_clear_new:N { c }
10048 \cs_new_protected:Npn \prop_gclear_new:N #1
10049 { \prop_if_exist:NTF #1 { \prop_gclear:N #1 } { \prop_new:N #1 } }
10050 \cs_generate_variant:Nn \prop_gclear_new:N { c }
10051 \cs_new_protected:Npn \prop_clear_new_linked:N #1
10052 { \prop_if_exist:NTF #1 { \prop_clear:N #1 } { \prop_new_linked:N #1 } }
10053 \cs_generate_variant:Nn \prop_clear_new_linked:N { c }
10054 \cs_new_protected:Npn \prop_gclear_new_linked:N #1
10055 { \prop_if_exist:NTF #1 { \prop_gclear:N #1 } { \prop_new_linked:N #1 } }
10056 \cs_generate_variant:Nn \prop_gclear_new_linked:N { c }
10057 \cs_new_protected:Npn \prop_set_eq:NN
10058 { \__prop_set_eq:NNNN \cs_set_eq:NN \cs_set_nopar:Npe }
10059 \cs_generate_variant:Nn \prop_set_eq:NN { Nc , cN , cc }
10060 \cs_new_protected:Npn \prop_gset_eq:NN
10061 { \__prop_set_eq:NNNN \cs_gset_eq:NN \cs_gset_nopar:Npe }
10062 \cs_generate_variant:Nn \prop_gset_eq:NN { Nc , cN , cc }
10063 \cs_new_protected:Npn \__prop_set_eq:NNNN #1#2#3#4
10064 {
10065 \cs_if_eq:NNF #3#4
10066 {
10067 \__prop_if_flat:NTF #3
10068 {
10069 \__prop_if_flat:NTF #4
10070 { #1 #3 #4 }
10071 { #2 #3 { \__prop_flatten:N #4 } }
10072 }
10073 { \exp_after:wN \__prop_set_eq:wNNNN #3 #1#2#3#4 }
10074 }
10075 }
10076 \cs_new_protected:Npn \__prop_set_eq:wNNNN
10077 \__prop_flatten:w #1 \s__prop #2#3#4#5#6#7
10078 {
10079 \__prop_clear_entries:NN #4 #3
10080 \exp_args:Nf \__prop_set_eq:nNnNN {#7} #1 {#2} #5 #6
10081 }
10082 \cs_new_protected:Npn \__prop_set_eq:nNnNN #1#2#3#4#5
10083 {
10084 \use_i:nnn
10085 {
10086 \__prop_set_eq_loop:NNnw #5 #4 {#3}
10087 \__prop_flatten:w #2 \s__prop {#3}
10088 }
10089 #1
10090 \use_none:n \__prop_pair:wn ? \s__prop
10091 }
10092 \cs_new_protected:Npn \__prop_set_eq_loop:NNnw
10093 #1#2#3#4 \s__prop #5#6 \__prop_pair:wn #7 \s__prop
10094 {
10095 \tl_set:Ne \l__prop_tmp_tl { \exp_not:c { __prop ~ #3 #6 ~ #7 } }
10096 #2 #1 { \exp_not:n { #4 \s__prop {#5} } \exp_not:o \l__prop_tmp_tl }
10097 \use_none:n #6 \__prop_set_eq_end:w
10098 \exp_after:wN \__prop_set_eq_loop:NNnw \l__prop_tmp_tl #2 {#3}
10099 \use_none:n #1 \__prop_pair:wn #7 \s__prop
10100 }
10101 \cs_new_protected:Npn \__prop_set_eq_end:w
10102 \exp_after:wN \__prop_set_eq_loop:NNnw #1#2#3
10103 \use_none:n #4#5 \s__prop
10104 {
10105 \exp_after:wN #2 \l__prop_tmp_tl { \exp_not:n { \use_none:n #4 } }
10106 }
10107 \cs_new_protected:Npn \prop_make_flat:N #1
10108 {
10109 \int_compare:nNnTF { \tex_currentgrouplevel:D } = 0
10110 {
10111 \__prop_if_flat:NTF #1 { }
10112 { \exp_args:NNf \__prop_make_flat:Nn #1 {#1} }
10113 }
10114 {
10115 \msg_error:nnee { prop } { inner-make }
10116 { \token_to_str:N \prop_make_flat:N } { \token_to_str:N #1 }
10117 }
10118 }
10119 \cs_generate_variant:Nn \prop_make_flat:N { c }
10120 \cs_new_protected:Npn \__prop_make_flat:Nn #1#2
10121 {
10122 \exp_after:wN \__prop_clear:wNNN #1 \cs_set_eq:NN \cs_set_nopar:Npe #1
10123 \cs_set_nopar:Npe #1 { \exp_not:n {#2} }
10124 }
10125 \cs_new_protected:Npn \prop_make_linked:N #1
10126 {
10127 \int_compare:nNnTF { \tex_currentgrouplevel:D } = 0
10128 {
10129 \__prop_if_flat:NTF #1
10130 { \exp_args:NNo \__prop_make_linked:Nn #1 {#1} } { }
10131 }
10132 {
10133 \msg_error:nnee { prop } { inner-make }
10134 { \token_to_str:N \prop_make_linked:N } { \token_to_str:N #1 }
10135 }
10136 }
10137 \cs_generate_variant:Nn \prop_make_linked:N { c }
10138 \cs_new_protected:Npn \__prop_make_linked:Nn #1#2
10139 {
10140 \__prop_new_linked:N #1
10141 \tl_set:Nn \l__prop_tmp_tl {#2}
10142 \exp_after:wN \__prop_set_eq:wNNNN #1
10143 \cs_set_eq:NN \cs_set_nopar:Npe #1 \l__prop_tmp_tl
10144 }
10145 \prop_new:N \l_tmpa_prop
10146 \prop_new:N \l_tmpb_prop
10147 \prop_new:N \g_tmpa_prop
10148 \prop_new:N \g_tmpb_prop
10149 \cs_new_protected:Npn \prop_concat:NNN
10150 { \__prop_concat:NNNNN \cs_set_eq:NN \cs_set_nopar:Npe }
10151 \cs_generate_variant:Nn \prop_concat:NNN { ccc }
10152 \cs_new_protected:Npn \prop_gconcat:NNN
10153 { \__prop_concat:NNNNN \cs_gset_eq:NN \cs_gset_nopar:Npe }
10154 \cs_generate_variant:Nn \prop_gconcat:NNN { ccc }
10155 \cs_new_protected:Npn \__prop_concat:NNNNN #1#2#3#4#5
10156 {
10157 \cs_if_eq:NNTF #3 #5
10158 { \__prop_concat:nNNN \use_none:nnn #2 #3 #4 }
10159 {
10160 \__prop_set_eq:NNNN #1 #2 #3 #4
10161 \__prop_concat:nNNN { } #2 #3 #5
10162 }
10163 }
10164 \cs_new_protected:Npn \__prop_concat:nNNN #1#2#3#4
10165 {
10166 \cs_gset_eq:NN \__prop_tmp:w \__prop_pair:wn
10167 \cs_gset_protected:Npn \__prop_pair:wn ##1 \s__prop
10168 { \__prop_put:nNNnn {#1} #2 #3 {##1} }
10169 \exp_last_unbraced:Nf \use_none:nn #4
10170 \cs_gset_eq:NN \__prop_pair:wn \__prop_tmp:w
10171 }
10172 \cs_new_protected:Npn \prop_put_from_keyval:Nn #1
10173 { \__prop_from_keyval:nn { \__prop_put:nNNnn { } \cs_set_nopar:Npe #1 } }
10174 \cs_generate_variant:Nn \prop_put_from_keyval:Nn { c }
10175 \cs_new_protected:Npn \prop_gput_from_keyval:Nn #1
10176 { \__prop_from_keyval:nn { \__prop_put:nNNnn { } \cs_gset_nopar:Npe #1 } }
10177 \cs_generate_variant:Nn \prop_gput_from_keyval:Nn { c }
10178 \cs_new_protected:Npn \__prop_from_keyval:nn
10179 {
10180 \bool_if:NTF \l__kernel_keyval_allow_blank_keys_bool
10181 { \__prop_from_keyval:Nnn \c_true_bool }
10182 { \__prop_from_keyval:Nnn \c_false_bool }
10183 }
10184 \cs_new_protected:Npn \__prop_from_keyval:Nnn #1#2#3
10185 {
10186 \bool_set_eq:NN \l__kernel_keyval_allow_blank_keys_bool \c_true_bool
10187 \keyval_parse:nnn \__prop_missing_eq:n {#2} {#3}
10188 \bool_set_eq:NN \l__kernel_keyval_allow_blank_keys_bool #1
10189 }
10190 \cs_new_protected:Npn \__prop_missing_eq:n
10191 { \msg_error:nnn { prop } { prop-keyval } }
10192 \cs_new_protected:Npn \prop_set_from_keyval:Nn #1
10193 {
10194 \__prop_clear:NNN \cs_set_eq:NN \cs_set_nopar:Npe #1
10195 \prop_put_from_keyval:Nn #1
10196 }
10197 \cs_generate_variant:Nn \prop_set_from_keyval:Nn { c }
10198 \cs_new_protected:Npn \prop_gset_from_keyval:Nn #1
10199 {
10200 \__prop_clear:NNN \cs_gset_eq:NN \cs_gset_nopar:Npe #1
10201 \prop_gput_from_keyval:Nn #1
10202 }
10203 \cs_generate_variant:Nn \prop_gset_from_keyval:Nn { c }
10204 \cs_new_protected:Npn \prop_const_from_keyval:Nn #1
10205 {
10206 \prop_new:N #1
10207 \__prop_from_keyval:nn { \__prop_put:nNNnn { } \cs_gset_nopar:Npe #1 }
10208 }
10209 \cs_generate_variant:Nn \prop_const_from_keyval:Nn { c }
10210 \cs_new_protected:Npn \prop_const_linked_from_keyval:Nn #1
10211 {
10212 \prop_new_linked:N #1
10213 \__prop_from_keyval:nn { \__prop_put:nNNnn { } \cs_gset_nopar:Npe #1 }
10214 }
10215 \cs_generate_variant:Nn \prop_const_linked_from_keyval:Nn { c }
10216 \cs_new_protected:Npn \__prop_split:NnTFn #1#2
10217 {
10218 \exp_after:wN \__prop_split_aux:nNTFn
10219 \exp_after:wN { \tl_to_str:n {#2} } #1
10220 }
10221 \cs_new_protected:Npn \__prop_split_aux:nNTFn #1#2#3
10222 {
10223 \cs_set:Npn \__prop_split_flat:w \__prop_split_linked:w ##1
10224 \__prop_pair:wn #1 \s__prop ##2 ##3 \s__prop_mark ##4 ##5 \s__prop_stop
10225 { ##4 {#3} }
10226 \exp_after:wN \__prop_split_test:wn #2 \s__prop_mark \use_i:nnn
10227 \__prop_pair:wn #1 \s__prop { ? \fi: \__prop_split_wrong:Nw #2 }
10228 \s__prop_mark \use_ii:nnn
10229 \s__prop_stop
10230 }
10231 \cs_new:Npn \__prop_split_flat:w { }
10232 \cs_new_protected:Npn \__prop_split_test:wn #1 \s__prop #2
10233 {
10234 \if_meaning:w \__prop_chk:w #2 \exp_after:wN \__prop_split_flat:w \fi:
10235 \__prop_split_linked:w
10236 }
10237 \cs_new_protected:Npn \__prop_split_linked:w #1 \s__prop_stop #2#3 {#3}
10238 \cs_new_protected:Npn \__prop_split_wrong:Nw #1#2 \s__prop_stop #3#4
10239 {
10240 \prop_show:N #1
10241 \cs_gset_eq:NN #1 \c_empty_prop
10242 #3
10243 }
10244 \cs_new_protected:Npn \prop_get:NnN #1#2#3
10245 {
10246 \__prop_get:NnnTF #1 {#2}
10247 { \tl_set:Nn #3 } { } { \tl_set:Nn #3 { \q_no_value } }
10248 }
10249 \cs_generate_variant:Nn \prop_get:NnN { NV , Nv , Ne , c , cV , cv , ce }
10250 \cs_generate_variant:Nn \prop_get:NnN { No , Nx , co , cx }
10251 \cs_generate_variant:Nn \prop_get:NnN { cnc }
10252 \prg_new_protected_conditional:Npnn \prop_get:NnN #1#2#3 { T , F , TF }
10253 {
10254 \__prop_get:NnnTF #1 {#2}
10255 { \tl_set:Nn #3 } \prg_return_true: \prg_return_false:
10256 }
10257 \prg_generate_conditional_variant:Nnn \prop_get:NnN
10258 { NV , Nv , Ne , c , cV , cv , ce } { T , F , TF }
10259 \prg_generate_conditional_variant:Nnn \prop_get:NnN
10260 { No , Nx , co , cx } { T , F , TF }
10261 \prg_generate_conditional_variant:Nnn \prop_get:NnN
10262 { cnc } { T , F , TF }
10263 \cs_new_protected:Npn \__prop_get:NnnTF #1#2#3#4#5
10264 {
10265 \__prop_split:NnTFn #1 {#2}
10266 { #3 {##2} #4 }
10267 {#5}
10268 { \exp_after:wN \__prop_get_linked:w #1 {#2} {#3} {#4} {#5} }
10269 }
10270 \cs_new:Npn \__prop_get_linked:w
10271 \__prop_flatten:w #1 \s__prop #2#3#4#5#6#7
10272 {
10273 \if_cs_exist:w __prop ~ #2 ~ \tl_to_str:n {#4} \cs_end:
10274 \exp_after:wN \exp_after:wN \exp_after:wN \__prop_get_linked_aux:w
10275 \cs:w __prop ~ #2 ~ \tl_to_str:n {#4} \exp_after:wN \cs_end:
10276 \else:
10277 \exp_after:wN \__prop_get_linked_aux:w
10278 \fi:
10279 \s__prop_mark {#5} {#6}
10280 \s__prop { } \s__prop_mark \use_none:n {#7}
10281 \s__prop_stop
10282 }
10283 \cs_new:Npn \__prop_get_linked_aux:w
10284 #1 \s__prop #2 #3 \s__prop_mark #4 #5 #6 \s__prop_stop { #4 {#2} #5 }
10285 \cs_new:Npn \prop_item:Nn #1#2
10286 {
10287 \__prop_if_flat:NTF #1
10288 {
10289 \exp_args:NNo \prop_map_tokens:Nn #1
10290 {
10291 \exp_after:wN \__prop_item:nnn
10292 \exp_after:wN { \tl_to_str:n {#2} }
10293 }
10294 }
10295 { \exp_after:wN \__prop_get_linked:w #1 {#2} \exp_not:n { } { } }
10296 }
10297 \cs_new:Npn \__prop_item:nnn #1#2#3
10298 {
10299 \str_if_eq:eeT {#1} {#2}
10300 { \prop_map_break:n { \exp_not:n {#3} } }
10301 }
10302 \cs_generate_variant:Nn \prop_item:Nn { NV , No , Ne , c , cV , co , ce }
10303 \cs_new_protected:Npn \__prop_pop:NnNNnTF #1#2#3#4#5#6#7
10304 {
10305 \__prop_split:NnTFn #1 {#2}
10306 {
10307 #4 #1 { \exp_not:n { \s__prop \__prop_chk:w ##1 ##3 } }
10308 #5 {##2}
10309 #6
10310 }
10311 {#7}
10312 {
10313 \exp_after:wN \__prop_pop_linked:wnNNnTF #1 {#2}
10314 #3 #4 {#5} {#6} {#7}
10315 }
10316 }
10317 \cs_new_protected:Npn \__prop_pop_linked:wnNNnTF
10318 \__prop_flatten:w #1 \s__prop #2#3#4#5#6#7
10319 {
10320 \if_cs_exist:w __prop ~ #2 ~ \tl_to_str:n {#4} \cs_end:
10321 \exp_after:wN \__prop_pop_linked:NNNn
10322 \cs:w __prop ~ #2 ~ \tl_to_str:n {#4} \cs_end:
10323 #5 #6 {#7}
10324 \else:
10325 \exp_after:wN \use_iii:nnn
10326 \fi:
10327 \use_i:nn
10328 }
10329 \cs_new_protected:Npn \__prop_pop_linked:NNNn #1#2#3#4
10330 {
10331 \if_meaning:w \scan_stop: #1
10332 \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
10333 \else:
10334 \exp_after:wN \__prop_pop_linked:w #1 #1 #2 #3 {#4}
10335 \fi:
10336 }
10337 \cs_new_protected:Npn \__prop_pop_linked:w
10338 \use_none:n #1#2 \s__prop #3#4#5#6#7#8
10339 {
10340 #6 #5 \tex_undefined:D
10341 #7 #1
10342 {
10343 \exp_after:wN \__prop_pop_linked_prev:w #1
10344 \exp_not:N #4
10345 }
10346 #7 #4
10347 {
10348 \exp_not:n { \use_none:n #1 }
10349 \exp_not:f { \exp_after:wN \__prop_pop_linked_next:w #4 }
10350 }
10351 #8 {#3}
10352 }
10353 \cs_new:Npn \__prop_pop_linked_prev:w #1 \s__prop #2#3
10354 { \exp_not:n { #1 \s__prop {#2} } }
10355 \cs_new:Npn \__prop_pop_linked_next:w \use_none:n #1 { \exp_stop_f: }
10356 \cs_new_protected:Npn \prop_remove:Nn #1#2
10357 {
10358 \__prop_pop:NnNNnTF #1 {#2}
10359 \cs_set_eq:NN \cs_set_nopar:Npe
10360 \use_none:n { } { }
10361 }
10362 \cs_new_protected:Npn \prop_gremove:Nn #1#2
10363 {
10364 \__prop_pop:NnNNnTF #1 {#2}
10365 \cs_gset_eq:NN \cs_gset_nopar:Npe
10366 \use_none:n { } { }
10367 }
10368 \cs_generate_variant:Nn \prop_remove:Nn { NV , Ne , c , cV , ce }
10369 \cs_generate_variant:Nn \prop_gremove:Nn { NV , Ne , c , cV , ce }
10370 \cs_new_protected:Npn \prop_pop:NnN #1#2#3
10371 {
10372 \__prop_pop:NnNNnTF #1 {#2}
10373 \cs_set_eq:NN \cs_set_nopar:Npe
10374 { \tl_set:Nn #3 } { } { \tl_set:Nn #3 { \q_no_value } }
10375 }
10376 \cs_new_protected:Npn \prop_gpop:NnN #1#2#3
10377 {
10378 \__prop_pop:NnNNnTF #1 {#2}
10379 \cs_gset_eq:NN \cs_gset_nopar:Npe
10380 { \tl_set:Nn #3 } { } { \tl_set:Nn #3 { \q_no_value } }
10381 }
10382 \cs_generate_variant:Nn \prop_pop:NnN { NV , No }
10383 \cs_generate_variant:Nn \prop_pop:NnN { c , cV , co }
10384 \cs_generate_variant:Nn \prop_gpop:NnN { NV , No }
10385 \cs_generate_variant:Nn \prop_gpop:NnN { c , cV , co }
10386 \prg_new_protected_conditional:Npnn \prop_pop:NnN #1#2#3 { T , F , TF }
10387 {
10388 \__prop_pop:NnNNnTF #1 {#2}
10389 \cs_set_eq:NN \cs_set_nopar:Npe
10390 { \tl_set:Nn #3 } \prg_return_true: \prg_return_false:
10391 }
10392 \prg_new_protected_conditional:Npnn \prop_gpop:NnN #1#2#3 { T , F , TF }
10393 {
10394 \__prop_pop:NnNNnTF #1 {#2}
10395 \cs_gset_eq:NN \cs_gset_nopar:Npe
10396 { \tl_set:Nn #3 } \prg_return_true: \prg_return_false:
10397 }
10398 \prg_generate_conditional_variant:Nnn \prop_pop:NnN
10399 { NV , No , c , cV , co } { T , F , TF }
10400 \prg_generate_conditional_variant:Nnn \prop_gpop:NnN
10401 { NV , No , c , cV , co } { T , F , TF }
10402 \cs_new_protected:Npn \prop_put:Nnn
10403 { \__prop_put:nNNnn { } \cs_set_nopar:Npe }
10404 \cs_new_protected:Npn \prop_gput:Nnn
10405 { \__prop_put:nNNnn { } \cs_gset_nopar:Npe }
10406 \cs_new_protected:Npn \prop_put_if_not_in:Nnn
10407 { \__prop_put:nNNnn \use_none:nnn \cs_set_nopar:Npe }
10408 \cs_new_protected:Npn \prop_gput_if_not_in:Nnn
10409 { \__prop_put:nNNnn \use_none:nnn \cs_gset_nopar:Npe }
10410 \cs_generate_variant:Nn \prop_put:Nnn
10411 {
10412 NnV , Nnv , Nne , NV , NVV , NVv , NVe ,
10413 Nv , NvV , Nvv , Nve , Ne , NeV , Nev , Nee
10414 }
10415 \cs_generate_variant:Nn \prop_put:Nnn
10416 { Nno , No , Noo , Nnx , NVx , NxV , Nxx }
10417 \cs_generate_variant:Nn \prop_put:Nnn
10418 {
10419 c , cnV , cnv , cne , cV , cVV , cVv , cVe ,
10420 cv , cvV , cvv , cve , ce , ceV , cev , cee
10421 }
10422 \cs_generate_variant:Nn \prop_put:Nnn
10423 { cno , co , coo , cnx , cVx , cxV , cxx }
10424 \cs_generate_variant:Nn \prop_gput:Nnn
10425 {
10426 NnV , Nnv , Nne , NV , NVV , NVv , NVe ,
10427 Nv , NvV , Nvv , Nve , Ne , NeV , Nev , Nee
10428 }
10429 \cs_generate_variant:Nn \prop_gput:Nnn
10430 { Nno , No , Noo , Nnx , NVx , NxV , Nxx }
10431 \cs_generate_variant:Nn \prop_gput:Nnn
10432 {
10433 c , cnV , cnv , cne , cV , cVV , cVv , cVe ,
10434 cv , cvV , cvv , cve , ce , ceV , cev , cee
10435 }
10436 \cs_generate_variant:Nn \prop_gput:Nnn
10437 { cno , co , coo , cnx , cVx , cxV , cxx }
10438 \cs_generate_variant:Nn \prop_put_if_not_in:Nnn
10439 {
10440 NnV , Nnv , Nne , NV , NVV , NVv , NVe ,
10441 Nv , NvV , Nvv , Nve , Ne , NeV , Nev , Nee ,
10442 c , cnV , cnv , cne , cV , cVV , cVv , cVe ,
10443 cv , cvV , cvv , cve , ce , ceV , cev , cee
10444 }
10445 \cs_generate_variant:Nn \prop_gput_if_not_in:Nnn
10446 {
10447 NnV , Nnv , Nne , NV , NVV , NVv , NVe ,
10448 Nv , NvV , Nvv , Nve , Ne , NeV , Nev , Nee ,
10449 c , cnV , cnv , cne , cV , cVV , cVv , cVe ,
10450 cv , cvV , cvv , cve , ce , ceV , cev , cee
10451 }
10452 \cs_new_protected:Npn \__prop_put:nNNnn #1#2#3#4#5
10453 {
10454 \tl_set:Nn \l__prop_tmp_tl
10455 {
10456 \exp_not:N \__prop_pair:wn \tl_to_str:n {#4}
10457 \s__prop { \exp_not:n {#5} }
10458 }
10459 \__prop_split:NnTFn #3 {#4}
10460 {
10461 #1 #2 #3
10462 {
10463 \s__prop \__prop_chk:w \exp_not:n {##1}
10464 \l__prop_tmp_tl \exp_not:n {##3}
10465 }
10466 }
10467 { #2 #3 { \exp_not:o {#3} \l__prop_tmp_tl } }
10468 { \exp_after:wN \__prop_put_linked:wnnN #3 {#4} {#1} #2 }
10469 }
10470 \cs_new_protected:Npn \__prop_put_linked:wnnN
10471 \__prop_flatten:w #1 \s__prop #2#3#4
10472 {
10473 \exp_after:wN \__prop_put_linked:NNnN
10474 \cs:w __prop ~ #2 ~ \tl_to_str:n {#4} \cs_end:
10475 #1
10476 }
10477 \cs_new_protected:Npn \__prop_put_linked:NNnN #1#2#3#4
10478 {
10479 \if_meaning:w \scan_stop: #1
10480 \exp_after:wN \__prop_put_linked_new:w #2 #1 #2 #4
10481 \else:
10482 \exp_after:wN \__prop_put_linked_old:w #1 { #3 #4 #1 }
10483 \fi:
10484 }
10485 \cs_new_protected:Npn \__prop_put_linked_new:w
10486 \use_none:n #1#2#3#4
10487 {
10488 #4 #1
10489 {
10490 \exp_after:wN \__prop_pop_linked_prev:w #1
10491 \exp_not:N #2
10492 }
10493 #4 #2
10494 {
10495 \exp_not:n { \use_none:n #1 }
10496 \l__prop_tmp_tl
10497 \exp_not:N #3
10498 }
10499 #4 #3 { \exp_not:n { \use_none:n #2 } }
10500 }
10501 \cs_new_protected:Npn \__prop_put_linked_old:w
10502 \use_none:n #1#2 \s__prop #3#4#5
10503 {
10504 #5
10505 {
10506 \exp_not:n { \use_none:n #1 }
10507 \l__prop_tmp_tl
10508 \exp_not:N #4
10509 }
10510 }
10511 \prg_new_eq_conditional:NNn \prop_if_exist:N \cs_if_exist:N
10512 { TF , T , F , p }
10513 \prg_new_eq_conditional:NNn \prop_if_exist:c \cs_if_exist:c
10514 { TF , T , F , p }
10515 \prg_new_conditional:Npnn \prop_if_empty:N #1 { p , T , F , TF }
10516 {
10517 \if_meaning:w #1 \c_empty_prop
10518 \prg_return_true:
10519 \else:
10520 \exp_after:wN \__prop_if_empty_return:w #1
10521 \__prop_flatten:w 2 \s__prop 34 \s__prop_stop
10522 \fi:
10523 }
10524 \cs_new:Npn \__prop_if_empty_return:w
10525 #1 \__prop_flatten:w #2 \s__prop #3#4#5 \s__prop_stop
10526 {
10527 \if_meaning:w #2 #4
10528 \prg_return_true:
10529 \else:
10530 \prg_return_false:
10531 \fi:
10532 }
10533 \prg_generate_conditional_variant:Nnn \prop_if_empty:N
10534 { c } { p , T , F , TF }
10535 \prg_new_conditional:Npnn \prop_if_in:Nn #1#2 { p , T , F , TF }
10536 {
10537 \__prop_if_flat:NTF #1
10538 {
10539 \exp_after:wN \prop_map_tokens:Nn \exp_after:wN #1
10540 {
10541 \exp_after:wN \__prop_if_in_flat:nnn
10542 \exp_after:wN { \tl_to_str:n {#2} }
10543 }
10544 \prg_return_false:
10545 }
10546 {
10547 \exp_after:wN \__prop_get_linked:w #1 {#2}
10548 \use_none:n \prg_return_true: \prg_return_false:
10549 }
10550 }
10551 \cs_new:Npn \__prop_if_in_flat:nnn #1#2#3
10552 {
10553 \str_if_eq:eeT {#1} {#2}
10554 { \prop_map_break:n { \use_i:nn \prg_return_true: } }
10555 }
10556 \prg_generate_conditional_variant:Nnn \prop_if_in:Nn
10557 { NV , Ne , No , c , cV , ce , co } { p , T , F , TF }
10558 \cs_new:Npn \prop_map_function:NN #1#2
10559 {
10560 \exp_last_unbraced:Nnf
10561 \use_i:nnn { \__prop_map_function:Nw #2 } #1
10562 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10563 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10564 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10565 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10566 \prg_break_point:Nn \prop_map_break: { }
10567 }
10568 \cs_new:Npn \__prop_map_function:Nw #1
10569 \__prop_pair:wn #2 \s__prop #3
10570 \__prop_pair:wn #4 \s__prop #5
10571 \__prop_pair:wn #6 \s__prop #7
10572 \__prop_pair:wn #8 \s__prop #9
10573 {
10574 \if_false: #2 \fi: #1 {#2} {#3}
10575 \if_false: #4 \fi: #1 {#4} {#5}
10576 \if_false: #6 \fi: #1 {#6} {#7}
10577 \if_false: #8 \fi: #1 {#8} {#9}
10578 \__prop_map_function:Nw #1
10579 }
10580 \cs_generate_variant:Nn \prop_map_function:NN { Nc , c , cc }
10581 \cs_new_protected:Npn \prop_map_inline:Nn #1#2
10582 {
10583 \cs_gset_eq:cN
10584 { __prop_map_ \int_use:N \g__kernel_prg_map_int :wn } \__prop_pair:wn
10585 \int_gincr:N \g__kernel_prg_map_int
10586 \cs_gset_protected:Npn \__prop_pair:wn ##1 \s__prop ##2 {#2}
10587 \exp_last_unbraced:Nf \use_none:nn #1
10588 \prg_break_point:Nn \prop_map_break:
10589 {
10590 \int_gdecr:N \g__kernel_prg_map_int
10591 \cs_gset_eq:Nc \__prop_pair:wn
10592 { __prop_map_ \int_use:N \g__kernel_prg_map_int :wn }
10593 }
10594 }
10595 \cs_generate_variant:Nn \prop_map_inline:Nn { c }
10596 \cs_new:Npn \prop_map_tokens:Nn #1#2
10597 {
10598 \exp_last_unbraced:Nnf
10599 \use_i:nnn { \__prop_map_tokens:nw {#2} } #1
10600 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10601 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10602 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10603 \__prop_pair:wn \fi: \prop_map_break: \s__prop { }
10604 \prg_break_point:Nn \prop_map_break: { }
10605 }
10606 \cs_new:Npn \__prop_map_tokens:nw #1
10607 \__prop_pair:wn #2 \s__prop #3
10608 \__prop_pair:wn #4 \s__prop #5
10609 \__prop_pair:wn #6 \s__prop #7
10610 \__prop_pair:wn #8 \s__prop #9
10611 {
10612 \if_false: #2 \fi: \use:n {#1} {#2} {#3}
10613 \if_false: #4 \fi: \use:n {#1} {#4} {#5}
10614 \if_false: #6 \fi: \use:n {#1} {#6} {#7}
10615 \if_false: #8 \fi: \use:n {#1} {#8} {#9}
10616 \__prop_map_tokens:nw {#1}
10617 }
10618 \cs_generate_variant:Nn \prop_map_tokens:Nn { c }
10619 \cs_new:Npn \prop_map_break:
10620 { \prg_map_break:Nn \prop_map_break: { } }
10621 \cs_new:Npn \prop_map_break:n
10622 { \prg_map_break:Nn \prop_map_break: }
10623 \cs_new:Npn \prop_count:N #1
10624 {
10625 \int_eval:n
10626 {
10627 0
10628 \prop_map_function:NN #1 \__prop_count:nn
10629 }
10630 }
10631 \cs_new:Npn \__prop_count:nn #1#2 { + 1 }
10632 \cs_generate_variant:Nn \prop_count:N { c }
10633 \cs_new:Npn \prop_to_keyval:N #1
10634 {
10635 \__kernel_exp_not:w
10636 \prop_if_empty:NTF #1
10637 { {} }
10638 {
10639 \exp_after:wN \exp_after:wN \exp_after:wN
10640 {
10641 \tex_expanded:D
10642 {
10643 \exp_not:N \use_none:n
10644 \prop_map_function:NN #1 \__prop_to_keyval:nn
10645 }
10646 }
10647 }
10648 }
10649 \cs_new:Npn \__prop_to_keyval:nn #1#2
10650 { , ~ {#1} =~ { \__kernel_exp_not:w {#2} } }
10651 \cs_new_protected:Npn \prop_show:N { \__prop_show:NN \msg_show:nneeee }
10652 \cs_generate_variant:Nn \prop_show:N { c }
10653 \cs_new_protected:Npn \prop_log:N { \__prop_show:NN \msg_log:nneeee }
10654 \cs_generate_variant:Nn \prop_log:N { c }
10655 \cs_new_protected:Npn \__prop_show:NN #1#2
10656 {
10657 \__kernel_chk_tl_type:NnnT #2 { prop }
10658 {
10659 \__prop_if_flat:NTF #2
10660 {
10661 \s__prop \__prop_chk:w
10662 \exp_after:wN \__prop_show_flat:w #2
10663 \s__prop { }
10664 \__prop_pair:wn \q__prop_recursion_tail \s__prop { }
10665 \q__prop_recursion_stop
10666 }
10667 { \exp_after:wN \__prop_show_linked:w #2 \s__prop ! ? \s__prop_stop }
10668 }
10669 {
10670 \__prop_if_flat:NTF #2
10671 { \__prop_show_finally:NNn #1 #2 { flat } }
10672 {
10673 \tl_set:Nn \l__prop_tmp_tl { #1 #2 }
10674 \exp_after:wN \__prop_show_prepare:w #2 #2
10675 }
10676 }
10677 }
10678 \cs_new:Npn \__prop_show_flat:w #1 \__prop_pair:wn #2 \s__prop #3
10679 {
10680 \__prop_if_recursion_tail_stop:n {#2}
10681 \exp_not:N \__prop_pair:wn \tl_to_str:n {#2} \s__prop \exp_not:n { {#3} }
10682 \__prop_show_flat:w
10683 }
10684 \cs_new:Npn \__prop_show_linked:w #1 \s__prop #2#3#4 \s__prop_stop
10685 {
10686 \exp_not:N \__prop_flatten:w
10687 \exp_not:c { __prop ~ \tl_to_str:n {#2} }
10688 \s__prop { \tl_to_str:n {#2} }
10689 \exp_not:n {#3}
10690 }
10691 \cs_new_protected:Npn \__prop_show_finally:NNn #1#2#3
10692 {
10693 #1 { prop } { show }
10694 { \token_to_str:N #2 }
10695 { \prop_map_function:NN #2 \msg_show_item:nn }
10696 {#3} { }
10697 }
10698 \cs_new_protected:Npn \__prop_show_prepare:w
10699 \__prop_flatten:w #1 \s__prop #2#3#4
10700 {
10701 \use:e
10702 {
10703 \cs_set_nopar:Npn \exp_not:N \__prop_tmp:w
10704 ##1 \token_to_str:N #1 ##2 \s__prop_mark ##3 \s__prop_stop
10705 {
10706 \exp_not:N \tl_if_empty:nTF {##1}
10707 {
10708 \exp_not:N \tl_if_head_is_space:nTF {##2}
10709 { \exp_not:N \exp_args:Nf \__prop_show_loop_key:wNNN }
10710 { \exp_not:N \tl_if_empty:nTF }
10711 {##2}
10712 }
10713 { \exp_not:N \use_ii:nn }
10714 \__prop_show_end:NNN
10715 \__prop_show_bad_name:NNN
10716 }
10717 }
10718 \exp_last_unbraced:NNNo \__prop_show_loop:NNw #1 #4 #4
10719 }
10720 \cs_new_protected:Npn \__prop_show_loop:NNw #1#2 #3 \s__prop #4#5
10721 {
10722 \exp_last_two_unbraced:Noo \__prop_tmp:w
10723 { \token_to_str:N #5 \s__prop_mark }
10724 { \token_to_str:N #1 \s__prop_mark \s__prop_stop }
10725 #1 #2 #5
10726 }
10727 \cs_new_protected:Npn \__prop_show_bad_name:NNN #1#2#3
10728 {
10729 \msg_error:nneeee { prop } { bad-link }
10730 { \tl_tail:N \l__prop_tmp_tl }
10731 { \token_to_str:N #2 }
10732 { \token_to_str:N #3 }
10733 { \token_to_str:N #1 }
10734 }
10735 \cs_new_protected:Npn \__prop_show_end:NNN #1#2#3
10736 {
10737 \__kernel_chk_tl_type:NnnT #3
10738 { \tl_tail:N \l__prop_tmp_tl prop~entry }
10739 { \exp_not:n { \use_none:n #2 } }
10740 {
10741 \exp_after:wN \__prop_show_finally:NNn
10742 \l__prop_tmp_tl { linked }
10743 }
10744 }
10745 \cs_new_protected:Npn \__prop_show_loop_key:wNNN #1#2#3#4#5#6
10746 {
10747 \__kernel_chk_tl_type:NnnT #6
10748 { \tl_tail:N \l__prop_tmp_tl prop~entry }
10749 {
10750 \exp_not:n { \use_none:n #5 }
10751 \exp_after:wN \__prop_show_flat:w #6 \s__prop { }
10752 \__prop_pair:wn \q__prop_recursion_tail \s__prop { }
10753 \q__prop_recursion_stop
10754 \tl_item:Nn #6 { -1 }
10755 }
10756 { \exp_last_unbraced:NNNo \__prop_show_loop:NNw #4 #6 #6 }
10757 }
10758 %% File: l3msg.dtx
10759 \tl_new:N \l__msg_tmp_tl
10760 \str_new:N \l__msg_name_str
10761 \str_new:N \l__msg_text_str
10762 \scan_new:N \s__msg_mark
10763 \scan_new:N \s__msg_stop
10764 \cs_new:Npn \__msg_use_none_delimit_by_s_stop:w #1 \s__msg_stop { }
10765 \tl_const:Nn \c__msg_text_prefix_tl { msg~text~>~ }
10766 \tl_const:Nn \c__msg_more_text_prefix_tl { msg~extra~text~>~ }
10767 \prg_new_conditional:Npnn \msg_if_exist:nn #1#2 { p , T , F , TF }
10768 {
10769 \cs_if_exist:cTF { \c__msg_text_prefix_tl #1 / #2 }
10770 { \prg_return_true: } { \prg_return_false: }
10771 }
10772 \cs_new_protected:Npn \__msg_chk_free:nn #1#2
10773 {
10774 \msg_if_exist:nnT {#1} {#2}
10775 {
10776 \msg_error:nnnn { msg } { already-defined }
10777 {#1} {#2}
10778 }
10779 }
10780 \cs_new_protected:Npn \msg_new:nnnn #1#2#3#4
10781 {
10782 \__msg_chk_free:nn {#1} {#2}
10783 \cs_gset:cpn { \c__msg_text_prefix_tl #1 / #2 }
10784 ##1##2##3##4 {#3}
10785 \cs_gset:cpn { \c__msg_more_text_prefix_tl #1 / #2 }
10786 ##1##2##3##4 {#4}
10787 }
10788 \cs_generate_variant:Nn \msg_new:nnnn { nnee , nnxx }
10789 \cs_new_protected:Npn \msg_new:nnn #1#2#3
10790 { \msg_new:nnnn {#1} {#2} {#3} { } }
10791 \cs_generate_variant:Nn \msg_new:nnn { nne , nnx }
10792 \cs_new_protected:Npn \msg_set:nnnn #1#2#3#4
10793 {
10794 \cs_set:cpn { \c__msg_text_prefix_tl #1 / #2 }
10795 ##1##2##3##4 {#3}
10796 \cs_set:cpn { \c__msg_more_text_prefix_tl #1 / #2 }
10797 ##1##2##3##4 {#4}
10798 }
10799 \cs_new_protected:Npn \msg_set:nnn #1#2#3
10800 { \msg_set:nnnn {#1} {#2} {#3} { } }
10801 \tl_const:Nn \c__msg_coding_error_text_tl
10802 {
10803 This~is~a~coding~error.
10804 \\ \\
10805 }
10806 \tl_const:Nn \c__msg_continue_text_tl
10807 { Type~<return>~to~continue }
10808 \tl_const:Nn \c__msg_critical_text_tl
10809 { Reading~the~current~file~'\g_file_curr_name_str'~will~stop. }
10810 \tl_const:Nn \c__msg_fatal_text_tl
10811 { This~is~a~fatal~error:~LaTeX~will~abort. }
10812 \tl_const:Nn \c__msg_help_text_tl
10813 { For~immediate~help~type~H~<return> }
10814 \tl_const:Nn \c__msg_no_info_text_tl
10815 {
10816 LaTeX~does~not~know~anything~more~about~this~error,~sorry.
10817 \c__msg_return_text_tl
10818 }
10819 \tl_const:Nn \c__msg_on_line_text_tl { on~line }
10820 \tl_const:Nn \c__msg_return_text_tl
10821 {
10822 \\ \\
10823 Try~typing~<return>~to~proceed.
10824 \\
10825 If~that~doesn't~work,~type~X~<return>~to~quit.
10826 }
10827 \tl_const:Nn \c__msg_trouble_text_tl
10828 {
10829 \\ \\
10830 More~errors~will~almost~certainly~follow: \\
10831 the~LaTeX~run~should~be~aborted.
10832 }
10833 \cs_new:Npn \msg_line_number: { \int_use:N \tex_inputlineno:D }
10834 \cs_gset:Npn \msg_line_context:
10835 {
10836 \c__msg_on_line_text_tl
10837 \c_space_tl
10838 \msg_line_number:
10839 }
10840 \cs_new_protected:Npn \__msg_interrupt:NnnnN #1#2#3#4#5
10841 {
10842 \str_set:Ne \l__msg_text_str { #1 {#2} }
10843 \str_set:Ne \l__msg_name_str { \msg_module_name:n {#2} }
10844 \cs_if_eq:cNTF
10845 { \c__msg_more_text_prefix_tl #2 / #3 }
10846 \__msg_no_more_text:nnnn
10847 {
10848 \__msg_interrupt_wrap:nnn
10849 { \use:c { \c__msg_text_prefix_tl #2 / #3 } #4 }
10850 { \c__msg_continue_text_tl }
10851 {
10852 \c__msg_no_info_text_tl
10853 \tl_if_empty:NF #5
10854 { \\ \\ #5 }
10855 }
10856 }
10857 {
10858 \__msg_interrupt_wrap:nnn
10859 { \use:c { \c__msg_text_prefix_tl #2 / #3 } #4 }
10860 { \c__msg_help_text_tl }
10861 {
10862 \use:c { \c__msg_more_text_prefix_tl #2 / #3 } #4
10863 \tl_if_empty:NF #5
10864 { \\ \\ #5 }
10865 }
10866 }
10867 }
10868 \cs_new:Npn \__msg_no_more_text:nnnn #1#2#3#4 { }
10869 \cs_new_protected:Npn \__msg_interrupt_wrap:nnn #1#2#3
10870 {
10871 \iow_wrap:nnnN { \\ #3 } { } { } \__msg_interrupt_more_text:n
10872 \group_begin:
10873 \int_sub:Nn \l_iow_line_count_int { 2 }
10874 \iow_wrap:nenN { \l__msg_text_str : ~ #1 }
10875 {
10876 ( \l__msg_name_str )
10877 \prg_replicate:nn
10878 {
10879 \str_count:N \l__msg_text_str
10880 - \str_count:N \l__msg_name_str
10881 + 2
10882 }
10883 { ~ }
10884 }
10885 { } \__msg_interrupt_text:n
10886 \iow_wrap:nnnN { \l__msg_tmp_tl \\ \\ #2 } { } { }
10887 \__msg_interrupt:n
10888 }
10889 \cs_new_protected:Npn \__msg_interrupt_text:n #1
10890 {
10891 \group_end:
10892 \tl_set:Nn \l__msg_tmp_tl {#1}
10893 }
10894 \cs_new_protected:Npn \__msg_interrupt_more_text:n #1
10895 { \exp_args:Ne \tex_errhelp:D { #1 \iow_newline: } }
10896 \group_begin:
10897 \char_set_lccode:nn { 38 } { 32 } % &
10898 \char_set_lccode:nn { 46 } { 32 } % .
10899 \char_set_lccode:nn { 123 } { 32 } % {
10900 \char_set_lccode:nn { 125 } { 32 } % }
10901 \char_set_catcode_active:N \&
10902 \tex_lowercase:D
10903 {
10904 \group_end:
10905 \cs_new_protected:Npn \__msg_interrupt:n #1
10906 {
10907 \iow_term:n { }
10908 \__kernel_iow_with:Nnn \tex_newlinechar:D { `\^^J }
10909 {
10910 \__kernel_iow_with:Nnn \tex_errorcontextlines:D { -1 }
10911 {
10912 \group_begin:
10913 \cs_set_protected:Npn &
10914 {
10915 \tex_errmessage:D
10916 {
10917 #1
10918 \use_none:n
10919 { ............................................ }
10920 }
10921 }
10922 \exp_after:wN
10923 \group_end:
10924 &
10925 }
10926 }
10927 }
10928 }
10929 \int_gset:Nn \tex_errorcontextlines:D { -1 }
10930 \cs_new:Npn \msg_fatal_text:n #1
10931 {
10932 Fatal ~
10933 \msg_error_text:n {#1}
10934 }
10935 \cs_new:Npn \msg_critical_text:n #1
10936 {
10937 Critical ~
10938 \msg_error_text:n {#1}
10939 }
10940 \cs_new:Npn \msg_error_text:n #1
10941 { \__msg_text:nn {#1} { Error } }
10942 \cs_new:Npn \msg_warning_text:n #1
10943 { \__msg_text:nn {#1} { Warning } }
10944 \cs_new:Npn \msg_info_text:n #1
10945 { \__msg_text:nn {#1} { Info } }
10946 \cs_new:Npn \__msg_text:nn #1#2
10947 {
10948 \exp_args:Nf \__msg_text:n { \msg_module_type:n {#1} }
10949 \exp_args:Nf \__msg_text:n { \msg_module_name:n {#1} }
10950 #2
10951 }
10952 \cs_new:Npn \__msg_text:n #1
10953 {
10954 \tl_if_blank:nF {#1}
10955 { #1 ~ }
10956 }
10957 \prop_new:N \g_msg_module_name_prop
10958 \prop_new:N \g_msg_module_type_prop
10959 \prop_gput:Nnn \g_msg_module_type_prop { LaTeX } { }
10960 \cs_new:Npn \msg_module_type:n #1
10961 {
10962 \prop_if_in:NnTF \g_msg_module_type_prop {#1}
10963 { \prop_item:Nn \g_msg_module_type_prop {#1} }
10964 { Package }
10965 }
10966 \cs_new:Npn \msg_module_name:n #1
10967 {
10968 \prop_if_in:NnTF \g_msg_module_name_prop {#1}
10969 { \prop_item:Nn \g_msg_module_name_prop {#1} }
10970 {#1}
10971 }
10972 \cs_new:Npn \msg_see_documentation_text:n #1
10973 {
10974 See~the~ \msg_module_name:n {#1} ~
10975 documentation~for~further~information.
10976 }
10977 \group_begin:
10978 \cs_set_protected:Npn \__msg_class_new:nn #1#2
10979 {
10980 \prop_new:c { l__msg_redirect_ #1 _prop }
10981 \cs_new_protected:cpn { __msg_ #1 _code:nnnnnn }
10982 ##1##2##3##4##5##6 {#2}
10983 \cs_new_protected:cpn { msg_ #1 :nnnnnn } ##1##2##3##4##5##6
10984 {
10985 \use:e
10986 {
10987 \exp_not:n { \__msg_use:nnnnnnn {#1} {##1} {##2} }
10988 { \tl_to_str:n {##3} } { \tl_to_str:n {##4} }
10989 { \tl_to_str:n {##5} } { \tl_to_str:n {##6} }
10990 }
10991 }
10992 \cs_new_protected:cpe { msg_ #1 :nnnnn } ##1##2##3##4##5
10993 { \exp_not:c { msg_ #1 :nnnnnn } {##1} {##2} {##3} {##4} {##5} { } }
10994 \cs_new_protected:cpe { msg_ #1 :nnnn } ##1##2##3##4
10995 { \exp_not:c { msg_ #1 :nnnnnn } {##1} {##2} {##3} {##4} { } { } }
10996 \cs_new_protected:cpe { msg_ #1 :nnn } ##1##2##3
10997 { \exp_not:c { msg_ #1 :nnnnnn } {##1} {##2} {##3} { } { } { } }
10998 \cs_new_protected:cpe { msg_ #1 :nn } ##1##2
10999 { \exp_not:c { msg_ #1 :nnnnnn } {##1} {##2} { } { } { } { } }
11000 \cs_generate_variant:cn { msg_ #1 :nnn }
11001 { nnV , nne , nnx }
11002 \cs_generate_variant:cn { msg_ #1 :nnnn }
11003 { nnVV , nnVn , nnnV , nnne , nnnx , nnee , nnxx }
11004 \cs_generate_variant:cn { msg_ #1 :nnnnn }
11005 { nnnee , nnnxx , nneee , nnxxx }
11006 \cs_generate_variant:cn { msg_ #1 :nnnnnn } { nneeee , nnxxxx }
11007 }
11008 \__msg_class_new:nn { fatal }
11009 {
11010 \__msg_interrupt:NnnnN
11011 \msg_fatal_text:n {#1} {#2}
11012 { {#3} {#4} {#5} {#6} }
11013 \c__msg_fatal_text_tl
11014 \__msg_fatal_exit:
11015 }
11016 \cs_new_protected:Npn \__msg_fatal_exit:
11017 {
11018 \tex_batchmode:D
11019 \tex_read:D -1 to \l__msg_tmp_tl
11020 }
11021 \__msg_class_new:nn { critical }
11022 {
11023 \__msg_interrupt:NnnnN
11024 \msg_critical_text:n {#1} {#2}
11025 { {#3} {#4} {#5} {#6} }
11026 \c__msg_critical_text_tl
11027 \tex_endinput:D
11028 }
11029 \cs_undefine:N \msg_error:nnee
11030 \cs_undefine:N \msg_error:nne
11031 \cs_undefine:N \msg_error:nn
11032 \__msg_class_new:nn { error }
11033 {
11034 \__msg_interrupt:NnnnN
11035 \msg_error_text:n {#1} {#2}
11036 { {#3} {#4} {#5} {#6} }
11037 \c_empty_tl
11038 }
11039 \cs_new_protected:Npn \__msg_info_aux:NNnnnnnn #1#2#3#4#5#6#7#8
11040 {
11041 \str_set:Ne \l__msg_text_str { #2 {#3} }
11042 \str_set:Ne \l__msg_name_str { \msg_module_name:n {#3} }
11043 #1 { }
11044 \iow_wrap:nenN
11045 {
11046 \l__msg_text_str : ~
11047 \use:c { \c__msg_text_prefix_tl #3 / #4 } {#5} {#6} {#7} {#8}
11048 }
11049 {
11050 ( \l__msg_name_str )
11051 \prg_replicate:nn
11052 {
11053 \str_count:N \l__msg_text_str
11054 - \str_count:N \l__msg_name_str
11055 }
11056 { ~ }
11057 }
11058 { } #1
11059 #1 { }
11060 }
11061 \__msg_class_new:nn { warning }
11062 {
11063 \__msg_info_aux:NNnnnnnn \iow_term:n \msg_warning_text:n
11064 {#1} {#2} {#3} {#4} {#5} {#6}
11065 }
11066 \__msg_class_new:nn { note }
11067 {
11068 \__msg_info_aux:NNnnnnnn \iow_term:n \msg_info_text:n
11069 {#1} {#2} {#3} {#4} {#5} {#6}
11070 }
11071 \__msg_class_new:nn { info }
11072 {
11073 \__msg_info_aux:NNnnnnnn \iow_log:n \msg_info_text:n
11074 {#1} {#2} {#3} {#4} {#5} {#6}
11075 }
11076 \__msg_class_new:nn { log }
11077 {
11078 \iow_wrap:nnnN
11079 { \use:c { \c__msg_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
11080 { } { } \iow_log:n
11081 }
11082 \__msg_class_new:nn { term }
11083 {
11084 \iow_wrap:nnnN
11085 { \use:c { \c__msg_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
11086 { } { } \iow_term:n
11087 }
11088 \__msg_class_new:nn { none } { }
11089 \__msg_class_new:nn { show }
11090 {
11091 \iow_wrap:nnnN
11092 { \use:c { \c__msg_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
11093 { } { } \__msg_show:n
11094 }
11095 \cs_new_protected:Npn \__msg_show:n #1
11096 {
11097 \tl_if_in:nnTF { ^^J #1 } { ^^J > ~ }
11098 {
11099 \tl_if_in:nnTF { #1 \s__msg_mark } { . \s__msg_mark }
11100 { \__msg_show_dot:w } { \__msg_show:w }
11101 ^^J #1 \s__msg_stop
11102 }
11103 { \__msg_show:nn { ? #1 } { } }
11104 }
11105 \cs_new:Npn \__msg_show_dot:w #1 ^^J > ~ #2 . \s__msg_stop
11106 { \__msg_show:nn {#1} {#2} }
11107 \cs_new:Npn \__msg_show:w #1 ^^J > ~ #2 \s__msg_stop
11108 { \__msg_show:nn {#1} {#2} }
11109 \cs_new_protected:Npn \__msg_show:nn #1#2
11110 {
11111 \tl_if_empty:nF {#1}
11112 { \exp_args:No \iow_term:n { \use_none:n #1 } }
11113 \tl_set:Nn \l__msg_tmp_tl {#2}
11114 \__kernel_iow_with:Nnn \tex_newlinechar:D { 10 }
11115 {
11116 \__kernel_iow_with:Nnn \tex_errorcontextlines:D { -1 }
11117 {
11118 \tex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN
11119 { \exp_after:wN \l__msg_tmp_tl }
11120 }
11121 }
11122 }
11123 \group_end:
11124 \cs_new:Npe \msg_show_item:n #1
11125 { ^^J > ~ \c_space_tl \exp_not:N \tl_to_str:n { {#1} } }
11126 \cs_new:Npe \msg_show_item_unbraced:n #1
11127 { ^^J > ~ \c_space_tl \exp_not:N \tl_to_str:n {#1} }
11128 \cs_new:Npe \msg_show_item:nn #1#2
11129 {
11130 ^^J > \use:nn { ~ } { ~ }
11131 \exp_not:N \tl_to_str:n { {#1} }
11132 \use:nn { ~ } { ~ } => \use:nn { ~ } { ~ }
11133 \exp_not:N \tl_to_str:n { {#2} }
11134 }
11135 \cs_new:Npe \msg_show_item_unbraced:nn #1#2
11136 {
11137 ^^J > \use:nn { ~ } { ~ }
11138 \exp_not:N \tl_to_str:n {#1}
11139 \use:nn { ~ } { ~ } => \use:nn { ~ } { ~ }
11140 \exp_not:N \tl_to_str:n {#2}
11141 }
11142 \cs_new:Npn \__msg_class_chk_exist:nT #1
11143 {
11144 \cs_if_free:cTF { __msg_ #1 _code:nnnnnn }
11145 { \msg_error:nnn { msg } { class-unknown } {#1} }
11146 }
11147 \tl_new:N \l__msg_class_tl
11148 \tl_new:N \l__msg_current_class_tl
11149 \prop_new:N \l__msg_redirect_prop
11150 \seq_new:N \l__msg_hierarchy_seq
11151 \seq_new:N \l__msg_class_loop_seq
11152 \cs_new_protected:Npn \__msg_use:nnnnnnn #1#2#3#4#5#6#7
11153 {
11154 \cs_if_exist_use:N \conditionally@traceoff
11155 \msg_if_exist:nnTF {#2} {#3}
11156 {
11157 \__msg_class_chk_exist:nT {#1}
11158 {
11159 \tl_set:Nn \l__msg_current_class_tl {#1}
11160 \cs_set_protected:Npe \__msg_use_code:
11161 {
11162 \exp_not:n
11163 {
11164 \use:c { __msg_ \l__msg_class_tl _code:nnnnnn }
11165 {#2} {#3} {#4} {#5} {#6} {#7}
11166 }
11167 }
11168 \__msg_use_redirect_name:n { #2 / #3 }
11169 }
11170 }
11171 { \msg_error:nnnn { msg } { unknown } {#2} {#3} }
11172 \cs_if_exist_use:N \conditionally@traceon
11173 }
11174 \cs_new_protected:Npn \__msg_use_code: { }
11175 \cs_new_protected:Npn \__msg_use_redirect_name:n #1
11176 {
11177 \prop_get:NnNTF \l__msg_redirect_prop { / #1 } \l__msg_class_tl
11178 { \__msg_use_code: }
11179 {
11180 \seq_clear:N \l__msg_hierarchy_seq
11181 \__msg_use_hierarchy:nwwN { }
11182 #1 \s__msg_mark \__msg_use_hierarchy:nwwN
11183 / \s__msg_mark \__msg_use_none_delimit_by_s_stop:w
11184 \s__msg_stop
11185 \__msg_use_redirect_module:n { }
11186 }
11187 }
11188 \cs_new_protected:Npn \__msg_use_hierarchy:nwwN #1#2 / #3 \s__msg_mark #4
11189 {
11190 \seq_put_left:Nn \l__msg_hierarchy_seq {#1}
11191 #4 { #1 / #2 } #3 \s__msg_mark #4
11192 }
11193 \cs_new_protected:Npn \__msg_use_redirect_module:n #1
11194 {
11195 \seq_map_inline:Nn \l__msg_hierarchy_seq
11196 {
11197 \prop_get:cnNTF { l__msg_redirect_ \l__msg_current_class_tl _prop }
11198 {##1} \l__msg_class_tl
11199 {
11200 \seq_map_break:n
11201 {
11202 \tl_if_eq:NNTF \l__msg_current_class_tl \l__msg_class_tl
11203 { \__msg_use_code: }
11204 {
11205 \tl_set_eq:NN \l__msg_current_class_tl \l__msg_class_tl
11206 \__msg_use_redirect_module:n {##1}
11207 }
11208 }
11209 }
11210 {
11211 \str_if_eq:nnT {##1} {#1}
11212 {
11213 \tl_set_eq:NN \l__msg_class_tl \l__msg_current_class_tl
11214 \seq_map_break:n { \__msg_use_code: }
11215 }
11216 }
11217 }
11218 }
11219 \cs_new_protected:Npn \msg_redirect_name:nnn #1#2#3
11220 {
11221 \tl_if_empty:nTF {#3}
11222 { \prop_remove:Nn \l__msg_redirect_prop { / #1 / #2 } }
11223 {
11224 \__msg_class_chk_exist:nT {#3}
11225 { \prop_put:Nnn \l__msg_redirect_prop { / #1 / #2 } {#3} }
11226 }
11227 }
11228 \cs_new_protected:Npn \msg_redirect_class:nn
11229 { \__msg_redirect:nnn { } }
11230 \cs_new_protected:Npn \msg_redirect_module:nnn #1
11231 { \__msg_redirect:nnn { / #1 } }
11232 \cs_new_protected:Npn \__msg_redirect:nnn #1#2#3
11233 {
11234 \__msg_class_chk_exist:nT {#2}
11235 {
11236 \tl_if_empty:nTF {#3}
11237 { \prop_remove:cn { l__msg_redirect_ #2 _prop } {#1} }
11238 {
11239 \__msg_class_chk_exist:nT {#3}
11240 {
11241 \prop_put:cnn { l__msg_redirect_ #2 _prop } {#1} {#3}
11242 \tl_set:Nn \l__msg_current_class_tl {#2}
11243 \seq_clear:N \l__msg_class_loop_seq
11244 \__msg_redirect_loop_chk:nnn {#2} {#3} {#1}
11245 }
11246 }
11247 }
11248 }
11249 \cs_new_protected:Npn \__msg_redirect_loop_chk:nnn #1#2#3
11250 {
11251 \seq_put_right:Nn \l__msg_class_loop_seq {#1}
11252 \prop_get:cnNT { l__msg_redirect_ #1 _prop } {#3} \l__msg_class_tl
11253 {
11254 \str_if_eq:VnF \l__msg_class_tl {#1}
11255 {
11256 \tl_if_eq:NNTF \l__msg_class_tl \l__msg_current_class_tl
11257 {
11258 \prop_put:cnn { l__msg_redirect_ #2 _prop } {#3} {#2}
11259 \msg_warning:nneeee
11260 { msg } { redirect-loop }
11261 { \seq_item:Nn \l__msg_class_loop_seq { 1 } }
11262 { \seq_item:Nn \l__msg_class_loop_seq { 2 } }
11263 {#3}
11264 {
11265 \seq_map_function:NN \l__msg_class_loop_seq
11266 \__msg_redirect_loop_list:n
11267 { \seq_item:Nn \l__msg_class_loop_seq { 1 } }
11268 }
11269 }
11270 { \__msg_redirect_loop_chk:onn \l__msg_class_tl {#2} {#3} }
11271 }
11272 }
11273 }
11274 \cs_generate_variant:Nn \__msg_redirect_loop_chk:nnn { o }
11275 \cs_new:Npn \__msg_redirect_loop_list:n #1 { {#1} ~ => ~ }
11276 \cs_new_protected:Npn \__kernel_msg_show_eval:Nn #1#2
11277 { \exp_args:Nf \__msg_show_eval:nnN { #1 {#2} } {#2} \tl_show:n }
11278 \cs_new_protected:Npn \__kernel_msg_log_eval:Nn #1#2
11279 { \exp_args:Nf \__msg_show_eval:nnN { #1 {#2} } {#2} \tl_log:n }
11280 \cs_new_protected:Npn \__msg_show_eval:nnN #1#2#3 { #3 { #2 = #1 } }
11281 \cs_new_protected:Npn \__kernel_msg_new:nnnn #1
11282 { \msg_new:nnnn { LaTeX / #1 } }
11283 \cs_new_protected:Npn \__kernel_msg_new:nnn #1
11284 { \msg_new:nnn { LaTeX / #1 } }
11285 \cs_new_protected:Npn \__kernel_msg_info:nnxx #1
11286 { \msg_info:nnee { LaTeX / #1 } }
11287 \cs_new_protected:Npn \__kernel_msg_warning:nnx #1
11288 { \msg_warning:nne { LaTeX / #1 } }
11289 \cs_new_protected:Npn \__kernel_msg_warning:nnxx #1
11290 { \msg_warning:nnee { LaTeX / #1 } }
11291 \cs_new_protected:Npn \__kernel_msg_error:nnx #1
11292 { \msg_error:nne { LaTeX / #1 } }
11293 \cs_new_protected:Npn \__kernel_msg_error:nnxx #1
11294 { \msg_error:nnee { LaTeX / #1 } }
11295 \cs_new_protected:Npn \__kernel_msg_error:nnxxx #1
11296 { \msg_error:nneee { LaTeX / #1 } }
11297 \cs_new:Npn \__kernel_msg_expandable_error:nnn #1
11298 { \msg_expandable_error:nnn { LaTeX / #1 } }
11299 \cs_new:Npn \__kernel_msg_expandable_error:nnf #1
11300 { \msg_expandable_error:nnf { LaTeX / #1 } }
11301 \cs_new:Npn \__kernel_msg_expandable_error:nnff #1
11302 { \msg_expandable_error:nnff { LaTeX / #1 } }
11303 \msg_new:nnnn { msg } { already-defined }
11304 { Message~'#2'~for~module~'#1'~already~defined. }
11305 {
11306 \c__msg_coding_error_text_tl
11307 LaTeX~was~asked~to~define~a~new~message~called~'#2'\\
11308 by~the~module~'#1':~this~message~already~exists.
11309 \c__msg_return_text_tl
11310 }
11311 \msg_new:nnnn { msg } { unknown }
11312 { Unknown~message~'#2'~for~module~'#1'. }
11313 {
11314 \c__msg_coding_error_text_tl
11315 LaTeX~was~asked~to~display~a~message~called~'#2'\\
11316 by~the~module~'#1':~this~message~does~not~exist.
11317 \c__msg_return_text_tl
11318 }
11319 \msg_new:nnnn { msg } { class-unknown }
11320 { Unknown~message~class~'#1'. }
11321 {
11322 LaTeX~has~been~asked~to~redirect~messages~to~a~class~'#1':\\
11323 this~was~never~defined.
11324 \c__msg_return_text_tl
11325 }
11326 \msg_new:nnnn { msg } { redirect-loop }
11327 {
11328 Message~redirection~loop~caused~by~ {#1} ~=>~ {#2}
11329 \tl_if_empty:nF {#3} { ~for~module~' \use_none:n #3 ' } .
11330 }
11331 {
11332 Adding~the~message~redirection~ {#1} ~=>~ {#2}
11333 \tl_if_empty:nF {#3} { ~for~the~module~' \use_none:n #3 ' } ~
11334 created~an~infinite~loop\\\\
11335 \iow_indent:n { #4 \\\\ }
11336 }
11337 \msg_new:nnnn { kernel } { bad-number-of-arguments }
11338 { Function~'#1'~cannot~be~defined~with~#2~arguments. }
11339 {
11340 \c__msg_coding_error_text_tl
11341 LaTeX~has~been~asked~to~define~a~function~'#1'~with~
11342 #2~arguments.~
11343 TeX~allows~between~0~and~9~arguments~for~a~single~function.
11344 }
11345 \msg_new:nnnn { kernel } { command-already-defined }
11346 { Control~sequence~#1~already~defined. }
11347 {
11348 \c__msg_coding_error_text_tl
11349 LaTeX~has~been~asked~to~create~a~new~control~sequence~'#1'~
11350 but~this~name~has~already~been~used~elsewhere. \\ \\
11351 The~current~meaning~is:\\
11352 \ \ #2
11353 }
11354 \msg_new:nnnn { kernel } { command-not-defined }
11355 { Control~sequence~#1~undefined. }
11356 {
11357 \c__msg_coding_error_text_tl
11358 LaTeX~has~been~asked~to~use~a~control~sequence~'#1':\\
11359 this~has~not~been~defined~yet.
11360 }
11361 \msg_new:nnnn { kernel } { empty-search-pattern }
11362 { Empty~search~pattern. }
11363 {
11364 \c__msg_coding_error_text_tl
11365 LaTeX~has~been~asked~to~replace~an~empty~pattern~by~'#1':~that~
11366 would~lead~to~an~infinite~loop!
11367 }
11368 \msg_new:nnnn { kernel } { non-base-function }
11369 { Function~'#1'~is~not~a~base~function }
11370 {
11371 \c__msg_coding_error_text_tl
11372 Functions~defined~through~\iow_char:N\\cs_new:Nn~must~have~
11373 a~signature~consisting~of~only~normal~arguments~'N'~and~'n'.~
11374 The~signature~'#2'~of~'#1'~contains~other~arguments~'#3'.~
11375 To~define~variants~use~\iow_char:N\\cs_generate_variant:Nn~
11376 and~to~define~other~functions~use~\iow_char:N\\cs_new:Npn.
11377 }
11378 \msg_new:nnnn { kernel } { missing-colon }
11379 { Function~'#1'~contains~no~':'. }
11380 {
11381 \c__msg_coding_error_text_tl
11382 Code-level~functions~must~contain~':'~to~separate~the~
11383 argument~specification~from~the~function~name.~This~is~
11384 needed~when~defining~conditionals~or~variants,~or~when~building~a~
11385 parameter~text~from~the~number~of~arguments~of~the~function.
11386 }
11387 \msg_new:nnnn { kernel } { overflow }
11388 { Integers~larger~than~2^{30}-1~cannot~be~stored~in~arrays. }
11389 {
11390 An~attempt~was~made~to~store~#3~
11391 \tl_if_empty:nF {#2} { at~position~#2~ } in~the~array~'#1'.~
11392 The~largest~allowed~value~#4~will~be~used~instead.
11393 }
11394 \msg_new:nnnn { kernel } { out-of-bounds }
11395 { Access~to~an~entry~beyond~an~array's~bounds. }
11396 {
11397 An~attempt~was~made~to~access~or~store~data~at~position~#2~of~the~
11398 array~'#1',~but~this~array~has~entries~at~positions~from~1~to~#3.
11399 }
11400 \msg_new:nnnn { kernel } { protected-predicate }
11401 { Predicate~'#1'~must~be~expandable. }
11402 {
11403 \c__msg_coding_error_text_tl
11404 LaTeX~has~been~asked~to~define~'#1'~as~a~protected~predicate.~
11405 Only~expandable~tests~can~have~a~predicate~version.
11406 }
11407 \msg_new:nnn { kernel } { randint-backward-range }
11408 { Wrong~order~of~bounds~in~\iow_char:N\\int_rand:nn{#1}{#2}. }
11409 \msg_new:nnnn { kernel } { conditional-base-undefined }
11410 { Undefined~conditional~base~function~'#1'. }
11411 {
11412 \c__msg_coding_error_text_tl
11413 LaTeX~has~been~asked~to~define~a~variant~of~the~conditional~'#1',~
11414 but~the~latter~is~not~defined.
11415 }
11416 \msg_new:nnnn { kernel } { conditional-form-unknown }
11417 { Conditional~form~'#1'~for~function~'#2'~unknown. }
11418 {
11419 \c__msg_coding_error_text_tl
11420 LaTeX~has~been~asked~to~define~the~conditional~form~'#1'~of~
11421 the~function~'#2',~but~only~'TF',~'T',~'F',~and~'p'~forms~exist.
11422 }
11423 \msg_new:nnnn { kernel } { variant-same-as-base }
11424 { Variant~form~same~as~base~form~'#1'. }
11425 {
11426 \c__msg_coding_error_text_tl
11427 LaTeX~has~been~asked~to~create~a~variant~of~the~function~'#1'~
11428 with~the~same~signature.
11429 }
11430 \msg_new:nnnn { kernel } { variant-too-long }
11431 { Variant~form~'#1'~longer~than~base~signature~of~'#2'. }
11432 {
11433 \c__msg_coding_error_text_tl
11434 LaTeX~has~been~asked~to~create~a~variant~of~the~function~'#2'~
11435 with~a~signature~starting~with~'#1',~but~that~is~longer~than~
11436 the~signature~(part~after~the~colon)~of~'#2'.
11437 }
11438 \msg_new:nnnn { kernel } { invalid-variant }
11439 { Variant~form~'#1'~invalid~for~base~form~'#2'. }
11440 {
11441 \c__msg_coding_error_text_tl
11442 LaTeX~has~been~asked~to~create~a~variant~of~the~function~'#2'~
11443 with~a~signature~starting~with~'#1',~but~cannot~change~an~argument~
11444 from~type~'#3'~to~type~'#4'.
11445 }
11446 \msg_new:nnnn { kernel } { invalid-exp-args }
11447 { Invalid~variant~specifier~'#1'~in~'#2'. }
11448 {
11449 \c__msg_coding_error_text_tl
11450 LaTeX~has~been~asked~to~create~an~\iow_char:N\\exp_args:N...~
11451 function~with~signature~'N#2'~but~'#1'~is~not~a~valid~argument~
11452 specifier.
11453 }
11454 \msg_new:nnn { kernel } { deprecated-variant }
11455 {
11456 Variant~form~'#1'~deprecated~for~base~form~'#2'.~
11457 One~should~not~change~an~argument~from~type~'#3'~to~type~'#4'
11458 \str_case:nnF {#3}
11459 {
11460 { n } { :~use~a~'\token_if_eq_charcode:NNTF #4 c v V'~variant? }
11461 { N } { :~base~form~only~accepts~a~single~token~argument. }
11462 {#4} { :~base~form~is~already~a~variant. }
11463 } { . }
11464 }
11465 \msg_new:nnn { char } { active }
11466 { Cannot~generate~active~chars. }
11467 \msg_new:nnn { char } { invalid-catcode }
11468 { Invalid~catcode~for~char~generation. }
11469 \msg_new:nnn { char } { null-space }
11470 { Cannot~generate~null~char~as~a~space. }
11471 \msg_new:nnn { char } { out-of-range }
11472 { Charcode~requested~out~of~engine~range. }
11473 \msg_new:nnn { dim } { zero-unit }
11474 { Zero~unit~in~conversion. }
11475 \msg_new:nnnn { kernel } { quote-in-shell }
11476 { Quotes~in~shell~command~'#1'. }
11477 { Shell~commands~cannot~contain~quotes~("). }
11478 \msg_new:nnnn { keys } { no-property }
11479 { No~property~given~in~definition~of~key~'#1'. }
11480 {
11481 \c__msg_coding_error_text_tl
11482 Inside~\keys_define:nn each~key~name~
11483 needs~a~property: \\ \\
11484 \iow_indent:n { #1 .<property> } \\ \\
11485 LaTeX~did~not~find~a~'.'~to~indicate~the~start~of~a~property.
11486 }
11487 \msg_new:nnnn { keys } { property-boolean-values-only }
11488 { The~property~'#1'~accepts~boolean~values~only. }
11489 {
11490 \c__msg_coding_error_text_tl
11491 The~property~'#1'~only~accepts~the~values~'true'~and~'false'.
11492 }
11493 \msg_new:nnnn { keys } { property-requires-value }
11494 { The~property~'#1'~requires~a~value. }
11495 {
11496 \c__msg_coding_error_text_tl
11497 LaTeX~was~asked~to~set~property~'#1'~for~key~'#2'.\\
11498 No~value~was~given~for~the~property,~and~one~is~required.
11499 }
11500 \msg_new:nnnn { keys } { property-unknown }
11501 { The~key~property~'#1'~is~unknown. }
11502 {
11503 \c__msg_coding_error_text_tl
11504 LaTeX~has~been~asked~to~set~the~property~'#1'~for~key~'#2':~
11505 this~property~is~not~defined.
11506 }
11507 \msg_new:nnnn { quark } { invalid-function }
11508 { Quark~test~function~'#1'~is~invalid. }
11509 {
11510 \c__msg_coding_error_text_tl
11511 LaTeX~has~been~asked~to~create~quark~test~function~'#1'~
11512 \tl_if_empty:nTF {#2}
11513 { but~that~name~ }
11514 { with~signature~'#2',~but~that~signature~ }
11515 is~not~valid.
11516 }
11517 \__kernel_msg_new:nnn { quark } { invalid }
11518 { Invalid~quark~variable~'#1'. }
11519 \msg_new:nnnn { scanmark } { already-defined }
11520 { Scan~mark~#1~already~defined. }
11521 {
11522 \c__msg_coding_error_text_tl
11523 LaTeX~has~been~asked~to~create~a~new~scan~mark~'#1'~
11524 but~this~name~has~already~been~used~for~a~scan~mark.
11525 }
11526 \msg_new:nnnn { seq } { item-too-large }
11527 { Sequence~'#1'~does~not~have~an~item~#3 }
11528 {
11529 An~attempt~was~made~to~push~or~pop~the~item~at~position~#3~
11530 of~'#1',~but~this~
11531 \int_compare:nTF { #3 = 0 }
11532 { position~does~not~exist. }
11533 { sequence~only~has~#2~item \int_compare:nF { #2 = 1 } {s}. }
11534 }
11535 \msg_new:nnnn { seq } { shuffle-too-large }
11536 { The~sequence~#1~is~too~long~to~be~shuffled~by~TeX. }
11537 {
11538 TeX~has~ \int_eval:n { \c_max_register_int + 1 } ~
11539 toks~registers:~this~only~allows~to~shuffle~up~to~
11540 \int_use:N \c_max_register_int \ items.~
11541 The~list~will~not~be~shuffled.
11542 }
11543 \msg_new:nnnn { kernel } { variable-not-defined }
11544 { Variable~#1~undefined. }
11545 {
11546 \c__msg_coding_error_text_tl
11547 LaTeX~has~been~asked~to~show~a~variable~#1,~but~this~has~not~
11548 been~defined~yet.
11549 }
11550 \msg_new:nnnn { kernel } { bad-type }
11551 { Variable~'#1'~is~not~a~valid~#3. }
11552 {
11553 \c__msg_coding_error_text_tl
11554 The~variable~'#1'~with~\tl_if_empty:nTF {#4} {meaning} {value}\\\\
11555 \iow_indent:n {#2}\\\\
11556 should~be~a~#3~variable,~but~
11557 \tl_if_empty:nTF {#4}
11558 { it~is~not \str_if_eq:nnF {#3} { bool } { ~a~short~macro } . }
11559 {
11560 it~does~not~have~the~correct~
11561 \str_if_eq:nnTF {#2} {#4}
11562 { category~codes. }
11563 { internal~structure:\\\\\iow_indent:n {#4} }
11564 }
11565 }
11566 \msg_new:nnnn { prop } { bad-link }
11567 { Variable~'#1'~is~not~a~valid~(linked)~prop. }
11568 {
11569 \c__msg_coding_error_text_tl
11570 The~variable~'#1'~has~an~incorrect~internal~structure.~
11571 Its~internal~entry~'#2'~points~to~'#3',~whose~name~is~not~of~the~
11572 form~'#4~<key>'.
11573 }
11574 \msg_new:nnnn { clist } { non-clist }
11575 { Variable~'#1'~is~not~a~valid~clist. }
11576 {
11577 \c__msg_coding_error_text_tl
11578 The~variable~'#1'~with~value\\\\
11579 \iow_indent:n {#2}\\\\
11580 should~be~a~clist~variable,~but~it~includes~empty~or~blank~items~
11581 without~braces.
11582 }
11583 \msg_new:nnnn { prop } { misused }
11584 { A~property~list~was~misused. }
11585 {
11586 \c__msg_coding_error_text_tl
11587 A~property~list~variable~was~used~without~an~accessor~function.~
11588 It~
11589 \tl_if_empty:nTF {#1}
11590 { is~empty. }
11591 { contains~the~key-value~pairs \use_none:n #1 . }
11592 }
11593 \msg_new:nnnn { prop } { inner-make }
11594 { '#1'~ cannot~ be~ used~ in~ a~ group. }
11595 {
11596 \c__msg_coding_error_text_tl
11597 The~ command~ '#1'~ was~ applied~ to~ the~ property~ list~
11598 variable~ '#2', but~ the~ storage~ type~ can~ only~ be~ changed~
11599 at~ the~ outermost~ group~ level.
11600 }
11601 \msg_new:nnn { kernel } { bad-exp-end-f }
11602 { Misused~\exp_end_continue_f:w or~:nw }
11603 \msg_new:nnn { kernel } { bad-variable }
11604 { Erroneous~variable~#1 used! }
11605 \msg_new:nnn { seq } { misused }
11606 { A~sequence~was~misused. }
11607 \msg_new:nnn { prg } { negative-replication }
11608 { Negative~argument~for~\iow_char:N\\prg_replicate:nn. }
11609 \msg_new:nnn { prop } { prop-keyval }
11610 { Missing~'='~in~'#1'~(in~'..._keyval:Nn') }
11611 \msg_new:nnn { kernel } { unknown-comparison }
11612 { Relation~'#1'~not~among~=,<,>,==,!=,<=,>=. }
11613 \msg_new:nnn { kernel } { zero-step }
11614 { Zero~step~size~for~function~#1. }
11615 \msg_new:nnn { clist } { show }
11616 {
11617 The~comma~list~ \tl_if_empty:nF {#1} { #1 ~ }
11618 \tl_if_empty:nTF {#2}
11619 { is~empty \\>~ . }
11620 { contains~the~items~(without~outer~braces): #2 . }
11621 }
11622 \msg_new:nnn { intarray } { show }
11623 { The~integer~array~#1~contains~#2~items: \\ #3 . }
11624 \msg_new:nnn { prop } { show }
11625 {
11626 The~ \str_if_eq:nnF {#3} { flat } { #3~ }
11627 property~list~#1~
11628 \tl_if_empty:nTF {#2}
11629 { is~empty \\>~ . }
11630 { contains~the~pairs~(without~outer~braces): #2 . }
11631 }
11632 \msg_new:nnn { seq } { show }
11633 {
11634 The~sequence~#1~
11635 \tl_if_empty:nTF {#2}
11636 { is~empty \\>~ . }
11637 { contains~the~items~(without~outer~braces): #2 . }
11638 }
11639 \msg_new:nnn { kernel } { show-streams }
11640 {
11641 \tl_if_empty:nTF {#2} { No~ } { The~following~ }
11642 \str_case:nn {#1}
11643 {
11644 { ior } { input ~ }
11645 { iow } { output ~ }
11646 }
11647 streams~are~
11648 \tl_if_empty:nTF {#2} { open } { in~use: #2 . }
11649 }
11650 \msg_new:nnnn { sys } { backend-set }
11651 { Backend~configuration~already~set. }
11652 {
11653 Run-time~backend~selection~may~only~be~carried~out~once~during~a~run.~
11654 This~second~attempt~to~set~them~will~be~ignored.
11655 }
11656 \msg_new:nnnn { sys } { load-debug-in-preamble }
11657 { Load~debug~support~in~the~preamble. }
11658 {
11659 Debugging~requires~support~loaded~in~the~preamble: \\
11660 Use~\sys_load_debug:~before~\begin{document}.
11661 }
11662 \msg_new:nnnn { sys } { wrong-backend }
11663 { Backend~request~inconsistent~with~engine:~using~'#2'~backend. }
11664 {
11665 You~have~requested~backend~'#1',~but~this~is~not~suitable~for~use~with~the~
11666 active~engine.~LaTeX~will~use~the~'#2'~backend~instead.
11667 }
11668 \cs_set_protected:Npn \__msg_tmp:w #1
11669 {
11670 \cs_new:Npn #1 ? { }
11671 \cs_new:Npn \__kernel_msg_expandable_error:nn ##1##2
11672 {
11673 \exp_after:wN \exp_after:wN
11674 \exp_after:wN \__msg_use_none_delimit_by_s_stop:w
11675 \use:n { #1 ~ ! ~ ##2 : ~ ##1 } \s__msg_stop
11676 }
11677 }
11678 \exp_args:Nc \__msg_tmp:w { ??? }
11679 \exp_args_generate:n { oooo }
11680 \cs_new:Npn \msg_expandable_error:nnnnnn #1#2#3#4#5#6
11681 {
11682 \exp_args:Nee \__kernel_msg_expandable_error:nn
11683 {
11684 \exp_args:Nc \exp_args:Noooo
11685 { \c__msg_text_prefix_tl #1 / #2 }
11686 { \tl_to_str:n {#3} }
11687 { \tl_to_str:n {#4} }
11688 { \tl_to_str:n {#5} }
11689 { \tl_to_str:n {#6} }
11690 }
11691 { \msg_error_text:n {#1} }
11692 }
11693 \cs_new:Npn \msg_expandable_error:nnnnn #1#2#3#4#5
11694 { \msg_expandable_error:nnnnnn {#1} {#2} {#3} {#4} {#5} { } }
11695 \cs_new:Npn \msg_expandable_error:nnnn #1#2#3#4
11696 { \msg_expandable_error:nnnnnn {#1} {#2} {#3} {#4} { } { } }
11697 \cs_new:Npn \msg_expandable_error:nnn #1#2#3
11698 { \msg_expandable_error:nnnnnn {#1} {#2} {#3} { } { } { } }
11699 \cs_new:Npn \msg_expandable_error:nn #1#2
11700 { \msg_expandable_error:nnnnnn {#1} {#2} { } { } { } { } }
11701 \cs_generate_variant:Nn \msg_expandable_error:nnnnnn { nneeee , nnffff }
11702 \cs_generate_variant:Nn \msg_expandable_error:nnnnn { nneee , nnfff }
11703 \cs_generate_variant:Nn \msg_expandable_error:nnnn { nnee , nnff }
11704 \cs_generate_variant:Nn \msg_expandable_error:nnn { nne , nnf }
11705 \prop_gput:Nnn \g_msg_module_name_prop { kernel } { LaTeX }
11706 \prop_gput:Nnn \g_msg_module_type_prop { kernel } { }
11707 \clist_map_inline:nn
11708 {
11709 char , clist , coffin , debug , deprecation , dim, msg ,
11710 quark , prg , prop , scanmark , seq , sys
11711 }
11712 {
11713 \prop_gput:Nnn \g_msg_module_name_prop {#1} { LaTeX }
11714 \prop_gput:Nnn \g_msg_module_type_prop {#1} { }
11715 }
11716 \prop_gput:Nnn \g_msg_module_name_prop { LaTeX / cmd } { LaTeX }
11717 \prop_gput:Nnn \g_msg_module_type_prop { LaTeX / cmd } { }
11718 \prop_gput:Nnn \g_msg_module_name_prop { LaTeX / ltcmd } { LaTeX }
11719 \prop_gput:Nnn \g_msg_module_type_prop { LaTeX / ltcmd } { }
11720 %% File: l3file.dtx
11721 \tl_new:N \l__ior_tmp_tl
11722 \int_const:Nn \c__ior_term_ior { 16 }
11723 \seq_new:N \g__ior_streams_seq
11724 \tl_new:N \l__ior_stream_tl
11725 \prop_new:N \g__ior_streams_prop
11726 \int_step_inline:nnn
11727 { 0 }
11728 {
11729 \cs_if_exist:NTF \contextversion
11730 { \tex_count:D 38 ~ }
11731 {
11732 \tex_count:D 16 ~ %
11733 \cs_if_exist:NT \loccount { - 1 }
11734 }
11735 }
11736 {
11737 \prop_gput:Nnn \g__ior_streams_prop {#1} { Reserved~by~format }
11738 }
11739 \cs_new_protected:Npn \ior_new:N #1 { \cs_new_eq:NN #1 \c__ior_term_ior }
11740 \cs_generate_variant:Nn \ior_new:N { c }
11741 \ior_new:N \g_tmpa_ior
11742 \ior_new:N \g_tmpb_ior
11743 \cs_new_protected:Npn \ior_open:Nn #1#2
11744 { \ior_open:NnF #1 {#2} { \__kernel_file_missing:n {#2} } }
11745 \cs_generate_variant:Nn \ior_open:Nn { c }
11746 \tl_new:N \l__ior_file_name_tl
11747 \prg_new_protected_conditional:Npnn \ior_open:Nn #1#2 { T , F , TF }
11748 {
11749 \file_get_full_name:nNTF {#2} \l__ior_file_name_tl
11750 {
11751 \__kernel_ior_open:No #1 \l__ior_file_name_tl
11752 \prg_return_true:
11753 }
11754 { \prg_return_false: }
11755 }
11756 \prg_generate_conditional_variant:Nnn \ior_open:Nn { c } { T , F , TF }
11757 \exp_args:NNf \cs_new_protected:Npn \__ior_new:N
11758 { \exp_args:NNc \exp_after:wN \exp_stop_f: { newread } }
11759 \cs_if_exist:NT \contextversion
11760 {
11761 \cs_new_eq:NN \__ior_new_aux:N \__ior_new:N
11762 \cs_gset_protected:Npn \__ior_new:N #1
11763 {
11764 \cs_undefine:N #1
11765 \__ior_new_aux:N #1
11766 }
11767 }
11768 \cs_new_protected:Npn \__kernel_ior_open:Nn #1#2
11769 {
11770 \ior_close:N #1
11771 \seq_gpop:NNTF \g__ior_streams_seq \l__ior_stream_tl
11772 { \__ior_open_stream:Nn #1 {#2} }
11773 {
11774 \__ior_new:N #1
11775 \__kernel_tl_set:Nx \l__ior_stream_tl { \int_eval:n {#1} }
11776 \__ior_open_stream:Nn #1 {#2}
11777 }
11778 }
11779 \cs_generate_variant:Nn \__kernel_ior_open:Nn { No }
11780 \cs_new_protected:Npe \__ior_open_stream:Nn #1#2
11781 {
11782 \tex_global:D \tex_chardef:D #1 = \exp_not:N \l__ior_stream_tl \scan_stop:
11783 \prop_gput:NVn \exp_not:N \g__ior_streams_prop #1 {#2}
11784 \tex_openin:D #1
11785 \sys_if_engine_luatex:TF
11786 { {#2} }
11787 { \exp_not:N \__kernel_file_name_quote:n {#2} \scan_stop: }
11788 }
11789 \cs_new_protected:Npn \ior_shell_open:Nn #1#2
11790 {
11791 \sys_if_shell:TF
11792 { \__ior_shell_open:oN { \tl_to_str:n {#2} } #1 }
11793 { \msg_error:nn { kernel } { pipe-failed } }
11794 }
11795 \cs_new_protected:Npn \__ior_shell_open:nN #1#2
11796 {
11797 \tl_if_in:nnTF {#1} { " }
11798 {
11799 \msg_error:nne
11800 { kernel } { quote-in-shell } {#1}
11801 }
11802 { \__kernel_ior_open:Nn #2 { |#1 } }
11803 }
11804 \cs_generate_variant:Nn \__ior_shell_open:nN { o }
11805 \msg_new:nnnn { kernel } { pipe-failed }
11806 { Cannot~run~piped~system~commands. }
11807 {
11808 LaTeX~tried~to~call~a~system~process~but~this~was~not~possible.\\
11809 Try~the~"--shell-escape"~(or~"--enable-pipes")~option.
11810 }
11811 \cs_new_protected:Npn \ior_close:N #1
11812 {
11813 \int_compare:nT { -1 < #1 < \c__ior_term_ior }
11814 {
11815 \tex_closein:D #1
11816 \prop_gremove:NV \g__ior_streams_prop #1
11817 \seq_if_in:NVF \g__ior_streams_seq #1
11818 { \seq_gpush:NV \g__ior_streams_seq #1 }
11819 \cs_gset_eq:NN #1 \c__ior_term_ior
11820 }
11821 }
11822 \cs_generate_variant:Nn \ior_close:N { c }
11823 \cs_new_protected:Npn \ior_show:N { \__ior_show:NN \tl_show:n }
11824 \cs_generate_variant:Nn \ior_show:N { c }
11825 \cs_new_protected:Npn \ior_log:N { \__ior_show:NN \tl_log:n }
11826 \cs_generate_variant:Nn \ior_log:N { c }
11827 \cs_new_protected:Npn \__ior_show:NN #1#2
11828 {
11829 \__kernel_chk_defined:NT #2
11830 {
11831 \prop_get:NVNTF \g__ior_streams_prop #2 \l__ior_tmp_tl
11832 {
11833 \exp_args:Ne #1
11834 { \token_to_str:N #2 ~ open: ~ \l__ior_tmp_tl }
11835 }
11836 { \exp_args:Ne #1 { \token_to_str:N #2 ~ closed } }
11837 }
11838 }
11839 \cs_new_protected:Npn \ior_show_list: { \__ior_list:N \msg_show:nneeee }
11840 \cs_new_protected:Npn \ior_log_list: { \__ior_list:N \msg_log:nneeee }
11841 \cs_new_protected:Npn \__ior_list:N #1
11842 {
11843 #1 { kernel } { show-streams }
11844 { ior }
11845 {
11846 \prop_map_function:NN \g__ior_streams_prop
11847 \msg_show_item_unbraced:nn
11848 }
11849 { } { }
11850 }
11851 \cs_new_eq:NN \if_eof:w \tex_ifeof:D
11852 \prg_new_conditional:Npnn \ior_if_eof:N #1 { p , T , F , TF }
11853 {
11854 \if_int_compare:w -1 < #1
11855 \if_int_compare:w #1 < \c__ior_term_ior
11856 \if_eof:w #1
11857 \prg_return_true:
11858 \else:
11859 \prg_return_false:
11860 \fi:
11861 \else:
11862 \prg_return_true:
11863 \fi:
11864 \else:
11865 \prg_return_true:
11866 \fi:
11867 }
11868 \cs_new_protected:Npn \ior_get:NN #1#2
11869 { \ior_get:NNF #1 #2 { \tl_set:Nn #2 { \q_no_value } } }
11870 \cs_new_protected:Npn \__ior_get:NN #1#2
11871 { \tex_read:D #1 to #2 }
11872 \prg_new_protected_conditional:Npnn \ior_get:NN #1#2 { T , F , TF }
11873 {
11874 \ior_if_eof:NTF #1
11875 { \prg_return_false: }
11876 {
11877 \__ior_get:NN #1 #2
11878 \prg_return_true:
11879 }
11880 }
11881 \cs_new_protected:Npn \ior_str_get:NN #1#2
11882 { \ior_str_get:NNF #1 #2 { \tl_set:Nn #2 { \q_no_value } } }
11883 \cs_new_protected:Npn \__ior_str_get:NN #1#2
11884 {
11885 \exp_args:Nno \use:n
11886 {
11887 \int_set:Nn \tex_endlinechar:D { -1 }
11888 \tex_readline:D #1 to #2
11889 \int_set:Nn \tex_endlinechar:D
11890 } { \int_use:N \tex_endlinechar:D }
11891 }
11892 \prg_new_protected_conditional:Npnn \ior_str_get:NN #1#2 { T , F , TF }
11893 {
11894 \ior_if_eof:NTF #1
11895 { \prg_return_false: }
11896 {
11897 \__ior_str_get:NN #1 #2
11898 \prg_return_true:
11899 }
11900 }
11901 \int_const:Nn \c__ior_term_noprompt_ior { -1 }
11902 \cs_new_protected:Npn \ior_get_term:nN #1#2
11903 { \__ior_get_term:NnN \__ior_get:NN {#1} #2 }
11904 \cs_new_protected:Npn \ior_str_get_term:nN #1#2
11905 { \__ior_get_term:NnN \__ior_str_get:NN {#1} #2 }
11906 \cs_new_protected:Npn \__ior_get_term:NnN #1#2#3
11907 {
11908 \group_begin:
11909 \tex_escapechar:D = -1 \scan_stop:
11910 \tl_if_blank:nTF {#2}
11911 { \exp_args:NNc #1 \c__ior_term_noprompt_ior }
11912 { \exp_args:NNc #1 \c__ior_term_ior }
11913 {#2}
11914 \exp_args:NNNv \group_end:
11915 \tl_set:Nn #3 {#2}
11916 }
11917 \cs_new:Npn \ior_map_break:
11918 { \prg_map_break:Nn \ior_map_break: { } }
11919 \cs_new:Npn \ior_map_break:n
11920 { \prg_map_break:Nn \ior_map_break: }
11921 \cs_new_protected:Npn \ior_map_inline:Nn
11922 { \__ior_map_inline:NNn \__ior_get:NN }
11923 \cs_new_protected:Npn \ior_str_map_inline:Nn
11924 { \__ior_map_inline:NNn \__ior_str_get:NN }
11925 \cs_new_protected:Npn \__ior_map_inline:NNn
11926 {
11927 \int_gincr:N \g__kernel_prg_map_int
11928 \exp_args:Nc \__ior_map_inline:NNNn
11929 { __ior_map_ \int_use:N \g__kernel_prg_map_int :n }
11930 }
11931 \cs_new_protected:Npn \__ior_map_inline:NNNn #1#2#3#4
11932 {
11933 \cs_gset_protected:Npn #1 ##1 {#4}
11934 \ior_if_eof:NF #3 { \__ior_map_inline_loop:NNN #1#2#3 }
11935 \prg_break_point:Nn \ior_map_break:
11936 { \int_gdecr:N \g__kernel_prg_map_int }
11937 }
11938 \cs_new_protected:Npn \__ior_map_inline_loop:NNN #1#2#3
11939 {
11940 #2 #3 \l__ior_tmp_tl
11941 \if_eof:w #3
11942 \exp_after:wN \ior_map_break:
11943 \fi:
11944 \exp_args:No #1 \l__ior_tmp_tl
11945 \__ior_map_inline_loop:NNN #1#2#3
11946 }
11947 \cs_new_protected:Npn \ior_map_variable:NNn
11948 { \__ior_map_variable:NNNn \ior_get:NN }
11949 \cs_new_protected:Npn \ior_str_map_variable:NNn
11950 { \__ior_map_variable:NNNn \ior_str_get:NN }
11951 \cs_new_protected:Npn \__ior_map_variable:NNNn #1#2#3#4
11952 {
11953 \ior_if_eof:NF #2 { \__ior_map_variable_loop:NNNn #1#2#3 {#4} }
11954 \prg_break_point:Nn \ior_map_break: { }
11955 }
11956 \cs_new_protected:Npn \__ior_map_variable_loop:NNNn #1#2#3#4
11957 {
11958 #1 #2 #3
11959 \if_eof:w #2
11960 \exp_after:wN \ior_map_break:
11961 \fi:
11962 #4
11963 \__ior_map_variable_loop:NNNn #1#2#3 {#4}
11964 }
11965 \tl_new:N \l__iow_tmp_tl
11966 \int_const:Nn \c_log_iow { -1 }
11967 \int_const:Nn \c_term_iow
11968 {
11969 \bool_lazy_and:nnTF
11970 { \sys_if_engine_luatex_p: }
11971 { \int_compare_p:nNn \tex_luatexversion:D > { 80 } }
11972 { 128 }
11973 { 16 }
11974 }
11975 \seq_new:N \g__iow_streams_seq
11976 \tl_new:N \l__iow_stream_tl
11977 \prop_new:N \g__iow_streams_prop
11978 \int_step_inline:nnn
11979 { 0 }
11980 {
11981 \cs_if_exist:NTF \contextversion
11982 { \tex_count:D 39 ~ }
11983 {
11984 \tex_count:D 17 ~
11985 \cs_if_exist:NT \loccount { - 1 }
11986 }
11987 }
11988 {
11989 \prop_gput:Nnn \g__iow_streams_prop {#1} { Reserved~by~format }
11990 }
11991 \scan_new:N \s__iow_mark
11992 \scan_new:N \s__iow_stop
11993 \cs_new:Npn \__iow_use_i_delimit_by_s_stop:nw #1 #2 \s__iow_stop {#1}
11994 \quark_new:N \q__iow_nil
11995 \cs_new_protected:Npn \iow_new:N #1 { \cs_new_eq:NN #1 \c_term_iow }
11996 \cs_generate_variant:Nn \iow_new:N { c }
11997 \iow_new:N \g_tmpa_iow
11998 \iow_new:N \g_tmpb_iow
11999 \exp_args:NNf \cs_new_protected:Npn \__iow_new:N
12000 { \exp_args:NNc \exp_after:wN \exp_stop_f: { newwrite } }
12001 \cs_if_exist:NT \contextversion
12002 {
12003 \cs_new_eq:NN \__iow_new_aux:N \__iow_new:N
12004 \cs_gset_protected:Npn \__iow_new:N #1
12005 {
12006 \cs_undefine:N #1
12007 \__iow_new_aux:N #1
12008 }
12009 }
12010 \tl_new:N \l__iow_file_name_tl
12011 \cs_new_protected:Npn \iow_open:Nn #1#2
12012 {
12013 \__kernel_tl_set:Nx \l__iow_file_name_tl
12014 { \__kernel_file_name_sanitize:n {#2} }
12015 \__kernel_iow_open:No #1 \l__iow_file_name_tl
12016 }
12017 \cs_generate_variant:Nn \iow_open:Nn { NV , c , cV }
12018 \cs_new_protected:Npn \__kernel_iow_open:Nn #1#2
12019 {
12020 \iow_close:N #1
12021 \seq_gpop:NNTF \g__iow_streams_seq \l__iow_stream_tl
12022 { \__iow_open_stream:Nn #1 {#2} }
12023 {
12024 \__iow_new:N #1
12025 \__kernel_tl_set:Nx \l__iow_stream_tl { \int_eval:n {#1} }
12026 \__iow_open_stream:Nn #1 {#2}
12027 }
12028 }
12029 \cs_generate_variant:Nn \__kernel_iow_open:Nn { No }
12030 \cs_new_protected:Npn \__iow_open_stream:Nn #1#2
12031 {
12032 \tex_global:D \tex_chardef:D #1 = \l__iow_stream_tl \scan_stop:
12033 \prop_gput:NVn \g__iow_streams_prop #1 {#2}
12034 \tex_immediate:D \tex_openout:D
12035 #1 \__kernel_file_name_quote:n {#2} \scan_stop:
12036 }
12037 \cs_generate_variant:Nn \__iow_open_stream:Nn { NV }
12038 \cs_new_protected:Npn \iow_shell_open:Nn #1#2
12039 {
12040 \sys_if_shell:TF
12041 { \__iow_shell_open:oN { \tl_to_str:n {#2} } #1 }
12042 { \msg_error:nn { kernel } { pipe-failed } }
12043 }
12044 \cs_new_protected:Npn \__iow_shell_open:nN #1#2
12045 {
12046 \tl_if_in:nnTF {#1} { " }
12047 {
12048 \msg_error:nne
12049 { kernel } { quote-in-shell } {#1}
12050 }
12051 { \__kernel_iow_open:Nn #2 { |#1 } }
12052 }
12053 \cs_generate_variant:Nn \__iow_shell_open:nN { o }
12054 \cs_new_protected:Npn \iow_close:N #1
12055 {
12056 \int_compare:nT { \c_log_iow < #1 < \c_term_iow }
12057 {
12058 \tex_immediate:D \tex_closeout:D #1
12059 \prop_gremove:NV \g__iow_streams_prop #1
12060 \seq_if_in:NVF \g__iow_streams_seq #1
12061 { \seq_gpush:NV \g__iow_streams_seq #1 }
12062 \cs_gset_eq:NN #1 \c_term_iow
12063 }
12064 }
12065 \cs_generate_variant:Nn \iow_close:N { c }
12066 \cs_new_protected:Npn \iow_show:N { \__iow_show:NN \tl_show:n }
12067 \cs_generate_variant:Nn \iow_show:N { c }
12068 \cs_new_protected:Npn \iow_log:N { \__iow_show:NN \tl_log:n }
12069 \cs_generate_variant:Nn \iow_log:N { c }
12070 \cs_new_protected:Npn \__iow_show:NN #1#2
12071 {
12072 \__kernel_chk_defined:NT #2
12073 {
12074 \prop_get:NVNTF \g__iow_streams_prop #2 \l__iow_tmp_tl
12075 {
12076 \exp_args:Ne #1
12077 { \token_to_str:N #2 ~ open: ~ \l__iow_tmp_tl }
12078 }
12079 { \exp_args:Ne #1 { \token_to_str:N #2 ~ closed } }
12080 }
12081 }
12082 \cs_new_protected:Npn \iow_show_list: { \__iow_list:N \msg_show:nneeee }
12083 \cs_new_protected:Npn \iow_log_list: { \__iow_list:N \msg_log:nneeee }
12084 \cs_new_protected:Npn \__iow_list:N #1
12085 {
12086 #1 { kernel } { show-streams }
12087 { iow }
12088 {
12089 \prop_map_function:NN \g__iow_streams_prop
12090 \msg_show_item_unbraced:nn
12091 }
12092 { } { }
12093 }
12094 \cs_new_protected:Npn \iow_shipout_e:Nn #1#2
12095 { \tex_write:D #1 {#2} }
12096 \cs_generate_variant:Nn \iow_shipout_e:Nn { Ne , c, ce }
12097 \cs_new_protected:Npn \iow_shipout:Nn #1#2
12098 { \tex_write:D #1 { \exp_not:n {#2} } }
12099 \cs_generate_variant:Nn \iow_shipout:Nn { Ne , c, ce }
12100 \cs_generate_variant:Nn \iow_shipout:Nn { Nx , cx }
12101 \cs_new_protected:Npn \__kernel_iow_with:Nnn #1#2
12102 {
12103 \int_compare:nNnTF {#1} = {#2}
12104 { \use:n }
12105 { \__iow_with:oNnn { \int_use:N #1 } #1 {#2} }
12106 }
12107 \cs_new_protected:Npn \__iow_with:nNnn #1#2#3#4
12108 {
12109 \int_set:Nn #2 {#3}
12110 #4
12111 \int_set:Nn #2 {#1}
12112 }
12113 \cs_generate_variant:Nn \__iow_with:nNnn { o }
12114 \cs_new_protected:Npn \iow_now:Nn #1#2
12115 {
12116 \__kernel_iow_with:Nnn \tex_newlinechar:D { `\^^J }
12117 { \tex_immediate:D \tex_write:D #1 { \exp_not:n {#2} } }
12118 }
12119 \cs_generate_variant:Nn \iow_now:Nn { NV , Ne , c , cV , ce }
12120 \cs_generate_variant:Nn \iow_now:Nn { Nx , cx }
12121 \cs_new_protected:Npn \iow_log:n { \iow_now:Nn \c_log_iow }
12122 \cs_new_protected:Npn \iow_log:e { \iow_now:Ne \c_log_iow }
12123 \cs_generate_variant:Nn \iow_log:n { x }
12124 \cs_new_protected:Npn \iow_show:n { \iow_now:Nn \tex_showstream:D }
12125 \cs_new_protected:Npn \iow_show:e { \iow_now:Ne \tex_showstream:D }
12126 \cs_new_protected:Npn \iow_term:n { \iow_now:Nn \c_term_iow }
12127 \cs_new_protected:Npn \iow_term:e { \iow_now:Ne \c_term_iow }
12128 \cs_generate_variant:Nn \iow_term:n { x }
12129 \cs_if_exist:NT \tex_showstream:D
12130 { \int_gset_eq:NN \tex_showstream:D \c_term_iow }
12131 \cs_new:Npn \iow_newline: { ^^J }
12132 \cs_new_eq:NN \iow_char:N \cs_to_str:N
12133 \int_new:N \l_iow_line_count_int
12134 \int_set:Nn \l_iow_line_count_int { 78 }
12135 \tl_new:N \l__iow_newline_tl
12136 \int_new:N \l__iow_line_target_int
12137 \tl_new:N \l__iow_one_indent_tl
12138 \int_new:N \l__iow_one_indent_int
12139 \cs_new:Npn \__iow_unindent:w { }
12140 \cs_new_protected:Npn \__iow_set_indent:n #1
12141 {
12142 \__kernel_tl_set:Nx \l__iow_one_indent_tl
12143 { \exp_args:No \__kernel_str_to_other_fast:n { \tl_to_str:n {#1} } }
12144 \int_set:Nn \l__iow_one_indent_int
12145 { \str_count:N \l__iow_one_indent_tl }
12146 \exp_last_unbraced:NNo
12147 \cs_set:Npn \__iow_unindent:w \l__iow_one_indent_tl { }
12148 }
12149 \exp_args:Ne \__iow_set_indent:n { \prg_replicate:nn { 4 } { ~ } }
12150 \tl_new:N \l__iow_indent_tl
12151 \int_new:N \l__iow_indent_int
12152 \tl_new:N \l__iow_line_tl
12153 \tl_new:N \l__iow_line_part_tl
12154 \bool_new:N \l__iow_line_break_bool
12155 \tl_new:N \l__iow_wrap_tl
12156 \group_begin:
12157 \int_set:Nn \tex_escapechar:D { -1 }
12158 \tl_const:Ne \c__iow_wrap_marker_tl
12159 { \tl_to_str:n { \^^I \^^O \^^W \^^_ \^^W \^^R \^^A \^^P } }
12160 \group_end:
12161 \tl_map_inline:nn
12162 { { end } { newline } { allow_break } { indent } { unindent } }
12163 {
12164 \tl_const:ce { c__iow_wrap_ #1 _marker_tl }
12165 {
12166 \c__iow_wrap_marker_tl
12167 #1
12168 \c_catcode_other_space_tl
12169 }
12170 }
12171 \cs_new_protected:Npn \iow_wrap_allow_break:
12172 {
12173 \msg_error:nnnn { kernel } { iow-indent }
12174 { \iow_wrap:nnnN } { \iow_wrap_allow_break: }
12175 }
12176 \cs_new:Npe \__iow_wrap_allow_break: { \c__iow_wrap_allow_break_marker_tl }
12177 \cs_new:Npn \__iow_wrap_allow_break_error:
12178 {
12179 \msg_expandable_error:nnnn { kernel } { iow-indent }
12180 { \iow_wrap:nnnN } { \iow_wrap_allow_break: }
12181 }
12182 \cs_new_protected:Npn \iow_indent:n #1
12183 {
12184 \msg_error:nnnnn { kernel } { iow-indent }
12185 { \iow_wrap:nnnN } { \iow_indent:n } {#1}
12186 #1
12187 }
12188 \cs_new:Npe \__iow_indent:n #1
12189 {
12190 \c__iow_wrap_indent_marker_tl
12191 #1
12192 \c__iow_wrap_unindent_marker_tl
12193 }
12194 \cs_new:Npn \__iow_indent_error:n #1
12195 {
12196 \msg_expandable_error:nnnnn { kernel } { iow-indent }
12197 { \iow_wrap:nnnN } { \iow_indent:n } {#1}
12198 #1
12199 }
12200 \cs_new_protected:Npn \iow_wrap:nnnN #1#2#3#4
12201 {
12202 \group_begin:
12203 \cs_if_exist_use:N \conditionally@traceoff
12204 \int_set:Nn \tex_escapechar:D { -1 }
12205 \cs_set:Npe \{ { \token_to_str:N \{ }
12206 \cs_set:Npe \# { \token_to_str:N \# }
12207 \cs_set:Npe \} { \token_to_str:N \} }
12208 \cs_set:Npe \% { \token_to_str:N \% }
12209 \cs_set:Npe \~ { \token_to_str:N \~ }
12210 \int_set:Nn \tex_escapechar:D { 92 }
12211 \cs_set_eq:NN \\ \iow_newline:
12212 \cs_set_eq:NN \ \c_catcode_other_space_tl
12213 \cs_set_eq:NN \iow_wrap_allow_break: \__iow_wrap_allow_break:
12214 \cs_set_eq:NN \iow_indent:n \__iow_indent:n
12215 #3
12216 \cs_set_eq:NN \protect \token_to_str:N
12217 \__kernel_tl_set:Nx \l__iow_wrap_tl {#1}
12218 \cs_set_eq:NN \iow_wrap_allow_break: \__iow_wrap_allow_break_error:
12219 \cs_set_eq:NN \iow_indent:n \__iow_indent_error:n
12220 \__kernel_tl_set:Nx \l__iow_newline_tl { \iow_newline: #2 }
12221 \__kernel_tl_set:Nx \l__iow_newline_tl { \tl_to_str:N \l__iow_newline_tl }
12222 \int_set:Nn \l__iow_line_target_int
12223 { \l_iow_line_count_int - \str_count:N \l__iow_newline_tl + 1 }
12224 \int_compare:nNnT { \l__iow_line_target_int } < 0
12225 {
12226 \tl_set:Nn \l__iow_newline_tl { \iow_newline: }
12227 \int_set:Nn \l__iow_line_target_int
12228 { \l_iow_line_count_int + 1 }
12229 }
12230 \__iow_wrap_do:
12231 \exp_args:NNf \group_end:
12232 #4 { \tl_to_str:N \l__iow_wrap_tl }
12233 }
12234 \cs_generate_variant:Nn \iow_wrap:nnnN { ne }
12235 \cs_new_protected:Npn \__iow_wrap_do:
12236 {
12237 \__kernel_tl_set:Nx \l__iow_wrap_tl
12238 {
12239 \exp_args:No \__kernel_str_to_other_fast:n \l__iow_wrap_tl
12240 \c__iow_wrap_end_marker_tl
12241 }
12242 \__kernel_tl_set:Nx \l__iow_wrap_tl
12243 {
12244 \exp_after:wN \__iow_wrap_fix_newline:w \l__iow_wrap_tl
12245 ^^J \q__iow_nil ^^J \s__iow_stop
12246 }
12247 \exp_after:wN \__iow_wrap_start:w \l__iow_wrap_tl
12248 }
12249 \cs_new:Npn \__iow_wrap_fix_newline:w #1 ^^J #2 ^^J
12250 {
12251 #1
12252 \if_meaning:w \q__iow_nil #2
12253 \__iow_use_i_delimit_by_s_stop:nw
12254 \fi:
12255 \c__iow_wrap_newline_marker_tl
12256 \__iow_wrap_fix_newline:w #2 ^^J
12257 }
12258 \cs_new_protected:Npn \__iow_wrap_start:w
12259 {
12260 \bool_set_false:N \l__iow_line_break_bool
12261 \tl_clear:N \l__iow_line_tl
12262 \tl_clear:N \l__iow_line_part_tl
12263 \tl_set:Nn \l__iow_wrap_tl { ~ \use_none:n }
12264 \int_zero:N \l__iow_indent_int
12265 \tl_clear:N \l__iow_indent_tl
12266 \__iow_wrap_chunk:nw { \l_iow_line_count_int }
12267 }
12268 \cs_new_eq:NN \__iow_sep: \__kernel_int_sep:
12269 \cs_set_protected:Npn \__iow_tmp:w #1#2
12270 {
12271 \cs_new_protected:Npn \__iow_wrap_chunk:nw ##1##2 #2
12272 {
12273 \tl_if_empty:nTF {##2}
12274 {
12275 \tl_clear:N \l__iow_line_part_tl
12276 \__iow_wrap_next:nw {##1}
12277 }
12278 {
12279 \tl_if_empty:NTF \l__iow_line_tl
12280 {
12281 \__iow_wrap_line:nw
12282 { \l__iow_indent_tl }
12283 ##1 - \l__iow_indent_int \__iow_sep:
12284 }
12285 { \__iow_wrap_line:nw { } ##1 \__iow_sep: }
12286 ##2 #1
12287 \__iow_wrap_end_chunk:w 7 6 5 4 3 2 1 0 \s__iow_stop
12288 }
12289 }
12290 \cs_new_protected:Npn \__iow_wrap_next:nw ##1##2 #1
12291 { \use:c { __iow_wrap_##2:n } {##1} }
12292 }
12293 \exp_args:NVV \__iow_tmp:w \c_catcode_other_space_tl \c__iow_wrap_marker_tl
12294 \cs_new_protected:Npn \__iow_wrap_line:nw #1
12295 {
12296 \tex_edef:D \l__iow_line_part_tl { \if_false: } \fi:
12297 #1
12298 \exp_after:wN \__iow_wrap_line_loop:w
12299 \int_value:w \int_eval:w
12300 }
12301 \cs_new:Npn \__iow_wrap_line_loop:w #1 \__iow_sep: #2#3#4#5#6#7#8#9
12302 {
12303 \if_int_compare:w #1 < 8 \exp_stop_f:
12304 \__iow_wrap_line_aux:Nw #1
12305 \fi:
12306 #2 #3 #4 #5 #6 #7 #8 #9
12307 \exp_after:wN \__iow_wrap_line_loop:w
12308 \int_value:w \int_eval:w #1 - 8 \__iow_sep:
12309 }
12310 \cs_new:Npn \__iow_wrap_line_aux:Nw #1#2#3 \exp_after:wN #4 \__iow_sep:
12311 {
12312 #2
12313 \exp_after:wN \__iow_wrap_line_end:NnnnnnnnN
12314 \exp_after:wN #1
12315 \exp:w \exp_end_continue_f:w
12316 \exp_after:wN \exp_after:wN
12317 \if_case:w #1 \exp_stop_f:
12318 \prg_do_nothing:
12319 \or: \use_none:n
12320 \or: \use_none:nn
12321 \or: \use_none:nnn
12322 \or: \use_none:nnnn
12323 \or: \use_none:nnnnn
12324 \or: \use_none:nnnnnn
12325 \or: \__iow_wrap_line_seven:nnnnnnn
12326 \fi:
12327 { } { } { } { } { } { } { } #3
12328 }
12329 \cs_new:Npn \__iow_wrap_line_seven:nnnnnnn #1#2#3#4#5#6#7 { \exp_stop_f: }
12330 \cs_new:Npn \__iow_wrap_line_end:NnnnnnnnN #1#2#3#4#5#6#7#8#9
12331 {
12332 #2 #3 #4 #5 #6 #7 #8
12333 \use_none:nnnnn \int_eval:w 8 - \__iow_sep: #9
12334 \token_if_eq_charcode:NNTF \c_space_token #9
12335 { \__iow_wrap_line_end:nw { } }
12336 { \if_false: { \fi: } \__iow_wrap_break:w #9 }
12337 }
12338 \cs_new:Npn \__iow_wrap_line_end:nw #1
12339 {
12340 \if_false: { \fi: }
12341 \__iow_wrap_store_do:n {#1}
12342 \__iow_wrap_next_line:w
12343 }
12344 \cs_new:Npn \__iow_wrap_end_chunk:w
12345 #1 \int_eval:w #2 - #3 \__iow_sep: #4#5 \s__iow_stop
12346 {
12347 \if_false: { \fi: }
12348 \exp_args:Nf \__iow_wrap_next:nw { \int_eval:n { #2 - #4 } }
12349 }
12350 \cs_set_protected:Npn \__iow_tmp:w #1
12351 {
12352 \cs_new:Npn \__iow_wrap_break:w
12353 {
12354 \tex_edef:D \l__iow_line_part_tl
12355 { \if_false: } \fi:
12356 \exp_after:wN \__iow_wrap_break_first:w
12357 \l__iow_line_part_tl
12358 #1
12359 { ? \__iow_wrap_break_end:w }
12360 \s__iow_mark
12361 }
12362 \cs_new:Npn \__iow_wrap_break_first:w ##1 #1 ##2
12363 {
12364 \use_none:nn ##2 \__iow_wrap_break_none:w
12365 \__iow_wrap_break_loop:w ##1 #1 ##2
12366 }
12367 \cs_new:Npn \__iow_wrap_break_none:w ##1##2 #1 ##3 \s__iow_mark ##4 #1
12368 {
12369 \tl_if_empty:NTF \l__iow_line_tl
12370 { ##2 ##4 \__iow_wrap_line_end:nw { } }
12371 { \__iow_wrap_line_end:nw { \__iow_wrap_trim:N } ##2 ##4 #1 }
12372 }
12373 \cs_new:Npn \__iow_wrap_break_loop:w ##1 #1 ##2 #1 ##3
12374 {
12375 \use_none:n ##3
12376 ##1 #1
12377 \__iow_wrap_break_loop:w ##2 #1 ##3
12378 }
12379 \cs_new:Npn \__iow_wrap_break_end:w ##1 #1 ##2 ##3 #1 ##4 \s__iow_mark
12380 { ##1 \__iow_wrap_line_end:nw { } ##3 }
12381 }
12382 \exp_args:NV \__iow_tmp:w \c_catcode_other_space_tl
12383 \cs_new_protected:Npn \__iow_wrap_next_line:w #1#2 \s__iow_stop
12384 {
12385 \tl_clear:N \l__iow_line_tl
12386 \token_if_eq_meaning:NNTF #1 \__iow_wrap_end_chunk:w
12387 {
12388 \tl_clear:N \l__iow_line_part_tl
12389 \bool_set_true:N \l__iow_line_break_bool
12390 \__iow_wrap_next:nw { \l__iow_line_target_int }
12391 }
12392 {
12393 \__iow_wrap_line:nw
12394 { \l__iow_indent_tl }
12395 \l__iow_line_target_int - \l__iow_indent_int \__iow_sep:
12396 #1 #2 \s__iow_stop
12397 }
12398 }
12399 \cs_new_protected:Npn \__iow_wrap_allow_break:n #1
12400 {
12401 \__kernel_tl_set:Nx \l__iow_line_tl
12402 { \l__iow_line_tl \__iow_wrap_trim:N \l__iow_line_part_tl }
12403 \bool_set_false:N \l__iow_line_break_bool
12404 \tl_if_empty:NTF \l__iow_line_part_tl
12405 { \__iow_wrap_chunk:nw {#1} }
12406 { \exp_args:Nf \__iow_wrap_chunk:nw { \int_eval:n { #1 + 1 } } }
12407 }
12408 \cs_new_protected:Npn \__iow_wrap_indent:n #1
12409 {
12410 \tl_put_right:Ne \l__iow_line_tl { \l__iow_line_part_tl }
12411 \bool_set_false:N \l__iow_line_break_bool
12412 \int_add:Nn \l__iow_indent_int { \l__iow_one_indent_int }
12413 \tl_put_right:No \l__iow_indent_tl { \l__iow_one_indent_tl }
12414 \__iow_wrap_chunk:nw {#1}
12415 }
12416 \cs_new_protected:Npn \__iow_wrap_unindent:n #1
12417 {
12418 \tl_put_right:Ne \l__iow_line_tl { \l__iow_line_part_tl }
12419 \bool_set_false:N \l__iow_line_break_bool
12420 \int_sub:Nn \l__iow_indent_int { \l__iow_one_indent_int }
12421 \__kernel_tl_set:Nx \l__iow_indent_tl
12422 { \exp_after:wN \__iow_unindent:w \l__iow_indent_tl }
12423 \__iow_wrap_chunk:nw {#1}
12424 }
12425 \cs_new_protected:Npn \__iow_wrap_newline:n #1
12426 {
12427 \bool_if:NF \l__iow_line_break_bool
12428 { \__iow_wrap_store_do:n { \__iow_wrap_trim:N } }
12429 \bool_set_false:N \l__iow_line_break_bool
12430 \__iow_wrap_chunk:nw { \l__iow_line_target_int }
12431 }
12432 \cs_new_protected:Npn \__iow_wrap_end:n #1
12433 {
12434 \bool_if:NF \l__iow_line_break_bool
12435 { \__iow_wrap_store_do:n { \__iow_wrap_trim:N } }
12436 \bool_set_false:N \l__iow_line_break_bool
12437 }
12438 \cs_new_protected:Npn \__iow_wrap_store_do:n #1
12439 {
12440 \__kernel_tl_set:Nx \l__iow_line_tl
12441 { \l__iow_line_tl \l__iow_line_part_tl }
12442 \__kernel_tl_set:Nx \l__iow_wrap_tl
12443 {
12444 \l__iow_wrap_tl
12445 \l__iow_newline_tl
12446 #1 \l__iow_line_tl
12447 }
12448 \tl_clear:N \l__iow_line_tl
12449 }
12450 \cs_set_protected:Npn \__iow_tmp:w #1
12451 {
12452 \cs_new:Npn \__iow_wrap_trim:N ##1
12453 { \exp_after:wN \__iow_wrap_trim:w ##1 \s__iow_mark #1 \s__iow_mark \s__iow_stop }
12454 \cs_new:Npn \__iow_wrap_trim:w ##1 #1 \s__iow_mark
12455 { \__iow_wrap_trim_aux:w ##1 \s__iow_mark }
12456 \cs_new:Npn \__iow_wrap_trim_aux:w ##1 \s__iow_mark ##2 \s__iow_stop {##1}
12457 }
12458 \exp_args:NV \__iow_tmp:w \c_catcode_other_space_tl
12459 \tl_new:N \l__file_tmp_tl
12460 \str_new:N \g_file_curr_dir_str
12461 \str_new:N \g_file_curr_ext_str
12462 \str_new:N \g_file_curr_name_str
12463 \seq_new:N \g__file_stack_seq
12464 \group_begin:
12465 \cs_set_protected:Npn \__file_tmp:w #1#2#3
12466 {
12467 \tl_if_blank:nTF {#1}
12468 {
12469 \cs_set:Npn \__file_tmp:w ##1 " ##2 " ##3 \s__file_stop
12470 { { } {##2} { } }
12471 \seq_gput_right:Ne \g__file_stack_seq
12472 {
12473 \exp_after:wN \__file_tmp:w \tex_jobname:D
12474 " \tex_jobname:D " \s__file_stop
12475 }
12476 }
12477 {
12478 \seq_gput_right:Nn \g__file_stack_seq { { } {#1} {#2} }
12479 \__file_tmp:w
12480 }
12481 }
12482 \cs_if_exist:NT \@currnamestack
12483 {
12484 \tl_if_empty:NF \@currnamestack
12485 { \exp_after:wN \__file_tmp:w \@currnamestack }
12486 }
12487 \group_end:
12488 \seq_new:N \g__file_record_seq
12489 \tl_new:N \l__file_base_name_tl
12490 \tl_new:N \l__file_full_name_tl
12491 \str_new:N \l__file_dir_str
12492 \str_new:N \l__file_ext_str
12493 \str_new:N \l__file_name_str
12494 \seq_new:N \l_file_search_path_seq
12495 \seq_new:N \l__file_tmp_seq
12496 \scan_new:N \s__file_stop
12497 \quark_new:N \q__file_nil
12498 \__kernel_quark_new_conditional:Nn \__file_quark_if_nil:n { TF }
12499 \quark_new:N \q__file_recursion_tail
12500 \quark_new:N \q__file_recursion_stop
12501 \__kernel_quark_new_test:N \__file_if_recursion_tail_stop:N
12502 \__kernel_quark_new_test:N \__file_if_recursion_tail_stop_do:nn
12503 \cs_new:Npn \__kernel_file_name_sanitize:n #1
12504 {
12505 \exp_args:Ne \__file_name_trim_spaces:n
12506 {
12507 \exp_args:Ne \__file_name_strip_quotes:n
12508 { \__file_name_expand:n {#1} }
12509 }
12510 }
12511 \cs_new:Npn \__file_name_expand:n #1
12512 {
12513 \exp_after:wN \__file_name_expand_cleanup:Nw
12514 \cs:w __file_name = #1 \cs_end:
12515 \__file_name_expand_end:
12516 }
12517 \cs_new:Npn \__file_name_expand_cleanup:Nw #1 #2 \__file_name_expand_end:
12518 {
12519 \tl_if_empty:nF {#2}
12520 { \__file_name_expand_error:Nw #2 \__file_name_expand_end: }
12521 \exp_after:wN \__file_name_expand_cleanup:w \token_to_str:N #1
12522 }
12523 \exp_last_unbraced:NNNNo
12524 \cs_new:Npn \__file_name_expand_cleanup:w #1 \tl_to_str:n { __file_name = } { }
12525 \cs_new:Npn \__file_name_expand_end:
12526 {
12527 \msg_expandable_error:nn
12528 { kernel } { filename-missing-endcsname }
12529 \cs_end: \__file_name_expand_end:
12530 }
12531 \cs_new:Npn \__file_name_expand_error:Nw #1 #2 \__file_name_expand_end:
12532 { \__file_name_expand_error_aux:Nw #1 #2 \cs_end: \__file_name_expand_end: }
12533 \cs_new:Npn \__file_name_expand_error_aux:Nw #1 #2 \cs_end: #3
12534 \__file_name_expand_end:
12535 {
12536 \msg_expandable_error:nnff
12537 { kernel } { filename-chars-lost }
12538 { \token_to_str:N #1 } { \exp_stop_f: #2 }
12539 }
12540 \cs_new:Npn \__file_name_strip_quotes:n #1
12541 {
12542 \__file_name_strip_quotes:nw { 0 }
12543 #1 " \q__file_recursion_tail " \q__file_recursion_stop {#1}
12544 }
12545 \cs_new:Npn \__file_name_strip_quotes:nw #1#2 "
12546 {
12547 \if_meaning:w \q__file_recursion_tail #2
12548 \__file_name_strip_quotes_end:wnwn
12549 \fi:
12550 #2
12551 \__file_name_strip_quotes:nw { #1 + 1 }
12552 }
12553 \cs_new:Npn \__file_name_strip_quotes_end:wnwn \fi: #1
12554 \__file_name_strip_quotes:nw #2 \q__file_recursion_stop #3
12555 {
12556 \fi:
12557 \int_if_odd:nT {#2}
12558 {
12559 \msg_expandable_error:nnn
12560 { kernel } { unbalanced-quote-in-filename } {#3}
12561 }
12562 }
12563 \cs_new:Npn \__file_name_trim_spaces:n #1
12564 { \__file_name_trim_spaces:nw {#1} #1 . \q__file_nil . \s__file_stop }
12565 \cs_new:Npn \__file_name_trim_spaces:nw #1#2 . #3 . #4 \s__file_stop
12566 {
12567 \__file_quark_if_nil:nTF {#3}
12568 {
12569 \tl_trim_spaces_apply:nN { #1 \s__file_stop }
12570 \__file_name_trim_spaces_aux:n
12571 }
12572 { \tl_trim_spaces:n {#1} }
12573 }
12574 \cs_new:Npn \__file_name_trim_spaces_aux:n #1
12575 { \__file_name_trim_spaces_aux:w #1 }
12576 \cs_new:Npn \__file_name_trim_spaces_aux:w #1 \s__file_stop {#1}
12577 \cs_new:Npn \__kernel_file_name_quote:n #1
12578 { \__file_name_quote:nw {#1} #1 ~ \q__file_nil \s__file_stop }
12579 \cs_new:Npn \__file_name_quote:nw #1 #2 ~ #3 \s__file_stop
12580 {
12581 \__file_quark_if_nil:nTF {#3}
12582 { #1 }
12583 { "#1" }
12584 }
12585 \tl_const:Ne \c__file_marker_tl { : \token_to_str:N : }
12586 \cs_new_protected:Npn \file_get:nnN #1#2#3
12587 {
12588 \file_get:nnNF {#1} {#2} #3
12589 { \tl_set:Nn #3 { \q_no_value } }
12590 }
12591 \cs_generate_variant:Nn \file_get:nnN { V }
12592 \prg_new_protected_conditional:Npnn \file_get:nnN #1#2#3 { T , F , TF }
12593 {
12594 \file_get_full_name:nNTF {#1} \l__file_full_name_tl
12595 {
12596 \exp_args:NV \__file_get_aux:nnN
12597 \l__file_full_name_tl
12598 {#2} #3
12599 \prg_return_true:
12600 }
12601 { \prg_return_false: }
12602 }
12603 \prg_generate_conditional_variant:Nnn \file_get:nnN { V } { T , F , TF }
12604 \cs_new_protected:Npe \__file_get_aux:nnN #1#2#3
12605 {
12606 \exp_not:N \if_false: { \exp_not:N \fi:
12607 \group_begin:
12608 \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
12609 \exp_not:N \exp_args:No \tex_everyeof:D
12610 { \exp_not:N \c__file_marker_tl }
12611 #2 \scan_stop:
12612 \exp_not:N \exp_after:wN \exp_not:N \__file_get_do:Nw
12613 \exp_not:N \exp_after:wN #3
12614 \exp_not:N \exp_after:wN \exp_not:N \prg_do_nothing:
12615 \exp_not:N \tex_input:D
12616 \sys_if_engine_luatex:TF
12617 { {#1} }
12618 { \exp_not:N \__kernel_file_name_quote:n {#1} \scan_stop: }
12619 \exp_not:N \if_false: } \exp_not:N \fi:
12620 }
12621 \exp_args:Nno \use:nn
12622 { \cs_new_protected:Npn \__file_get_do:Nw #1#2 }
12623 { \c__file_marker_tl }
12624 {
12625 \group_end:
12626 \tl_set:No #1 {#2}
12627 }
12628 \cs_new_eq:NN \__file_size:n \tex_filesize:D
12629 \cs_new:Npn \file_full_name:n #1
12630 {
12631 \exp_args:Ne \__file_full_name:n
12632 { \__kernel_file_name_sanitize:n {#1} }
12633 }
12634 \cs_generate_variant:Nn \file_full_name:n { V }
12635 \cs_new:Npn \__file_full_name:n #1
12636 {
12637 \tl_if_blank:nF {#1}
12638 { \exp_args:Nne \__file_full_name_auxii:nn {#1} { \__file_full_name_aux:n {#1} } }
12639 }
12640 \cs_new:Npn \__file_full_name_aux:n #1
12641 {
12642 \if_cs_exist:w __file_seen_ \tl_to_str:n {#1} : \cs_end:
12643 -1
12644 \else:
12645 \exp_args:Ne \__file_full_name_auxi:nn { \__file_size:n {#1} } {#1}
12646 \fi:
12647 }
12648 \cs_new:Npn \__file_full_name_auxi:nn #1#2
12649 {
12650 \if:w \scan_stop: #1 \scan_stop:
12651 \else:
12652 \exp_after:wN \use_none:n
12653 \cs:w __file_seen_ \tl_to_str:n {#2} : \cs_end:
12654 #1
12655 \fi:
12656 }
12657 \cs_new:Npn \__file_full_name_auxii:nn #1 #2
12658 {
12659 \tl_if_blank:nTF {#2}
12660 {
12661 \seq_map_tokens:Nn \l_file_search_path_seq
12662 { \__file_full_name_aux:Nnn \seq_map_break:n {#1} }
12663 \cs_if_exist:NT \input@path
12664 {
12665 \tl_map_tokens:Nn \input@path
12666 { \__file_full_name_aux:Nnn \tl_map_break:n {#1} }
12667 }
12668 \__file_name_end:
12669 }
12670 { \__file_ext_check:nn {#1} {#2} }
12671 }
12672 \cs_new:Npn \__file_full_name_aux:Nnn #1#2#3
12673 {
12674 \exp_args:Ne \__file_full_name_aux:nN
12675 { \__file_full_name_slash:n {#3} #2 }
12676 #1
12677 }
12678 \cs_new:Npn \__file_full_name_slash:n #1
12679 {
12680 \__file_full_name_slash:nw {#1} #1 \q_nil / \q_nil / \q_nil \q_stop
12681 }
12682 \cs_new:Npn \__file_full_name_slash:nw #1#2 / \q_nil / #3 \q_stop
12683 {
12684 \quark_if_nil:nTF {#3}
12685 { #1 / }
12686 { #2 / }
12687 }
12688 \cs_new:Npn \__file_full_name_aux:nN #1
12689 { \exp_args:Nne \__file_full_name_aux:nnN {#1} { \__file_full_name_aux:n {#1} } }
12690 \cs_new:Npn \__file_full_name_aux:nnN #1 #2 #3
12691 {
12692 \tl_if_blank:nF {#2}
12693 {
12694 #3
12695 {
12696 \__file_ext_check:nn {#1} {#2}
12697 \__file_name_cleanup:w
12698 }
12699 }
12700 }
12701 \cs_new:Npn \__file_name_cleanup:w #1 \__file_name_end: { }
12702 \cs_new:Npn \__file_name_end: { }
12703 \cs_new:Npn \__file_ext_check:nn #1 #2
12704 { \__file_ext_check:nnw {#2} { / } #1 / \q__file_nil / \s__file_stop }
12705 \cs_new:Npn \__file_ext_check:nnw #1 #2 #3 / #4 / #5 \s__file_stop
12706 {
12707 \__file_quark_if_nil:nTF {#4}
12708 {
12709 \exp_args:No \__file_ext_check:nnnw
12710 { \use_none:n #2 } {#1} {#3} #3 . \q__file_nil . \s__file_stop
12711 }
12712 { \__file_ext_check:nnw {#1} { #2 #3 / } #4 / #5 \s__file_stop }
12713 }
12714 \cs_new:Npe \__file_ext_check:nnnw #1#2#3#4 . #5 . #6 \s__file_stop
12715 {
12716 \exp_not:N \__file_quark_if_nil:nTF {#5}
12717 {
12718 \exp_not:N \__file_ext_check:nnn
12719 { #1 #3 \tl_to_str:n { .tex } } { #1 #3 } {#2}
12720 }
12721 { #1 #3 }
12722 }
12723 \cs_new:Npn \__file_ext_check:nnn #1
12724 { \exp_args:Nne \__file_ext_check:nnnn {#1} { \__file_full_name_aux:n {#1} } }
12725 \cs_new:Npn \__file_ext_check:nnnn #1#2#3#4
12726 {
12727 \tl_if_blank:nTF {#2}
12728 {#3}
12729 {
12730 \bool_lazy_or:nnTF
12731 { \int_compare_p:nNn {#4} = {#2} }
12732 { \int_compare_p:nNn {#2} = { -1 } }
12733 {#1}
12734 {#3}
12735 }
12736 }
12737 \cs_new_protected:Npn \file_forget:n #1
12738 { \cs_undefine:c { __file_seen_ \file_full_name:n {#1} : } }
12739 \cs_new_protected:Npn \file_get_full_name:nN #1#2
12740 {
12741 \file_get_full_name:nNF {#1} #2
12742 { \tl_set:Nn #2 { \q_no_value } }
12743 }
12744 \cs_generate_variant:Nn \file_get_full_name:nN { V }
12745 \prg_new_protected_conditional:Npnn \file_get_full_name:nN #1#2 { T , F , TF }
12746 {
12747 \__kernel_tl_set:Nx #2
12748 { \file_full_name:n {#1} }
12749 \tl_if_empty:NTF #2
12750 { \prg_return_false: }
12751 { \prg_return_true: }
12752 }
12753 \prg_generate_conditional_variant:Nnn \file_get_full_name:nN
12754 { V } { T , F , TF }
12755 \ior_new:N \g__file_tmp_ior
12756 \cs_new:Npn \file_size:n #1
12757 { \__file_details:nn {#1} { size } }
12758 \cs_generate_variant:Nn \file_size:n { V }
12759 \cs_new:Npn \file_timestamp:n #1
12760 { \__file_details:nn {#1} { moddate } }
12761 \cs_generate_variant:Nn \file_timestamp:n { V }
12762 \cs_new:Npn \__file_details:nn #1#2
12763 {
12764 \exp_args:Ne \__file_details_aux:nn
12765 { \file_full_name:n {#1} } {#2}
12766 }
12767 \cs_new:Npn \__file_details_aux:nn #1#2
12768 {
12769 \tl_if_blank:nF {#1}
12770 { \use:c { tex_file #2 :D } {#1} }
12771 }
12772 \cs_new:Npn \file_mdfive_hash:n #1
12773 { \exp_args:Ne \__file_mdfive_hash:n { \file_full_name:n {#1} } }
12774 \cs_generate_variant:Nn \file_mdfive_hash:n { V }
12775 \cs_new:Npn \__file_mdfive_hash:n #1
12776 { \tex_mdfivesum:D file {#1} }
12777 \cs_new:Npn \file_hex_dump:nnn #1#2#3
12778 {
12779 \exp_args:Neee \__file_hex_dump_auxi:nnn
12780 { \file_full_name:n {#1} }
12781 { \int_eval:n {#2} }
12782 { \int_eval:n {#3} }
12783 }
12784 \cs_generate_variant:Nn \file_hex_dump:nnn { V }
12785 \cs_new:Npn \__file_hex_dump_auxi:nnn #1#2#3
12786 {
12787 \bool_lazy_any:nF
12788 {
12789 { \tl_if_blank_p:n {#1} }
12790 { \int_compare_p:nNn {#2} = 0 }
12791 { \int_compare_p:nNn {#3} = 0 }
12792 }
12793 {
12794 \exp_args:Ne \__file_hex_dump_auxii:nnnn
12795 { \__file_details_aux:nn {#1} { size } }
12796 {#1} {#2} {#3}
12797 }
12798 }
12799 \cs_new:Npn \__file_hex_dump_auxii:nnnn #1#2#3#4
12800 {
12801 \int_compare:nNnTF {#3} > 0
12802 { \__file_hex_dump_auxiii:nnnn {#3} }
12803 {
12804 \exp_args:Ne \__file_hex_dump_auxiii:nnnn
12805 { \int_eval:n { #1 + #3 } }
12806 }
12807 {#1} {#2} {#4}
12808 }
12809 \cs_new:Npn \__file_hex_dump_auxiii:nnnn #1#2#3#4
12810 {
12811 \int_compare:nNnTF {#4} > 0
12812 { \__file_hex_dump_auxiv:nnn {#4} }
12813 {
12814 \exp_args:Ne \__file_hex_dump_auxiv:nnn
12815 { \int_eval:n { #2 + #4 } }
12816 }
12817 {#1} {#3}
12818 }
12819 \cs_new:Npn \__file_hex_dump_auxiv:nnn #1#2#3
12820 {
12821 \tex_filedump:D
12822 offset ~ \int_eval:n { #2 - 1 } ~
12823 length ~ \int_eval:n { #1 - #2 + 1 }
12824 {#3}
12825 }
12826 \cs_new:Npn \file_hex_dump:n #1
12827 { \exp_args:Ne \__file_hex_dump:n { \file_full_name:n {#1} } }
12828 \cs_generate_variant:Nn \file_hex_dump:n { V }
12829 \sys_if_engine_luatex:TF
12830 {
12831 \cs_new:Npn \__file_hex_dump:n #1
12832 {
12833 \tl_if_blank:nF {#1}
12834 { \tex_filedump:D whole {#1} {#1} }
12835 }
12836 }
12837 {
12838 \cs_new:Npn \__file_hex_dump:n #1
12839 {
12840 \tl_if_blank:nF {#1}
12841 { \tex_filedump:D length \tex_filesize:D {#1} {#1} }
12842 }
12843 }
12844 \cs_new_protected:Npn \file_get_hex_dump:nN #1#2
12845 { \file_get_hex_dump:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
12846 \cs_generate_variant:Nn \file_get_hex_dump:nN { V }
12847 \cs_new_protected:Npn \file_get_mdfive_hash:nN #1#2
12848 { \file_get_mdfive_hash:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
12849 \cs_generate_variant:Nn \file_get_mdfive_hash:nN { V }
12850 \cs_new_protected:Npn \file_get_size:nN #1#2
12851 { \file_get_size:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
12852 \cs_generate_variant:Nn \file_get_size:nN { V }
12853 \cs_new_protected:Npn \file_get_timestamp:nN #1#2
12854 { \file_get_timestamp:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
12855 \cs_generate_variant:Nn \file_get_timestamp:nN { V }
12856 \prg_new_protected_conditional:Npnn \file_get_hex_dump:nN #1#2 { T , F , TF }
12857 { \__file_get_details:nnN {#1} { hex_dump } #2 }
12858 \prg_generate_conditional_variant:Nnn \file_get_hex_dump:nN
12859 { V } { T , F , TF }
12860 \prg_new_protected_conditional:Npnn \file_get_mdfive_hash:nN #1#2 { T , F , TF }
12861 { \__file_get_details:nnN {#1} { mdfive_hash } #2 }
12862 \prg_generate_conditional_variant:Nnn \file_get_mdfive_hash:nN
12863 { V } { T , F , TF }
12864 \prg_new_protected_conditional:Npnn \file_get_size:nN #1#2 { T , F , TF }
12865 { \__file_get_details:nnN {#1} { size } #2 }
12866 \prg_generate_conditional_variant:Nnn \file_get_size:nN
12867 { V } { T , F , TF }
12868 \prg_new_protected_conditional:Npnn \file_get_timestamp:nN #1#2 { T , F , TF }
12869 { \__file_get_details:nnN {#1} { timestamp } #2 }
12870 \prg_generate_conditional_variant:Nnn \file_get_timestamp:nN
12871 { V } { T , F , TF }
12872 \cs_new_protected:Npn \__file_get_details:nnN #1#2#3
12873 {
12874 \__kernel_tl_set:Nx #3
12875 { \use:c { file_ #2 :n } {#1} }
12876 \tl_if_empty:NTF #3
12877 { \prg_return_false: }
12878 { \prg_return_true: }
12879 }
12880 \cs_new_protected:Npn \file_get_hex_dump:nnnN #1#2#3#4
12881 {
12882 \file_get_hex_dump:nnnNF {#1} {#2} {#3} #4
12883 { \tl_set:Nn #4 { \q_no_value } }
12884 }
12885 \cs_generate_variant:Nn \file_get_hex_dump:nnnN { V }
12886 \prg_new_protected_conditional:Npnn \file_get_hex_dump:nnnN #1#2#3#4
12887 { T , F , TF }
12888 {
12889 \__kernel_tl_set:Nx #4
12890 { \file_hex_dump:nnn {#1} {#2} {#3} }
12891 \tl_if_empty:NTF #4
12892 { \prg_return_false: }
12893 { \prg_return_true: }
12894 }
12895 \prg_generate_conditional_variant:Nnn \file_get_hex_dump:nnnN
12896 { V } { T , F , TF }
12897 \cs_new_eq:NN \__file_str_cmp:nn \tex_strcmp:D
12898 \prg_new_conditional:Npnn \file_compare_timestamp:nNn #1#2#3
12899 { p , T , F , TF }
12900 {
12901 \exp_args:Nee \__file_compare_timestamp:nnN
12902 { \file_full_name:n {#1} }
12903 { \file_full_name:n {#3} }
12904 #2
12905 }
12906 \prg_generate_conditional_variant:Nnn \file_compare_timestamp:nNn
12907 { nNV , V , VNV } { p , T , F , TF }
12908 \cs_new:Npn \__file_compare_timestamp:nnN #1#2#3
12909 {
12910 \tl_if_blank:nTF {#1}
12911 {
12912 \if_charcode:w #3 <
12913 \prg_return_true:
12914 \else:
12915 \prg_return_false:
12916 \fi:
12917 }
12918 {
12919 \tl_if_blank:nTF {#2}
12920 {
12921 \if_charcode:w #3 >
12922 \prg_return_true:
12923 \else:
12924 \prg_return_false:
12925 \fi:
12926 }
12927 {
12928 \if_int_compare:w
12929 \__file_str_cmp:nn
12930 { \__file_timestamp:n {#1} }
12931 { \__file_timestamp:n {#2} }
12932 #3 \c_zero_int
12933 \prg_return_true:
12934 \else:
12935 \prg_return_false:
12936 \fi:
12937 }
12938 }
12939 }
12940 \cs_new_eq:NN \__file_timestamp:n \tex_filemoddate:D
12941 \prg_new_conditional:Npnn \file_if_exist:n #1 { p , T , F , TF }
12942 {
12943 \tl_if_blank:eTF { \file_full_name:n {#1} }
12944 { \prg_return_false: }
12945 { \prg_return_true: }
12946 }
12947 \prg_generate_conditional_variant:Nnn \file_if_exist:n { V } { p , T , F , TF }
12948 \cs_new_protected:Npn \file_if_exist_input:n #1
12949 {
12950 \file_get_full_name:nNT {#1} \l__file_full_name_tl
12951 { \__file_input:V \l__file_full_name_tl }
12952 }
12953 \cs_generate_variant:Nn \file_if_exist_input:n { V }
12954 \cs_new_protected:Npn \file_if_exist_input:nF #1#2
12955 {
12956 \file_get_full_name:nNTF {#1} \l__file_full_name_tl
12957 { \__file_input:V \l__file_full_name_tl }
12958 {#2}
12959 }
12960 \cs_generate_variant:Nn \file_if_exist_input:nF { V }
12961 \cs_new_protected:Npn \file_input_stop: { \tex_endinput:D }
12962 \cs_new_protected:Npn \__kernel_file_missing:n #1
12963 {
12964 \msg_error:nne { kernel } { file-not-found }
12965 { \__kernel_file_name_sanitize:n {#1} }
12966 }
12967 \cs_new_protected:Npn \file_input:n #1
12968 {
12969 \file_get_full_name:nNTF {#1} \l__file_full_name_tl
12970 { \__file_input:V \l__file_full_name_tl }
12971 { \__kernel_file_missing:n {#1} }
12972 }
12973 \cs_generate_variant:Nn \file_input:n { V }
12974 \cs_new_protected:Npe \__file_input:n #1
12975 {
12976 \exp_not:N \clist_if_exist:NTF \exp_not:N \@filelist
12977 { \exp_not:N \@addtofilelist {#1} }
12978 { \seq_gput_right:Nn \exp_not:N \g__file_record_seq {#1} }
12979 \exp_not:N \__file_input_push:n {#1}
12980 \exp_not:N \tex_input:D
12981 \sys_if_engine_luatex:TF
12982 { {#1} }
12983 { \exp_not:N \__kernel_file_name_quote:n {#1} \scan_stop: }
12984 \exp_not:N \__file_input_pop:
12985 }
12986 \cs_generate_variant:Nn \__file_input:n { V }
12987 \cs_new_protected:Npn \__file_input_push:n #1
12988 {
12989 \seq_gpush:Ne \g__file_stack_seq
12990 {
12991 { \g_file_curr_dir_str }
12992 { \g_file_curr_name_str }
12993 { \g_file_curr_ext_str }
12994 }
12995 \file_parse_full_name:nNNN {#1}
12996 \l__file_dir_str \l__file_name_str \l__file_ext_str
12997 \str_gset_eq:NN \g_file_curr_dir_str \l__file_dir_str
12998 \str_gset_eq:NN \g_file_curr_name_str \l__file_name_str
12999 \str_gset_eq:NN \g_file_curr_ext_str \l__file_ext_str
13000 }
13001 \cs_new_eq:NN \__kernel_file_input_push:n \__file_input_push:n
13002 \cs_new_protected:Npn \__file_input_pop:
13003 {
13004 \seq_gpop:NN \g__file_stack_seq \l__file_tmp_tl
13005 \exp_after:wN \__file_input_pop:nnn \l__file_tmp_tl
13006 }
13007 \cs_new_eq:NN \__kernel_file_input_pop: \__file_input_pop:
13008 \cs_new_protected:Npn \__file_input_pop:nnn #1#2#3
13009 {
13010 \str_gset:Nn \g_file_curr_dir_str {#1}
13011 \str_gset:Nn \g_file_curr_name_str {#2}
13012 \str_gset:Nn \g_file_curr_ext_str {#3}
13013 }
13014 \cs_new:Npn \file_input_raw:n #1
13015 { \exp_args:Ne \__file_input_raw:nn { \file_full_name:n {#1} } {#1} }
13016 \cs_generate_variant:Nn \file_input_raw:n { V }
13017 \cs_new:Npn \__file_input_raw:nn #1#2
13018 {
13019 \tl_if_blank:nTF {#1}
13020 {
13021 \exp_args:Nnne \msg_expandable_error:nnn
13022 { kernel } { file-not-found }
13023 { \__kernel_file_name_sanitize:n {#2} }
13024 }
13025 { \tex_input:D {#1} }
13026 }
13027 \exp_args_generate:n { nne }
13028 \cs_new:Npn \file_parse_full_name:n #1
13029 {
13030 \file_parse_full_name_apply:nN {#1}
13031 \prg_do_nothing:
13032 }
13033 \cs_generate_variant:Nn \file_parse_full_name:n { V }
13034 \cs_new:Npn \file_parse_full_name_apply:nN #1
13035 {
13036 \exp_args:Ne \__file_parse_full_name_auxi:nN
13037 { \__kernel_file_name_sanitize:n {#1} }
13038 }
13039 \cs_generate_variant:Nn \file_parse_full_name_apply:nN { V }
13040 \cs_new:Npn \__file_parse_full_name_auxi:nN #1
13041 {
13042 \__file_parse_full_name_area:nw { } #1
13043 / \s__file_stop
13044 }
13045 \cs_new:Npn \__file_parse_full_name_area:nw #1 #2 / #3 \s__file_stop
13046 {
13047 \tl_if_empty:nTF {#3}
13048 { \__file_parse_full_name_base:nw { } #2 . \s__file_stop {#1} }
13049 { \__file_parse_full_name_area:nw { #1 / #2 } #3 \s__file_stop }
13050 }
13051 \cs_new:Npn \__file_parse_full_name_base:nw #1 #2 . #3 \s__file_stop
13052 {
13053 \tl_if_empty:nTF {#3}
13054 {
13055 \tl_if_empty:nTF {#1}
13056 {
13057 \tl_if_empty:nTF {#2}
13058 { \__file_parse_full_name_tidy:nnnN { } { } }
13059 { \__file_parse_full_name_tidy:nnnN { .#2 } { } }
13060 }
13061 { \__file_parse_full_name_tidy:nnnN {#1} { .#2 } }
13062 }
13063 { \__file_parse_full_name_base:nw { #1 . #2 } #3 \s__file_stop }
13064 }
13065 \cs_new:Npn \__file_parse_full_name_tidy:nnnN #1 #2 #3 #4
13066 {
13067 \exp_args:Nee #4
13068 {
13069 \str_if_eq:nnF {#3} { / } { \use_none:n }
13070 #3 \prg_do_nothing:
13071 }
13072 { \use_none:n #1 \prg_do_nothing: }
13073 {#2}
13074 }
13075 \cs_new_protected:Npn \file_parse_full_name:nNNN #1 #2 #3 #4
13076 {
13077 \file_parse_full_name_apply:nN {#1}
13078 \__file_full_name_assign:nnnNNN #2 #3 #4
13079 }
13080 \cs_new_protected:Npn \__file_full_name_assign:nnnNNN #1 #2 #3 #4 #5 #6
13081 {
13082 \str_set:Nn #4 {#1}
13083 \str_set:Nn #5 {#2}
13084 \str_set:Nn #6 {#3}
13085 }
13086 \cs_generate_variant:Nn \file_parse_full_name:nNNN { V }
13087 \cs_new_protected:Npn \file_show_list: { \__file_list:N \msg_show:nneeee }
13088 \cs_new_protected:Npn \file_log_list: { \__file_list:N \msg_log:nneeee }
13089 \cs_new_protected:Npn \__file_list:N #1
13090 {
13091 \seq_clear:N \l__file_tmp_seq
13092 \clist_if_exist:NT \@filelist
13093 {
13094 \exp_args:NNe \seq_set_from_clist:Nn \l__file_tmp_seq
13095 { \tl_to_str:N \@filelist }
13096 }
13097 \seq_concat:NNN \l__file_tmp_seq \l__file_tmp_seq \g__file_record_seq
13098 \seq_remove_duplicates:N \l__file_tmp_seq
13099 #1 { kernel } { file-list }
13100 { \seq_map_function:NN \l__file_tmp_seq \__file_list_aux:n }
13101 { } { } { }
13102 }
13103 \cs_new:Npn \__file_list_aux:n #1 { \iow_newline: #1 }
13104 \cs_if_exist:NT \@filelist
13105 {
13106 \AtBeginDocument
13107 {
13108 \exp_args:NNe \seq_set_from_clist:Nn \l__file_tmp_seq
13109 { \tl_to_str:N \@filelist }
13110 \seq_gconcat:NNN
13111 \g__file_record_seq
13112 \g__file_record_seq
13113 \l__file_tmp_seq
13114 }
13115 }
13116 \cs_new_protected:Npn \GetIdInfo
13117 {
13118 \tl_clear_new:N \ExplFileDescription
13119 \tl_clear_new:N \ExplFileDate
13120 \tl_clear_new:N \ExplFileName
13121 \tl_clear_new:N \ExplFileExtension
13122 \tl_clear_new:N \ExplFileVersion
13123 \group_begin:
13124 \char_set_catcode_space:n { 32 }
13125 \exp_after:wN
13126 \group_end:
13127 \__file_id_info_auxi:w
13128 }
13129 \cs_new_protected:Npn \__file_id_info_auxi:w $ #1 $ #2
13130 {
13131 \tl_set:Nn \ExplFileDescription {#2}
13132 \str_if_eq:nnTF {#1} { Id }
13133 {
13134 \tl_set:Nn \ExplFileDate { 0000/00/00 }
13135 \tl_set:Nn \ExplFileName { [unknown] }
13136 \tl_set:Nn \ExplFileExtension { [unknown~extension] }
13137 \tl_set:Nn \ExplFileVersion {-1}
13138 }
13139 { \__file_id_info_auxii:w #1 ~ \s__file_stop }
13140 }
13141 \cs_new_protected:Npn \__file_id_info_auxii:w
13142 #1 ~ #2.#3 ~ #4 ~ #5 ~ #6 \s__file_stop
13143 {
13144 \tl_set:Nn \ExplFileName {#2}
13145 \tl_set:Nn \ExplFileExtension {#3}
13146 \tl_set:Nn \ExplFileVersion {#4}
13147 \str_if_eq:nnTF {#4} {-1}
13148 { \tl_set:Nn \ExplFileDate { 0000/00/00 } }
13149 { \__file_id_info_auxiii:w #5 - 0 - 0 - \s__file_stop }
13150 }
13151 \cs_new_protected:Npn \__file_id_info_auxiii:w #1 - #2 - #3 - #4 \s__file_stop
13152 { \tl_set:Nn \ExplFileDate { #1/#2/#3 } }
13153 \cs_new_protected:Npn \__kernel_dependency_version_check:Nn #1
13154 { \exp_args:NV \__kernel_dependency_version_check:nn #1 }
13155 \cs_new_protected:Npn \__kernel_dependency_version_check:nn #1
13156 {
13157 \cs_if_exist:NTF \c__kernel_expl_date_tl
13158 {
13159 \exp_args:NV \__file_kernel_dependency_compare:nnn
13160 \c__kernel_expl_date_tl {#1}
13161 }
13162 { \__file_kernel_dependency_compare:nnn { 0000-00-00 } {#1} }
13163 }
13164 \cs_new_protected:Npn \__file_kernel_dependency_compare:nnn #1 #2 #3
13165 {
13166 \int_compare:nNnT
13167 { \__file_parse_version:w #1 \s__file_stop } <
13168 { \__file_parse_version:w #2 \s__file_stop }
13169 { \__file_mismatched_dependency_error:nn {#2} {#3} }
13170 }
13171 \cs_new:Npn \__file_parse_version:w #1 - #2 - #3 \s__file_stop {#1#2#3}
13172 \cs_new_protected:Npn \__file_mismatched_dependency_error:nn #1 #2
13173 {
13174 \exp_args:NNe \ior_shell_open:Nn \g__file_tmp_ior
13175 {
13176 kpsewhich ~ --all ~
13177 --engine = \c_sys_engine_exec_str
13178 \c_space_tl \c_sys_engine_format_str
13179 \bool_lazy_and:nnT
13180 { \tl_if_exist_p:N \development@branch@name }
13181 { ! \tl_if_empty_p:N \development@branch@name }
13182 { -dev } .fmt
13183 }
13184 \seq_clear:N \l__file_tmp_seq
13185 \ior_map_inline:Nn \g__file_tmp_ior
13186 { \seq_put_right:Nn \l__file_tmp_seq {##1} }
13187 \ior_close:N \g__file_tmp_ior
13188 \msg_error:nnnn { kernel } { mismatched-support-file }
13189 {#1} {#2}
13190 \tex_endinput:D
13191 }
13192 \msg_new:nnnn { kernel } { mismatched-support-file }
13193 {
13194 Mismatched~LaTeX~support~files~detected. \\
13195 Loading~'#2'~aborted!
13196 \tl_if_exist:NT \c__kernel_expl_date_tl
13197 {
13198 \\ \\
13199 The~L3~programming~layer~in~the~LaTeX~format \\
13200 is~dated~\c__kernel_expl_date_tl,~but~in~your~TeX~
13201 tree~the~files~require \\ at~least~#1.
13202 }
13203 }
13204 {
13205 \int_compare:nNnTF { \seq_count:N \l__file_tmp_seq } > 1
13206 {
13207 The~cause~seems~to~be~an~old~format~file~in~the~user~tree. \\
13208 LaTeX~found~these~files:
13209 \seq_map_tokens:Nn \l__file_tmp_seq { \\~-~\use:n } \\
13210 Try~deleting~the~file~in~the~user~tree~then~run~LaTeX~again.
13211 }
13212 {
13213 The~most~likely~causes~are:
13214 \\~-~A~recent~format~generation~failed;
13215 \\~-~A~stray~format~file~in~the~user~tree~which~needs~
13216 to~be~removed~or~rebuilt;
13217 \\~-~You~are~running~a~manually~installed~version~of~#2 \\
13218 \ \ \ which~is~incompatible~with~the~version~in~LaTeX. \\
13219 }
13220 \\
13221 LaTeX~will~abort~loading~the~incompatible~support~files~
13222 but~this~may~lead~to \\ later~errors.~Please~ensure~that~
13223 your~LaTeX~format~is~correctly~regenerated.
13224 }
13225 \msg_new:nnnn { kernel } { file-not-found }
13226 { File~'#1'~not~found. }
13227 {
13228 The~requested~file~could~not~be~found~in~the~current~directory,~
13229 in~the~TeX~search~path~or~in~the~LaTeX~search~path.
13230 }
13231 \msg_new:nnn { kernel } { file-list }
13232 {
13233 >~File~List~<
13234 #1 \\
13235 .............
13236 }
13237 \msg_new:nnnn { kernel } { filename-chars-lost }
13238 { #1~invalid~in~file~name.~Lost:~#2. }
13239 {
13240 There~was~an~invalid~token~in~the~file~name~that~caused~
13241 the~characters~following~it~to~be~lost.
13242 }
13243 \msg_new:nnnn { kernel } { filename-missing-endcsname }
13244 { Missing~\iow_char:N\\endcsname~inserted~in~filename. }
13245 {
13246 The~file~name~had~more~\iow_char:N\\csname~commands~than~
13247 \iow_char:N\\endcsname~ones.~LaTeX~will~add~the~missing~
13248 \iow_char:N\\endcsname~and~try~to~continue~as~best~as~it~can.
13249 }
13250 \msg_new:nnnn { kernel } { unbalanced-quote-in-filename }
13251 { Unbalanced~quotes~in~file~name~'#1'. }
13252 {
13253 File~names~must~contain~balanced~numbers~of~quotes~(").
13254 }
13255 \msg_new:nnnn { kernel } { iow-indent }
13256 { Only~#1 allows~#2 }
13257 {
13258 The~command~#2 can~only~be~used~in~messages~
13259 which~will~be~wrapped~using~#1.
13260 \tl_if_empty:nF {#3} { ~ It~was~called~with~argument~'#3'. }
13261 }
13262 \sys_if_engine_luatex:TF
13263 {
13264 \str_const:Ne \c_sys_platform_str
13265 { \tex_directlua:D { tex.print(os.type) } }
13266 }
13267 {
13268 \file_if_exist:nTF { nul: }
13269 {
13270 \file_if_exist:nF { /dev/null }
13271 { \str_const:Nn \c_sys_platform_str { windows } }
13272 }
13273 {
13274 \file_if_exist:nT { /dev/null }
13275 { \str_const:Nn \c_sys_platform_str { unix } }
13276 }
13277 }
13278 \cs_if_exist:NF \c_sys_platform_str
13279 { \str_const:Nn \c_sys_platform_str { unknown } }
13280 \clist_map_inline:nn { unix , windows }
13281 {
13282 \__sys_const:nn { sys_if_platform_ #1 }
13283 { \str_if_eq_p:Vn \c_sys_platform_str { #1 } }
13284 }
13285 %% File: l3skip.dtx
13286 \cs_new_eq:NN \if_dim:w \tex_ifdim:D
13287 \cs_new_eq:NN \__dim_eval:w \tex_dimexpr:D
13288 \cs_new_eq:NN \__dim_eval_end: \tex_relax:D
13289 \scan_new:N \s__dim_mark
13290 \scan_new:N \s__dim_stop
13291 \cs_new:Npn \__dim_use_none_delimit_by_s_stop:w #1 \s__dim_stop { }
13292 \cs_new_protected:Npn \dim_new:N #1
13293 {
13294 \__kernel_chk_if_free_cs:N #1
13295 \cs:w newdimen \cs_end: #1
13296 }
13297 \cs_generate_variant:Nn \dim_new:N { c }
13298 \cs_new_protected:Npn \dim_const:Nn #1#2
13299 {
13300 \dim_new:N #1
13301 \tex_global:D #1 = \dim_eval:n {#2} \scan_stop:
13302 }
13303 \cs_generate_variant:Nn \dim_const:Nn { c }
13304 \cs_new_protected:Npn \dim_zero:N #1 { #1 = \c_zero_skip }
13305 \cs_new_protected:Npn \dim_gzero:N #1
13306 { \tex_global:D #1 = \c_zero_skip }
13307 \cs_generate_variant:Nn \dim_zero:N { c }
13308 \cs_generate_variant:Nn \dim_gzero:N { c }
13309 \cs_new_protected:Npn \dim_zero_new:N #1
13310 { \dim_if_exist:NTF #1 { \dim_zero:N #1 } { \dim_new:N #1 } }
13311 \cs_new_protected:Npn \dim_gzero_new:N #1
13312 { \dim_if_exist:NTF #1 { \dim_gzero:N #1 } { \dim_new:N #1 } }
13313 \cs_generate_variant:Nn \dim_zero_new:N { c }
13314 \cs_generate_variant:Nn \dim_gzero_new:N { c }
13315 \prg_new_eq_conditional:NNn \dim_if_exist:N \cs_if_exist:N
13316 { TF , T , F , p }
13317 \prg_new_eq_conditional:NNn \dim_if_exist:c \cs_if_exist:c
13318 { TF , T , F , p }
13319 \cs_new_protected:Npn \dim_set:Nn #1#2
13320 { #1 = \__dim_eval:w #2 \__dim_eval_end: \scan_stop: }
13321 \cs_new_protected:Npn \dim_gset:Nn #1#2
13322 { \tex_global:D #1 = \__dim_eval:w #2 \__dim_eval_end: \scan_stop: }
13323 \cs_generate_variant:Nn \dim_set:Nn { NV , c , cV }
13324 \cs_generate_variant:Nn \dim_gset:Nn { NV , c , cV }
13325 \cs_new_protected:Npn \dim_set_eq:NN #1#2
13326 { #1 = #2 \scan_stop: }
13327 \cs_generate_variant:Nn \dim_set_eq:NN { c , Nc , cc }
13328 \cs_new_protected:Npn \dim_gset_eq:NN #1#2
13329 { \tex_global:D #1 = #2 \scan_stop: }
13330 \cs_generate_variant:Nn \dim_gset_eq:NN { c , Nc , cc }
13331 \cs_new_protected:Npn \dim_add:Nn #1#2
13332 { \tex_advance:D #1 \__dim_eval:w #2 \__dim_eval_end: \scan_stop: }
13333 \cs_new_protected:Npn \dim_gadd:Nn #1#2
13334 {
13335 \tex_global:D \tex_advance:D #1
13336 \__dim_eval:w #2 \__dim_eval_end: \scan_stop:
13337 }
13338 \cs_generate_variant:Nn \dim_add:Nn { c }
13339 \cs_generate_variant:Nn \dim_gadd:Nn { c }
13340 \cs_new_protected:Npn \dim_sub:Nn #1#2
13341 { \tex_advance:D #1 - \__dim_eval:w #2 \__dim_eval_end: \scan_stop: }
13342 \cs_new_protected:Npn \dim_gsub:Nn #1#2
13343 {
13344 \tex_global:D \tex_advance:D #1
13345 -\__dim_eval:w #2 \__dim_eval_end: \scan_stop:
13346 }
13347 \cs_generate_variant:Nn \dim_sub:Nn { c }
13348 \cs_generate_variant:Nn \dim_gsub:Nn { c }
13349 \cs_new_eq:NN \__dim_sep: \__kernel_int_sep:
13350 \cs_new:Npn \dim_abs:n #1
13351 {
13352 \exp_after:wN \__dim_abs:N
13353 \dim_use:N \__dim_eval:w #1 \__dim_eval_end:
13354 }
13355 \cs_new:Npn \__dim_abs:N #1
13356 { \if_meaning:w - #1 \else: \exp_after:wN #1 \fi: }
13357 \cs_new:Npn \dim_max:nn #1#2
13358 {
13359 \dim_use:N \__dim_eval:w \exp_after:wN \__dim_maxmin:wwN
13360 \dim_use:N \__dim_eval:w #1 \exp_after:wN \__dim_sep:
13361 \dim_use:N \__dim_eval:w #2 \__dim_sep:
13362 >
13363 \__dim_eval_end:
13364 }
13365 \cs_new:Npn \dim_min:nn #1#2
13366 {
13367 \dim_use:N \__dim_eval:w \exp_after:wN \__dim_maxmin:wwN
13368 \dim_use:N \__dim_eval:w #1 \exp_after:wN \__dim_sep:
13369 \dim_use:N \__dim_eval:w #2 \__dim_sep:
13370 <
13371 \__dim_eval_end:
13372 }
13373 \cs_new:Npn \__dim_maxmin:wwN #1 \__dim_sep: #2 \__dim_sep: #3
13374 {
13375 \if_dim:w #1 #3 #2 ~
13376 #1
13377 \else:
13378 #2
13379 \fi:
13380 }
13381 \cs_new:Npn \dim_ratio:nn #1#2
13382 { \__dim_ratio:n {#1} / \__dim_ratio:n {#2} }
13383 \cs_new:Npn \__dim_ratio:n #1
13384 { \int_value:w \__dim_eval:w (#1) \__dim_eval_end: }
13385 \prg_new_conditional:Npnn \dim_compare:nNn #1#2#3 { p , T , F , TF }
13386 {
13387 \if_dim:w \__dim_eval:w #1 #2 \__dim_eval:w #3 \__dim_eval_end:
13388 \prg_return_true: \else: \prg_return_false: \fi:
13389 }
13390 \cs_new:Npn \dim_compare_p:vNn #1#2#3
13391 { \dim_compare_p:nNn { \use:c {#1} } #2 {#3} }
13392 \cs_new:Npn \dim_compare_p:nNv #1#2#3
13393 { \dim_compare_p:nNn {#1} #2 { \use:c {#3} } }
13394 \cs_new:Npn \dim_compare_p:vNv #1#2#3
13395 { \dim_compare_p:nNn { \use:c {#1} } #2 { \use:c {#3} } }
13396 \clist_map_inline:nn { T , F , TF }
13397 {
13398 \cs_new:cpe { dim_compare:vNn #1 } ##1##2##3
13399 {
13400 \exp_not:c { dim_compare:nNn #1 }
13401 { \exp_not:N \use:c {##1} } ##2 {##3}
13402 }
13403 \cs_new:cpe { dim_compare:nNv #1 } ##1##2##3
13404 {
13405 \exp_not:c { dim_compare:nNn #1 }
13406 {##1} ##2 { \exp_not:N \use:c {##3} }
13407 }
13408 \cs_new:cpe { dim_compare:vNv #1 } ##1##2##3
13409 {
13410 \exp_not:c { dim_compare:nNn #1 }
13411 { \exp_not:N \use:c {##1} } ##2 { \exp_not:N \use:c {##3} }
13412 }
13413 }
13414 \prg_new_conditional:Npnn \dim_compare:n #1 { p , T , F , TF }
13415 {
13416 \exp_after:wN \__dim_compare:w
13417 \dim_use:N \__dim_eval:w #1 \__dim_compare_error:
13418 }
13419 \cs_new:Npn \__dim_compare:w #1 \__dim_compare_error:
13420 {
13421 \exp_after:wN \if_false: \exp:w \exp_end_continue_f:w
13422 \__dim_compare:wNN #1 ? { = \__dim_compare_end:w \else: } \s__dim_stop
13423 }
13424 \exp_args:Nno \use:nn
13425 { \cs_new:Npn \__dim_compare:wNN #1 } { \tl_to_str:n {pt} #2#3 }
13426 {
13427 \if_meaning:w = #3
13428 \use:c { __dim_compare_#2:w }
13429 \fi:
13430 #1 pt \exp_stop_f:
13431 \prg_return_false:
13432 \exp_after:wN \__dim_use_none_delimit_by_s_stop:w
13433 \fi:
13434 \reverse_if:N \if_dim:w #1 pt #2
13435 \exp_after:wN \__dim_compare:wNN
13436 \dim_use:N \__dim_eval:w #3
13437 }
13438 \cs_new:cpn { __dim_compare_ ! :w }
13439 #1 \reverse_if:N #2 ! #3 = { #1 #2 = #3 }
13440 \cs_new:cpn { __dim_compare_ = :w }
13441 #1 \__dim_eval:w = { #1 \__dim_eval:w }
13442 \cs_new:cpn { __dim_compare_ < :w }
13443 #1 \reverse_if:N #2 < #3 = { #1 #2 > #3 }
13444 \cs_new:cpn { __dim_compare_ > :w }
13445 #1 \reverse_if:N #2 > #3 = { #1 #2 < #3 }
13446 \cs_new:Npn \__dim_compare_end:w #1 \prg_return_false: #2 \s__dim_stop
13447 { #1 \prg_return_false: \else: \prg_return_true: \fi: }
13448 \cs_new_protected:Npn \__dim_compare_error:
13449 {
13450 \if_int_compare:w \c_zero_int \c_zero_int \fi:
13451 =
13452 \__dim_compare_error:
13453 }
13454 \cs_new:Npn \dim_case:nnTF #1
13455 {
13456 \exp:w
13457 \exp_args:Nf \__dim_case:nnTF { \dim_eval:n {#1} }
13458 }
13459 \cs_new:Npn \dim_case:nnT #1#2#3
13460 {
13461 \exp:w
13462 \exp_args:Nf \__dim_case:nnTF { \dim_eval:n {#1} } {#2} {#3} { }
13463 }
13464 \cs_new:Npn \dim_case:nnF #1#2
13465 {
13466 \exp:w
13467 \exp_args:Nf \__dim_case:nnTF { \dim_eval:n {#1} } {#2} { }
13468 }
13469 \cs_new:Npn \dim_case:nn #1#2
13470 {
13471 \exp:w
13472 \exp_args:Nf \__dim_case:nnTF { \dim_eval:n {#1} } {#2} { } { }
13473 }
13474 \cs_new:Npn \__dim_case:nnTF #1#2#3#4
13475 { \__dim_case:nw {#1} #2 {#1} { } \s__dim_mark {#3} \s__dim_mark {#4} \s__dim_stop }
13476 \cs_new:Npn \__dim_case:nw #1#2#3
13477 {
13478 \dim_compare:nNnTF {#1} = {#2}
13479 { \__dim_case_end:nw {#3} }
13480 { \__dim_case:nw {#1} }
13481 }
13482 \cs_new:Npn \__dim_case_end:nw #1#2#3 \s__dim_mark #4#5 \s__dim_stop
13483 { \exp_end: #1 #4 }
13484 \cs_new:Npn \dim_while_do:nn #1#2
13485 {
13486 \dim_compare:nT {#1}
13487 {
13488 #2
13489 \dim_while_do:nn {#1} {#2}
13490 }
13491 }
13492 \cs_new:Npn \dim_until_do:nn #1#2
13493 {
13494 \dim_compare:nF {#1}
13495 {
13496 #2
13497 \dim_until_do:nn {#1} {#2}
13498 }
13499 }
13500 \cs_new:Npn \dim_do_while:nn #1#2
13501 {
13502 #2
13503 \dim_compare:nT {#1}
13504 { \dim_do_while:nn {#1} {#2} }
13505 }
13506 \cs_new:Npn \dim_do_until:nn #1#2
13507 {
13508 #2
13509 \dim_compare:nF {#1}
13510 { \dim_do_until:nn {#1} {#2} }
13511 }
13512 \cs_new:Npn \dim_while_do:nNnn #1#2#3#4
13513 {
13514 \dim_compare:nNnT {#1} #2 {#3}
13515 {
13516 #4
13517 \dim_while_do:nNnn {#1} #2 {#3} {#4}
13518 }
13519 }
13520 \cs_new:Npn \dim_until_do:nNnn #1#2#3#4
13521 {
13522 \dim_compare:nNnF {#1} #2 {#3}
13523 {
13524 #4
13525 \dim_until_do:nNnn {#1} #2 {#3} {#4}
13526 }
13527 }
13528 \cs_new:Npn \dim_do_while:nNnn #1#2#3#4
13529 {
13530 #4
13531 \dim_compare:nNnT {#1} #2 {#3}
13532 { \dim_do_while:nNnn {#1} #2 {#3} {#4} }
13533 }
13534 \cs_new:Npn \dim_do_until:nNnn #1#2#3#4
13535 {
13536 #4
13537 \dim_compare:nNnF {#1} #2 {#3}
13538 { \dim_do_until:nNnn {#1} #2 {#3} {#4} }
13539 }
13540 \cs_new:Npn \dim_step_function:nnnN #1#2#3
13541 {
13542 \exp_after:wN \__dim_step:wwwN
13543 \tex_the:D \__dim_eval:w #1 \exp_after:wN \__dim_sep:
13544 \tex_the:D \__dim_eval:w #2 \exp_after:wN \__dim_sep:
13545 \tex_the:D \__dim_eval:w #3 \__dim_sep:
13546 }
13547 \cs_new:Npn \__dim_step:wwwN #1 \__dim_sep: #2 \__dim_sep: #3 \__dim_sep: #4
13548 {
13549 \dim_compare:nNnTF {#2} > \c_zero_dim
13550 { \__dim_step:NnnnN > }
13551 {
13552 \dim_compare:nNnTF {#2} = \c_zero_dim
13553 {
13554 \msg_expandable_error:nnn { kernel } { zero-step } {#4}
13555 \use_none:nnnn
13556 }
13557 { \__dim_step:NnnnN < }
13558 }
13559 {#1} {#2} {#3} #4
13560 }
13561 \cs_new:Npn \__dim_step:NnnnN #1#2#3#4#5
13562 {
13563 \dim_compare:nNnF {#2} #1 {#4}
13564 {
13565 #5 {#2}
13566 \exp_args:NNf \__dim_step:NnnnN
13567 #1 { \dim_eval:n { #2 + #3 } } {#3} {#4} #5
13568 }
13569 }
13570 \cs_new_protected:Npn \dim_step_inline:nnnn
13571 {
13572 \int_gincr:N \g__kernel_prg_map_int
13573 \exp_args:NNc \__dim_step:NNnnnn
13574 \cs_gset_protected:Npn
13575 { __dim_map_ \int_use:N \g__kernel_prg_map_int :w }
13576 }
13577 \cs_new_protected:Npn \dim_step_variable:nnnNn #1#2#3#4#5
13578 {
13579 \int_gincr:N \g__kernel_prg_map_int
13580 \exp_args:NNc \__dim_step:NNnnnn
13581 \cs_gset_protected:Npe
13582 { __dim_map_ \int_use:N \g__kernel_prg_map_int :w }
13583 {#1}{#2}{#3}
13584 {
13585 \tl_set:Nn \exp_not:N #4 {##1}
13586 \exp_not:n {#5}
13587 }
13588 }
13589 \cs_new_protected:Npn \__dim_step:NNnnnn #1#2#3#4#5#6
13590 {
13591 #1 #2 ##1 {#6}
13592 \dim_step_function:nnnN {#3} {#4} {#5} #2
13593 \prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__kernel_prg_map_int }
13594 }
13595 \cs_new:Npn \dim_eval:n #1
13596 { \dim_use:N \__dim_eval:w #1 \__dim_eval_end: }
13597 \cs_new:Npn \dim_sign:n #1
13598 {
13599 \int_value:w \exp_after:wN \__dim_sign:Nw
13600 \dim_use:N \__dim_eval:w #1 \__dim_eval_end: \__dim_sep:
13601 \exp_stop_f:
13602 }
13603 \cs_new:Npn \__dim_sign:Nw #1#2 \__dim_sep:
13604 {
13605 \if_dim:w #1#2 > \c_zero_dim
13606 1
13607 \else:
13608 \if_meaning:w - #1
13609 -1
13610 \else:
13611 0
13612 \fi:
13613 \fi:
13614 }
13615 \cs_new_eq:NN \dim_use:N \tex_the:D
13616 \cs_new:Npn \dim_use:c #1 { \tex_the:D \cs:w #1 \cs_end: }
13617 \cs_new:Npn \dim_to_decimal:n #1
13618 {
13619 \exp_after:wN
13620 \__dim_to_decimal:w \dim_use:N \__dim_eval:w #1 \__dim_eval_end:
13621 }
13622 \use:e
13623 {
13624 \cs_new:Npn \exp_not:N \__dim_to_decimal:w
13625 #1 . #2 \tl_to_str:n { pt }
13626 }
13627 {
13628 \int_compare:nNnTF {#2} > \c_zero_int
13629 { #1 . #2 }
13630 { #1 }
13631 }
13632 \cs_new:Npn \dim_to_decimal_in_sp:n #1
13633 { \int_value:w \__dim_eval:w #1 \__dim_eval_end: }
13634 \group_begin:
13635 \cs_set_protected:Npn \__dim_tmp:w #1#2
13636 {
13637 \cs_new:cpn { dim_to_decimal_in_ #1 :n } ##1
13638 {
13639 \exp_after:wN \__dim_to_decimal_aux:w
13640 \int_value:w \__dim_eval:w ##1 \__dim_eval_end: \__dim_sep: #2 \__dim_sep:
13641 }
13642 }
13643 \__dim_tmp:w { in } { 50 / 7227 } % delta = 7227/100
13644 \__dim_tmp:w { pc } { 1 / 24 } % delta = 12/1
13645 \__dim_tmp:w { cm } { 127 / 7227 } % delta = 7227/254
13646 \__dim_tmp:w { mm } { 1270 / 7227 } % delta = 7227/2540
13647 \__dim_tmp:w { bp } { 400 / 803 } % delta = 7227/7200
13648 \__dim_tmp:w { dd } { 1157 / 2476 } % delta = 1238/1157
13649 \__dim_tmp:w { cc } { 1157 / 29712 } % delta = 14856/1157
13650 \group_end:
13651 \cs_new:Npn \__dim_to_decimal_aux:w #1#2 \__dim_sep: #3 \__dim_sep:
13652 {
13653 \dim_to_decimal:n
13654 {
13655 \int_eval:n
13656 { ( 2 * #1#2 \if:w #1 - - \else: + \fi: 1 ) * #3 }
13657 sp
13658 }
13659 }
13660 \cs_new:Npn \dim_to_decimal_in_unit:nn #1#2
13661 {
13662 \exp_after:wN \__dim_chk_unit:w
13663 \int_value:w \__dim_eval:w #2 \__dim_eval_end: \__dim_sep: {#1}
13664 }
13665 \cs_new:Npn \__dim_chk_unit:w #1#2 \__dim_sep: #3
13666 {
13667 \token_if_eq_charcode:NNTF #1 0
13668 { \msg_expandable_error:nn { dim } { zero-unit } }
13669 {
13670 \exp_after:wN \__dim_branch_unit:w
13671 \int_value:w \if:w #1 - - \fi: \__dim_eval:w #3 \exp_after:wN \__dim_sep:
13672 \int_value:w \if:w #1 - - \fi: #1#2 \__dim_sep:
13673 }
13674 }
13675 \cs_new:Npn \__dim_branch_unit:w #1 \__dim_sep: #2 \__dim_sep:
13676 {
13677 \int_compare:nNnTF {#2} > { 65536 }
13678 { \__dim_to_decimal_aux:w #1 \__dim_sep: 32768 / #2 \__dim_sep: }
13679 {
13680 \int_compare:nNnTF {#2} = { 65536 }
13681 { \dim_to_decimal:n { #1sp } }
13682 { \__dim_get_quotient:w #1 \__dim_sep: #2 \__dim_sep: }
13683 }
13684 }
13685 \cs_new:Npn \__dim_get_quotient:w #1#2 \__dim_sep: #3 \__dim_sep:
13686 {
13687 \token_if_eq_charcode:NNTF #1 0
13688 { 0 }
13689 {
13690 \token_if_eq_charcode:NNTF #1 -
13691 {
13692 \exp_after:wN \exp_after:wN \exp_after:wN \__dim_get_remainder:w
13693 \int_eval:n { ( 2 * #2 - #3 ) / ( 2 * #3 ) } \__dim_sep:
13694 #2 \__dim_sep: #3 \__dim_sep: - \__dim_sep:
13695 }
13696 {
13697 \exp_after:wN \exp_after:wN \exp_after:wN \__dim_get_remainder:w
13698 \int_eval:n { ( 2 * #1#2 - #3 ) / ( 2 * #3 ) } \__dim_sep:
13699 #1#2 \__dim_sep: #3 \__dim_sep: \__dim_sep:
13700 }
13701 }
13702 }
13703 \cs_new:Npn \__dim_get_remainder:w #1 \__dim_sep: #2 \__dim_sep: #3 \__dim_sep:
13704 {
13705 \exp_after:wN \exp_after:wN \exp_after:wN \__dim_convert_remainder:w
13706 \int_eval:n { #2 - #1 * #3 } \__dim_sep:
13707 #3 \__dim_sep: #1 \__dim_sep:
13708 }
13709 \cs_new:Npn \__dim_convert_remainder:w #1 \__dim_sep: #2 \__dim_sep:
13710 {
13711 \exp_after:wN \exp_after:wN \exp_after:wN \__dim_test_candidate:w
13712 \int_eval:n { #1 * 65536 / #2 } \__dim_sep:
13713 #1 \__dim_sep: #2 \__dim_sep:
13714 }
13715 \cs_new:Npn \__dim_test_candidate:w #1 \__dim_sep: #2 \__dim_sep: #3 \__dim_sep:
13716 {
13717 \dim_compare:nNnTF { #2sp } =
13718 { \dim_to_decimal:n { #1sp } \__dim_eval:w #3sp \__dim_eval_end: }
13719 { \__dim_parse_decimal:w #1 \__dim_sep: }
13720 {
13721 \__dim_parse_decimal:w \int_eval:n { #1 + 1 } \__dim_sep:
13722 }
13723 }
13724 \cs_new:Npn \__dim_parse_decimal:w #1 \__dim_sep: #2 \__dim_sep: #3 \__dim_sep:
13725 {
13726 \exp_after:wN \__dim_parse_decimal_aux:w
13727 \int_value:w #3 \int_eval:w #2 + \dim_to_decimal:n { #1sp } \__dim_sep:
13728 }
13729 \cs_new:Npn \__dim_parse_decimal_aux:w #1 \__dim_sep: {#1}
13730 \cs_new_eq:NN \dim_show:N \__kernel_register_show:N
13731 \cs_generate_variant:Nn \dim_show:N { c }
13732 \cs_new_protected:Npn \dim_show:n
13733 { \__kernel_msg_show_eval:Nn \dim_eval:n }
13734 \cs_new_eq:NN \dim_log:N \__kernel_register_log:N
13735 \cs_new_eq:NN \dim_log:c \__kernel_register_log:c
13736 \cs_new_protected:Npn \dim_log:n
13737 { \__kernel_msg_log_eval:Nn \dim_eval:n }
13738 \dim_const:Nn \c_zero_dim { 0 pt }
13739 \dim_const:Nn \c_max_dim { 16383.99999 pt }
13740 \dim_new:N \l_tmpa_dim
13741 \dim_new:N \l_tmpb_dim
13742 \dim_new:N \g_tmpa_dim
13743 \dim_new:N \g_tmpb_dim
13744 \cs_new_protected:Npn \dim_horizontal:n #1
13745 {
13746 \mode_leave_vertical:
13747 \__dim_kern:n {#1}
13748 }
13749 \cs_set_eq:NN \dim_horizontal:N \dim_horizontal:n
13750 \cs_generate_variant:Nn \dim_horizontal:N { c }
13751 \cs_new_protected:Npn \dim_vertical:n #1
13752 {
13753 \mode_if_vertical:F
13754 { \par }
13755 \__dim_kern:n {#1}
13756 }
13757 \cs_set_eq:NN \dim_vertical:N \dim_vertical:n
13758 \cs_generate_variant:Nn \dim_vertical:N { c }
13759 \cs_new_protected:Npn \__dim_kern:n #1
13760 { \tex_kern:D \tex_dimexpr:D #1 \scan_stop: }
13761 \scan_new:N \s__skip_stop
13762 \cs_new_protected:Npn \skip_new:N #1
13763 {
13764 \__kernel_chk_if_free_cs:N #1
13765 \cs:w newskip \cs_end: #1
13766 }
13767 \cs_generate_variant:Nn \skip_new:N { c }
13768 \cs_new_protected:Npn \skip_const:Nn #1#2
13769 {
13770 \skip_new:N #1
13771 \tex_global:D #1 = \skip_eval:n {#2} \scan_stop:
13772 }
13773 \cs_generate_variant:Nn \skip_const:Nn { c }
13774 \cs_new_eq:NN \skip_zero:N \dim_zero:N
13775 \cs_new_eq:NN \skip_gzero:N \dim_gzero:N
13776 \cs_generate_variant:Nn \skip_zero:N { c }
13777 \cs_generate_variant:Nn \skip_gzero:N { c }
13778 \cs_new_protected:Npn \skip_zero_new:N #1
13779 { \skip_if_exist:NTF #1 { \skip_zero:N #1 } { \skip_new:N #1 } }
13780 \cs_new_protected:Npn \skip_gzero_new:N #1
13781 { \skip_if_exist:NTF #1 { \skip_gzero:N #1 } { \skip_new:N #1 } }
13782 \cs_generate_variant:Nn \skip_zero_new:N { c }
13783 \cs_generate_variant:Nn \skip_gzero_new:N { c }
13784 \prg_new_eq_conditional:NNn \skip_if_exist:N \cs_if_exist:N
13785 { TF , T , F , p }
13786 \prg_new_eq_conditional:NNn \skip_if_exist:c \cs_if_exist:c
13787 { TF , T , F , p }
13788 \cs_new_protected:Npn \skip_set:Nn #1#2
13789 { #1 = \tex_glueexpr:D #2 \scan_stop: }
13790 \cs_new_protected:Npn \skip_gset:Nn #1#2
13791 { \tex_global:D #1 = \tex_glueexpr:D #2 \scan_stop: }
13792 \cs_generate_variant:Nn \skip_set:Nn { NV , c , cV }
13793 \cs_generate_variant:Nn \skip_gset:Nn { NV , c , cV }
13794 \cs_new_protected:Npn \skip_set_eq:NN #1#2 { #1 = #2 }
13795 \cs_generate_variant:Nn \skip_set_eq:NN { c , Nc , cc }
13796 \cs_new_protected:Npn \skip_gset_eq:NN #1#2 { \tex_global:D #1 = #2 }
13797 \cs_generate_variant:Nn \skip_gset_eq:NN { c , Nc , cc }
13798 \cs_new_protected:Npn \skip_add:Nn #1#2
13799 { \tex_advance:D #1 \tex_glueexpr:D #2 \scan_stop: }
13800 \cs_new_protected:Npn \skip_gadd:Nn #1#2
13801 { \tex_global:D \tex_advance:D #1 \tex_glueexpr:D #2 \scan_stop: }
13802 \cs_generate_variant:Nn \skip_add:Nn { c }
13803 \cs_generate_variant:Nn \skip_gadd:Nn { c }
13804 \cs_new_protected:Npn \skip_sub:Nn #1#2
13805 { \tex_advance:D #1 - \tex_glueexpr:D #2 \scan_stop: }
13806 \cs_new_protected:Npn \skip_gsub:Nn #1#2
13807 { \tex_global:D \tex_advance:D #1 - \tex_glueexpr:D #2 \scan_stop: }
13808 \cs_generate_variant:Nn \skip_sub:Nn { c }
13809 \cs_generate_variant:Nn \skip_gsub:Nn { c }
13810 \prg_new_conditional:Npnn \skip_if_eq:nn #1#2 { p , T , F , TF }
13811 {
13812 \str_if_eq:eeTF { \skip_eval:n {#1} } { \skip_eval:n {#2} }
13813 { \prg_return_true: }
13814 { \prg_return_false: }
13815 }
13816 \cs_new_eq:NN \__skip_sep: \__kernel_int_sep:
13817 \cs_set_protected:Npn \__skip_tmp:w #1
13818 {
13819 \prg_new_conditional:Npnn \skip_if_finite:n ##1 { p , T , F , TF }
13820 {
13821 \exp_after:wN \__skip_if_finite:wwNw
13822 \skip_use:N \tex_glueexpr:D ##1 \__skip_sep: \prg_return_false:
13823 #1 \__skip_sep: \prg_return_true: \s__skip_stop
13824 }
13825 \cs_new:Npn \__skip_if_finite:wwNw ##1 #1 ##2 \__skip_sep: ##3 ##4 \s__skip_stop {##3}
13826 }
13827 \exp_args:No \__skip_tmp:w { \tl_to_str:n { fil } }
13828 \cs_new:Npn \skip_eval:n #1
13829 { \skip_use:N \tex_glueexpr:D #1 \scan_stop: }
13830 \cs_new_eq:NN \skip_use:N \dim_use:N
13831 \cs_new_eq:NN \skip_use:c \dim_use:c
13832 \cs_new_eq:NN \skip_horizontal:N \tex_hskip:D
13833 \cs_new:Npn \skip_horizontal:n #1
13834 { \tex_hskip:D \tex_glueexpr:D #1 \scan_stop: }
13835 \cs_new_eq:NN \skip_vertical:N \tex_vskip:D
13836 \cs_new:Npn \skip_vertical:n #1
13837 { \tex_vskip:D \tex_glueexpr:D #1 \scan_stop: }
13838 \cs_generate_variant:Nn \skip_horizontal:N { c }
13839 \cs_generate_variant:Nn \skip_vertical:N { c }
13840 \cs_new_eq:NN \skip_show:N \__kernel_register_show:N
13841 \cs_generate_variant:Nn \skip_show:N { c }
13842 \cs_new_protected:Npn \skip_show:n
13843 { \__kernel_msg_show_eval:Nn \skip_eval:n }
13844 \cs_new_eq:NN \skip_log:N \__kernel_register_log:N
13845 \cs_new_eq:NN \skip_log:c \__kernel_register_log:c
13846 \cs_new_protected:Npn \skip_log:n
13847 { \__kernel_msg_log_eval:Nn \skip_eval:n }
13848 \skip_const:Nn \c_zero_skip { \c_zero_dim }
13849 \skip_const:Nn \c_max_skip { \c_max_dim }
13850 \skip_new:N \l_tmpa_skip
13851 \skip_new:N \l_tmpb_skip
13852 \skip_new:N \g_tmpa_skip
13853 \skip_new:N \g_tmpb_skip
13854 \cs_new_protected:Npn \muskip_new:N #1
13855 {
13856 \__kernel_chk_if_free_cs:N #1
13857 \cs:w newmuskip \cs_end: #1
13858 }
13859 \cs_generate_variant:Nn \muskip_new:N { c }
13860 \cs_new_protected:Npn \muskip_const:Nn #1#2
13861 {
13862 \muskip_new:N #1
13863 \tex_global:D #1 = \muskip_eval:n {#2} \scan_stop:
13864 }
13865 \cs_generate_variant:Nn \muskip_const:Nn { c }
13866 \cs_new_protected:Npn \muskip_zero:N #1
13867 { #1 = \c_zero_muskip }
13868 \cs_new_protected:Npn \muskip_gzero:N #1
13869 { \tex_global:D #1 = \c_zero_muskip }
13870 \cs_generate_variant:Nn \muskip_zero:N { c }
13871 \cs_generate_variant:Nn \muskip_gzero:N { c }
13872 \cs_new_protected:Npn \muskip_zero_new:N #1
13873 { \muskip_if_exist:NTF #1 { \muskip_zero:N #1 } { \muskip_new:N #1 } }
13874 \cs_new_protected:Npn \muskip_gzero_new:N #1
13875 { \muskip_if_exist:NTF #1 { \muskip_gzero:N #1 } { \muskip_new:N #1 } }
13876 \cs_generate_variant:Nn \muskip_zero_new:N { c }
13877 \cs_generate_variant:Nn \muskip_gzero_new:N { c }
13878 \prg_new_eq_conditional:NNn \muskip_if_exist:N \cs_if_exist:N
13879 { TF , T , F , p }
13880 \prg_new_eq_conditional:NNn \muskip_if_exist:c \cs_if_exist:c
13881 { TF , T , F , p }
13882 \cs_new_protected:Npn \muskip_set:Nn #1#2
13883 { #1 = \tex_muexpr:D #2 \scan_stop: }
13884 \cs_new_protected:Npn \muskip_gset:Nn #1#2
13885 { \tex_global:D #1 = \tex_muexpr:D #2 \scan_stop: }
13886 \cs_generate_variant:Nn \muskip_set:Nn { NV , c , cV }
13887 \cs_generate_variant:Nn \muskip_gset:Nn { NV , c , cV }
13888 \cs_new_protected:Npn \muskip_set_eq:NN #1#2 { #1 = #2 }
13889 \cs_generate_variant:Nn \muskip_set_eq:NN { c , Nc , cc }
13890 \cs_new_protected:Npn \muskip_gset_eq:NN #1#2 { \tex_global:D #1 = #2 }
13891 \cs_generate_variant:Nn \muskip_gset_eq:NN { c , Nc , cc }
13892 \cs_new_protected:Npn \muskip_add:Nn #1#2
13893 { \tex_advance:D #1 \tex_muexpr:D #2 \scan_stop: }
13894 \cs_new_protected:Npn \muskip_gadd:Nn #1#2
13895 { \tex_global:D \tex_advance:D #1 \tex_muexpr:D #2 \scan_stop: }
13896 \cs_generate_variant:Nn \muskip_add:Nn { c }
13897 \cs_generate_variant:Nn \muskip_gadd:Nn { c }
13898 \cs_new_protected:Npn \muskip_sub:Nn #1#2
13899 { \tex_advance:D #1 - \tex_muexpr:D #2 \scan_stop: }
13900 \cs_new_protected:Npn \muskip_gsub:Nn #1#2
13901 { \tex_global:D \tex_advance:D #1 - \tex_muexpr:D #2 \scan_stop: }
13902 \cs_generate_variant:Nn \muskip_sub:Nn { c }
13903 \cs_generate_variant:Nn \muskip_gsub:Nn { c }
13904 \cs_new:Npn \muskip_eval:n #1
13905 { \muskip_use:N \tex_muexpr:D #1 \scan_stop: }
13906 \cs_new_eq:NN \muskip_use:N \dim_use:N
13907 \cs_new_eq:NN \muskip_use:c \dim_use:c
13908 \cs_new_eq:NN \muskip_show:N \__kernel_register_show:N
13909 \cs_generate_variant:Nn \muskip_show:N { c }
13910 \cs_new_protected:Npn \muskip_show:n
13911 { \__kernel_msg_show_eval:Nn \muskip_eval:n }
13912 \cs_new_eq:NN \muskip_log:N \__kernel_register_log:N
13913 \cs_new_eq:NN \muskip_log:c \__kernel_register_log:c
13914 \cs_new_protected:Npn \muskip_log:n
13915 { \__kernel_msg_log_eval:Nn \muskip_eval:n }
13916 \muskip_const:Nn \c_zero_muskip { 0 mu }
13917 \muskip_const:Nn \c_max_muskip { 16383.99999 mu }
13918 \muskip_new:N \l_tmpa_muskip
13919 \muskip_new:N \l_tmpb_muskip
13920 \muskip_new:N \g_tmpa_muskip
13921 \muskip_new:N \g_tmpb_muskip
13922 %% File: l3keys.dtx
13923 \scan_new:N \s__keyval_nil
13924 \scan_new:N \s__keyval_mark
13925 \scan_new:N \s__keyval_stop
13926 \scan_new:N \s__keyval_tail
13927 \bool_new:N \l__kernel_keyval_allow_blank_keys_bool
13928 \group_begin:
13929 \cs_set_protected:Npn \__keyval_tmp:nn #1#2
13930 {
13931 \cs_new:Npn \keyval_parse:nnn ##1 ##2 ##3
13932 {
13933 \__kernel_exp_not:w \tex_expanded:D
13934 {
13935 {
13936 \__keyval_loop_active:nnw {##1} {##2}
13937 \s__keyval_mark ##3 #1 \s__keyval_tail #1
13938 }
13939 }
13940 }
13941 \cs_new_eq:NN \keyval_parse:NNn \keyval_parse:nnn
13942 \cs_new:Npn \__keyval_loop_active:nnw ##1 ##2 ##3 #1
13943 {
13944 \__keyval_if_recursion_tail:w ##3
13945 \__keyval_end_loop_active:w \s__keyval_tail
13946 \__keyval_loop_other:nnw {##1} {##2} ##3 , \s__keyval_tail ,
13947 }
13948 \cs_new:Npn \__keyval_split_other:w ##1 = ##2 \s__keyval_mark ##3
13949 { ##3 ##1 \s__keyval_stop \s__keyval_mark ##2 }
13950 \cs_new:Npn \__keyval_split_active:w ##1 #2 ##2 \s__keyval_mark ##3
13951 { ##3 ##1 \s__keyval_stop \s__keyval_mark ##2 }
13952 \cs_new:Npn \__keyval_loop_other:nnw ##1 ##2 ##3 ,
13953 {
13954 \__keyval_if_recursion_tail:w ##3
13955 \__keyval_end_loop_other:w \s__keyval_tail
13956 \__keyval_split_active:w ##3 \s__keyval_nil
13957 \s__keyval_mark \__keyval_split_active_auxi:w
13958 #2 \s__keyval_mark \__keyval_clean_up_active:w
13959 {##1} {##2}
13960 \s__keyval_mark
13961 }
13962 \cs_new:Npn \__keyval_split_active_auxi:w ##1 \s__keyval_stop
13963 {
13964 \__keyval_split_other:w ##1 \s__keyval_nil
13965 \s__keyval_mark \__keyval_misplaced_equal_after_active_error:w
13966 = \s__keyval_mark \__keyval_split_active_auxii:w
13967 }
13968 \cs_new:Npn \__keyval_split_active_auxii:w
13969 ##1 \s__keyval_nil \s__keyval_mark \__keyval_misplaced_equal_after_active_error:w
13970 \s__keyval_stop \s__keyval_mark
13971 ##2 \s__keyval_nil #2 \s__keyval_mark \__keyval_clean_up_active:w
13972 { \__keyval_trim:nN {##1} \__keyval_split_active_auxiii:w ##2 \s__keyval_nil }
13973 \cs_new:Npn \__keyval_split_active_auxiii:w ##1 ##2 \s__keyval_nil
13974 {
13975 \__keyval_split_active:w ##2 \s__keyval_nil
13976 \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
13977 #2 \s__keyval_mark \__keyval_split_active_auxiv:w
13978 {##1}
13979 }
13980 \cs_new:Npn \__keyval_split_active_auxiv:w
13981 ##1 \s__keyval_nil \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
13982 \s__keyval_stop \s__keyval_mark
13983 {
13984 \__keyval_split_other:w ##1 \s__keyval_nil
13985 \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
13986 = \s__keyval_mark \__keyval_split_active_auxv:w
13987 }
13988 \cs_new:Npn \__keyval_split_active_auxv:w
13989 ##1 \s__keyval_nil \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
13990 \s__keyval_stop \s__keyval_mark
13991 { \__keyval_trim:nN { ##1 } \__keyval_pair:nnnn }
13992 \cs_new:Npn \__keyval_clean_up_active:w
13993 ##1 \s__keyval_nil \s__keyval_mark \__keyval_split_active_auxi:w \s__keyval_stop \s__keyval_mark
13994 {
13995 \__keyval_split_other:w ##1 \s__keyval_nil
13996 \s__keyval_mark \__keyval_split_other_auxi:w
13997 = \s__keyval_mark \__keyval_clean_up_other:w
13998 }
13999 \cs_new:Npn \__keyval_split_other_auxi:w ##1 \s__keyval_stop
14000 { \__keyval_trim:nN { ##1 } \__keyval_split_other_auxii:w }
14001 \cs_new:Npn \__keyval_split_other_auxii:w
14002 ##1 ##2 \s__keyval_nil = \s__keyval_mark \__keyval_clean_up_other:w
14003 {
14004 \__keyval_split_other:w ##2 \s__keyval_nil
14005 \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
14006 = \s__keyval_mark \__keyval_split_other_auxiii:w
14007 { ##1 }
14008 }
14009 \cs_new:Npn \__keyval_split_other_auxiii:w
14010 ##1 \s__keyval_nil \s__keyval_mark \__keyval_misplaced_equal_in_split_error:w
14011 \s__keyval_stop \s__keyval_mark
14012 { \__keyval_trim:nN { ##1 } \__keyval_pair:nnnn }
14013 \cs_new:Npn \__keyval_clean_up_other:w
14014 ##1 \s__keyval_nil \s__keyval_mark \__keyval_split_other_auxi:w \s__keyval_stop \s__keyval_mark
14015 {
14016 \__keyval_if_blank:w ##1 \s__keyval_nil \s__keyval_stop \__keyval_blank_true:w
14017 \s__keyval_mark \s__keyval_stop
14018 \__keyval_trim:nN { ##1 } \__keyval_key:nn
14019 }
14020 \cs_new:Npn \__keyval_misplaced_equal_after_active_error:w
14021 \s__keyval_mark ##1 \s__keyval_stop \s__keyval_mark ##2 \s__keyval_nil
14022 = \s__keyval_mark \__keyval_split_active_auxii:w
14023 \s__keyval_mark ##3 \s__keyval_nil
14024 #2 \s__keyval_mark \__keyval_clean_up_active:w
14025 {
14026 \msg_expandable_error:nn
14027 { keyval } { misplaced-equals-sign }
14028 \__keyval_loop_other:nnw
14029 }
14030 \cs_new:Npn \__keyval_misplaced_equal_in_split_error:w
14031 \s__keyval_mark ##1 \s__keyval_stop \s__keyval_mark ##2 \s__keyval_nil
14032 ##3 \s__keyval_mark ##4 ##5
14033 {
14034 \msg_expandable_error:nn
14035 { keyval } { misplaced-equals-sign }
14036 \__keyval_loop_other:nnw
14037 }
14038 \cs_new:Npn \__keyval_end_loop_other:w
14039 \s__keyval_tail
14040 \__keyval_split_active:w
14041 \s__keyval_mark \s__keyval_tail
14042 \s__keyval_nil \s__keyval_mark
14043 \__keyval_split_active_auxi:w
14044 #2 \s__keyval_mark \__keyval_clean_up_active:w
14045 { \__keyval_loop_active:nnw }
14046 \cs_new:Npn \__keyval_end_loop_active:w
14047 \s__keyval_tail
14048 \__keyval_loop_other:nnw ##1 \s__keyval_mark \s__keyval_tail , \s__keyval_tail ,
14049 { }
14050 }
14051 \char_set_catcode_active:n { `\, }
14052 \char_set_catcode_active:n { `\= }
14053 \__keyval_tmp:nn , =
14054 \group_end:
14055 \cs_generate_variant:Nn \keyval_parse:NNn { NNV , NNv }
14056 \cs_generate_variant:Nn \keyval_parse:nnn { nnV , nnv }
14057 \group_begin:
14058 \cs_set_protected:Npn \__keyval_tmp:nn #1#2
14059 {
14060 \cs_new:Npn \__keyval_pair:nnnn ##1 ##2 ##3 ##4
14061 {
14062 \__keyval_if_blank:w \s__keyval_mark ##2 \s__keyval_nil \s__keyval_stop \__keyval_blank_key_error:w
14063 \s__keyval_mark \s__keyval_stop
14064 #1
14065 \exp_not:n { ##4 {##2} {##1} }
14066 #2
14067 \__keyval_loop_other:nnw {##3} {##4}
14068 }
14069 \cs_new:Npn \__keyval_key:nn ##1 ##2
14070 {
14071 \__keyval_if_blank:w \s__keyval_mark ##1 \s__keyval_nil \s__keyval_stop \__keyval_blank_key_error:w
14072 \s__keyval_mark \s__keyval_stop
14073 #1
14074 \exp_not:n { ##2 {##1} }
14075 #2
14076 \__keyval_loop_other:nnw {##2}
14077 }
14078 }
14079 \__keyval_tmp:nn { } { }
14080 \group_end:
14081 \cs_new:Npn \__keyval_if_empty:w #1 \s__keyval_mark \s__keyval_stop { }
14082 \cs_new:Npn \__keyval_if_blank:w \s__keyval_mark #1 { \__keyval_if_empty:w \s__keyval_mark }
14083 \cs_new:Npn \__keyval_if_recursion_tail:w \s__keyval_mark #1 \s__keyval_tail { }
14084 \cs_new:Npn \__keyval_blank_true:w \s__keyval_mark \s__keyval_stop \__keyval_trim:nN #1 \__keyval_key:nn
14085 { \__keyval_loop_other:nnw }
14086 \cs_new:Npn \__keyval_blank_key_error:w \s__keyval_mark \s__keyval_stop #1 \__keyval_loop_other:nnw
14087 {
14088 \bool_if:NTF \l__kernel_keyval_allow_blank_keys_bool
14089 { #1 }
14090 { \msg_expandable_error:nn { keyval } { blank-key-name } }
14091 \__keyval_loop_other:nnw
14092 }
14093 \msg_new:nnn { keyval } { misplaced-equals-sign }
14094 { Misplaced~'='~in~key-value~input~\msg_line_context: }
14095 \msg_new:nnn { keyval } { blank-key-name }
14096 { Blank~key~name~in~key-value~input~\msg_line_context: }
14097 \prop_gput:Nnn \g_msg_module_name_prop { keyval } { LaTeX }
14098 \prop_gput:Nnn \g_msg_module_type_prop { keyval } { }
14099 \group_begin:
14100 \cs_set_protected:Npn \__keyval_tmp:n #1
14101 {
14102 \cs_new:Npn \__keyval_trim:nN ##1
14103 {
14104 \__keyval_trim_auxi:w
14105 ##1
14106 \s__keyval_nil
14107 \s__keyval_mark #1 { }
14108 \s__keyval_mark \__keyval_trim_auxii:w
14109 \__keyval_trim_auxiii:w
14110 #1 \s__keyval_nil
14111 \__keyval_trim_auxiv:w
14112 }
14113 \cs_new:Npn \__keyval_trim_auxi:w ##1 \s__keyval_mark #1 ##2 \s__keyval_mark ##3
14114 {
14115 ##3
14116 \__keyval_trim_auxi:w
14117 \s__keyval_mark
14118 ##2
14119 \s__keyval_mark #1 {##1}
14120 }
14121 \cs_new:Npn \__keyval_trim_auxii:w \__keyval_trim_auxi:w \s__keyval_mark \s__keyval_mark ##1
14122 {
14123 \__keyval_trim_auxiii:w
14124 ##1
14125 }
14126 \cs_new:Npn \__keyval_trim_auxiii:w ##1 #1 \s__keyval_nil ##2
14127 {
14128 ##2
14129 ##1 \s__keyval_nil
14130 \__keyval_trim_auxiii:w
14131 }
14132 \cs_new:Npn \__keyval_trim_auxiv:w
14133 \s__keyval_mark ##1 \s__keyval_nil
14134 \__keyval_trim_auxiii:w \s__keyval_nil \__keyval_trim_auxiii:w
14135 ##2
14136 { ##2 { ##1 } }
14137 }
14138 \__keyval_tmp:n { ~ }
14139 \group_end:
14140 \cs_new_protected:Npn \keyval_map_inline:nnn #1#2#3
14141 {
14142 \group_begin:
14143 \cs_set:Npn \__keyval_tmp:n ##1 { \exp_not:n {#2} }
14144 \cs_set:Npn \__keyval_tmp:nn ##1##2 { \exp_not:n {#3} }
14145 \exp_args:NNe \exp_last_unbraced:Ne
14146 \group_end:
14147 { \keyval_parse:NNn \__keyval_tmp:n \__keyval_tmp:nn {#1} }
14148 \prg_break_point:Nn \keyval_map_break: { }
14149 }
14150 \cs_new:Npn \keyval_map_break: { \prg_map_break:Nn \keyval_map_break: { } }
14151 \cs_new:Npn \keyval_map_break:n { \prg_map_break:Nn \keyval_map_break: }
14152 \str_const:Nn \c__keys_code_root_str { key~code~>~ }
14153 \str_const:Nn \c__keys_check_root_str { key~check~>~ }
14154 \str_const:Nn \c__keys_default_root_str { key~default~>~ }
14155 \str_const:Nn \c__keys_groups_root_str { key~groups~>~ }
14156 \str_const:Nn \c__keys_inherit_root_str { key~inherit~>~ }
14157 \str_const:Nn \c__keys_type_root_str { key~type~>~ }
14158 \str_const:Nn \c__keys_props_root_str { key~prop~>~ }
14159 \int_new:N \l_keys_choice_int
14160 \str_new:N \l_keys_choice_str
14161 \tl_new:N \l_keys_choice_tl
14162 \str_new:N \l__keys_exp_str
14163 \clist_new:N \l__keys_groups_clist
14164 \bool_new:N \l__keys_inherit_bool
14165 \clist_new:N \l__keys_inherit_clist
14166 \str_new:N \l_keys_key_str
14167 \tl_new:N \l_keys_key_tl
14168 \str_new:N \l__keys_module_str
14169 \bool_new:N \l__keys_no_value_bool
14170 \bool_new:N \l__keys_only_known_bool
14171 \str_new:N \l_keys_path_str
14172 \tl_new:N \l_keys_path_tl
14173 \str_new:N \l__keys_inherit_str
14174 \tl_new:N \l__keys_relative_tl
14175 \tl_set:Nn \l__keys_relative_tl { \q__keys_no_value }
14176 \str_new:N \l__keys_property_str
14177 \bool_new:N \l__keys_selective_bool
14178 \bool_new:N \l__keys_exclude_bool
14179 \clist_new:N \l__keys_selective_clist
14180 \clist_new:N \l__keys_tmp_clist
14181 \clist_new:N \l__keys_unused_clist
14182 \tl_new:N \l_keys_value_tl
14183 \bool_new:N \l__keys_tmp_bool
14184 \tl_new:N \l__keys_tmpa_tl
14185 \tl_new:N \l__keys_tmpb_tl
14186 \bool_new:N \l__keys_precompile_bool
14187 \tl_new:N \l__keys_precompile_tl
14188 \prop_new:N \l_keys_usage_load_prop
14189 \prop_new:N \l_keys_usage_preamble_prop
14190 \scan_new:N \s__keys_nil
14191 \scan_new:N \s__keys_mark
14192 \scan_new:N \s__keys_stop
14193 \quark_new:N \q__keys_no_value
14194 \__kernel_quark_new_conditional:Nn \__keys_quark_if_no_value:N { TF }
14195 \cs_new_protected:Npn \__keys_precompile:n #1
14196 {
14197 \bool_if:NTF \l__keys_precompile_bool
14198 { \tl_put_right:Nn \l__keys_precompile_tl }
14199 { \use:n }
14200 {#1}
14201 }
14202 \cs_new_protected:Npn \__keys_cs_undefine:c #1
14203 {
14204 \if_cs_exist:w #1 \cs_end:
14205 \else:
14206 \use_i:nnnn
14207 \fi:
14208 \cs_set_eq:cN {#1} \tex_undefined:D
14209 }
14210 \cs_new_protected:Npn \keys_define:nn #1#2
14211 {
14212 \use:e
14213 {
14214 \exp_not:n
14215 {
14216 \str_set:Ne \l__keys_module_str { \__keys_trim_spaces:n {#1} }
14217 \keyval_parse:NNn \__keys_define:n \__keys_define:nn {#2}
14218 }
14219 \__keys_reset_var:N \l__keys_module_str
14220 \__keys_reset_var:N \l__keys_inherit_str
14221 \__keys_reset_var:N \l_keys_choice_tl
14222 \__keys_reset_var:N \l_keys_choice_str
14223 \__keys_reset_var:N \l_keys_key_tl
14224 \__keys_reset_var:N \l_keys_key_str
14225 \__keys_reset_var:N \l_keys_path_tl
14226 \__keys_reset_var:N \l_keys_path_str
14227 \__keys_reset_var:N \l_keys_value_tl
14228 \int_set:Nn \l_keys_choice_int { \int_use:N \l_keys_choice_int }
14229 }
14230 }
14231 \cs_generate_variant:Nn \keys_define:nn { ne , nx }
14232 \cs_new_protected:Npn \__keys_define:n #1
14233 {
14234 \bool_set_true:N \l__keys_no_value_bool
14235 \__keys_define_aux:nn {#1} { }
14236 }
14237 \cs_new_protected:Npn \__keys_define:nn #1#2
14238 {
14239 \bool_set_false:N \l__keys_no_value_bool
14240 \__keys_define_aux:nn {#1} {#2}
14241 }
14242 \cs_new_protected:Npn \__keys_define_aux:nn #1#2
14243 {
14244 \__keys_property_find:n {#1}
14245 \cs_if_exist:cTF { \c__keys_props_root_str \l__keys_property_str }
14246 { \__keys_define_code:n {#2} }
14247 {
14248 \str_if_empty:NF \l__keys_property_str
14249 {
14250 \msg_error:nnee { keys } { property-unknown }
14251 \l__keys_property_str \l_keys_path_str
14252 }
14253 }
14254 }
14255 \cs_new_protected:Npn \__keys_property_find:n #1
14256 {
14257 \exp_after:wN \__keys_property_find_auxi:w \tl_to_str:n {#1}
14258 \s__keys_nil \__keys_property_find_auxii:w
14259 . \s__keys_nil \__keys_property_find_err:w
14260 }
14261 \cs_new:Npn \__keys_property_find_auxi:w #1 . #2 \s__keys_nil #3
14262 {
14263 #3 #1 \s__keys_mark #2 \s__keys_nil #3
14264 }
14265 \cs_new_protected:Npn \__keys_property_find_auxii:w
14266 #1 \s__keys_mark #2 \s__keys_nil \__keys_property_find_auxii:w . \s__keys_nil
14267 \__keys_property_find_err:w
14268 {
14269 \cs_set_nopar:Npe \l_keys_path_str
14270 {
14271 \str_if_empty:NF \l__keys_module_str { \l__keys_module_str / }
14272 \exp_after:wN \__keys_trim_spaces:n \tex_expanded:D {{
14273 #1
14274 \if_false: }}} \fi:
14275 \__keys_property_find_auxi:w #2 \s__keys_nil \__keys_property_find_auxiii:w
14276 . \s__keys_nil \__keys_property_find_auxiv:w
14277 }
14278 \cs_new:Npn \__keys_property_find_auxiii:w #1 \s__keys_mark #2 . #3 \s__keys_nil #4
14279 {
14280 . #1 #4 #2 \s__keys_mark #3 \s__keys_nil #4
14281 }
14282 \cs_new:Npn \__keys_property_find_auxiv:w
14283 #1 \s__keys_nil \__keys_property_find_auxiii:w
14284 \s__keys_mark \s__keys_nil \__keys_property_find_auxiv:w
14285 {
14286 \if_false: {{{ \fi: }}}
14287 \cs_set_nopar:Npe \l__keys_property_str { . #1 }
14288 \tl_set_eq:NN \l_keys_path_tl \l_keys_path_str
14289 }
14290 \cs_new_protected:Npn \__keys_property_find_err:w
14291 #1 \s__keys_nil #2 \__keys_property_find_err:w
14292 {
14293 \str_clear:N \l__keys_property_str
14294 \msg_error:nnn { keys } { no-property } {#1}
14295 }
14296 \cs_new_protected:Npn \__keys_define_code:n #1
14297 {
14298 \bool_if:NTF \l__keys_no_value_bool
14299 {
14300 \__keys_define_code:nnn
14301 { \use:c { \c__keys_props_root_str \l__keys_property_str } {#1} }
14302 { \use:c { \c__keys_props_root_str \l__keys_property_str } }
14303 {
14304 \msg_error:nnee { keys } { property-requires-value }
14305 \l__keys_property_str \l_keys_path_str
14306 }
14307 }
14308 { \use:c { \c__keys_props_root_str \l__keys_property_str } {#1} }
14309 }
14310 \cs_new:Npe \__keys_define_code:nnn
14311 {
14312 \exp_not:N \exp_after:wN \exp_not:N \__keys_define_code:w
14313 \exp_not:N \l__keys_property_str
14314 \c_colon_str \c_colon_str
14315 \exp_not:N \s__keys_stop
14316 }
14317 \use:e
14318 {
14319 \cs_new:Npn \exp_not:N \__keys_define_code:w
14320 #1 \c_colon_str #2 \c_colon_str #3 \exp_not:N \s__keys_stop
14321 }
14322 {
14323 \tl_if_empty:nTF {#3}
14324 { \use_i:nnn }
14325 {
14326 \tl_if_empty:nTF {#2}
14327 { \use_ii:nnn }
14328 { \use_iii:nnn }
14329 }
14330 }
14331 \cs_new_protected:Npn \__keys_bool_set:Nn #1#2
14332 { \__keys_bool_set:Nnnn #1 {#2} { true } { false } }
14333 \cs_generate_variant:Nn \__keys_bool_set:Nn { c }
14334 \cs_new_protected:Npn \__keys_bool_set_inverse:Nn #1#2
14335 { \__keys_bool_set:Nnnn #1 {#2} { false } { true } }
14336 \cs_generate_variant:Nn \__keys_bool_set_inverse:Nn { c }
14337 \cs_new_protected:Npn \__keys_bool_set:Nnnn #1#2#3#4
14338 {
14339 \bool_if_exist:NF #1 { \bool_new:N #1 }
14340 \__keys_choice_make:
14341 \__keys_cmd_set:ne { \l_keys_path_str / true }
14342 { \exp_not:c { bool_ #2 set_ #3 :N } \exp_not:N #1 }
14343 \__keys_cmd_set:ne { \l_keys_path_str / false }
14344 { \exp_not:c { bool_ #2 set_ #4 :N } \exp_not:N #1 }
14345 \__keys_cmd_set_direct:nn { \l_keys_path_str / unknown }
14346 {
14347 \msg_error:nne { keys } { boolean-values-only }
14348 \l_keys_path_str
14349 }
14350 \__keys_default_set:n { true }
14351 }
14352 \cs_generate_variant:Nn \__keys_bool_set:Nn { c }
14353 \cs_new_protected:Npn \__keys_choice_make:
14354 { \__keys_choice_make:N \__keys_choice_find:n }
14355 \cs_new_protected:Npn \__keys_multichoice_make:
14356 { \__keys_choice_make:N \__keys_multichoice_find:n }
14357 \cs_new_protected:Npn \__keys_choice_make:N #1
14358 {
14359 \cs_if_exist:cTF
14360 { \c__keys_type_root_str \__keys_parent:o \l_keys_path_str }
14361 {
14362 \str_if_eq:vnTF
14363 { \c__keys_type_root_str \__keys_parent:o \l_keys_path_str }
14364 { choice }
14365 {
14366 \msg_error:nnee { keys } { nested-choice-key }
14367 \l_keys_path_tl { \__keys_parent:o \l_keys_path_str }
14368 }
14369 { \__keys_choice_make_aux:N #1 }
14370 }
14371 { \__keys_choice_make_aux:N #1 }
14372 }
14373 \cs_new_protected:Npn \__keys_choice_make_aux:N #1
14374 {
14375 \cs_set_nopar:cpn { \c__keys_type_root_str \l_keys_path_str }
14376 { choice }
14377 \__keys_cmd_set_direct:nn \l_keys_path_str { #1 {##1} }
14378 \__keys_cmd_set_direct:nn { \l_keys_path_str / unknown }
14379 {
14380 \msg_error:nnee { keys } { choice-unknown }
14381 \l_keys_path_str {##1}
14382 }
14383 }
14384 \cs_new_protected:Npn \__keys_choices_make:nn
14385 { \__keys_choices_make:Nnn \__keys_choice_make: }
14386 \cs_new_protected:Npn \__keys_multichoices_make:nn
14387 { \__keys_choices_make:Nnn \__keys_multichoice_make: }
14388 \cs_new_protected:Npn \__keys_choices_make:Nnn #1#2#3
14389 {
14390 #1
14391 \int_zero:N \l_keys_choice_int
14392 \clist_map_inline:nn {#2}
14393 {
14394 \int_incr:N \l_keys_choice_int
14395 \__keys_cmd_set:ne
14396 { \l_keys_path_str / \__keys_trim_spaces:n {##1} }
14397 {
14398 \str_set:Nn \exp_not:N \l_keys_choice_str {##1}
14399 \tl_set:Nn \exp_not:N \l_keys_choice_tl {##1}
14400 \int_set:Nn \exp_not:N \l_keys_choice_int
14401 { \int_use:N \l_keys_choice_int }
14402 \exp_not:n {#3}
14403 }
14404 }
14405 }
14406 \cs_new_protected:Npn \__keys_cmd_set:nn #1#2
14407 { \__keys_cmd_set_direct:nn {#1} { \__keys_precompile:n {#2} } }
14408 \cs_generate_variant:Nn \__keys_cmd_set:nn { ne , Vn , Vo }
14409 \cs_new_protected:Npn \__keys_cmd_set_direct:nn #1#2
14410 { \cs_set_protected:cpn { \c__keys_code_root_str #1 } ##1 {#2} }
14411 \cs_new_protected:Npn \__keys_cs_set:NNpn #1#2#3#
14412 {
14413 \cs_set_protected:cpe { \c__keys_code_root_str \l_keys_path_str } ##1
14414 {
14415 \__keys_precompile:n
14416 { #1 \exp_not:N #2 \exp_not:n {#3} {##1} }
14417 }
14418 \use_none:n
14419 }
14420 \cs_generate_variant:Nn \__keys_cs_set:NNpn { Nc }
14421 \cs_new_protected:Npn \__keys_default_set:n #1
14422 {
14423 \tl_if_empty:nTF {#1}
14424 {
14425 \__keys_cs_undefine:c
14426 { \c__keys_default_root_str \l_keys_path_str }
14427 }
14428 {
14429 \cs_set_nopar:cpe
14430 { \c__keys_default_root_str \l_keys_path_str }
14431 { \exp_not:n {#1} }
14432 \__keys_value_requirement:nn { required } { false }
14433 }
14434 }
14435 \cs_new_protected:Npn \__keys_groups_set:n #1
14436 {
14437 \clist_set:Ne \l__keys_groups_clist { \tl_to_str:n {#1} }
14438 \clist_if_empty:NTF \l__keys_groups_clist
14439 {
14440 \__keys_cs_undefine:c
14441 { \c__keys_groups_root_str \l_keys_path_str }
14442 }
14443 {
14444 \cs_set_eq:cN { \c__keys_groups_root_str \l_keys_path_str }
14445 \l__keys_groups_clist
14446 }
14447 }
14448 \cs_new_protected:Npn \__keys_inherit:n #1
14449 {
14450 \__keys_undefine:
14451 \clist_set:Nn \l__keys_inherit_clist {#1}
14452 \cs_set_eq:cN { \c__keys_inherit_root_str \l_keys_path_str }
14453 \l__keys_inherit_clist
14454 }
14455 \cs_new_protected:Npn \__keys_initialize:n #1
14456 {
14457 \exp_after:wN \__keys_find_key_module:wNN
14458 \l_keys_path_str \s__keys_stop
14459 \l_keys_key_tl \l_keys_key_str
14460 \tl_set_eq:NN \l_keys_key_tl \l_keys_key_str
14461 \tl_set:Nn \l_keys_value_tl {#1}
14462 \cs_if_exist:cTF { \c__keys_code_root_str \l_keys_path_str }
14463 {
14464 \str_clear:N \l__keys_inherit_str
14465 \__keys_execute:nn \l_keys_path_str {#1}
14466 }
14467 {
14468 \cs_if_exist:cT
14469 { \c__keys_inherit_root_str \__keys_parent:o \l_keys_path_str }
14470 { \__keys_execute_inherit: }
14471 }
14472 }
14473 \cs_new_protected:Npn \__keys_legacy_if_set:nn #1#2
14474 { \__keys_legacy_if_set:nnnn {#1} {#2} { true } { false } }
14475 \cs_new_protected:Npn \__keys_legacy_if_set_inverse:nn #1#2
14476 { \__keys_legacy_if_set:nnnn {#1} {#2} { false } { true } }
14477 \cs_new_protected:Npn \__keys_legacy_if_set:nnnn #1#2#3#4
14478 {
14479 \__keys_choice_make:
14480 \__keys_cmd_set:ne { \l_keys_path_str / true }
14481 { \exp_not:c { legacy_if_#2 set_ #3 :n } { \exp_not:n {#1} } }
14482 \__keys_cmd_set:ne { \l_keys_path_str / false }
14483 { \exp_not:c { legacy_if_#2 set_ #4 :n } { \exp_not:n {#1} } }
14484 \__keys_cmd_set:nn { \l_keys_path_str / unknown }
14485 {
14486 \msg_error:nne { keys } { boolean-values-only }
14487 \l_keys_path_str
14488 }
14489 \__keys_default_set:n { true }
14490 \cs_if_exist:cF { if#1 }
14491 {
14492 \cs:w newif \exp_after:wN \cs_end:
14493 \cs:w if#1 \cs_end:
14494 }
14495 }
14496 \cs_new_protected:Npn \__keys_meta_make:n
14497 { \exp_args:NV \__keys_meta_make:nn \l__keys_module_str }
14498 \cs_new_protected:Npn \__keys_meta_make:nn #1#2
14499 {
14500 \exp_args:NV \__keys_cmd_set_direct:nn
14501 \l_keys_path_str { \__keys_set:nn {#1} {#2} }
14502 }
14503 \cs_new_protected:Npn \__keys_prop_put:Nn #1#2
14504 {
14505 \prop_if_exist:NF #1 { \prop_new:N #1 }
14506 \exp_after:wN \__keys_find_key_module:wNN \l_keys_path_str \s__keys_stop
14507 \l__keys_tmpa_tl \l__keys_tmpb_tl
14508 \__keys_cmd_set:ne \l_keys_path_str
14509 {
14510 \exp_not:c { prop_ #2 put:Nnn }
14511 \exp_not:N #1
14512 { \l__keys_tmpb_tl }
14513 \exp_not:n { {##1} }
14514 }
14515 }
14516 \cs_generate_variant:Nn \__keys_prop_put:Nn { c }
14517 \cs_new_protected:Npn \__keys_undefine:
14518 {
14519 \clist_map_inline:nn
14520 { code , default , groups , inherit , type , check }
14521 {
14522 \__keys_cs_undefine:c
14523 { \tl_use:c { c__keys_ ##1 _root_str } \l_keys_path_str }
14524 }
14525 }
14526 \cs_new_protected:Npn \__keys_value_requirement:nn #1#2
14527 {
14528 \str_case:nnF {#2}
14529 {
14530 { true }
14531 {
14532 \cs_set_eq:cc
14533 { \c__keys_check_root_str \l_keys_path_str }
14534 { __keys_check_ #1 : }
14535 }
14536 { false }
14537 {
14538 \cs_if_eq:ccT
14539 { \c__keys_check_root_str \l_keys_path_str }
14540 { __keys_check_ #1 : }
14541 {
14542 \__keys_cs_undefine:c
14543 { \c__keys_check_root_str \l_keys_path_str }
14544 }
14545 }
14546 }
14547 {
14548 \msg_error:nne { keys }
14549 { boolean-values-only }
14550 { .value_ #1 :n }
14551 }
14552 }
14553 \cs_new_protected:Npn \__keys_check_forbidden:
14554 {
14555 \bool_if:NF \l__keys_no_value_bool
14556 {
14557 \msg_error:nnee { keys } { value-forbidden }
14558 \l_keys_path_str \l_keys_value_tl
14559 \use_none:nnn
14560 }
14561 }
14562 \cs_new_protected:Npn \__keys_check_required:
14563 {
14564 \bool_if:NT \l__keys_no_value_bool
14565 {
14566 \msg_error:nne { keys } { value-required }
14567 \l_keys_path_str
14568 \use_none:nnn
14569 }
14570 }
14571 \cs_new_protected:Npn \__keys_usage:n #1
14572 {
14573 \str_case:nnF {#1}
14574 {
14575 { general }
14576 {
14577 \__keys_usage:NN \l_keys_usage_load_prop
14578 \c_false_bool
14579 \__keys_usage:NN \l_keys_usage_preamble_prop
14580 \c_false_bool
14581 }
14582 { load }
14583 {
14584 \__keys_usage:NN \l_keys_usage_load_prop
14585 \c_true_bool
14586 \__keys_usage:NN \l_keys_usage_preamble_prop
14587 \c_false_bool
14588 }
14589 { preamble }
14590 {
14591 \__keys_usage:NN \l_keys_usage_load_prop
14592 \c_false_bool
14593 \__keys_usage:NN \l_keys_usage_preamble_prop
14594 \c_true_bool
14595 }
14596 }
14597 {
14598 \msg_error:nnnn { keys }
14599 { choice-unknown }
14600 { .usage:n }
14601 {#1}
14602 }
14603 }
14604 \cs_new_protected:Npn \__keys_usage:NN #1#2
14605 {
14606 \prop_get:NVNF #1 \l__keys_module_str \l__keys_tmpa_tl
14607 { \tl_clear:N \l__keys_tmpa_tl }
14608 \tl_set:Ne \l__keys_tmpb_tl
14609 {
14610 \exp_after:wN \exp_after:wN \exp_after:wN \__keys_usage:w \exp_after:wN
14611 \l_keys_path_str \exp_after:wN / \exp_after:wN \s__keys_stop
14612 \exp_after:wN { \l_keys_path_str }
14613 }
14614 \bool_if:NTF #2
14615 { \clist_put_right:NV \l__keys_tmpa_tl \l__keys_tmpb_tl }
14616 { \clist_remove_all:NV \l__keys_tmpa_tl \l__keys_tmpb_tl }
14617 \prop_put:NVV #1 \l__keys_module_str
14618 \l__keys_tmpa_tl
14619 }
14620 \cs_new:Npn \__keys_usage:w #1 / #2 \s__keys_stop #3
14621 {
14622 \tl_if_blank:nTF {#2}
14623 {#1}
14624 { \__keys_usage_aux:w #3 \s__keys_stop }
14625 }
14626 \cs_new:Npn \__keys_usage_aux:w #1 / #2 \s__keys_stop {#2}
14627 \cs_new_protected:Npn \__keys_variable_set:NnnN #1#2#3#4
14628 {
14629 \use:c { #2_if_exist:NF } #1 { \use:c { #2 _new:N } #1 }
14630 \__keys_cmd_set:ne \l_keys_path_str
14631 {
14632 \exp_not:c { #2 _ #3 set:N #4 }
14633 \exp_not:N #1
14634 \exp_not:n { {##1} }
14635 }
14636 }
14637 \cs_generate_variant:Nn \__keys_variable_set:NnnN { c }
14638 \cs_new_protected:Npn \__keys_variable_set_required:NnnN #1#2#3#4
14639 {
14640 \__keys_variable_set:NnnN #1 {#2} {#3} #4
14641 \__keys_value_requirement:nn { required } { true }
14642 }
14643 \cs_generate_variant:Nn \__keys_variable_set_required:NnnN { c }
14644 \cs_new_protected:cpn { \c__keys_props_root_str .bool_set:N } #1
14645 { \__keys_bool_set:Nn #1 { } }
14646 \cs_new_protected:cpn { \c__keys_props_root_str .bool_set:c } #1
14647 { \__keys_bool_set:cn {#1} { } }
14648 \cs_new_protected:cpn { \c__keys_props_root_str .bool_gset:N } #1
14649 { \__keys_bool_set:Nn #1 { g } }
14650 \cs_new_protected:cpn { \c__keys_props_root_str .bool_gset:c } #1
14651 { \__keys_bool_set:cn {#1} { g } }
14652 \cs_new_protected:cpn { \c__keys_props_root_str .bool_set_inverse:N } #1
14653 { \__keys_bool_set_inverse:Nn #1 { } }
14654 \cs_new_protected:cpn { \c__keys_props_root_str .bool_set_inverse:c } #1
14655 { \__keys_bool_set_inverse:cn {#1} { } }
14656 \cs_new_protected:cpn { \c__keys_props_root_str .bool_gset_inverse:N } #1
14657 { \__keys_bool_set_inverse:Nn #1 { g } }
14658 \cs_new_protected:cpn { \c__keys_props_root_str .bool_gset_inverse:c } #1
14659 { \__keys_bool_set_inverse:cn {#1} { g } }
14660 \cs_new_protected:cpn { \c__keys_props_root_str .choice: }
14661 { \__keys_choice_make: }
14662 \cs_new_protected:cpn { \c__keys_props_root_str .choices:nn } #1
14663 { \__keys_choices_make:nn #1 }
14664 \cs_new_protected:cpn { \c__keys_props_root_str .choices:Vn } #1
14665 { \exp_args:NV \__keys_choices_make:nn #1 }
14666 \cs_new_protected:cpn { \c__keys_props_root_str .choices:en } #1
14667 { \exp_args:Ne \__keys_choices_make:nn #1 }
14668 \cs_new_protected:cpn { \c__keys_props_root_str .choices:on } #1
14669 { \exp_args:No \__keys_choices_make:nn #1 }
14670 \cs_new_protected:cpn { \c__keys_props_root_str .choices:xn } #1
14671 { \exp_args:Nx \__keys_choices_make:nn #1 }
14672 \cs_new_protected:cpn { \c__keys_props_root_str .code:n } #1
14673 { \__keys_cmd_set:nn \l_keys_path_str {#1} }
14674 \cs_new_protected:cpn { \c__keys_props_root_str .clist_set:N } #1
14675 { \__keys_variable_set:NnnN #1 { clist } { } n }
14676 \cs_new_protected:cpn { \c__keys_props_root_str .clist_set:c } #1
14677 { \__keys_variable_set:cnnN {#1} { clist } { } n }
14678 \cs_new_protected:cpn { \c__keys_props_root_str .clist_gset:N } #1
14679 { \__keys_variable_set:NnnN #1 { clist } { g } n }
14680 \cs_new_protected:cpn { \c__keys_props_root_str .clist_gset:c } #1
14681 { \__keys_variable_set:cnnN {#1} { clist } { g } n }
14682 \cs_new_protected:cpn { \c__keys_props_root_str .cs_set:Np } #1
14683 { \__keys_cs_set:NNpn \cs_set:Npn #1 { } }
14684 \cs_new_protected:cpn { \c__keys_props_root_str .cs_set:cp } #1
14685 { \__keys_cs_set:Ncpn \cs_set:Npn #1 { } }
14686 \cs_new_protected:cpn { \c__keys_props_root_str .cs_set_protected:Np } #1
14687 { \__keys_cs_set:NNpn \cs_set_protected:Npn #1 { } }
14688 \cs_new_protected:cpn { \c__keys_props_root_str .cs_set_protected:cp } #1
14689 { \__keys_cs_set:Ncpn \cs_set_protected:Npn #1 { } }
14690 \cs_new_protected:cpn { \c__keys_props_root_str .cs_gset:Np } #1
14691 { \__keys_cs_set:NNpn \cs_gset:Npn #1 { } }
14692 \cs_new_protected:cpn { \c__keys_props_root_str .cs_gset:cp } #1
14693 { \__keys_cs_set:Ncpn \cs_gset:Npn #1 { } }
14694 \cs_new_protected:cpn { \c__keys_props_root_str .cs_gset_protected:Np } #1
14695 { \__keys_cs_set:NNpn \cs_gset_protected:Npn #1 { } }
14696 \cs_new_protected:cpn { \c__keys_props_root_str .cs_gset_protected:cp } #1
14697 { \__keys_cs_set:Ncpn \cs_gset_protected:Npn #1 { } }
14698 \cs_new_protected:cpn { \c__keys_props_root_str .default:n } #1
14699 { \__keys_default_set:n {#1} }
14700 \cs_new_protected:cpn { \c__keys_props_root_str .default:V } #1
14701 { \exp_args:NV \__keys_default_set:n #1 }
14702 \cs_new_protected:cpn { \c__keys_props_root_str .default:e } #1
14703 { \exp_args:Ne \__keys_default_set:n {#1} }
14704 \cs_new_protected:cpn { \c__keys_props_root_str .default:o } #1
14705 { \exp_args:No \__keys_default_set:n {#1} }
14706 \cs_new_protected:cpn { \c__keys_props_root_str .default:x } #1
14707 { \exp_args:Nx \__keys_default_set:n {#1} }
14708 \cs_new_protected:cpn { \c__keys_props_root_str .dim_set:N } #1
14709 { \__keys_variable_set_required:NnnN #1 { dim } { } n }
14710 \cs_new_protected:cpn { \c__keys_props_root_str .dim_set:c } #1
14711 { \__keys_variable_set_required:cnnN {#1} { dim } { } n }
14712 \cs_new_protected:cpn { \c__keys_props_root_str .dim_gset:N } #1
14713 { \__keys_variable_set_required:NnnN #1 { dim } { g } n }
14714 \cs_new_protected:cpn { \c__keys_props_root_str .dim_gset:c } #1
14715 { \__keys_variable_set_required:cnnN {#1} { dim } { g } n }
14716 \cs_new_protected:cpn { \c__keys_props_root_str .fp_set:N } #1
14717 { \__keys_variable_set_required:NnnN #1 { fp } { } n }
14718 \cs_new_protected:cpn { \c__keys_props_root_str .fp_set:c } #1
14719 { \__keys_variable_set_required:cnnN {#1} { fp } { } n }
14720 \cs_new_protected:cpn { \c__keys_props_root_str .fp_gset:N } #1
14721 { \__keys_variable_set_required:NnnN #1 { fp } { g } n }
14722 \cs_new_protected:cpn { \c__keys_props_root_str .fp_gset:c } #1
14723 { \__keys_variable_set_required:cnnN {#1} { fp } { g } n }
14724 \cs_new_protected:cpn { \c__keys_props_root_str .groups:n } #1
14725 { \__keys_groups_set:n {#1} }
14726 \cs_new_protected:cpn { \c__keys_props_root_str .inherit:n } #1
14727 { \__keys_inherit:n {#1} }
14728 \cs_new_protected:cpn { \c__keys_props_root_str .initial:n } #1
14729 { \__keys_initialize:n {#1} }
14730 \cs_new_protected:cpn { \c__keys_props_root_str .initial:V } #1
14731 { \exp_args:NV \__keys_initialize:n #1 }
14732 \cs_new_protected:cpn { \c__keys_props_root_str .initial:e } #1
14733 { \exp_args:Ne \__keys_initialize:n {#1} }
14734 \cs_new_protected:cpn { \c__keys_props_root_str .initial:o } #1
14735 { \exp_args:No \__keys_initialize:n {#1} }
14736 \cs_new_protected:cpn { \c__keys_props_root_str .initial:x } #1
14737 { \exp_args:Nx \__keys_initialize:n {#1} }
14738 \cs_new_protected:cpn { \c__keys_props_root_str .int_set:N } #1
14739 { \__keys_variable_set_required:NnnN #1 { int } { } n }
14740 \cs_new_protected:cpn { \c__keys_props_root_str .int_set:c } #1
14741 { \__keys_variable_set_required:cnnN {#1} { int } { } n }
14742 \cs_new_protected:cpn { \c__keys_props_root_str .int_gset:N } #1
14743 { \__keys_variable_set_required:NnnN #1 { int } { g } n }
14744 \cs_new_protected:cpn { \c__keys_props_root_str .int_gset:c } #1
14745 { \__keys_variable_set_required:cnnN {#1} { int } { g } n }
14746 \cs_new_protected:cpn { \c__keys_props_root_str .legacy_if_set:n } #1
14747 { \__keys_legacy_if_set:nn {#1} { } }
14748 \cs_new_protected:cpn { \c__keys_props_root_str .legacy_if_gset:n } #1
14749 { \__keys_legacy_if_set:nn {#1} { g } }
14750 \cs_new_protected:cpn { \c__keys_props_root_str .legacy_if_set_inverse:n } #1
14751 { \__keys_legacy_if_set_inverse:nn {#1} { } }
14752 \cs_new_protected:cpn { \c__keys_props_root_str .legacy_if_gset_inverse:n } #1
14753 { \__keys_legacy_if_set_inverse:nn {#1} { g } }
14754 \cs_new_protected:cpn { \c__keys_props_root_str .meta:n } #1
14755 { \__keys_meta_make:n {#1} }
14756 \cs_new_protected:cpn { \c__keys_props_root_str .meta:nn } #1
14757 { \__keys_meta_make:nn #1 }
14758 \cs_new_protected:cpn { \c__keys_props_root_str .multichoice: }
14759 { \__keys_multichoice_make: }
14760 \cs_new_protected:cpn { \c__keys_props_root_str .multichoices:nn } #1
14761 { \__keys_multichoices_make:nn #1 }
14762 \cs_new_protected:cpn { \c__keys_props_root_str .multichoices:Vn } #1
14763 { \exp_args:NV \__keys_multichoices_make:nn #1 }
14764 \cs_new_protected:cpn { \c__keys_props_root_str .multichoices:en } #1
14765 { \exp_args:Ne \__keys_multichoices_make:nn #1 }
14766 \cs_new_protected:cpn { \c__keys_props_root_str .multichoices:on } #1
14767 { \exp_args:No \__keys_multichoices_make:nn #1 }
14768 \cs_new_protected:cpn { \c__keys_props_root_str .multichoices:xn } #1
14769 { \exp_args:Nx \__keys_multichoices_make:nn #1 }
14770 \cs_new_protected:cpn { \c__keys_props_root_str .muskip_set:N } #1
14771 { \__keys_variable_set_required:NnnN #1 { muskip } { } n }
14772 \cs_new_protected:cpn { \c__keys_props_root_str .muskip_set:c } #1
14773 { \__keys_variable_set_required:cnnN {#1} { muskip } { } n }
14774 \cs_new_protected:cpn { \c__keys_props_root_str .muskip_gset:N } #1
14775 { \__keys_variable_set_required:NnnN #1 { muskip } { g } n }
14776 \cs_new_protected:cpn { \c__keys_props_root_str .muskip_gset:c } #1
14777 { \__keys_variable_set_required:cnnN {#1} { muskip } { g } n }
14778 \cs_new_protected:cpn { \c__keys_props_root_str .prop_put:N } #1
14779 { \__keys_prop_put:Nn #1 { } }
14780 \cs_new_protected:cpn { \c__keys_props_root_str .prop_put:c } #1
14781 { \__keys_prop_put:cn {#1} { } }
14782 \cs_new_protected:cpn { \c__keys_props_root_str .prop_gput:N } #1
14783 { \__keys_prop_put:Nn #1 { g } }
14784 \cs_new_protected:cpn { \c__keys_props_root_str .prop_gput:c } #1
14785 { \__keys_prop_put:cn {#1} { g } }
14786 \cs_new_protected:cpn { \c__keys_props_root_str .skip_set:N } #1
14787 { \__keys_variable_set_required:NnnN #1 { skip } { } n }
14788 \cs_new_protected:cpn { \c__keys_props_root_str .skip_set:c } #1
14789 { \__keys_variable_set_required:cnnN {#1} { skip } { } n }
14790 \cs_new_protected:cpn { \c__keys_props_root_str .skip_gset:N } #1
14791 { \__keys_variable_set_required:NnnN #1 { skip } { g } n }
14792 \cs_new_protected:cpn { \c__keys_props_root_str .skip_gset:c } #1
14793 { \__keys_variable_set_required:cnnN {#1} { skip } { g } n }
14794 \cs_new_protected:cpn { \c__keys_props_root_str .str_set:N } #1
14795 { \__keys_variable_set:NnnN #1 { str } { } n }
14796 \cs_new_protected:cpn { \c__keys_props_root_str .str_set:c } #1
14797 { \__keys_variable_set:cnnN {#1} { str } { } n }
14798 \cs_new_protected:cpn { \c__keys_props_root_str .str_set_e:N } #1
14799 { \__keys_variable_set:NnnN #1 { str } { } e }
14800 \cs_new_protected:cpn { \c__keys_props_root_str .str_set_e:c } #1
14801 { \__keys_variable_set:cnnN {#1} { str } { } e }
14802 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset:N } #1
14803 { \__keys_variable_set:NnnN #1 { str } { g } n }
14804 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset:c } #1
14805 { \__keys_variable_set:cnnN {#1} { str } { g } n }
14806 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset_e:N } #1
14807 { \__keys_variable_set:NnnN #1 { str } { g } e }
14808 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset_e:c } #1
14809 { \__keys_variable_set:cnnN {#1} { str } { g } e }
14810 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set:N } #1
14811 { \__keys_variable_set:NnnN #1 { tl } { } n }
14812 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set:c } #1
14813 { \__keys_variable_set:cnnN {#1} { tl } { } n }
14814 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set_e:N } #1
14815 { \__keys_variable_set:NnnN #1 { tl } { } e }
14816 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set_e:c } #1
14817 { \__keys_variable_set:cnnN {#1} { tl } { } e }
14818 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset:N } #1
14819 { \__keys_variable_set:NnnN #1 { tl } { g } n }
14820 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset:c } #1
14821 { \__keys_variable_set:cnnN {#1} { tl } { g } n }
14822 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset_e:N } #1
14823 { \__keys_variable_set:NnnN #1 { tl } { g } e }
14824 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset_e:c } #1
14825 { \__keys_variable_set:cnnN {#1} { tl } { g } e }
14826 \cs_new_protected:cpn { \c__keys_props_root_str .undefine: }
14827 { \__keys_undefine: }
14828 \cs_new_protected:cpn { \c__keys_props_root_str .usage:n } #1
14829 { \__keys_usage:n {#1} }
14830 \cs_new_protected:cpn { \c__keys_props_root_str .value_forbidden:n } #1
14831 { \__keys_value_requirement:nn { forbidden } {#1} }
14832 \cs_new_protected:cpn { \c__keys_props_root_str .value_required:n } #1
14833 { \__keys_value_requirement:nn { required } {#1} }
14834 \cs_new_protected:Npn \__keys_set:nnnnNn #1#2#3#4#5#6
14835 {
14836 \use:e
14837 {
14838 \exp_not:n
14839 {
14840 \clist_clear:N \l__keys_unused_clist
14841 \clist_set:Ne \l__keys_selective_clist { \tl_to_str:n {#2} }
14842 \tl_set:Nn \l__keys_relative_tl {#4}
14843 #6
14844 \__keys_set:nn {#1} {#3}
14845 \clist_set_eq:NN #5 \l__keys_unused_clist
14846 }
14847 \__keys_reset_bool:N \l__keys_only_known_bool
14848 \__keys_reset_bool:N \l__keys_exclude_bool
14849 \__keys_reset_bool:N \l__keys_selective_bool
14850 \__keys_reset_var:N \l__keys_unused_clist
14851 \__keys_reset_var:N \l__keys_selective_clist
14852 \__keys_reset_var:N \l__keys_relative_tl
14853 \__keys_reset_var:N \l__keys_inherit_str
14854 \__keys_reset_var:N \l_keys_choice_tl
14855 \__keys_reset_var:N \l_keys_choice_str
14856 \__keys_reset_var:N \l_keys_key_tl
14857 \__keys_reset_var:N \l_keys_key_str
14858 \__keys_reset_var:N \l_keys_path_tl
14859 \__keys_reset_var:N \l_keys_path_str
14860 \__keys_reset_var:N \l_keys_value_tl
14861 \int_set:Nn \l_keys_choice_int { \int_use:N \l_keys_choice_int }
14862 }
14863 }
14864 \cs_new:Npn \__keys_reset_bool:N #1
14865 {
14866 \exp_not:c
14867 { bool_set_ \bool_if:NTF #1 { true } { false } :N }
14868 \exp_not:N #1
14869 }
14870 \cs_new:Npn \__keys_reset_var:N #1
14871 {
14872 \exp_not:n
14873 { \__kernel_tl_set:Nx #1 }
14874 { \exp_not:N \exp_not:n { \exp_not:o { #1 } } }
14875 }
14876 \cs_new_protected:Npn \__keys_set:nn #1#2
14877 { \exp_args:No \__keys_set:nnn \l__keys_module_str {#1} {#2} }
14878 \cs_new_protected:Npn \__keys_set:nnn #1#2#3
14879 {
14880 \str_set:Ne \l__keys_module_str { \__keys_trim_spaces:n {#2} }
14881 \keyval_parse:NNn \__keys_set_keyval:n \__keys_set_keyval:nn {#3}
14882 \str_set:Nn \l__keys_module_str {#1}
14883 }
14884 \cs_new_protected:Npn \keys_set:nn #1#2
14885 {
14886 \__keys_set:nnnnNn
14887 {#1} { } {#2} { \q__keys_no_value } \l__keys_tmp_clist
14888 {
14889 \bool_set_false:N \l__keys_only_known_bool
14890 \bool_set_false:N \l__keys_exclude_bool
14891 \bool_set_false:N \l__keys_selective_bool
14892 }
14893 }
14894 \cs_generate_variant:Nn \keys_set:nn { nV , nv , ne , no , nx }
14895 \cs_new_protected:Npn \keys_set_known:nnnN #1#2#3#4
14896 {
14897 \__keys_set:nnnnNn
14898 {#1} { } {#2} {#3} #4
14899 {
14900 \bool_set_true:N \l__keys_only_known_bool
14901 \bool_set_false:N \l__keys_exclude_bool
14902 \bool_set_false:N \l__keys_selective_bool
14903 }
14904 }
14905 \cs_generate_variant:Nn \keys_set_known:nnnN { nV , nv , ne , no }
14906 \cs_new_protected:Npn \keys_set_known:nnN #1#2#3
14907 { \keys_set_known:nnnN {#1} {#2} { \q__keys_no_value } #3 }
14908 \cs_generate_variant:Nn \keys_set_known:nnN { nV , nv , ne , no }
14909 \cs_new_protected:Npn \keys_set_known:nn #1#2
14910 { \keys_set_known:nnnN {#1} {#2} { \q__keys_no_value } \l__keys_tmp_clist }
14911 \cs_generate_variant:Nn \keys_set_known:nn { nV , nv , ne , no }
14912 \cs_new_protected:Npn \keys_set_exclude_groups:nnnnN #1#2#3#4#5
14913 {
14914 \__keys_set:nnnnNn
14915 {#1} {#2} {#3} {#4} #5
14916 {
14917 \bool_set_false:N \l__keys_only_known_bool
14918 \bool_set_true:N \l__keys_exclude_bool
14919 \bool_set_true:N \l__keys_selective_bool
14920 }
14921 }
14922 \cs_generate_variant:Nn \keys_set_exclude_groups:nnnnN { nnV , nnv , nno }
14923 \cs_new_protected:Npn \keys_set_exclude_groups:nnnN #1#2#3#4
14924 { \keys_set_exclude_groups:nnnnN {#1} {#2} {#3} { \q__keys_no_value } #4 }
14925 \cs_generate_variant:Nn \keys_set_exclude_groups:nnnN { nnV , nnv , nno }
14926 \cs_new_protected:Npn \keys_set_exclude_groups:nnn #1#2#3
14927 {
14928 \keys_set_exclude_groups:nnnnN {#1} {#2} {#3}
14929 { \q__keys_no_value } \l__keys_tmp_clist
14930 }
14931 \cs_generate_variant:Nn \keys_set_exclude_groups:nnn { nnV , nnv , nno }
14932 \cs_new_protected:Npn \keys_set_groups:nnnnN #1#2#3#4#5
14933 {
14934 \__keys_set:nnnnNn
14935 {#1} {#2} {#3} {#4} #5
14936 {
14937 \bool_set_false:N \l__keys_only_known_bool
14938 \bool_set_false:N \l__keys_exclude_bool
14939 \bool_set_true:N \l__keys_selective_bool
14940 }
14941 }
14942 \cs_generate_variant:Nn \keys_set_groups:nnnnN { nnV , nnv , nno }
14943 \cs_new_protected:Npn \keys_set_groups:nnnN #1#2#3#4
14944 { \keys_set_groups:nnnnN {#1} {#2} {#3} { \q__keys_no_value } #4 }
14945 \cs_generate_variant:Nn \keys_set_groups:nnnN { nnV , nnv , nno }
14946 \cs_new_protected:Npn \keys_set_groups:nnn #1#2#3
14947 {
14948 \keys_set_groups:nnnnN {#1} {#2} {#3}
14949 { \q__keys_no_value } \l__keys_tmp_clist
14950 }
14951 \cs_generate_variant:Nn \keys_set_groups:nnn { nnV , nnv , nno }
14952 \cs_new_protected:Npn \keys_precompile:nnN #1#2#3
14953 {
14954 \bool_set_true:N \l__keys_precompile_bool
14955 \tl_clear:N \l__keys_precompile_tl
14956 \keys_set:nn {#1} {#2}
14957 \bool_set_false:N \l__keys_precompile_bool
14958 \tl_set_eq:NN #3 \l__keys_precompile_tl
14959 }
14960 \cs_new_protected:Npn \__keys_set_keyval:n #1
14961 {
14962 \bool_set_true:N \l__keys_no_value_bool
14963 \__keys_set_keyval:onn \l__keys_module_str {#1} { }
14964 }
14965 \cs_new_protected:Npn \__keys_set_keyval:nn #1#2
14966 {
14967 \bool_set_false:N \l__keys_no_value_bool
14968 \__keys_set_keyval:onn \l__keys_module_str {#1} {#2}
14969 }
14970 \cs_new_protected:Npn \__keys_set_keyval:nnn #1#2#3
14971 {
14972 \__kernel_tl_set:Nx \l_keys_path_str
14973 {
14974 \tl_if_blank:nF {#1}
14975 { #1 / }
14976 \__keys_trim_spaces:n {#2}
14977 }
14978 \str_clear:N \l__keys_module_str
14979 \str_clear:N \l__keys_inherit_str
14980 \exp_after:wN \__keys_find_key_module:wNN \l_keys_path_str \s__keys_stop
14981 \l__keys_module_str \l_keys_key_str
14982 \str_set:Ne \l_keys_path_str
14983 {
14984 \l__keys_module_str
14985 \str_if_empty:NF \l__keys_module_str { / }
14986 \l_keys_key_str
14987 }
14988 \tl_set_eq:NN \l_keys_key_tl \l_keys_key_str
14989 \__keys_value_or_default:n {#3}
14990 \bool_if:NTF \l__keys_selective_bool
14991 \__keys_set_selective:
14992 \__keys_execute:
14993 \str_set:Nn \l__keys_module_str {#1}
14994 }
14995 \cs_generate_variant:Nn \__keys_set_keyval:nnn { o }
14996 \cs_new_protected:Npn \__keys_find_key_module:wNN #1 \s__keys_stop #2#3
14997 {
14998 \__keys_find_key_module_auxi:Nw #2 #1 \s__keys_nil \__keys_find_key_module_auxii:Nw
14999 / \s__keys_nil \__keys_find_key_module_auxiv:Nw #3
15000 }
15001 \cs_new_protected:Npn \__keys_find_key_module_auxi:Nw #1 #2 / #3 \s__keys_nil #4
15002 {
15003 #4 #1 #2 \s__keys_mark #3 \s__keys_nil #4
15004 }
15005 \cs_new_protected:Npn \__keys_find_key_module_auxii:Nw
15006 #1 #2 \s__keys_mark #3 \s__keys_nil \__keys_find_key_module_auxii:Nw
15007 {
15008 \cs_set_nopar:Npe #1 { \tl_if_empty:NF #1 { #1 / } #2 }
15009 \__keys_find_key_module_auxi:Nw #1 #3 \s__keys_nil \__keys_find_key_module_auxiii:Nw
15010 }
15011 \cs_new_protected:Npn \__keys_find_key_module_auxiii:Nw #1 #2 \s__keys_mark
15012 {
15013 \cs_set_nopar:Npe #1 { \tl_if_empty:NF #1 { #1 / } #2 }
15014 \__keys_find_key_module_auxi:Nw #1
15015 }
15016 \cs_new_protected:Npe \__keys_find_key_module_auxiv:Nw
15017 #1 #2 \s__keys_nil #3 \s__keys_mark
15018 \s__keys_nil \__keys_find_key_module_auxiv:Nw #4
15019 {
15020 \exp_not:N \__keys_find_key_module_auxv:Nw #4
15021 #2 \token_to_str:N : n \token_to_str:N : \s__keys_mark
15022 }
15023 \use:e
15024 {
15025 \cs_new_protected:Npn \exp_not:N \__keys_find_key_module_auxv:Nw
15026 #1 #2 \token_to_str:N : #3 \token_to_str:N : #4 \s__keys_mark
15027 }
15028 {
15029 \cs_set_nopar:Npn #1 {#2}
15030 \cs_set_nopar:Npn \l__keys_exp_str {#3}
15031 }
15032 \cs_new_protected:Npn \__keys_set_selective:
15033 {
15034 \cs_if_exist:cTF { \c__keys_groups_root_str \l_keys_path_str }
15035 {
15036 \clist_set_eq:Nc \l__keys_groups_clist
15037 { \c__keys_groups_root_str \l_keys_path_str }
15038 \__keys_check_groups:
15039 }
15040 {
15041 \bool_if:NTF \l__keys_exclude_bool
15042 \__keys_execute:
15043 \__keys_store_unused:
15044 }
15045 }
15046 \cs_new_protected:Npn \__keys_check_groups:
15047 {
15048 \bool_set_false:N \l__keys_tmp_bool
15049 \clist_map_inline:Nn \l__keys_selective_clist
15050 {
15051 \clist_if_in:NnT \l__keys_groups_clist {##1}
15052 {
15053 \bool_set_true:N \l__keys_tmp_bool
15054 \clist_map_break:
15055 }
15056 }
15057 \bool_if:NTF \l__keys_tmp_bool
15058 {
15059 \bool_if:NTF \l__keys_exclude_bool
15060 \__keys_store_unused:
15061 \__keys_execute:
15062 }
15063 {
15064 \bool_if:NTF \l__keys_exclude_bool
15065 \__keys_execute:
15066 \__keys_store_unused:
15067 }
15068 }
15069 \cs_new_protected:Npn \__keys_value_or_default:n #1
15070 {
15071 \bool_if:NTF \l__keys_no_value_bool
15072 {
15073 \cs_if_exist:cTF { \c__keys_default_root_str \l_keys_path_str }
15074 {
15075 \tl_set_eq:Nc
15076 \l_keys_value_tl
15077 { \c__keys_default_root_str \l_keys_path_str }
15078 }
15079 {
15080 \tl_clear:N \l_keys_value_tl
15081 \cs_if_exist:cT
15082 { \c__keys_inherit_root_str \__keys_parent:o \l_keys_path_str }
15083 { \__keys_default_inherit: }
15084 }
15085 }
15086 {
15087 \cs_if_exist_use:cF { __keys_value_set:N \l__keys_exp_str }
15088 {
15089 \msg_error:nnV { keys } { unknown-expansion } \l__keys_exp_str
15090 \use_none:nn
15091 }
15092 \l_keys_value_tl {#1}
15093 }
15094 }
15095 \cs_new_protected:Npn \__keys_default_inherit:
15096 {
15097 \clist_map_inline:cn
15098 { \c__keys_inherit_root_str \__keys_parent:o \l_keys_path_str }
15099 {
15100 \cs_if_exist:cT
15101 { \c__keys_default_root_str ##1 / \l_keys_key_str }
15102 {
15103 \tl_set_eq:Nc
15104 \l_keys_value_tl
15105 { \c__keys_default_root_str ##1 / \l_keys_key_str }
15106 \clist_map_break:
15107 }
15108 }
15109 }
15110 \cs_new_eq:NN \__keys_value_set:Nn \tl_set:Nn
15111 \cs_generate_variant:Nn \__keys_value_set:Nn { No , NV , Nv , Ne }
15112 \cs_new_protected:Npn \__keys_value_set:NN #1#2 { \tl_set:Nn #1 {#2} }
15113 \cs_generate_variant:Nn \__keys_value_set:NN { Nc }
15114 \cs_new_protected:Npn \__keys_execute:
15115 {
15116 \cs_if_exist:cTF { \c__keys_code_root_str \l_keys_path_str }
15117 {
15118 \cs_if_exist_use:c { \c__keys_check_root_str \l_keys_path_str }
15119 \__keys_execute:no \l_keys_path_str \l_keys_value_tl
15120 }
15121 {
15122 \cs_if_exist:cTF
15123 { \c__keys_inherit_root_str \__keys_parent:o \l_keys_path_str }
15124 { \__keys_execute_inherit: }
15125 { \__keys_execute_unknown: }
15126 }
15127 }
15128 \cs_new_protected:Npn \__keys_execute_inherit:
15129 {
15130 \bool_set_false:N \l__keys_inherit_bool
15131 \clist_map_inline:cn
15132 { \c__keys_inherit_root_str \__keys_parent:o \l_keys_path_str }
15133 { \__keys_execute_inherit:n {##1} }
15134 \bool_if:NF \l__keys_inherit_bool
15135 { \__keys_execute_unknown: }
15136 }
15137 \cs_new_protected:Npn \__keys_execute_inherit:n #1
15138 {
15139 \cs_if_exist:cTF
15140 { \c__keys_code_root_str #1 / \l_keys_key_str }
15141 {
15142 \str_set:Nn \l__keys_inherit_str {#1}
15143 \cs_if_exist_use:c { \c__keys_check_root_str #1 / \l_keys_key_str }
15144 \__keys_execute:no { #1 / \l_keys_key_str } \l_keys_value_tl
15145 \clist_map_break:n
15146 { \bool_set_true:N \l__keys_inherit_bool }
15147 }
15148 {
15149 \cs_if_exist:cT
15150 { \c__keys_inherit_root_str #1 }
15151 {
15152 \clist_map_inline:cn { \c__keys_inherit_root_str #1 }
15153 { \__keys_execute_inherit:n {##1} }
15154 \bool_if:NT \l__keys_inherit_bool
15155 { \clist_map_break: }
15156 }
15157 }
15158 }
15159 \cs_new_protected:Npn \__keys_execute_unknown:
15160 {
15161 \bool_if:NTF \l__keys_only_known_bool
15162 { \__keys_store_unused: }
15163 {
15164 \cs_if_exist:cTF
15165 { \c__keys_code_root_str \l__keys_module_str / unknown }
15166 {
15167 \bool_if:NT \l__keys_no_value_bool
15168 {
15169 \cs_if_exist:cT
15170 { \c__keys_default_root_str \l__keys_module_str / unknown }
15171 {
15172 \tl_set_eq:Nc
15173 \l_keys_value_tl
15174 { \c__keys_default_root_str \l__keys_module_str / unknown }
15175 }
15176 }
15177 \__keys_execute:no { \l__keys_module_str / unknown } \l_keys_value_tl
15178 }
15179 {
15180 \msg_error:nnee { keys } { unknown }
15181 \l_keys_path_str \l__keys_module_str
15182 }
15183 }
15184 }
15185 \cs_new:Npn \__keys_execute:nn #1#2
15186 { \__keys_execute:no {#1} { \prg_do_nothing: #2 } }
15187 \cs_new:Npn \__keys_execute:no #1#2
15188 {
15189 \exp_args:NNo \exp_args:No \use:n
15190 {
15191 \cs:w \c__keys_code_root_str #1 \exp_after:wN \cs_end:
15192 \exp_after:wN {#2}
15193 }
15194 }
15195 \cs_new_protected:Npn \__keys_store_unused:
15196 {
15197 \__keys_quark_if_no_value:NTF \l__keys_relative_tl
15198 {
15199 \clist_put_right:Ne \l__keys_unused_clist
15200 {
15201 \l_keys_key_str
15202 \bool_if:NF \l__keys_no_value_bool
15203 { = { \exp_not:o \l_keys_value_tl } }
15204 }
15205 }
15206 {
15207 \tl_if_empty:NTF \l__keys_relative_tl
15208 {
15209 \clist_put_right:Ne \l__keys_unused_clist
15210 {
15211 \l_keys_path_str
15212 \bool_if:NF \l__keys_no_value_bool
15213 { = { \exp_not:o \l_keys_value_tl } }
15214 }
15215 }
15216 { \__keys_store_unused_aux: }
15217 }
15218 }
15219 \cs_new_protected:Npn \__keys_store_unused_aux:
15220 {
15221 \__kernel_tl_set:Nx \l__keys_relative_tl
15222 { \exp_args:No \__keys_trim_spaces:n \l__keys_relative_tl }
15223 \use:e
15224 {
15225 \cs_set_protected:Npn \__keys_store_unused:w
15226 ##1 \l__keys_relative_tl /
15227 ##2 \l__keys_relative_tl /
15228 ##3 \s__keys_stop
15229 }
15230 {
15231 \tl_if_blank:nF {##1}
15232 {
15233 \msg_error:nnee { keys } { bad-relative-key-path }
15234 \l_keys_path_str
15235 \l__keys_relative_tl
15236 }
15237 \clist_put_right:Ne \l__keys_unused_clist
15238 {
15239 \exp_not:n {##2}
15240 \bool_if:NF \l__keys_no_value_bool
15241 { = { \exp_not:o \l_keys_value_tl } }
15242 }
15243 }
15244 \use:e
15245 {
15246 \__keys_store_unused:w \l_keys_path_str
15247 \l__keys_relative_tl / \l__keys_relative_tl /
15248 \s__keys_stop
15249 }
15250 }
15251 \cs_new_protected:Npn \__keys_store_unused:w { }
15252 \cs_new:Npn \__keys_choice_find:n #1
15253 {
15254 \str_if_empty:NTF \l__keys_inherit_str
15255 { \__keys_choice_find:nn \l_keys_path_str {#1} }
15256 {
15257 \__keys_choice_find:nn
15258 { \l__keys_inherit_str / \l_keys_key_str } {#1}
15259 }
15260 }
15261 \cs_new:Npn \__keys_choice_find:nn #1#2
15262 {
15263 \cs_if_exist:cTF { \c__keys_code_root_str #1 / \__keys_trim_spaces:n {#2} }
15264 { \__keys_execute:nn { #1 / \__keys_trim_spaces:n {#2} } {#2} }
15265 { \__keys_execute:nn { #1 / unknown } {#2} }
15266 }
15267 \cs_new:Npn \__keys_multichoice_find:n #1
15268 { \clist_map_function:nN {#1} \__keys_choice_find:n }
15269 \cs_new:Npn \__keys_parent:o #1
15270 {
15271 \exp_after:wN \__keys_parent_auxi:w #1 \q_nil \__keys_parent_auxii:w
15272 / \q_nil \__keys_parent_auxiv:w
15273 }
15274 \cs_new:Npn \__keys_parent_auxi:w #1 / #2 \q_nil #3
15275 {
15276 #3 { #1 } #2 \q_nil #3
15277 }
15278 \cs_new:Npn \__keys_parent_auxii:w #1 #2 \q_nil \__keys_parent_auxii:w
15279 {
15280 #1 \__keys_parent_auxi:w #2 \q_nil \__keys_parent_auxiii:n
15281 }
15282 \cs_new:Npn \__keys_parent_auxiii:n #1
15283 {
15284 / #1 \__keys_parent_auxi:w
15285 }
15286 \cs_new:Npn \__keys_parent_auxiv:w #1 \q_nil \__keys_parent_auxiv:w
15287 {
15288 }
15289 \group_begin:
15290 \cs_set:Npn \__keys_tmp:w #1
15291 {
15292 \cs_new:Npn \__keys_trim_spaces:n ##1
15293 {
15294 \exp_after:wN \__keys_trim_spaces_auxi:w \tl_to_str:n { / ##1 } /
15295 \s__keys_nil \__keys_trim_spaces_auxi:w
15296 \s__keys_mark \__keys_trim_spaces_auxii:w
15297 #1 / #1
15298 \s__keys_nil \__keys_trim_spaces_auxii:w
15299 \s__keys_mark \__keys_trim_spaces_auxiii:w
15300 }
15301 }
15302 \__keys_tmp:w { ~ }
15303 \group_end:
15304 \cs_new:Npn \__keys_trim_spaces_auxi:w #1 ~ / #2 \s__keys_nil #3
15305 {
15306 #3 #1 / #2 \s__keys_nil #3
15307 }
15308 \cs_new:Npn \__keys_trim_spaces_auxii:w #1 / ~ #2 \s__keys_mark #3
15309 {
15310 #3 #1 / #2 \s__keys_mark #3
15311 }
15312 \cs_new:Npn \__keys_trim_spaces_auxiii:w
15313 / #1 /
15314 \s__keys_nil \__keys_trim_spaces_auxi:w
15315 \s__keys_mark \__keys_trim_spaces_auxii:w
15316 /
15317 \s__keys_nil \__keys_trim_spaces_auxii:w
15318 \s__keys_mark \__keys_trim_spaces_auxiii:w
15319 {
15320 #1
15321 }
15322 \prg_new_conditional:Npnn \keys_if_exist:nn #1#2 { p , T , F , TF }
15323 {
15324 \__keys_if_exist:ee
15325 { \__keys_trim_spaces:n {#1} }
15326 { \__keys_trim_spaces:n {#2} }
15327 }
15328 \prg_generate_conditional_variant:Nnn \keys_if_exist:nn { ne } { p , T , F , TF }
15329 \cs_new:Npn \__keys_if_exist:nn #1#2
15330 {
15331 \cs_if_exist:cTF
15332 { \c__keys_code_root_str #1 \tl_if_blank:nF {#1} { / } #2 }
15333 { \prg_return_true: }
15334 { \prg_return_false: }
15335 }
15336 \cs_generate_variant:Nn \__keys_if_exist:nn { ee }
15337 \prg_new_conditional:Npnn \keys_if_choice_exist:nnn #1#2#3
15338 { p , T , F , TF }
15339 {
15340 \__keys_if_exist:eee
15341 { \__keys_trim_spaces:n {#1} }
15342 { \__keys_trim_spaces:n {#2} }
15343 { \__keys_trim_spaces:n {#3} }
15344 }
15345 \cs_new:Npn \__keys_if_exist:nnn #1#2#3
15346 {
15347 \cs_if_exist:cTF
15348 {
15349 \c__keys_code_root_str
15350 #1 \tl_if_blank:nF {#1} { / }
15351 #2 \tl_if_blank:nF {#2} { / }
15352 #3
15353 }
15354 { \prg_return_true: }
15355 { \prg_return_false: }
15356 }
15357 \cs_generate_variant:Nn \__keys_if_exist:nnn { eee }
15358 \cs_new_protected:Npn \keys_show:nn
15359 { \__keys_show:Nnn \msg_show:nneeee }
15360 \cs_new_protected:Npn \keys_log:nn
15361 { \__keys_show:Nnn \msg_log:nneeee }
15362 \cs_new_protected:Npn \__keys_show:Nnn #1#2#3
15363 {
15364 \__keys_show_aux:Nee
15365 #1
15366 { \__keys_trim_spaces:n {#2} }
15367 { \__keys_trim_spaces:n {#3} }
15368 }
15369 \cs_new_protected:Npn \__keys_show_aux:Nnn #1#2#3
15370 {
15371 #1 { keys } { show-key }
15372 { #2 \tl_if_blank:nF {#2} { / } #3 }
15373 {
15374 \keys_if_exist:nnT {#2} {#3}
15375 {
15376 \exp_args:Nnf \msg_show_item_unbraced:nn { code }
15377 {
15378 \exp_args:Ne \__keys_show:n
15379 {
15380 \exp_args:Nc \cs_replacement_spec:N
15381 {
15382 \c__keys_code_root_str
15383 #2 \tl_if_blank:nF {#2} { / } #3
15384 }
15385 }
15386 }
15387 }
15388 }
15389 { } { }
15390 }
15391 \cs_generate_variant:Nn \__keys_show_aux:Nnn { Nee }
15392 \cs_new:Npe \__keys_show:n #1
15393 {
15394 \exp_not:N \__keys_show:w
15395 #1
15396 \tl_to_str:n { \__keys_precompile:n }
15397 #1
15398 \tl_to_str:n { \__keys_precompile:n }
15399 \exp_not:N \s__keys_stop
15400 }
15401 \use:e
15402 {
15403 \cs_new:Npn \exp_not:N \__keys_show:w
15404 #1 \tl_to_str:n { \__keys_precompile:n }
15405 #2 \tl_to_str:n { \__keys_precompile:n }
15406 #3 \exp_not:N \s__keys_stop
15407 }
15408 {
15409 \tl_if_blank:nTF {#2}
15410 {#1}
15411 { \__keys_show:Nw #2 \s__keys_stop }
15412 }
15413 \use:e
15414 {
15415 \cs_new:Npn \exp_not:N \__keys_show:Nw #1#2
15416 \c_right_brace_str \exp_not:N \s__keys_stop
15417 }
15418 {#2}
15419 \msg_new:nnnn { keys } { bad-relative-key-path }
15420 { The~key~'#1'~is~not~inside~the~'#2'~path. }
15421 { The~key~'#1'~cannot~be~expressed~relative~to~path~'#2'. }
15422 \msg_new:nnnn { keys } { boolean-values-only }
15423 { Key~'#1'~accepts~boolean~values~only. }
15424 { The~key~'#1'~only~accepts~the~values~'true'~and~'false'. }
15425 \msg_new:nnnn { keys } { choice-unknown }
15426 { Key~'#1'~accepts~only~a~fixed~set~of~choices. }
15427 {
15428 The~key~'#1'~only~accepts~predefined~values,~
15429 and~'#2'~is~not~one~of~these.
15430 }
15431 \msg_new:nnnn { keys } { unknown }
15432 { The~key~'#1'~is~unknown~and~is~being~ignored. }
15433 {
15434 The~module~'#2'~does~not~have~a~key~called~'#1'.\\
15435 Check~that~you~have~spelled~the~key~name~correctly.
15436 }
15437 \msg_new:nnnn { keys } { unknown-expansion }
15438 { The~value~expansion~'#1'~is~unknown. }
15439 {
15440 Key~values~can~only~be~expanded~using~one~of~the~pre-defined~methods:~
15441 n,~o,~V,~v,~e,~N~or~c.
15442 }
15443 \msg_new:nnnn { keys } { nested-choice-key }
15444 { Attempt~to~define~'#1'~as~a~nested~choice~key. }
15445 {
15446 The~key~'#1'~cannot~be~defined~as~a~choice~as~the~parent~key~'#2'~is~
15447 itself~a~choice.
15448 }
15449 \msg_new:nnnn { keys } { value-forbidden }
15450 { The~key~'#1'~does~not~take~a~value. }
15451 {
15452 The~key~'#1'~should~be~given~without~a~value.\\
15453 The~value~'#2'~was~present:~the~key~will~be~ignored.
15454 }
15455 \msg_new:nnnn { keys } { value-required }
15456 { The~key~'#1'~requires~a~value. }
15457 {
15458 The~key~'#1'~must~have~a~value.\\
15459 No~value~was~present:~the~key~will~be~ignored.
15460 }
15461 \msg_new:nnn { keys } { show-key }
15462 {
15463 The~key~#1~
15464 \tl_if_empty:nTF {#2}
15465 { is~undefined. }
15466 { has~the~properties: #2 . }
15467 }
15468 \prop_gput:Nnn \g_msg_module_name_prop { keys } { LaTeX }
15469 \prop_gput:Nnn \g_msg_module_type_prop { keys } { }
15470 %% File: l3intarray.dtx
15471 \msg_new:nnn { kernel } { negative-array-size }
15472 { Size~of~array~may~not~be~negative:~#1 }
15473 \cs_new_eq:NN \__intarray_sep: \__kernel_int_sep:
15474 \int_new:N \l__intarray_loop_int
15475 \cs_if_exist:NTF \__intarray_gset_count:Nw
15476 {
15477 \int_new:N \g__intarray_table_int
15478 \int_new:N \l__intarray_bad_index_int
15479 \cs_new_protected:Npn \__intarray_new:N #1
15480 {
15481 \__kernel_chk_if_free_cs:N #1
15482 \int_gincr:N \g__intarray_table_int
15483 \cs_gset_nopar:Npe #1 { \__intarray:w \int_use:N \g__intarray_table_int \c_space_tl }
15484 }
15485 \cs_new_protected:Npn \intarray_new:Nn #1#2
15486 {
15487 \__intarray_new:N #1
15488 \__intarray_gset_count:Nw #1 \int_eval:n {#2} \scan_stop:
15489 \int_compare:nNnT { \intarray_count:N #1 } < 0
15490 {
15491 \msg_error:nne { kernel } { negative-array-size }
15492 { \intarray_count:N #1 }
15493 }
15494 }
15495 \cs_generate_variant:Nn \intarray_new:Nn { c }
15496 \cs_generate_variant:Nn \intarray_count:N { c }
15497 \cs_new_protected:Npn \__kernel_intarray_gset:Nnn #1#2#3
15498 { \__intarray_gset:w #2 #1 #3 \scan_stop: }
15499 \cs_new_protected:Npn \intarray_gset:Nnn #1#2#3
15500 {
15501 \__intarray_gset:wF \int_eval:n {#2} #1 \int_eval:n{#3}
15502 {
15503 \msg_error:nneee { kernel } { out-of-bounds }
15504 { \token_to_str:N #1 } { \int_use:N \l__intarray_bad_index_int } { \intarray_count:N #1 }
15505 }
15506 }
15507 \cs_generate_variant:Nn \intarray_gset:Nnn { c }
15508 \cs_generate_variant:Nn \intarray_gzero:N { c }
15509 \cs_new:Npn \__kernel_intarray_item:Nn #1#2
15510 { \__intarray_item:w #2 #1 }
15511 \cs_new:Npn \intarray_item:Nn #1#2
15512 {
15513 \__intarray_item:wF \int_eval:n {#2} #1
15514 {
15515 \msg_expandable_error:nnfff { kernel } { out-of-bounds }
15516 { \token_to_str:N #1 } { \int_use:N \l__intarray_bad_index_int } { \intarray_count:N #1 }
15517 0
15518 }
15519 }
15520 \cs_generate_variant:Nn \intarray_item:Nn { c }
15521 \cs_new:Npn \intarray_rand_item:N #1
15522 { \intarray_item:Nn #1 { \int_rand:n { \intarray_count:N #1 } } }
15523 \cs_generate_variant:Nn \intarray_rand_item:N { c }
15524 \cs_new_protected:Npn \intarray_const_from_clist:Nn #1#2
15525 {
15526 \__intarray_new:N #1
15527 \int_zero:N \l__intarray_loop_int
15528 \clist_map_inline:nn {#2}
15529 {
15530 \int_incr:N \l__intarray_loop_int
15531 \__kernel_intarray_gset:Nnn #1 \l__intarray_loop_int { \int_eval:n {##1} } }
15532 }
15533 \cs_generate_variant:Nn \intarray_const_from_clist:Nn { c }
15534 \cs_new:Npn \__kernel_intarray_range_to_clist:Nnn #1#2#3
15535 {
15536 \__intarray_range_to_clist:w #1
15537 \int_eval:n {#2} ~ \int_eval:n {#3} ~
15538 }
15539 \cs_new_protected:Npn \__kernel_intarray_gset_range_from_clist:Nnn #1#2#3
15540 {
15541 \__intarray_gset_range:w \int_eval:w #2 #1 #3 , , \scan_stop:
15542 }
15543 \cs_new_protected:Npn \__intarray_gset_overflow_test:nw #1
15544 {
15545 }
15546 }
15547 {
15548 \cs_new_eq:NN \__intarray_entry:w \tex_fontdimen:D
15549 \cs_new_eq:NN \__intarray_count:w \tex_hyphenchar:D
15550 \dim_const:Nn \c__intarray_sp_dim { 1 sp }
15551 \int_new:N \g__intarray_font_int
15552 \cs_new_protected:Npn \__intarray_new:N #1
15553 {
15554 \__kernel_chk_if_free_cs:N #1
15555 \int_gincr:N \g__intarray_font_int
15556 \tex_global:D \tex_font:D #1
15557 = cmr10~at~ \g__intarray_font_int \c__intarray_sp_dim \scan_stop:
15558 \int_step_inline:nn { 8 }
15559 { \__kernel_intarray_gset:Nnn #1 {##1} \c_zero_int }
15560 }
15561 \cs_new_protected:Npn \intarray_new:Nn #1#2
15562 {
15563 \__intarray_new:N #1
15564 \__intarray_count:w #1 = \int_eval:n {#2} \scan_stop:
15565 \int_compare:nNnT { \intarray_count:N #1 } < 0
15566 {
15567 \msg_error:nne { kernel } { negative-array-size }
15568 { \intarray_count:N #1 }
15569 }
15570 \int_compare:nNnT { \intarray_count:N #1 } > 0
15571 { \__kernel_intarray_gset:Nnn #1 { \intarray_count:N #1 } { 0 } }
15572 }
15573 \cs_generate_variant:Nn \intarray_new:Nn { c }
15574 \cs_new:Npn \intarray_count:N #1 { \int_value:w \__intarray_count:w #1 }
15575 \cs_generate_variant:Nn \intarray_count:N { c }
15576 \cs_new:Npn \__intarray_signed_max_dim:n #1
15577 { \int_value:w \int_compare:nNnT {#1} < 0 { - } \c_max_dim }
15578 \cs_new:Npn \__intarray_bounds:NNnTF #1#2#3
15579 {
15580 \if_int_compare:w 1 > #3 \exp_stop_f:
15581 \__intarray_bounds_error:NNnw #1 #2 {#3}
15582 \else:
15583 \if_int_compare:w #3 > \intarray_count:N #2 \exp_stop_f:
15584 \__intarray_bounds_error:NNnw #1 #2 {#3}
15585 \fi:
15586 \fi:
15587 \use_i:nn
15588 }
15589 \cs_new:Npn \__intarray_bounds_error:NNnw #1#2#3#4 \use_i:nn #5#6
15590 {
15591 #4
15592 #1 { kernel } { out-of-bounds }
15593 { \token_to_str:N #2 } {#3} { \intarray_count:N #2 }
15594 #6
15595 }
15596 \cs_new_protected:Npn \__kernel_intarray_gset:Nnn #1#2#3
15597 { \__intarray_entry:w #2 #1 #3 \c__intarray_sp_dim }
15598 \cs_new_protected:Npn \intarray_gset:Nnn #1#2#3
15599 {
15600 \exp_after:wN \__intarray_gset:Nww
15601 \exp_after:wN #1
15602 \int_value:w \int_eval:n {#2} \exp_after:wN \__intarray_sep:
15603 \int_value:w \int_eval:n {#3} \__intarray_sep:
15604 }
15605 \cs_generate_variant:Nn \intarray_gset:Nnn { c }
15606 \cs_new_protected:Npn \__intarray_gset:Nww #1#2 \__intarray_sep: #3 \__intarray_sep:
15607 {
15608 \__intarray_bounds:NNnTF \msg_error:nneee #1 {#2}
15609 {
15610 \__intarray_gset_overflow_test:nw {#3}
15611 \__kernel_intarray_gset:Nnn #1 {#2} {#3}
15612 }
15613 { }
15614 }
15615 \cs_if_exist:NTF \tex_ifabsnum:D
15616 {
15617 \cs_new_protected:Npn \__intarray_gset_overflow_test:nw #1
15618 {
15619 \tex_ifabsnum:D #1 > \c_max_dim
15620 \exp_after:wN \__intarray_gset_overflow:NNnn
15621 \fi:
15622 }
15623 }
15624 {
15625 \cs_new_protected:Npn \__intarray_gset_overflow_test:nw #1
15626 {
15627 \if_int_compare:w \int_abs:n {#1} > \c_max_dim
15628 \exp_after:wN \__intarray_gset_overflow:NNnn
15629 \fi:
15630 }
15631 }
15632 \cs_new_protected:Npn \__intarray_gset_overflow:NNnn #1#2#3#4
15633 {
15634 \msg_error:nneeee { kernel } { overflow }
15635 { \token_to_str:N #2 } {#3} {#4} { \__intarray_signed_max_dim:n {#4} }
15636 #1 #2 {#3} { \__intarray_signed_max_dim:n {#4} }
15637 }
15638 \cs_new_protected:Npn \intarray_gzero:N #1
15639 {
15640 \int_zero:N \l__intarray_loop_int
15641 \prg_replicate:nn { \intarray_count:N #1 }
15642 {
15643 \int_incr:N \l__intarray_loop_int
15644 \__intarray_entry:w \l__intarray_loop_int #1 \c_zero_dim
15645 }
15646 }
15647 \cs_generate_variant:Nn \intarray_gzero:N { c }
15648 \cs_new:Npn \__kernel_intarray_item:Nn #1#2
15649 { \int_value:w \__intarray_entry:w #2 #1 }
15650 \cs_new:Npn \intarray_item:Nn #1#2
15651 {
15652 \exp_after:wN \__intarray_item:Nw
15653 \exp_after:wN #1
15654 \int_value:w \int_eval:n {#2} \__intarray_sep:
15655 }
15656 \cs_generate_variant:Nn \intarray_item:Nn { c }
15657 \cs_new:Npn \__intarray_item:Nw #1#2 \__intarray_sep:
15658 {
15659 \__intarray_bounds:NNnTF \msg_expandable_error:nnfff #1 {#2}
15660 { \__kernel_intarray_item:Nn #1 {#2} }
15661 { 0 }
15662 }
15663 \cs_new:Npn \intarray_rand_item:N #1
15664 { \intarray_item:Nn #1 { \int_rand:n { \intarray_count:N #1 } } }
15665 \cs_generate_variant:Nn \intarray_rand_item:N { c }
15666 \cs_new_protected:Npn \intarray_const_from_clist:Nn #1#2
15667 {
15668 \__intarray_new:N #1
15669 \int_zero:N \l__intarray_loop_int
15670 \clist_map_inline:nn {#2}
15671 { \exp_args:Nf \__intarray_const_from_clist:nN { \int_eval:n {##1} } #1 }
15672 \__intarray_count:w #1 \l__intarray_loop_int
15673 }
15674 \cs_generate_variant:Nn \intarray_const_from_clist:Nn { c }
15675 \cs_new_protected:Npn \__intarray_const_from_clist:nN #1#2
15676 {
15677 \int_incr:N \l__intarray_loop_int
15678 \__intarray_gset_overflow_test:nw {#1}
15679 \__kernel_intarray_gset:Nnn #2 \l__intarray_loop_int {#1}
15680 }
15681 \cs_new:Npn \__intarray_to_clist:Nn #1#2
15682 {
15683 \int_compare:nNnF { \intarray_count:N #1 } = \c_zero_int
15684 {
15685 \exp_last_unbraced:Nf \use_none:n
15686 { \__intarray_to_clist:w 1 \__intarray_sep: #1 {#2} \prg_break_point: }
15687 }
15688 }
15689 \cs_new:Npn \__intarray_to_clist:w #1 \__intarray_sep: #2#3
15690 {
15691 \if_int_compare:w #1 > \__intarray_count:w #2
15692 \prg_break:n
15693 \fi:
15694 #3 \__kernel_intarray_item:Nn #2 {#1}
15695 \exp_after:wN \__intarray_to_clist:w
15696 \int_value:w \int_eval:w #1 + \c_one_int \__intarray_sep: #2 {#3}
15697 }
15698 \cs_new:Npn \__kernel_intarray_range_to_clist:Nnn #1#2#3
15699 {
15700 \exp_last_unbraced:Nf \use_none:n
15701 {
15702 \exp_after:wN \__intarray_range_to_clist:ww
15703 \int_value:w \int_eval:w #2 \exp_after:wN \__intarray_sep:
15704 \int_value:w \int_eval:w #3 \__intarray_sep:
15705 #1 \prg_break_point:
15706 }
15707 }
15708 \cs_new:Npn \__intarray_range_to_clist:ww #1 \__intarray_sep: #2 \__intarray_sep: #3
15709 {
15710 \if_int_compare:w #1 > #2 \exp_stop_f:
15711 \prg_break:n
15712 \fi:
15713 , \__kernel_intarray_item:Nn #3 {#1}
15714 \exp_after:wN \__intarray_range_to_clist:ww
15715 \int_value:w \int_eval:w #1 + \c_one_int \__intarray_sep: #2 \__intarray_sep: #3
15716 }
15717 \cs_new_protected:Npn \__kernel_intarray_gset_range_from_clist:Nnn #1#2#3
15718 {
15719 \int_set:Nn \l__intarray_loop_int {#2}
15720 \__intarray_gset_range:Nw #1 #3 , , \prg_break_point:
15721 }
15722 \cs_new_protected:Npn \__intarray_gset_range:Nw #1 #2 ,
15723 {
15724 \if_catcode:w \scan_stop: \tl_to_str:n {#2} \scan_stop:
15725 \prg_break:n
15726 \fi:
15727 \__kernel_intarray_gset:Nnn #1 \l__intarray_loop_int {#2}
15728 \int_incr:N \l__intarray_loop_int
15729 \__intarray_gset_range:Nw #1
15730 }
15731 }
15732 \prg_new_eq_conditional:NNn \intarray_if_exist:N \cs_if_exist:N
15733 { TF , T , F , p }
15734 \prg_new_eq_conditional:NNn \intarray_if_exist:c \cs_if_exist:c
15735 { TF , T , F , p }
15736 \cs_new_protected:Npn \intarray_show:N { \__intarray_show:NN \msg_show:nneeee }
15737 \cs_generate_variant:Nn \intarray_show:N { c }
15738 \cs_new_protected:Npn \intarray_log:N { \__intarray_show:NN \msg_log:nneeee }
15739 \cs_generate_variant:Nn \intarray_log:N { c }
15740 \cs_new_protected:Npn \__intarray_show:NN #1#2
15741 {
15742 \__kernel_chk_defined:NT #2
15743 {
15744 #1 { intarray } { show }
15745 { \token_to_str:N #2 }
15746 { \intarray_count:N #2 }
15747 { >~ \__intarray_to_clist:Nn #2 { , ~ } }
15748 { }
15749 }
15750 }
15751 %% File: l3fp.dtx
15752 %% File: l3fp-aux.dtx
15753 \cs_new_eq:NN \__fp_int_eval:w \tex_numexpr:D
15754 \cs_new_eq:NN \__fp_int_eval_end: \scan_stop:
15755 \cs_new_eq:NN \__fp_int_to_roman:w \tex_romannumeral:D
15756 \cs_new_eq:NN \__fp_sep: \__kernel_int_sep:
15757 \cs_new:Npn \__fp_use_none_stop_f:n #1 { \exp_stop_f: }
15758 \cs_new:Npn \__fp_use_s:n #1 { #1\__fp_sep: }
15759 \cs_new:Npn \__fp_use_s:nn #1#2 { #1#2\__fp_sep: }
15760 \cs_new:Npn \__fp_use_none_until_s:w #1\__fp_sep: { }
15761 \cs_new:Npn \__fp_use_i_until_s:nw #1#2\__fp_sep: {#1}
15762 \cs_new:Npn \__fp_use_ii_until_s:nnw #1#2#3\__fp_sep: {#2}
15763 \cs_new:Npn \__fp_reverse_args:Nww #1 #2\__fp_sep: #3\__fp_sep:
15764 { #1 #3\__fp_sep: #2\__fp_sep: }
15765 \cs_new:Npn \__fp_rrot:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
15766 { #2\__fp_sep: #3\__fp_sep: #1\__fp_sep: }
15767 \cs_new:Npn \__fp_use_i:ww #1\__fp_sep: #2\__fp_sep: { #1\__fp_sep: }
15768 \cs_new:Npn \__fp_use_i:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep: { #1\__fp_sep: }
15769 \cs_new_protected:Npn \__fp_misused:n #1
15770 { \msg_error:nne { fp } { misused } { \fp_to_tl:n {#1} } }
15771 \scan_new:N \s__fp
15772 \cs_new_protected:Npn \__fp_chk:w #1 \__fp_sep:
15773 { \__fp_misused:n { \s__fp \__fp_chk:w #1 \__fp_sep: } }
15774 \scan_new:N \s__fp_expr_mark
15775 \scan_new:N \s__fp_expr_stop
15776 \scan_new:N \s__fp_mark
15777 \scan_new:N \s__fp_stop
15778 \cs_new:Npn \__fp_use_i_delimit_by_s_stop:nw #1 #2 \s__fp_stop {#1}
15779 \scan_new:N \s__fp_invalid
15780 \scan_new:N \s__fp_underflow
15781 \scan_new:N \s__fp_overflow
15782 \scan_new:N \s__fp_division
15783 \scan_new:N \s__fp_exact
15784 \tl_const:Nn \c_zero_fp { \s__fp \__fp_chk:w 0 0 \s__fp_exact \__fp_sep: }
15785 \tl_const:Nn \c_minus_zero_fp { \s__fp \__fp_chk:w 0 2 \s__fp_exact \__fp_sep: }
15786 \tl_const:Nn \c_inf_fp { \s__fp \__fp_chk:w 2 0 \s__fp_exact \__fp_sep: }
15787 \tl_const:Nn \c_minus_inf_fp { \s__fp \__fp_chk:w 2 2 \s__fp_exact \__fp_sep: }
15788 \tl_const:Nn \c_nan_fp { \s__fp \__fp_chk:w 3 1 \s__fp_exact \__fp_sep: }
15789 \int_const:Nn \c__fp_prec_int { 16 }
15790 \int_const:Nn \c__fp_half_prec_int { 8 }
15791 \int_const:Nn \c__fp_block_int { 4 }
15792 \int_const:Nn \c__fp_myriad_int { 10000 }
15793 \int_const:Nn \c__fp_minus_min_exponent_int { 10000 }
15794 \int_const:Nn \c__fp_max_exponent_int { 10000 }
15795 \int_const:Nn \c__fp_max_exp_exponent_int { 5 }
15796 \tl_const:Ne \c__fp_overflowing_fp
15797 {
15798 \s__fp \__fp_chk:w 1 0
15799 { \int_eval:n { \c__fp_max_exponent_int + 1 } }
15800 {1000} {0000} {0000} {0000} \__fp_sep:
15801 }
15802 \cs_new:Npn \__fp_zero_fp:N #1
15803 { \s__fp \__fp_chk:w 0 #1 \s__fp_underflow \__fp_sep: }
15804 \cs_new:Npn \__fp_inf_fp:N #1
15805 { \s__fp \__fp_chk:w 2 #1 \s__fp_overflow \__fp_sep: }
15806 \cs_new:Npn \__fp_exponent:w \s__fp \__fp_chk:w #1
15807 {
15808 \if_meaning:w 1 #1
15809 \exp_after:wN \__fp_use_ii_until_s:nnw
15810 \else:
15811 \exp_after:wN \__fp_use_i_until_s:nw
15812 \exp_after:wN 0
15813 \fi:
15814 }
15815 \cs_new:Npn \__fp_neg_sign:N #1
15816 { \__fp_int_eval:w 2 - #1 \__fp_int_eval_end: }
15817 \cs_new:Npn \__fp_kind:w #1
15818 {
15819 \__fp_if_type_fp:NTwFw
15820 #1 \__fp_use_ii_until_s:nnw
15821 \s__fp { \__fp_use_i_until_s:nw 4 }
15822 \s__fp_stop
15823 }
15824 \cs_new:Npn \__fp_sanitize:Nw #1 #2\__fp_sep:
15825 {
15826 \if_case:w
15827 \if_int_compare:w #2 > \c__fp_max_exponent_int 1 ~ \else:
15828 \if_int_compare:w #2 < - \c__fp_minus_min_exponent_int 2 ~ \else:
15829 \if_meaning:w 1 #1 3 ~ \fi: \fi: \fi: 0 ~
15830 \or: \exp_after:wN \__fp_overflow:w
15831 \or: \exp_after:wN \__fp_underflow:w
15832 \or: \exp_after:wN \__fp_sanitize_zero:w
15833 \fi:
15834 \s__fp \__fp_chk:w 1 #1 {#2}
15835 }
15836 \cs_new:Npn \__fp_sanitize:wN #1\__fp_sep: #2 { \__fp_sanitize:Nw #2 #1\__fp_sep: }
15837 \cs_new:Npn \__fp_sanitize_zero:w \s__fp \__fp_chk:w #1 #2 #3\__fp_sep:
15838 { \c_zero_fp }
15839 \cs_new:Npn \__fp_exp_after_o:w \s__fp \__fp_chk:w #1
15840 {
15841 \if_meaning:w 1 #1
15842 \exp_after:wN \__fp_exp_after_normal:nNNw
15843 \else:
15844 \exp_after:wN \__fp_exp_after_special:nNNw
15845 \fi:
15846 { }
15847 #1
15848 }
15849 \cs_new:Npn \__fp_exp_after_f:nw #1 \s__fp \__fp_chk:w #2
15850 {
15851 \if_meaning:w 1 #2
15852 \exp_after:wN \__fp_exp_after_normal:nNNw
15853 \else:
15854 \exp_after:wN \__fp_exp_after_special:nNNw
15855 \fi:
15856 { \exp:w \exp_end_continue_f:w #1 }
15857 #2
15858 }
15859 \cs_new:Npn \__fp_exp_after_special:nNNw #1#2#3#4\__fp_sep:
15860 {
15861 \exp_after:wN \s__fp
15862 \exp_after:wN \__fp_chk:w
15863 \exp_after:wN #2
15864 \exp_after:wN #3
15865 \exp_after:wN #4
15866 \exp_after:wN \__fp_sep:
15867 #1
15868 }
15869 \cs_new:Npn \__fp_exp_after_normal:nNNw #1 1 #2 #3 #4#5#6#7\__fp_sep:
15870 {
15871 \exp_after:wN \__fp_exp_after_normal:Nwwwww
15872 \exp_after:wN #2
15873 \int_value:w #3 \exp_after:wN \__fp_sep:
15874 \int_value:w 1 #4 \exp_after:wN \__fp_sep:
15875 \int_value:w 1 #5 \exp_after:wN \__fp_sep:
15876 \int_value:w 1 #6 \exp_after:wN \__fp_sep:
15877 \int_value:w 1 #7 \exp_after:wN \__fp_sep: #1
15878 }
15879 \cs_new:Npn \__fp_exp_after_normal:Nwwwww
15880 #1 #2\__fp_sep: 1 #3 \__fp_sep: 1 #4 \__fp_sep: 1 #5 \__fp_sep: 1 #6 \__fp_sep:
15881 { \s__fp \__fp_chk:w 1 #1 {#2} {#3} {#4} {#5} {#6} \__fp_sep: }
15882 \scan_new:N \s__fp_tuple
15883 \cs_new_protected:Npn \__fp_tuple_chk:w #1 \__fp_sep:
15884 { \__fp_misused:n { \s__fp_tuple \__fp_tuple_chk:w #1 \__fp_sep: } }
15885 \tl_const:Nn \c__fp_empty_tuple_fp
15886 { \s__fp_tuple \__fp_tuple_chk:w { } \__fp_sep: }
15887 \cs_new:Npn \__fp_array_count:n #1
15888 { \__fp_tuple_count:w \s__fp_tuple \__fp_tuple_chk:w {#1} \__fp_sep: }
15889 \cs_new:Npn \__fp_tuple_count:w \s__fp_tuple \__fp_tuple_chk:w #1 \__fp_sep:
15890 {
15891 \int_value:w \__fp_int_eval:w 0
15892 \__fp_tuple_count_loop:Nw #1 { ? \prg_break: } \__fp_sep:
15893 \prg_break_point:
15894 \__fp_int_eval_end:
15895 }
15896 \cs_new:Npn \__fp_tuple_count_loop:Nw #1#2\__fp_sep:
15897 { \use_none:n #1 + 1 \__fp_tuple_count_loop:Nw }
15898 \cs_new:Npn \__fp_if_type_fp:NTwFw #1 \s__fp #2 #3 \s__fp_stop {#2}
15899 \cs_new:Npn \__fp_array_if_all_fp:nTF #1
15900 {
15901 \__fp_array_if_all_fp_loop:w #1 { \s__fp \prg_break: } \__fp_sep:
15902 \prg_break_point: \use_i:nn
15903 }
15904 \cs_new:Npn \__fp_array_if_all_fp_loop:w #1#2 \__fp_sep:
15905 {
15906 \__fp_if_type_fp:NTwFw
15907 #1 \__fp_array_if_all_fp_loop:w
15908 \s__fp { \prg_break:n \use_iii:nnn }
15909 \s__fp_stop
15910 }
15911 \cs_new:Npn \__fp_type_from_scan:N #1
15912 {
15913 \__fp_if_type_fp:NTwFw
15914 #1 { }
15915 \s__fp { \__fp_type_from_scan_other:N #1 }
15916 \s__fp_stop
15917 }
15918 \cs_new:Npe \__fp_type_from_scan_other:N #1
15919 {
15920 \exp_not:N \exp_after:wN \exp_not:N \__fp_type_from_scan:w
15921 \exp_not:N \token_to_str:N #1 \s__fp_mark
15922 \tl_to_str:n { s__fp _? } \s__fp_mark \s__fp_stop
15923 }
15924 \exp_last_unbraced:NNNNo
15925 \cs_new:Npn \__fp_type_from_scan:w #1
15926 { \tl_to_str:n { s__fp } } #2 \s__fp_mark #3 \s__fp_stop {#2}
15927 \cs_new:Npn \__fp_change_func_type:NNN #1#2#3
15928 {
15929 \__fp_if_type_fp:NTwFw
15930 #1 #2
15931 \s__fp
15932 {
15933 \exp_after:wN \__fp_change_func_type_chk:NNN
15934 \cs:w
15935 __fp \__fp_type_from_scan_other:N #1
15936 \exp_after:wN \__fp_change_func_type_aux:w \token_to_str:N #2
15937 \cs_end:
15938 #2 #3
15939 }
15940 \s__fp_stop
15941 }
15942 \exp_last_unbraced:NNNNo
15943 \cs_new:Npn \__fp_change_func_type_aux:w #1 { \tl_to_str:n { __fp } } { }
15944 \cs_new:Npn \__fp_change_func_type_chk:NNN #1#2#3
15945 {
15946 \if_meaning:w \scan_stop: #1
15947 \exp_after:wN #3 \exp_after:wN #2
15948 \else:
15949 \exp_after:wN #1
15950 \fi:
15951 }
15952 \cs_new:Npn \__fp_exp_after_any_f:Nnw #1
15953 { \cs:w __fp_exp_after \__fp_type_from_scan_other:N #1 _f:nw \cs_end: }
15954 \cs_new:Npn \__fp_exp_after_any_f:nw #1#2
15955 {
15956 \__fp_if_type_fp:NTwFw
15957 #2 \__fp_exp_after_f:nw
15958 \s__fp { \__fp_exp_after_any_f:Nnw #2 }
15959 \s__fp_stop
15960 {#1} #2
15961 }
15962 \cs_new_eq:NN \__fp_exp_after_expr_stop_f:nw \use_none:nn
15963 \cs_new:Npn \__fp_exp_after_tuple_o:w
15964 { \__fp_exp_after_tuple_f:nw { \exp_after:wN \exp_stop_f: } }
15965 \cs_new:Npn \__fp_exp_after_tuple_f:nw
15966 #1 \s__fp_tuple \__fp_tuple_chk:w #2 \__fp_sep:
15967 {
15968 \exp_after:wN \s__fp_tuple
15969 \exp_after:wN \__fp_tuple_chk:w
15970 \exp_after:wN {
15971 \exp:w \exp_end_continue_f:w
15972 \__fp_exp_after_array_f:w #2 \s__fp_expr_stop
15973 \exp_after:wN }
15974 \exp_after:wN \__fp_sep:
15975 \exp:w \exp_end_continue_f:w #1
15976 }
15977 \cs_new:Npn \__fp_exp_after_array_f:w
15978 { \__fp_exp_after_any_f:nw { \__fp_exp_after_array_f:w } }
15979 \int_const:Nn \c__fp_leading_shift_int { - 5 0000 }
15980 \int_const:Nn \c__fp_middle_shift_int { 5 0000 * 9999 }
15981 \int_const:Nn \c__fp_trailing_shift_int { 5 0000 * 10000 }
15982 \cs_new:Npn \__fp_pack:NNNNNw #1 #2#3#4#5 #6\__fp_sep:
15983 { + #1#2#3#4#5 \__fp_sep: {#6} }
15984 \int_const:Nn \c__fp_big_leading_shift_int { - 15 2374 }
15985 \int_const:Nn \c__fp_big_middle_shift_int { 15 2374 * 9999 }
15986 \int_const:Nn \c__fp_big_trailing_shift_int { 15 2374 * 10000 }
15987 \cs_new:Npn \__fp_pack_big:NNNNNNw #1#2 #3#4#5#6 #7\__fp_sep:
15988 { + #1#2#3#4#5#6 \__fp_sep: {#7} }
15989 \int_const:Nn \c__fp_Bigg_leading_shift_int { - 20 0000 }
15990 \int_const:Nn \c__fp_Bigg_middle_shift_int { 20 0000 * 9999 }
15991 \int_const:Nn \c__fp_Bigg_trailing_shift_int { 20 0000 * 10000 }
15992 \cs_new:Npn \__fp_pack_Bigg:NNNNNNw #1#2 #3#4#5#6 #7\__fp_sep:
15993 { + #1#2#3#4#5#6 \__fp_sep: {#7} }
15994 \cs_new:Npn \__fp_pack_twice_four:wNNNNNNNN #1\__fp_sep: #2#3#4#5 #6#7#8#9
15995 { #1 {#2#3#4#5} {#6#7#8#9} \__fp_sep: }
15996 \cs_new:Npn \__fp_pack_eight:wNNNNNNNN #1\__fp_sep: #2#3#4#5 #6#7#8#9
15997 { #1 {#2#3#4#5#6#7#8#9} \__fp_sep: }
15998 \cs_new:Npn \__fp_basics_pack_low:NNNNNw #1 #2#3#4#5 #6\__fp_sep:
15999 { + #1 - 1 \__fp_sep: {#2#3#4#5} {#6} \__fp_sep: }
16000 \cs_new:Npn \__fp_basics_pack_high:NNNNNw #1 #2#3#4#5 #6\__fp_sep:
16001 {
16002 \if_meaning:w 2 #1
16003 \__fp_basics_pack_high_carry:w
16004 \fi:
16005 \__fp_sep: {#2#3#4#5} {#6}
16006 }
16007 \cs_new:Npn \__fp_basics_pack_high_carry:w \fi: \__fp_sep: #1
16008 { \fi: + 1 \__fp_sep: {1000} }
16009 \cs_new:Npn \__fp_basics_pack_weird_low:NNNNw #1 #2#3#4 #5\__fp_sep:
16010 {
16011 \if_meaning:w 2 #1
16012 + 1
16013 \fi:
16014 \__fp_int_eval_end:
16015 #2#3#4\__fp_sep: {#5} \__fp_sep:
16016 }
16017 \cs_new:Npn \__fp_basics_pack_weird_high:NNNNNNNNw
16018 1 #1#2#3#4 #5#6#7#8 #9\__fp_sep: { \__fp_sep: {#1#2#3#4} {#5#6#7#8} {#9} }
16019 \cs_new:Npn \__fp_decimate:nNnnnn #1
16020 {
16021 \cs:w
16022 __fp_decimate_
16023 \if_int_compare:w \__fp_int_eval:w #1 > \c__fp_prec_int
16024 tiny
16025 \else:
16026 \__fp_int_to_roman:w \__fp_int_eval:w #1
16027 \fi:
16028 :Nnnnn
16029 \cs_end:
16030 }
16031 \cs_new:Npn \__fp_decimate_:Nnnnn #1 #2#3#4#5
16032 { #1 0 {#2#3} {#4#5} \__fp_sep: }
16033 \cs_new:Npn \__fp_decimate_tiny:Nnnnn #1 #2#3#4#5
16034 { #1 1 { 0000 0000 } { 0000 0000 } 0 #2#3#4#5 \__fp_sep: }
16035 \cs_new:Npn \__fp_tmp:w #1 #2 #3
16036 {
16037 \cs_new:cpn { __fp_decimate_ #1 :Nnnnn } ##1 ##2##3##4##5
16038 {
16039 \exp_after:wN ##1
16040 \int_value:w
16041 \exp_after:wN \__fp_round_digit:Nw #2 \__fp_sep:
16042 \__fp_decimate_pack:nnnnnnnnnnw #3 \__fp_sep:
16043 }
16044 }
16045 \__fp_tmp:w {i} {\use_none:nnn #50}{ 0{#2}#3{#4}#5 }
16046 \__fp_tmp:w {ii} {\use_none:nn #5 }{ 00{#2}#3{#4}#5 }
16047 \__fp_tmp:w {iii} {\use_none:n #5 }{ 000{#2}#3{#4}#5 }
16048 \__fp_tmp:w {iv} { #5 }{ {0000}#2{#3}#4 #5 }
16049 \__fp_tmp:w {v} {\use_none:nnn #4#5 }{ 0{0000}#2{#3}#4 #5 }
16050 \__fp_tmp:w {vi} {\use_none:nn #4#5 }{ 00{0000}#2{#3}#4 #5 }
16051 \__fp_tmp:w {vii} {\use_none:n #4#5 }{ 000{0000}#2{#3}#4 #5 }
16052 \__fp_tmp:w {viii}{ #4#5 }{ {0000}0000{#2}#3 #4 #5 }
16053 \__fp_tmp:w {ix} {\use_none:nnn #3#4+#5}{ 0{0000}0000{#2}#3 #4 #5 }
16054 \__fp_tmp:w {x} {\use_none:nn #3#4+#5}{ 00{0000}0000{#2}#3 #4 #5 }
16055 \__fp_tmp:w {xi} {\use_none:n #3#4+#5}{ 000{0000}0000{#2}#3 #4 #5 }
16056 \__fp_tmp:w {xii} { #3#4+#5}{ {0000}0000{0000}#2 #3 #4 #5 }
16057 \__fp_tmp:w {xiii}{\use_none:nnn#2#3+#4#5}{ 0{0000}0000{0000}#2 #3 #4 #5 }
16058 \__fp_tmp:w {xiv} {\use_none:nn #2#3+#4#5}{ 00{0000}0000{0000}#2 #3 #4 #5 }
16059 \__fp_tmp:w {xv} {\use_none:n #2#3+#4#5}{ 000{0000}0000{0000}#2 #3 #4 #5 }
16060 \__fp_tmp:w {xvi} { #2#3+#4#5}{{0000}0000{0000}0000 #2 #3 #4 #5}
16061 \cs_new:Npn \__fp_decimate_pack:nnnnnnnnnnw #1#2#3#4#5
16062 { \__fp_decimate_pack:nnnnnnw { #1#2#3#4#5 } }
16063 \cs_new:Npn \__fp_decimate_pack:nnnnnnw #1 #2#3#4#5#6
16064 { {#1} {#2#3#4#5#6} }
16065 \cs_new:Npn \__fp_case_use:nw #1#2 \fi: #3 \s__fp { \fi: #1 \s__fp }
16066 \cs_new:Npn \__fp_case_return:nw #1#2 \fi: #3 \__fp_sep: { \fi: #1 }
16067 \cs_new:Npn \__fp_case_return_o:Nw #1#2 \fi: #3 \s__fp #4 \__fp_sep:
16068 { \fi: \exp_after:wN #1 }
16069 \cs_new:Npn \__fp_case_return_same_o:w #1 \fi: #2 \s__fp
16070 { \fi: \__fp_exp_after_o:w \s__fp }
16071 \cs_new:Npn \__fp_case_return_o:Nww #1#2 \fi: #3 \s__fp #4 \__fp_sep: #5 \__fp_sep:
16072 { \fi: \exp_after:wN #1 }
16073 \cs_new:Npn \__fp_case_return_i_o:ww
16074 #1 \fi: #2 \s__fp #3 \__fp_sep: \s__fp #4 \__fp_sep:
16075 { \fi: \__fp_exp_after_o:w \s__fp #3 \__fp_sep: }
16076 \cs_new:Npn \__fp_case_return_ii_o:ww #1 \fi: #2 \s__fp #3 \__fp_sep:
16077 { \fi: \__fp_exp_after_o:w }
16078 \prg_new_conditional:Npnn \__fp_int:w \s__fp \__fp_chk:w #1 #2 #3 #4\__fp_sep:
16079 { TF , T , F , p }
16080 {
16081 \if_case:w #1 \exp_stop_f:
16082 \prg_return_true:
16083 \or:
16084 \if_charcode:w 0
16085 \__fp_decimate:nNnnnn { \c__fp_prec_int - #3 }
16086 \__fp_use_i_until_s:nw #4
16087 \prg_return_true:
16088 \else:
16089 \prg_return_false:
16090 \fi:
16091 \else: \prg_return_false:
16092 \fi:
16093 }
16094 \cs_new:Npn \__fp_small_int:wTF \s__fp \__fp_chk:w #1#2
16095 {
16096 \if_case:w #1 \exp_stop_f:
16097 \__fp_case_return:nw { \__fp_small_int_true:wTF 0 \__fp_sep: }
16098 \or: \exp_after:wN \__fp_small_int_normal:NnwTF
16099 \or:
16100 \__fp_case_return:nw
16101 {
16102 \exp_after:wN \__fp_small_int_true:wTF \int_value:w
16103 \if_meaning:w 2 #2 - \fi: 1 0000 0000 \__fp_sep:
16104 }
16105 \else: \__fp_case_return:nw \use_ii:nn
16106 \fi:
16107 #2
16108 }
16109 \cs_new:Npn \__fp_small_int_true:wTF #1\__fp_sep: #2#3 { #2 {#1} }
16110 \cs_new:Npn \__fp_small_int_normal:NnwTF #1#2#3\__fp_sep:
16111 {
16112 \__fp_decimate:nNnnnn { \c__fp_prec_int - #2 }
16113 \__fp_small_int_test:NnnwNw
16114 #3 #1
16115 }
16116 \cs_new:Npn \__fp_small_int_test:NnnwNw #1#2#3#4\__fp_sep: #5
16117 {
16118 \if_meaning:w 0 #1
16119 \exp_after:wN \__fp_small_int_true:wTF
16120 \int_value:w \if_meaning:w 2 #5 - \fi:
16121 \if_int_compare:w #2 > \c_zero_int
16122 1 0000 0000
16123 \else:
16124 #3
16125 \fi:
16126 \exp_after:wN \__fp_sep:
16127 \else:
16128 \exp_after:wN \use_ii:nn
16129 \fi:
16130 }
16131 \cs_new_eq:NN \__fp_str_if_eq:nn \tex_strcmp:D
16132 \cs_new:Npn \__fp_func_to_name:N #1
16133 {
16134 \exp_last_unbraced:Nf
16135 \__fp_func_to_name_aux:w { \cs_to_str:N #1 } X
16136 }
16137 \cs_set_protected:Npn \__fp_tmp:w #1 #2
16138 { \cs_new:Npn \__fp_func_to_name_aux:w ##1 #1 ##2 #2 ##3 X {##2} }
16139 \exp_args:Nff \__fp_tmp:w { \tl_to_str:n { __fp_ } }
16140 { \tl_to_str:n { _o: } }
16141 \msg_new:nnnn { fp } { misused }
16142 { A~floating~point~with~value~'#1'~was~misused. }
16143 {
16144 To~obtain~the~value~of~a~floating~point~variable,~use~
16145 '\token_to_str:N \fp_to_decimal:N',~
16146 '\token_to_str:N \fp_to_tl:N',~or~other~
16147 conversion~functions.
16148 }
16149 \prop_gput:Nnn \g_msg_module_name_prop { fp } { LaTeX }
16150 \prop_gput:Nnn \g_msg_module_type_prop { fp } { }
16151 %% File: l3fp-traps.dtx
16152 \flag_new:N \l_fp_invalid_operation_flag
16153 \flag_new:N \l_fp_division_by_zero_flag
16154 \flag_new:N \l_fp_overflow_flag
16155 \flag_new:N \l_fp_underflow_flag
16156 \cs_new_protected:Npn \fp_trap:nn #1#2
16157 {
16158 \cs_if_exist_use:cF { __fp_trap_#1_set_#2: }
16159 {
16160 \clist_if_in:nnTF
16161 { invalid_operation , division_by_zero , overflow , underflow }
16162 {#1}
16163 {
16164 \msg_error:nnee { fp }
16165 { unknown-fpu-trap-type } {#1} {#2}
16166 }
16167 {
16168 \msg_error:nne
16169 { fp } { unknown-fpu-exception } {#1}
16170 }
16171 }
16172 }
16173 \cs_new_protected:Npn \__fp_trap_invalid_operation_set_error:
16174 { \__fp_trap_invalid_operation_set:N \prg_do_nothing: }
16175 \cs_new_protected:Npn \__fp_trap_invalid_operation_set_flag:
16176 { \__fp_trap_invalid_operation_set:N \use_none:nnnnn }
16177 \cs_new_protected:Npn \__fp_trap_invalid_operation_set_none:
16178 { \__fp_trap_invalid_operation_set:N \use_none:nnnnnnn }
16179 \cs_new_protected:Npn \__fp_trap_invalid_operation_set:N #1
16180 {
16181 \exp_args:Nno \use:n
16182 { \cs_set:Npn \__fp_invalid_operation:nnw ##1##2##3\__fp_sep: }
16183 {
16184 #1
16185 \__fp_error:nnfn { invalid } {##2} { \fp_to_tl:n { ##3\__fp_sep: } } { }
16186 \flag_ensure_raised:N \l_fp_invalid_operation_flag
16187 ##1
16188 }
16189 \exp_args:Nno \use:n
16190 { \cs_set:Npn \__fp_invalid_operation_o:Nww ##1##2\__fp_sep: ##3\__fp_sep: }
16191 {
16192 #1
16193 \__fp_error:nffn { invalid-ii }
16194 { \fp_to_tl:n { ##2\__fp_sep: } }
16195 { \fp_to_tl:n { ##3\__fp_sep: } }
16196 {##1}
16197 \flag_ensure_raised:N \l_fp_invalid_operation_flag
16198 \exp_after:wN \c_nan_fp
16199 }
16200 \exp_args:Nno \use:n
16201 { \cs_set:Npn \__fp_invalid_operation_tl_o:ff ##1##2 }
16202 {
16203 #1
16204 \__fp_error:nffn { invalid } {##1} {##2} { }
16205 \flag_ensure_raised:N \l_fp_invalid_operation_flag
16206 \exp_after:wN \c_nan_fp
16207 }
16208 }
16209 \cs_new_protected:Npn \__fp_trap_division_by_zero_set_error:
16210 { \__fp_trap_division_by_zero_set:N \prg_do_nothing: }
16211 \cs_new_protected:Npn \__fp_trap_division_by_zero_set_flag:
16212 { \__fp_trap_division_by_zero_set:N \use_none:nnnnn }
16213 \cs_new_protected:Npn \__fp_trap_division_by_zero_set_none:
16214 { \__fp_trap_division_by_zero_set:N \use_none:nnnnnnn }
16215 \cs_new_protected:Npn \__fp_trap_division_by_zero_set:N #1
16216 {
16217 \exp_args:Nno \use:n
16218 { \cs_set:Npn \__fp_division_by_zero_o:Nnw ##1##2##3\__fp_sep: }
16219 {
16220 #1
16221 \__fp_error:nnfn { zero-div } {##2} { \fp_to_tl:n { ##3\__fp_sep: } } { }
16222 \flag_ensure_raised:N \l_fp_division_by_zero_flag
16223 \exp_after:wN ##1
16224 }
16225 \exp_args:Nno \use:n
16226 {
16227 \cs_set:Npn \__fp_division_by_zero_o:NNww ##1##2##3\__fp_sep: ##4\__fp_sep:
16228 }
16229 {
16230 #1
16231 \__fp_error:nffn { zero-div-ii }
16232 { \fp_to_tl:n { ##3\__fp_sep: } }
16233 { \fp_to_tl:n { ##4\__fp_sep: } }
16234 {##2}
16235 \flag_ensure_raised:N \l_fp_division_by_zero_flag
16236 \exp_after:wN ##1
16237 }
16238 }
16239 \cs_new_protected:Npn \__fp_trap_overflow_set_error:
16240 { \__fp_trap_overflow_set:N \prg_do_nothing: }
16241 \cs_new_protected:Npn \__fp_trap_overflow_set_flag:
16242 { \__fp_trap_overflow_set:N \use_none:nnnnn }
16243 \cs_new_protected:Npn \__fp_trap_overflow_set_none:
16244 { \__fp_trap_overflow_set:N \use_none:nnnnnnn }
16245 \cs_new_protected:Npn \__fp_trap_overflow_set:N #1
16246 { \__fp_trap_overflow_set:NnNn #1 { overflow } \__fp_inf_fp:N { inf } }
16247 \cs_new_protected:Npn \__fp_trap_underflow_set_error:
16248 { \__fp_trap_underflow_set:N \prg_do_nothing: }
16249 \cs_new_protected:Npn \__fp_trap_underflow_set_flag:
16250 { \__fp_trap_underflow_set:N \use_none:nnnnn }
16251 \cs_new_protected:Npn \__fp_trap_underflow_set_none:
16252 { \__fp_trap_underflow_set:N \use_none:nnnnnnn }
16253 \cs_new_protected:Npn \__fp_trap_underflow_set:N #1
16254 { \__fp_trap_overflow_set:NnNn #1 { underflow } \__fp_zero_fp:N { 0 } }
16255 \cs_new_protected:Npn \__fp_trap_overflow_set:NnNn #1#2#3#4
16256 {
16257 \exp_args:Nno \use:n
16258 { \cs_set:cpn { __fp_ #2 :w } \s__fp \__fp_chk:w ##1##2##3\__fp_sep: }
16259 {
16260 #1
16261 \__fp_error:nffn
16262 { flow \if_meaning:w 1 ##1 -to \fi: }
16263 { \fp_to_tl:n { \s__fp \__fp_chk:w ##1##2##3\__fp_sep: } }
16264 { \token_if_eq_meaning:NNF 0 ##2 { - } #4 }
16265 {#2}
16266 \flag_ensure_raised:c { l_fp_#2_flag }
16267 #3 ##2
16268 }
16269 }
16270 \cs_new:Npn \__fp_invalid_operation:nnw #1#2#3\__fp_sep: { }
16271 \cs_new:Npn \__fp_invalid_operation_o:Nww #1#2\__fp_sep: #3\__fp_sep: { }
16272 \cs_new:Npn \__fp_invalid_operation_tl_o:ff #1 #2 { }
16273 \cs_new:Npn \__fp_division_by_zero_o:Nnw #1#2#3\__fp_sep: { }
16274 \cs_new:Npn \__fp_division_by_zero_o:NNww #1#2#3\__fp_sep: #4\__fp_sep: { }
16275 \cs_new:Npn \__fp_overflow:w { }
16276 \cs_new:Npn \__fp_underflow:w { }
16277 \fp_trap:nn { invalid_operation } { error }
16278 \fp_trap:nn { division_by_zero } { flag }
16279 \fp_trap:nn { overflow } { flag }
16280 \fp_trap:nn { underflow } { flag }
16281 \cs_new:Npn \__fp_invalid_operation_o:nw
16282 { \__fp_invalid_operation:nnw { \exp_after:wN \c_nan_fp } }
16283 \cs_generate_variant:Nn \__fp_invalid_operation_o:nw { f }
16284 \cs_new:Npn \__fp_error:nnnn
16285 { \msg_expandable_error:nnnnn { fp } }
16286 \cs_generate_variant:Nn \__fp_error:nnnn { nnf, nff , nfff }
16287 \cs_new:Npn \__fp_error_num_args:nnnn #1#2#3#4
16288 {
16289 \int_compare:nNnTF {#2} = {#3}
16290 { \msg_expandable_error:nnnnn { fp } { num-args-eq } {#1} {#2} {#4} }
16291 { \msg_expandable_error:nnnnnn { fp } { num-args } {#1} {#2} {#3} {#4} }
16292 }
16293 \cs_generate_variant:Nn \__fp_error_num_args:nnnn { ffff }
16294 \msg_new:nnn { fp } { num-args-eq }
16295 { #1()~needs~#2~arguments,~got~#3. }
16296 \msg_new:nnn { fp } { num-args }
16297 { #1()~needs~#2~to~#3~arguments,~got~#4. }
16298 \msg_new:nnnn { fp } { unknown-fpu-exception }
16299 {
16300 The~FPU~exception~'#1'~is~not~known:~
16301 that~trap~will~never~be~triggered.
16302 }
16303 {
16304 The~only~exceptions~to~which~traps~can~be~attached~are \\
16305 \iow_indent:n
16306 {
16307 * ~ invalid_operation \\
16308 * ~ division_by_zero \\
16309 * ~ overflow \\
16310 * ~ underflow
16311 }
16312 }
16313 \msg_new:nnnn { fp } { unknown-fpu-trap-type }
16314 { The~FPU~trap~type~'#2'~is~not~known. }
16315 {
16316 The~trap~type~must~be~one~of \\
16317 \iow_indent:n
16318 {
16319 * ~ error \\
16320 * ~ flag \\
16321 * ~ none
16322 }
16323 }
16324 \msg_new:nnn { fp } { flow }
16325 { An ~ #3 ~ occurred. }
16326 \msg_new:nnn { fp } { flow-to }
16327 { #1 ~ #3 ed ~ to ~ #2 . }
16328 \msg_new:nnn { fp } { zero-div }
16329 { Division~by~zero~in~ #1 (#2) }
16330 \msg_new:nnn { fp } { zero-div-ii }
16331 { Division~by~zero~in~ (#1) #3 (#2) }
16332 \msg_new:nnn { fp } { invalid }
16333 { Invalid~operation~ #1 (#2) }
16334 \msg_new:nnn { fp } { invalid-ii }
16335 { Invalid~operation~ (#1) #3 (#2) }
16336 \msg_new:nnn { fp } { unknown-type }
16337 { Unknown~type~for~'#1' }
16338 %% File: l3fp-round.dtx
16339 \cs_new:Npn \__fp_parse_word_trunc:N
16340 { \__fp_parse_function:NNN \__fp_round_o:Nw \__fp_round_to_zero:NNN }
16341 \cs_new:Npn \__fp_parse_word_floor:N
16342 { \__fp_parse_function:NNN \__fp_round_o:Nw \__fp_round_to_ninf:NNN }
16343 \cs_new:Npn \__fp_parse_word_ceil:N
16344 { \__fp_parse_function:NNN \__fp_round_o:Nw \__fp_round_to_pinf:NNN }
16345 \cs_new:Npn \__fp_parse_word_round:N #1#2
16346 {
16347 \__fp_parse_function:NNN
16348 \__fp_round_o:Nw \__fp_round_to_nearest:NNN #1
16349 #2
16350 }
16351 \cs_new:Npn \__fp_parse_round:Nw #1 #2 \__fp_round_to_nearest:NNN #3#4
16352 { #2 #1 #3 }
16353 \int_const:Nn \c__fp_five_int { 5 }
16354 \cs_new:Npn \__fp_round_return_one:
16355 { \exp_after:wN 1 \exp_after:wN \exp_stop_f: \exp:w }
16356 \cs_new:Npn \__fp_round_to_ninf:NNN #1 #2 #3
16357 {
16358 \if_meaning:w 2 #1
16359 \if_int_compare:w #3 > \c_zero_int
16360 \__fp_round_return_one:
16361 \fi:
16362 \fi:
16363 \c_zero_int
16364 }
16365 \cs_new:Npn \__fp_round_to_zero:NNN #1 #2 #3 { \c_zero_int }
16366 \cs_new:Npn \__fp_round_to_pinf:NNN #1 #2 #3
16367 {
16368 \if_meaning:w 0 #1
16369 \if_int_compare:w #3 > \c_zero_int
16370 \__fp_round_return_one:
16371 \fi:
16372 \fi:
16373 \c_zero_int
16374 }
16375 \cs_new:Npn \__fp_round_to_nearest:NNN #1 #2 #3
16376 {
16377 \if_int_compare:w #3 > \c__fp_five_int
16378 \__fp_round_return_one:
16379 \else:
16380 \if_meaning:w 5 #3
16381 \if_int_odd:w #2 \exp_stop_f:
16382 \__fp_round_return_one:
16383 \fi:
16384 \fi:
16385 \fi:
16386 \c_zero_int
16387 }
16388 \cs_new:Npn \__fp_round_to_nearest_ninf:NNN #1 #2 #3
16389 {
16390 \if_int_compare:w #3 > \c__fp_five_int
16391 \__fp_round_return_one:
16392 \else:
16393 \if_meaning:w 5 #3
16394 \if_meaning:w 2 #1
16395 \__fp_round_return_one:
16396 \fi:
16397 \fi:
16398 \fi:
16399 \c_zero_int
16400 }
16401 \cs_new:Npn \__fp_round_to_nearest_zero:NNN #1 #2 #3
16402 {
16403 \if_int_compare:w #3 > \c__fp_five_int
16404 \__fp_round_return_one:
16405 \fi:
16406 \c_zero_int
16407 }
16408 \cs_new:Npn \__fp_round_to_nearest_pinf:NNN #1 #2 #3
16409 {
16410 \if_int_compare:w #3 > \c__fp_five_int
16411 \__fp_round_return_one:
16412 \else:
16413 \if_meaning:w 5 #3
16414 \if_meaning:w 0 #1
16415 \__fp_round_return_one:
16416 \fi:
16417 \fi:
16418 \fi:
16419 \c_zero_int
16420 }
16421 \cs_new_eq:NN \__fp_round:NNN \__fp_round_to_nearest:NNN
16422 \cs_new:Npn \__fp_round_s:NNNw #1 #2 #3 #4\__fp_sep:
16423 {
16424 \exp_after:wN \__fp_round:NNN
16425 \exp_after:wN #1
16426 \exp_after:wN #2
16427 \int_value:w \__fp_int_eval:w
16428 \if_int_odd:w 0 \if_meaning:w 0 #3 1 \fi:
16429 \if_meaning:w 5 #3 1 \fi:
16430 \exp_stop_f:
16431 \if_int_compare:w \__fp_int_eval:w #4 > \c_zero_int
16432 1 +
16433 \fi:
16434 \fi:
16435 #3
16436 \__fp_sep:
16437 }
16438 \cs_new:Npn \__fp_round_digit:Nw #1 #2\__fp_sep:
16439 {
16440 \if_int_odd:w \if_meaning:w 0 #1 1 \else:
16441 \if_meaning:w 5 #1 1 \else:
16442 0 \fi: \fi: \exp_stop_f:
16443 \if_int_compare:w \__fp_int_eval:w #2 > \c_zero_int
16444 \__fp_int_eval:w 1 +
16445 \fi:
16446 \fi:
16447 #1
16448 }
16449 \cs_new_eq:NN \__fp_round_to_ninf_neg:NNN \__fp_round_to_pinf:NNN
16450 \cs_new:Npn \__fp_round_to_zero_neg:NNN #1 #2 #3
16451 {
16452 \if_int_compare:w #3 > \c_zero_int
16453 \__fp_round_return_one:
16454 \fi:
16455 \c_zero_int
16456 }
16457 \cs_new_eq:NN \__fp_round_to_pinf_neg:NNN \__fp_round_to_ninf:NNN
16458 \cs_new_eq:NN \__fp_round_to_nearest_neg:NNN \__fp_round_to_nearest:NNN
16459 \cs_new_eq:NN \__fp_round_to_nearest_ninf_neg:NNN
16460 \__fp_round_to_nearest_pinf:NNN
16461 \cs_new:Npn \__fp_round_to_nearest_zero_neg:NNN #1 #2 #3
16462 {
16463 \if_int_compare:w #3 < \c__fp_five_int \else:
16464 \__fp_round_return_one:
16465 \fi:
16466 \c_zero_int
16467 }
16468 \cs_new_eq:NN \__fp_round_to_nearest_pinf_neg:NNN
16469 \__fp_round_to_nearest_ninf:NNN
16470 \cs_new_eq:NN \__fp_round_neg:NNN \__fp_round_to_nearest_neg:NNN
16471 \cs_new:Npn \__fp_round_o:Nw #1
16472 {
16473 \__fp_parse_function_all_fp_o:fnw
16474 { \__fp_round_name_from_cs:N #1 }
16475 { \__fp_round_aux_o:Nw #1 }
16476 }
16477 \cs_new:Npn \__fp_round_aux_o:Nw #1#2 @
16478 {
16479 \if_case:w
16480 \__fp_int_eval:w \__fp_array_count:n {#2} \__fp_int_eval_end:
16481 \__fp_round_no_arg_o:Nw #1 \exp:w
16482 \or: \__fp_round:Nwn #1 #2 {0} \exp:w
16483 \or: \__fp_round:Nww #1 #2 \exp:w
16484 \else: \__fp_round:Nwww #1 #2 @ \exp:w
16485 \fi:
16486 \exp_after:wN \exp_end:
16487 }
16488 \cs_new:Npn \__fp_round_no_arg_o:Nw #1
16489 {
16490 \cs_if_eq:NNTF #1 \__fp_round_to_nearest:NNN
16491 { \__fp_error_num_args:nnnn { round } { 1 } { 3 } { 0 } }
16492 {
16493 \__fp_error_num_args:ffff
16494 { \__fp_round_name_from_cs:N #1 } { 1 } { 2 } { 0 }
16495 }
16496 \exp_after:wN \c_nan_fp
16497 }
16498 \cs_new:Npn \__fp_round:Nwww
16499 #1#2 \__fp_sep: #3 \__fp_sep: \s__fp \__fp_chk:w #4#5#6 \__fp_sep: #7 @
16500 {
16501 \cs_if_eq:NNTF #1 \__fp_round_to_nearest:NNN
16502 {
16503 \tl_if_empty:nTF {#7}
16504 {
16505 \exp_args:Nc \__fp_round:Nww
16506 {
16507 __fp_round_to_nearest
16508 \if_meaning:w 0 #4 _zero \else:
16509 \if_case:w #5 \exp_stop_f: _pinf \or: \else: _ninf \fi: \fi:
16510 :NNN
16511 }
16512 #2 \__fp_sep: #3 \__fp_sep:
16513 }
16514 {
16515 \__fp_error_num_args:ffff { round } { 1 } { 3 }
16516 { \int_eval:n { 3 + \__fp_array_count:n {#7} } }
16517 \exp_after:wN \c_nan_fp
16518 }
16519 }
16520 {
16521 \__fp_error_num_args:ffff
16522 { \__fp_round_name_from_cs:N #1 } { 1 } { 2 }
16523 { \int_eval:n { 3 + \__fp_array_count:n {#7} } }
16524 \exp_after:wN \c_nan_fp
16525 }
16526 }
16527 \cs_new:Npn \__fp_round_name_from_cs:N #1
16528 {
16529 \cs_if_eq:NNTF #1 \__fp_round_to_zero:NNN { trunc }
16530 {
16531 \cs_if_eq:NNTF #1 \__fp_round_to_ninf:NNN { floor }
16532 {
16533 \cs_if_eq:NNTF #1 \__fp_round_to_pinf:NNN { ceil }
16534 { round }
16535 }
16536 }
16537 }
16538 \cs_new:Npn \__fp_round:Nww #1#2 \__fp_sep: #3 \__fp_sep:
16539 {
16540 \__fp_small_int:wTF #3\__fp_sep: { \__fp_round:Nwn #1#2\__fp_sep: }
16541 {
16542 \if:w 3 \__fp_kind:w #3 \__fp_sep:
16543 \exp_after:wN \use_i:nn
16544 \else:
16545 \exp_after:wN \use_ii:nn
16546 \fi:
16547 { \exp_after:wN \c_nan_fp }
16548 {
16549 \__fp_invalid_operation_tl_o:ff
16550 { \__fp_round_name_from_cs:N #1 }
16551 { \__fp_array_to_clist:n { #2\__fp_sep: #3\__fp_sep: } }
16552 }
16553 }
16554 }
16555 \cs_new:Npn \__fp_round:Nwn #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: #5
16556 {
16557 \if_meaning:w 1 #2
16558 \exp_after:wN \__fp_round_normal:NwNNnw
16559 \exp_after:wN #1
16560 \int_value:w #5
16561 \else:
16562 \exp_after:wN \__fp_exp_after_o:w
16563 \fi:
16564 \s__fp \__fp_chk:w #2#3#4\__fp_sep:
16565 }
16566 \cs_new:Npn \__fp_round_normal:NwNNnw #1#2 \s__fp \__fp_chk:w 1#3#4#5\__fp_sep:
16567 {
16568 \__fp_decimate:nNnnnn { \c__fp_prec_int - #4 - #2 }
16569 \__fp_round_normal:NnnwNNnn #5 #1 #3 {#4} {#2}
16570 }
16571 \cs_new:Npn \__fp_round_normal:NnnwNNnn #1#2#3#4\__fp_sep: #5#6
16572 {
16573 \exp_after:wN \__fp_round_normal:NNwNnn
16574 \int_value:w \__fp_int_eval:w
16575 \if_int_compare:w #2 > \c_zero_int
16576 1 \int_value:w #2
16577 \exp_after:wN \__fp_round_pack:Nw
16578 \int_value:w \__fp_int_eval:w 1#3 +
16579 \else:
16580 \if_int_compare:w #3 > \c_zero_int
16581 1 \int_value:w #3 +
16582 \fi:
16583 \fi:
16584 \exp_after:wN #5
16585 \exp_after:wN #6
16586 \use_none:nnnnnnn #3
16587 #1
16588 \__fp_int_eval_end:
16589 0000 0000 0000 0000 \__fp_sep: #6
16590 }
16591 \cs_new:Npn \__fp_round_pack:Nw #1
16592 { \if_meaning:w 2 #1 + 1 \fi: \__fp_int_eval_end: }
16593 \cs_new:Npn \__fp_round_normal:NNwNnn #1 #2
16594 {
16595 \if_meaning:w 0 #2
16596 \exp_after:wN \__fp_round_special:NwwNnn
16597 \exp_after:wN #1
16598 \fi:
16599 \__fp_pack_twice_four:wNNNNNNNN
16600 \__fp_pack_twice_four:wNNNNNNNN
16601 \__fp_round_normal_end:wwNnn
16602 \__fp_sep: #2
16603 }
16604 \cs_new:Npn \__fp_round_normal_end:wwNnn #1\__fp_sep:#2\__fp_sep:#3#4#5
16605 {
16606 \exp_after:wN \__fp_exp_after_o:w \exp:w \exp_end_continue_f:w
16607 \__fp_sanitize:Nw #3 #4 \__fp_sep: #1 \__fp_sep:
16608 }
16609 \cs_new:Npn \__fp_round_special:NwwNnn #1#2\__fp_sep:#3\__fp_sep:#4#5#6
16610 {
16611 \if_meaning:w 0 #1
16612 \__fp_case_return:nw
16613 { \exp_after:wN \__fp_zero_fp:N \exp_after:wN #4 }
16614 \else:
16615 \exp_after:wN \__fp_round_special_aux:Nw
16616 \exp_after:wN #4
16617 \int_value:w \__fp_int_eval:w 1
16618 \if_meaning:w 1 #1 -#6 \else: +#5 \fi:
16619 \fi:
16620 \__fp_sep:
16621 }
16622 \cs_new:Npn \__fp_round_special_aux:Nw #1#2\__fp_sep:
16623 {
16624 \exp_after:wN \__fp_exp_after_o:w \exp:w \exp_end_continue_f:w
16625 \__fp_sanitize:Nw #1#2\__fp_sep: {1000}{0000}{0000}{0000}\__fp_sep:
16626 }
16627 %% File: l3fp-parse.dtx
16628 \int_const:Nn \c__fp_prec_func_int { 16 }
16629 \int_const:Nn \c__fp_prec_hatii_int { 14 }
16630 \int_const:Nn \c__fp_prec_hat_int { 13 }
16631 \int_const:Nn \c__fp_prec_not_int { 12 }
16632 \int_const:Nn \c__fp_prec_juxt_int { 11 }
16633 \int_const:Nn \c__fp_prec_times_int { 10 }
16634 \int_const:Nn \c__fp_prec_plus_int { 9 }
16635 \int_const:Nn \c__fp_prec_comp_int { 7 }
16636 \int_const:Nn \c__fp_prec_and_int { 6 }
16637 \int_const:Nn \c__fp_prec_or_int { 5 }
16638 \int_const:Nn \c__fp_prec_quest_int { 4 }
16639 \int_const:Nn \c__fp_prec_colon_int { 3 }
16640 \int_const:Nn \c__fp_prec_comma_int { 2 }
16641 \int_const:Nn \c__fp_prec_tuple_int { 1 }
16642 \int_const:Nn \c__fp_prec_end_int { 0 }
16643 \cs_new:Npn \__fp_parse_expand:w #1 { \exp_end_continue_f:w #1 }
16644 \cs_new:Npn \__fp_parse_return_sep:w
16645 #1 \fi: \__fp_parse_expand:w { \fi: \__fp_sep: #1 }
16646 \cs_set_protected:Npn \__fp_tmp:w #1 #2 #3
16647 {
16648 \cs_new:cpn { __fp_parse_digits_ #1 :N } ##1
16649 {
16650 \if_int_compare:w 9 < 1 \token_to_str:N ##1 \exp_stop_f:
16651 \token_to_str:N ##1 \exp_after:wN #2 \exp:w
16652 \else:
16653 \__fp_parse_return_sep:w #3 ##1
16654 \fi:
16655 \__fp_parse_expand:w
16656 }
16657 }
16658 \__fp_tmp:w {vii} \__fp_parse_digits_vi:N { 0000000 \__fp_sep: 7 }
16659 \__fp_tmp:w {vi} \__fp_parse_digits_v:N { 000000 \__fp_sep: 6 }
16660 \__fp_tmp:w {v} \__fp_parse_digits_iv:N { 00000 \__fp_sep: 5 }
16661 \__fp_tmp:w {iv} \__fp_parse_digits_iii:N { 0000 \__fp_sep: 4 }
16662 \__fp_tmp:w {iii} \__fp_parse_digits_ii:N { 000 \__fp_sep: 3 }
16663 \__fp_tmp:w {ii} \__fp_parse_digits_i:N { 00 \__fp_sep: 2 }
16664 \__fp_tmp:w {i} \__fp_parse_digits_:N { 0 \__fp_sep: 1 }
16665 \cs_new:Npn \__fp_parse_digits_:N { \__fp_sep: \__fp_sep: 0 }
16666 \cs_new:Npn \__fp_parse_one:Nw #1 #2
16667 {
16668 \if_catcode:w \scan_stop: \exp_not:N #2
16669 \exp_after:wN \if_meaning:w \exp_not:N #2 #2 \else:
16670 \exp_after:wN \reverse_if:N
16671 \fi:
16672 \if_meaning:w \scan_stop: #2
16673 \exp_after:wN \exp_after:wN
16674 \exp_after:wN \__fp_parse_one_fp:NN
16675 \else:
16676 \exp_after:wN \exp_after:wN
16677 \exp_after:wN \__fp_parse_one_register:NN
16678 \fi:
16679 \else:
16680 \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f:
16681 \exp_after:wN \exp_after:wN
16682 \exp_after:wN \__fp_parse_one_digit:NN
16683 \else:
16684 \exp_after:wN \exp_after:wN
16685 \exp_after:wN \__fp_parse_one_other:NN
16686 \fi:
16687 \fi:
16688 #1 #2
16689 }
16690 \cs_new:Npn \__fp_parse_one_fp:NN #1
16691 {
16692 \__fp_exp_after_any_f:nw
16693 {
16694 \exp_after:wN \__fp_parse_infix:NN
16695 \exp_after:wN #1 \exp:w \__fp_parse_expand:w
16696 }
16697 }
16698 \cs_new:Npn \__fp_exp_after_expr_mark_f:nw #1
16699 {
16700 \int_case:nnF { \exp_after:wN \use_i:nnn \use_none:nnn #1 }
16701 {
16702 \c__fp_prec_comma_int { }
16703 \c__fp_prec_tuple_int { }
16704 \c__fp_prec_end_int
16705 {
16706 \exp_after:wN \c__fp_empty_tuple_fp
16707 \exp:w \exp_end_continue_f:w
16708 }
16709 }
16710 {
16711 \msg_expandable_error:nn { fp } { early-end }
16712 \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
16713 }
16714 #1
16715 }
16716 \cs_new:cpn { __fp_exp_after_?_f:nw } #1#2
16717 {
16718 \msg_expandable_error:nnn { kernel } { bad-variable }
16719 {#2}
16720 \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w #1
16721 }
16722 \cs_set_protected:Npn \__fp_tmp:w #1
16723 {
16724 \cs_if_exist:NT #1
16725 {
16726 \cs_gset:cpn { __fp_exp_after_?_f:nw } ##1##2
16727 {
16728 \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w ##1
16729 \str_if_eq:nnTF {##2} { \protect }
16730 {
16731 \cs_if_eq:NNTF ##2 #1 { \use_i:nn } { \use:n }
16732 {
16733 \msg_expandable_error:nnn { fp }
16734 { robust-cmd }
16735 }
16736 }
16737 {
16738 \msg_expandable_error:nnn { kernel }
16739 { bad-variable } {##2}
16740 }
16741 }
16742 }
16743 }
16744 \exp_args:Nc \__fp_tmp:w { @unexpandable@protect }
16745 \cs_new:Npn \__fp_parse_one_register:NN #1#2
16746 {
16747 \exp_after:wN \__fp_parse_infix_after_operand:NwN
16748 \exp_after:wN #1
16749 \exp:w \exp_end_continue_f:w
16750 \__fp_parse_one_register_special:N #2
16751 \exp_after:wN \__fp_parse_one_register_aux:Nw
16752 \exp_after:wN #2
16753 \int_value:w
16754 \exp_after:wN \__fp_parse_exponent:N
16755 \exp:w \__fp_parse_expand:w
16756 }
16757 \cs_new:Npe \__fp_parse_one_register_aux:Nw #1
16758 {
16759 \exp_not:n
16760 {
16761 \exp_after:wN \use:nn
16762 \exp_after:wN \__fp_parse_one_register_auxii:wwwNw
16763 }
16764 \exp_not:N \exp_after:wN { \exp_not:N \tex_the:D #1 }
16765 \__fp_sep: \exp_not:N \__fp_parse_one_register_dim:ww
16766 \tl_to_str:n { pt } \__fp_sep: \exp_not:N \__fp_parse_one_register_mu:www
16767 . \tl_to_str:n { pt } \__fp_sep: \exp_not:N \__fp_parse_one_register_int:www
16768 \s__fp_stop
16769 }
16770 \exp_args:Nno \use:nn
16771 { \cs_new:Npn \__fp_parse_one_register_auxii:wwwNw #1 . #2 }
16772 { \tl_to_str:n { pt } #3 \__fp_sep: #4#5 \s__fp_stop }
16773 { #4 #1.#2\__fp_sep: }
16774 \exp_args:Nno \use:nn
16775 { \cs_new:Npn \__fp_parse_one_register_mu:www #1 }
16776 { \tl_to_str:n { mu } \__fp_sep: #2 \__fp_sep: }
16777 { \__fp_parse_one_register_dim:ww #1 \__fp_sep: }
16778 \cs_new:Npn \__fp_parse_one_register_int:www #1\__fp_sep: #2.\__fp_sep: #3\__fp_sep:
16779 { \__fp_parse:n { #1 e #3 } }
16780 \cs_new:Npn \__fp_parse_one_register_dim:ww #1\__fp_sep: #2\__fp_sep:
16781 {
16782 \exp_after:wN \__fp_from_dim_test:ww
16783 \int_value:w #2 \exp_after:wN ,
16784 \int_value:w \dim_to_decimal_in_sp:n { #1 pt } \__fp_sep:
16785 }
16786 \cs_new:Npn \__fp_parse_one_register_special:N #1
16787 {
16788 \if_meaning:w \box_wd:N #1 \__fp_parse_one_register_wd:w \fi:
16789 \if_meaning:w \box_ht:N #1 \__fp_parse_one_register_wd:w \fi:
16790 \if_meaning:w \box_dp:N #1 \__fp_parse_one_register_wd:w \fi:
16791 \if_meaning:w \infty #1
16792 \__fp_parse_one_register_math:NNw \infty #1
16793 \fi:
16794 \if_meaning:w \pi #1
16795 \__fp_parse_one_register_math:NNw \pi #1
16796 \fi:
16797 }
16798 \cs_new:Npn \__fp_parse_one_register_math:NNw
16799 #1#2#3#4 \__fp_parse_expand:w
16800 {
16801 #3
16802 \str_if_eq:nnTF {#1} {#2}
16803 {
16804 \msg_expandable_error:nnn
16805 { fp } { infty-pi } {#1}
16806 \c_nan_fp
16807 }
16808 { #4 \__fp_parse_expand:w }
16809 }
16810 \cs_new:Npn \__fp_parse_one_register_wd:w
16811 #1#2 \exp_after:wN #3#4 \__fp_parse_expand:w
16812 {
16813 #1
16814 \exp_after:wN \__fp_parse_one_register_wd:Nw
16815 #4 \__fp_parse_expand:w e
16816 }
16817 \cs_new:Npn \__fp_parse_one_register_wd:Nw #1#2 \__fp_sep:
16818 {
16819 \exp_after:wN \__fp_from_dim_test:ww
16820 \exp_after:wN 0 \exp_after:wN ,
16821 \int_value:w \dim_to_decimal_in_sp:n { #1 #2 } \__fp_sep:
16822 }
16823 \cs_new:Npn \__fp_parse_one_digit:NN #1
16824 {
16825 \exp_after:wN \__fp_parse_infix_after_operand:NwN
16826 \exp_after:wN #1
16827 \exp:w \exp_end_continue_f:w
16828 \exp_after:wN \__fp_sanitize:wN
16829 \int_value:w \__fp_int_eval:w 0 \__fp_parse_trim_zeros:N
16830 }
16831 \cs_new:Npn \__fp_parse_one_other:NN #1 #2
16832 {
16833 \if_int_compare:w
16834 \__fp_int_eval:w
16835 ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26
16836 = 3 \exp_stop_f:
16837 \exp_after:wN \__fp_parse_word:Nw
16838 \exp_after:wN #1
16839 \exp_after:wN #2
16840 \exp:w \exp_after:wN \__fp_parse_letters:N
16841 \exp:w
16842 \else:
16843 \exp_after:wN \__fp_parse_prefix:NNN
16844 \exp_after:wN #1
16845 \exp_after:wN #2
16846 \cs:w
16847 __fp_parse_prefix_ \token_to_str:N #2 :Nw
16848 \exp_after:wN
16849 \cs_end:
16850 \exp:w
16851 \fi:
16852 \__fp_parse_expand:w
16853 }
16854 \cs_new:Npn \__fp_parse_word:Nw #1#2\__fp_sep:
16855 {
16856 \cs_if_exist_use:cF { __fp_parse_word_#2:N }
16857 {
16858 \cs_if_exist_use:cF
16859 { __fp_parse_caseless_ \str_casefold:n {#2} :N }
16860 {
16861 \msg_expandable_error:nnn
16862 { fp } { unknown-fp-word } {#2}
16863 \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
16864 \__fp_parse_infix:NN
16865 }
16866 }
16867 #1
16868 }
16869 \cs_new:Npn \__fp_parse_letters:N #1
16870 {
16871 \exp_end_continue_f:w
16872 \if_int_compare:w
16873 \if_catcode:w \scan_stop: \exp_not:N #1
16874 0
16875 \else:
16876 \__fp_int_eval:w
16877 ( `#1 \if_int_compare:w `#1 > `Z - 32 \fi: ) / 26
16878 \fi:
16879 = 3 \exp_stop_f:
16880 \exp_after:wN #1
16881 \exp:w \exp_after:wN \__fp_parse_letters:N
16882 \exp:w
16883 \else:
16884 \__fp_parse_return_sep:w #1
16885 \fi:
16886 \__fp_parse_expand:w
16887 }
16888 \cs_new:Npn \__fp_parse_prefix:NNN #1#2#3
16889 {
16890 \if_meaning:w \scan_stop: #3
16891 \exp_after:wN \__fp_parse_prefix_unknown:NNN
16892 \exp_after:wN #2
16893 \fi:
16894 #3 #1
16895 }
16896 \cs_new:Npn \__fp_parse_prefix_unknown:NNN #1#2#3
16897 {
16898 \cs_if_exist:cTF { __fp_parse_infix_ \token_to_str:N #1 :N }
16899 {
16900 \msg_expandable_error:nnn
16901 { fp } { missing-number } {#1}
16902 \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
16903 \__fp_parse_infix:NN #3 #1
16904 }
16905 {
16906 \msg_expandable_error:nnn
16907 { fp } { unknown-symbol } {#1}
16908 \__fp_parse_one:Nw #3
16909 }
16910 }
16911 \cs_new:Npn \__fp_parse_trim_zeros:N #1
16912 {
16913 \if:w 0 \exp_not:N #1
16914 \exp_after:wN \__fp_parse_trim_zeros:N
16915 \exp:w
16916 \else:
16917 \if:w . \exp_not:N #1
16918 \exp_after:wN \__fp_parse_strim_zeros:N
16919 \exp:w
16920 \else:
16921 \__fp_parse_trim_end:w #1
16922 \fi:
16923 \fi:
16924 \__fp_parse_expand:w
16925 }
16926 \cs_new:Npn \__fp_parse_trim_end:w #1 \fi: \fi: \__fp_parse_expand:w
16927 {
16928 \fi:
16929 \fi:
16930 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
16931 \exp_after:wN \__fp_parse_large:N
16932 \else:
16933 \exp_after:wN \__fp_parse_zero:
16934 \fi:
16935 #1
16936 }
16937 \cs_new:Npn \__fp_parse_strim_zeros:N #1
16938 {
16939 \if:w 0 \exp_not:N #1
16940 - 1
16941 \exp_after:wN \__fp_parse_strim_zeros:N \exp:w
16942 \else:
16943 \__fp_parse_strim_end:w #1
16944 \fi:
16945 \__fp_parse_expand:w
16946 }
16947 \cs_new:Npn \__fp_parse_strim_end:w #1 \fi: \__fp_parse_expand:w
16948 {
16949 \fi:
16950 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
16951 \exp_after:wN \__fp_parse_small:N
16952 \else:
16953 \exp_after:wN \__fp_parse_zero:
16954 \fi:
16955 #1
16956 }
16957 \cs_new:Npn \__fp_parse_zero:
16958 {
16959 \exp_after:wN \__fp_sep: \exp_after:wN 1
16960 \int_value:w \__fp_parse_exponent:N
16961 }
16962 \cs_new:Npn \__fp_parse_small:N #1
16963 {
16964 \exp_after:wN \__fp_parse_pack_leading:NNNNNww
16965 \int_value:w \__fp_int_eval:w 1 \token_to_str:N #1
16966 \exp_after:wN \__fp_parse_small_leading:wwNN
16967 \int_value:w 1
16968 \exp_after:wN \__fp_parse_digits_vii:N
16969 \exp:w \__fp_parse_expand:w
16970 }
16971 \cs_new:Npn \__fp_parse_small_leading:wwNN 1 #1 \__fp_sep: #2\__fp_sep: #3 #4
16972 {
16973 #1 #2
16974 \exp_after:wN \__fp_parse_pack_trailing:NNNNNNww
16975 \exp_after:wN 0
16976 \int_value:w \__fp_int_eval:w 1
16977 \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f:
16978 \token_to_str:N #4
16979 \exp_after:wN \__fp_parse_small_trailing:wwNN
16980 \int_value:w 1
16981 \exp_after:wN \__fp_parse_digits_vi:N
16982 \exp:w
16983 \else:
16984 0000 0000 \__fp_parse_exponent:Nw #4
16985 \fi:
16986 \__fp_parse_expand:w
16987 }
16988 \cs_new:Npn \__fp_parse_small_trailing:wwNN 1 #1 \__fp_sep: #2\__fp_sep: #3 #4
16989 {
16990 #1 #2
16991 \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f:
16992 \token_to_str:N #4
16993 \exp_after:wN \__fp_parse_small_round:NN
16994 \exp_after:wN #4
16995 \exp:w
16996 \else:
16997 0 \__fp_parse_exponent:Nw #4
16998 \fi:
16999 \__fp_parse_expand:w
17000 }
17001 \cs_new:Npn \__fp_parse_pack_trailing:NNNNNNww
17002 #1 #2 #3#4#5#6 #7\__fp_sep: #8 \__fp_sep:
17003 {
17004 \if_meaning:w 2 #2 + 1 \fi:
17005 \__fp_sep: #8 + #1 \__fp_sep: {#3#4#5#6} {#7}\__fp_sep:
17006 }
17007 \cs_new:Npn \__fp_parse_pack_leading:NNNNNww #1 #2#3#4#5 #6\__fp_sep: #7\__fp_sep:
17008 {
17009 + #7
17010 \if_meaning:w 2 #1 \__fp_parse_pack_carry:w \fi:
17011 \__fp_sep: 0 {#2#3#4#5} {#6}
17012 }
17013 \cs_new:Npn \__fp_parse_pack_carry:w \fi: \__fp_sep: 0 #1
17014 { \fi: + 1 \__fp_sep: 0 {1000} }
17015 \cs_new:Npn \__fp_parse_large:N #1
17016 {
17017 \exp_after:wN \__fp_parse_large_leading:wwNN
17018 \int_value:w 1 \token_to_str:N #1
17019 \exp_after:wN \__fp_parse_digits_vii:N
17020 \exp:w \__fp_parse_expand:w
17021 }
17022 \cs_new:Npn \__fp_parse_large_leading:wwNN 1 #1 \__fp_sep: #2\__fp_sep: #3 #4
17023 {
17024 + \c__fp_half_prec_int - #3
17025 \exp_after:wN \__fp_parse_pack_leading:NNNNNww
17026 \int_value:w \__fp_int_eval:w 1 #1
17027 \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f:
17028 \exp_after:wN \__fp_parse_large_trailing:wwNN
17029 \int_value:w 1 \token_to_str:N #4
17030 \exp_after:wN \__fp_parse_digits_vi:N
17031 \exp:w
17032 \else:
17033 \if:w . \exp_not:N #4
17034 \exp_after:wN \__fp_parse_small_leading:wwNN
17035 \int_value:w 1
17036 \cs:w
17037 __fp_parse_digits_
17038 \__fp_int_to_roman:w #3
17039 :N \exp_after:wN
17040 \cs_end:
17041 \exp:w
17042 \else:
17043 #2
17044 \exp_after:wN \__fp_parse_pack_trailing:NNNNNNww
17045 \exp_after:wN 0
17046 \int_value:w 1 0000 0000
17047 \__fp_parse_exponent:Nw #4
17048 \fi:
17049 \fi:
17050 \__fp_parse_expand:w
17051 }
17052 \cs_new:Npn \__fp_parse_large_trailing:wwNN 1 #1 \__fp_sep: #2\__fp_sep: #3 #4
17053 {
17054 \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f:
17055 \exp_after:wN \__fp_parse_pack_trailing:NNNNNNww
17056 \exp_after:wN \c__fp_half_prec_int
17057 \int_value:w \__fp_int_eval:w 1 #1 \token_to_str:N #4
17058 \exp_after:wN \__fp_parse_large_round:NN
17059 \exp_after:wN #4
17060 \exp:w
17061 \else:
17062 \exp_after:wN \__fp_parse_pack_trailing:NNNNNNww
17063 \int_value:w \__fp_int_eval:w 7 - #3 \exp_stop_f:
17064 \int_value:w \__fp_int_eval:w 1 #1
17065 \if:w . \exp_not:N #4
17066 \exp_after:wN \__fp_parse_small_trailing:wwNN
17067 \int_value:w 1
17068 \cs:w
17069 __fp_parse_digits_
17070 \__fp_int_to_roman:w #3
17071 :N \exp_after:wN
17072 \cs_end:
17073 \exp:w
17074 \else:
17075 #2 0 \__fp_parse_exponent:Nw #4
17076 \fi:
17077 \fi:
17078 \__fp_parse_expand:w
17079 }
17080 \cs_new:Npn \__fp_parse_round_loop:N #1
17081 {
17082 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
17083 + 1
17084 \if:w 0 \token_to_str:N #1
17085 \exp_after:wN \__fp_parse_round_loop:N
17086 \exp:w
17087 \else:
17088 \exp_after:wN \__fp_parse_round_up:N
17089 \exp:w
17090 \fi:
17091 \else:
17092 \__fp_parse_return_sep:w 0 #1
17093 \fi:
17094 \__fp_parse_expand:w
17095 }
17096 \cs_new:Npn \__fp_parse_round_up:N #1
17097 {
17098 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
17099 + 1
17100 \exp_after:wN \__fp_parse_round_up:N
17101 \exp:w
17102 \else:
17103 \__fp_parse_return_sep:w 1 #1
17104 \fi:
17105 \__fp_parse_expand:w
17106 }
17107 \cs_new:Npn \__fp_parse_round_after:wN #1\__fp_sep: #2
17108 {
17109 + #2 \exp_after:wN \__fp_sep:
17110 \int_value:w \__fp_int_eval:w #1 + \__fp_parse_exponent:N
17111 }
17112 \cs_new:Npn \__fp_parse_small_round:NN #1#2
17113 {
17114 \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f:
17115 +
17116 \exp_after:wN \__fp_round_s:NNNw
17117 \exp_after:wN 0
17118 \exp_after:wN #1
17119 \exp_after:wN #2
17120 \int_value:w \__fp_int_eval:w
17121 \exp_after:wN \__fp_parse_round_after:wN
17122 \int_value:w \__fp_int_eval:w 0 * \__fp_int_eval:w 0
17123 \exp_after:wN \__fp_parse_round_loop:N
17124 \exp:w
17125 \else:
17126 \__fp_parse_exponent:Nw #2
17127 \fi:
17128 \__fp_parse_expand:w
17129 }
17130 \cs_new:Npn \__fp_parse_large_round:NN #1#2
17131 {
17132 \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f:
17133 +
17134 \exp_after:wN \__fp_round_s:NNNw
17135 \exp_after:wN 0
17136 \exp_after:wN #1
17137 \exp_after:wN #2
17138 \int_value:w \__fp_int_eval:w
17139 \exp_after:wN \__fp_parse_large_round_aux:wNN
17140 \int_value:w \__fp_int_eval:w 1
17141 \exp_after:wN \__fp_parse_round_loop:N
17142 \else: %^^A could be dot, or e, or other
17143 \exp_after:wN \__fp_parse_large_round_test:NN
17144 \exp_after:wN #1
17145 \exp_after:wN #2
17146 \fi:
17147 }
17148 \cs_new:Npn \__fp_parse_large_round_test:NN #1#2
17149 {
17150 \if:w . \exp_not:N #2
17151 \exp_after:wN \__fp_parse_small_round:NN
17152 \exp_after:wN #1
17153 \exp:w
17154 \else:
17155 \__fp_parse_exponent:Nw #2
17156 \fi:
17157 \__fp_parse_expand:w
17158 }
17159 \cs_new:Npn \__fp_parse_large_round_aux:wNN #1 \__fp_sep: #2 #3
17160 {
17161 + #2
17162 \exp_after:wN \__fp_parse_round_after:wN
17163 \int_value:w \__fp_int_eval:w #1
17164 \if:w . \exp_not:N #3
17165 + 0 * \__fp_int_eval:w 0
17166 \exp_after:wN \__fp_parse_round_loop:N
17167 \exp:w \exp_after:wN \__fp_parse_expand:w
17168 \else:
17169 \exp_after:wN \__fp_sep:
17170 \exp_after:wN 0
17171 \exp_after:wN #3
17172 \fi:
17173 }
17174 \cs_new:Npn \__fp_parse_exponent:Nw #1 #2 \__fp_parse_expand:w
17175 {
17176 \exp_after:wN \__fp_sep:
17177 \int_value:w #2 \__fp_parse_exponent:N #1
17178 }
17179 \cs_new:Npn \__fp_parse_exponent:N #1
17180 {
17181 \if:w e \if:w E \exp_not:N #1 e \else: \exp_not:N #1 \fi:
17182 \exp_after:wN \__fp_parse_exponent_aux:NN
17183 \exp_after:wN #1
17184 \exp:w
17185 \else:
17186 0 \__fp_parse_return_sep:w #1
17187 \fi:
17188 \__fp_parse_expand:w
17189 }
17190 \cs_new:Npn \__fp_parse_exponent_aux:NN #1#2
17191 {
17192 \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #2
17193 0 \else: `#2 \fi: > `9 \exp_stop_f:
17194 0 \exp_after:wN \__fp_sep: \exp_after:wN #1
17195 \else:
17196 \exp_after:wN \__fp_parse_exponent_sign:N
17197 \fi:
17198 #2
17199 }
17200 \cs_new:Npn \__fp_parse_exponent_sign:N #1
17201 {
17202 \if:w + \if:w - \exp_not:N #1 + \fi: \token_to_str:N #1
17203 \exp_after:wN \__fp_parse_exponent_sign:N
17204 \exp:w \exp_after:wN \__fp_parse_expand:w
17205 \else:
17206 \exp_after:wN \__fp_parse_exponent_body:N
17207 \exp_after:wN #1
17208 \fi:
17209 }
17210 \cs_new:Npn \__fp_parse_exponent_body:N #1
17211 {
17212 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
17213 \token_to_str:N #1
17214 \exp_after:wN \__fp_parse_exponent_digits:N
17215 \exp:w
17216 \else:
17217 \__fp_parse_exponent_keep:NTF #1
17218 { \__fp_parse_return_sep:w #1 }
17219 {
17220 \exp_after:wN \__fp_sep:
17221 \exp:w
17222 }
17223 \fi:
17224 \__fp_parse_expand:w
17225 }
17226 \cs_new:Npn \__fp_parse_exponent_digits:N #1
17227 {
17228 \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f:
17229 \token_to_str:N #1
17230 \exp_after:wN \__fp_parse_exponent_digits:N
17231 \exp:w
17232 \else:
17233 \__fp_parse_return_sep:w #1
17234 \fi:
17235 \__fp_parse_expand:w
17236 }
17237 \prg_new_conditional:Npnn \__fp_parse_exponent_keep:N #1 { TF }
17238 {
17239 \if_catcode:w \scan_stop: \exp_not:N #1
17240 \if_meaning:w \scan_stop: #1
17241 \if:w 0 \__fp_str_if_eq:nn { \s__fp } { \exp_not:N #1 }
17242 0
17243 \msg_expandable_error:nnn
17244 { fp } { after-e } { floating~point~ }
17245 \prg_return_true:
17246 \else:
17247 0
17248 \msg_expandable_error:nnn
17249 { kernel } { bad-variable } {#1}
17250 \prg_return_false:
17251 \fi:
17252 \else:
17253 \if:w 0 \__fp_str_if_eq:nn { \int_value:w #1 } { \tex_the:D #1 }
17254 \int_value:w #1
17255 \else:
17256 0
17257 \msg_expandable_error:nnn
17258 { fp } { after-e } { dimension~#1 }
17259 \fi:
17260 \prg_return_false:
17261 \fi:
17262 \else:
17263 0
17264 \msg_expandable_error:nnn
17265 { fp } { missing } { exponent }
17266 \prg_return_true:
17267 \fi:
17268 }
17269 \cs_new_eq:cN { __fp_parse_prefix_+:Nw } \__fp_parse_one:Nw
17270 \cs_new:Npn \__fp_parse_apply_function:NNNwN #1#2#3#4@#5
17271 {
17272 #3 #2 #4 @
17273 \exp:w \exp_end_continue_f:w #5 #1
17274 }
17275 \cs_new:Npn \__fp_parse_apply_unary:NNNwN #1#2#3#4@#5
17276 {
17277 \__fp_parse_apply_unary_chk:NwNw #4 @ \__fp_sep: . \s__fp_stop
17278 \__fp_parse_apply_unary_type:NNN
17279 #3 #2 #4 @
17280 \exp:w \exp_end_continue_f:w #5 #1
17281 }
17282 \cs_new:Npn \__fp_parse_apply_unary_chk:NwNw #1#2 \__fp_sep: #3#4 \s__fp_stop
17283 {
17284 \if_meaning:w @ #3 \else:
17285 \token_if_eq_meaning:NNTF . #3
17286 { \__fp_parse_apply_unary_chk:nNNNNw { no } }
17287 { \__fp_parse_apply_unary_chk:nNNNNw { multi } }
17288 \fi:
17289 }
17290 \cs_new:Npn \__fp_parse_apply_unary_chk:nNNNNw #1#2#3#4#5#6 @
17291 {
17292 #2
17293 \__fp_error:nffn { #1-arg } { \__fp_func_to_name:N #4 } { } { }
17294 \exp_after:wN #4 \exp_after:wN #5 \c_nan_fp @
17295 }
17296 \cs_new:Npn \__fp_parse_apply_unary_type:NNN #1#2#3
17297 {
17298 \__fp_change_func_type:NNN #3 #1 \__fp_parse_apply_unary_error:NNw
17299 #2 #3
17300 }
17301 \cs_new:Npn \__fp_parse_apply_unary_error:NNw #1#2#3 @
17302 { \__fp_invalid_operation_o:fw { \__fp_func_to_name:N #1 } #3 }
17303 \cs_set_protected:Npn \__fp_tmp:w #1#2#3#4
17304 {
17305 \cs_new:cpn { __fp_parse_prefix_ #1 :Nw } ##1
17306 {
17307 \exp_after:wN \__fp_parse_apply_unary:NNNwN
17308 \exp_after:wN ##1
17309 \exp_after:wN #4
17310 \exp_after:wN #3
17311 \exp:w
17312 \if_int_compare:w #2 < ##1
17313 \__fp_parse_operand:Nw ##1
17314 \else:
17315 \__fp_parse_operand:Nw #2
17316 \fi:
17317 \__fp_parse_expand:w
17318 }
17319 }
17320 \__fp_tmp:w - \c__fp_prec_not_int \__fp_set_sign_o:w 2
17321 \__fp_tmp:w ! \c__fp_prec_not_int \__fp_not_o:w ?
17322 \cs_new:cpn { __fp_parse_prefix_.:Nw } #1
17323 {
17324 \exp_after:wN \__fp_parse_infix_after_operand:NwN
17325 \exp_after:wN #1
17326 \exp:w \exp_end_continue_f:w
17327 \exp_after:wN \__fp_sanitize:wN
17328 \int_value:w \__fp_int_eval:w 0 \__fp_parse_strim_zeros:N
17329 }
17330 \cs_new:cpn { __fp_parse_prefix_(:Nw } #1
17331 {
17332 \exp_after:wN \__fp_parse_lparen_after:NwN
17333 \exp_after:wN #1
17334 \exp:w
17335 \if_int_compare:w #1 = \c__fp_prec_func_int
17336 \__fp_parse_operand:Nw \c__fp_prec_comma_int
17337 \else:
17338 \__fp_parse_operand:Nw \c__fp_prec_tuple_int
17339 \fi:
17340 \__fp_parse_expand:w
17341 }
17342 \cs_new:Npe \__fp_parse_lparen_after:NwN #1#2 @ #3
17343 {
17344 \exp_not:N \token_if_eq_meaning:NNTF #3
17345 \exp_not:c { __fp_parse_infix_):N }
17346 {
17347 \exp_not:N \__fp_exp_after_array_f:w #2 \s__fp_expr_stop
17348 \exp_not:N \exp_after:wN
17349 \exp_not:N \__fp_parse_infix_after_paren:NN
17350 \exp_not:N \exp_after:wN #1
17351 \exp_not:N \exp:w
17352 \exp_not:N \__fp_parse_expand:w
17353 }
17354 {
17355 \exp_not:N \msg_expandable_error:nnn
17356 { fp } { missing } { ) }
17357 \exp_not:N \tl_if_empty:nT {#2} \exp_not:N \c__fp_empty_tuple_fp
17358 #2 @
17359 \exp_not:N \use_none:n #3
17360 }
17361 }
17362 \cs_new:cpn { __fp_parse_prefix_):Nw } #1
17363 {
17364 \if_int_compare:w #1 = \c__fp_prec_comma_int
17365 \else:
17366 \if_int_compare:w #1 = \c__fp_prec_tuple_int
17367 \exp_after:wN \c__fp_empty_tuple_fp \exp:w
17368 \else:
17369 \msg_expandable_error:nnn
17370 { fp } { missing-number } { ) }
17371 \exp_after:wN \c_nan_fp \exp:w
17372 \fi:
17373 \exp_end_continue_f:w
17374 \fi:
17375 \__fp_parse_infix_after_paren:NN #1 )
17376 }
17377 \cs_set_protected:Npn \__fp_tmp:w #1 #2
17378 {
17379 \cs_new:cpn { __fp_parse_word_#1:N }
17380 { \exp_after:wN #2 \exp:w \exp_end_continue_f:w \__fp_parse_infix:NN }
17381 }
17382 \__fp_tmp:w { inf } \c_inf_fp
17383 \__fp_tmp:w { nan } \c_nan_fp
17384 \__fp_tmp:w { pi } \c_pi_fp
17385 \__fp_tmp:w { deg } \c_one_degree_fp
17386 \__fp_tmp:w { true } \c_one_fp
17387 \__fp_tmp:w { false } \c_zero_fp
17388 \cs_new_eq:NN \__fp_parse_caseless_inf:N \__fp_parse_word_inf:N
17389 \cs_new_eq:NN \__fp_parse_caseless_infinity:N \__fp_parse_word_inf:N
17390 \cs_new_eq:NN \__fp_parse_caseless_nan:N \__fp_parse_word_nan:N
17391 \cs_set_protected:Npn \__fp_tmp:w #1 #2
17392 {
17393 \cs_new:cpn { __fp_parse_word_#1:N }
17394 {
17395 \__fp_exp_after_f:nw { \__fp_parse_infix:NN }
17396 \s__fp \__fp_chk:w 10 #2 \__fp_sep:
17397 }
17398 }
17399 \__fp_tmp:w {pt} { {1} {1000} {0000} {0000} {0000} }
17400 \__fp_tmp:w {in} { {2} {7227} {0000} {0000} {0000} }
17401 \__fp_tmp:w {pc} { {2} {1200} {0000} {0000} {0000} }
17402 \__fp_tmp:w {cm} { {2} {2845} {2755} {9055} {1181} }
17403 \__fp_tmp:w {mm} { {1} {2845} {2755} {9055} {1181} }
17404 \__fp_tmp:w {dd} { {1} {1070} {0085} {6496} {0630} }
17405 \__fp_tmp:w {cc} { {2} {1284} {0102} {7795} {2756} }
17406 \__fp_tmp:w {nd} { {1} {1066} {9783} {4645} {6693} }
17407 \__fp_tmp:w {nc} { {2} {1280} {3740} {1574} {8031} }
17408 \__fp_tmp:w {bp} { {1} {1003} {7500} {0000} {0000} }
17409 \__fp_tmp:w {sp} { {-4} {1525} {8789} {0625} {0000} }
17410 \tl_map_inline:nn { {em} {ex} }
17411 {
17412 \cs_new:cpn { __fp_parse_word_#1:N }
17413 {
17414 \exp_after:wN \__fp_from_dim_test:ww
17415 \exp_after:wN 0 \exp_after:wN ,
17416 \int_value:w \dim_to_decimal_in_sp:n { 1 #1 } \exp_after:wN \__fp_sep:
17417 \exp:w \exp_end_continue_f:w \__fp_parse_infix:NN
17418 }
17419 }
17420 \cs_new:Npn \__fp_parse_unary_function:NNN #1#2#3
17421 {
17422 \exp_after:wN \__fp_parse_apply_unary:NNNwN
17423 \exp_after:wN #3
17424 \exp_after:wN #2
17425 \exp_after:wN #1
17426 \exp:w
17427 \__fp_parse_operand:Nw \c__fp_prec_func_int \__fp_parse_expand:w
17428 }
17429 \cs_new:Npn \__fp_parse_function:NNN #1#2#3
17430 {
17431 \exp_after:wN \__fp_parse_apply_function:NNNwN
17432 \exp_after:wN #3
17433 \exp_after:wN #2
17434 \exp_after:wN #1
17435 \exp:w
17436 \__fp_parse_operand:Nw \c__fp_prec_func_int \__fp_parse_expand:w
17437 }
17438 \cs_new:Npn \__fp_parse:n #1
17439 {
17440 \exp:w
17441 \group_align_safe_begin:
17442 \exp_after:wN \group_align_safe_end:
17443 \exp_after:wN \__fp_parse_after:ww
17444 \exp:w
17445 \__fp_parse_operand:Nw \c__fp_prec_end_int
17446 \__fp_parse_expand:w #1
17447 \s__fp_expr_mark \__fp_parse_infix_end:N
17448 \s__fp_expr_stop
17449 \exp_end:
17450 }
17451 \cs_new:Npn \__fp_parse_after:ww
17452 #1@ \__fp_parse_infix_end:N \s__fp_expr_stop #2 { #2 #1 }
17453 \cs_new:Npn \__fp_parse_o:n #1
17454 {
17455 \exp:w
17456 \group_align_safe_begin:
17457 \exp_after:wN \group_align_safe_end:
17458 \exp_after:wN \__fp_parse_after:ww
17459 \exp:w
17460 \__fp_parse_operand:Nw \c__fp_prec_end_int
17461 \__fp_parse_expand:w #1
17462 \s__fp_expr_mark \__fp_parse_infix_end:N
17463 \s__fp_expr_stop
17464 {
17465 \exp_end_continue_f:w
17466 \__fp_exp_after_any_f:nw { \exp_after:wN \exp_stop_f: }
17467 }
17468 }
17469 \cs_new:Npn \__fp_parse_operand:Nw #1
17470 {
17471 \exp_end_continue_f:w
17472 \exp_after:wN \__fp_parse_continue:NwN
17473 \exp_after:wN #1
17474 \exp:w \exp_end_continue_f:w
17475 \exp_after:wN \__fp_parse_one:Nw
17476 \exp_after:wN #1
17477 \exp:w
17478 }
17479 \cs_new:Npn \__fp_parse_continue:NwN #1 #2 @ #3 { #3 #1 #2 @ }
17480 \cs_new:Npn \__fp_parse_apply_binary:NwNwN #1 #2#3@ #4 #5#6@ #7
17481 {
17482 \exp_after:wN \__fp_parse_continue:NwN
17483 \exp_after:wN #1
17484 \exp:w \exp_end_continue_f:w
17485 \exp_after:wN \__fp_parse_apply_binary_chk:NN
17486 \cs:w
17487 __fp
17488 \__fp_type_from_scan:N #2
17489 _#4
17490 \__fp_type_from_scan:N #5
17491 _o:ww
17492 \cs_end:
17493 #4
17494 #2#3 #5#6
17495 \exp:w \exp_end_continue_f:w #7 #1
17496 }
17497 \cs_new:Npn \__fp_parse_apply_binary_chk:NN #1#2
17498 {
17499 \if_meaning:w \scan_stop: #1
17500 \__fp_parse_apply_binary_error:NNN #2
17501 \fi:
17502 #1
17503 }
17504 \cs_new:Npn \__fp_parse_apply_binary_error:NNN #1#2#3
17505 {
17506 #2
17507 \__fp_invalid_operation_o:Nww #1
17508 }
17509 \cs_new:Npn \__fp_binary_type_o:Nww #1 #2#3 \__fp_sep: #4
17510 {
17511 \exp_after:wN \__fp_parse_apply_binary_chk:NN
17512 \cs:w
17513 __fp
17514 \__fp_type_from_scan:N #2
17515 _ #1
17516 \__fp_type_from_scan:N #4
17517 _o:ww
17518 \cs_end:
17519 #1
17520 #2 #3 \__fp_sep: #4
17521 }
17522 \cs_new:Npn \__fp_binary_rev_type_o:Nww #1 #2#3 \__fp_sep: #4#5 \__fp_sep:
17523 {
17524 \exp_after:wN \__fp_parse_apply_binary_chk:NN
17525 \cs:w
17526 __fp
17527 \__fp_type_from_scan:N #4
17528 _ #1
17529 \__fp_type_from_scan:N #2
17530 _o:ww
17531 \cs_end:
17532 #1
17533 #4 #5 \__fp_sep: #2 #3 \__fp_sep:
17534 }
17535 \cs_new:Npn \__fp_parse_infix_after_operand:NwN #1 #2\__fp_sep:
17536 {
17537 \__fp_exp_after_f:nw { \__fp_parse_infix:NN #1 }
17538 #2\__fp_sep:
17539 }
17540 \cs_new:Npn \__fp_parse_infix:NN #1 #2
17541 {
17542 \if_catcode:w \scan_stop: \exp_not:N #2
17543 \if:w 0 \__fp_str_if_eq:nn { \s__fp_expr_mark } { \exp_not:N #2 }
17544 \exp_after:wN \exp_after:wN
17545 \exp_after:wN \__fp_parse_infix_mark:NNN
17546 \else:
17547 \exp_after:wN \exp_after:wN
17548 \exp_after:wN \__fp_parse_infix_juxt:N
17549 \fi:
17550 \else:
17551 \if_int_compare:w
17552 \__fp_int_eval:w
17553 ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26
17554 = 3 \exp_stop_f:
17555 \exp_after:wN \exp_after:wN
17556 \exp_after:wN \__fp_parse_infix_juxt:N
17557 \else:
17558 \exp_after:wN \__fp_parse_infix_check:NNN
17559 \cs:w
17560 __fp_parse_infix_ \token_to_str:N #2 :N
17561 \exp_after:wN \exp_after:wN \exp_after:wN
17562 \cs_end:
17563 \fi:
17564 \fi:
17565 #1
17566 #2
17567 }
17568 \cs_new:Npn \__fp_parse_infix_check:NNN #1#2#3
17569 {
17570 \if_meaning:w \scan_stop: #1
17571 \msg_expandable_error:nnn
17572 { fp } { missing } { * }
17573 \exp_after:wN \__fp_parse_infix_mul:N
17574 \exp_after:wN #2
17575 \exp_after:wN #3
17576 \else:
17577 \exp_after:wN #1
17578 \exp_after:wN #2
17579 \exp:w \exp_after:wN \__fp_parse_expand:w
17580 \fi:
17581 }
17582 \cs_new:Npn \__fp_parse_infix_after_paren:NN #1 #2
17583 {
17584 \if_catcode:w \scan_stop: \exp_not:N #2
17585 \if:w 0 \__fp_str_if_eq:nn { \s__fp_expr_mark } { \exp_not:N #2 }
17586 \exp_after:wN \exp_after:wN
17587 \exp_after:wN \__fp_parse_infix_mark:NNN
17588 \else:
17589 \exp_after:wN \exp_after:wN
17590 \exp_after:wN \__fp_parse_infix_mul:N
17591 \fi:
17592 \else:
17593 \if_int_compare:w
17594 \__fp_int_eval:w
17595 ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26
17596 = 3 \exp_stop_f:
17597 \exp_after:wN \exp_after:wN
17598 \exp_after:wN \__fp_parse_infix_mul:N
17599 \else:
17600 \exp_after:wN \__fp_parse_infix_check:NNN
17601 \cs:w
17602 __fp_parse_infix_ \token_to_str:N #2 :N
17603 \exp_after:wN \exp_after:wN \exp_after:wN
17604 \cs_end:
17605 \fi:
17606 \fi:
17607 #1
17608 #2
17609 }
17610 \cs_new:Npn \__fp_parse_infix_mark:NNN #1#2#3 { #3 #1 }
17611 \cs_new:Npn \__fp_parse_infix_end:N #1
17612 { @ \use_none:n \__fp_parse_infix_end:N }
17613 \cs_set_protected:Npn \__fp_tmp:w #1
17614 {
17615 \cs_new:Npn #1 ##1
17616 {
17617 \if_int_compare:w ##1 > \c__fp_prec_end_int
17618 \exp_after:wN @
17619 \exp_after:wN \use_none:n
17620 \exp_after:wN #1
17621 \else:
17622 \msg_expandable_error:nnn { fp } { extra } { ) }
17623 \exp_after:wN \__fp_parse_infix:NN
17624 \exp_after:wN ##1
17625 \exp:w \exp_after:wN \__fp_parse_expand:w
17626 \fi:
17627 }
17628 }
17629 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_):N }
17630 \cs_set_protected:Npn \__fp_tmp:w #1
17631 {
17632 \cs_new:Npn #1 ##1
17633 {
17634 \if_int_compare:w ##1 > \c__fp_prec_comma_int
17635 \exp_after:wN @
17636 \exp_after:wN \use_none:n
17637 \exp_after:wN #1
17638 \else:
17639 \if_int_compare:w ##1 < \c__fp_prec_comma_int
17640 \exp_after:wN @
17641 \exp_after:wN \__fp_parse_apply_comma:NwNwN
17642 \exp_after:wN ,
17643 \exp:w
17644 \else:
17645 \exp_after:wN \__fp_parse_infix_comma:w
17646 \exp:w
17647 \fi:
17648 \__fp_parse_operand:Nw \c__fp_prec_comma_int
17649 \exp_after:wN \__fp_parse_expand:w
17650 \fi:
17651 }
17652 }
17653 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_,:N }
17654 \cs_new:Npn \__fp_parse_infix_comma:w #1 @
17655 { #1 @ \use_none:n }
17656 \cs_new:Npn \__fp_parse_apply_comma:NwNwN #1 #2@ #3 #4@ #5
17657 {
17658 \exp_after:wN \__fp_parse_continue:NwN
17659 \exp_after:wN #1
17660 \exp:w \exp_end_continue_f:w
17661 \__fp_exp_after_tuple_f:nw { }
17662 \s__fp_tuple \__fp_tuple_chk:w { #2 #4 } \__fp_sep:
17663 #5 #1
17664 }
17665 \cs_set_protected:Npn \__fp_tmp:w #1#2#3#4
17666 {
17667 \cs_new:Npn #1 ##1
17668 {
17669 \if_int_compare:w ##1 < #3
17670 \exp_after:wN @
17671 \exp_after:wN \__fp_parse_apply_binary:NwNwN
17672 \exp_after:wN #2
17673 \exp:w
17674 \__fp_parse_operand:Nw #4
17675 \exp_after:wN \__fp_parse_expand:w
17676 \else:
17677 \exp_after:wN @
17678 \exp_after:wN \use_none:n
17679 \exp_after:wN #1
17680 \fi:
17681 }
17682 }
17683 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_^:N } ^
17684 \c__fp_prec_hatii_int \c__fp_prec_hat_int
17685 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_juxt:N } *
17686 \c__fp_prec_juxt_int \c__fp_prec_juxt_int
17687 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_/:N } /
17688 \c__fp_prec_times_int \c__fp_prec_times_int
17689 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_mul:N } *
17690 \c__fp_prec_times_int \c__fp_prec_times_int
17691 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_-:N } -
17692 \c__fp_prec_plus_int \c__fp_prec_plus_int
17693 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_+:N } +
17694 \c__fp_prec_plus_int \c__fp_prec_plus_int
17695 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_and:N } &
17696 \c__fp_prec_and_int \c__fp_prec_and_int
17697 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_or:N } |
17698 \c__fp_prec_or_int \c__fp_prec_or_int
17699 \cs_new:cpn { __fp_parse_infix_(:N } #1
17700 { \__fp_parse_infix_mul:N #1 ( }
17701 \cs_set_protected:Npn \__fp_tmp:w #1
17702 {
17703 \cs_new:cpn { __fp_parse_infix_*:N } ##1##2
17704 {
17705 \if:w * \exp_not:N ##2
17706 \exp_after:wN #1
17707 \exp_after:wN ##1
17708 \else:
17709 \exp_after:wN \__fp_parse_infix_mul:N
17710 \exp_after:wN ##1
17711 \exp_after:wN ##2
17712 \fi:
17713 }
17714 }
17715 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_^:N }
17716 \cs_set_protected:Npn \__fp_tmp:w #1#2#3
17717 {
17718 \cs_new:Npn #1 ##1##2
17719 {
17720 \if:w #2 \exp_not:N ##2
17721 \exp_after:wN #1
17722 \exp_after:wN ##1
17723 \exp:w \exp_after:wN \__fp_parse_expand:w
17724 \else:
17725 \exp_after:wN #3
17726 \exp_after:wN ##1
17727 \exp_after:wN ##2
17728 \fi:
17729 }
17730 }
17731 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_|:N } | \__fp_parse_infix_or:N
17732 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_&:N } & \__fp_parse_infix_and:N
17733 \cs_set_protected:Npn \__fp_tmp:w #1#2#3#4
17734 {
17735 \cs_new:Npn #1 ##1
17736 {
17737 \if_int_compare:w ##1 < \c__fp_prec_quest_int
17738 #4
17739 \exp_after:wN @
17740 \exp_after:wN #2
17741 \exp:w
17742 \__fp_parse_operand:Nw #3
17743 \exp_after:wN \__fp_parse_expand:w
17744 \else:
17745 \exp_after:wN @
17746 \exp_after:wN \use_none:n
17747 \exp_after:wN #1
17748 \fi:
17749 }
17750 }
17751 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_?:N }
17752 \__fp_ternary:NwwN \c__fp_prec_quest_int { }
17753 \exp_args:Nc \__fp_tmp:w { __fp_parse_infix_::N }
17754 \__fp_ternary_auxii:NwwN \c__fp_prec_colon_int
17755 {
17756 \msg_expandable_error:nnnn
17757 { fp } { missing } { ? } { ~for~?: }
17758 }
17759 \cs_new:cpn { __fp_parse_infix_<:N } #1
17760 { \__fp_parse_compare:NNNNNNN #1 1 0 0 0 0 < }
17761 \cs_new:cpn { __fp_parse_infix_=:N } #1
17762 { \__fp_parse_compare:NNNNNNN #1 1 0 0 0 0 = }
17763 \cs_new:cpn { __fp_parse_infix_>:N } #1
17764 { \__fp_parse_compare:NNNNNNN #1 1 0 0 0 0 > }
17765 \cs_new:cpn { __fp_parse_infix_!:N } #1
17766 {
17767 \exp_after:wN \__fp_parse_compare:NNNNNNN
17768 \exp_after:wN #1
17769 \exp_after:wN 0
17770 \exp_after:wN 1
17771 \exp_after:wN 1
17772 \exp_after:wN 1
17773 \exp_after:wN 1
17774 }
17775 \cs_new:Npn \__fp_parse_excl_error:
17776 {
17777 \msg_expandable_error:nnnn
17778 { fp } { missing } { = } { ~after~!. }
17779 }
17780 \cs_new:Npn \__fp_parse_compare:NNNNNNN #1
17781 {
17782 \if_int_compare:w #1 < \c__fp_prec_comp_int
17783 \exp_after:wN \__fp_parse_compare_auxi:NNNNNNN
17784 \exp_after:wN \__fp_parse_excl_error:
17785 \else:
17786 \exp_after:wN @
17787 \exp_after:wN \use_none:n
17788 \exp_after:wN \__fp_parse_compare:NNNNNNN
17789 \fi:
17790 }
17791 \cs_new:Npn \__fp_parse_compare_auxi:NNNNNNN #1#2#3#4#5#6#7
17792 {
17793 \if_case:w
17794 \__fp_int_eval:w \exp_after:wN ` \token_to_str:N #7 - `<
17795 \__fp_int_eval_end:
17796 \__fp_parse_compare_auxii:NNNNN #2#2#4#5#6
17797 \or: \__fp_parse_compare_auxii:NNNNN #2#3#2#5#6
17798 \or: \__fp_parse_compare_auxii:NNNNN #2#3#4#2#6
17799 \or: \__fp_parse_compare_auxii:NNNNN #2#3#4#5#2
17800 \else: #1 \__fp_parse_compare_end:NNNNw #3#4#5#6#7
17801 \fi:
17802 }
17803 \cs_new:Npn \__fp_parse_compare_auxii:NNNNN #1#2#3#4#5
17804 {
17805 \exp_after:wN \__fp_parse_compare_auxi:NNNNNNN
17806 \exp_after:wN \prg_do_nothing:
17807 \exp_after:wN #1
17808 \exp_after:wN #2
17809 \exp_after:wN #3
17810 \exp_after:wN #4
17811 \exp_after:wN #5
17812 \exp:w \exp_after:wN \__fp_parse_expand:w
17813 }
17814 \cs_new:Npn \__fp_parse_compare_end:NNNNw #1#2#3#4#5 \fi:
17815 {
17816 \fi:
17817 \exp_after:wN @
17818 \exp_after:wN \__fp_parse_apply_compare:NwNNNNNwN
17819 \exp_after:wN \c_one_fp
17820 \exp_after:wN #1
17821 \exp_after:wN #2
17822 \exp_after:wN #3
17823 \exp_after:wN #4
17824 \exp:w
17825 \__fp_parse_operand:Nw \c__fp_prec_comp_int \__fp_parse_expand:w #5
17826 }
17827 \cs_new:Npn \__fp_parse_apply_compare:NwNNNNNwN
17828 #1 #2@ #3 #4#5#6#7 #8@ #9
17829 {
17830 \if_int_odd:w
17831 \if_meaning:w \c_zero_fp #3
17832 0
17833 \else:
17834 \if_case:w \__fp_compare_back_any:ww #8 #2 \exp_stop_f:
17835 #5 \or: #6 \or: #7 \else: #4
17836 \fi:
17837 \fi:
17838 \exp_stop_f:
17839 \exp_after:wN \__fp_parse_apply_compare_aux:NNwN
17840 \exp_after:wN \c_one_fp
17841 \else:
17842 \exp_after:wN \__fp_parse_apply_compare_aux:NNwN
17843 \exp_after:wN \c_zero_fp
17844 \fi:
17845 #1 #8 #9
17846 }
17847 \cs_new:Npn \__fp_parse_apply_compare_aux:NNwN #1 #2 #3\__fp_sep: #4
17848 {
17849 \if_meaning:w \__fp_parse_compare:NNNNNNN #4
17850 \exp_after:wN \__fp_parse_continue_compare:NNwNN
17851 \exp_after:wN #1
17852 \exp_after:wN #2
17853 \exp:w \exp_end_continue_f:w
17854 \__fp_exp_after_o:w #3\__fp_sep:
17855 \exp:w \exp_end_continue_f:w
17856 \else:
17857 \exp_after:wN \__fp_parse_continue:NwN
17858 \exp_after:wN #2
17859 \exp:w \exp_end_continue_f:w
17860 \exp_after:wN #1
17861 \exp:w \exp_end_continue_f:w
17862 \fi:
17863 #4 #2
17864 }
17865 \cs_new:Npn \__fp_parse_continue_compare:NNwNN #1#2 #3@ #4#5
17866 { #4 #2 #3@ #1 }
17867 \cs_new:Npn \__fp_parse_function_all_fp_o:fnw #1#2#3 @
17868 {
17869 \__fp_array_if_all_fp:nTF {#3}
17870 { #2 #3 @ }
17871 {
17872 \__fp_error:nffn { bad-args }
17873 {#1}
17874 { \fp_to_tl:n { \s__fp_tuple \__fp_tuple_chk:w {#3} \__fp_sep: } }
17875 { }
17876 \exp_after:wN \c_nan_fp
17877 }
17878 }
17879 \cs_new:Npn \__fp_parse_function_one_two:nnw #1#2#3
17880 {
17881 \__fp_if_type_fp:NTwFw
17882 #3 { } \s__fp \__fp_parse_function_one_two_error_o:w \s__fp_stop
17883 \__fp_parse_function_one_two_aux:nnw {#1} {#2} #3
17884 }
17885 \cs_new:Npn \__fp_parse_function_one_two_error_o:w #1#2#3#4 @
17886 {
17887 \__fp_error:nffn { bad-args }
17888 {#2}
17889 { \fp_to_tl:n { \s__fp_tuple \__fp_tuple_chk:w {#4} \__fp_sep: } }
17890 { }
17891 \exp_after:wN \c_nan_fp
17892 }
17893 \cs_new:Npn \__fp_parse_function_one_two_aux:nnw #1#2 #3\__fp_sep: #4
17894 {
17895 \__fp_if_type_fp:NTwFw
17896 #4 { }
17897 \s__fp
17898 {
17899 \if_meaning:w @ #4
17900 \exp_after:wN \use_iv:nnnn
17901 \fi:
17902 \__fp_parse_function_one_two_error_o:w
17903 }
17904 \s__fp_stop
17905 \__fp_parse_function_one_two_auxii:nnw {#1} {#2} #3\__fp_sep: #4
17906 }
17907 \cs_new:Npn \__fp_parse_function_one_two_auxii:nnw #1#2#3\__fp_sep: #4\__fp_sep: #5
17908 {
17909 \if_meaning:w @ #5 \else:
17910 \exp_after:wN \__fp_parse_function_one_two_error_o:w
17911 \fi:
17912 \use_ii:nn {#1} { \use_none:n #2 } #3\__fp_sep: #4\__fp_sep: #5
17913 }
17914 \cs_new:Npn \__fp_tuple_map_o:nw #1 \s__fp_tuple \__fp_tuple_chk:w #2 \__fp_sep:
17915 {
17916 \exp_after:wN \s__fp_tuple
17917 \exp_after:wN \__fp_tuple_chk:w
17918 \exp_after:wN {
17919 \exp:w \exp_end_continue_f:w
17920 \__fp_tuple_map_loop_o:nw {#1} #2
17921 { \s__fp \prg_break: } \__fp_sep:
17922 \prg_break_point:
17923 \exp_after:wN } \exp_after:wN \__fp_sep:
17924 }
17925 \cs_new:Npn \__fp_tuple_map_loop_o:nw #1#2#3 \__fp_sep:
17926 {
17927 \use_none:n #2
17928 #1 #2 #3 \__fp_sep:
17929 \exp:w \exp_end_continue_f:w
17930 \__fp_tuple_map_loop_o:nw {#1}
17931 }
17932 \cs_new:Npn \__fp_tuple_mapthread_o:nww #1
17933 \s__fp_tuple \__fp_tuple_chk:w #2 \__fp_sep:
17934 \s__fp_tuple \__fp_tuple_chk:w #3 \__fp_sep:
17935 {
17936 \exp_after:wN \s__fp_tuple
17937 \exp_after:wN \__fp_tuple_chk:w
17938 \exp_after:wN {
17939 \exp:w \exp_end_continue_f:w
17940 \__fp_tuple_mapthread_loop_o:nw {#1}
17941 #2 { \s__fp \prg_break: } \__fp_sep: @
17942 #3 { \s__fp \prg_break: } \__fp_sep:
17943 \prg_break_point:
17944 \exp_after:wN } \exp_after:wN \__fp_sep:
17945 }
17946 \cs_new:Npn \__fp_tuple_mapthread_loop_o:nw #1#2#3 \__fp_sep: #4 @ #5#6 \__fp_sep:
17947 {
17948 \use_none:n #2
17949 \use_none:n #5
17950 #1 #2 #3 \__fp_sep: #5 #6 \__fp_sep:
17951 \exp:w \exp_end_continue_f:w
17952 \__fp_tuple_mapthread_loop_o:nw {#1} #4 @
17953 }
17954 \msg_new:nnn { fp } { deprecated }
17955 { '#1'~deprecated;~use~'#2' }
17956 \msg_new:nnn { fp } { unknown-fp-word }
17957 { Unknown~fp~word~#1. }
17958 \msg_new:nnn { fp } { missing }
17959 { Missing~#1~inserted #2. }
17960 \msg_new:nnn { fp } { extra }
17961 { Extra~#1~ignored. }
17962 \msg_new:nnn { fp } { early-end }
17963 { Premature~end~in~fp~expression. }
17964 \msg_new:nnn { fp } { after-e }
17965 { Cannot~use~#1 after~'e'. }
17966 \msg_new:nnn { fp } { missing-number }
17967 { Missing~number~before~'#1'. }
17968 \msg_new:nnn { fp } { unknown-symbol }
17969 { Unknown~symbol~#1~ignored. }
17970 \msg_new:nnn { fp } { extra-comma }
17971 { Unexpected~comma~turned~to~nan~result. }
17972 \msg_new:nnn { fp } { no-arg }
17973 { #1~got~no~argument;~used~nan. }
17974 \msg_new:nnn { fp } { multi-arg }
17975 { #1~got~more~than~one~argument;~used~nan. }
17976 \msg_new:nnn { fp } { bad-args }
17977 { Arguments~in~#1#2~are~invalid. }
17978 \msg_new:nnn { fp } { infty-pi }
17979 { Math~command~#1 is~not~an~fp }
17980 \cs_if_exist:cT { @unexpandable@protect }
17981 {
17982 \msg_new:nnn { fp } { robust-cmd }
17983 { Robust~command~#1 invalid~in~fp~expression! }
17984 }
17985 %% File: l3fp-assign.dtx
17986 \cs_new_protected:Npn \fp_new:N #1
17987 { \cs_new_eq:NN #1 \c_zero_fp }
17988 \cs_generate_variant:Nn \fp_new:N {c}
17989 \cs_new_protected:Npn \fp_set:Nn #1#2
17990 { \__kernel_tl_set:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
17991 \cs_new_protected:Npn \fp_gset:Nn #1#2
17992 { \__kernel_tl_gset:Nx #1 { \exp_not:f { \__fp_parse:n {#2} } } }
17993 \cs_new_protected:Npn \fp_const:Nn #1#2
17994 { \tl_const:Ne #1 { \exp_not:f { \__fp_parse:n {#2} } } }
17995 \cs_generate_variant:Nn \fp_set:Nn { NV , c , cV }
17996 \cs_generate_variant:Nn \fp_gset:Nn { NV , c , cV }
17997 \cs_generate_variant:Nn \fp_const:Nn {c}
17998 \cs_new_eq:NN \fp_set_eq:NN \tl_set_eq:NN
17999 \cs_new_eq:NN \fp_gset_eq:NN \tl_gset_eq:NN
18000 \cs_generate_variant:Nn \fp_set_eq:NN { c , Nc , cc }
18001 \cs_generate_variant:Nn \fp_gset_eq:NN { c , Nc , cc }
18002 \cs_new_protected:Npn \fp_zero:N #1 { \fp_set_eq:NN #1 \c_zero_fp }
18003 \cs_new_protected:Npn \fp_gzero:N #1 { \fp_gset_eq:NN #1 \c_zero_fp }
18004 \cs_generate_variant:Nn \fp_zero:N { c }
18005 \cs_generate_variant:Nn \fp_gzero:N { c }
18006 \cs_new_protected:Npn \fp_zero_new:N #1
18007 { \fp_if_exist:NTF #1 { \fp_zero:N #1 } { \fp_new:N #1 } }
18008 \cs_new_protected:Npn \fp_gzero_new:N #1
18009 { \fp_if_exist:NTF #1 { \fp_gzero:N #1 } { \fp_new:N #1 } }
18010 \cs_generate_variant:Nn \fp_zero_new:N { c }
18011 \cs_generate_variant:Nn \fp_gzero_new:N { c }
18012 \cs_new_protected:Npn \fp_add:Nn { \__fp_add:NNNn \fp_set:Nn + }
18013 \cs_new_protected:Npn \fp_gadd:Nn { \__fp_add:NNNn \fp_gset:Nn + }
18014 \cs_new_protected:Npn \fp_sub:Nn { \__fp_add:NNNn \fp_set:Nn - }
18015 \cs_new_protected:Npn \fp_gsub:Nn { \__fp_add:NNNn \fp_gset:Nn - }
18016 \cs_new_protected:Npn \__fp_add:NNNn #1#2#3#4
18017 { #1 #3 { #3 #2 \__fp_parse:n {#4} } }
18018 \cs_generate_variant:Nn \fp_add:Nn { c }
18019 \cs_generate_variant:Nn \fp_gadd:Nn { c }
18020 \cs_generate_variant:Nn \fp_sub:Nn { c }
18021 \cs_generate_variant:Nn \fp_gsub:Nn { c }
18022 \cs_new_protected:Npn \fp_show:N { \__fp_show:NN \tl_show:n }
18023 \cs_generate_variant:Nn \fp_show:N { c }
18024 \cs_new_protected:Npn \fp_log:N { \__fp_show:NN \tl_log:n }
18025 \cs_generate_variant:Nn \fp_log:N { c }
18026 \cs_new_protected:Npn \__fp_show:NN #1#2
18027 {
18028 \__kernel_chk_tl_type:NnnT #2 { fp }
18029 { \exp_args:No \__fp_show_validate:n #2 }
18030 { \exp_args:Ne #1 { \token_to_str:N #2 = \fp_to_tl:N #2 } }
18031 }
18032 \cs_new:Npn \__fp_show_validate:n #1
18033 {
18034 \__fp_show_validate:nn { #1 }
18035 {
18036 \s__fp \__fp_chk:w ??? \__fp_sep: or \iow_newline:
18037 \s__fp_tuple \__fp_tuple_chk:w ? \__fp_sep: or \iow_newline:
18038 \s__fp_symbolic \__fp_symbolic_chk:w ? , ? \__fp_sep:
18039 }
18040 }
18041 \cs_new:Npn \__fp_show_validate_aux:n #1
18042 {
18043 \__fp_show_validate:nn { #1 } { }
18044 }
18045 \cs_new:Npn \__fp_show_validate:nn #1#2
18046 {
18047 \tl_if_empty:nF { #1 }
18048 {
18049 \str_case:enF { \tl_head:n { #1 } }
18050 {
18051 { \s__fp }
18052 {
18053 \__fp_show_validate:w #1 \s__fp
18054 \__fp_chk:w ??? \__fp_sep: \s__fp_stop
18055 }
18056 { \s__fp_tuple }
18057 {
18058 \__fp_tuple_show_validate:w #1
18059 \s__fp_tuple \__fp_tuple_chk:w ?? \__fp_sep: \s__fp_stop
18060 }
18061 { \s__fp_symbolic }
18062 {
18063 \__fp_symbolic_show_validate:w #1
18064 \s__fp_symbolic \__fp_symbolic_chk:w ? , ?? \__fp_sep: \s__fp_stop
18065 }
18066 }
18067 { #2 }
18068 }
18069 }
18070 \cs_new:Npn \__fp_show_validate:w
18071 #1 \s__fp \__fp_chk:w #2#3#4#5 \__fp_sep: #6 \s__fp_stop
18072 {
18073 \str_if_eq:nnF { #2 } {?}
18074 {
18075 \token_if_eq_meaning:NNTF #2 1
18076 { \s__fp \__fp_chk:w #2 #3 { #4 } #5 \__fp_sep: }
18077 { \s__fp \__fp_chk:w #2 #3 #4 #5 \__fp_sep: }
18078 \__fp_show_validate_aux:n { #6 }
18079 }
18080 }
18081 \cs_new:Npn \__fp_tuple_show_validate:w
18082 #1 \s__fp_tuple \__fp_tuple_chk:w #2#3 \__fp_sep: #4 \s__fp_stop
18083 {
18084 \str_if_eq:nnF { #2 } {?}
18085 {
18086 \s__fp_tuple \__fp_tuple_chk:w { \__fp_show_validate_aux:n { #2 } }
18087 \__fp_sep:
18088 }
18089 }
18090 \cs_new:Npn \__fp_symbolic_show_validate:w
18091 #1 \s__fp_symbolic \__fp_symbolic_chk:w #2 , #3#4 \__fp_sep: #5 \s__fp_stop
18092 {
18093 \str_if_eq:nnF { #2 } {?}
18094 {
18095 \s__fp_symbolic \__fp_symbolic_chk:w \exp_not:n { #2 } ,
18096 { \__fp_show_validate_aux:n { #3 } }\__fp_sep:
18097 \__fp_show_validate_aux:n { #5 }
18098 }
18099 }
18100 \cs_new_protected:Npn \fp_show:n
18101 { \__kernel_msg_show_eval:Nn \fp_to_tl:n }
18102 \cs_new_protected:Npn \fp_log:n
18103 { \__kernel_msg_log_eval:Nn \fp_to_tl:n }
18104 \fp_const:Nn \c_e_fp { 2.718 2818 2845 9045 }
18105 \fp_const:Nn \c_one_fp { 1 }
18106 \fp_const:Nn \c_pi_fp { 3.141 5926 5358 9793 }
18107 \fp_const:Nn \c_one_degree_fp { 0.0 1745 3292 5199 4330 }
18108 \fp_new:N \l_tmpa_fp
18109 \fp_new:N \l_tmpb_fp
18110 \fp_new:N \g_tmpa_fp
18111 \fp_new:N \g_tmpb_fp
18112 %% File: l3fp-logic.dtx
18113 \cs_new:Npn \__fp_parse_word_max:N
18114 { \__fp_parse_function:NNN \__fp_minmax_o:Nw 2 }
18115 \cs_new:Npn \__fp_parse_word_min:N
18116 { \__fp_parse_function:NNN \__fp_minmax_o:Nw 0 }
18117 \prg_new_eq_conditional:NNn \fp_if_exist:N \cs_if_exist:N { TF , T , F , p }
18118 \prg_new_eq_conditional:NNn \fp_if_exist:c \cs_if_exist:c { TF , T , F , p }
18119 \prg_new_conditional:Npnn \fp_if_nan:n #1 { TF , T , F , p }
18120 {
18121 \if:w 3 \exp_last_unbraced:Nf \__fp_kind:w { \__fp_parse:n {#1} }
18122 \prg_return_true:
18123 \else:
18124 \prg_return_false:
18125 \fi:
18126 }
18127 \prg_new_conditional:Npnn \fp_compare:n #1 { p , T , F , TF }
18128 {
18129 \exp_after:wN \__fp_compare_return:w
18130 \exp:w \exp_end_continue_f:w \__fp_parse:n {#1}
18131 }
18132 \cs_new:Npn \__fp_compare_return:w #1#2#3\__fp_sep:
18133 {
18134 \if_charcode:w 0
18135 \__fp_if_type_fp:NTwFw
18136 #1 { \__fp_use_i_delimit_by_s_stop:nw #3 \s__fp_stop }
18137 \s__fp 1 \s__fp_stop
18138 \prg_return_false:
18139 \else:
18140 \prg_return_true:
18141 \fi:
18142 }
18143 \prg_new_conditional:Npnn \fp_compare:nNn #1#2#3 { p , T , F , TF }
18144 {
18145 \if_int_compare:w
18146 \exp_after:wN \__fp_compare_aux:wn
18147 \exp:w \exp_end_continue_f:w \__fp_parse:n {#1} {#3}
18148 = \__fp_int_eval:w `#2 - `= \__fp_int_eval_end:
18149 \prg_return_true:
18150 \else:
18151 \prg_return_false:
18152 \fi:
18153 }
18154 \cs_new:Npn \__fp_compare_aux:wn #1\__fp_sep: #2
18155 {
18156 \exp_after:wN \__fp_compare_back_any:ww
18157 \exp:w \exp_end_continue_f:w \__fp_parse:n {#2} #1\__fp_sep:
18158 }
18159 \cs_new:Npn \__fp_compare_back:ww #1#2\__fp_sep: #3#4\__fp_sep:
18160 {
18161 \cs:w
18162 __fp
18163 \__fp_type_from_scan:N #1
18164 _bcmp
18165 \__fp_type_from_scan:N #3
18166 :ww
18167 \cs_end:
18168 #1#2\__fp_sep: #3#4\__fp_sep:
18169 }
18170 \cs_new:Npn \__fp_compare_back_any:ww #1#2\__fp_sep: #3
18171 {
18172 \__fp_if_type_fp:NTwFw
18173 #1 { \__fp_if_type_fp:NTwFw #3 \use_i:nn \s__fp \use_ii:nn \s__fp_stop }
18174 \s__fp \use_ii:nn \s__fp_stop
18175 \__fp_compare_back:ww
18176 {
18177 \cs:w
18178 __fp
18179 \__fp_type_from_scan:N #1
18180 _compare_back
18181 \__fp_type_from_scan:N #3
18182 :ww
18183 \cs_end:
18184 }
18185 #1#2 \__fp_sep: #3
18186 }
18187 \cs_new:Npn \__fp_bcmp:ww
18188 \s__fp \__fp_chk:w #1 #2 #3\__fp_sep:
18189 \s__fp \__fp_chk:w #4 #5 #6\__fp_sep:
18190 {
18191 \int_value:w
18192 \if_meaning:w 3 #1 \exp_after:wN \__fp_compare_nan:w \fi:
18193 \if_meaning:w 3 #4 \exp_after:wN \__fp_compare_nan:w \fi:
18194 \if_meaning:w 2 #5 - \fi:
18195 \if_meaning:w #2 #5
18196 \if_meaning:w #1 #4
18197 \if_meaning:w 1 #1
18198 \__fp_compare_npos:nwnw #6\__fp_sep: #3\__fp_sep:
18199 \else:
18200 0
18201 \fi:
18202 \else:
18203 \if_int_compare:w #4 < #1 - \fi: 1
18204 \fi:
18205 \else:
18206 \if_int_compare:w #1#4 = \c_zero_int
18207 0
18208 \else:
18209 1
18210 \fi:
18211 \fi:
18212 \exp_stop_f:
18213 }
18214 \cs_new:Npn \__fp_compare_nan:w #1 \fi: \exp_stop_f: { 2 \exp_stop_f: }
18215 \cs_new:Npn \__fp_compare_back_tuple:ww #1\__fp_sep: #2\__fp_sep: { 2 }
18216 \cs_new:Npn \__fp_tuple_compare_back:ww #1\__fp_sep: #2\__fp_sep: { 2 }
18217 \cs_new:Npn \__fp_tuple_compare_back_tuple:ww
18218 \s__fp_tuple \__fp_tuple_chk:w #1\__fp_sep:
18219 \s__fp_tuple \__fp_tuple_chk:w #2\__fp_sep:
18220 {
18221 \int_compare:nNnTF { \__fp_array_count:n {#1} } =
18222 { \__fp_array_count:n {#2} }
18223 {
18224 \int_value:w 0
18225 \__fp_tuple_compare_back_loop:w
18226 #1 { \s__fp \prg_break: } \__fp_sep: @
18227 #2 { \s__fp \prg_break: } \__fp_sep:
18228 \prg_break_point:
18229 \exp_stop_f:
18230 }
18231 { 2 }
18232 }
18233 \cs_new:Npn \__fp_tuple_compare_back_loop:w #1#2 \__fp_sep: #3 @ #4#5 \__fp_sep:
18234 {
18235 \use_none:n #1
18236 \use_none:n #4
18237 \if_int_compare:w
18238 \__fp_compare_back_any:ww #1 #2 \__fp_sep: #4 #5 \__fp_sep: = \c_zero_int
18239 \else:
18240 2 \exp_after:wN \prg_break:
18241 \fi:
18242 \__fp_tuple_compare_back_loop:w #3 @
18243 }
18244 \cs_new:Npn \__fp_compare_npos:nwnw #1#2\__fp_sep: #3#4\__fp_sep:
18245 {
18246 \if_int_compare:w #1 = #3 \exp_stop_f:
18247 \__fp_compare_significand:nnnnnnnn #2 #4
18248 \else:
18249 \if_int_compare:w #1 < #3 - \fi: 1
18250 \fi:
18251 }
18252 \cs_new:Npn \__fp_compare_significand:nnnnnnnn #1#2#3#4#5#6#7#8
18253 {
18254 \if_int_compare:w #1#2 = #5#6 \exp_stop_f:
18255 \if_int_compare:w #3#4 = #7#8 \exp_stop_f:
18256 0
18257 \else:
18258 \if_int_compare:w #3#4 < #7#8 - \fi: 1
18259 \fi:
18260 \else:
18261 \if_int_compare:w #1#2 < #5#6 - \fi: 1
18262 \fi:
18263 }
18264 \cs_new:Npn \fp_do_until:nn #1#2
18265 {
18266 #2
18267 \fp_compare:nF {#1}
18268 { \fp_do_until:nn {#1} {#2} }
18269 }
18270 \cs_new:Npn \fp_do_while:nn #1#2
18271 {
18272 #2
18273 \fp_compare:nT {#1}
18274 { \fp_do_while:nn {#1} {#2} }
18275 }
18276 \cs_new:Npn \fp_until_do:nn #1#2
18277 {
18278 \fp_compare:nF {#1}
18279 {
18280 #2
18281 \fp_until_do:nn {#1} {#2}
18282 }
18283 }
18284 \cs_new:Npn \fp_while_do:nn #1#2
18285 {
18286 \fp_compare:nT {#1}
18287 {
18288 #2
18289 \fp_while_do:nn {#1} {#2}
18290 }
18291 }
18292 \cs_new:Npn \fp_do_until:nNnn #1#2#3#4
18293 {
18294 #4
18295 \fp_compare:nNnF {#1} #2 {#3}
18296 { \fp_do_until:nNnn {#1} #2 {#3} {#4} }
18297 }
18298 \cs_new:Npn \fp_do_while:nNnn #1#2#3#4
18299 {
18300 #4
18301 \fp_compare:nNnT {#1} #2 {#3}
18302 { \fp_do_while:nNnn {#1} #2 {#3} {#4} }
18303 }
18304 \cs_new:Npn \fp_until_do:nNnn #1#2#3#4
18305 {
18306 \fp_compare:nNnF {#1} #2 {#3}
18307 {
18308 #4
18309 \fp_until_do:nNnn {#1} #2 {#3} {#4}
18310 }
18311 }
18312 \cs_new:Npn \fp_while_do:nNnn #1#2#3#4
18313 {
18314 \fp_compare:nNnT {#1} #2 {#3}
18315 {
18316 #4
18317 \fp_while_do:nNnn {#1} #2 {#3} {#4}
18318 }
18319 }
18320 \cs_new:Npn \fp_step_function:nnnN #1#2#3
18321 {
18322 \exp_after:wN \__fp_step:wwwN
18323 \exp:w \exp_end_continue_f:w \__fp_parse_o:n {#1}
18324 \exp:w \exp_end_continue_f:w \__fp_parse_o:n {#2}
18325 \exp:w \exp_end_continue_f:w \__fp_parse:n {#3}
18326 }
18327 \cs_generate_variant:Nn \fp_step_function:nnnN { nnnc }
18328 \cs_new:Npn \__fp_step:wwwN #1#2\__fp_sep: #3#4\__fp_sep: #5#6\__fp_sep: #7
18329 {
18330 \__fp_if_type_fp:NTwFw #1 { } \s__fp \prg_break: \s__fp_stop
18331 \__fp_if_type_fp:NTwFw #3 { } \s__fp \prg_break: \s__fp_stop
18332 \__fp_if_type_fp:NTwFw #5 { } \s__fp \prg_break: \s__fp_stop
18333 \use_i:nnnn
18334 { \__fp_step_fp:wwwN #1#2\__fp_sep: #3#4\__fp_sep: #5#6\__fp_sep: #7 }
18335 \prg_break_point:
18336 \use:n
18337 {
18338 \__fp_error:nfff { step-tuple } { \fp_to_tl:n { #1#2 \__fp_sep: } }
18339 { \fp_to_tl:n { #3#4 \__fp_sep: } } { \fp_to_tl:n { #5#6 \__fp_sep: } }
18340 }
18341 }
18342 \cs_new:Npn \__fp_step_fp:wwwN
18343 #1 \__fp_sep: \s__fp \__fp_chk:w #2#3#4 \__fp_sep: #5\__fp_sep: #6
18344 {
18345 \token_if_eq_meaning:NNTF #2 1
18346 {
18347 \token_if_eq_meaning:NNTF #3 0
18348 { \__fp_step:NnnnnN > }
18349 { \__fp_step:NnnnnN < }
18350 }
18351 {
18352 \token_if_eq_meaning:NNTF #2 0
18353 {
18354 \msg_expandable_error:nnn { kernel }
18355 { zero-step } {#6}
18356 }
18357 {
18358 \__fp_error:nnfn { bad-step } { }
18359 { \fp_to_tl:n { \s__fp \__fp_chk:w #2#3#4 \__fp_sep: } } {#6}
18360 }
18361 \use_none:nnnnn
18362 }
18363 { #1 \__fp_sep: }
18364 { \c_nan_fp }
18365 { \s__fp \__fp_chk:w #2#3#4 \__fp_sep: }
18366 { #5 \__fp_sep: }
18367 #6
18368 }
18369 \cs_new:Npn \__fp_step:NnnnnN #1#2#3#4#5#6
18370 {
18371 \fp_compare:nNnTF {#2} = {#3}
18372 {
18373 \__fp_error:nffn { tiny-step }
18374 { \fp_to_tl:n {#3} } { \fp_to_tl:n {#4} } {#6}
18375 }
18376 {
18377 \fp_compare:nNnF {#2} #1 {#5}
18378 {
18379 \exp_args:Nf #6 { \__fp_to_decimal_dispatch:w #2 }
18380 \__fp_step:NfnnnN
18381 #1 { \__fp_parse:n { #2 + #4 } } {#2} {#4} {#5} #6
18382 }
18383 }
18384 }
18385 \cs_generate_variant:Nn \__fp_step:NnnnnN { Nf }
18386 \cs_new_protected:Npn \fp_step_inline:nnnn
18387 {
18388 \int_gincr:N \g__kernel_prg_map_int
18389 \exp_args:NNc \__fp_step:NNnnnn
18390 \cs_gset_protected:Npn
18391 { __fp_map_ \int_use:N \g__kernel_prg_map_int :w }
18392 }
18393 \cs_new_protected:Npn \fp_step_variable:nnnNn #1#2#3#4#5
18394 {
18395 \int_gincr:N \g__kernel_prg_map_int
18396 \exp_args:NNc \__fp_step:NNnnnn
18397 \cs_gset_protected:Npe
18398 { __fp_map_ \int_use:N \g__kernel_prg_map_int :w }
18399 {#1} {#2} {#3}
18400 {
18401 \tl_set:Nn \exp_not:N #4 {##1}
18402 \exp_not:n {#5}
18403 }
18404 }
18405 \cs_new_protected:Npn \__fp_step:NNnnnn #1#2#3#4#5#6
18406 {
18407 #1 #2 ##1 {#6}
18408 \fp_step_function:nnnN {#3} {#4} {#5} #2
18409 \prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__kernel_prg_map_int }
18410 }
18411 \msg_new:nnn { fp } { step-tuple }
18412 { Tuple~argument~in~fp_step_...~{#1}{#2}{#3}. }
18413 \msg_new:nnn { fp } { bad-step }
18414 { Invalid~step~size~#2~for~function~#3. }
18415 \msg_new:nnn { fp } { tiny-step }
18416 { Tiny~step~size~(#1+#2=#1)~for~function~#3. }
18417 \cs_new:Npn \__fp_minmax_o:Nw #1
18418 {
18419 \__fp_parse_function_all_fp_o:fnw
18420 { \token_if_eq_meaning:NNTF 0 #1 { min } { max } }
18421 { \__fp_minmax_aux_o:Nw #1 }
18422 }
18423 \cs_new:Npn \__fp_minmax_aux_o:Nw #1#2 @
18424 {
18425 \if_meaning:w 0 #1
18426 \exp_after:wN \__fp_minmax_loop:Nww \exp_after:wN +
18427 \else:
18428 \exp_after:wN \__fp_minmax_loop:Nww \exp_after:wN -
18429 \fi:
18430 #2
18431 \s__fp \__fp_chk:w 2 #1 \s__fp_exact \__fp_sep:
18432 \s__fp \__fp_chk:w { 3 \__fp_minmax_break_o:w } \__fp_sep:
18433 }
18434 \cs_new:Npn \__fp_minmax_loop:Nww
18435 #1 \s__fp \__fp_chk:w #2#3\__fp_sep: \s__fp \__fp_chk:w #4#5\__fp_sep:
18436 {
18437 \if_meaning:w 3 #4
18438 \if_meaning:w 3 #2
18439 \__fp_minmax_auxi:ww
18440 \else:
18441 \__fp_minmax_auxii:ww
18442 \fi:
18443 \else:
18444 \if_int_compare:w
18445 \__fp_compare_back:ww
18446 \s__fp \__fp_chk:w #4#5\__fp_sep:
18447 \s__fp \__fp_chk:w #2#3\__fp_sep:
18448 = #1 1 \exp_stop_f:
18449 \__fp_minmax_auxii:ww
18450 \else:
18451 \__fp_minmax_auxi:ww
18452 \fi:
18453 \fi:
18454 \__fp_minmax_loop:Nww #1
18455 \s__fp \__fp_chk:w #2#3\__fp_sep:
18456 \s__fp \__fp_chk:w #4#5\__fp_sep:
18457 }
18458 \cs_new:Npn \__fp_minmax_auxi:ww
18459 #1 \fi: \fi: #2 \s__fp #3 \__fp_sep: \s__fp #4\__fp_sep:
18460 { \fi: \fi: #2 \s__fp #3 \__fp_sep: }
18461 \cs_new:Npn \__fp_minmax_auxii:ww #1 \fi: \fi: #2 \s__fp #3 \__fp_sep:
18462 { \fi: \fi: #2 }
18463 \cs_new:Npn \__fp_minmax_break_o:w #1 \fi: \fi: #2 \s__fp #3\__fp_sep: #4\__fp_sep:
18464 { \fi: \__fp_exp_after_o:w \s__fp #3\__fp_sep: }
18465 \cs_new:Npn \__fp_not_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
18466 {
18467 \if_meaning:w 0 #2
18468 \exp_after:wN \exp_after:wN \exp_after:wN \c_one_fp
18469 \else:
18470 \exp_after:wN \exp_after:wN \exp_after:wN \c_zero_fp
18471 \fi:
18472 }
18473 \cs_new:Npn \__fp_tuple_not_o:w #1 @ { \exp_after:wN \c_zero_fp }
18474 \group_begin:
18475 \char_set_catcode_letter:N &
18476 \char_set_catcode_letter:N |
18477 \cs_new:Npn \__fp_&_o:ww #1 \s__fp \__fp_chk:w #2#3\__fp_sep:
18478 {
18479 \if_meaning:w 0 #2 #1
18480 \__fp_and_return:wNw \s__fp \__fp_chk:w #2#3\__fp_sep:
18481 \fi:
18482 \__fp_exp_after_o:w
18483 }
18484 \cs_new:Npn \__fp_&_tuple_o:ww #1 \s__fp \__fp_chk:w #2#3\__fp_sep:
18485 {
18486 \if_meaning:w 0 #2 #1
18487 \__fp_and_return:wNw \s__fp \__fp_chk:w #2#3\__fp_sep:
18488 \fi:
18489 \__fp_exp_after_tuple_o:w
18490 }
18491 \cs_new:Npn \__fp_tuple_&_o:ww #1\__fp_sep: { \__fp_exp_after_o:w }
18492 \cs_new:Npn \__fp_tuple_&_tuple_o:ww #1\__fp_sep: { \__fp_exp_after_tuple_o:w }
18493 \cs_new:Npn \__fp_|_o:ww { \__fp_&_o:ww \else: }
18494 \cs_new:Npn \__fp_|_tuple_o:ww { \__fp_&_tuple_o:ww \else: }
18495 \cs_new:Npn \__fp_tuple_|_o:ww #1\__fp_sep: #2\__fp_sep:
18496 { \__fp_exp_after_tuple_o:w #1\__fp_sep: }
18497 \cs_new:Npn \__fp_tuple_|_tuple_o:ww #1\__fp_sep: #2\__fp_sep:
18498 { \__fp_exp_after_tuple_o:w #1\__fp_sep: }
18499 \group_end:
18500 \cs_new:Npn \__fp_and_return:wNw #1\__fp_sep: \fi: #2\__fp_sep:
18501 { \fi: \__fp_exp_after_o:w #1\__fp_sep: }
18502 \cs_new:Npn \__fp_ternary:NwwN #1 #2#3@ #4@ #5
18503 {
18504 \if_meaning:w \__fp_parse_infix_::N #5
18505 \if_charcode:w 0
18506 \__fp_if_type_fp:NTwFw
18507 #2 { \use_i:nn \__fp_use_i_delimit_by_s_stop:nw #3 \s__fp_stop }
18508 \s__fp 1 \s__fp_stop
18509 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_ternary_auxii:NwwN
18510 \else:
18511 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_ternary_auxi:NwwN
18512 \fi:
18513 \exp_after:wN #1
18514 \exp:w \exp_end_continue_f:w
18515 \__fp_exp_after_array_f:w #4 \s__fp_expr_stop
18516 \exp_after:wN @
18517 \exp:w
18518 \__fp_parse_operand:Nw \c__fp_prec_colon_int
18519 \__fp_parse_expand:w
18520 \else:
18521 \msg_expandable_error:nnnn
18522 { fp } { missing } { : } { ~for~?: }
18523 \exp_after:wN \__fp_parse_continue:NwN
18524 \exp_after:wN #1
18525 \exp:w \exp_end_continue_f:w
18526 \__fp_exp_after_array_f:w #4 \s__fp_expr_stop
18527 \exp_after:wN #5
18528 \exp_after:wN #1
18529 \fi:
18530 }
18531 \cs_new:Npn \__fp_ternary_auxi:NwwN #1#2@#3@#4
18532 {
18533 \exp_after:wN \__fp_parse_continue:NwN
18534 \exp_after:wN #1
18535 \exp:w \exp_end_continue_f:w
18536 \__fp_exp_after_array_f:w #2 \s__fp_expr_stop
18537 #4 #1
18538 }
18539 \cs_new:Npn \__fp_ternary_auxii:NwwN #1#2@#3@#4
18540 {
18541 \exp_after:wN \__fp_parse_continue:NwN
18542 \exp_after:wN #1
18543 \exp:w \exp_end_continue_f:w
18544 \__fp_exp_after_array_f:w #3 \s__fp_expr_stop
18545 #4 #1
18546 }
18547 %% File: l3fp-basics.dtx
18548 \cs_new:Npn \__fp_parse_word_abs:N
18549 { \__fp_parse_unary_function:NNN \__fp_set_sign_o:w 0 }
18550 \cs_new:Npn \__fp_parse_word_logb:N
18551 { \__fp_parse_unary_function:NNN \__fp_logb_o:w ? }
18552 \cs_new:Npn \__fp_parse_word_sign:N
18553 { \__fp_parse_unary_function:NNN \__fp_sign_o:w ? }
18554 \cs_new:Npn \__fp_parse_word_sqrt:N
18555 { \__fp_parse_unary_function:NNN \__fp_sqrt_o:w ? }
18556 \cs_new:cpe { __fp_-_o:ww } \s__fp
18557 {
18558 \exp_not:c { __fp_+_o:ww }
18559 \exp_not:n { \s__fp \__fp_neg_sign:N }
18560 }
18561 \cs_new:cpn { __fp_+_o:ww }
18562 \s__fp #1 \__fp_chk:w #2 #3 \__fp_sep: \s__fp \__fp_chk:w #4 #5
18563 {
18564 \if_case:w
18565 \if_meaning:w #2 #4
18566 #2
18567 \else:
18568 \if_int_compare:w #2 > #4 \exp_stop_f:
18569 3
18570 \else:
18571 4
18572 \fi:
18573 \fi:
18574 \exp_stop_f:
18575 \exp_after:wN \__fp_add_zeros_o:Nww \int_value:w
18576 \or: \exp_after:wN \__fp_add_normal_o:Nww \int_value:w
18577 \or: \exp_after:wN \__fp_add_inf_o:Nww \int_value:w
18578 \or: \__fp_case_return_i_o:ww
18579 \else: \exp_after:wN \__fp_add_return_ii_o:Nww \int_value:w
18580 \fi:
18581 #1 #5
18582 \s__fp \__fp_chk:w #2 #3 \__fp_sep:
18583 \s__fp \__fp_chk:w #4 #5
18584 }
18585 \cs_new:Npn \__fp_add_return_ii_o:Nww #1 #2 \__fp_sep: \s__fp \__fp_chk:w #3 #4
18586 { \__fp_exp_after_o:w \s__fp \__fp_chk:w #3 #1 }
18587 \cs_new:Npn \__fp_add_zeros_o:Nww #1 \s__fp \__fp_chk:w 0 #2
18588 {
18589 \if_int_compare:w #2 #1 = 20 \exp_stop_f:
18590 \exp_after:wN \__fp_add_return_ii_o:Nww
18591 \else:
18592 \__fp_case_return_i_o:ww
18593 \fi:
18594 #1
18595 \s__fp \__fp_chk:w 0 #2
18596 }
18597 \cs_new:Npn \__fp_add_inf_o:Nww
18598 #1 \s__fp \__fp_chk:w 2 #2 #3\__fp_sep: \s__fp \__fp_chk:w 2 #4
18599 {
18600 \if_meaning:w #1 #2
18601 \__fp_case_return_i_o:ww
18602 \else:
18603 \__fp_case_use:nw
18604 {
18605 \exp_last_unbraced:Nf \__fp_invalid_operation_o:Nww
18606 { \token_if_eq_meaning:NNTF #1 #4 + - }
18607 }
18608 \fi:
18609 \s__fp \__fp_chk:w 2 #2 #3\__fp_sep:
18610 \s__fp \__fp_chk:w 2 #4
18611 }
18612 \cs_new:Npn \__fp_add_normal_o:Nww #1 \s__fp \__fp_chk:w 1 #2
18613 {
18614 \if_meaning:w #1#2
18615 \exp_after:wN \__fp_add_npos_o:NnwNnw
18616 \else:
18617 \exp_after:wN \__fp_sub_npos_o:NnwNnw
18618 \fi:
18619 #2
18620 }
18621 \cs_new:Npn \__fp_add_npos_o:NnwNnw #1#2#3 \__fp_sep: \s__fp \__fp_chk:w 1 #4 #5
18622 {
18623 \exp_after:wN \__fp_sanitize:Nw
18624 \exp_after:wN #1
18625 \int_value:w \__fp_int_eval:w
18626 \if_int_compare:w #2 > #5 \exp_stop_f:
18627 #2
18628 \exp_after:wN \__fp_add_big_i_o:wNww \int_value:w -
18629 \else:
18630 #5
18631 \exp_after:wN \__fp_add_big_ii_o:wNww \int_value:w
18632 \fi:
18633 \__fp_int_eval:w #5 - #2 \__fp_sep: #1 #3\__fp_sep:
18634 }
18635 \cs_new:Npn \__fp_add_big_i_o:wNww #1\__fp_sep: #2 #3\__fp_sep: #4\__fp_sep:
18636 {
18637 \__fp_decimate:nNnnnn {#1}
18638 \__fp_add_significand_o:NnnwnnnnN
18639 #4
18640 #3
18641 #2
18642 }
18643 \cs_new:Npn \__fp_add_big_ii_o:wNww #1\__fp_sep: #2 #3\__fp_sep: #4\__fp_sep:
18644 {
18645 \__fp_decimate:nNnnnn {#1}
18646 \__fp_add_significand_o:NnnwnnnnN
18647 #3
18648 #4
18649 #2
18650 }
18651 \cs_new:Npn \__fp_add_significand_o:NnnwnnnnN #1 #2#3 #4\__fp_sep: #5#6#7#8
18652 {
18653 \exp_after:wN \__fp_add_significand_test_o:N
18654 \int_value:w \__fp_int_eval:w 1#5#6 + #2
18655 \exp_after:wN \__fp_add_significand_pack:NNNNNNN
18656 \int_value:w \__fp_int_eval:w 1#7#8 + #3 \__fp_sep: #1
18657 }
18658 \cs_new:Npn \__fp_add_significand_pack:NNNNNNN #1 #2#3#4#5#6#7
18659 {
18660 \if_meaning:w 2 #1
18661 + 1
18662 \fi:
18663 \__fp_sep: #2 #3 #4 #5 #6 #7 \__fp_sep:
18664 }
18665 \cs_new:Npn \__fp_add_significand_test_o:N #1
18666 {
18667 \if_meaning:w 2 #1
18668 \exp_after:wN \__fp_add_significand_carry_o:wwwNN
18669 \else:
18670 \exp_after:wN \__fp_add_significand_no_carry_o:wwwNN
18671 \fi:
18672 }
18673 \cs_new:Npn \__fp_add_significand_no_carry_o:wwwNN
18674 #1\__fp_sep: #2\__fp_sep: #3#4 \__fp_sep: #5#6
18675 {
18676 \exp_after:wN \__fp_basics_pack_high:NNNNNw
18677 \int_value:w \__fp_int_eval:w 1 #1
18678 \exp_after:wN \__fp_basics_pack_low:NNNNNw
18679 \int_value:w \__fp_int_eval:w 1 #2 #3#4
18680 + \__fp_round:NNN #6 #4 #5
18681 \exp_after:wN \__fp_sep:
18682 }
18683 \cs_new:Npn \__fp_add_significand_carry_o:wwwNN
18684 #1\__fp_sep: #2\__fp_sep: #3#4\__fp_sep: #5#6
18685 {
18686 + 1
18687 \exp_after:wN \__fp_basics_pack_weird_high:NNNNNNNNw
18688 \int_value:w \__fp_int_eval:w 1 1 #1
18689 \exp_after:wN \__fp_basics_pack_weird_low:NNNNw
18690 \int_value:w \__fp_int_eval:w 1 #2#3 +
18691 \exp_after:wN \__fp_round:NNN
18692 \exp_after:wN #6
18693 \exp_after:wN #3
18694 \int_value:w \__fp_round_digit:Nw #4 #5 \__fp_sep:
18695 \exp_after:wN \__fp_sep:
18696 }
18697 \cs_new:Npn \__fp_sub_npos_o:NnwNnw
18698 #1#2#3\__fp_sep: \s__fp \__fp_chk:w 1 #4#5#6\__fp_sep:
18699 {
18700 \if_case:w
18701 \__fp_compare_npos:nwnw {#2} #3\__fp_sep: {#5} #6\__fp_sep: \exp_stop_f:
18702 \exp_after:wN \__fp_sub_eq_o:Nnwnw
18703 \or:
18704 \exp_after:wN \__fp_sub_npos_i_o:Nnwnw
18705 \else:
18706 \exp_after:wN \__fp_sub_npos_ii_o:Nnwnw
18707 \fi:
18708 #1 {#2} #3\__fp_sep: {#5} #6\__fp_sep:
18709 }
18710 \cs_new:Npn \__fp_sub_eq_o:Nnwnw #1#2\__fp_sep: #3\__fp_sep:
18711 { \exp_after:wN \c_zero_fp }
18712 \cs_new:Npn \__fp_sub_npos_ii_o:Nnwnw #1 #2\__fp_sep: #3\__fp_sep:
18713 {
18714 \exp_after:wN \__fp_sub_npos_i_o:Nnwnw
18715 \int_value:w \__fp_neg_sign:N #1
18716 #3\__fp_sep: #2\__fp_sep:
18717 }
18718 \cs_new:Npn \__fp_sub_npos_i_o:Nnwnw #1 #2#3\__fp_sep: #4#5\__fp_sep:
18719 {
18720 \exp_after:wN \__fp_sanitize:Nw
18721 \exp_after:wN #1
18722 \int_value:w \__fp_int_eval:w
18723 #2
18724 \if_int_compare:w #2 = #4 \exp_stop_f:
18725 \exp_after:wN \__fp_sub_back_near_o:nnnnnnnnN
18726 \else:
18727 \exp_after:wN \__fp_decimate:nNnnnn \exp_after:wN
18728 { \int_value:w \__fp_int_eval:w #2 - #4 - 1 \exp_after:wN }
18729 \exp_after:wN \__fp_sub_back_far_o:NnnwnnnnN
18730 \fi:
18731 #5
18732 #3
18733 #1
18734 }
18735 \cs_new:Npn \__fp_sub_back_near_o:nnnnnnnnN #1#2#3#4 #5#6#7#8 #9
18736 {
18737 \exp_after:wN \__fp_sub_back_near_after:wNNNNw
18738 \int_value:w \__fp_int_eval:w 10#5#6 - #1#2 - 11
18739 \exp_after:wN \__fp_sub_back_near_pack:NNNNNNw
18740 \int_value:w \__fp_int_eval:w 11#7#8 - #3#4 \exp_after:wN \__fp_sep:
18741 }
18742 \cs_new:Npn \__fp_sub_back_near_pack:NNNNNNw #1#2#3#4#5#6#7 \__fp_sep:
18743 { + #1#2 \__fp_sep: {#3#4#5#6} {#7} \__fp_sep: }
18744 \cs_new:Npn \__fp_sub_back_near_after:wNNNNw 10 #1#2#3#4 #5 \__fp_sep:
18745 {
18746 \if_meaning:w 0 #1
18747 \exp_after:wN \__fp_sub_back_shift:wnnnn
18748 \fi:
18749 \__fp_sep: {#1#2#3#4} {#5}
18750 }
18751 \cs_new:Npn \__fp_sub_back_shift:wnnnn \__fp_sep: #1#2
18752 {
18753 \exp_after:wN \__fp_sub_back_shift_ii:ww
18754 \int_value:w #1 #2 0 \__fp_sep:
18755 }
18756 \cs_new:Npn \__fp_sub_back_shift_ii:ww #1 0 \__fp_sep: #2#3 \__fp_sep:
18757 {
18758 \if_meaning:w @ #1 @
18759 - 7
18760 - \exp_after:wN \use_i:nnn
18761 \exp_after:wN \__fp_sub_back_shift_iii:NNNNNNNNw
18762 \int_value:w #2#3 0 ~ 123456789\__fp_sep:
18763 \else:
18764 - \__fp_sub_back_shift_iii:NNNNNNNNw #1 123456789\__fp_sep:
18765 \fi:
18766 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
18767 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
18768 \exp_after:wN \__fp_sub_back_shift_iv:nnnnw
18769 \exp_after:wN \__fp_sep:
18770 \int_value:w
18771 #1 ~ #2#3 0 ~ 0000 0000 0000 000 \__fp_sep:
18772 }
18773 \cs_new:Npn \__fp_sub_back_shift_iii:NNNNNNNNw #1#2#3#4#5#6#7#8#9\__fp_sep: {#8}
18774 \cs_new:Npn \__fp_sub_back_shift_iv:nnnnw #1 \__fp_sep: #2 \__fp_sep:
18775 { \__fp_sep: #1 \__fp_sep: }
18776 \cs_new:Npn \__fp_sub_back_far_o:NnnwnnnnN #1 #2#3 #4\__fp_sep: #5#6#7#8
18777 {
18778 \if_case:w
18779 \if_int_compare:w 1 #2 = #5#6 \use_i:nnnn #7 \exp_stop_f:
18780 \if_int_compare:w #3 = \use_none:n #7#8 0 \exp_stop_f:
18781 0
18782 \else:
18783 \if_int_compare:w #3 > \use_none:n #7#8 0 - \fi: 1
18784 \fi:
18785 \else:
18786 \if_int_compare:w 1 #2 > #5#6 \use_i:nnnn #7 - \fi: 1
18787 \fi:
18788 \exp_stop_f:
18789 \exp_after:wN \__fp_sub_back_quite_far_o:wwNN
18790 \or: \exp_after:wN \__fp_sub_back_very_far_o:wwwwNN
18791 \else: \exp_after:wN \__fp_sub_back_not_far_o:wwwwNN
18792 \fi:
18793 #2 ~ #3 \__fp_sep: #5 #6 ~ #7 #8 \__fp_sep: #1
18794 }
18795 \cs_new:Npn \__fp_sub_back_quite_far_o:wwNN #1\__fp_sep: #2\__fp_sep: #3#4
18796 {
18797 \exp_after:wN \__fp_sub_back_quite_far_ii:NN
18798 \exp_after:wN #3
18799 \exp_after:wN #4
18800 }
18801 \cs_new:Npn \__fp_sub_back_quite_far_ii:NN #1#2
18802 {
18803 \if_case:w \__fp_round_neg:NNN #2 0 #1
18804 \exp_after:wN \use_i:nn
18805 \else:
18806 \exp_after:wN \use_ii:nn
18807 \fi:
18808 { \__fp_sep: {1000} {0000} {0000} {0000} \__fp_sep: }
18809 { - 1 \__fp_sep: {9999} {9999} {9999} {9999} \__fp_sep: }
18810 }
18811 \cs_new:Npn \__fp_sub_back_not_far_o:wwwwNN #1 ~ #2\__fp_sep: #3 ~ #4\__fp_sep: #5#6
18812 {
18813 - 1
18814 \exp_after:wN \__fp_sub_back_near_after:wNNNNw
18815 \int_value:w \__fp_int_eval:w 1#30 - #1 - 11
18816 \exp_after:wN \__fp_sub_back_near_pack:NNNNNNw
18817 \int_value:w \__fp_int_eval:w 11 0000 0000 + #40 - #2
18818 - \exp_after:wN \__fp_round_neg:NNN
18819 \exp_after:wN #6
18820 \use_none:nnnnnnn #2 #5
18821 \exp_after:wN \__fp_sep:
18822 }
18823 \cs_new:Npn \__fp_sub_back_very_far_o:wwwwNN #1#2#3#4#5#6#7
18824 {
18825 \__fp_pack_eight:wNNNNNNNN
18826 \__fp_sub_back_very_far_ii_o:nnNwwNN
18827 { 0 #1#2#3 #4#5#6#7 }
18828 \__fp_sep:
18829 }
18830 \cs_new:Npn \__fp_sub_back_very_far_ii_o:nnNwwNN
18831 #1#2 \__fp_sep: #3 \__fp_sep: #4 ~ #5\__fp_sep: #6#7
18832 {
18833 \exp_after:wN \__fp_basics_pack_high:NNNNNw
18834 \int_value:w \__fp_int_eval:w 1#4 - #1 - 1
18835 \exp_after:wN \__fp_basics_pack_low:NNNNNw
18836 \int_value:w \__fp_int_eval:w 2#5 - #2
18837 - \exp_after:wN \__fp_round_neg:NNN
18838 \exp_after:wN #7
18839 \int_value:w
18840 \if_int_odd:w \__fp_int_eval:w #5 - #2 \__fp_int_eval_end:
18841 1 \else: 2 \fi:
18842 \int_value:w \__fp_round_digit:Nw #3 #6 \__fp_sep:
18843 \exp_after:wN \__fp_sep:
18844 }
18845 \cs_new:cpn { __fp_*_o:ww }
18846 {
18847 \__fp_mul_cases_o:NnNnww
18848 *
18849 { - 2 + }
18850 \__fp_mul_npos_o:Nww
18851 { }
18852 }
18853 \cs_new:Npn \__fp_mul_cases_o:NnNnww
18854 #1#2#3#4 \s__fp \__fp_chk:w #5#6#7\__fp_sep: \s__fp \__fp_chk:w #8#9
18855 {
18856 \if_case:w \__fp_int_eval:w
18857 \if_int_compare:w #5 #8 = 11 ~
18858 1
18859 \else:
18860 \if_meaning:w 3 #8
18861 3
18862 \else:
18863 \if_meaning:w 3 #5
18864 2
18865 \else:
18866 \if_int_compare:w #5 #8 = 10 ~
18867 9 #2 - 2
18868 \else:
18869 (#5 #2 #8) / 2 * 2 + 7
18870 \fi:
18871 \fi:
18872 \fi:
18873 \fi:
18874 \if_meaning:w #6 #9 - 1 \fi:
18875 \__fp_int_eval_end:
18876 \__fp_case_use:nw { #3 0 }
18877 \or: \__fp_case_use:nw { #3 2 }
18878 \or: \__fp_case_return_i_o:ww
18879 \or: \__fp_case_return_ii_o:ww
18880 \or: \__fp_case_return_o:Nww \c_zero_fp
18881 \or: \__fp_case_return_o:Nww \c_minus_zero_fp
18882 \or: \__fp_case_use:nw { \__fp_invalid_operation_o:Nww #1 }
18883 \or: \__fp_case_use:nw { \__fp_invalid_operation_o:Nww #1 }
18884 \or: \__fp_case_return_o:Nww \c_inf_fp
18885 \or: \__fp_case_return_o:Nww \c_minus_inf_fp
18886 #4
18887 \fi:
18888 \s__fp \__fp_chk:w #5 #6 #7\__fp_sep:
18889 \s__fp \__fp_chk:w #8 #9
18890 }
18891 \cs_new:Npn \__fp_mul_npos_o:Nww
18892 #1 \s__fp \__fp_chk:w #2 #3 #4 #5 \__fp_sep:
18893 \s__fp \__fp_chk:w #6 #7 #8 #9 \__fp_sep:
18894 {
18895 \exp_after:wN \__fp_sanitize:Nw
18896 \exp_after:wN #1
18897 \int_value:w \__fp_int_eval:w
18898 #4 + #8
18899 \__fp_mul_significand_o:nnnnNnnnn #5 #1 #9
18900 }
18901 \cs_new:Npn \__fp_mul_significand_o:nnnnNnnnn #1#2#3#4 #5 #6#7#8#9
18902 {
18903 \exp_after:wN \__fp_mul_significand_test_f:NNN
18904 \exp_after:wN #5
18905 \int_value:w \__fp_int_eval:w 99990000 + #1*#6 +
18906 \exp_after:wN \__fp_mul_significand_keep:NNNNNw
18907 \int_value:w \__fp_int_eval:w 99990000 + #1*#7 + #2*#6 +
18908 \exp_after:wN \__fp_mul_significand_keep:NNNNNw
18909 \int_value:w \__fp_int_eval:w 99990000 + #1*#8 + #2*#7 + #3*#6 +
18910 \exp_after:wN \__fp_mul_significand_drop:NNNNNw
18911 \int_value:w \__fp_int_eval:w 99990000 + #1*#9 + #2*#8 +
18912 #3*#7 + #4*#6 +
18913 \exp_after:wN \__fp_mul_significand_drop:NNNNNw
18914 \int_value:w \__fp_int_eval:w 99990000 + #2*#9 + #3*#8 +
18915 #4*#7 +
18916 \exp_after:wN \__fp_mul_significand_drop:NNNNNw
18917 \int_value:w \__fp_int_eval:w 99990000 + #3*#9 + #4*#8 +
18918 \exp_after:wN \__fp_mul_significand_drop:NNNNNw
18919 \int_value:w \__fp_int_eval:w 100000000 + #4*#9 \__fp_sep:
18920 \__fp_sep: \exp_after:wN \__fp_sep:
18921 }
18922 \cs_new:Npn \__fp_mul_significand_drop:NNNNNw #1#2#3#4#5 #6\__fp_sep:
18923 { #1#2#3#4#5 \__fp_sep: + #6 }
18924 \cs_new:Npn \__fp_mul_significand_keep:NNNNNw #1#2#3#4#5 #6\__fp_sep:
18925 { #1#2#3#4#5 \__fp_sep: #6 \__fp_sep: }
18926 \cs_new:Npn \__fp_mul_significand_test_f:NNN #1 #2 #3
18927 {
18928 \if_meaning:w 0 #3
18929 \exp_after:wN \__fp_mul_significand_small_f:NNwwwN
18930 \else:
18931 \exp_after:wN \__fp_mul_significand_large_f:NwwNNNN
18932 \fi:
18933 #1 #3
18934 }
18935 \cs_new:Npn \__fp_mul_significand_large_f:NwwNNNN
18936 #1 #2\__fp_sep: #3\__fp_sep: #4#5#6#7\__fp_sep: +
18937 {
18938 \exp_after:wN \__fp_basics_pack_high:NNNNNw
18939 \int_value:w \__fp_int_eval:w 1#2
18940 \exp_after:wN \__fp_basics_pack_low:NNNNNw
18941 \int_value:w \__fp_int_eval:w 1#3#4#5#6#7
18942 + \exp_after:wN \__fp_round:NNN
18943 \exp_after:wN #1
18944 \exp_after:wN #7
18945 \int_value:w \__fp_round_digit:Nw
18946 }
18947 \cs_new:Npn \__fp_mul_significand_small_f:NNwwwN
18948 #1 #2#3\__fp_sep: #4#5\__fp_sep: #6\__fp_sep: + #7
18949 {
18950 - 1
18951 \exp_after:wN \__fp_basics_pack_high:NNNNNw
18952 \int_value:w \__fp_int_eval:w 1#3#4
18953 \exp_after:wN \__fp_basics_pack_low:NNNNNw
18954 \int_value:w \__fp_int_eval:w 1#5#6#7
18955 + \exp_after:wN \__fp_round:NNN
18956 \exp_after:wN #1
18957 \exp_after:wN #7
18958 \int_value:w \__fp_round_digit:Nw
18959 }
18960 \cs_new:cpn { __fp_/_o:ww }
18961 {
18962 \__fp_mul_cases_o:NnNnww
18963 /
18964 { - }
18965 \__fp_div_npos_o:Nww
18966 {
18967 \or:
18968 \__fp_case_use:nw
18969 { \__fp_division_by_zero_o:NNww \c_inf_fp / }
18970 \or:
18971 \__fp_case_use:nw
18972 { \__fp_division_by_zero_o:NNww \c_minus_inf_fp / }
18973 }
18974 }
18975 \cs_new:Npn \__fp_div_npos_o:Nww
18976 #1 \s__fp \__fp_chk:w 1 #2 #3 #4 \__fp_sep:
18977 \s__fp \__fp_chk:w 1 #5 #6 #7#8#9\__fp_sep:
18978 {
18979 \exp_after:wN \__fp_sanitize:Nw
18980 \exp_after:wN #1
18981 \int_value:w \__fp_int_eval:w
18982 #3 - #6
18983 \exp_after:wN \__fp_div_significand_i_o:wnnw
18984 \int_value:w \__fp_int_eval:w #7 \use_i:nnnn #8 + 1 \__fp_sep:
18985 #4
18986 {#7}{#8}#9 \__fp_sep:
18987 #1
18988 }
18989 \cs_new:Npn \__fp_div_significand_i_o:wnnw #1 \__fp_sep: #2#3 #4 \__fp_sep:
18990 {
18991 \exp_after:wN \__fp_div_significand_test_o:w
18992 \int_value:w \__fp_int_eval:w
18993 \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn
18994 \int_value:w \__fp_int_eval:w 999999 + #2 #3 0 / #1 \__fp_sep:
18995 #2 #3 \__fp_sep:
18996 #4
18997 { \exp_after:wN \__fp_div_significand_ii:wwn \int_value:w #1 }
18998 { \exp_after:wN \__fp_div_significand_ii:wwn \int_value:w #1 }
18999 { \exp_after:wN \__fp_div_significand_ii:wwn \int_value:w #1 }
19000 { \exp_after:wN \__fp_div_significand_iii:wwnnnnn \int_value:w #1 }
19001 }
19002 \cs_new:Npn \__fp_div_significand_calc:wwnnnnnnn 1#1
19003 {
19004 \if_meaning:w 1 #1
19005 \exp_after:wN \__fp_div_significand_calc_i:wwnnnnnnn
19006 \else:
19007 \exp_after:wN \__fp_div_significand_calc_ii:wwnnnnnnn
19008 \fi:
19009 }
19010 \cs_new:Npn \__fp_div_significand_calc_i:wwnnnnnnn
19011 #1\__fp_sep: #2\__fp_sep:#3#4 #5#6#7#8 #9
19012 {
19013 1 1 #1
19014 #9 \exp_after:wN \__fp_sep:
19015 \int_value:w \__fp_int_eval:w \c__fp_Bigg_leading_shift_int
19016 + #2 - #1 * #5 - #5#60
19017 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19018 \int_value:w \__fp_int_eval:w \c__fp_Bigg_middle_shift_int
19019 + #3 - #1 * #6 - #70
19020 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19021 \int_value:w \__fp_int_eval:w \c__fp_Bigg_middle_shift_int
19022 + #4 - #1 * #7 - #80
19023 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19024 \int_value:w \__fp_int_eval:w \c__fp_Bigg_trailing_shift_int
19025 - #1 * #8 \__fp_sep:
19026 {#5}{#6}{#7}{#8}
19027 }
19028 \cs_new:Npn \__fp_div_significand_calc_ii:wwnnnnnnn
19029 #1\__fp_sep: #2\__fp_sep:#3#4 #5#6#7#8 #9
19030 {
19031 1 0 #1
19032 #9 \exp_after:wN \__fp_sep:
19033 \int_value:w \__fp_int_eval:w \c__fp_Bigg_leading_shift_int
19034 + #2 - #1 * #5
19035 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19036 \int_value:w \__fp_int_eval:w \c__fp_Bigg_middle_shift_int
19037 + #3 - #1 * #6
19038 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19039 \int_value:w \__fp_int_eval:w \c__fp_Bigg_middle_shift_int
19040 + #4 - #1 * #7
19041 \exp_after:wN \__fp_pack_Bigg:NNNNNNw
19042 \int_value:w \__fp_int_eval:w \c__fp_Bigg_trailing_shift_int
19043 - #1 * #8 \__fp_sep:
19044 {#5}{#6}{#7}{#8}
19045 }
19046 \cs_new:Npn \__fp_div_significand_ii:wwn #1\__fp_sep: #2\__fp_sep:#3
19047 {
19048 \exp_after:wN \__fp_div_significand_pack:NNN
19049 \int_value:w \__fp_int_eval:w
19050 \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn
19051 \int_value:w \__fp_int_eval:w
19052 999999 + #2 #3 0 / #1 \__fp_sep: #2 #3 \__fp_sep:
19053 }
19054 \cs_new:Npn \__fp_div_significand_iii:wwnnnnn #1\__fp_sep: #2\__fp_sep:#3#4#5 #6#7
19055 {
19056 0
19057 \exp_after:wN \__fp_div_significand_iv:wwnnnnnnn
19058 \int_value:w \__fp_int_eval:w ( 2 * #2 #3) / #6 #7 \__fp_sep: % <- P
19059 #2 \__fp_sep: {#3} {#4} {#5}
19060 {#6} {#7}
19061 }
19062 \cs_new:Npn \__fp_div_significand_iv:wwnnnnnnn
19063 #1\__fp_sep: #2\__fp_sep:#3#4#5 #6#7#8#9
19064 {
19065 + 5 * #1
19066 \exp_after:wN \__fp_div_significand_vi:Nw
19067 \int_value:w \__fp_int_eval:w -50 + 2*#2#3 - #1*#6#7 +
19068 \exp_after:wN \__fp_div_significand_v:NN
19069 \int_value:w \__fp_int_eval:w 499950 + 2*#4 - #1*#8 +
19070 \exp_after:wN \__fp_div_significand_v:NN
19071 \int_value:w \__fp_int_eval:w 500000 + 2*#5 - #1*#9 \__fp_sep:
19072 }
19073 \cs_new:Npn \__fp_div_significand_v:NN #1#2 { #1#2 \__fp_int_eval_end: + }
19074 \cs_new:Npn \__fp_div_significand_vi:Nw #1#2\__fp_sep:
19075 {
19076 \if_meaning:w 0 #1
19077 \if_int_compare:w \__fp_int_eval:w #2 > 0 + 1 \fi:
19078 \else:
19079 \if_meaning:w - #1 - \else: + \fi: 1
19080 \fi:
19081 \__fp_sep:
19082 }
19083 \cs_new:Npn \__fp_div_significand_pack:NNN 1 #1 #2 { + #1 #2 \__fp_sep: }
19084 \cs_new:Npn \__fp_div_significand_test_o:w 10 #1
19085 {
19086 \if_meaning:w 0 #1
19087 \exp_after:wN \__fp_div_significand_small_o:wwwNNNNwN
19088 \else:
19089 \exp_after:wN \__fp_div_significand_large_o:wwwNNNNwN
19090 \fi:
19091 #1
19092 }
19093 \cs_new:Npn \__fp_div_significand_small_o:wwwNNNNwN
19094 0 #1\__fp_sep: #2\__fp_sep: #3\__fp_sep: #4#5#6#7#8\__fp_sep: #9
19095 {
19096 \exp_after:wN \__fp_basics_pack_high:NNNNNw
19097 \int_value:w \__fp_int_eval:w 1 #1#2
19098 \exp_after:wN \__fp_basics_pack_low:NNNNNw
19099 \int_value:w \__fp_int_eval:w 1 #3#4#5#6#7
19100 + \__fp_round:NNN #9 #7 #8
19101 \exp_after:wN \__fp_sep:
19102 }
19103 \cs_new:Npn \__fp_div_significand_large_o:wwwNNNNwN
19104 #1\__fp_sep: #2\__fp_sep: #3\__fp_sep: #4#5#6#7#8\__fp_sep: #9
19105 {
19106 + 1
19107 \exp_after:wN \__fp_basics_pack_weird_high:NNNNNNNNw
19108 \int_value:w \__fp_int_eval:w 1 #1 #2
19109 \exp_after:wN \__fp_basics_pack_weird_low:NNNNw
19110 \int_value:w \__fp_int_eval:w 1 #3 #4 #5 #6 +
19111 \exp_after:wN \__fp_round:NNN
19112 \exp_after:wN #9
19113 \exp_after:wN #6
19114 \int_value:w \__fp_round_digit:Nw #7 #8 \__fp_sep:
19115 \exp_after:wN \__fp_sep:
19116 }
19117 \cs_new:Npn \__fp_sqrt_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
19118 {
19119 \if_meaning:w 0 #2 \__fp_case_return_same_o:w \fi:
19120 \if_meaning:w 2 #3
19121 \__fp_case_use:nw { \__fp_invalid_operation_o:nw { sqrt } }
19122 \fi:
19123 \if_meaning:w 1 #2 \else: \__fp_case_return_same_o:w \fi:
19124 \__fp_sqrt_npos_o:w
19125 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
19126 }
19127 \cs_new:Npn \__fp_sqrt_npos_o:w \s__fp \__fp_chk:w 1 0 #1#2#3#4#5\__fp_sep:
19128 {
19129 \exp_after:wN \__fp_sanitize:Nw
19130 \exp_after:wN 0
19131 \int_value:w \__fp_int_eval:w
19132 \if_int_odd:w #1 \exp_stop_f:
19133 \exp_after:wN \__fp_sqrt_npos_auxi_o:wwnnN
19134 \fi:
19135 #1 / 2
19136 \__fp_sqrt_Newton_o:wwn 56234133\__fp_sep: 0\__fp_sep: {#2#3} {#4#5} 0
19137 }
19138 \cs_new:Npn \__fp_sqrt_npos_auxi_o:wwnnN #1 / 2 #2\__fp_sep: 0\__fp_sep: #3#4#5
19139 {
19140 ( #1 + 1 ) / 2
19141 \__fp_pack_eight:wNNNNNNNN
19142 \__fp_sqrt_npos_auxii_o:wNNNNNNNN
19143 \__fp_sep:
19144 0 #3 #4
19145 }
19146 \cs_new:Npn \__fp_sqrt_npos_auxii_o:wNNNNNNNN #1\__fp_sep: #2#3#4#5#6#7#8#9
19147 { \__fp_sqrt_Newton_o:wwn 17782794\__fp_sep: 0\__fp_sep: {#1} {#2#3#4#5#6#7#8#9} }
19148 \cs_new:Npn \__fp_sqrt_Newton_o:wwn #1\__fp_sep: #2\__fp_sep: #3
19149 {
19150 \if_int_compare:w #1 = #2 \exp_stop_f:
19151 \exp_after:wN \__fp_sqrt_auxi_o:NNNNwnnN
19152 \int_value:w \__fp_int_eval:w 9999 9999 +
19153 \exp_after:wN \__fp_use_none_until_s:w
19154 \fi:
19155 \exp_after:wN \__fp_sqrt_Newton_o:wwn
19156 \int_value:w \__fp_int_eval:w (#1 + #3 * 1 0000 0000 / #1) / 2 \__fp_sep:
19157 #1\__fp_sep: {#3}
19158 }
19159 \cs_new:Npn \__fp_sqrt_auxi_o:NNNNwnnN 1 #1#2#3#4#5\__fp_sep:
19160 {
19161 \__fp_sqrt_auxii_o:NnnnnnnnN
19162 \__fp_sqrt_auxiii_o:wnnnnnnnn
19163 {#1#2#3#4} {#5} {2499} {9988} {7500}
19164 }
19165 \cs_new:Npn \__fp_sqrt_auxii_o:NnnnnnnnN #1 #2#3#4#5#6 #7#8#9
19166 {
19167 \exp_after:wN #1
19168 \int_value:w \__fp_int_eval:w \c__fp_big_leading_shift_int
19169 + #7 - #2 * #2
19170 \exp_after:wN \__fp_pack_big:NNNNNNw
19171 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19172 - 2 * #2 * #3
19173 \exp_after:wN \__fp_pack_big:NNNNNNw
19174 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19175 + #8 - #3 * #3 - 2 * #2 * #4
19176 \exp_after:wN \__fp_pack_big:NNNNNNw
19177 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19178 - 2 * #3 * #4 - 2 * #2 * #5
19179 \exp_after:wN \__fp_pack_big:NNNNNNw
19180 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19181 + #9 000 0000 - #4 * #4 - 2 * #3 * #5 - 2 * #2 * #6
19182 \exp_after:wN \__fp_pack_big:NNNNNNw
19183 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19184 - 2 * #4 * #5 - 2 * #3 * #6
19185 \exp_after:wN \__fp_pack_big:NNNNNNw
19186 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19187 - #5 * #5 - 2 * #4 * #6
19188 \exp_after:wN \__fp_pack_big:NNNNNNw
19189 \int_value:w \__fp_int_eval:w
19190 \c__fp_big_middle_shift_int
19191 - 2 * #5 * #6
19192 \exp_after:wN \__fp_pack_big:NNNNNNw
19193 \int_value:w \__fp_int_eval:w
19194 \c__fp_big_trailing_shift_int
19195 - #6 * #6 \__fp_sep:
19196 % (
19197 - 257 ) * 5000 0000 / (#2#3 + 1) + 10 0000 0000 \__fp_sep:
19198 {#2}{#3}{#4}{#5}{#6} {#7}{#8}#9
19199 }
19200 \cs_new:Npn \__fp_sqrt_auxiii_o:wnnnnnnnn
19201 #1\__fp_sep: #2#3#4#5#6#7#8#9
19202 {
19203 \if_int_compare:w #1 > \c_one_int
19204 \exp_after:wN \__fp_sqrt_auxiv_o:NNNNNw
19205 \int_value:w \__fp_int_eval:w (#1#2 %)
19206 \else:
19207 \if_int_compare:w #1#2 > \c_one_int
19208 \exp_after:wN \__fp_sqrt_auxv_o:NNNNNw
19209 \int_value:w \__fp_int_eval:w (#1#2#3 %)
19210 \else:
19211 \if_int_compare:w #1#2#3 > \c_one_int
19212 \exp_after:wN \__fp_sqrt_auxvi_o:NNNNNw
19213 \int_value:w \__fp_int_eval:w (#1#2#3#4 %)
19214 \else:
19215 \exp_after:wN \__fp_sqrt_auxvii_o:NNNNNw
19216 \int_value:w \__fp_int_eval:w (#1#2#3#4#5 %)
19217 \fi:
19218 \fi:
19219 \fi:
19220 }
19221 \cs_new:Npn \__fp_sqrt_auxiv_o:NNNNNw 1#1#2#3#4#5#6\__fp_sep:
19222 { \__fp_sqrt_auxviii_o:nnnnnnn {#1#2#3#4#5#6} {00000000} }
19223 \cs_new:Npn \__fp_sqrt_auxv_o:NNNNNw 1#1#2#3#4#5#6\__fp_sep:
19224 { \__fp_sqrt_auxviii_o:nnnnnnn {000#1#2#3#4#5} {#60000} }
19225 \cs_new:Npn \__fp_sqrt_auxvi_o:NNNNNw 1#1#2#3#4#5#6\__fp_sep:
19226 { \__fp_sqrt_auxviii_o:nnnnnnn {0000000#1} {#2#3#4#5#6} }
19227 \cs_new:Npn \__fp_sqrt_auxvii_o:NNNNNw 1#1#2#3#4#5#6\__fp_sep:
19228 {
19229 \if_int_compare:w #1#2 = \c_zero_int
19230 \exp_after:wN \__fp_sqrt_auxx_o:Nnnnnnnn
19231 \fi:
19232 \__fp_sqrt_auxviii_o:nnnnnnn {00000000} {000#1#2#3#4#5}
19233 }
19234 \cs_new:Npn \__fp_sqrt_auxviii_o:nnnnnnn #1#2 #3#4#5#6#7
19235 {
19236 \exp_after:wN \__fp_sqrt_auxix_o:wnwnw
19237 \int_value:w \__fp_int_eval:w #3
19238 \exp_after:wN \__fp_basics_pack_low:NNNNNw
19239 \int_value:w \__fp_int_eval:w #1 + 1#4#5
19240 \exp_after:wN \__fp_basics_pack_low:NNNNNw
19241 \int_value:w \__fp_int_eval:w #2 + 1#6#7 \__fp_sep:
19242 }
19243 \cs_new:Npn \__fp_sqrt_auxix_o:wnwnw #1\__fp_sep: #2#3\__fp_sep: #4#5\__fp_sep:
19244 {
19245 \__fp_sqrt_auxii_o:NnnnnnnnN
19246 \__fp_sqrt_auxiii_o:wnnnnnnnn {#1}{#2}{#3}{#4}{#5}
19247 }
19248 \cs_new:Npn \__fp_sqrt_auxx_o:Nnnnnnnn #1#2#3 #4#5#6#7#8
19249 {
19250 \exp_after:wN \__fp_sqrt_auxxi_o:wwnnN
19251 \int_value:w \__fp_int_eval:w
19252 (#8 + 2499) / 5000 * 5000 \__fp_sep:
19253 {#4} {#5} {#6} {#7} \__fp_sep:
19254 }
19255 \cs_new:Npn \__fp_sqrt_auxxi_o:wwnnN #1\__fp_sep: #2\__fp_sep: #3#4#5
19256 {
19257 \__fp_sqrt_auxii_o:NnnnnnnnN
19258 \__fp_sqrt_auxxii_o:nnnnnnnnw
19259 #2 {#1}
19260 {#3} { #4 + 1 } #5
19261 }
19262 \cs_new:Npn \__fp_sqrt_auxxii_o:nnnnnnnnw 0\__fp_sep: #1#2#3#4#5#6#7#8 #9\__fp_sep:
19263 {
19264 \if_int_compare:w #1#2 > \c_zero_int
19265 \if_int_compare:w #1#2 = \c_one_int
19266 \if_int_compare:w #3#4 = \c_zero_int
19267 \if_int_compare:w #5#6 = \c_zero_int
19268 \if_int_compare:w #7#8 = \c_zero_int
19269 \__fp_sqrt_auxxiii_o:w
19270 \fi:
19271 \fi:
19272 \fi:
19273 \fi:
19274 \exp_after:wN \__fp_sqrt_auxxiv_o:wnnnnnnnN
19275 \int_value:w 9998
19276 \else:
19277 \exp_after:wN \__fp_sqrt_auxxiv_o:wnnnnnnnN
19278 \int_value:w 10000
19279 \fi:
19280 \__fp_sep:
19281 }
19282 \cs_new:Npn \__fp_sqrt_auxxiii_o:w \fi: \fi: \fi: \fi: #1 \fi: \__fp_sep:
19283 {
19284 \fi: \fi: \fi: \fi: \fi:
19285 \__fp_sqrt_auxxiv_o:wnnnnnnnN 9999 \__fp_sep:
19286 }
19287 \cs_new:Npn \__fp_sqrt_auxxiv_o:wnnnnnnnN #1\__fp_sep: #2#3#4#5#6 #7#8#9
19288 {
19289 \exp_after:wN \__fp_basics_pack_high:NNNNNw
19290 \int_value:w \__fp_int_eval:w 1 0000 0000 + #2#3
19291 \exp_after:wN \__fp_basics_pack_low:NNNNNw
19292 \int_value:w \__fp_int_eval:w 1 0000 0000
19293 + #4#5
19294 \if_int_compare:w #6 > #1 \exp_stop_f: + 1 \fi:
19295 + \exp_after:wN \__fp_round:NNN
19296 \exp_after:wN 0
19297 \exp_after:wN 0
19298 \int_value:w
19299 \exp_after:wN \use_i:nn
19300 \exp_after:wN \__fp_round_digit:Nw
19301 \int_value:w \__fp_int_eval:w #6 + 19999 - #1 \__fp_sep:
19302 \exp_after:wN \__fp_sep:
19303 }
19304 \cs_new:Npn \__fp_logb_o:w ? \s__fp \__fp_chk:w #1#2\__fp_sep: @
19305 {
19306 \if_case:w #1 \exp_stop_f:
19307 \__fp_case_use:nw
19308 { \__fp_division_by_zero_o:Nnw \c_minus_inf_fp { logb } }
19309 \or: \exp_after:wN \__fp_logb_aux_o:w
19310 \or: \__fp_case_return_o:Nw \c_inf_fp
19311 \else: \__fp_case_return_same_o:w
19312 \fi:
19313 \s__fp \__fp_chk:w #1 #2\__fp_sep:
19314 }
19315 \cs_new:Npn \__fp_logb_aux_o:w \s__fp \__fp_chk:w #1 #2 #3 #4 \__fp_sep:
19316 {
19317 \exp_after:wN \__fp_parse:n \exp_after:wN
19318 { \int_value:w \int_eval:w #3 - 1 \exp_after:wN }
19319 }
19320 \cs_new:Npn \__fp_sign_o:w ? \s__fp \__fp_chk:w #1#2\__fp_sep: @
19321 {
19322 \if_case:w #1 \exp_stop_f:
19323 \__fp_case_return_same_o:w
19324 \or: \exp_after:wN \__fp_sign_aux_o:w
19325 \or: \exp_after:wN \__fp_sign_aux_o:w
19326 \else: \__fp_case_return_same_o:w
19327 \fi:
19328 \s__fp \__fp_chk:w #1 #2\__fp_sep:
19329 }
19330 \cs_new:Npn \__fp_sign_aux_o:w \s__fp \__fp_chk:w #1 #2 #3 \__fp_sep:
19331 { \exp_after:wN \__fp_set_sign_o:w \exp_after:wN #2 \c_one_fp @ }
19332 \cs_new:Npn \__fp_set_sign_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
19333 {
19334 \exp_after:wN \__fp_exp_after_o:w
19335 \exp_after:wN \s__fp
19336 \exp_after:wN \__fp_chk:w
19337 \exp_after:wN #2
19338 \int_value:w
19339 \if_case:w #3 \exp_stop_f: #1 \or: 1 \or: 0 \fi: \exp_stop_f:
19340 #4\__fp_sep:
19341 }
19342 \cs_new:Npn \__fp_tuple_set_sign_o:w #1#2 @
19343 {
19344 \if_meaning:w 2 #1
19345 \exp_after:wN \__fp_tuple_set_sign_aux_o:Nnw
19346 \fi:
19347 \__fp_invalid_operation_o:nw { abs }
19348 #2
19349 }
19350 \cs_new:Npn \__fp_tuple_set_sign_aux_o:Nnw #1#2
19351 { \__fp_tuple_map_o:nw \__fp_tuple_set_sign_aux_o:w }
19352 \cs_new:Npn \__fp_tuple_set_sign_aux_o:w #1#2 \__fp_sep:
19353 {
19354 \__fp_change_func_type:NNN #1 \__fp_set_sign_o:w
19355 \__fp_parse_apply_unary_error:NNw
19356 2 #1 #2 \__fp_sep: @
19357 }
19358 \cs_new:cpn { __fp_*_tuple_o:ww } #1 \__fp_sep:
19359 { \__fp_tuple_map_o:nw { \__fp_binary_type_o:Nww * #1 \__fp_sep: } }
19360 \cs_new:cpn { __fp_tuple_*_o:ww } #1 \__fp_sep: #2 \__fp_sep:
19361 {
19362 \__fp_tuple_map_o:nw { \__fp_binary_rev_type_o:Nww * #2 \__fp_sep: }
19363 #1 \__fp_sep:
19364 }
19365 \cs_new:cpn { __fp_tuple_/_o:ww } #1 \__fp_sep: #2 \__fp_sep:
19366 {
19367 \__fp_tuple_map_o:nw { \__fp_binary_rev_type_o:Nww / #2 \__fp_sep: }
19368 #1 \__fp_sep:
19369 }
19370 \cs_set_protected:Npn \__fp_tmp:w #1
19371 {
19372 \cs_new:cpn { __fp_tuple_#1_tuple_o:ww }
19373 \s__fp_tuple \__fp_tuple_chk:w ##1 \__fp_sep:
19374 \s__fp_tuple \__fp_tuple_chk:w ##2 \__fp_sep:
19375 {
19376 \int_compare:nNnTF
19377 { \__fp_array_count:n {##1} } = { \__fp_array_count:n {##2} }
19378 { \__fp_tuple_mapthread_o:nww { \__fp_binary_type_o:Nww #1 } }
19379 { \__fp_invalid_operation_o:nww #1 }
19380 \s__fp_tuple \__fp_tuple_chk:w {##1} \__fp_sep:
19381 \s__fp_tuple \__fp_tuple_chk:w {##2} \__fp_sep:
19382 }
19383 }
19384 \__fp_tmp:w +
19385 \__fp_tmp:w -
19386 %% File: l3fp-extended.dtx
19387 \tl_const:Nn \c__fp_one_fixed_tl
19388 { {10000} {0000} {0000} {0000} {0000} {0000} \__fp_sep: }
19389 \cs_new:Npn \__fp_fixed_continue:wn #1\__fp_sep: #2 { #2 #1\__fp_sep: }
19390 \cs_new:Npn \__fp_fixed_add_one:wN #1#2\__fp_sep: #3
19391 {
19392 \exp_after:wN #3 \exp_after:wN
19393 { \int_value:w \__fp_int_eval:w \c__fp_myriad_int + #1 } #2 \__fp_sep:
19394 }
19395 \cs_new:Npn \__fp_fixed_div_myriad:wn #1#2#3#4#5#6\__fp_sep:
19396 {
19397 \exp_after:wN \__fp_fixed_mul_after:wwn
19398 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
19399 \exp_after:wN \__fp_pack:NNNNNw
19400 \int_value:w \__fp_int_eval:w \c__fp_trailing_shift_int
19401 + #1 \__fp_sep: {#2}{#3}{#4}{#5}\__fp_sep:
19402 }
19403 \cs_new:Npn \__fp_fixed_mul_after:wwn #1\__fp_sep: #2\__fp_sep: #3
19404 { #3 {#1} #2\__fp_sep: }
19405 \cs_new:Npn \__fp_fixed_mul_short:wwn #1#2#3#4#5#6\__fp_sep: #7#8#9\__fp_sep:
19406 {
19407 \exp_after:wN \__fp_fixed_mul_after:wwn
19408 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
19409 + #1*#7
19410 \exp_after:wN \__fp_pack:NNNNNw
19411 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19412 + #1*#8 + #2*#7
19413 \exp_after:wN \__fp_pack:NNNNNw
19414 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19415 + #1*#9 + #2*#8 + #3*#7
19416 \exp_after:wN \__fp_pack:NNNNNw
19417 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19418 + #2*#9 + #3*#8 + #4*#7
19419 \exp_after:wN \__fp_pack:NNNNNw
19420 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19421 + #3*#9 + #4*#8 + #5*#7
19422 \exp_after:wN \__fp_pack:NNNNNw
19423 \int_value:w \__fp_int_eval:w \c__fp_trailing_shift_int
19424 + #4*#9 + #5*#8 + #6*#7
19425 + ( #5*#9 + #6*#8 + #6*#9 / \c__fp_myriad_int )
19426 / \c__fp_myriad_int \__fp_sep: \__fp_sep:
19427 }
19428 \cs_new:Npn \__fp_fixed_div_int:wwN #1#2#3#4#5#6 \__fp_sep: #7 \__fp_sep: #8
19429 {
19430 \exp_after:wN \__fp_fixed_div_int_after:Nw
19431 \exp_after:wN #8
19432 \int_value:w \__fp_int_eval:w - 1
19433 \__fp_fixed_div_int:wnN
19434 #1\__fp_sep: {#7} \__fp_fixed_div_int_auxi:wnn
19435 #2\__fp_sep: {#7} \__fp_fixed_div_int_auxi:wnn
19436 #3\__fp_sep: {#7} \__fp_fixed_div_int_auxi:wnn
19437 #4\__fp_sep: {#7} \__fp_fixed_div_int_auxi:wnn
19438 #5\__fp_sep: {#7} \__fp_fixed_div_int_auxi:wnn
19439 #6\__fp_sep: {#7} \__fp_fixed_div_int_auxii:wnn \__fp_sep:
19440 }
19441 \cs_new:Npn \__fp_fixed_div_int:wnN #1\__fp_sep: #2 #3
19442 {
19443 \exp_after:wN #3
19444 \int_value:w \__fp_int_eval:w #1 / #2 - 1 \__fp_sep:
19445 {#2}
19446 {#1}
19447 }
19448 \cs_new:Npn \__fp_fixed_div_int_auxi:wnn #1\__fp_sep: #2 #3
19449 {
19450 + #1
19451 \exp_after:wN \__fp_fixed_div_int_pack:Nw
19452 \int_value:w \__fp_int_eval:w 9999
19453 \exp_after:wN \__fp_fixed_div_int:wnN
19454 \int_value:w \__fp_int_eval:w #3 - #1*#2 \__fp_int_eval_end:
19455 }
19456 \cs_new:Npn \__fp_fixed_div_int_auxii:wnn #1\__fp_sep: #2 #3 { + #1 + 2 \__fp_sep: }
19457 \cs_new:Npn \__fp_fixed_div_int_pack:Nw #1 #2\__fp_sep: { + #1\__fp_sep: {#2} }
19458 \cs_new:Npn \__fp_fixed_div_int_after:Nw #1 #2\__fp_sep: { #1 {#2} }
19459 \cs_new:Npn \__fp_fixed_add:wwn { \__fp_fixed_add:Nnnnnwnn + }
19460 \cs_new:Npn \__fp_fixed_sub:wwn { \__fp_fixed_add:Nnnnnwnn - }
19461 \cs_new:Npn \__fp_fixed_add:Nnnnnwnn #1 #2#3#4#5 #6\__fp_sep: #7#8
19462 {
19463 \exp_after:wN \__fp_fixed_add_after:NNNNNwn
19464 \int_value:w \__fp_int_eval:w 9 9999 9998 + #2#3 #1 #7#8
19465 \exp_after:wN \__fp_fixed_add_pack:NNNNNwn
19466 \int_value:w \__fp_int_eval:w 1 9999 9998 + #4#5
19467 \__fp_fixed_add:nnNnnnwn #6 #1
19468 }
19469 \cs_new:Npn \__fp_fixed_add:nnNnnnwn #1#2 #3 #4#5 #6#7 \__fp_sep: #8
19470 {
19471 #3 #4#5
19472 \exp_after:wN \__fp_fixed_add_pack:NNNNNwn
19473 \int_value:w \__fp_int_eval:w
19474 2 0000 0000 #3 #6#7 + #1#2 \__fp_sep: {#8} \__fp_sep:
19475 }
19476 \cs_new:Npn \__fp_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6\__fp_sep: #7
19477 { + #1 \__fp_sep: {#7} {#2#3#4#5} {#6} }
19478 \cs_new:Npn \__fp_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6\__fp_sep: #7
19479 { #7 {#1#2#3#4#5} {#6} }
19480 \cs_new:Npn \__fp_fixed_mul:wwn #1#2#3#4 #5\__fp_sep: #6#7#8#9
19481 {
19482 \exp_after:wN \__fp_fixed_mul_after:wwn
19483 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
19484 \exp_after:wN \__fp_pack:NNNNNw
19485 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19486 + #1*#6
19487 \exp_after:wN \__fp_pack:NNNNNw
19488 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19489 + #1*#7 + #2*#6
19490 \exp_after:wN \__fp_pack:NNNNNw
19491 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19492 + #1*#8 + #2*#7 + #3*#6
19493 \exp_after:wN \__fp_pack:NNNNNw
19494 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
19495 + #1*#9 + #2*#8 + #3*#7 + #4*#6
19496 \exp_after:wN \__fp_pack:NNNNNw
19497 \int_value:w \__fp_int_eval:w \c__fp_trailing_shift_int
19498 + #2*#9 + #3*#8 + #4*#7
19499 + ( #3*#9 + #4*#8
19500 + \__fp_fixed_mul:nnnnnnnw #5 {#6}{#7} {#1}{#2}
19501 }
19502 \cs_new:Npn \__fp_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 \__fp_sep:
19503 {
19504 #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c__fp_myriad_int
19505 + #1*#3 + #5*#7 \__fp_sep: \__fp_sep:
19506 }
19507 \cs_new:Npn \__fp_fixed_mul_add:wwwn #1\__fp_sep: #2\__fp_sep: #3#4#5#6#7#8\__fp_sep:
19508 {
19509 \exp_after:wN \__fp_fixed_mul_after:wwn
19510 \int_value:w \__fp_int_eval:w \c__fp_big_leading_shift_int
19511 \exp_after:wN \__fp_pack_big:NNNNNNw
19512 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int + #3 #4
19513 \__fp_fixed_mul_add:Nwnnnwnnn +
19514 + #5 #6 \__fp_sep: #2 \__fp_sep: #1 \__fp_sep: #2 \__fp_sep: +
19515 + #7 #8 \__fp_sep: \__fp_sep:
19516 }
19517 \cs_new:Npn \__fp_fixed_mul_sub_back:wwwn
19518 #1\__fp_sep: #2\__fp_sep: #3#4#5#6#7#8\__fp_sep:
19519 {
19520 \exp_after:wN \__fp_fixed_mul_after:wwn
19521 \int_value:w \__fp_int_eval:w \c__fp_big_leading_shift_int
19522 \exp_after:wN \__fp_pack_big:NNNNNNw
19523 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int + #3 #4
19524 \__fp_fixed_mul_add:Nwnnnwnnn -
19525 + #5 #6 \__fp_sep: #2 \__fp_sep: #1 \__fp_sep: #2 \__fp_sep: -
19526 + #7 #8 \__fp_sep: \__fp_sep:
19527 }
19528 \cs_new:Npn \__fp_fixed_one_minus_mul:wwn #1\__fp_sep: #2\__fp_sep:
19529 {
19530 \exp_after:wN \__fp_fixed_mul_after:wwn
19531 \int_value:w \__fp_int_eval:w \c__fp_big_leading_shift_int
19532 \exp_after:wN \__fp_pack_big:NNNNNNw
19533 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int +
19534 1 0000 0000
19535 \__fp_fixed_mul_add:Nwnnnwnnn -
19536 \__fp_sep: #2 \__fp_sep: #1 \__fp_sep: #2 \__fp_sep: -
19537 \__fp_sep: \__fp_sep:
19538 }
19539 \cs_new:Npn \__fp_fixed_mul_add:Nwnnnwnnn #1 #2\__fp_sep: #3#4#5#6\__fp_sep: #7#8#9
19540 {
19541 #1 #7*#3
19542 \exp_after:wN \__fp_pack_big:NNNNNNw
19543 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19544 #1 #7*#4 #1 #8*#3
19545 \exp_after:wN \__fp_pack_big:NNNNNNw
19546 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19547 #1 #7*#5 #1 #8*#4 #1 #9*#3 #2
19548 \exp_after:wN \__fp_pack_big:NNNNNNw
19549 \int_value:w \__fp_int_eval:w \c__fp_big_middle_shift_int
19550 #1 \__fp_fixed_mul_add:nnnnwnnnn {#7}{#8}{#9}
19551 }
19552 \cs_new:Npn \__fp_fixed_mul_add:nnnnwnnnn #1#2#3#4#5\__fp_sep: #6#7#8#9
19553 {
19554 ( #1*#9 + #2*#8 + #3*#7 + #4*#6 )
19555 \exp_after:wN \__fp_pack_big:NNNNNNw
19556 \int_value:w \__fp_int_eval:w \c__fp_big_trailing_shift_int
19557 \__fp_fixed_mul_add:nnnnwnnwN
19558 { #6 + #4*#7 + #3*#8 + #2*#9 + #1 }
19559 { #7 + #4*#8 + #3*#9 + #2 }
19560 {#1} #5\__fp_sep:
19561 {#6}
19562 }
19563 \cs_new:Npn \__fp_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5\__fp_sep: #6#7#8\__fp_sep: #9
19564 {
19565 #9 (#4* #1 *#7)
19566 #9 (#5*#6+#4* #2 *#7+#3*#8) / \c__fp_myriad_int
19567 }
19568 \cs_new:Npn \__fp_ep_to_fixed:wwn #1,#2
19569 {
19570 \exp_after:wN \__fp_ep_to_fixed_auxi:www
19571 \int_value:w \__fp_int_eval:w 1 0000 0000 + #2 \exp_after:wN \__fp_sep:
19572 \exp:w \exp_end_continue_f:w
19573 \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } \__fp_sep:
19574 }
19575 \cs_new:Npn \__fp_ep_to_fixed_auxi:www
19576 1#1\__fp_sep: #2\__fp_sep: #3#4#5#6#7\__fp_sep:
19577 {
19578 \__fp_pack_eight:wNNNNNNNN
19579 \__fp_pack_twice_four:wNNNNNNNN
19580 \__fp_pack_twice_four:wNNNNNNNN
19581 \__fp_pack_twice_four:wNNNNNNNN
19582 \__fp_ep_to_fixed_auxii:nnnnnnnwn \__fp_sep:
19583 #2 #1#3#4#5#6#7 0000 !
19584 }
19585 \cs_new:Npn \__fp_ep_to_fixed_auxii:nnnnnnnwn #1#2#3#4#5#6#7\__fp_sep: #8! #9
19586 { #9 {#1#2}{#3}{#4}{#5}{#6}{#7}\__fp_sep: }
19587 \cs_new:Npn \__fp_ep_to_ep:wwN #1,#2#3#4#5#6#7\__fp_sep: #8
19588 {
19589 \exp_after:wN #8
19590 \int_value:w \__fp_int_eval:w #1 + 4
19591 \exp_after:wN \use_i:nn
19592 \exp_after:wN \__fp_ep_to_ep_loop:N
19593 \int_value:w \__fp_int_eval:w 1 0000 0000 + #2 \__fp_int_eval_end:
19594 #3#4#5#6#7 \__fp_sep: \__fp_sep: !
19595 }
19596 \cs_new:Npn \__fp_ep_to_ep_loop:N #1
19597 {
19598 \if_meaning:w 0 #1
19599 - 1
19600 \else:
19601 \__fp_ep_to_ep_end:www #1
19602 \fi:
19603 \__fp_ep_to_ep_loop:N
19604 }
19605 \cs_new:Npn \__fp_ep_to_ep_end:www
19606 #1 \fi: \__fp_ep_to_ep_loop:N #2\__fp_sep: #3!
19607 {
19608 \fi:
19609 \if_meaning:w \__fp_sep: #1
19610 - 2 * \c__fp_max_exponent_int
19611 \__fp_ep_to_ep_zero:ww
19612 \fi:
19613 \__fp_pack_twice_four:wNNNNNNNN
19614 \__fp_pack_twice_four:wNNNNNNNN
19615 \__fp_pack_twice_four:wNNNNNNNN
19616 \__fp_use_i:ww , \__fp_sep:
19617 #1 #2 0000 0000 0000 0000 0000 0000 \__fp_sep:
19618 }
19619 \cs_new:Npn \__fp_ep_to_ep_zero:ww \fi: #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
19620 { \fi: , {1000}{0000}{0000}{0000}{0000}{0000} \__fp_sep: }
19621 \cs_new:Npn \__fp_ep_compare:wwww #1,#2#3#4#5#6#7\__fp_sep:
19622 { \__fp_ep_compare_aux:wwww {#1}{#2}{#3}{#4}{#5}\__fp_sep: #6#7\__fp_sep: }
19623 \cs_new:Npn \__fp_ep_compare_aux:wwww
19624 #1\__fp_sep:#2\__fp_sep:#3,#4#5#6#7#8#9\__fp_sep:
19625 {
19626 \if_case:w
19627 \__fp_compare_npos:nwnw
19628 #1\__fp_sep: {#3}{#4}{#5}{#6}{#7}\__fp_sep: \exp_stop_f:
19629 \if_int_compare:w #2 = #8#9 \exp_stop_f:
19630 0
19631 \else:
19632 \if_int_compare:w #2 < #8#9 - \fi: 1
19633 \fi:
19634 \or: 1
19635 \else: -1
19636 \fi:
19637 }
19638 \cs_new:Npn \__fp_ep_mul:wwwwn #1,#2\__fp_sep: #3,#4\__fp_sep:
19639 {
19640 \__fp_ep_to_ep:wwN #3,#4\__fp_sep:
19641 \__fp_fixed_continue:wn
19642 {
19643 \__fp_ep_to_ep:wwN #1,#2\__fp_sep:
19644 \__fp_ep_mul_raw:wwwwN
19645 }
19646 \__fp_fixed_continue:wn
19647 }
19648 \cs_new:Npn \__fp_ep_mul_raw:wwwwN #1,#2\__fp_sep: #3,#4\__fp_sep: #5
19649 {
19650 \__fp_fixed_mul:wwn #2\__fp_sep: #4\__fp_sep:
19651 { \exp_after:wN #5 \int_value:w \__fp_int_eval:w #1 + #3 , }
19652 }
19653 \cs_new:Npn \__fp_ep_div:wwwwn #1,#2\__fp_sep: #3,#4\__fp_sep:
19654 {
19655 \__fp_ep_to_ep:wwN #1,#2\__fp_sep:
19656 \__fp_fixed_continue:wn
19657 {
19658 \__fp_ep_to_ep:wwN #3,#4\__fp_sep:
19659 \__fp_ep_div_esti:wwwwn
19660 }
19661 }
19662 \cs_new:Npn \__fp_ep_div_esti:wwwwn #1,#2#3\__fp_sep: #4,
19663 {
19664 \exp_after:wN \__fp_ep_div_estii:wwnnwwn
19665 \int_value:w \__fp_int_eval:w 10 0000 0000 / ( #2 + 1 )
19666 \exp_after:wN \__fp_sep:
19667 \int_value:w \__fp_int_eval:w #4 - #1 + 1 ,
19668 {#2} #3\__fp_sep:
19669 }
19670 \cs_new:Npn \__fp_ep_div_estii:wwnnwwn
19671 #1\__fp_sep: #2,#3#4#5\__fp_sep: #6\__fp_sep: #7
19672 {
19673 \exp_after:wN \__fp_ep_div_estiii:NNNNNwwwn
19674 \int_value:w \__fp_int_eval:w 10 0000 0000 - 1750
19675 + #1 000 + (10 0000 0000 / #3 - #1) * (1000 - #4 / 10) \__fp_sep:
19676 {#3}{#4}#5\__fp_sep: #6\__fp_sep: { #7 #2, }
19677 }
19678 \cs_new:Npn \__fp_ep_div_estiii:NNNNNwwwn 1#1#2#3#4#5#6\__fp_sep: #7\__fp_sep:
19679 {
19680 \__fp_fixed_mul_short:wwn #7\__fp_sep: {#1}{#2#3#4#5}{#6}\__fp_sep:
19681 \__fp_ep_div_epsi:wnNNNNNn {#1#2#3#4}#5#6
19682 \__fp_fixed_mul:wwn
19683 }
19684 \cs_new:Npn \__fp_ep_div_epsi:wnNNNNNn #1#2#3#4#5#6\__fp_sep:
19685 {
19686 \exp_after:wN \__fp_ep_div_epsii:wwnNNNNNn
19687 \int_value:w \__fp_int_eval:w 1 9998 - #2
19688 \exp_after:wN \__fp_ep_div_eps_pack:NNNNNw
19689 \int_value:w \__fp_int_eval:w 1 9999 9998 - #3#4
19690 \exp_after:wN \__fp_ep_div_eps_pack:NNNNNw
19691 \int_value:w \__fp_int_eval:w 2 0000 0000 - #5#6 \__fp_sep: \__fp_sep:
19692 }
19693 \cs_new:Npn \__fp_ep_div_eps_pack:NNNNNw #1#2#3#4#5#6\__fp_sep:
19694 { + #1 \__fp_sep: {#2#3#4#5} {#6} }
19695 \cs_new:Npn \__fp_ep_div_epsii:wwnNNNNNn 1#1\__fp_sep: #2\__fp_sep: #3#4#5#6#7#8
19696 {
19697 \__fp_fixed_mul:wwn {0000}{#1}#2\__fp_sep: {0000}{#1}#2\__fp_sep:
19698 \__fp_fixed_add_one:wN
19699 \__fp_fixed_mul:wwn {10000} {#1} #2 \__fp_sep:
19700 {
19701 \__fp_fixed_mul_short:wwn
19702 {0000}{#1}#2\__fp_sep: {#3}{#4#5#6#7}{#8000}\__fp_sep:
19703 \__fp_fixed_div_myriad:wn
19704 \__fp_fixed_mul:wwn
19705 }
19706 \__fp_fixed_add:wwn {#3}{#4#5#6#7}{#8000}{0000}{0000}{0000}\__fp_sep:
19707 }
19708 \cs_new:Npn \__fp_ep_isqrt:wwn #1,#2\__fp_sep:
19709 {
19710 \__fp_ep_to_ep:wwN #1,#2\__fp_sep:
19711 \__fp_ep_isqrt_auxi:wwn
19712 }
19713 \cs_new:Npn \__fp_ep_isqrt_auxi:wwn #1,
19714 {
19715 \exp_after:wN \__fp_ep_isqrt_auxii:wwnnnwn
19716 \int_value:w \__fp_int_eval:w
19717 \int_if_odd:nTF {#1}
19718 { (1 - #1) / 2 , 535 , { 0 } { } }
19719 { 1 - #1 / 2 , 168 , { } { 0 } }
19720 }
19721 \cs_new:Npn \__fp_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6\__fp_sep: #7
19722 {
19723 \__fp_ep_isqrt_esti:wwwnnwn #2, 0, #5, {#3} {#4}
19724 {#5} #6 \__fp_sep: { #7 #1 , }
19725 }
19726 \cs_new:Npn \__fp_ep_isqrt_esti:wwwnnwn #1, #2, #3, #4
19727 {
19728 \if_int_compare:w #1 = #2 \exp_stop_f:
19729 \exp_after:wN \__fp_ep_isqrt_estii:wwwnnwn
19730 \fi:
19731 \exp_after:wN \__fp_ep_isqrt_esti:wwwnnwn
19732 \int_value:w \__fp_int_eval:w
19733 (#1 + 1 0050 0000 #4 / (#1 * #3)) / 2 ,
19734 #1, #3, {#4}
19735 }
19736 \cs_new:Npn \__fp_ep_isqrt_estii:wwwnnwn #1, #2, #3, #4#5
19737 {
19738 \exp_after:wN \__fp_ep_isqrt_estiii:NNNNNwwwn
19739 \int_value:w \__fp_int_eval:w 1000 0000 + #2 * #2 #5 * 5
19740 \exp_after:wN , \int_value:w \__fp_int_eval:w 10000 + #2 \__fp_sep:
19741 }
19742 \cs_new:Npn \__fp_ep_isqrt_estiii:NNNNNwwwn
19743 1#1#2#3#4#5#6, 1#7#8\__fp_sep: #9\__fp_sep:
19744 {
19745 \__fp_fixed_mul_short:wwn #9\__fp_sep: {#1} {#2#3#4#5} {#600} \__fp_sep:
19746 \__fp_ep_isqrt_epsi:wN
19747 \__fp_fixed_mul_short:wwn {#7} {#80} {0000} \__fp_sep:
19748 }
19749 \cs_new:Npn \__fp_ep_isqrt_epsi:wN #1\__fp_sep:
19750 {
19751 \__fp_fixed_sub:wwn {15000}{0000}{0000}{0000}{0000}{0000}\__fp_sep: #1\__fp_sep:
19752 \__fp_ep_isqrt_epsii:wwN #1\__fp_sep:
19753 \__fp_ep_isqrt_epsii:wwN #1\__fp_sep:
19754 \__fp_ep_isqrt_epsii:wwN #1\__fp_sep:
19755 }
19756 \cs_new:Npn \__fp_ep_isqrt_epsii:wwN #1\__fp_sep: #2\__fp_sep:
19757 {
19758 \__fp_fixed_mul:wwn #1\__fp_sep: #1\__fp_sep:
19759 \__fp_fixed_mul_sub_back:wwwn #2\__fp_sep:
19760 {15000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
19761 \__fp_fixed_mul:wwn #1\__fp_sep:
19762 }
19763 \cs_new:Npn \__fp_ep_to_float_o:wwN #1,
19764 { + \__fp_int_eval:w #1 \__fp_fixed_to_float_o:wN }
19765 \cs_new:Npn \__fp_ep_inv_to_float_o:wwN #1,#2\__fp_sep:
19766 {
19767 \__fp_ep_div:wwwwn
19768 1,{1000}{0000}{0000}{0000}{0000}{0000}\__fp_sep: #1,#2\__fp_sep:
19769 \__fp_ep_to_float_o:wwN
19770 }
19771 \cs_new:Npn \__fp_fixed_inv_to_float_o:wN
19772 { \__fp_ep_inv_to_float_o:wwN 0, }
19773 \cs_new:Npn \__fp_fixed_to_float_rad_o:wN #1\__fp_sep:
19774 {
19775 \__fp_fixed_mul:wwn #1\__fp_sep: {5729}{5779}{5130}{8232}{0876}{7981}\__fp_sep:
19776 { \__fp_ep_to_float_o:wwN 2, }
19777 }
19778 \cs_new:Npn \__fp_fixed_to_float_o:Nw #1#2\__fp_sep:
19779 { \__fp_fixed_to_float_o:wN #2\__fp_sep: #1 }
19780 \cs_new:Npn \__fp_fixed_to_float_o:wN #1#2#3#4#5#6\__fp_sep: #7
19781 { % for the 8-digit-at-the-start thing
19782 + \__fp_int_eval:w \c__fp_block_int
19783 \exp_after:wN \exp_after:wN
19784 \exp_after:wN \__fp_fixed_to_loop:N
19785 \exp_after:wN \use_none:n
19786 \int_value:w \__fp_int_eval:w
19787 1 0000 0000 + #1 \exp_after:wN \__fp_use_none_stop_f:n
19788 \int_value:w 1#2 \exp_after:wN \__fp_use_none_stop_f:n
19789 \int_value:w 1#3#4 \exp_after:wN \__fp_use_none_stop_f:n
19790 \int_value:w 1#5#6
19791 \exp_after:wN \__fp_sep:
19792 \exp_after:wN \__fp_sep:
19793 }
19794 \cs_new:Npn \__fp_fixed_to_loop:N #1
19795 {
19796 \if_meaning:w 0 #1
19797 - 1
19798 \exp_after:wN \__fp_fixed_to_loop:N
19799 \else:
19800 \exp_after:wN \__fp_fixed_to_loop_end:w
19801 \exp_after:wN #1
19802 \fi:
19803 }
19804 \cs_new:Npn \__fp_fixed_to_loop_end:w #1 #2 \__fp_sep:
19805 {
19806 \if_meaning:w \__fp_sep: #1
19807 \exp_after:wN \__fp_fixed_to_float_zero:w
19808 \else:
19809 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
19810 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
19811 \exp_after:wN \__fp_fixed_to_float_pack:ww
19812 \exp_after:wN \__fp_sep:
19813 \fi:
19814 #1 #2 0000 0000 0000 0000 \__fp_sep:
19815 }
19816 \cs_new:Npn \__fp_fixed_to_float_zero:w \__fp_sep: 0000 0000 0000 0000 \__fp_sep:
19817 {
19818 - 2 * \c__fp_max_exponent_int \__fp_sep:
19819 {0000} {0000} {0000} {0000} \__fp_sep:
19820 }
19821 \cs_new:Npn \__fp_fixed_to_float_pack:ww #1 \__fp_sep: #2#3 \__fp_sep: \__fp_sep:
19822 {
19823 \if_int_compare:w #2 > 4 \exp_stop_f:
19824 \exp_after:wN \__fp_fixed_to_float_round_up:wnnnnw
19825 \fi:
19826 \__fp_sep: #1 \__fp_sep:
19827 }
19828 \cs_new:Npn \__fp_fixed_to_float_round_up:wnnnnw \__fp_sep: #1#2#3#4 \__fp_sep:
19829 {
19830 \exp_after:wN \__fp_basics_pack_high:NNNNNw
19831 \int_value:w \__fp_int_eval:w 1 #1#2
19832 \exp_after:wN \__fp_basics_pack_low:NNNNNw
19833 \int_value:w \__fp_int_eval:w 1 #3#4 + 1 \__fp_sep:
19834 }
19835 %% File: l3fp-expo.dtx
19836 \cs_new:Npn \__fp_parse_word_exp:N
19837 { \__fp_parse_unary_function:NNN \__fp_exp_o:w ? }
19838 \cs_new:Npn \__fp_parse_word_ln:N
19839 { \__fp_parse_unary_function:NNN \__fp_ln_o:w ? }
19840 \cs_new:Npn \__fp_parse_word_fact:N
19841 { \__fp_parse_unary_function:NNN \__fp_fact_o:w ? }
19842 \tl_const:Nn \c__fp_ln_i_fixed_tl
19843 { {0000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:}
19844 \tl_const:Nn \c__fp_ln_ii_fixed_tl
19845 { {6931}{4718}{0559}{9453}{0941}{7232}\__fp_sep:}
19846 \tl_const:Nn \c__fp_ln_iii_fixed_tl
19847 {{10986}{1228}{8668}{1096}{9139}{5245}\__fp_sep:}
19848 \tl_const:Nn \c__fp_ln_iv_fixed_tl
19849 {{13862}{9436}{1119}{8906}{1883}{4464}\__fp_sep:}
19850 \tl_const:Nn \c__fp_ln_vi_fixed_tl
19851 {{17917}{5946}{9228}{0550}{0081}{2477}\__fp_sep:}
19852 \tl_const:Nn \c__fp_ln_vii_fixed_tl
19853 {{19459}{1014}{9055}{3133}{0510}{5353}\__fp_sep:}
19854 \tl_const:Nn \c__fp_ln_viii_fixed_tl
19855 {{20794}{4154}{1679}{8359}{2825}{1696}\__fp_sep:}
19856 \tl_const:Nn \c__fp_ln_ix_fixed_tl
19857 {{21972}{2457}{7336}{2193}{8279}{0490}\__fp_sep:}
19858 \tl_const:Nn \c__fp_ln_x_fixed_tl
19859 {{23025}{8509}{2994}{0456}{8401}{7991}\__fp_sep:}
19860 \cs_new:Npn \__fp_ln_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
19861 {
19862 \if_meaning:w 2 #3
19863 \__fp_case_use:nw { \__fp_invalid_operation_o:nw { ln } }
19864 \fi:
19865 \if_case:w #2 \exp_stop_f:
19866 \__fp_case_use:nw
19867 { \__fp_division_by_zero_o:Nnw \c_minus_inf_fp { ln } }
19868 \or:
19869 \else:
19870 \__fp_case_return_same_o:w
19871 \fi:
19872 \__fp_ln_npos_o:w \s__fp \__fp_chk:w #2#3#4\__fp_sep:
19873 }
19874 \cs_new:Npn \__fp_ln_npos_o:w \s__fp \__fp_chk:w 10#1#2#3\__fp_sep:
19875 { %^^A todo: ln(1) should be "exact zero", not "underflow"
19876 \exp_after:wN \__fp_sanitize:Nw
19877 \int_value:w % for the overall sign
19878 \if_int_compare:w #1 < \c_one_int
19879 2
19880 \else:
19881 0
19882 \fi:
19883 \exp_after:wN \exp_stop_f:
19884 \int_value:w \__fp_int_eval:w % for the exponent
19885 \__fp_ln_significand:NNNNnnnN #2#3
19886 \__fp_ln_exponent:wn {#1}
19887 }
19888 \cs_new:Npn \__fp_ln_significand:NNNNnnnN #1#2#3#4
19889 {
19890 \exp_after:wN \__fp_ln_x_ii:wnnnn
19891 \int_value:w
19892 \if_case:w #1 \exp_stop_f:
19893 \or:
19894 \if_int_compare:w #2 < 4 \exp_stop_f:
19895 \__fp_int_eval:w 10 - #2
19896 \else:
19897 6
19898 \fi:
19899 \or: 4
19900 \or: 3
19901 \or: 2
19902 \or: 2
19903 \or: 2
19904 \else: 1
19905 \fi:
19906 \__fp_sep: { #1 #2 #3 #4 }
19907 }
19908 \cs_new:Npn \__fp_ln_x_ii:wnnnn #1\__fp_sep: #2#3#4#5
19909 {
19910 \exp_after:wN \__fp_ln_div_after:Nw
19911 \cs:w c__fp_ln_ \__fp_int_to_roman:w #1 _fixed_tl \exp_after:wN \cs_end:
19912 \int_value:w
19913 \exp_after:wN \__fp_ln_x_iv:wnnnnnnnn
19914 \int_value:w \__fp_int_eval:w
19915 \exp_after:wN \__fp_ln_x_iii_var:NNNNNw
19916 \int_value:w \__fp_int_eval:w 9999 9990 + #1*#2#3 +
19917 \exp_after:wN \__fp_ln_x_iii:NNNNNNw
19918 \int_value:w \__fp_int_eval:w 10 0000 0000 + #1*#4#5 \__fp_sep:
19919 {20000} {0000} {0000} {0000}
19920 } %^^A todo: reoptimize (a generalization attempt failed).
19921 \cs_new:Npn \__fp_ln_x_iii:NNNNNNw #1#2 #3#4#5#6 #7\__fp_sep:
19922 { #1#2\__fp_sep: {#3#4#5#6} {#7} }
19923 \cs_new:Npn \__fp_ln_x_iii_var:NNNNNw #1 #2#3#4#5 #6\__fp_sep:
19924 {
19925 #1#2#3#4#5 + 1 \__fp_sep:
19926 {#1#2#3#4#5} {#6}
19927 }
19928 \cs_new:Npn \__fp_ln_x_iv:wnnnnnnnn #1\__fp_sep: #2#3#4#5 #6#7#8#9
19929 {
19930 \exp_after:wN \__fp_div_significand_pack:NNN
19931 \int_value:w \__fp_int_eval:w
19932 \__fp_ln_div_i:w #1 \__fp_sep:
19933 #6 #7 \__fp_sep: {#8} {#9}
19934 {#2} {#3} {#4} {#5}
19935 { \exp_after:wN \__fp_ln_div_ii:wwn \int_value:w #1 }
19936 { \exp_after:wN \__fp_ln_div_ii:wwn \int_value:w #1 }
19937 { \exp_after:wN \__fp_ln_div_ii:wwn \int_value:w #1 }
19938 { \exp_after:wN \__fp_ln_div_ii:wwn \int_value:w #1 }
19939 { \exp_after:wN \__fp_ln_div_vi:wwn \int_value:w #1 }
19940 }
19941 \cs_new:Npn \__fp_ln_div_i:w #1\__fp_sep:
19942 {
19943 \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn
19944 \int_value:w \__fp_int_eval:w 999999 + 2 0000 0000 / #1 \__fp_sep: % Q1
19945 }
19946 \cs_new:Npn \__fp_ln_div_ii:wwn
19947 #1\__fp_sep: #2\__fp_sep:#3 % y\__fp_sep: B1\__fp_sep:B2 <- for k=1
19948 {
19949 \exp_after:wN \__fp_div_significand_pack:NNN
19950 \int_value:w \__fp_int_eval:w
19951 \exp_after:wN \__fp_div_significand_calc:wwnnnnnnn
19952 \int_value:w \__fp_int_eval:w 999999 + #2 #3 / #1 \__fp_sep: % Q2
19953 #2 #3 \__fp_sep:
19954 }
19955 \cs_new:Npn \__fp_ln_div_vi:wwn
19956 #1\__fp_sep: #2\__fp_sep:#3#4#5 #6#7#8#9 %y\__fp_sep:F1\__fp_sep:F2F3F4x1x2x3x4
19957 {
19958 \exp_after:wN \__fp_div_significand_pack:NNN
19959 \int_value:w \__fp_int_eval:w 1000000 + #2 #3 / #1 \__fp_sep: % Q6
19960 }
19961 \cs_new:Npn \__fp_ln_div_after:Nw #1#2\__fp_sep:
19962 {
19963 \if_meaning:w 0 #2
19964 \exp_after:wN \__fp_ln_t_small:Nw
19965 \else:
19966 \exp_after:wN \__fp_ln_t_large:NNw
19967 \exp_after:wN -
19968 \fi:
19969 #1
19970 }
19971 \cs_new:Npn \__fp_ln_t_small:Nw
19972 #1 #2\__fp_sep: #3\__fp_sep: #4\__fp_sep: #5\__fp_sep: #6\__fp_sep: #7\__fp_sep:
19973 {
19974 \exp_after:wN \__fp_ln_t_large:NNw
19975 \exp_after:wN + % <sign>
19976 \exp_after:wN #1
19977 \int_value:w \__fp_int_eval:w 9999 - #2 \exp_after:wN \__fp_sep:
19978 \int_value:w \__fp_int_eval:w 9999 - #3 \exp_after:wN \__fp_sep:
19979 \int_value:w \__fp_int_eval:w 9999 - #4 \exp_after:wN \__fp_sep:
19980 \int_value:w \__fp_int_eval:w 9999 - #5 \exp_after:wN \__fp_sep:
19981 \int_value:w \__fp_int_eval:w 9999 - #6 \exp_after:wN \__fp_sep:
19982 \int_value:w \__fp_int_eval:w 1 0000 - #7 \__fp_sep:
19983 }
19984 \cs_new:Npn \__fp_ln_t_large:NNw
19985 #1 #2
19986 #3\__fp_sep: #4\__fp_sep: #5\__fp_sep: #6\__fp_sep: #7\__fp_sep: #8\__fp_sep:
19987 {
19988 \exp_after:wN \__fp_ln_square_t_after:w
19989 \int_value:w \__fp_int_eval:w 9999 0000 + #3*#3
19990 \exp_after:wN \__fp_ln_square_t_pack:NNNNNw
19991 \int_value:w \__fp_int_eval:w 9999 0000 + 2*#3*#4
19992 \exp_after:wN \__fp_ln_square_t_pack:NNNNNw
19993 \int_value:w \__fp_int_eval:w 9999 0000 + 2*#3*#5 + #4*#4
19994 \exp_after:wN \__fp_ln_square_t_pack:NNNNNw
19995 \int_value:w \__fp_int_eval:w 9999 0000 + 2*#3*#6 + 2*#4*#5
19996 \exp_after:wN \__fp_ln_square_t_pack:NNNNNw
19997 \int_value:w \__fp_int_eval:w
19998 1 0000 0000 + 2*#3*#7 + 2*#4*#6 + #5*#5
19999 + (2*#3*#8 + 2*#4*#7 + 2*#5*#6) / 1 0000
20000 % \__fp_sep: \__fp_sep: \__fp_sep:
20001 \exp_after:wN \__fp_ln_twice_t_after:w
20002 \int_value:w \__fp_int_eval:w -1 + 2*#3
20003 \exp_after:wN \__fp_ln_twice_t_pack:Nw
20004 \int_value:w \__fp_int_eval:w 9999 + 2*#4
20005 \exp_after:wN \__fp_ln_twice_t_pack:Nw
20006 \int_value:w \__fp_int_eval:w 9999 + 2*#5
20007 \exp_after:wN \__fp_ln_twice_t_pack:Nw
20008 \int_value:w \__fp_int_eval:w 9999 + 2*#6
20009 \exp_after:wN \__fp_ln_twice_t_pack:Nw
20010 \int_value:w \__fp_int_eval:w 9999 + 2*#7
20011 \exp_after:wN \__fp_ln_twice_t_pack:Nw
20012 \int_value:w \__fp_int_eval:w 10000 + 2*#8 \__fp_sep: \__fp_sep:
20013 { \__fp_ln_c:NwNw #1 }
20014 #2
20015 }
20016 \cs_new:Npn \__fp_ln_twice_t_pack:Nw #1 #2\__fp_sep: { + #1 \__fp_sep: {#2} }
20017 \cs_new:Npn \__fp_ln_twice_t_after:w #1\__fp_sep:
20018 { \__fp_sep:\__fp_sep:\__fp_sep: {#1} }
20019 \cs_new:Npn \__fp_ln_square_t_pack:NNNNNw #1 #2#3#4#5 #6\__fp_sep:
20020 { + #1#2#3#4#5 \__fp_sep: {#6} }
20021 \cs_new:Npn \__fp_ln_square_t_after:w 1 0 #1#2#3 #4\__fp_sep:
20022 { \__fp_ln_Taylor:wwNw {0#1#2#3} {#4} }
20023 \cs_new:Npn \__fp_ln_Taylor:wwNw
20024 {
20025 \__fp_ln_Taylor_loop:www
20026 21 \__fp_sep: {0000}{0000}{0000}{0000}{0000}{0000} \__fp_sep:
20027 }
20028 \cs_new:Npn \__fp_ln_Taylor_loop:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
20029 {
20030 \if_int_compare:w #1 = \c_one_int
20031 \__fp_ln_Taylor_break:w
20032 \fi:
20033 \exp_after:wN \__fp_fixed_div_int:wwN \c__fp_one_fixed_tl #1\__fp_sep:
20034 \__fp_fixed_add:wwn #2\__fp_sep:
20035 \__fp_fixed_mul:wwn #3\__fp_sep:
20036 {
20037 \exp_after:wN \__fp_ln_Taylor_loop:www
20038 \int_value:w \__fp_int_eval:w #1 - 2 \__fp_sep:
20039 }
20040 #3\__fp_sep:
20041 }
20042 \cs_new:Npn \__fp_ln_Taylor_break:w
20043 \fi: #1 \__fp_fixed_add:wwn #2#3\__fp_sep: #4 \__fp_sep:\__fp_sep:
20044 {
20045 \fi:
20046 \exp_after:wN \__fp_fixed_mul:wwn
20047 \exp_after:wN { \int_value:w \__fp_int_eval:w 10000 + #2 } #3\__fp_sep:
20048 }
20049 \cs_new:Npn \__fp_ln_c:NwNw #1 #2\__fp_sep: #3
20050 {
20051 \if_meaning:w + #1
20052 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_sub:wwn
20053 \else:
20054 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_fixed_add:wwn
20055 \fi:
20056 #3 #2 \__fp_sep:
20057 }
20058 \cs_new:Npn \__fp_ln_exponent:wn #1\__fp_sep: #2
20059 {
20060 \if_case:w #2 \exp_stop_f:
20061 0 \__fp_case_return:nw { \__fp_fixed_to_float_o:Nw 2 }
20062 \or:
20063 \exp_after:wN \__fp_ln_exponent_one:ww \int_value:w
20064 \else:
20065 \if_int_compare:w #2 > \c_zero_int
20066 \exp_after:wN \__fp_ln_exponent_small:NNww
20067 \exp_after:wN 0
20068 \exp_after:wN \__fp_fixed_sub:wwn \int_value:w
20069 \else:
20070 \exp_after:wN \__fp_ln_exponent_small:NNww
20071 \exp_after:wN 2
20072 \exp_after:wN \__fp_fixed_add:wwn \int_value:w -
20073 \fi:
20074 \fi:
20075 #2\__fp_sep: #1\__fp_sep:
20076 }
20077 \cs_new:Npn \__fp_ln_exponent_one:ww 1\__fp_sep: #1\__fp_sep:
20078 {
20079 0
20080 \exp_after:wN \__fp_fixed_sub:wwn \c__fp_ln_x_fixed_tl #1\__fp_sep:
20081 \__fp_fixed_to_float_o:wN 0
20082 }
20083 \cs_new:Npn \__fp_ln_exponent_small:NNww #1#2#3\__fp_sep: #4#5#6#7#8#9\__fp_sep:
20084 {
20085 4
20086 \exp_after:wN \__fp_fixed_mul:wwn
20087 \c__fp_ln_x_fixed_tl
20088 {#3}{0000}{0000}{0000}{0000}{0000} \__fp_sep:
20089 #2
20090 {0000}{#4}{#5}{#6}{#7}{#8}\__fp_sep:
20091 \__fp_fixed_to_float_o:wN #1
20092 }
20093 \cs_new:Npn \__fp_exp_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20094 {
20095 \if_case:w #2 \exp_stop_f:
20096 \__fp_case_return_o:Nw \c_one_fp
20097 \or:
20098 \exp_after:wN \__fp_exp_normal_o:w
20099 \or:
20100 \if_meaning:w 0 #3
20101 \exp_after:wN \__fp_case_return_o:Nw
20102 \exp_after:wN \c_inf_fp
20103 \else:
20104 \exp_after:wN \__fp_case_return_o:Nw
20105 \exp_after:wN \c_zero_fp
20106 \fi:
20107 \or:
20108 \__fp_case_return_same_o:w
20109 \fi:
20110 \s__fp \__fp_chk:w #2#3#4\__fp_sep:
20111 }
20112 \cs_new:Npn \__fp_exp_normal_o:w \s__fp \__fp_chk:w 1#1
20113 {
20114 \if_meaning:w 0 #1
20115 \__fp_exp_pos_o:NNwnw + \__fp_fixed_to_float_o:wN
20116 \else:
20117 \__fp_exp_pos_o:NNwnw - \__fp_fixed_inv_to_float_o:wN
20118 \fi:
20119 }
20120 \cs_new:Npn \__fp_exp_pos_o:NNwnw #1#2#3 \fi: #4#5\__fp_sep:
20121 {
20122 \fi:
20123 \if_int_compare:w #4 > \c__fp_max_exp_exponent_int
20124 \token_if_eq_charcode:NNTF + #1
20125 { \__fp_exp_overflow:NN \__fp_overflow:w \c_inf_fp }
20126 { \__fp_exp_overflow:NN \__fp_underflow:w \c_zero_fp }
20127 \exp:w
20128 \else:
20129 \exp_after:wN \__fp_sanitize:Nw
20130 \exp_after:wN 0
20131 \int_value:w #1 \__fp_int_eval:w
20132 \if_int_compare:w #4 < \c_zero_int
20133 \exp_after:wN \use_i:nn
20134 \else:
20135 \exp_after:wN \use_ii:nn
20136 \fi:
20137 {
20138 0
20139 \__fp_decimate:nNnnnn { - #4 }
20140 \__fp_exp_Taylor:Nnnwn
20141 }
20142 {
20143 \__fp_decimate:nNnnnn { \c__fp_prec_int - #4 }
20144 \__fp_exp_pos_large:NnnNwn
20145 }
20146 #5
20147 {#4}
20148 #1 #2 0
20149 \exp:w
20150 \fi:
20151 \exp_after:wN \exp_end:
20152 }
20153 \cs_new:Npn \__fp_exp_overflow:NN #1#2
20154 {
20155 \exp_after:wN \exp_after:wN
20156 \exp_after:wN #1
20157 \exp_after:wN #2
20158 }
20159 \cs_new:Npn \__fp_exp_Taylor:Nnnwn #1#2#3 #4\__fp_sep: #5 #6
20160 {
20161 #6
20162 \__fp_pack_twice_four:wNNNNNNNN
20163 \__fp_pack_twice_four:wNNNNNNNN
20164 \__fp_pack_twice_four:wNNNNNNNN
20165 \__fp_exp_Taylor_ii:ww
20166 \__fp_sep: #2#3#4 0000 0000 \__fp_sep:
20167 }
20168 \cs_new:Npn \__fp_exp_Taylor_ii:ww #1\__fp_sep: #2\__fp_sep:
20169 { \__fp_exp_Taylor_loop:www 10 \__fp_sep: #1 \__fp_sep: #1 \__fp_sep: \s__fp_stop }
20170 \cs_new:Npn \__fp_exp_Taylor_loop:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
20171 {
20172 \if_int_compare:w #1 = \c_one_int
20173 \exp_after:wN \__fp_exp_Taylor_break:Nww
20174 \fi:
20175 \__fp_fixed_div_int:wwN #3 \__fp_sep: #1 \__fp_sep:
20176 \__fp_fixed_add_one:wN
20177 \__fp_fixed_mul:wwn #2 \__fp_sep:
20178 {
20179 \exp_after:wN \__fp_exp_Taylor_loop:www
20180 \int_value:w \__fp_int_eval:w #1 - 1 \__fp_sep:
20181 #2 \__fp_sep:
20182 }
20183 }
20184 \cs_new:Npn \__fp_exp_Taylor_break:Nww #1 #2\__fp_sep: #3 \s__fp_stop
20185 { \__fp_fixed_add_one:wN #2 \__fp_sep: }
20186 \intarray_const_from_clist:Nn \c__fp_exp_intarray
20187 {
20188 1 , 1 1105 1709 , 1 1807 5647 , 1 6248 1171 ,
20189 1 , 1 1221 4027 , 1 5816 0169 , 1 8339 2107 ,
20190 1 , 1 1349 8588 , 1 0757 6003 , 1 1039 8374 ,
20191 1 , 1 1491 8246 , 1 9764 1270 , 1 3178 2485 ,
20192 1 , 1 1648 7212 , 1 7070 0128 , 1 1468 4865 ,
20193 1 , 1 1822 1188 , 1 0039 0508 , 1 9748 7537 ,
20194 1 , 1 2013 7527 , 1 0747 0476 , 1 5216 2455 ,
20195 1 , 1 2225 5409 , 1 2849 2467 , 1 6045 7954 ,
20196 1 , 1 2459 6031 , 1 1115 6949 , 1 6638 0013 ,
20197 1 , 1 2718 2818 , 1 2845 9045 , 1 2353 6029 ,
20198 1 , 1 7389 0560 , 1 9893 0650 , 1 2272 3043 ,
20199 2 , 1 2008 5536 , 1 9231 8766 , 1 7740 9285 ,
20200 2 , 1 5459 8150 , 1 0331 4423 , 1 9078 1103 ,
20201 3 , 1 1484 1315 , 1 9102 5766 , 1 0342 1116 ,
20202 3 , 1 4034 2879 , 1 3492 7351 , 1 2260 8387 ,
20203 4 , 1 1096 6331 , 1 5842 8458 , 1 5992 6372 ,
20204 4 , 1 2980 9579 , 1 8704 1728 , 1 2747 4359 ,
20205 4 , 1 8103 0839 , 1 2757 5384 , 1 0077 1000 ,
20206 5 , 1 2202 6465 , 1 7948 0671 , 1 6516 9579 ,
20207 9 , 1 4851 6519 , 1 5409 7902 , 1 7796 9107 ,
20208 14 , 1 1068 6474 , 1 5815 2446 , 1 2146 9905 ,
20209 18 , 1 2353 8526 , 1 6837 0199 , 1 8540 7900 ,
20210 22 , 1 5184 7055 , 1 2858 7072 , 1 4640 8745 ,
20211 27 , 1 1142 0073 , 1 8981 5684 , 1 2836 6296 ,
20212 31 , 1 2515 4386 , 1 7091 9167 , 1 0062 6578 ,
20213 35 , 1 5540 6223 , 1 8439 3510 , 1 0525 7117 ,
20214 40 , 1 1220 4032 , 1 9431 7840 , 1 8020 0271 ,
20215 44 , 1 2688 1171 , 1 4181 6135 , 1 4484 1263 ,
20216 87 , 1 7225 9737 , 1 6812 5749 , 1 2581 7748 ,
20217 131 , 1 1942 4263 , 1 9524 1255 , 1 9365 8421 ,
20218 174 , 1 5221 4696 , 1 8976 4143 , 1 9505 8876 ,
20219 218 , 1 1403 5922 , 1 1785 2837 , 1 4107 3977 ,
20220 261 , 1 3773 0203 , 1 0092 9939 , 1 8234 0143 ,
20221 305 , 1 1014 2320 , 1 5473 5004 , 1 5094 5533 ,
20222 348 , 1 2726 3745 , 1 7211 2566 , 1 5673 6478 ,
20223 391 , 1 7328 8142 , 1 2230 7421 , 1 7051 8866 ,
20224 435 , 1 1970 0711 , 1 1401 7046 , 1 9938 8888 ,
20225 869 , 1 3881 1801 , 1 9428 4368 , 1 5764 8232 ,
20226 1303 , 1 7646 2009 , 1 8905 4704 , 1 8893 1073 ,
20227 1738 , 1 1506 3559 , 1 7005 0524 , 1 9009 7592 ,
20228 2172 , 1 2967 6283 , 1 8402 3667 , 1 0689 6630 ,
20229 2606 , 1 5846 4389 , 1 5650 2114 , 1 7278 5046 ,
20230 3041 , 1 1151 7900 , 1 5080 6878 , 1 2914 4154 ,
20231 3475 , 1 2269 1083 , 1 0850 6857 , 1 8724 4002 ,
20232 3909 , 1 4470 3047 , 1 3316 5442 , 1 6408 6591 ,
20233 4343 , 1 8806 8182 , 1 2566 2921 , 1 5872 6150 ,
20234 8686 , 1 7756 0047 , 1 2598 6861 , 1 0458 3204 ,
20235 13029 , 1 6830 5723 , 1 7791 4884 , 1 1932 7351 ,
20236 17372 , 1 6015 5609 , 1 3095 3052 , 1 3494 7574 ,
20237 21715 , 1 5297 7951 , 1 6443 0315 , 1 3251 3576 ,
20238 26058 , 1 4665 6719 , 1 0099 3379 , 1 5527 2929 ,
20239 30401 , 1 4108 9724 , 1 3326 3186 , 1 5271 5665 ,
20240 34744 , 1 3618 6973 , 1 3140 0875 , 1 3856 4102 ,
20241 39087 , 1 3186 9209 , 1 6113 3900 , 1 6705 9685 ,
20242 }
20243 \cs_new:Npn \__fp_exp_pos_large:NnnNwn #1#2#3 #4#5\__fp_sep: #6
20244 {
20245 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_exp_large:NwN
20246 \exp_after:wN \exp_after:wN \exp_after:wN #6
20247 \exp_after:wN \c__fp_one_fixed_tl
20248 \int_value:w #3 #4 \exp_stop_f:
20249 #5 00000 \__fp_sep:
20250 }
20251 \cs_new:Npn \__fp_exp_large:NwN #1#2\__fp_sep: #3
20252 {
20253 \if_case:w #3 ~
20254 \exp_after:wN \__fp_fixed_continue:wn
20255 \else:
20256 \exp_after:wN \__fp_exp_intarray:w
20257 \int_value:w \__fp_int_eval:w 36 * #1 + 4 * #3 \exp_after:wN \__fp_sep:
20258 \fi:
20259 #2\__fp_sep:
20260 {
20261 \if_meaning:w 0 #1
20262 \exp_after:wN \__fp_exp_large_after:wwn
20263 \else:
20264 \exp_after:wN \__fp_exp_large:NwN
20265 \int_value:w \__fp_int_eval:w #1 - 1 \exp_after:wN \scan_stop:
20266 \fi:
20267 }
20268 }
20269 \cs_new:Npn \__fp_exp_intarray:w #1 \__fp_sep:
20270 {
20271 +
20272 \__kernel_intarray_item:Nn \c__fp_exp_intarray
20273 { \__fp_int_eval:w #1 - 3 \scan_stop: }
20274 \exp_after:wN \use_i:nnn
20275 \exp_after:wN \__fp_fixed_mul:wwn
20276 \int_value:w 0
20277 \exp_after:wN \__fp_exp_intarray_aux:w
20278 \int_value:w \__kernel_intarray_item:Nn
20279 \c__fp_exp_intarray { \__fp_int_eval:w #1 - 2 }
20280 \exp_after:wN \__fp_exp_intarray_aux:w
20281 \int_value:w \__kernel_intarray_item:Nn
20282 \c__fp_exp_intarray { \__fp_int_eval:w #1 - 1 }
20283 \exp_after:wN \__fp_exp_intarray_aux:w
20284 \int_value:w \__kernel_intarray_item:Nn
20285 \c__fp_exp_intarray {#1} \__fp_sep: \__fp_sep:
20286 }
20287 \cs_new:Npn \__fp_exp_intarray_aux:w 1 #1#2#3#4#5 \__fp_sep:
20288 { \__fp_sep: {#1#2#3#4} {#5} }
20289 \cs_new:Npn \__fp_exp_large_after:wwn #1\__fp_sep: #2\__fp_sep: #3
20290 {
20291 \__fp_exp_Taylor:Nnnwn ? { } { } 0 #2\__fp_sep: {} #3
20292 \__fp_fixed_mul:wwn #1\__fp_sep:
20293 }
20294 \cs_new:cpn { __fp_ \iow_char:N \^ _o:ww }
20295 \s__fp \__fp_chk:w #1#2#3\__fp_sep: \s__fp \__fp_chk:w #4#5#6\__fp_sep:
20296 {
20297 \if_meaning:w 0 #4
20298 \__fp_case_return_o:Nw \c_one_fp
20299 \fi:
20300 \if_case:w #2 \exp_stop_f:
20301 \exp_after:wN \use_i:nn
20302 \or:
20303 \__fp_case_return_o:Nw \c_nan_fp
20304 \else:
20305 \exp_after:wN \__fp_pow_neg:www
20306 \exp:w \exp_end_continue_f:w \exp_after:wN \use:nn
20307 \fi:
20308 {
20309 \if_meaning:w 1 #1
20310 \exp_after:wN \__fp_pow_normal_o:ww
20311 \else:
20312 \exp_after:wN \__fp_pow_zero_or_inf:ww
20313 \fi:
20314 \s__fp \__fp_chk:w #1#2#3\__fp_sep:
20315 }
20316 { \s__fp \__fp_chk:w #4#5#6\__fp_sep: \s__fp \__fp_chk:w #1#2#3\__fp_sep: }
20317 \s__fp \__fp_chk:w #4#5#6\__fp_sep:
20318 }
20319 \cs_new:Npn \__fp_pow_zero_or_inf:ww
20320 \s__fp \__fp_chk:w #1#2\__fp_sep: \s__fp \__fp_chk:w #3#4
20321 {
20322 \if_meaning:w 1 #4
20323 \__fp_case_return_same_o:w
20324 \fi:
20325 \if_meaning:w #1 #4
20326 \__fp_case_return_o:Nw \c_zero_fp
20327 \fi:
20328 \if_meaning:w 2 #1
20329 \__fp_case_return_o:Nw \c_inf_fp
20330 \fi:
20331 \if_meaning:w 2 #3
20332 \__fp_case_return_o:Nw \c_inf_fp
20333 \else:
20334 \__fp_case_use:nw
20335 {
20336 \__fp_division_by_zero_o:NNww \c_inf_fp ^
20337 \s__fp \__fp_chk:w #1 #2 \__fp_sep:
20338 }
20339 \fi:
20340 \s__fp \__fp_chk:w #3#4
20341 }
20342 \cs_new:Npn \__fp_pow_normal_o:ww
20343 \s__fp \__fp_chk:w 1 #1#2#3\__fp_sep: \s__fp \__fp_chk:w #4#5
20344 {
20345 \if:w 0 \__fp_str_if_eq:nn { #2 #3 } { 1 {1000} {0000} {0000} {0000} }
20346 \if_int_compare:w #4 #1 = 32 \exp_stop_f:
20347 \exp_after:wN \__fp_case_return_ii_o:ww
20348 \fi:
20349 \__fp_case_return_o:Nww \c_one_fp
20350 \fi:
20351 \if_case:w #4 \exp_stop_f:
20352 \or:
20353 \exp_after:wN \__fp_pow_npos_o:Nww
20354 \exp_after:wN #5
20355 \or:
20356 \if_meaning:w 2 #5 \exp_after:wN \reverse_if:N \fi:
20357 \if_int_compare:w #2 > \c_zero_int
20358 \exp_after:wN \__fp_case_return_o:Nww
20359 \exp_after:wN \c_inf_fp
20360 \else:
20361 \exp_after:wN \__fp_case_return_o:Nww
20362 \exp_after:wN \c_zero_fp
20363 \fi:
20364 \or:
20365 \__fp_case_return_ii_o:ww
20366 \fi:
20367 \s__fp \__fp_chk:w 1 #1 {#2} #3 \__fp_sep:
20368 \s__fp \__fp_chk:w #4 #5
20369 }
20370 \cs_new:Npn \__fp_pow_npos_o:Nww #1 \s__fp \__fp_chk:w 1#2#3
20371 {
20372 \exp_after:wN \__fp_sanitize:Nw
20373 \exp_after:wN 0
20374 \int_value:w
20375 \if:w #1 \if_int_compare:w #3 > \c_zero_int 0 \else: 2 \fi:
20376 \exp_after:wN \__fp_pow_npos_aux:NNnww
20377 \exp_after:wN +
20378 \exp_after:wN \__fp_fixed_to_float_o:wN
20379 \else:
20380 \exp_after:wN \__fp_pow_npos_aux:NNnww
20381 \exp_after:wN -
20382 \exp_after:wN \__fp_fixed_inv_to_float_o:wN
20383 \fi:
20384 {#3}
20385 }
20386 \cs_new:Npn \__fp_pow_npos_aux:NNnww
20387 #1#2#3#4#5\__fp_sep: \s__fp \__fp_chk:w 1#6#7#8\__fp_sep:
20388 {
20389 #1
20390 \__fp_int_eval:w
20391 \__fp_ln_significand:NNNNnnnN #4#5
20392 \__fp_pow_exponent:wnN {#3}
20393 \__fp_fixed_mul:wwn #8 {0000}{0000} \__fp_sep:
20394 \__fp_pow_B:wwN #7\__fp_sep:
20395 #1 #2 0 % fixed_to_float_o:wN
20396 }
20397 \cs_new:Npn \__fp_pow_exponent:wnN #1\__fp_sep: #2
20398 {
20399 \if_int_compare:w #2 > \c_zero_int
20400 \exp_after:wN \__fp_pow_exponent:Nwnnnnnw % n\ln(10) - (-\ln(x))
20401 \exp_after:wN +
20402 \else:
20403 \exp_after:wN \__fp_pow_exponent:Nwnnnnnw % -(|n|\ln(10) + (-\ln(x)))
20404 \exp_after:wN -
20405 \fi:
20406 #2\__fp_sep: #1\__fp_sep:
20407 }
20408 \cs_new:Npn \__fp_pow_exponent:Nwnnnnnw #1#2\__fp_sep: #3#4#5#6#7#8\__fp_sep:
20409 { %^^A todo: use that in ln.
20410 \exp_after:wN \__fp_fixed_mul_after:wwn
20411 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
20412 \exp_after:wN \__fp_pack:NNNNNw
20413 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
20414 #1#2*23025 - #1 #3
20415 \exp_after:wN \__fp_pack:NNNNNw
20416 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
20417 #1 #2*8509 - #1 #4
20418 \exp_after:wN \__fp_pack:NNNNNw
20419 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
20420 #1 #2*2994 - #1 #5
20421 \exp_after:wN \__fp_pack:NNNNNw
20422 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
20423 #1 #2*0456 - #1 #6
20424 \exp_after:wN \__fp_pack:NNNNNw
20425 \int_value:w \__fp_int_eval:w \c__fp_trailing_shift_int
20426 #1 #2*8401 - #1 #7
20427 #1 ( #2*7991 - #8 ) / 1 0000 \__fp_sep: \__fp_sep:
20428 }
20429 \cs_new:Npn \__fp_pow_B:wwN #1#2#3#4#5#6\__fp_sep: #7\__fp_sep:
20430 {
20431 \if_int_compare:w #7 < \c_zero_int
20432 \exp_after:wN \__fp_pow_C_neg:w \int_value:w -
20433 \else:
20434 \if_int_compare:w #7 < 22 \exp_stop_f:
20435 \exp_after:wN \__fp_pow_C_pos:w \int_value:w
20436 \else:
20437 \exp_after:wN \__fp_pow_C_overflow:w \int_value:w
20438 \fi:
20439 \fi:
20440 #7 \exp_after:wN \__fp_sep:
20441 \int_value:w \__fp_int_eval:w 10 0000 + #1 \__fp_int_eval_end:
20442 #2#3#4#5#6 0000 0000 0000 0000 0000 0000 \__fp_sep: %^^A todo: how many 0?
20443 }
20444 \cs_new:Npn \__fp_pow_C_overflow:w #1\__fp_sep: #2\__fp_sep: #3
20445 {
20446 + 2 * \c__fp_max_exponent_int
20447 \exp_after:wN \__fp_fixed_continue:wn \c__fp_one_fixed_tl
20448 }
20449 \cs_new:Npn \__fp_pow_C_neg:w #1 \__fp_sep: 1
20450 {
20451 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_pow_C_pack:w
20452 \prg_replicate:nn {#1} {0}
20453 }
20454 \cs_new:Npn \__fp_pow_C_pos:w #1\__fp_sep: 1
20455 { \__fp_pow_C_pos_loop:wN #1\__fp_sep: }
20456 \cs_new:Npn \__fp_pow_C_pos_loop:wN #1\__fp_sep: #2
20457 {
20458 \if_meaning:w 0 #1
20459 \exp_after:wN \__fp_pow_C_pack:w
20460 \exp_after:wN #2
20461 \else:
20462 \if_meaning:w 0 #2
20463 \exp_after:wN \__fp_pow_C_pos_loop:wN \int_value:w
20464 \else:
20465 \exp_after:wN \__fp_pow_C_overflow:w \int_value:w
20466 \fi:
20467 \__fp_int_eval:w #1 - 1 \exp_after:wN \__fp_sep:
20468 \fi:
20469 }
20470 \cs_new:Npn \__fp_pow_C_pack:w
20471 {
20472 \exp_after:wN \__fp_exp_large:NwN
20473 \exp_after:wN 5
20474 \c__fp_one_fixed_tl
20475 }
20476 \cs_new:Npn \__fp_pow_neg:www
20477 \s__fp \__fp_chk:w #1#2\__fp_sep: #3\__fp_sep: #4\__fp_sep:
20478 {
20479 \if_case:w \__fp_pow_neg_case:w #4 \__fp_sep:
20480 \exp_after:wN \__fp_pow_neg_aux:wNN
20481 \or:
20482 \if_int_compare:w \__fp_int_eval:w #1 / 2 = \c_one_int
20483 \__fp_invalid_operation_o:Nww ^ #3\__fp_sep: #4\__fp_sep:
20484 \exp:w \exp_end_continue_f:w
20485 \exp_after:wN \exp_after:wN
20486 \exp_after:wN \__fp_use_none_until_s:w
20487 \fi:
20488 \fi:
20489 \__fp_exp_after_o:w
20490 \s__fp \__fp_chk:w #1#2\__fp_sep:
20491 }
20492 \cs_new:Npn \__fp_pow_neg_aux:wNN #1 \s__fp \__fp_chk:w #2#3
20493 {
20494 \exp_after:wN \__fp_exp_after_o:w
20495 \exp_after:wN \s__fp
20496 \exp_after:wN \__fp_chk:w
20497 \exp_after:wN #2
20498 \int_value:w \__fp_int_eval:w 2 - #3 \__fp_int_eval_end:
20499 }
20500 \cs_new:Npn \__fp_pow_neg_case:w \s__fp \__fp_chk:w #1#2#3\__fp_sep:
20501 {
20502 \if_case:w #1 \exp_stop_f:
20503 -1
20504 \or: \__fp_pow_neg_case_aux:nnnnn #3
20505 \or: -1
20506 \else: 1
20507 \fi:
20508 \exp_stop_f:
20509 }
20510 \cs_new:Npn \__fp_pow_neg_case_aux:nnnnn #1#2#3#4#5
20511 {
20512 \if_int_compare:w #1 > \c__fp_prec_int
20513 -1
20514 \else:
20515 \__fp_decimate:nNnnnn { \c__fp_prec_int - #1 }
20516 \__fp_pow_neg_case_aux:Nnnw
20517 {#2} {#3} {#4} {#5}
20518 \fi:
20519 }
20520 \cs_new:Npn \__fp_pow_neg_case_aux:Nnnw #1#2#3#4 \__fp_sep:
20521 {
20522 \if_meaning:w 0 #1
20523 \if_int_odd:w #3 \exp_stop_f:
20524 0
20525 \else:
20526 -1
20527 \fi:
20528 \else:
20529 1
20530 \fi:
20531 }
20532 \int_const:Nn \c__fp_fact_max_arg_int { 3248 }
20533 \cs_new:Npn \__fp_fact_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20534 {
20535 \if_case:w #2 \exp_stop_f:
20536 \__fp_case_return_o:Nw \c_one_fp
20537 \or:
20538 \or:
20539 \if_meaning:w 0 #3
20540 \exp_after:wN \__fp_case_return_same_o:w
20541 \fi:
20542 \or:
20543 \__fp_case_return_same_o:w
20544 \fi:
20545 \if_meaning:w 2 #3
20546 \__fp_case_use:nw { \__fp_invalid_operation_o:fw { fact } }
20547 \fi:
20548 \__fp_fact_pos_o:w
20549 \s__fp \__fp_chk:w #2 #3 #4 \__fp_sep:
20550 }
20551 \cs_new:Npn \__fp_fact_pos_o:w #1\__fp_sep:
20552 {
20553 \__fp_small_int:wTF #1\__fp_sep:
20554 { \__fp_fact_int_o:n }
20555 { \__fp_invalid_operation_o:fw { fact } #1\__fp_sep: }
20556 }
20557 \cs_new:Npn \__fp_fact_int_o:n #1
20558 {
20559 \if_int_compare:w #1 > \c__fp_fact_max_arg_int
20560 \__fp_case_return:nw
20561 {
20562 \exp_after:wN \exp_after:wN \exp_after:wN \__fp_overflow:w
20563 \exp_after:wN \c_inf_fp
20564 }
20565 \fi:
20566 \exp_after:wN \__fp_sanitize:Nw
20567 \exp_after:wN 0
20568 \int_value:w \__fp_int_eval:w
20569 \__fp_fact_loop_o:w #1 . 4 , { 1 } { } { } { } { } { } \__fp_sep:
20570 }
20571 \cs_new:Npn \__fp_fact_loop_o:w #1 . #2 \__fp_sep:
20572 {
20573 \if_int_compare:w #1 < 12 \exp_stop_f:
20574 \__fp_fact_small_o:w #1
20575 \fi:
20576 \exp_after:wN \__fp_ep_mul:wwwwn
20577 \exp_after:wN 4 \exp_after:wN ,
20578 \exp_after:wN { \int_value:w \__fp_int_eval:w #1 * (#1 - 1) }
20579 { } { } { } { } { } \__fp_sep:
20580 #2 \__fp_sep:
20581 {
20582 \exp_after:wN \__fp_fact_loop_o:w
20583 \int_value:w \__fp_int_eval:w #1 - 2 .
20584 }
20585 }
20586 \cs_new:Npn \__fp_fact_small_o:w #1 \fi: #2 \__fp_sep: #3 \__fp_sep: #4
20587 {
20588 \fi:
20589 \exp_after:wN \__fp_ep_mul:wwwwn
20590 \exp_after:wN 4 \exp_after:wN ,
20591 \exp_after:wN
20592 {
20593 \int_value:w
20594 \if_case:w #1 \exp_stop_f:
20595 1 \or: 1 \or: 2 \or: 6 \or: 24 \or: 120 \or: 720 \or: 5040
20596 \or: 40320 \or: 362880 \or: 3628800 \or: 39916800
20597 \fi:
20598 } { } { } { } { } { } \__fp_sep:
20599 #3 \__fp_sep:
20600 \__fp_ep_to_float_o:wwN 0
20601 }
20602 %% File: l3fp-trig.dtx
20603 \tl_map_inline:nn
20604 {
20605 {acos} {acsc} {asec} {asin}
20606 {cos} {cot} {csc} {sec} {sin} {tan}
20607 }
20608 {
20609 \cs_new:cpe { __fp_parse_word_#1:N }
20610 {
20611 \exp_not:N \__fp_parse_unary_function:NNN
20612 \exp_not:c { __fp_#1_o:w }
20613 \exp_not:N \use_i:nn
20614 }
20615 \cs_new:cpe { __fp_parse_word_#1d:N }
20616 {
20617 \exp_not:N \__fp_parse_unary_function:NNN
20618 \exp_not:c { __fp_#1_o:w }
20619 \exp_not:N \use_ii:nn
20620 }
20621 }
20622 \cs_new:Npn \__fp_parse_word_acot:N
20623 { \__fp_parse_function:NNN \__fp_acot_o:Nw \use_i:nn }
20624 \cs_new:Npn \__fp_parse_word_acotd:N
20625 { \__fp_parse_function:NNN \__fp_acot_o:Nw \use_ii:nn }
20626 \cs_new:Npn \__fp_parse_word_atan:N
20627 { \__fp_parse_function:NNN \__fp_atan_o:Nw \use_i:nn }
20628 \cs_new:Npn \__fp_parse_word_atand:N
20629 { \__fp_parse_function:NNN \__fp_atan_o:Nw \use_ii:nn }
20630 \cs_new:Npn \__fp_sin_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20631 {
20632 \if_case:w #2 \exp_stop_f:
20633 \__fp_case_return_same_o:w
20634 \or: \__fp_case_use:nw
20635 {
20636 \__fp_trig:NNNNNwn #1 \__fp_sin_series_o:NNwwww
20637 \__fp_ep_to_float_o:wwN #3 0
20638 }
20639 \or: \__fp_case_use:nw
20640 { \__fp_invalid_operation_o:fw { #1 { sin } { sind } } }
20641 \else: \__fp_case_return_same_o:w
20642 \fi:
20643 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
20644 }
20645 \cs_new:Npn \__fp_cos_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
20646 {
20647 \if_case:w #2 \exp_stop_f:
20648 \__fp_case_return_o:Nw \c_one_fp
20649 \or: \__fp_case_use:nw
20650 {
20651 \__fp_trig:NNNNNwn #1 \__fp_sin_series_o:NNwwww
20652 \__fp_ep_to_float_o:wwN 0 2
20653 }
20654 \or: \__fp_case_use:nw
20655 { \__fp_invalid_operation_o:fw { #1 { cos } { cosd } } }
20656 \else: \__fp_case_return_same_o:w
20657 \fi:
20658 \s__fp \__fp_chk:w #2 #3\__fp_sep:
20659 }
20660 \cs_new:Npn \__fp_csc_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20661 {
20662 \if_case:w #2 \exp_stop_f:
20663 \__fp_cot_zero_o:Nfw #3 { #1 { csc } { cscd } }
20664 \or: \__fp_case_use:nw
20665 {
20666 \__fp_trig:NNNNNwn #1 \__fp_sin_series_o:NNwwww
20667 \__fp_ep_inv_to_float_o:wwN #3 0
20668 }
20669 \or: \__fp_case_use:nw
20670 { \__fp_invalid_operation_o:fw { #1 { csc } { cscd } } }
20671 \else: \__fp_case_return_same_o:w
20672 \fi:
20673 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
20674 }
20675 \cs_new:Npn \__fp_sec_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
20676 {
20677 \if_case:w #2 \exp_stop_f:
20678 \__fp_case_return_o:Nw \c_one_fp
20679 \or: \__fp_case_use:nw
20680 {
20681 \__fp_trig:NNNNNwn #1 \__fp_sin_series_o:NNwwww
20682 \__fp_ep_inv_to_float_o:wwN 0 2
20683 }
20684 \or: \__fp_case_use:nw
20685 { \__fp_invalid_operation_o:fw { #1 { sec } { secd } } }
20686 \else: \__fp_case_return_same_o:w
20687 \fi:
20688 \s__fp \__fp_chk:w #2 #3\__fp_sep:
20689 }
20690 \cs_new:Npn \__fp_tan_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20691 {
20692 \if_case:w #2 \exp_stop_f:
20693 \__fp_case_return_same_o:w
20694 \or: \__fp_case_use:nw
20695 {
20696 \__fp_trig:NNNNNwn #1
20697 \__fp_tan_series_o:NNwwww 0 #3 1
20698 }
20699 \or: \__fp_case_use:nw
20700 { \__fp_invalid_operation_o:fw { #1 { tan } { tand } } }
20701 \else: \__fp_case_return_same_o:w
20702 \fi:
20703 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
20704 }
20705 \cs_new:Npn \__fp_cot_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
20706 {
20707 \if_case:w #2 \exp_stop_f:
20708 \__fp_cot_zero_o:Nfw #3 { #1 { cot } { cotd } }
20709 \or: \__fp_case_use:nw
20710 {
20711 \__fp_trig:NNNNNwn #1
20712 \__fp_tan_series_o:NNwwww 2 #3 3
20713 }
20714 \or: \__fp_case_use:nw
20715 { \__fp_invalid_operation_o:fw { #1 { cot } { cotd } } }
20716 \else: \__fp_case_return_same_o:w
20717 \fi:
20718 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
20719 }
20720 \cs_new:Npn \__fp_cot_zero_o:Nfw #1#2#3 \fi:
20721 {
20722 \fi:
20723 \token_if_eq_meaning:NNTF 0 #1
20724 { \exp_args:NNf \__fp_division_by_zero_o:Nnw \c_inf_fp }
20725 { \exp_args:NNf \__fp_division_by_zero_o:Nnw \c_minus_inf_fp }
20726 {#2}
20727 }
20728 \cs_new:Npn \__fp_trig:NNNNNwn #1#2#3#4#5 \s__fp \__fp_chk:w 1#6#7#8\__fp_sep:
20729 {
20730 \exp_after:wN #2
20731 \exp_after:wN #3
20732 \exp_after:wN #4
20733 \int_value:w \__fp_int_eval:w #5
20734 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN
20735 \if_int_compare:w #7 > #1 0 1 \exp_stop_f:
20736 #1 \__fp_trig_large:ww \__fp_trigd_large:ww
20737 \else:
20738 #1 \__fp_trig_small:ww \__fp_trigd_small:ww
20739 \fi:
20740 #7,#8{0000}{0000}\__fp_sep:
20741 }
20742 \cs_new:Npn \__fp_trig_small:ww #1,#2\__fp_sep:
20743 { \__fp_ep_to_fixed:wwn #1,#2\__fp_sep: . #1,#2\__fp_sep: }
20744 \cs_new:Npn \__fp_trigd_small:ww #1,#2\__fp_sep:
20745 {
20746 \__fp_ep_mul_raw:wwwwN
20747 -1,{1745}{3292}{5199}{4329}{5769}{2369}\__fp_sep: #1,#2\__fp_sep:
20748 \__fp_trig_small:ww
20749 }
20750 \cs_new:Npn \__fp_trigd_large:ww #1, #2#3#4#5#6#7\__fp_sep:
20751 {
20752 \exp_after:wN \__fp_pack_eight:wNNNNNNNN
20753 \exp_after:wN \__fp_pack_eight:wNNNNNNNN
20754 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
20755 \exp_after:wN \__fp_pack_twice_four:wNNNNNNNN
20756 \exp_after:wN \__fp_trigd_large_auxi:nnnnwNNNN
20757 \exp_after:wN \__fp_sep:
20758 \exp:w \exp_end_continue_f:w
20759 \prg_replicate:nn { \int_max:nn { 22 - #1 } { 0 } } { 0 }
20760 #2#3#4#5#6#7 0000 0000 0000 !
20761 }
20762 \cs_new:Npn \__fp_trigd_large_auxi:nnnnwNNNN #1#2#3#4#5\__fp_sep: #6#7#8#9
20763 {
20764 \exp_after:wN \__fp_trigd_large_auxii:wNw
20765 \int_value:w \__fp_int_eval:w #1 + #2
20766 - (#1 + #2 - 4) / 9 * 9 \__fp_int_eval_end:
20767 #3\__fp_sep:
20768 #4\__fp_sep: #5{#6#7#8#9}\__fp_sep:
20769 }
20770 \cs_new:Npn \__fp_trigd_large_auxii:wNw #1\__fp_sep: #2#3\__fp_sep:
20771 {
20772 + (#1#2 - 4) / 9 * 2
20773 \exp_after:wN \__fp_trigd_large_auxiii:www
20774 \int_value:w \__fp_int_eval:w #1#2
20775 - (#1#2 - 4) / 9 * 9 \__fp_int_eval_end: #3 \__fp_sep:
20776 }
20777 \cs_new:Npn \__fp_trigd_large_auxiii:www #1\__fp_sep: #2\__fp_sep: #3!
20778 {
20779 \if_int_compare:w #1 < 4500 \exp_stop_f:
20780 \exp_after:wN \__fp_use_i_until_s:nw
20781 \exp_after:wN \__fp_fixed_continue:wn
20782 \else:
20783 + 1
20784 \fi:
20785 \__fp_fixed_sub:wwn {9000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
20786 {#1}#2{0000}{0000}\__fp_sep:
20787 { \__fp_trigd_small:ww 2, }
20788 }
20789 \intarray_const_from_clist:Nn \c__fp_trig_intarray
20790 {
20791 100000000, 100000000, 115915494, 130918953, 135768883, 176337251,
20792 143620344, 159645740, 145644874, 176673440, 158896797, 163422653,
20793 150901138, 102766253, 108595607, 128427267, 157958036, 189291184,
20794 161145786, 152877967, 141073169, 198392292, 139966937, 140907757,
20795 130777463, 196925307, 168871739, 128962173, 197661693, 136239024,
20796 117236290, 111832380, 111422269, 197557159, 140461890, 108690267,
20797 139561204, 189410936, 193784408, 155287230, 199946443, 140024867,
20798 123477394, 159610898, 132309678, 130749061, 166986462, 180469944,
20799 186521878, 181574786, 156696424, 110389958, 174139348, 160998386,
20800 180991999, 162442875, 158517117, 188584311, 117518767, 116054654,
20801 175369880, 109739460, 136475933, 137680593, 102494496, 163530532,
20802 171567755, 103220324, 177781639, 171660229, 146748119, 159816584,
20803 106060168, 103035998, 113391198, 174988327, 186654435, 127975507,
20804 100162406, 177564388, 184957131, 108801221, 199376147, 168137776,
20805 147378906, 133068046, 145797848, 117613124, 127314069, 196077502,
20806 145002977, 159857089, 105690279, 167851315, 125210016, 131774602,
20807 109248116, 106240561, 145620314, 164840892, 148459191, 143521157,
20808 154075562, 100871526, 160680221, 171591407, 157474582, 172259774,
20809 162853998, 175155329, 139081398, 117724093, 158254797, 107332871,
20810 190406999, 175907657, 170784934, 170393589, 182808717, 134256403,
20811 166895116, 162545705, 194332763, 112686500, 126122717, 197115321,
20812 112599504, 138667945, 103762556, 108363171, 116952597, 158128224,
20813 194162333, 143145106, 112353687, 185631136, 136692167, 114206974,
20814 169601292, 150578336, 105311960, 185945098, 139556718, 170995474,
20815 165104316, 123815517, 158083944, 129799709, 199505254, 138756612,
20816 194458833, 106846050, 178529151, 151410404, 189298850, 163881607,
20817 176196993, 107341038, 199957869, 118905980, 193737772, 106187543,
20818 122271893, 101366255, 126123878, 103875388, 181106814, 106765434,
20819 108282785, 126933426, 179955607, 107903860, 160352738, 199624512,
20820 159957492, 176297023, 159409558, 143011648, 129641185, 157771240,
20821 157544494, 157021789, 176979240, 194903272, 194770216, 164960356,
20822 153181535, 144003840, 168987471, 176915887, 163190966, 150696440,
20823 147769706, 187683656, 177810477, 197954503, 153395758, 130188183,
20824 186879377, 166124814, 195305996, 155802190, 183598751, 103512712,
20825 190432315, 180498719, 168687775, 194656634, 162210342, 104440855,
20826 149785037, 192738694, 129353661, 193778292, 187359378, 143470323,
20827 102371458, 137923557, 111863634, 119294601, 183182291, 196416500,
20828 187830793, 131353497, 179099745, 186492902, 167450609, 189368909,
20829 145883050, 133703053, 180547312, 132158094, 131976760, 132283131,
20830 141898097, 149822438, 133517435, 169898475, 101039500, 168388003,
20831 197867235, 199608024, 100273901, 108749548, 154787923, 156826113,
20832 199489032, 168997427, 108349611, 149208289, 103776784, 174303550,
20833 145684560, 183671479, 130845672, 133270354, 185392556, 120208683,
20834 193240995, 162211753, 131839402, 109707935, 170774965, 149880868,
20835 160663609, 168661967, 103747454, 121028312, 119251846, 122483499,
20836 111611495, 166556037, 196967613, 199312829, 196077608, 127799010,
20837 107830360, 102338272, 198790854, 102387615, 157445430, 192601191,
20838 100543379, 198389046, 154921248, 129516070, 172853005, 122721023,
20839 160175233, 113173179, 175931105, 103281551, 109373913, 163964530,
20840 157926071, 180083617, 195487672, 146459804, 173977292, 144810920,
20841 109371257, 186918332, 189588628, 139904358, 168666639, 175673445,
20842 114095036, 137327191, 174311388, 106638307, 125923027, 159734506,
20843 105482127, 178037065, 133778303, 121709877, 134966568, 149080032,
20844 169885067, 141791464, 168350828, 116168533, 114336160, 173099514,
20845 198531198, 119733758, 144420984, 116559541, 152250643, 139431286,
20846 144403838, 183561508, 179771645, 101706470, 167518774, 156059160,
20847 187168578, 157939226, 123475633, 117111329, 198655941, 159689071,
20848 198506887, 144230057, 151919770, 156900382, 118392562, 120338742,
20849 135362568, 108354156, 151729710, 188117217, 195936832, 156488518,
20850 174997487, 108553116, 159830610, 113921445, 144601614, 188452770,
20851 125114110, 170248521, 173974510, 138667364, 103872860, 109967489,
20852 131735618, 112071174, 104788993, 168886556, 192307848, 150230570,
20853 157144063, 163863202, 136852010, 174100574, 185922811, 115721968,
20854 100397824, 175953001, 166958522, 112303464, 118773650, 143546764,
20855 164565659, 171901123, 108476709, 193097085, 191283646, 166919177,
20856 169387914, 133315566, 150669813, 121641521, 100895711, 172862384,
20857 126070678, 145176011, 113450800, 169947684, 122356989, 162488051,
20858 157759809, 153397080, 185475059, 175362656, 149034394, 145420581,
20859 178864356, 183042000, 131509559, 147434392, 152544850, 167491429,
20860 108647514, 142303321, 133245695, 111634945, 167753939, 142403609,
20861 105438335, 152829243, 142203494, 184366151, 146632286, 102477666,
20862 166049531, 140657343, 157553014, 109082798, 180914786, 169343492,
20863 127376026, 134997829, 195701816, 119643212, 133140475, 176289748,
20864 140828911, 174097478, 126378991, 181699939, 148749771, 151989818,
20865 172666294, 160183053, 195832752, 109236350, 168538892, 128468247,
20866 125997252, 183007668, 156937583, 165972291, 198244297, 147406163,
20867 181831139, 158306744, 134851692, 185973832, 137392662, 140243450,
20868 119978099, 140402189, 161348342, 173613676, 144991382, 171541660,
20869 163424829, 136374185, 106122610, 186132119, 198633462, 184709941,
20870 183994274, 129559156, 128333990, 148038211, 175011612, 111667205,
20871 119125793, 103552929, 124113440, 131161341, 112495318, 138592695,
20872 184904438, 146807849, 109739828, 108855297, 104515305, 139914009,
20873 188698840, 188365483, 166522246, 168624087, 125401404, 100911787,
20874 142122045, 123075334, 173972538, 114940388, 141905868, 142311594,
20875 163227443, 139066125, 116239310, 162831953, 123883392, 113153455,
20876 163815117, 152035108, 174595582, 101123754, 135976815, 153401874,
20877 107394340, 136339780, 138817210, 104531691, 182951948, 179591767,
20878 139541778, 179243527, 161740724, 160593916, 102732282, 187946819,
20879 136491289, 149714953, 143255272, 135916592, 198072479, 198580612,
20880 169007332, 118844526, 179433504, 155801952, 149256630, 162048766,
20881 116134365, 133992028, 175452085, 155344144, 109905129, 182727454,
20882 165911813, 122232840, 151166615, 165070983, 175574337, 129548631,
20883 120411217, 116380915, 160616116, 157320000, 183306114, 160618128,
20884 103262586, 195951602, 146321661, 138576614, 180471993, 127077713,
20885 116441201, 159496011, 106328305, 120759583, 148503050, 179095584,
20886 198298218, 167402898, 138551383, 123957020, 180763975, 150429225,
20887 198476470, 171016426, 197438450, 143091658, 164528360, 132493360,
20888 143546572, 137557916, 113663241, 120457809, 196971566, 134022158,
20889 180545794, 131328278, 100552461, 132088901, 187421210, 192448910,
20890 141005215, 149680971, 113720754, 100571096, 134066431, 135745439,
20891 191597694, 135788920, 179342561, 177830222, 137011486, 142492523,
20892 192487287, 113132021, 176673607, 156645598, 127260957, 141566023,
20893 143787436, 129132109, 174858971, 150713073, 191040726, 143541417,
20894 197057222, 165479803, 181512759, 157912400, 125344680, 148220261,
20895 173422990, 101020483, 106246303, 137964746, 178190501, 181183037,
20896 151538028, 179523433, 141955021, 135689770, 191290561, 143178787,
20897 192086205, 174499925, 178975690, 118492103, 124206471, 138519113,
20898 188147564, 102097605, 154895793, 178514140, 141453051, 151583964,
20899 128232654, 106020603, 131189158, 165702720, 186250269, 191639375,
20900 115278873, 160608114, 155694842, 110322407, 177272742, 116513642,
20901 134366992, 171634030, 194053074, 180652685, 109301658, 192136921,
20902 141431293, 171341061, 157153714, 106203978, 147618426, 150297807,
20903 186062669, 169960809, 118422347, 163350477, 146719017, 145045144,
20904 161663828, 146208240, 186735951, 102371302, 190444377, 194085350,
20905 134454426, 133413062, 163074595, 113830310, 122931469, 134466832,
20906 185176632, 182415152, 110179422, 164439571, 181217170, 121756492,
20907 119644493, 196532222, 118765848, 182445119, 109401340, 150443213,
20908 198586286, 121083179, 139396084, 143898019, 114787389, 177233102,
20909 186310131, 148695521, 126205182, 178063494, 157118662, 177825659,
20910 188310053, 151552316, 165984394, 109022180, 163144545, 121212978,
20911 197344714, 188741258, 126822386, 102360271, 109981191, 152056882,
20912 134723983, 158013366, 106837863, 128867928, 161973236, 172536066,
20913 185216856, 132011948, 197807339, 158419190, 166595838, 167852941,
20914 124187182, 117279875, 106103946, 106481958, 157456200, 160892122,
20915 184163943, 173846549, 158993202, 184812364, 133466119, 170732430,
20916 195458590, 173361878, 162906318, 150165106, 126757685, 112163575,
20917 188696307, 145199922, 100107766, 176830946, 198149756, 122682434,
20918 179367131, 108412102, 119520899, 148191244, 140487511, 171059184,
20919 141399078, 189455775, 118462161, 190415309, 134543802, 180893862,
20920 180732375, 178615267, 179711433, 123241969, 185780563, 176301808,
20921 184386640, 160717536, 183213626, 129671224, 126094285, 140110963,
20922 121826276, 151201170, 122552929, 128965559, 146082049, 138409069,
20923 107606920, 103954646, 119164002, 115673360, 117909631, 187289199,
20924 186343410, 186903200, 157966371, 103128612, 135698881, 176403642,
20925 152540837, 109810814, 183519031, 121318624, 172281810, 150845123,
20926 169019064, 166322359, 138872454, 163073727, 128087898, 130041018,
20927 194859136, 173742589, 141812405, 167291912, 138003306, 134499821,
20928 196315803, 186381054, 124578934, 150084553, 128031351, 118843410,
20929 107373060, 159565443, 173624887, 171292628, 198074235, 139074061,
20930 178690578, 144431052, 174262641, 176783005, 182214864, 162289361,
20931 192966929, 192033046, 169332843, 181580535, 164864073, 118444059,
20932 195496893, 153773183, 167266131, 130108623, 158802128, 180432893,
20933 144562140, 147978945, 142337360, 158506327, 104399819, 132635916,
20934 168734194, 136567839, 101281912, 120281622, 195003330, 112236091,
20935 185875592, 101959081, 122415367, 194990954, 148881099, 175891989,
20936 108115811, 163538891, 163394029, 123722049, 184837522, 142362091,
20937 100834097, 156679171, 100841679, 157022331, 178971071, 102928884,
20938 189701309, 195339954, 124415335, 106062584, 139214524, 133864640,
20939 134324406, 157317477, 155340540, 144810061, 177612569, 108474646,
20940 114329765, 143900008, 138265211, 145210162, 136643111, 197987319,
20941 102751191, 144121361, 169620456, 193602633, 161023559, 162140467,
20942 102901215, 167964187, 135746835, 187317233, 110047459, 163339773,
20943 124770449, 118885134, 141536376, 100915375, 164267438, 145016622,
20944 113937193, 106748706, 128815954, 164819775, 119220771, 102367432,
20945 189062690, 170911791, 194127762, 112245117, 123546771, 115640433,
20946 135772061, 166615646, 174474627, 130562291, 133320309, 153340551,
20947 138417181, 194605321, 150142632, 180008795, 151813296, 175497284,
20948 167018836, 157425342, 150169942, 131069156, 134310662, 160434122,
20949 105213831, 158797111, 150754540, 163290657, 102484886, 148697402,
20950 187203725, 198692811, 149360627, 140384233, 128749423, 132178578,
20951 177507355, 171857043, 178737969, 134023369, 102911446, 196144864,
20952 197697194, 134527467, 144296030, 189437192, 154052665, 188907106,
20953 162062575, 150993037, 199766583, 167936112, 181374511, 104971506,
20954 115378374, 135795558, 167972129, 135876446, 130937572, 103221320,
20955 124605656, 161129971, 131027586, 191128460, 143251843, 143269155,
20956 129284585, 173495971, 150425653, 199302112, 118494723, 121323805,
20957 116549802, 190991967, 168151180, 122483192, 151273721, 199792134,
20958 133106764, 121874844, 126215985, 112167639, 167793529, 182985195,
20959 185453921, 106957880, 158685312, 132775454, 133229161, 198905318,
20960 190537253, 191582222, 192325972, 178133427, 181825606, 148823337,
20961 160719681, 101448145, 131983362, 137910767, 112550175, 128826351,
20962 183649210, 135725874, 110356573, 189469487, 154446940, 118175923,
20963 106093708, 128146501, 185742532, 149692127, 164624247, 183221076,
20964 154737505, 168198834, 156410354, 158027261, 125228550, 131543250,
20965 139591848, 191898263, 104987591, 115406321, 103542638, 190012837,
20966 142615518, 178773183, 175862355, 117537850, 169565995, 170028011,
20967 158412588, 170150030, 117025916, 174630208, 142412449, 112839238,
20968 105257725, 114737141, 123102301, 172563968, 130555358, 132628403,
20969 183638157, 168682846, 143304568, 105994018, 170010719, 152092970,
20970 117799058, 132164175, 179868116, 158654714, 177489647, 116547948,
20971 183121404, 131836079, 184431405, 157311793, 149677763, 173989893,
20972 102277656, 107058530, 140837477, 152640947, 143507039, 152145247,
20973 101683884, 107090870, 161471944, 137225650, 128231458, 172995869,
20974 173831689, 171268519, 139042297, 111072135, 107569780, 137262545,
20975 181410950, 138270388, 198736451, 162848201, 180468288, 120582913,
20976 153390138, 135649144, 130040157, 106509887, 192671541, 174507066,
20977 186888783, 143805558, 135011967, 145862340, 180595327, 124727843,
20978 182925939, 157715840, 136885940, 198993925, 152416883, 178793572,
20979 179679516, 154076673, 192703125, 164187609, 162190243, 104699348,
20980 159891990, 160012977, 174692145, 132970421, 167781726, 115178506,
20981 153008552, 155999794, 102099694, 155431545, 127458567, 104403686,
20982 168042864, 184045128, 181182309, 179349696, 127218364, 192935516,
20983 120298724, 169583299, 148193297, 183358034, 159023227, 105261254,
20984 121144370, 184359584, 194433836, 138388317, 175184116, 108817112,
20985 151279233, 137457721, 193398208, 119005406, 132929377, 175306906,
20986 160741530, 149976826, 147124407, 176881724, 186734216, 185881509,
20987 191334220, 175930947, 117385515, 193408089, 157124410, 163472089,
20988 131949128, 180783576, 131158294, 100549708, 191802336, 165960770,
20989 170927599, 101052702, 181508688, 197828549, 143403726, 142729262,
20990 110348701, 139928688, 153550062, 106151434, 130786653, 196085995,
20991 100587149, 139141652, 106530207, 100852656, 124074703, 166073660,
20992 153338052, 163766757, 120188394, 197277047, 122215363, 138511354,
20993 183463624, 161985542, 159938719, 133367482, 104220974, 149956672,
20994 170250544, 164232439, 157506869, 159133019, 137469191, 142980999,
20995 134242305, 150172665, 121209241, 145596259, 160554427, 159095199,
20996 168243130, 184279693, 171132070, 121049823, 123819574, 171759855,
20997 119501864, 163094029, 175943631, 194450091, 191506160, 149228764,
20998 132319212, 197034460, 193584259, 126727638, 168143633, 109856853,
20999 127860243, 132141052, 133076065, 188414958, 158718197, 107124299,
21000 159592267, 181172796, 144388537, 196763139, 127431422, 179531145,
21001 100064922, 112650013, 132686230, 121550837,
21002 }
21003 \cs_new:Npn \__fp_trig_large:ww #1, #2#3#4#5#6\__fp_sep:
21004 {
21005 \exp_after:wN \__fp_trig_large_auxi:w
21006 \int_value:w \__fp_int_eval:w (#1 - 4) / 8 \exp_after:wN ,
21007 \int_value:w #1 , \__fp_sep:
21008 {#2}{#3}{#4}{#5} \__fp_sep:
21009 }
21010 \cs_new:Npn \__fp_trig_large_auxi:w #1, #2,
21011 {
21012 \exp_after:wN \exp_after:wN
21013 \exp_after:wN \__fp_trig_large_auxii:w
21014 \cs:w
21015 use_none:n \prg_replicate:nn { #2 - #1 * 8 } { n }
21016 \exp_after:wN
21017 \cs_end:
21018 \int_value:w
21019 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21020 { \__fp_int_eval:w #1 + 1 \scan_stop: }
21021 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21022 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21023 { \__fp_int_eval:w #1 + 2 \scan_stop: }
21024 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21025 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21026 { \__fp_int_eval:w #1 + 3 \scan_stop: }
21027 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21028 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21029 { \__fp_int_eval:w #1 + 4 \scan_stop: }
21030 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21031 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21032 { \__fp_int_eval:w #1 + 5 \scan_stop: }
21033 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21034 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21035 { \__fp_int_eval:w #1 + 6 \scan_stop: }
21036 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21037 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21038 { \__fp_int_eval:w #1 + 7 \scan_stop: }
21039 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21040 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21041 { \__fp_int_eval:w #1 + 8 \scan_stop: }
21042 \exp_after:wN \__fp_trig_large_auxiii:w \int_value:w
21043 \__kernel_intarray_item:Nn \c__fp_trig_intarray
21044 { \__fp_int_eval:w #1 + 9 \scan_stop: }
21045 \exp_stop_f:
21046 }
21047 \cs_new:Npn \__fp_trig_large_auxii:w
21048 {
21049 \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN
21050 \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN
21051 \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN
21052 \__fp_pack_twice_four:wNNNNNNNN \__fp_pack_twice_four:wNNNNNNNN
21053 \__fp_trig_large_auxv:www \__fp_sep:
21054 }
21055 \cs_new:Npn \__fp_trig_large_auxiii:w 1 { \exp_stop_f: }
21056 \cs_new:Npn \__fp_trig_large_auxv:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
21057 {
21058 \exp_after:wN \__fp_use_i_until_s:nw
21059 \exp_after:wN \__fp_trig_large_auxvii:w
21060 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
21061 \prg_replicate:nn { 13 }
21062 { \__fp_trig_large_auxvi:wnnnnnnnn }
21063 + \c__fp_trailing_shift_int - \c__fp_middle_shift_int
21064 \__fp_use_i_until_s:nw
21065 \__fp_sep: #3 #1 \__fp_sep: \__fp_sep:
21066 }
21067 \cs_new:Npn \__fp_trig_large_auxvi:wnnnnnnnn #1\__fp_sep: #2#3#4#5#6#7#8#9
21068 {
21069 \exp_after:wN \__fp_trig_large_pack:NNNNNw
21070 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
21071 + #2*#9 + #3*#8 + #4*#7 + #5*#6
21072 #1\__fp_sep: {#2}{#3}{#4}{#5} {#7}{#8}{#9}
21073 }
21074 \cs_new:Npn \__fp_trig_large_pack:NNNNNw #1#2#3#4#5#6\__fp_sep:
21075 { + #1#2#3#4#5 \__fp_sep: #6 }
21076 \cs_new:Npn \__fp_trig_large_auxvii:w #1#2#3
21077 {
21078 \exp_after:wN \__fp_trig_large_auxviii:ww
21079 \int_value:w \__fp_int_eval:w (#1#2#3 - 62) / 125 \__fp_sep:
21080 #1#2#3
21081 }
21082 \cs_new:Npn \__fp_trig_large_auxviii:ww #1\__fp_sep:
21083 {
21084 + #1
21085 \if_int_odd:w #1 \exp_stop_f:
21086 \exp_after:wN \__fp_trig_large_auxix:Nw
21087 \exp_after:wN -
21088 \else:
21089 \exp_after:wN \__fp_trig_large_auxix:Nw
21090 \exp_after:wN +
21091 \fi:
21092 }
21093 \cs_new:Npn \__fp_trig_large_auxix:Nw
21094 {
21095 \exp_after:wN \__fp_use_i_until_s:nw
21096 \exp_after:wN \__fp_trig_large_auxxi:w
21097 \int_value:w \__fp_int_eval:w \c__fp_leading_shift_int
21098 \prg_replicate:nn { 13 }
21099 { \__fp_trig_large_auxx:wNNNNN }
21100 + \c__fp_trailing_shift_int - \c__fp_middle_shift_int
21101 \__fp_sep:
21102 }
21103 \cs_new:Npn \__fp_trig_large_auxx:wNNNNN #1\__fp_sep: #2 #3#4#5#6
21104 {
21105 \exp_after:wN \__fp_trig_large_pack:NNNNNw
21106 \int_value:w \__fp_int_eval:w \c__fp_middle_shift_int
21107 #2 8 * #3#4#5#6
21108 #1\__fp_sep: #2
21109 }
21110 \cs_new:Npn \__fp_trig_large_auxxi:w #1\__fp_sep:
21111 {
21112 \exp_after:wN \__fp_ep_mul_raw:wwwwN
21113 \int_value:w \__fp_int_eval:w 0 \__fp_ep_to_ep_loop:N #1 \__fp_sep: \__fp_sep: !
21114 0,{7853}{9816}{3397}{4483}{0961}{5661}\__fp_sep:
21115 \__fp_trig_small:ww
21116 }
21117 \cs_new:Npn \__fp_sin_series_o:NNwwww #1#2#3. #4\__fp_sep:
21118 {
21119 \__fp_fixed_mul:wwn #4\__fp_sep: #4\__fp_sep:
21120 {
21121 \exp_after:wN \__fp_sin_series_aux_o:NNnwww
21122 \exp_after:wN #1
21123 \int_value:w
21124 \if_int_odd:w \__fp_int_eval:w (#3 + 2) / 4 \__fp_int_eval_end:
21125 #2
21126 \else:
21127 \if_meaning:w #2 0 2 \else: 0 \fi:
21128 \fi:
21129 {#3}
21130 }
21131 }
21132 \cs_new:Npn \__fp_sin_series_aux_o:NNnwww #1#2#3 #4\__fp_sep: #5,#6\__fp_sep:
21133 {
21134 \if_int_odd:w \__fp_int_eval:w #3 / 2 \__fp_int_eval_end:
21135 \exp_after:wN \use_i:nn
21136 \else:
21137 \exp_after:wN \use_ii:nn
21138 \fi:
21139 { % 1/18!
21140 \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0001}{5619}{2070}\__fp_sep:
21141 #4\__fp_sep:
21142 {0000}{0000}{0000}{0477}{9477}{3324}\__fp_sep:
21143 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21144 {0000}{0000}{0011}{4707}{4559}{7730}\__fp_sep:
21145 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21146 {0000}{0000}{2087}{6756}{9878}{6810}\__fp_sep:
21147 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21148 {0000}{0027}{5573}{1922}{3985}{8907}\__fp_sep:
21149 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21150 {0000}{2480}{1587}{3015}{8730}{1587}\__fp_sep:
21151 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21152 {0013}{8888}{8888}{8888}{8888}{8889}\__fp_sep:
21153 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21154 {0416}{6666}{6666}{6666}{6666}{6667}\__fp_sep:
21155 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21156 {5000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21157 \__fp_fixed_mul_sub_back:wwwn#4\__fp_sep:
21158 {10000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21159 { \__fp_fixed_continue:wn 0, }
21160 }
21161 { % 1/17!
21162 \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{0000}{0028}{1145}{7254}\__fp_sep:
21163 #4\__fp_sep:
21164 {0000}{0000}{0000}{7647}{1637}{3182}\__fp_sep:
21165 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21166 {0000}{0000}{0160}{5904}{3836}{8216}\__fp_sep:
21167 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21168 {0000}{0002}{5052}{1083}{8544}{1719}\__fp_sep:
21169 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21170 {0000}{0275}{5731}{9223}{9858}{9065}\__fp_sep:
21171 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21172 {0001}{9841}{2698}{4126}{9841}{2698}\__fp_sep:
21173 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21174 {0083}{3333}{3333}{3333}{3333}{3333}\__fp_sep:
21175 \__fp_fixed_mul_sub_back:wwwn #4\__fp_sep:
21176 {1666}{6666}{6666}{6666}{6666}{6667}\__fp_sep:
21177 \__fp_fixed_mul_sub_back:wwwn#4\__fp_sep:
21178 {10000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21179 { \__fp_ep_mul:wwwwn 0, } #5,#6\__fp_sep:
21180 }
21181 {
21182 \exp_after:wN \__fp_sanitize:Nw
21183 \exp_after:wN #2
21184 \int_value:w \__fp_int_eval:w #1
21185 }
21186 #2
21187 }
21188 \cs_new:Npn \__fp_tan_series_o:NNwwww #1#2#3. #4\__fp_sep:
21189 {
21190 \__fp_fixed_mul:wwn #4\__fp_sep: #4\__fp_sep:
21191 {
21192 \exp_after:wN \__fp_tan_series_aux_o:Nnwww
21193 \int_value:w
21194 \if_int_odd:w \__fp_int_eval:w #3 / 2 \__fp_int_eval_end:
21195 \exp_after:wN \reverse_if:N
21196 \fi:
21197 \if_meaning:w #1#2 2 \else: 0 \fi:
21198 {#3}
21199 }
21200 }
21201 \cs_new:Npn \__fp_tan_series_aux_o:Nnwww #1 #2 #3\__fp_sep: #4,#5\__fp_sep:
21202 {
21203 \__fp_fixed_mul_sub_back:wwwn {0000}{0000}{1527}{3493}{0856}{7059}\__fp_sep:
21204 #3\__fp_sep:
21205 {0000}{0159}{6080}{0274}{5257}{6472}\__fp_sep:
21206 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21207 {0002}{4571}{2320}{0157}{2558}{8481}\__fp_sep:
21208 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21209 {0115}{5830}{7533}{5397}{3168}{2147}\__fp_sep:
21210 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21211 {1929}{8245}{6140}{3508}{7719}{2982}\__fp_sep:
21212 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21213 {10000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21214 { \__fp_ep_mul:wwwwn 0, } #4,#5\__fp_sep:
21215 {
21216 \__fp_fixed_mul_sub_back:wwwn {0000}{0007}{0258}{0681}{9408}{4706}\__fp_sep:
21217 #3\__fp_sep:
21218 {0000}{2343}{7175}{1399}{6151}{7670}\__fp_sep:
21219 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21220 {0019}{2638}{4588}{9232}{8861}{3691}\__fp_sep:
21221 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21222 {0536}{6357}{0691}{4344}{6852}{4252}\__fp_sep:
21223 \__fp_fixed_mul_sub_back:wwwn #3\__fp_sep:
21224 {5263}{1578}{9473}{6842}{1052}{6315}\__fp_sep:
21225 \__fp_fixed_mul_sub_back:wwwn#3\__fp_sep:
21226 {10000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21227 {
21228 \reverse_if:N \if_int_odd:w
21229 \__fp_int_eval:w (#2 - 1) / 2 \__fp_int_eval_end:
21230 \exp_after:wN \__fp_reverse_args:Nww
21231 \fi:
21232 \__fp_ep_div:wwwwn 0,
21233 }
21234 }
21235 {
21236 \exp_after:wN \__fp_sanitize:Nw
21237 \exp_after:wN #1
21238 \int_value:w \__fp_int_eval:w \__fp_ep_to_float_o:wwN
21239 }
21240 #1
21241 }
21242 \cs_new:Npn \__fp_atan_o:Nw #1
21243 {
21244 \__fp_parse_function_one_two:nnw
21245 { #1 { atan } { atand } }
21246 { \__fp_atan_default:w \__fp_atanii_o:Nww #1 }
21247 }
21248 \cs_new:Npn \__fp_acot_o:Nw #1
21249 {
21250 \__fp_parse_function_one_two:nnw
21251 { #1 { acot } { acotd } }
21252 { \__fp_atan_default:w \__fp_acotii_o:Nww #1 }
21253 }
21254 \cs_new:Npe \__fp_atan_default:w #1#2#3 @ { #1 #2 #3 \c_one_fp @ }
21255 \cs_new:Npn \__fp_atanii_o:Nww
21256 #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: \s__fp \__fp_chk:w #5 #6 @
21257 {
21258 \if_meaning:w 3 #2 \__fp_case_return_i_o:ww \fi:
21259 \if_meaning:w 3 #5 \__fp_case_return_ii_o:ww \fi:
21260 \if_case:w
21261 \if_meaning:w #2 #5
21262 \if_meaning:w 1 #2 10 \else: 0 \fi:
21263 \else:
21264 \if_int_compare:w #2 > #5 \exp_stop_f: 1 \else: 2 \fi:
21265 \fi:
21266 \exp_stop_f:
21267 \__fp_case_return:nw { \__fp_atan_inf_o:NNNw #1 #3 2 }
21268 \or: \__fp_case_return:nw { \__fp_atan_inf_o:NNNw #1 #3 4 }
21269 \or: \__fp_case_return:nw { \__fp_atan_inf_o:NNNw #1 #3 0 }
21270 \fi:
21271 \__fp_atan_normal_o:NNnwNnw #1
21272 \s__fp \__fp_chk:w #2#3#4\__fp_sep:
21273 \s__fp \__fp_chk:w #5 #6
21274 }
21275 \cs_new:Npn \__fp_acotii_o:Nww #1#2\__fp_sep: #3\__fp_sep:
21276 { \__fp_atanii_o:Nww #1#3\__fp_sep: #2\__fp_sep: }
21277 \cs_new:Npn \__fp_atan_inf_o:NNNw #1#2#3 \s__fp \__fp_chk:w #4#5#6\__fp_sep:
21278 {
21279 \exp_after:wN \__fp_atan_combine_o:NwwwwwN
21280 \exp_after:wN #2
21281 \int_value:w \__fp_int_eval:w
21282 \if_meaning:w 2 #5 7 - \fi: #3 \exp_after:wN \__fp_sep:
21283 \c__fp_one_fixed_tl
21284 {0000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21285 0,{0000}{0000}{0000}{0000}{0000}{0000}\__fp_sep: #1
21286 }
21287 \cs_new_protected:Npn \__fp_atan_normal_o:NNnwNnw
21288 #1 \s__fp \__fp_chk:w 1#2#3#4\__fp_sep: \s__fp \__fp_chk:w 1#5#6#7\__fp_sep:
21289 {
21290 \__fp_atan_test_o:NwwNwwN
21291 #2 #3, #4{0000}{0000}\__fp_sep:
21292 #5 #6, #7{0000}{0000}\__fp_sep: #1
21293 }
21294 \cs_new:Npn \__fp_atan_test_o:NwwNwwN #1#2,#3\__fp_sep: #4#5,#6\__fp_sep:
21295 {
21296 \exp_after:wN \__fp_atan_combine_o:NwwwwwN
21297 \exp_after:wN #1
21298 \int_value:w \__fp_int_eval:w
21299 \if_meaning:w 2 #4
21300 7 - \__fp_int_eval:w
21301 \fi:
21302 \if_int_compare:w
21303 \__fp_ep_compare:wwww #2,#3\__fp_sep: #5,#6\__fp_sep: > \c_zero_int
21304 3 -
21305 \exp_after:wN \__fp_reverse_args:Nww
21306 \fi:
21307 \__fp_atan_div:wnwwnw #2,#3\__fp_sep: #5,#6\__fp_sep:
21308 }
21309 \cs_new:Npn \__fp_atan_div:wnwwnw #1,#2#3\__fp_sep: #4,#5#6\__fp_sep:
21310 {
21311 \if_int_compare:w
21312 \__fp_int_eval:w 41421 * #5 < #2 000
21313 \if_case:w \__fp_int_eval:w #4 - #1 \__fp_int_eval_end:
21314 00 \or: 0 \fi:
21315 \exp_stop_f:
21316 \exp_after:wN \__fp_atan_near:wwwn
21317 \fi:
21318 0
21319 \__fp_ep_div:wwwwn #1,{#2}#3\__fp_sep: #4,{#5}#6\__fp_sep:
21320 \__fp_atan_auxi:ww
21321 }
21322 \cs_new:Npn \__fp_atan_near:wwwn
21323 0 \__fp_ep_div:wwwwn #1,#2\__fp_sep: #3,
21324 {
21325 1
21326 \__fp_ep_to_fixed:wwn #1 - #3, #2\__fp_sep:
21327 \__fp_atan_near_aux:wwn
21328 }
21329 \cs_new:Npn \__fp_atan_near_aux:wwn #1\__fp_sep: #2\__fp_sep:
21330 {
21331 \__fp_fixed_add:wwn #1\__fp_sep: #2\__fp_sep:
21332 { \__fp_fixed_sub:wwn #2\__fp_sep: #1\__fp_sep: { \__fp_ep_div:wwwwn 0, } 0, }
21333 }
21334 \cs_new:Npn \__fp_atan_auxi:ww #1,#2\__fp_sep:
21335 { \__fp_ep_to_fixed:wwn #1,#2\__fp_sep: \__fp_atan_auxii:w #1,#2\__fp_sep: }
21336 \cs_new:Npn \__fp_atan_auxii:w #1\__fp_sep:
21337 {
21338 \__fp_fixed_mul:wwn #1\__fp_sep: #1\__fp_sep:
21339 {
21340 \__fp_atan_Taylor_loop:www 39 \__fp_sep:
21341 {0000}{0000}{0000}{0000}{0000}{0000} \__fp_sep:
21342 }
21343 ! #1\__fp_sep:
21344 }
21345 \cs_new:Npn \__fp_atan_Taylor_loop:www #1\__fp_sep: #2\__fp_sep: #3\__fp_sep:
21346 {
21347 \if_int_compare:w #1 = - \c_one_int
21348 \__fp_atan_Taylor_break:w
21349 \fi:
21350 \exp_after:wN \__fp_fixed_div_int:wwN \c__fp_one_fixed_tl #1\__fp_sep:
21351 \__fp_rrot:www \__fp_fixed_mul_sub_back:wwwn #2\__fp_sep: #3\__fp_sep:
21352 {
21353 \exp_after:wN \__fp_atan_Taylor_loop:www
21354 \int_value:w \__fp_int_eval:w #1 - 2 \__fp_sep:
21355 }
21356 #3\__fp_sep:
21357 }
21358 \cs_new:Npn \__fp_atan_Taylor_break:w
21359 \fi: #1 \__fp_fixed_mul_sub_back:wwwn #2\__fp_sep: #3 !
21360 { \fi: \__fp_sep: #2 \__fp_sep: }
21361 \cs_new:Npn \__fp_atan_combine_o:NwwwwwN
21362 #1 #2\__fp_sep: #3\__fp_sep: #4\__fp_sep: #5,#6\__fp_sep: #7
21363 {
21364 \exp_after:wN \__fp_sanitize:Nw
21365 \exp_after:wN #1
21366 \int_value:w \__fp_int_eval:w
21367 \if_meaning:w 0 #2
21368 \exp_after:wN \use_i:nn
21369 \else:
21370 \exp_after:wN \use_ii:nn
21371 \fi:
21372 { #5 \__fp_fixed_mul:wwn #3\__fp_sep: #6\__fp_sep: }
21373 {
21374 \__fp_fixed_mul:wwn #3\__fp_sep: #4\__fp_sep:
21375 {
21376 \exp_after:wN \__fp_atan_combine_aux:ww
21377 \int_value:w \__fp_int_eval:w #2 / 2 \__fp_sep: #2\__fp_sep:
21378 }
21379 }
21380 { #7 \__fp_fixed_to_float_o:wN \__fp_fixed_to_float_rad_o:wN }
21381 #1
21382 }
21383 \cs_new:Npn \__fp_atan_combine_aux:ww #1\__fp_sep: #2\__fp_sep:
21384 {
21385 \__fp_fixed_mul_short:wwn
21386 {7853}{9816}{3397}{4483}{0961}{5661}\__fp_sep:
21387 {#1}{0000}{0000}\__fp_sep:
21388 {
21389 \if_int_odd:w #2 \exp_stop_f:
21390 \exp_after:wN \__fp_fixed_sub:wwn
21391 \else:
21392 \exp_after:wN \__fp_fixed_add:wwn
21393 \fi:
21394 }
21395 }
21396 \cs_new:Npn \__fp_asin_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
21397 {
21398 \if_case:w #2 \exp_stop_f:
21399 \__fp_case_return_same_o:w
21400 \or:
21401 \__fp_case_use:nw
21402 { \__fp_asin_normal_o:NfwNnnnnw #1 { #1 { asin } { asind } } }
21403 \or:
21404 \__fp_case_use:nw
21405 { \__fp_invalid_operation_o:fw { #1 { asin } { asind } } }
21406 \else:
21407 \__fp_case_return_same_o:w
21408 \fi:
21409 \s__fp \__fp_chk:w #2 #3\__fp_sep:
21410 }
21411 \cs_new:Npn \__fp_acos_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
21412 {
21413 \if_case:w #2 \exp_stop_f:
21414 \__fp_case_use:nw { \__fp_atan_inf_o:NNNw #1 0 4 }
21415 \or:
21416 \__fp_case_use:nw
21417 {
21418 \__fp_asin_normal_o:NfwNnnnnw #1 { #1 { acos } { acosd } }
21419 \__fp_reverse_args:Nww
21420 }
21421 \or:
21422 \__fp_case_use:nw
21423 { \__fp_invalid_operation_o:fw { #1 { acos } { acosd } } }
21424 \else:
21425 \__fp_case_return_same_o:w
21426 \fi:
21427 \s__fp \__fp_chk:w #2 #3\__fp_sep:
21428 }
21429 \cs_new:Npn \__fp_asin_normal_o:NfwNnnnnw
21430 #1#2#3 \s__fp \__fp_chk:w 1#4#5#6#7#8#9\__fp_sep:
21431 {
21432 \if_int_compare:w #5 < \c_one_int
21433 \exp_after:wN \__fp_use_none_until_s:w
21434 \fi:
21435 \if_int_compare:w \__fp_int_eval:w #5 + #6#7 + #8#9 = 1000 0001 ~
21436 \exp_after:wN \__fp_use_none_until_s:w
21437 \fi:
21438 \__fp_use_i:ww
21439 \__fp_invalid_operation_o:fw {#2}
21440 \s__fp \__fp_chk:w 1#4{#5}{#6}{#7}{#8}{#9}\__fp_sep:
21441 \__fp_asin_auxi_o:NnNww
21442 #1 {#3} #4 #5,{#6}{#7}{#8}{#9}{0000}{0000}\__fp_sep:
21443 }
21444 \cs_new:Npn \__fp_asin_auxi_o:NnNww #1#2#3#4,#5\__fp_sep:
21445 {
21446 \__fp_ep_to_fixed:wwn #4,#5\__fp_sep:
21447 \__fp_asin_isqrt:wn
21448 \__fp_ep_mul:wwwwn #4,#5\__fp_sep:
21449 \__fp_ep_to_ep:wwN
21450 \__fp_fixed_continue:wn
21451 { #2 \__fp_atan_test_o:NwwNwwN #3 }
21452 0 1,{1000}{0000}{0000}{0000}{0000}{0000}\__fp_sep: #1
21453 }
21454 \cs_new:Npn \__fp_asin_isqrt:wn #1\__fp_sep:
21455 {
21456 \exp_after:wN \__fp_fixed_sub:wwn \c__fp_one_fixed_tl #1\__fp_sep:
21457 {
21458 \__fp_fixed_add_one:wN #1\__fp_sep:
21459 \__fp_fixed_continue:wn { \__fp_ep_mul:wwwwn 0, } 0,
21460 }
21461 \__fp_ep_isqrt:wwn
21462 }
21463 \cs_new:Npn \__fp_acsc_o:w #1 \s__fp \__fp_chk:w #2#3#4\__fp_sep: @
21464 {
21465 \if_case:w \if_meaning:w 2 #2 #3 \fi: #2 \exp_stop_f:
21466 \__fp_case_use:nw
21467 { \__fp_invalid_operation_o:fw { #1 { acsc } { acscd } } }
21468 \or: \__fp_case_use:nw
21469 { \__fp_acsc_normal_o:NfwNnw #1 { #1 { acsc } { acscd } } }
21470 \or: \__fp_case_return_o:Nw \c_zero_fp
21471 \or: \__fp_case_return_same_o:w
21472 \else: \__fp_case_return_o:Nw \c_minus_zero_fp
21473 \fi:
21474 \s__fp \__fp_chk:w #2 #3 #4\__fp_sep:
21475 }
21476 \cs_new:Npn \__fp_asec_o:w #1 \s__fp \__fp_chk:w #2#3\__fp_sep: @
21477 {
21478 \if_case:w #2 \exp_stop_f:
21479 \__fp_case_use:nw
21480 { \__fp_invalid_operation_o:fw { #1 { asec } { asecd } } }
21481 \or:
21482 \__fp_case_use:nw
21483 {
21484 \__fp_acsc_normal_o:NfwNnw #1 { #1 { asec } { asecd } }
21485 \__fp_reverse_args:Nww
21486 }
21487 \or: \__fp_case_use:nw { \__fp_atan_inf_o:NNNw #1 0 4 }
21488 \else: \__fp_case_return_same_o:w
21489 \fi:
21490 \s__fp \__fp_chk:w #2 #3\__fp_sep:
21491 }
21492 \cs_new:Npn \__fp_acsc_normal_o:NfwNnw #1#2#3 \s__fp \__fp_chk:w 1#4#5#6\__fp_sep:
21493 {
21494 \int_compare:nNnTF {#5} < 1
21495 {
21496 \__fp_invalid_operation_o:fw {#2}
21497 \s__fp \__fp_chk:w 1#4{#5}#6\__fp_sep:
21498 }
21499 {
21500 \__fp_ep_div:wwwwn
21501 1,{1000}{0000}{0000}{0000}{0000}{0000}\__fp_sep:
21502 #5,#6{0000}{0000}\__fp_sep:
21503 { \__fp_asin_auxi_o:NnNww #1 {#3} #4 }
21504 }
21505 }
21506 %% File: l3fp-convert.dtx
21507 \cs_new:Npn \__fp_tuple_convert:Nw #1 \s__fp_tuple \__fp_tuple_chk:w #2 \__fp_sep:
21508 {
21509 \int_case:nnF { \__fp_array_count:n {#2} }
21510 {
21511 { 0 } { ( ) }
21512 { 1 } { \__fp_tuple_convert_end:w @ { #1 #2 , } }
21513 }
21514 {
21515 \__fp_tuple_convert_loop:nNw { } #1
21516 #2 { ? \__fp_tuple_convert_end:w } \__fp_sep:
21517 @ { \use_none:nn }
21518 }
21519 }
21520 \cs_new:Npn \__fp_tuple_convert_loop:nNw #1#2#3#4\__fp_sep: #5 @ #6
21521 {
21522 \use_none:n #3
21523 \exp_args:Nf \__fp_tuple_convert_loop:nNw { #2 #3#4 \__fp_sep: } #2 #5
21524 @ { #6 , ~ #1 }
21525 }
21526 \cs_new:Npn \__fp_tuple_convert_end:w #1 @ #2
21527 { \exp_after:wN ( \exp:w \exp_end_continue_f:w #2 ) }
21528 \cs_new:Npn \__fp_trim_zeros:w #1 \__fp_sep:
21529 {
21530 \__fp_trim_zeros_loop:w #1 \__fp_sep:
21531 \__fp_trim_zeros_loop:w 0\__fp_sep:
21532 \__fp_trim_zeros_dot:w .\__fp_sep:
21533 \s__fp_stop
21534 }
21535 \cs_new:Npn \__fp_trim_zeros_loop:w #1 0\__fp_sep: #2 { #2 #1 \__fp_sep: #2 }
21536 \cs_new:Npn \__fp_trim_zeros_dot:w #1 .\__fp_sep:
21537 { \__fp_trim_zeros_end:w #1 \__fp_sep: }
21538 \cs_new:Npn \__fp_trim_zeros_end:w #1 \__fp_sep: #2 \s__fp_stop { #1 }
21539 \cs_new:Npn \fp_to_scientific:N #1
21540 { \exp_after:wN \__fp_to_scientific_dispatch:w #1 }
21541 \cs_generate_variant:Nn \fp_to_scientific:N { c }
21542 \cs_new:Npn \fp_to_scientific:n
21543 {
21544 \exp_after:wN \__fp_to_scientific_dispatch:w
21545 \exp:w \exp_end_continue_f:w \__fp_parse:n
21546 }
21547 \cs_new:Npn \__fp_to_scientific_dispatch:w #1
21548 {
21549 \__fp_change_func_type:NNN
21550 #1 \__fp_to_scientific:w \__fp_to_scientific_recover:w
21551 #1
21552 }
21553 \cs_new:Npn \__fp_to_scientific_recover:w #1 #2 \__fp_sep:
21554 {
21555 \__fp_error:nffn { unknown-type } { \tl_to_str:n { #2 \__fp_sep: } } { } { }
21556 nan
21557 }
21558 \cs_new:Npn \__fp_tuple_to_scientific:w
21559 { \__fp_tuple_convert:Nw \__fp_to_scientific_dispatch:w }
21560 \cs_new:Npn \__fp_to_scientific:w \s__fp \__fp_chk:w #1#2
21561 {
21562 \if_meaning:w 2 #2 \exp_after:wN - \exp:w \exp_end_continue_f:w \fi:
21563 \if_case:w #1 \exp_stop_f:
21564 \__fp_case_return:nw { 0.000000000000000e0 }
21565 \or: \exp_after:wN \__fp_to_scientific_normal:wnnnnn
21566 \or:
21567 \__fp_case_use:nw
21568 {
21569 \__fp_invalid_operation:nnw
21570 { \fp_to_scientific:N \c__fp_overflowing_fp }
21571 { fp_to_scientific }
21572 }
21573 \or:
21574 \__fp_case_use:nw
21575 {
21576 \__fp_invalid_operation:nnw
21577 { \fp_to_scientific:N \c_zero_fp }
21578 { fp_to_scientific }
21579 }
21580 \fi:
21581 \s__fp \__fp_chk:w #1 #2
21582 }
21583 \cs_new:Npn \__fp_to_scientific_normal:wnnnnn
21584 \s__fp \__fp_chk:w 1 #1 #2 #3#4#5#6 \__fp_sep:
21585 {
21586 \exp_after:wN \__fp_to_scientific_normal:wNw
21587 \exp_after:wN e
21588 \int_value:w \__fp_int_eval:w #2 - 1
21589 \__fp_sep: #3 #4 #5 #6 \__fp_sep:
21590 }
21591 \cs_new:Npn \__fp_to_scientific_normal:wNw #1 \__fp_sep: #2#3\__fp_sep:
21592 { #2.#3 #1 }
21593 \cs_new:Npn \fp_to_decimal:N #1
21594 { \exp_after:wN \__fp_to_decimal_dispatch:w #1 }
21595 \cs_generate_variant:Nn \fp_to_decimal:N { c }
21596 \cs_new:Npn \fp_to_decimal:n
21597 {
21598 \exp_after:wN \__fp_to_decimal_dispatch:w
21599 \exp:w \exp_end_continue_f:w \__fp_parse:n
21600 }
21601 \cs_new:Npn \__fp_to_decimal_dispatch:w #1
21602 {
21603 \__fp_change_func_type:NNN
21604 #1 \__fp_to_decimal:w \__fp_to_decimal_recover:w
21605 #1
21606 }
21607 \cs_new:Npn \__fp_to_decimal_recover:w #1 #2 \__fp_sep:
21608 {
21609 \__fp_error:nffn { unknown-type } { \tl_to_str:n { #2 \__fp_sep: } } { } { }
21610 nan
21611 }
21612 \cs_new:Npn \__fp_tuple_to_decimal:w
21613 { \__fp_tuple_convert:Nw \__fp_to_decimal_dispatch:w }
21614 \cs_new:Npn \__fp_to_decimal:w \s__fp \__fp_chk:w #1#2
21615 {
21616 \if_meaning:w 2 #2 \exp_after:wN - \exp:w \exp_end_continue_f:w \fi:
21617 \if_case:w #1 \exp_stop_f:
21618 \__fp_case_return:nw { 0 }
21619 \or: \exp_after:wN \__fp_to_decimal_normal:wnnnnn
21620 \or:
21621 \__fp_case_use:nw
21622 {
21623 \__fp_invalid_operation:nnw
21624 { \fp_to_decimal:N \c__fp_overflowing_fp }
21625 { fp_to_decimal }
21626 }
21627 \or:
21628 \__fp_case_use:nw
21629 {
21630 \__fp_invalid_operation:nnw
21631 { 0 }
21632 { fp_to_decimal }
21633 }
21634 \fi:
21635 \s__fp \__fp_chk:w #1 #2
21636 }
21637 \cs_new:Npn \__fp_to_decimal_normal:wnnnnn
21638 \s__fp \__fp_chk:w 1 #1 #2 #3#4#5#6 \__fp_sep:
21639 {
21640 \int_compare:nNnTF {#2} > 0
21641 {
21642 \int_compare:nNnTF {#2} < \c__fp_prec_int
21643 {
21644 \__fp_decimate:nNnnnn { \c__fp_prec_int - #2 }
21645 \__fp_to_decimal_large:Nnnw
21646 }
21647 {
21648 \exp_after:wN \exp_after:wN
21649 \exp_after:wN \__fp_to_decimal_huge:wnnnn
21650 \prg_replicate:nn { #2 - \c__fp_prec_int } { 0 } \__fp_sep:
21651 }
21652 {#3} {#4} {#5} {#6}
21653 }
21654 {
21655 \exp_after:wN \__fp_trim_zeros:w
21656 \exp_after:wN 0
21657 \exp_after:wN .
21658 \exp:w \exp_end_continue_f:w \prg_replicate:nn { - #2 } { 0 }
21659 #3#4#5#6 \__fp_sep:
21660 }
21661 }
21662 \cs_new:Npn \__fp_to_decimal_large:Nnnw #1#2#3#4\__fp_sep:
21663 {
21664 \exp_after:wN \__fp_trim_zeros:w \int_value:w
21665 \if_int_compare:w #2 > \c_zero_int
21666 #2
21667 \fi:
21668 \exp_stop_f:
21669 #3.#4 \__fp_sep:
21670 }
21671 \cs_new:Npn \__fp_to_decimal_huge:wnnnn #1\__fp_sep: #2#3#4#5 { #2#3#4#5 #1 }
21672 \cs_new:Npn \fp_to_tl:N #1 { \exp_after:wN \__fp_to_tl_dispatch:w #1 }
21673 \cs_generate_variant:Nn \fp_to_tl:N { c }
21674 \cs_new:Npn \fp_to_tl:n
21675 {
21676 \exp_after:wN \__fp_to_tl_dispatch:w
21677 \exp:w \exp_end_continue_f:w \__fp_parse:n
21678 }
21679 \cs_new:Npn \__fp_to_tl_dispatch:w #1
21680 { \__fp_change_func_type:NNN #1 \__fp_to_tl:w \__fp_to_tl_recover:w #1 }
21681 \cs_new:Npn \__fp_to_tl_recover:w #1 #2 \__fp_sep:
21682 {
21683 \__fp_error:nffn { unknown-type } { \tl_to_str:n { #2 \__fp_sep: } } { } { }
21684 nan
21685 }
21686 \cs_new:Npn \__fp_tuple_to_tl:w
21687 { \__fp_tuple_convert:Nw \__fp_to_tl_dispatch:w }
21688 \cs_new:Npn \__fp_to_tl:w \s__fp \__fp_chk:w #1#2
21689 {
21690 \if_meaning:w 2 #2 \exp_after:wN - \exp:w \exp_end_continue_f:w \fi:
21691 \if_case:w #1 \exp_stop_f:
21692 \__fp_case_return:nw { 0 }
21693 \or: \exp_after:wN \__fp_to_tl_normal:nnnnn
21694 \or: \__fp_case_return:nw { inf }
21695 \else: \__fp_case_return:nw { nan }
21696 \fi:
21697 }
21698 \cs_new:Npn \__fp_to_tl_normal:nnnnn #1
21699 {
21700 \int_compare:nTF
21701 { -2 <= #1 <= \c__fp_prec_int }
21702 { \__fp_to_decimal_normal:wnnnnn }
21703 { \__fp_to_tl_scientific:wnnnnn }
21704 \s__fp \__fp_chk:w 1 0 {#1}
21705 }
21706 \cs_new:Npn \__fp_to_tl_scientific:wnnnnn
21707 \s__fp \__fp_chk:w 1 #1 #2 #3#4#5#6 \__fp_sep:
21708 {
21709 \exp_after:wN \__fp_to_tl_scientific:wNw
21710 \exp_after:wN e
21711 \int_value:w \__fp_int_eval:w #2 - 1
21712 \__fp_sep: #3 #4 #5 #6 \__fp_sep:
21713 }
21714 \cs_new:Npn \__fp_to_tl_scientific:wNw #1 \__fp_sep: #2#3\__fp_sep:
21715 { \__fp_trim_zeros:w #2.#3 \__fp_sep: #1 }
21716 \cs_new:Npn \fp_to_dim:N #1
21717 { \exp_after:wN \__fp_to_dim_dispatch:w #1 }
21718 \cs_generate_variant:Nn \fp_to_dim:N { c }
21719 \cs_new:Npn \fp_to_dim:n
21720 {
21721 \exp_after:wN \__fp_to_dim_dispatch:w
21722 \exp:w \exp_end_continue_f:w \__fp_parse:n
21723 }
21724 \cs_new:Npn \__fp_to_dim_dispatch:w #1#2 \__fp_sep:
21725 {
21726 \__fp_change_func_type:NNN #1 \__fp_to_dim:w \__fp_to_dim_recover:w
21727 #1 #2 \__fp_sep:
21728 }
21729 \cs_new:Npn \__fp_to_dim_recover:w #1
21730 { \__fp_invalid_operation:nnw { 0pt } { fp_to_dim } }
21731 \cs_new:Npn \__fp_to_dim:w #1 \__fp_sep: { \__fp_to_decimal:w #1 \__fp_sep: pt }
21732 \cs_new:Npn \fp_to_int:N #1 { \exp_after:wN \__fp_to_int_dispatch:w #1 }
21733 \cs_generate_variant:Nn \fp_to_int:N { c }
21734 \cs_new:Npn \fp_to_int:n
21735 {
21736 \exp_after:wN \__fp_to_int_dispatch:w
21737 \exp:w \exp_end_continue_f:w \__fp_parse:n
21738 }
21739 \cs_new:Npn \__fp_to_int_dispatch:w #1#2 \__fp_sep:
21740 {
21741 \__fp_change_func_type:NNN #1 \__fp_to_int:w \__fp_to_int_recover:w
21742 #1 #2 \__fp_sep:
21743 }
21744 \cs_new:Npn \__fp_to_int_recover:w #1
21745 { \__fp_invalid_operation:nnw { 0 } { fp_to_int } }
21746 \cs_new:Npn \__fp_to_int:w #1\__fp_sep:
21747 {
21748 \exp_after:wN \__fp_to_decimal:w \exp:w \exp_end_continue_f:w
21749 \__fp_round:Nwn \__fp_round_to_nearest:NNN #1\__fp_sep: { 0 }
21750 }
21751 \cs_new:Npn \dim_to_fp:n #1
21752 {
21753 \exp_after:wN \__fp_from_dim_test:ww
21754 \exp_after:wN 0
21755 \exp_after:wN ,
21756 \int_value:w \tex_glueexpr:D #1 \__fp_sep:
21757 }
21758 \cs_new:Npn \__fp_from_dim_test:ww #1, #2
21759 {
21760 \if_meaning:w 0 #2
21761 \__fp_case_return:nw { \exp_after:wN \c_zero_fp }
21762 \else:
21763 \exp_after:wN \__fp_from_dim:wNw
21764 \int_value:w \__fp_int_eval:w #1 - 4
21765 \if_meaning:w - #2
21766 \exp_after:wN , \exp_after:wN 2 \int_value:w
21767 \else:
21768 \exp_after:wN , \exp_after:wN 0 \int_value:w #2
21769 \fi:
21770 \fi:
21771 }
21772 \cs_new:Npn \__fp_from_dim:wNw #1,#2#3\__fp_sep:
21773 {
21774 \__fp_pack_twice_four:wNNNNNNNN \__fp_from_dim:wNNnnnnnn \__fp_sep:
21775 #3 000 0000 00 {10}987654321\__fp_sep: #2 {#1}
21776 }
21777 \cs_new:Npn \__fp_from_dim:wNNnnnnnn #1\__fp_sep: #2#3#4#5#6#7#8#9
21778 { \__fp_from_dim:wnnnnwNn #1 {#2#300} {0000} \__fp_sep: }
21779 \cs_new:Npn \__fp_from_dim:wnnnnwNn #1\__fp_sep: #2#3#4#5#6\__fp_sep: #7#8
21780 {
21781 \__fp_mul_npos_o:Nww #7
21782 \s__fp \__fp_chk:w 1 #7 {#5} #1 \__fp_sep:
21783 \s__fp \__fp_chk:w 1 0 {#8} {1525} {8789} {0625} {0000} \__fp_sep:
21784 \prg_do_nothing:
21785 }
21786 \cs_new_eq:NN \fp_use:N \fp_to_decimal:N
21787 \cs_generate_variant:Nn \fp_use:N { c }
21788 \cs_new_eq:NN \fp_eval:n \fp_to_decimal:n
21789 \cs_new:Npn \fp_sign:n #1
21790 { \fp_to_decimal:n { sign \__fp_parse:n {#1} } }
21791 \cs_new:Npn \fp_abs:n #1
21792 { \fp_to_decimal:n { abs \__fp_parse:n {#1} } }
21793 \cs_new:Npn \fp_max:nn #1#2
21794 { \fp_to_decimal:n { max ( \__fp_parse:n {#1} , \__fp_parse:n {#2} ) } }
21795 \cs_new:Npn \fp_min:nn #1#2
21796 { \fp_to_decimal:n { min ( \__fp_parse:n {#1} , \__fp_parse:n {#2} ) } }
21797 \cs_new:Npn \__fp_array_to_clist:n #1
21798 {
21799 \tl_if_empty:nF {#1}
21800 {
21801 \exp_last_unbraced:Ne \use_ii:nn
21802 {
21803 \__fp_array_to_clist_loop:Nw #1 { ? \prg_break: } \__fp_sep:
21804 \prg_break_point:
21805 }
21806 }
21807 }
21808 \cs_new:Npn \__fp_array_to_clist_loop:Nw #1#2\__fp_sep:
21809 {
21810 \use_none:n #1
21811 , ~
21812 \exp_not:f { \__fp_to_tl_dispatch:w #1 #2 \__fp_sep: }
21813 \__fp_array_to_clist_loop:Nw
21814 }
21815 %% File: l3fp-random.dtx
21816 \cs_new:Npn \__fp_parse_word_rand:N
21817 { \__fp_parse_function:NNN \__fp_rand_o:Nw ? }
21818 \cs_new:Npn \__fp_parse_word_randint:N
21819 { \__fp_parse_function:NNN \__fp_randint_o:Nw ? }
21820 \int_const:Nn \c__kernel_randint_max_int { 131071 }
21821 \cs_new:Npn \__kernel_randint:n #1
21822 {
21823 (#1 * \tex_uniformdeviate:D 16384
21824 + \tex_uniformdeviate:D #1 + 8192 ) / 16384
21825 }
21826 \cs_new:Npn \__fp_rand_myriads:n #1
21827 { \__fp_rand_myriads_loop:w #1 \prg_break: X \prg_break_point: \__fp_sep: }
21828 \cs_new:Npn \__fp_rand_myriads_loop:w #1 X
21829 {
21830 #1
21831 \exp_after:wN \__fp_rand_myriads_get:w
21832 \int_value:w \__fp_int_eval:w 9999 +
21833 \__kernel_randint:n { 10000 }
21834 \__fp_rand_myriads_loop:w
21835 }
21836 \cs_new:Npn \__fp_rand_myriads_get:w 1 #1 \__fp_sep: { \__fp_sep: {#1} }
21837 \cs_new:Npn \__fp_rand_o:Nw ? #1 @
21838 {
21839 \tl_if_empty:nTF {#1}
21840 {
21841 \exp_after:wN \__fp_rand_o:w
21842 \exp:w \exp_end_continue_f:w
21843 \__fp_rand_myriads:n { XXXX } { 0000 } { 0000 } \__fp_sep: 0
21844 }
21845 {
21846 \__fp_error_num_args:ffff { rand } { 0 } { 0 }
21847 { \__fp_array_count:n {#1} }
21848 \exp_after:wN \c_nan_fp
21849 }
21850 }
21851 \cs_new:Npn \__fp_rand_o:w \__fp_sep:
21852 {
21853 \exp_after:wN \__fp_sanitize:Nw
21854 \exp_after:wN 0
21855 \int_value:w \__fp_int_eval:w \c_zero_int
21856 \__fp_fixed_to_float_o:wN
21857 }
21858 \cs_new:Npn \__fp_randint_o:Nw ?
21859 {
21860 \__fp_parse_function_one_two:nnw
21861 { randint }
21862 { \__fp_randint_default:w \__fp_randint_o:w }
21863 }
21864 \cs_new:Npn \__fp_randint_default:w #1 { \exp_after:wN #1 \c_one_fp }
21865 \cs_new:Npn \__fp_randint_badarg:w \s__fp \__fp_chk:w #1#2#3\__fp_sep:
21866 {
21867 \__fp_int:wTF \s__fp \__fp_chk:w #1#2#3\__fp_sep:
21868 {
21869 \if_meaning:w 1 #1
21870 \if_int_compare:w
21871 \__fp_use_i_until_s:nw #3 \__fp_sep: > \c__fp_prec_int
21872 \c_one_int
21873 \fi:
21874 \fi:
21875 }
21876 { \c_one_int }
21877 }
21878 \cs_new:Npn \__fp_randint_o:w #1\__fp_sep: #2\__fp_sep: @
21879 {
21880 \if_case:w
21881 \__fp_randint_badarg:w #1\__fp_sep:
21882 \__fp_randint_badarg:w #2\__fp_sep:
21883 \if:w 1 \__fp_compare_back:ww #2\__fp_sep: #1\__fp_sep: \c_one_int \fi:
21884 \c_zero_int
21885 \__fp_randint_auxi_o:ww #1\__fp_sep: #2\__fp_sep:
21886 \or:
21887 \__fp_invalid_operation_tl_o:ff
21888 { randint } { \__fp_array_to_clist:n { #1\__fp_sep: #2\__fp_sep: } }
21889 \exp:w
21890 \fi:
21891 \exp_after:wN \exp_end:
21892 }
21893 \cs_new:Npn \__fp_randint_auxi_o:ww #1 \__fp_sep: #2 \__fp_sep: #3 \exp_end:
21894 {
21895 \fi:
21896 \__fp_randint_auxii:wn #2 \__fp_sep:
21897 { \__fp_randint_auxii:wn #1 \__fp_sep: \__fp_randint_auxiii_o:ww }
21898 }
21899 \cs_new:Npn \__fp_randint_auxii:wn \s__fp \__fp_chk:w #1#2#3#4 \__fp_sep:
21900 {
21901 \if_meaning:w 0 #1
21902 \exp_after:wN \use_i:nn
21903 \else:
21904 \exp_after:wN \use_ii:nn
21905 \fi:
21906 { \exp_after:wN \__fp_fixed_continue:wn \c__fp_one_fixed_tl }
21907 {
21908 \exp_after:wN \__fp_ep_to_fixed:wwn
21909 \int_value:w \__fp_int_eval:w
21910 #3 - \c__fp_prec_int , #4 {0000} {0000} \__fp_sep:
21911 {
21912 \if_meaning:w 0 #2
21913 \exp_after:wN \use_i:nnnn
21914 \exp_after:wN \__fp_fixed_add_one:wN
21915 \fi:
21916 \exp_after:wN \__fp_fixed_sub:wwn \c__fp_one_fixed_tl
21917 }
21918 \__fp_fixed_continue:wn
21919 }
21920 }
21921 \cs_new:Npn \__fp_randint_auxiii_o:ww #1 \__fp_sep: #2 \__fp_sep:
21922 {
21923 \__fp_fixed_add:wwn #2 \__fp_sep:
21924 {0000} {0000} {0000} {0001} {0000} {0000} \__fp_sep:
21925 \__fp_fixed_sub:wwn #1 \__fp_sep:
21926 {
21927 \exp_after:wN \use_i:nn
21928 \exp_after:wN \__fp_fixed_mul_add:wwwn
21929 \exp:w \exp_end_continue_f:w \__fp_rand_myriads:n { XXXXXX } \__fp_sep:
21930 }
21931 #1 \__fp_sep:
21932 \__fp_randint_auxiv_o:ww
21933 #2 \__fp_sep:
21934 \__fp_randint_auxv_o:w #1 \__fp_sep: @
21935 }
21936 \cs_new:Npn \__fp_randint_auxiv_o:ww #1#2#3#4#5 \__fp_sep: #6#7#8#9
21937 {
21938 \if_int_compare:w
21939 \if_int_compare:w #1#2 > #6#7 \exp_stop_f: 1 \else:
21940 \if_int_compare:w #1#2 < #6#7 \exp_stop_f: - \fi: \fi:
21941 #3#4 > #8#9 \exp_stop_f:
21942 \__fp_use_i_until_s:nw
21943 \fi:
21944 \__fp_randint_auxv_o:w {#1}{#2}{#3}{#4}#5
21945 }
21946 \cs_new:Npn \__fp_randint_auxv_o:w #1#2#3#4#5 \__fp_sep: #6 @
21947 {
21948 \exp_after:wN \__fp_sanitize:Nw
21949 \int_value:w
21950 \if_int_compare:w #1 < 10000 \exp_stop_f:
21951 2
21952 \else:
21953 0
21954 \exp_after:wN \exp_after:wN
21955 \exp_after:wN \__fp_reverse_args:Nww
21956 \fi:
21957 \exp_after:wN \__fp_fixed_sub:wwn \c__fp_one_fixed_tl
21958 {#1} {#2} {#3} {#4} {0000} {0000} \__fp_sep:
21959 {
21960 \exp_after:wN \exp_stop_f:
21961 \int_value:w \__fp_int_eval:w \c__fp_prec_int
21962 \__fp_fixed_to_float_o:wN
21963 }
21964 0
21965 \exp:w \exp_after:wN \exp_end:
21966 }
21967 \cs_new:Npn \int_rand:nn #1#2
21968 {
21969 \int_eval:n
21970 {
21971 \exp_after:wN \__fp_randint:ww
21972 \int_value:w \int_eval:n {#1} \exp_after:wN \__fp_sep:
21973 \int_value:w \int_eval:n {#2} \__fp_sep:
21974 }
21975 }
21976 \cs_new:Npn \__fp_randint:ww #1\__fp_sep: #2\__fp_sep:
21977 {
21978 \if_int_compare:w #1 > #2 \exp_stop_f:
21979 \msg_expandable_error:nnnn
21980 { kernel } { randint-backward-range } {#1} {#2}
21981 \__fp_randint:ww #2\__fp_sep: #1\__fp_sep:
21982 \else:
21983 \if_int_compare:w \__fp_int_eval:w #2
21984 \if_int_compare:w #1 > \c_zero_int
21985 - #1 < \__fp_int_eval:w
21986 \else:
21987 < \__fp_int_eval:w #1 +
21988 \fi:
21989 \c__kernel_randint_max_int
21990 \__fp_int_eval_end:
21991 \__kernel_randint:n
21992 { \__fp_int_eval:w #2 - #1 + 1 \__fp_int_eval_end: }
21993 - 1 + #1
21994 \else:
21995 \__kernel_randint:nn {#1} {#2}
21996 \fi:
21997 \fi:
21998 }
21999 \cs_new:Npn \__kernel_randint:nn #1#2
22000 {
22001 #1
22002 \exp_after:wN \__fp_randint_wide_aux:w
22003 \int_value:w
22004 \exp_after:wN \__fp_randint_split_o:Nw
22005 \tex_uniformdeviate:D 268435456 \__fp_sep:
22006 \int_value:w
22007 \exp_after:wN \__fp_randint_split_o:Nw
22008 \tex_uniformdeviate:D 268435456 \__fp_sep:
22009 \int_value:w
22010 \exp_after:wN \__fp_randint_split_o:Nw
22011 \int_value:w \__fp_int_eval:w 131072 +
22012 \exp_after:wN \__fp_randint_split_o:Nw
22013 \int_value:w
22014 \__kernel_int_add:nnn {#2} { -#1 } { -\c_max_int } \__fp_sep:
22015 .
22016 }
22017 \cs_new:Npn \__fp_randint_split_o:Nw #1#2 \__fp_sep:
22018 {
22019 \if_meaning:w 0 #1
22020 0 \exp_after:wN \__fp_sep: \int_value:w 0
22021 \else:
22022 \exp_after:wN \__fp_randint_split_aux:w
22023 \int_value:w \__fp_int_eval:w (#1#2 - 8192) / 16384 \__fp_sep:
22024 + #1#2
22025 \fi:
22026 \exp_after:wN \__fp_sep:
22027 }
22028 \cs_new:Npn \__fp_randint_split_aux:w #1 \__fp_sep:
22029 {
22030 #1 \exp_after:wN \__fp_sep:
22031 \int_value:w \__fp_int_eval:w - #1 * 16384
22032 }
22033 \cs_new:Npn \__fp_randint_wide_aux:w
22034 #1\__fp_sep:#2\__fp_sep: #3\__fp_sep:#4\__fp_sep:
22035 #5\__fp_sep:#6\__fp_sep:#7\__fp_sep: .
22036 {
22037 \exp_after:wN \__fp_randint_wide_auxii:w
22038 \int_value:w \__fp_int_eval:w #5 * #3 + #6 * #1 +
22039 (#5 * #4 + #6 * #3 + #7 * #1 +
22040 (#5 * #2 + #7 * #3 +
22041 (16384 * #6 + #7) * (16384 * #4 + #2) / 268435456) / 16384
22042 ) / 16384 \exp_after:wN \__fp_sep:
22043 \int_value:w \__fp_int_eval:w (#5 + #6) * 16384 + #7 \__fp_sep:
22044 #1 \__fp_sep: #5 \__fp_sep:
22045 }
22046 \cs_new:Npn \__fp_randint_wide_auxii:w
22047 #1\__fp_sep: #2\__fp_sep: #3\__fp_sep: #4\__fp_sep:
22048 {
22049 \if_int_odd:w 0
22050 \if_int_compare:w #1 = #2 \else: \exp_stop_f: \fi:
22051 \if_int_compare:w #4 = \c_zero_int 1 \fi:
22052 \if_int_compare:w #3 = 16383 ~ 1 \fi:
22053 \exp_stop_f:
22054 \exp_after:wN \prg_break:
22055 \fi:
22056 \if_int_compare:w #4 < 8 \exp_stop_f:
22057 + #4 * #3 * 16384
22058 \else:
22059 + 8 * #3 * 16384 + (#4 - 8) * #3 * 16384
22060 \fi:
22061 + #1
22062 \prg_break_point:
22063 }
22064 \cs_new:Npn \int_rand:n #1
22065 {
22066 \int_eval:n
22067 { \exp_args:Nf \__fp_randint:n { \int_eval:n {#1} } }
22068 }
22069 \cs_new:Npn \__fp_randint:n #1
22070 {
22071 \if_int_compare:w #1 < \c_one_int
22072 \msg_expandable_error:nnnn
22073 { kernel } { randint-backward-range } { 1 } {#1}
22074 \__fp_randint:ww #1\__fp_sep: 1\__fp_sep:
22075 \else:
22076 \if_int_compare:w #1 > \c__kernel_randint_max_int
22077 \__kernel_randint:nn { 1 } {#1}
22078 \else:
22079 \__kernel_randint:n {#1}
22080 \fi:
22081 \fi:
22082 }
22083 %% File l3fp-types.dtx (C) Copyright 2012-2015,2017,2018,2020,2021,2023 The LaTeX Project
22084 \cs_new:Npe \__fp_types_cs_to_op:N #1
22085 {
22086 \exp_not:N \exp_after:wN \exp_not:N \__fp_types_cs_to_op_auxi:wwwn
22087 \exp_not:N \token_to_str:N #1 \s__fp_mark
22088 \exp_not:N \__fp_use_i_delimit_by_s_stop:nw
22089 \tl_to_str:n { __fp_ _o:w } \s__fp_mark
22090 { \exp_not:N \__fp_use_i_delimit_by_s_stop:nw ? }
22091 \s__fp_stop
22092 }
22093 \use:e
22094 {
22095 \cs_new:Npn \exp_not:N \__fp_types_cs_to_op_auxi:wwwn
22096 #1 \tl_to_str:n { __fp_ } #2
22097 \tl_to_str:n { _o:w } #3 \s__fp_mark #4 { #4 {#2} }
22098 }
22099 \cs_new:Npn \__fp_types_unary:NNw #1
22100 {
22101 \exp_args:Nf \__fp_types_unary_auxi:nNw
22102 { \__fp_types_cs_to_op:N #1 }
22103 }
22104 \cs_new:Npn \__fp_types_unary_auxi:nNw #1#2#3
22105 {
22106 \exp_after:wN \__fp_types_unary_auxii:NnNw
22107 \cs:w __fp_#1 \__fp_type_from_scan:N #3 _o:w \cs_end:
22108 {#1}
22109 #2#3
22110 }
22111 \cs_new:Npn \__fp_types_unary_auxii:NnNw #1#2#3
22112 {
22113 \token_if_eq_meaning:NNTF \scan_stop: #1
22114 { \__fp_invalid_operation_o:nw {#2} }
22115 { #1 #3 }
22116 }
22117 \cs_new:Npn \__fp_types_binary:Nww #1
22118 {
22119 \exp_last_unbraced:Nf \__fp_types_binary_auxi:Nww
22120 { \__fp_types_cs_to_op:N #1 }
22121 }
22122 \cs_new:Npn \__fp_types_binary_auxi:Nww #1#2#3\__fp_sep: #4#5\__fp_sep: @
22123 {
22124 \exp_after:wN \__fp_types_binary_auxii:NNww
22125 \cs:w
22126 __fp
22127 \__fp_type_from_scan:N #2
22128 _#1
22129 \__fp_type_from_scan:N #4
22130 _o:ww
22131 \cs_end:
22132 #1 #2#3\__fp_sep: #4#5\__fp_sep:
22133 }
22134 \cs_new:Npn \__fp_types_binary_auxii:NNww #1#2
22135 {
22136 \token_if_eq_meaning:NNTF \scan_stop: #1
22137 { \__fp_invalid_operation_o:Nww #2 }
22138 {#1}
22139 }
22140 %% File l3fp-symbolic.dtx (C) Copyright 2012-2025 The LaTeX Project
22141 \fp_new:N \l__fp_symbolic_fp
22142 \scan_new:N \s__fp_symbolic
22143 \cs_new_protected:Npn \__fp_symbolic_chk:w #1,#2#3\__fp_sep:
22144 {
22145 \msg_error:nne { fp } { misused-fp }
22146 {
22147 \__fp_to_tl_dispatch:w
22148 \s__fp_symbolic \__fp_symbolic_chk:w #1,{#2}\__fp_sep:
22149 }
22150 }
22151 \cs_new:Npn \__fp_if_has_symbolic:nTF #1
22152 {
22153 \__fp_if_has_symbolic_aux:w
22154 #1 \s__fp_mark \use_i:nn
22155 \s__fp_symbolic \s__fp_mark \use_ii:nn
22156 \s__fp_stop
22157 }
22158 \cs_new:Npn \__fp_if_has_symbolic_aux:w
22159 #1 \s__fp_symbolic #2 \s__fp_mark #3#4 \s__fp_stop { #3 }
22160 \cs_new:Npn \__fp_exp_after_symbolic_f:nw
22161 #1 \s__fp_symbolic \__fp_symbolic_chk:w #2, #3#4\__fp_sep:
22162 {
22163 \exp_after:wN \__fp_exp_after_symbolic_aux:w
22164 \exp:w
22165 \__fp_exp_after_symbolic_loop:N #2
22166 { , \exp:w \use_none:nn }
22167 \exp_after:wN \exp_end: \exp_after:wN
22168 {
22169 \exp:w \exp_end_continue_f:w
22170 \__fp_exp_after_array_f:w #3 \s__fp_expr_stop
22171 \exp_after:wN
22172 }
22173 \exp_after:wN \__fp_sep:
22174 \exp:w \exp_end_continue_f:w #1
22175 }
22176 \cs_new:Npn \__fp_exp_after_symbolic_aux:w #1, #2\__fp_sep:
22177 {
22178 \__fp_if_has_symbolic:nTF {#2}
22179 { \s__fp_symbolic \__fp_symbolic_chk:w #1, {#2} \__fp_sep: }
22180 { #1 #2 @ \prg_do_nothing: }
22181 }
22182 \cs_new:Npn \__fp_exp_after_symbolic_loop:N #1
22183 {
22184 \exp_after:wN \exp_end:
22185 \exp_after:wN #1
22186 \exp:w
22187 \__fp_exp_after_symbolic_loop:N
22188 }
22189 \cs_new:Npn \__fp_symbolic_binary_o:Nww #1 #2\__fp_sep: #3\__fp_sep:
22190 {
22191 \__fp_exp_after_symbolic_f:nw { \exp_after:wN \exp_stop_f: }
22192 \s__fp_symbolic \__fp_symbolic_chk:w
22193 \__fp_types_binary:Nww #1 , { #2\__fp_sep: #3\__fp_sep: } \__fp_sep:
22194 }
22195 \cs_set_protected:Npn \__fp_tmp:w #1#2
22196 {
22197 \cs_new:cpn
22198 { __fp_symbolic_#2_symbolic_o:ww }
22199 { \__fp_symbolic_binary_o:Nww #1 }
22200 \cs_new_eq:cc
22201 { __fp_symbolic_#2 _o:ww }
22202 { __fp_symbolic_#2_symbolic_o:ww }
22203 \cs_new_eq:cc
22204 { __fp _#2_symbolic_o:ww }
22205 { __fp_symbolic_#2_symbolic_o:ww }
22206 }
22207 \tl_map_inline:nn { + - * / ^ & | } % |
22208 { \exp_args:Nc \__fp_tmp:w { __fp_#1_o:ww } {#1} }
22209 \cs_new:Npn \__fp_symbolic_unary_o:NNw #1#2#3\__fp_sep: @
22210 {
22211 \__fp_exp_after_symbolic_f:nw { \exp_after:wN \exp_stop_f: }
22212 \s__fp_symbolic \__fp_symbolic_chk:w
22213 \__fp_types_unary:NNw #1#2 , { #3\__fp_sep: } \__fp_sep:
22214 }
22215 \tl_map_inline:nn
22216 {
22217 {acos} {acsc} {asec} {asin} {cos} {cot} {csc} {exp} {fact} {ln}
22218 {not} {sec} {set_sign} {sin} {sign} {sqrt} {tan}
22219 }
22220 {
22221 \cs_new:cpe { __fp_symbolic_#1_o:w }
22222 {
22223 \exp_not:N \__fp_symbolic_unary_o:NNw
22224 \exp_not:c { __fp_#1_o:w }
22225 }
22226 }
22227 \cs_set_protected:Npn \__fp_tmp:w #1#2#3
22228 {
22229 \cs_new:cpn { __fp_symbolic_to_#1:w }
22230 {
22231 \exp_after:wN \__fp_symbolic_convert:wnnN
22232 \exp:w \exp_end_continue_f:w
22233 \__fp_exp_after_symbolic_f:nw { { #2 } { fp_to_#1 } #3 }
22234 }
22235 }
22236 \__fp_tmp:w { decimal } { 0 } \__fp_to_decimal_dispatch:w
22237 \__fp_tmp:w { int } { 0 } \__fp_to_int_dispatch:w
22238 \__fp_tmp:w { scientific } { nan } \__fp_to_scientific_dispatch:w
22239 \cs_new:Npn \__fp_symbolic_convert:wnnN #1#2\__fp_sep: #3#4#5
22240 {
22241 \str_if_eq:nnTF {#1} { \s__fp_symbolic }
22242 { \__fp_invalid_operation:nnw {#3} {#4} #1#2\__fp_sep: }
22243 { #5 #1#2\__fp_sep: }
22244 }
22245 \cs_new:Npn \__fp_symbolic_cs_arg_to_fn:NN #1
22246 {
22247 \exp_args:Nf \__fp_symbolic_op_arg_to_fn:nN
22248 { \__fp_types_cs_to_op:N #1 }
22249 }
22250 \cs_new:Npn \__fp_symbolic_op_arg_to_fn:nN #1#2
22251 {
22252 \str_case:nnF { #1 #2 }
22253 {
22254 { not ? } { ! }
22255 { set_sign 0 } { abs }
22256 { set_sign 2 } { - }
22257 }
22258 {
22259 \token_if_eq_meaning:NNTF #2 \use_ii:nn
22260 { #1 d } {#1}
22261 }
22262 }
22263 \cs_new:Npn \__fp_symbolic_to_tl:w
22264 \s__fp_symbolic \__fp_symbolic_chk:w #1#2, #3#4\__fp_sep:
22265 {
22266 \str_case:nnTF {#1}
22267 {
22268 { \__fp_types_unary:NNw } { \__fp_symbolic_unary_to_tl:NNw }
22269 { \__fp_types_binary:Nww } { \__fp_symbolic_binary_to_tl:Nww }
22270 { \__fp_function_o:w } { \__fp_symbolic_function_to_tl:Nw }
22271 }
22272 { #2, #3 @ }
22273 { \tl_to_str:n {#2} }
22274 }
22275 \cs_new:Npn \__fp_symbolic_unary_to_tl:NNw #1#2 , #3 @
22276 {
22277 \use:e
22278 {
22279 \__fp_symbolic_cs_arg_to_fn:NN #1#2
22280 ( \__fp_to_tl_dispatch:w #3 )
22281 }
22282 }
22283 \cs_new:Npn \__fp_symbolic_binary_to_tl:Nww #1, #2\__fp_sep: #3\__fp_sep: @
22284 {
22285 \use:e
22286 {
22287 ( \__fp_to_tl_dispatch:w #2\__fp_sep: )
22288 \__fp_types_cs_to_op:N #1
22289 ( \__fp_to_tl_dispatch:w #3\__fp_sep: )
22290 }
22291 }
22292 \cs_new:Npn \__fp_symbolic_function_to_tl:Nw #1, #2@
22293 {
22294 \use:e
22295 {
22296 \__fp_types_cs_to_op:N #1
22297 ( \__fp_array_to_clist:n {#2} )
22298 }
22299 }
22300 \prg_new_protected_conditional:Npnn
22301 \__fp_id_if_invalid:n #1 { T , F , TF }
22302 {
22303 \tl_if_empty:nTF {#1}
22304 { \prg_return_true: }
22305 {
22306 \tl_if_in:nnTF { #1 } { ~ }
22307 { \prg_return_true: }
22308 {
22309 \__fp_id_if_invalid_aux:N #1
22310 { ? \prg_break:n \prg_return_false: }
22311 \prg_break_point:
22312 }
22313 }
22314 }
22315 \cs_new:Npn \__fp_id_if_invalid_aux:N #1
22316 {
22317 \use_none:n #1
22318 \int_compare:nF { `a <= `#1 <= `z }
22319 {
22320 \int_compare:nF { `A <= `#1 <= `Z }
22321 { \prg_break:n \prg_return_true: }
22322 }
22323 \__fp_id_if_invalid_aux:N
22324 }
22325 \cs_new:Npn \__fp_variable_o:w #1 @ #2
22326 {
22327 \fp_if_exist:cTF { l__fp_variable_#1_fp }
22328 {
22329 \exp_last_unbraced:Nf \__fp_exp_after_array_f:w
22330 { \use:c { l__fp_variable_#1_fp } } \s__fp_expr_stop
22331 \exp_after:wN \exp_stop_f: #2
22332 }
22333 {
22334 \token_if_eq_meaning:NNTF #2 \prg_do_nothing:
22335 {
22336 \s__fp_symbolic \__fp_symbolic_chk:w
22337 \__fp_variable_o:w #1 , { } \__fp_sep:
22338 }
22339 {
22340 \exp_after:wN \s__fp_symbolic
22341 \exp_after:wN \__fp_symbolic_chk:w
22342 \exp_after:wN \__fp_variable_o:w
22343 \exp:w
22344 \__fp_exp_after_symbolic_loop:N #1
22345 { , \exp:w \use_none:nn }
22346 \exp_after:wN \exp_end:
22347 \exp_after:wN { \exp_after:wN } \exp_after:wN \__fp_sep:
22348 #2
22349 }
22350 }
22351 }
22352 \cs_new_protected:Npn \__fp_variable_set_parsing:Nn #1#2
22353 {
22354 \cs_set:Npn \__fp_tmp:w
22355 {
22356 \__fp_exp_after_symbolic_f:nw { \__fp_parse_infix:NN }
22357 \s__fp_symbolic \__fp_symbolic_chk:w
22358 \__fp_variable_o:w #2 , { } \__fp_sep:
22359 }
22360 \exp_args:NNc \__fp_variable_set_parsing_aux:NNn #1
22361 { __fp_parse_word_#2:N } {#2}
22362 }
22363 \cs_new_protected:Npn \__fp_variable_set_parsing_aux:NNn #1#2#3
22364 {
22365 \cs_if_eq:NNF #2 \__fp_tmp:w
22366 {
22367 \cs_if_exist:NTF #2
22368 {
22369 \msg_warning:nnnn
22370 { fp } { id-used-elsewhere } {#3} { variable }
22371 #1 #2 \__fp_tmp:w
22372 }
22373 {
22374 \cs_new_eq:NN #2 \scan_stop: % to declare the function
22375 #1 #2 \__fp_tmp:w
22376 }
22377 }
22378 }
22379 \cs_new_protected:Npn \fp_clear_variable:n #1
22380 {
22381 \exp_args:No \__fp_clear_variable:n { \tl_to_str:n {#1} }
22382 }
22383 \cs_new_protected:Npn \__fp_clear_variable:n #1
22384 {
22385 \__fp_id_if_invalid:nTF {#1}
22386 { \msg_error:nnn { fp } { id-invalid } {#1} }
22387 { \__fp_clear_variable_aux:n {#1} }
22388 }
22389 \cs_new_protected:Npn \__fp_clear_variable_aux:n #1
22390 {
22391 \cs_set_eq:cN { l__fp_variable_#1_fp } \tex_undefined:D
22392 \__fp_variable_set_parsing:Nn \cs_set_eq:NN {#1}
22393 }
22394 \cs_new_protected:Npn \fp_new_variable:n #1
22395 {
22396 \exp_args:No \__fp_new_variable:n { \tl_to_str:n {#1} }
22397 }
22398 \cs_new_protected:Npn \__fp_new_variable:n #1
22399 {
22400 \__fp_id_if_invalid:nTF {#1}
22401 { \msg_error:nnn { fp } { id-invalid } {#1} }
22402 {
22403 \cs_if_exist:cT { __fp_parse_word_#1:N }
22404 {
22405 \msg_error:nnn
22406 { fp } { id-already-defined } {#1}
22407 \cs_undefine:c { __fp_parse_word_#1:N }
22408 \cs_set_eq:cN { l__fp_variable_#1_fp } \tex_undefined:D
22409 }
22410 \__fp_variable_set_parsing:Nn \cs_gset_eq:NN {#1}
22411 }
22412 }
22413 \flag_new:N \l__fp_symbolic_flag
22414 \cs_new_protected:Npn \fp_set_variable:nn #1
22415 {
22416 \exp_args:No \__fp_set_variable:nn { \tl_to_str:n {#1} }
22417 }
22418 \cs_new_protected:Npn \__fp_set_variable:nn #1#2
22419 {
22420 \__fp_id_if_invalid:nTF {#1}
22421 { \msg_error:nnn { fp } { id-invalid } {#1} }
22422 {
22423 \cs_if_exist:cF { __fp_parse_word_#1:N }
22424 {
22425 \msg_error:nnn {fp} { id-undefined } {#1}
22426 \__fp_variable_set_parsing:Nn \cs_set_eq:NN {#1}
22427 }
22428 \fp_set:Nn \l__fp_symbolic_fp {#2}
22429 \cs_set_nopar:cpn { l__fp_variable_#1_fp }
22430 { \flag_ensure_raised:N \l__fp_symbolic_flag \c_nan_fp }
22431 \flag_clear:N \l__fp_symbolic_flag
22432 \fp_set:cn { l__fp_variable_#1_fp } { \l__fp_symbolic_fp }
22433 \flag_if_raised:NT \l__fp_symbolic_flag
22434 {
22435 \msg_error:nneee { fp } { id-loop }
22436 { #1 }
22437 { \tl_to_str:n {#2} }
22438 { \fp_to_tl:N \l__fp_symbolic_fp }
22439 }
22440 }
22441 }
22442 \msg_new:nnnn { fp } { id-invalid }
22443 { Floating~point~identifier~'#1'~invalid. }
22444 {
22445 LaTeX~has~been~asked~to~create~a~new~floating~point~identifier~'#1'~
22446 but~this~may~only~contain~ASCII~letters.
22447 }
22448 \msg_new:nnnn { fp } { id-already-defined }
22449 { Floating~point~identifier~'#1'~already~defined. }
22450 {
22451 LaTeX~has~been~asked~to~create~a~new~floating~point~identifier~'#1'~
22452 but~this~name~has~already~been~used~elsewhere.
22453 }
22454 \msg_new:nnnn { fp } { id-undefined }
22455 { Floating~point~identifier~'#1'~is~undefined. }
22456 {
22457 LaTeX~has~been~asked~to~set~a~floating~point~identifier~'#1'~
22458 but~this~name~has~not~been~declared.
22459 }
22460 \msg_new:nnnn { fp } { id-used-elsewhere }
22461 { Floating~point~identifier~'#1'~already~used~for~something~else. }
22462 {
22463 LaTeX~has~been~asked~to~create~a~new~floating~point~identifier~'#1'~
22464 but~this~name~is~used,~and~is~not~a~user-defined~#2.
22465 }
22466 \msg_new:nnnn { fp } { id-loop }
22467 { Variable~'#1'~used~in~the~definition~of~'#1'. }
22468 {
22469 LaTeX~has~been~asked~to~set~the~floating~point~identifier~'#1'~
22470 to~the~expression~'#2'.~Evaluating~this~expression~yields~'#3',~
22471 which~contains~'#1'~itself.
22472 }
22473 %% File l3fp-functions.dtx (C) Copyright 2012-2018,2020,2021,2023 The LaTeX Project
22474 \cs_new_protected:Npn \fp_new_function:n #1
22475 { \exp_args:No \__fp_new_function:n { \tl_to_str:n {#1} } }
22476 \cs_new_protected:Npn \__fp_new_function:n #1
22477 {
22478 \__fp_id_if_invalid:nTF {#1}
22479 { \msg_error:nnn { fp } { id-invalid } {#1} }
22480 {
22481 \cs_if_exist:cT { __fp_parse_word_#1:N }
22482 {
22483 \msg_error:nnn
22484 { fp } { id-already-defined } {#1}
22485 \cs_undefine:c { __fp_parse_word_#1:N }
22486 \cs_undefine:c { __fp_#1_o:w }
22487 }
22488 \__fp_function_set_parsing:Nn \cs_gset_eq:NN {#1}
22489 }
22490 }
22491 \cs_new_protected:Npn \__fp_function_set_parsing:Nn #1#2
22492 {
22493 \exp_args:NNc \__fp_function_set_parsing_aux:NNn #1
22494 { __fp_parse_word_#2:N } {#2}
22495 }
22496 \cs_new_protected:Npn \__fp_function_set_parsing_aux:NNn #1#2#3
22497 {
22498 \cs_set:Npe \__fp_tmp:w
22499 {
22500 \exp_not:N \__fp_parse_function:NNN
22501 \exp_not:N \__fp_function_o:w
22502 \exp_not:c { __fp_#3_o:w }
22503 }
22504 \cs_if_eq:NNF #2 \__fp_tmp:w
22505 {
22506 \cs_if_exist:NTF #2
22507 {
22508 \msg_warning:nnnn
22509 { fp } { id-used-elsewhere } {#3} { function }
22510 #1 #2 \__fp_tmp:w
22511 }
22512 {
22513 \cs_new_eq:NN #2 \scan_stop: % to declare the function
22514 #1 #2 \__fp_tmp:w
22515 }
22516 }
22517 }
22518 \cs_new:Npn \__fp_function_o:w #1#2 @
22519 {
22520 \cs_if_exist:NTF #1
22521 { #1 #2 @ }
22522 {
22523 \exp_after:wN \s__fp_symbolic
22524 \exp_after:wN \__fp_symbolic_chk:w
22525 \exp_after:wN \__fp_function_o:w
22526 \exp_after:wN #1
22527 \exp_after:wN ,
22528 \exp_after:wN {
22529 \exp:w \exp_end_continue_f:w
22530 \__fp_exp_after_array_f:w #2 \s__fp_expr_stop
22531 \exp_after:wN
22532 }
22533 \exp_after:wN \__fp_sep:
22534 }
22535 }
22536 \int_new:N \l__fp_function_arg_int
22537 \cs_new_protected:Npn \fp_set_function:nnn #1
22538 {
22539 \exp_args:NNo \__fp_set_function:Nnnn \cs_set_eq:cN
22540 { \tl_to_str:n {#1} }
22541 }
22542 \cs_new_protected:Npn \__fp_set_function:Nnnn #1#2#3#4
22543 {
22544 \__fp_id_if_invalid:nTF {#2}
22545 { \msg_error:nnn { fp } { id-invalid } {#2} }
22546 {
22547 \cs_if_exist:cF { __fp_parse_word_#2:N }
22548 {
22549 \msg_error:nnn {fp} { id-undefined } {#2}
22550 \__fp_function_set_parsing:Nn \cs_set_eq:NN {#2}
22551 }
22552 \group_begin:
22553 \int_zero:N \l__fp_function_arg_int
22554 \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#3} }
22555 {
22556 \int_incr:N \l__fp_function_arg_int
22557 \exp_args:Ne \__fp_clear_variable_aux:n
22558 {
22559 \c_underscore_str \tex_romannumeral:D \l__fp_function_arg_int
22560 }
22561 \fp_clear_variable:n {##1}
22562 \cs_set_nopar:cpe { l__fp_variable_##1_fp }
22563 {
22564 \exp_not:N \s__fp_symbolic
22565 \exp_not:N \__fp_symbolic_chk:w
22566 \exp_not:N \__fp_function_arg_o:w
22567 \int_use:N \l__fp_function_arg_int
22568 ########1 , { } \__fp_sep:
22569 }
22570 }
22571 \cs_set:Npn \__fp_function_arg_o:w ##1 @
22572 {
22573 \exp_after:wN \s__fp_symbolic
22574 \exp_after:wN \__fp_symbolic_chk:w
22575 \exp_after:wN \__fp_function_arg_o:w
22576 \tex_romannumeral:D
22577 \__fp_exp_after_symbolic_loop:N ##1
22578 { , \tex_romannumeral:D \use_none:nn }
22579 \exp_after:wN \c_zero_int
22580 \exp_after:wN { \exp_after:wN } \exp_after:wN \__fp_sep:
22581 }
22582 \fp_set:Nn \l__fp_symbolic_fp {#4}
22583 \use:e
22584 {
22585 \exp_not:n { \cs_gset:Npn \__fp_tmp:w ##1 }
22586 { \exp_not:o { \l__fp_symbolic_fp } }
22587 }
22588 \use:e
22589 {
22590 \exp_not:n { \cs_gset:Npn \__fp_tmp:w ##1 @ }
22591 {
22592 \exp_not:N \__fp_exp_after_symbolic_f:nw
22593 \exp_not:n { { \exp_after:wN \exp_stop_f: } }
22594 \exp_not:o { \__fp_tmp:w { . , {##1} } }
22595 }
22596 }
22597 \group_end:
22598 #1 { __fp_#2_o:w } \__fp_tmp:w
22599 }
22600 }
22601 \cs_new:Npn \__fp_function_arg_o:w #1. #2
22602 {
22603 \if_meaning:w @ #2
22604 \exp_after:wN \__fp_function_arg_few:w
22605 \fi:
22606 \if_int_compare:w #1 = \c_one_int
22607 \exp_after:wN \__fp_function_arg_get:w
22608 \fi:
22609 \__fp_use_i_until_s:nw
22610 {
22611 \exp_after:wN \__fp_function_arg_o:w
22612 \int_value:w \int_eval:n { #1 - 1 } .
22613 }
22614 #2
22615 }
22616 \cs_new:Npn \__fp_function_arg_few:w #1 @ { \exp_after:wN \c_nan_fp }
22617 \cs_new:Npn \__fp_function_arg_get:w #1#2#3\__fp_sep: #4 @
22618 {
22619 \__fp_exp_after_array_f:w #3\__fp_sep: \s__fp_expr_stop
22620 \exp_after:wN \exp_stop_f:
22621 }
22622 \cs_new_protected:Npn \fp_clear_function:n #1
22623 { \exp_args:No \__fp_clear_function:n { \tl_to_str:n {#1} } }
22624 \cs_new_protected:Npn \__fp_clear_function:n #1
22625 {
22626 \__fp_id_if_invalid:nTF {#1}
22627 { \msg_error:nnn { fp } { id-invalid } {#1} }
22628 {
22629 \cs_set_eq:cN { __fp_#1_o:w } \tex_undefine:D
22630 \__fp_function_set_parsing:Nn \cs_set_eq:NN {#1}
22631 }
22632 }
22633 %% File: l3fparray.dtx
22634 \int_new:N \g__fp_array_int
22635 \int_new:N \l__fp_array_loop_int
22636 \cs_new_protected:Npn \fparray_new:Nn #1#2
22637 {
22638 \tl_new:N #1
22639 \prg_replicate:nn { 3 }
22640 {
22641 \int_gincr:N \g__fp_array_int
22642 \exp_args:NNc \tl_gput_right:Nn #1
22643 { g__fp_array_ \__fp_int_to_roman:w \g__fp_array_int _intarray }
22644 }
22645 \exp_last_unbraced:Nfo \__fp_array_new:nNNNN
22646 { \int_eval:n {#2} } #1 #1
22647 }
22648 \cs_generate_variant:Nn \fparray_new:Nn { c }
22649 \cs_new_protected:Npn \__fp_array_new:nNNNN #1#2#3#4#5
22650 {
22651 \int_compare:nNnTF {#1} < 0
22652 {
22653 \msg_error:nnn { kernel } { negative-array-size } {#1}
22654 \cs_undefine:N #1
22655 \int_gsub:Nn \g__fp_array_int { 3 }
22656 }
22657 {
22658 \intarray_new:Nn #2 {#1}
22659 \intarray_new:Nn #3 {#1}
22660 \intarray_new:Nn #4 {#1}
22661 }
22662 }
22663 \cs_new:Npn \fparray_count:N #1
22664 {
22665 \exp_after:wN \use_i:nnn
22666 \exp_after:wN \intarray_count:N #1
22667 }
22668 \cs_generate_variant:Nn \fparray_count:N { c }
22669 \cs_new:Npn \__fp_array_bounds:NNnTF #1#2#3#4#5
22670 {
22671 \if_int_compare:w 1 > #3 \exp_stop_f:
22672 \__fp_array_bounds_error:NNn #1 #2 {#3}
22673 #5
22674 \else:
22675 \if_int_compare:w #3 > \fparray_count:N #2 \exp_stop_f:
22676 \__fp_array_bounds_error:NNn #1 #2 {#3}
22677 #5
22678 \else:
22679 #4
22680 \fi:
22681 \fi:
22682 }
22683 \cs_new:Npn \__fp_array_bounds_error:NNn #1#2#3
22684 {
22685 #1 { kernel } { out-of-bounds }
22686 { \token_to_str:N #2 } {#3} { \fparray_count:N #2 }
22687 }
22688 \cs_new_protected:Npn \fparray_gset:Nnn #1#2#3
22689 {
22690 \exp_after:wN \exp_after:wN
22691 \exp_after:wN \__fp_array_gset:NNNNww
22692 \exp_after:wN #1
22693 \exp_after:wN #1
22694 \int_value:w \int_eval:n {#2} \exp_after:wN \__fp_sep:
22695 \exp:w \exp_end_continue_f:w \__fp_parse:n {#3}
22696 }
22697 \cs_generate_variant:Nn \fparray_gset:Nnn { c }
22698 \cs_new_protected:Npn \__fp_array_gset:NNNNww #1#2#3#4#5 \__fp_sep: #6 \__fp_sep:
22699 {
22700 \__fp_array_bounds:NNnTF \msg_error:nneee #4 {#5}
22701 {
22702 \exp_after:wN \__fp_change_func_type:NNN
22703 \__fp_use_i_until_s:nw #6 \__fp_sep:
22704 \__fp_array_gset:w
22705 \__fp_array_gset_recover:Nw
22706 #6 \__fp_sep: {#5} #1 #2 #3
22707 }
22708 { }
22709 }
22710 \cs_new_protected:Npn \__fp_array_gset_recover:Nw #1#2 \__fp_sep:
22711 {
22712 \__fp_error:nffn { unknown-type } { \tl_to_str:n { #2 \__fp_sep: } } { } { }
22713 \exp_after:wN #1 \c_nan_fp
22714 }
22715 \cs_new_protected:Npn \__fp_array_gset:w \s__fp \__fp_chk:w #1#2
22716 {
22717 \if_case:w #1 \exp_stop_f:
22718 \__fp_case_return:nw { \__fp_array_gset_special:nnNNN {#2} }
22719 \or: \exp_after:wN \__fp_array_gset_normal:w
22720 \or: \__fp_case_return:nw { \__fp_array_gset_special:nnNNN { #2 3 } }
22721 \or: \__fp_case_return:nw { \__fp_array_gset_special:nnNNN { 1 } }
22722 \fi:
22723 \s__fp \__fp_chk:w #1 #2
22724 }
22725 \cs_new_protected:Npn \__fp_array_gset_normal:w
22726 \s__fp \__fp_chk:w 1 #1 #2 #3#4#5 \__fp_sep: #6#7#8#9
22727 {
22728 \__kernel_intarray_gset:Nnn #7 {#6} {#2}
22729 \__kernel_intarray_gset:Nnn #8 {#6}
22730 { \if_meaning:w 2 #1 3 \else: 1 \fi: #3#4 }
22731 \__kernel_intarray_gset:Nnn #9 {#6} { 1 \use:nn #5 }
22732 }
22733 \cs_new_protected:Npn \__fp_array_gset_special:nnNNN #1#2#3#4#5
22734 {
22735 \__kernel_intarray_gset:Nnn #3 {#2} {#1}
22736 \__kernel_intarray_gset:Nnn #4 {#2} {0}
22737 \__kernel_intarray_gset:Nnn #5 {#2} {0}
22738 }
22739 \cs_new_protected:Npn \fparray_gzero:N #1
22740 {
22741 \int_zero:N \l__fp_array_loop_int
22742 \prg_replicate:nn { \fparray_count:N #1 }
22743 {
22744 \int_incr:N \l__fp_array_loop_int
22745 \exp_after:wN \__fp_array_gset_special:nnNNN
22746 \exp_after:wN 0
22747 \exp_after:wN \l__fp_array_loop_int
22748 #1
22749 }
22750 }
22751 \cs_generate_variant:Nn \fparray_gzero:N { c }
22752 \cs_new:Npn \fparray_item:Nn #1#2
22753 {
22754 \exp_after:wN \__fp_array_item:NwN
22755 \exp_after:wN #1
22756 \int_value:w \int_eval:n {#2} \__fp_sep:
22757 \__fp_to_decimal:w
22758 }
22759 \cs_generate_variant:Nn \fparray_item:Nn { c }
22760 \cs_new:Npn \fparray_item_to_tl:Nn #1#2
22761 {
22762 \exp_after:wN \__fp_array_item:NwN
22763 \exp_after:wN #1
22764 \int_value:w \int_eval:n {#2} \__fp_sep:
22765 \__fp_to_tl:w
22766 }
22767 \cs_generate_variant:Nn \fparray_item_to_tl:Nn { c }
22768 \cs_new:Npn \__fp_array_item:NwN #1#2 \__fp_sep: #3
22769 {
22770 \__fp_array_bounds:NNnTF \msg_expandable_error:nnfff #1 {#2}
22771 { \exp_after:wN \__fp_array_item:NNNnN #1 {#2} #3 }
22772 { \exp_after:wN #3 \c_nan_fp }
22773 }
22774 \cs_new:Npn \__fp_array_item:NNNnN #1#2#3#4
22775 {
22776 \exp_after:wN \__fp_array_item:N
22777 \int_value:w \__kernel_intarray_item:Nn #2 {#4} \exp_after:wN \__fp_sep:
22778 \int_value:w \__kernel_intarray_item:Nn #3 {#4} \exp_after:wN \__fp_sep:
22779 \int_value:w \__kernel_intarray_item:Nn #1 {#4} \__fp_sep:
22780 }
22781 \cs_new:Npn \__fp_array_item:N #1
22782 {
22783 \if_meaning:w 0 #1 \exp_after:wN \__fp_array_item_special:w \fi:
22784 \__fp_array_item:w #1
22785 }
22786 \cs_new:Npn \__fp_array_item:w #1 #2#3#4#5 #6 \__fp_sep: 1 #7 \__fp_sep:
22787 {
22788 \exp_after:wN \__fp_array_item_normal:w
22789 \int_value:w \if_meaning:w #1 1 0 \else: 2 \fi: \exp_stop_f:
22790 #7 \__fp_sep: {#2#3#4#5} {#6} \__fp_sep:
22791 }
22792 \cs_new:Npn \__fp_array_item_special:w #1 \__fp_sep: #2 \__fp_sep: #3 \__fp_sep: #4
22793 {
22794 \exp_after:wN #4
22795 \exp:w \exp_end_continue_f:w
22796 \if_case:w #3 \exp_stop_f:
22797 \exp_after:wN \c_zero_fp
22798 \or: \exp_after:wN \c_nan_fp
22799 \or: \exp_after:wN \c_minus_zero_fp
22800 \or: \exp_after:wN \c_inf_fp
22801 \else: \exp_after:wN \c_minus_inf_fp
22802 \fi:
22803 }
22804 \cs_new:Npn \__fp_array_item_normal:w
22805 #1 #2#3#4#5 #6 \__fp_sep: #7 \__fp_sep: #8 \__fp_sep: #9
22806 { #9 \s__fp \__fp_chk:w 1 #1 {#8} #7 {#2#3#4#5} {#6} \__fp_sep: }
22807 \prg_new_eq_conditional:NNn \fparray_if_exist:N \cs_if_exist:N
22808 { TF , T , F , p }
22809 \prg_new_eq_conditional:NNn \fparray_if_exist:c \cs_if_exist:c
22810 { TF , T , F , p }
22811 %% File: l3bitset.dtx
22812 \cs_new_protected:Npn \bitset_new:N #1
22813 {
22814 \__kernel_chk_if_free_cs:N #1
22815 \cs_gset_eq:NN #1 \c_zero_str
22816 \prop_new:c { g__bitset_ \cs_to_str:N #1 _name_prop }
22817 }
22818 \cs_new_protected:Npn \bitset_new:Nn #1 #2
22819 {
22820 \__kernel_chk_if_free_cs:N #1
22821 \cs_gset_eq:NN #1 \c_zero_str
22822 \prop_new:c { g__bitset_ \cs_to_str:N #1 _name_prop }
22823 \prop_gset_from_keyval:cn
22824 { g__bitset_ \cs_to_str:N #1 _name_prop }
22825 {#2}
22826 }
22827 \cs_generate_variant:Nn \bitset_new:N { c }
22828 \cs_generate_variant:Nn \bitset_new:Nn { c }
22829 \cs_new_protected:Npn \bitset_addto_named_index:Nn #1#2
22830 {
22831 \prop_gput_from_keyval:cn
22832 { g__bitset_ \cs_to_str:N #1 _name_prop } { #2 }
22833 }
22834 \prg_new_eq_conditional:NNn
22835 \bitset_if_exist:N \str_if_exist:N { p , T , F , TF }
22836 \prg_new_eq_conditional:NNn
22837 \bitset_if_exist:c \str_if_exist:c { p , T , F , TF }
22838 \cs_new_protected:Npn \__bitset_set_true:Nn #1#2
22839 { \__bitset_set:NNnN \str_set:Ne #1 {#2} 1 }
22840 \cs_new_protected:Npn \__bitset_gset_true:Nn #1#2
22841 { \__bitset_set:NNnN \str_gset:Ne #1 {#2} 1 }
22842 \cs_new_protected:Npn \__bitset_set_false:Nn #1#2
22843 { \__bitset_set:NNnN \str_set:Ne #1 {#2} 0 }
22844 \cs_new_protected:Npn \__bitset_gset_false:Nn #1#2
22845 { \__bitset_set:NNnN \str_gset:Ne #1 {#2} 0 }
22846 \cs_new_protected:Npn \__bitset_set:NNnN #1#2#3#4
22847 {
22848 \int_compare:nNnT {#3} > { 0 }
22849 {
22850 \int_compare:nNnTF { \str_count:N #2 } < {#3}
22851 {
22852 #1 #2
22853 {
22854 #4
22855 \prg_replicate:nn { #3 - \str_count:N #2 - 1 } { 0 }
22856 #2
22857 }
22858 }
22859 {
22860 #1 #2
22861 {
22862 \str_range:Nnn #2 { 1 } { -1 - (#3) }
22863 #4
22864 \str_range:Nnn #2 { 1 - (#3) } { -1 }
22865 }
22866 }
22867 }
22868 }
22869 \int_new:N \l__bitset_tmp_int
22870 \prg_new_protected_conditional:Npnn \__bitset_test_digits:n #1 { TF }
22871 {
22872 \tex_afterassignment:D \__bitset_test_digits:w
22873 \l__bitset_tmp_int = 0 \tl_trim_spaces_apply:nN {#1} \tl_to_str:n
22874 \__bitset_test_digits_end:
22875 \use_i:nnn \if_false:
22876 \__bitset_test_digits_end:
22877 \if_int_compare:w \c_zero_int < \l__bitset_tmp_int
22878 \prg_return_true:
22879 \else:
22880 \prg_return_false:
22881 \fi:
22882 }
22883 \cs_new_eq:NN \__bitset_test_digits_end: \exp_stop_f:
22884 \cs_new_protected:Npn \__bitset_test_digits:w #1 \__bitset_test_digits_end: { }
22885 \cs_new_protected:Npn \bitset_set_true:Nn #1#2
22886 { \__bitset_set:NNn \__bitset_set_true:Nn #1 {#2} }
22887 \cs_new_protected:Npn \bitset_gset_true:Nn #1#2
22888 { \__bitset_set:NNn \__bitset_gset_true:Nn #1 {#2} }
22889 \cs_new_protected:Npn \bitset_set_false:Nn #1#2
22890 { \__bitset_set:NNn \__bitset_set_false:Nn #1 {#2} }
22891 \cs_new_protected:Npn \bitset_gset_false:Nn #1#2
22892 { \__bitset_set:NNn \__bitset_gset_false:Nn #1 {#2} }
22893 \cs_new_protected:Npn \__bitset_set:NNn #1#2#3
22894 {
22895 \prop_if_in:cnTF { g__bitset_ \cs_to_str:N #2 _name_prop } {#3}
22896 {
22897 #1 #2
22898 {
22899 \prop_item:cn { g__bitset_ \cs_to_str:N #2 _name_prop } {#3}
22900 }
22901 }
22902 {
22903 \__bitset_test_digits:nTF {#3}
22904 {
22905 #1 #2 {#3}
22906 \prop_gput:cnn { g__bitset_ \cs_to_str:N #2 _name_prop } {#3} {#3}
22907 }
22908 {
22909 \msg_warning:nnee { bitset } { unknown-name }
22910 { \token_to_str:N #2 }
22911 { \tl_to_str:n {#3} }
22912 }
22913 }
22914 }
22915 \cs_generate_variant:Nn \bitset_set_true:Nn { c }
22916 \cs_generate_variant:Nn \bitset_gset_true:Nn { c }
22917 \cs_generate_variant:Nn \bitset_set_false:Nn { c }
22918 \cs_generate_variant:Nn \bitset_gset_false:Nn { c }
22919 \cs_new_protected:Npn \bitset_clear:N #1
22920 {
22921 \str_set_eq:NN #1 \c_zero_str
22922 }
22923 \cs_new_protected:Npn \bitset_gclear:N #1
22924 {
22925 \str_gset_eq:NN #1 \c_zero_str
22926 }
22927 \cs_generate_variant:Nn \bitset_clear:N { c }
22928 \cs_generate_variant:Nn \bitset_gclear:N { c }
22929 \cs_new:Npn \bitset_to_arabic:N #1
22930 {
22931 \int_compare:nNnTF { \str_count:N #1 } < { 32 }
22932 { \exp_args:No \int_from_bin:n {#1} }
22933 {
22934 \exp_after:wN \__bitset_to_int:nN \exp_after:wN 0
22935 #1 \q_recursion_tail \q_recursion_stop
22936 }
22937 }
22938 \cs_new:Npn \__bitset_to_int:nN #1#2
22939 {
22940 \quark_if_recursion_tail_stop_do:Nn #2 {#1}
22941 \exp_args:Nf \__bitset_to_int:nN { \fp_eval:n { #1 * 2 + #2 } }
22942 }
22943 \cs_new:Npn \bitset_to_bin:N #1
22944 {
22945 #1
22946 }
22947 \cs_generate_variant:Nn \bitset_to_arabic:N { c }
22948 \cs_generate_variant:Nn \bitset_to_bin:N { c }
22949 \cs_new_eq:NN \bitset_use:N \tl_use:N
22950 \cs_generate_variant:Nn \bitset_use:N { c }
22951 \cs_new:Npn \bitset_item:Nn #1#2
22952 {
22953 \prop_if_in:cnTF { g__bitset_ \cs_to_str:N #1 _name_prop } {#2}
22954 {
22955 \int_eval:n
22956 {
22957 \str_item:Nn #1
22958 { 0 - ( \prop_item:cn { g__bitset_ \cs_to_str:N #1 _name_prop } {#2} ) }
22959 +0
22960 }
22961 }
22962 {
22963 0
22964 }
22965 }
22966 \cs_generate_variant:Nn \bitset_item:Nn { c }
22967 \cs_new_protected:Npn \bitset_show:N { \__bitset_show:NN \msg_show:nneeee }
22968 \cs_generate_variant:Nn \bitset_show:N { c }
22969 \cs_new_protected:Npn \bitset_log:N { \__bitset_show:NN \msg_log:nneeee }
22970 \cs_generate_variant:Nn \bitset_log:N { c }
22971 \cs_new_protected:Npn \__bitset_show:NN #1#2
22972 {
22973 \__kernel_chk_defined:NT #2
22974 {
22975 #1 { bitset } { show }
22976 { \token_to_str:N #2 }
22977 { \bitset_to_bin:N #2 }
22978 { \bitset_to_arabic:N #2 }
22979 { }
22980 }
22981 }
22982 \cs_new_protected:Npn \bitset_show_named_index:N
22983 { \__bitset_show_named_index:NN \msg_show:nneeee }
22984 \cs_generate_variant:Nn \bitset_show_named_index:N { c }
22985 \cs_new_protected:Npn \bitset_log_named_index:N
22986 { \__bitset_show_named_index:NN \msg_log:nneeee }
22987 \cs_generate_variant:Nn \bitset_log_named_index:N { c }
22988 \cs_new_protected:Npn \__bitset_show_named_index:NN #1#2
22989 {
22990 \__kernel_chk_defined:NT #2
22991 {
22992 #1 { bitset } { show-names }
22993 { \token_to_str:N #2 }
22994 { \prop_map_function:cN { g__bitset_ \cs_to_str:N #2 _name_prop } \msg_show_item:nn }
22995 { } { }
22996 }
22997 }
22998 \msg_new:nnn { bitset } { show }
22999 {
23000 The~bitset~#1~has~the~representation: \\
23001 >~binary:~#2 \\
23002 >~arabic:~#3 .
23003 }
23004 \msg_new:nnn { bitset } { show-names }
23005 {
23006 The~bitset~#1~
23007 \tl_if_empty:nTF {#2}
23008 { knows~no~names~yet \\>~ . }
23009 { knows~the~name/index~pairs~(without~outer~braces): #2 . }
23010 }
23011 \msg_new:nnn { bitset } { unknown-name }
23012 { The~name~'#2'~is~unknown~for~bitset~\tl_to_str:n {#1} }
23013 \prop_gput:Nnn \g_msg_module_name_prop { bitset } { LaTeX }
23014 \prop_gput:Nnn \g_msg_module_type_prop { bitset } { }
23015 %% File: l3cctab.dtx
23016 \seq_new:N \g__cctab_stack_seq
23017 \seq_new:N \g__cctab_unused_seq
23018 \seq_new:N \g__cctab_group_seq
23019 \int_new:N \g__cctab_allocate_int
23020 \tl_new:N \l__cctab_tmpa_tl
23021 \tl_new:N \l__cctab_tmpb_tl
23022 \prop_new:N \g__cctab_endlinechar_prop
23023 \sys_if_engine_luatex:TF
23024 {
23025 \cs_new_protected:Npn \cctab_new:N #1
23026 {
23027 \__kernel_chk_if_free_cs:N #1
23028 \__cctab_new:N #1
23029 }
23030 \cs_new_protected:Npn \__cctab_new:N #1
23031 {
23032 \newcatcodetable #1
23033 \tex_initcatcodetable:D #1
23034 }
23035 }
23036 {
23037 \cs_new_protected:Npn \__cctab_new:N #1
23038 {
23039 \debug_suspend:
23040 \intarray_new:Nn #1 { 257 }
23041 \debug_resume:
23042 }
23043 \cs_new_protected:Npn \__cctab_gstore:Nnn #1#2#3
23044 { \intarray_gset:Nnn #1 { #2 + 1 } {#3} }
23045 \cs_new_protected:Npn \cctab_new:N #1
23046 {
23047 \__kernel_chk_if_free_cs:N #1
23048 \__cctab_new:N #1
23049 \int_step_inline:nn { 256 }
23050 { \__kernel_intarray_gset:Nnn #1 {##1} { 12 } }
23051 \__kernel_intarray_gset:Nnn #1 { 257 } { 13 }
23052 \__cctab_gstore:Nnn #1 { 0 } { 9 }
23053 \__cctab_gstore:Nnn #1 { 13 } { 5 }
23054 \__cctab_gstore:Nnn #1 { 32 } { 10 }
23055 \__cctab_gstore:Nnn #1 { 37 } { 14 }
23056 \int_step_inline:nnn { 65 } { 90 }
23057 { \__cctab_gstore:Nnn #1 {##1} { 11 } }
23058 \__cctab_gstore:Nnn #1 { 92 } { 0 }
23059 \int_step_inline:nnn { 97 } { 122 }
23060 { \__cctab_gstore:Nnn #1 {##1} { 11 } }
23061 \__cctab_gstore:Nnn #1 { 127 } { 15 }
23062 }
23063 }
23064 \cs_generate_variant:Nn \cctab_new:N { c }
23065 \sys_if_engine_luatex:TF
23066 {
23067 \cs_new_protected:Npn \__cctab_gset:n #1
23068 { \exp_args:Nf \__cctab_gset_aux:n { \int_eval:n {#1} } }
23069 \cs_new_protected:Npn \__cctab_gset_aux:n #1
23070 {
23071 \tex_savecatcodetable:D #1 \scan_stop:
23072 \int_compare:nNnTF { \tex_endlinechar:D } = { 13 }
23073 { \prop_gremove:Nn \g__cctab_endlinechar_prop {#1} }
23074 {
23075 \prop_gput:NnV \g__cctab_endlinechar_prop {#1}
23076 \tex_endlinechar:D
23077 }
23078 }
23079 }
23080 {
23081 \cs_new_protected:Npn \__cctab_gset:n #1
23082 {
23083 \int_step_inline:nn { 256 }
23084 {
23085 \__kernel_intarray_gset:Nnn #1 {##1}
23086 { \char_value_catcode:n { ##1 - 1 } }
23087 }
23088 \__kernel_intarray_gset:Nnn #1 { 257 }
23089 { \tex_endlinechar:D }
23090 }
23091 }
23092 \cs_new_protected:Npn \cctab_gset:Nn #1#2
23093 {
23094 \__cctab_chk_if_valid:NT #1
23095 {
23096 \group_begin:
23097 \cctab_select:N \c_initex_cctab
23098 #2 \scan_stop:
23099 \__cctab_gset:n {#1}
23100 \group_end:
23101 }
23102 }
23103 \cs_generate_variant:Nn \cctab_gset:Nn { c }
23104 \cs_new_protected:Npn \cctab_gsave_current:N #1
23105 {
23106 \__cctab_chk_if_valid:NT #1
23107 { \__cctab_gset:n {#1} }
23108 }
23109 \cs_generate_variant:Nn \cctab_gsave_current:N { c }
23110 \sys_if_engine_luatex:T
23111 {
23112 \__cctab_new:N \g__cctab_tmp_cctab
23113 \cs_new:Npn \__cctab_tmp_cctab_name:
23114 {
23115 g__cctab_tmp
23116 \tex_romannumeral:D \tex_currentgrouplevel:D
23117 _cctab
23118 }
23119 }
23120 \cs_new_protected:Npn \cctab_select:N #1
23121 { \__cctab_chk_if_valid:NT #1 { \__cctab_select:N #1 } }
23122 \cs_generate_variant:Nn \cctab_select:N { c }
23123 \sys_if_engine_luatex:TF
23124 {
23125 \cs_new_protected:Npn \__cctab_select:N #1
23126 {
23127 \tex_catcodetable:D #1
23128 \prop_get:NVNTF \g__cctab_endlinechar_prop #1 \l__cctab_tmpa_tl
23129 { \int_set:Nn \tex_endlinechar:D { \l__cctab_tmpa_tl } }
23130 { \int_set:Nn \tex_endlinechar:D { 13 } }
23131 \cs_if_exist:cF { \__cctab_tmp_cctab_name: }
23132 { \exp_args:Nc \__cctab_new:N { \__cctab_tmp_cctab_name: } }
23133 \exp_args:Nc \tex_savecatcodetable:D { \__cctab_tmp_cctab_name: }
23134 \exp_args:Nc \tex_catcodetable:D { \__cctab_tmp_cctab_name: }
23135 }
23136 }
23137 {
23138 \cs_new_protected:Npn \__cctab_select:N #1
23139 {
23140 \int_step_inline:nn { 256 }
23141 {
23142 \char_set_catcode:nn { ##1 - 1 }
23143 { \__kernel_intarray_item:Nn #1 {##1} }
23144 }
23145 \int_set:Nn \tex_endlinechar:D
23146 { \__kernel_intarray_item:Nn #1 { 257 } }
23147 }
23148 }
23149 \sys_if_engine_luatex:TF
23150 {
23151 \cs_new_protected:Npn \__cctab_begin_aux:
23152 {
23153 \__cctab_new:N \g__cctab_next_cctab
23154 \tl_set:NV \l__cctab_tmpa_tl \g__cctab_next_cctab
23155 \cs_undefine:N \g__cctab_next_cctab
23156 }
23157 }
23158 {
23159 \cs_new_protected:Npn \__cctab_begin_aux:
23160 {
23161 \int_gincr:N \g__cctab_allocate_int
23162 \exp_args:Nc \__cctab_new:N
23163 { g__cctab_ \int_use:N \g__cctab_allocate_int _cctab }
23164 \exp_args:NNc \tl_set:Nn \l__cctab_tmpa_tl
23165 { g__cctab_ \int_use:N \g__cctab_allocate_int _cctab }
23166 }
23167 }
23168 \cs_new_protected:Npn \cctab_begin:N #1
23169 {
23170 \__cctab_chk_if_valid:NT #1
23171 {
23172 \seq_gpop:NNF \g__cctab_unused_seq \l__cctab_tmpa_tl
23173 { \__cctab_begin_aux: }
23174 \__cctab_chk_group_begin:e
23175 { \__cctab_nesting_number:N \l__cctab_tmpa_tl }
23176 \seq_gpush:NV \g__cctab_stack_seq \l__cctab_tmpa_tl
23177 \exp_args:NV \__cctab_gset:n \l__cctab_tmpa_tl
23178 \__cctab_select:N #1
23179 }
23180 }
23181 \cs_generate_variant:Nn \cctab_begin:N { c }
23182 \cs_new_protected:Npn \cctab_end:
23183 {
23184 \seq_gpop:NNTF \g__cctab_stack_seq \l__cctab_tmpa_tl
23185 {
23186 \seq_gpush:NV \g__cctab_unused_seq \l__cctab_tmpa_tl
23187 \exp_args:Ne \__cctab_chk_group_end:n
23188 { \__cctab_nesting_number:N \l__cctab_tmpa_tl }
23189 \__cctab_select:N \l__cctab_tmpa_tl
23190 }
23191 { \msg_error:nn { cctab } { extra-end } }
23192 }
23193 \cs_new_protected:Npn \__cctab_chk_group_begin:n #1
23194 {
23195 \seq_gpush:Ne \g__cctab_group_seq
23196 { \int_use:N \tex_currentgrouplevel:D }
23197 \cs_set_eq:cN { __cctab_group_ #1 _chk: } \prg_do_nothing:
23198 }
23199 \cs_generate_variant:Nn \__cctab_chk_group_begin:n { e }
23200 \cs_new_protected:Npn \__cctab_chk_group_end:n #1
23201 {
23202 \seq_gpop:NN \g__cctab_group_seq \l__cctab_tmpb_tl
23203 \bool_lazy_and:nnF
23204 {
23205 \int_compare_p:nNn
23206 { \tex_currentgrouplevel:D } = { \l__cctab_tmpb_tl }
23207 }
23208 { \cs_if_exist_p:c { __cctab_group_ #1 _chk: } }
23209 {
23210 \msg_error:nne { cctab } { group-mismatch }
23211 {
23212 \int_sign:n
23213 { \tex_currentgrouplevel:D - \l__cctab_tmpb_tl }
23214 }
23215 }
23216 \cs_undefine:c { __cctab_group_ #1 _chk: }
23217 }
23218 \sys_if_engine_luatex:TF
23219 { \cs_new:Npn \__cctab_nesting_number:N #1 {#1} }
23220 {
23221 \cs_new:Npn \__cctab_nesting_number:N #1
23222 {
23223 \exp_after:wN \exp_after:wN \exp_after:wN \__cctab_nesting_number:w
23224 \exp_after:wN \token_to_str:N #1
23225 }
23226 \use:e
23227 {
23228 \cs_new:Npn \exp_not:N \__cctab_nesting_number:w
23229 #1 \tl_to_str:n { g__cctab_ } #2 \tl_to_str:n { _cctab } {#2}
23230 }
23231 }
23232 \cs_if_exist:NT \hook_gput_code:nnn
23233 {
23234 \hook_gput_code:nnn { enddocument/end } { cctab }
23235 {
23236 \seq_if_empty:NF \g__cctab_stack_seq
23237 { \msg_error:nn { cctab } { missing-end } }
23238 }
23239 }
23240 \cs_new:Npn \cctab_item:Nn #1#2
23241 { \exp_args:Nf \__cctab_item:nN { \int_eval:n {#2} } #1 }
23242 \sys_if_engine_luatex:TF
23243 {
23244 \cs_new:Npn \__cctab_item:nN #1#2
23245 { \lua_now:e { tex.print(-2, tex.getcatcode(\int_use:N #2, #1)) } }
23246 }
23247 {
23248 \cs_new:Npn \__cctab_item:nN #1#2
23249 {
23250 \int_compare:nNnTF {#1} < { 256 }
23251 { \intarray_item:Nn #2 { #1 + 1 } }
23252 { \char_value_catcode:n {#1} }
23253 }
23254 }
23255 \cs_generate_variant:Nn \cctab_item:Nn { c }
23256 \prg_new_eq_conditional:NNn \cctab_if_exist:N \cs_if_exist:N
23257 { TF , T , F , p }
23258 \prg_new_eq_conditional:NNn \cctab_if_exist:c \cs_if_exist:c
23259 { TF , T , F , p }
23260 \prg_new_protected_conditional:Npnn \__cctab_chk_if_valid:N #1
23261 { TF , T , F }
23262 {
23263 \cctab_if_exist:NTF #1
23264 {
23265 \__cctab_chk_if_valid_aux:NTF #1
23266 { \prg_return_true: }
23267 {
23268 \msg_error:nne { cctab } { invalid-cctab }
23269 { \token_to_str:N #1 }
23270 \prg_return_false:
23271 }
23272 }
23273 {
23274 \msg_error:nne { kernel } { command-not-defined }
23275 { \token_to_str:N #1 }
23276 \prg_return_false:
23277 }
23278 }
23279 \sys_if_engine_luatex:TF
23280 {
23281 \cs_new_protected:Npn \__cctab_chk_if_valid_aux:NTF #1
23282 {
23283 \int_compare:nNnTF {#1-1} < { \e@alloc@ccodetable@count }
23284 }
23285 \cs_if_exist:NT \c_syst_catcodes_n
23286 {
23287 \cs_gset_protected:Npn \__cctab_chk_if_valid_aux:NTF #1
23288 {
23289 \int_compare:nTF { #1 <= \c_syst_catcodes_n }
23290 }
23291 }
23292 }
23293 {
23294 \cs_new_protected:Npn \__cctab_chk_if_valid_aux:NTF #1
23295 {
23296 \exp_args:Nf \str_if_in:nnTF
23297 { \cs_meaning:N #1 }
23298 { select~font~cmr10~at~ }
23299 }
23300 }
23301 \cs_new_protected:Npn \cctab_const:Nn #1#2
23302 {
23303 \__kernel_chk_if_free_cs:N #1
23304 \__cctab_new:N #1
23305 \group_begin:
23306 \cctab_select:N \c_initex_cctab
23307 #2 \scan_stop:
23308 \__cctab_gset:n {#1}
23309 \group_end:
23310 }
23311 \cs_generate_variant:Nn \cctab_const:Nn { c }
23312 \cctab_new:N \c_initex_cctab
23313 \cctab_const:Nn \c_other_cctab
23314 {
23315 \cctab_select:N \c_initex_cctab
23316 \int_set:Nn \tex_endlinechar:D { -1 }
23317 \int_step_inline:nnn { 0 } { 127 }
23318 { \char_set_catcode_other:n {#1} }
23319 }
23320 \cctab_const:Nn \c_str_cctab
23321 {
23322 \cctab_select:N \c_other_cctab
23323 \char_set_catcode_space:n { 32 }
23324 }
23325 \cs_if_exist:NTF \@expl@finalise@setup@@
23326 { \tl_gput_right:Nn \@expl@finalise@setup@@ }
23327 { \use:n }
23328 {
23329 \__cctab_new:N \c_code_cctab
23330 \group_begin:
23331 \int_set:Nn \tex_endlinechar:D { 32 }
23332 \char_set_catcode_invalid:n { 0 }
23333 \sys_if_engine_opentype:TF
23334 { \int_step_function:nN { 31 } \char_set_catcode_invalid:n }
23335 { \int_step_function:nN { 31 } \char_set_catcode_active:n }
23336 \int_step_function:nnN { 33 } { 64 } \char_set_catcode_other:n
23337 \int_step_function:nnN { 65 } { 90 } \char_set_catcode_letter:n
23338 \int_step_function:nnN { 91 } { 96 } \char_set_catcode_other:n
23339 \int_step_function:nnN { 97 } { 122 } \char_set_catcode_letter:n
23340 \char_set_catcode_ignore:n { 9 } % tab
23341 \char_set_catcode_other:n { 10 } % lf
23342 \char_set_catcode_active:n { 12 } % ff
23343 \char_set_catcode_end_line:n { 13 } % cr
23344 \char_set_catcode_ignore:n { 32 } % space
23345 \char_set_catcode_parameter:n { 35 } % hash
23346 \char_set_catcode_math_toggle:n { 36 } % dollar
23347 \char_set_catcode_comment:n { 37 } % percent
23348 \char_set_catcode_alignment:n { 38 } % ampersand
23349 \char_set_catcode_letter:n { 58 } % colon
23350 \char_set_catcode_escape:n { 92 } % backslash
23351 \char_set_catcode_math_superscript:n { 94 } % circumflex
23352 \char_set_catcode_letter:n { 95 } % underscore
23353 \char_set_catcode_group_begin:n { 123 } % left brace
23354 \char_set_catcode_other:n { 124 } % pipe
23355 \char_set_catcode_group_end:n { 125 } % right brace
23356 \char_set_catcode_space:n { 126 } % tilde
23357 \char_set_catcode_invalid:n { 127 } % ^^?
23358 \sys_if_engine_opentype:F
23359 { \int_step_function:nnN { 128 } { 255 } \char_set_catcode_active:n }
23360 \__cctab_gset:n { \c_code_cctab }
23361 \group_end:
23362 \cctab_const:Nn \c_document_cctab
23363 {
23364 \cctab_select:N \c_code_cctab
23365 \int_set:Nn \tex_endlinechar:D { 13 }
23366 \char_set_catcode_space:n { 9 }
23367 \char_set_catcode_space:n { 32 }
23368 \char_set_catcode_other:n { 58 }
23369 \char_set_catcode_math_subscript:n { 95 }
23370 \char_set_catcode_active:n { 126 }
23371 }
23372 }
23373 \cctab_new:N \g_tmpa_cctab
23374 \cctab_new:N \g_tmpb_cctab
23375 \msg_new:nnnn { cctab } { stack-full }
23376 { The~category~code~table~stack~is~exhausted. }
23377 {
23378 LaTeX~has~been~asked~to~switch~to~a~new~category~code~table,~
23379 but~there~is~no~more~space~to~do~this!
23380 }
23381 \msg_new:nnnn { cctab } { extra-end }
23382 { Extra~\iow_char:N\\cctab_end:~ignored~\msg_line_context:. }
23383 {
23384 LaTeX~came~across~a~\iow_char:N\\cctab_end:~without~a~matching~
23385 \iow_char:N\\cctab_begin:N.~This~command~will~be~ignored.
23386 }
23387 \msg_new:nnnn { cctab } { missing-end }
23388 { Missing~\iow_char:N\\cctab_end:~before~end~of~TeX~run. }
23389 {
23390 LaTeX~came~across~more~\iow_char:N\\cctab_begin:N~than~
23391 \iow_char:N\\cctab_end:.
23392 }
23393 \msg_new:nnnn { cctab } { invalid-cctab }
23394 { Invalid~\iow_char:N\\catcode~table. }
23395 {
23396 You~can~only~switch~to~a~\iow_char:N\\catcode~table~that~is~
23397 initialized~using~\iow_char:N\\cctab_new:N~or~
23398 \iow_char:N\\cctab_const:Nn.
23399 }
23400 \msg_new:nnnn { cctab } { group-mismatch }
23401 {
23402 \iow_char:N\\cctab_end:~occurred~in~a~
23403 \int_case:nn {#1}
23404 {
23405 { 0 } { different~group }
23406 { 1 } { higher~group~level }
23407 { -1 } { lower~group~level }
23408 } ~than~
23409 the~matching~\iow_char:N\\cctab_begin:N.
23410 }
23411 {
23412 Catcode~tables~and~groups~must~be~properly~nested,~but~
23413 you~tried~to~interleave~them.~LaTeX~will~try~to~proceed,~
23414 but~results~may~be~unexpected.
23415 }
23416 \prop_gput:Nnn \g_msg_module_name_prop { cctab } { LaTeX }
23417 \prop_gput:Nnn \g_msg_module_type_prop { cctab } { }
23418 %% File l3sort.dtx
23419 \cs_new_eq:NN \__sort_sep: \__kernel_int_sep:
23420 \seq_new:N \g__sort_tmp_seq
23421 \tl_new:N \g__sort_tmp_tl
23422 \int_new:N \l__sort_length_int
23423 \int_new:N \l__sort_min_int
23424 \int_new:N \l__sort_top_int
23425 \int_new:N \l__sort_max_int
23426 \int_new:N \l__sort_true_max_int
23427 \int_new:N \l__sort_block_int
23428 \int_new:N \l__sort_begin_int
23429 \int_new:N \l__sort_end_int
23430 \int_new:N \l__sort_A_int
23431 \int_new:N \l__sort_B_int
23432 \int_new:N \l__sort_C_int
23433 \scan_new:N \s__sort_mark
23434 \scan_new:N \s__sort_stop
23435 \cs_new_protected:Npn \__sort_shrink_range:
23436 {
23437 \int_set:Nn \l__sort_A_int
23438 { \l__sort_true_max_int - \l__sort_min_int + 1 }
23439 \int_set:Nn \l__sort_block_int { \c_max_register_int / 2 }
23440 \__sort_shrink_range_loop:
23441 \int_set:Nn \l__sort_max_int
23442 {
23443 \int_compare:nNnTF
23444 { \l__sort_block_int * 3 / 2 } > \l__sort_A_int
23445 {
23446 \l__sort_min_int
23447 + ( \l__sort_A_int - 1 ) / 2
23448 + \l__sort_block_int / 4
23449 - 1
23450 }
23451 { \l__sort_true_max_int - \l__sort_block_int / 2 }
23452 }
23453 }
23454 \cs_new_protected:Npn \__sort_shrink_range_loop:
23455 {
23456 \if_int_compare:w \l__sort_A_int < \l__sort_block_int
23457 \tex_divide:D \l__sort_block_int 2 \exp_stop_f:
23458 \exp_after:wN \__sort_shrink_range_loop:
23459 \fi:
23460 }
23461 \cs_new_protected:Npn \__sort_compute_range:
23462 {
23463 \int_set:Nn \l__sort_min_int { \tex_count:D 15 + 1 }
23464 \int_set:Nn \l__sort_true_max_int { \c_max_register_int + 1 }
23465 \__sort_shrink_range:
23466 \if_meaning:w \loctoks \tex_undefined:D \else:
23467 \if_meaning:w \loctoks \scan_stop: \else:
23468 \__sort_redefine_compute_range:
23469 \__sort_compute_range:
23470 \fi:
23471 \fi:
23472 }
23473 \cs_new_protected:Npn \__sort_redefine_compute_range:
23474 {
23475 \cs_if_exist:cTF { [email protected] }
23476 {
23477 \cs_gset_protected:Npn \__sort_compute_range:
23478 {
23479 \int_set:Nn \l__sort_min_int { \tex_count:D 265 }
23480 \int_set_eq:NN \l__sort_true_max_int \e@alloc@top
23481 \__sort_shrink_range:
23482 }
23483 }
23484 {
23485 \cs_gset_protected:Npn \__sort_compute_range:
23486 {
23487 \int_set:Nn \l__sort_min_int { \tex_count:D 265 }
23488 \int_set:Nn \l__sort_true_max_int { \tex_count:D 275 }
23489 \__sort_shrink_range:
23490 }
23491 }
23492 }
23493 \cs_if_exist:NT \loctoks { \__sort_redefine_compute_range: }
23494 \tl_map_inline:nn { \lastallocatedtoks \c_syst_last_allocated_toks }
23495 {
23496 \cs_if_exist:NT #1
23497 {
23498 \cs_gset_protected:Npn \__sort_compute_range:
23499 {
23500 \int_set:Nn \l__sort_min_int { #1 + 1 }
23501 \int_set:Nn \l__sort_true_max_int { \c_max_register_int + 1 }
23502 \__sort_shrink_range:
23503 }
23504 }
23505 }
23506 \cs_new_protected:Npn \__sort_main:NNNn #1#2#3#4
23507 {
23508 \__sort_disable_toksdef:
23509 \__sort_compute_range:
23510 \int_set_eq:NN \l__sort_top_int \l__sort_min_int
23511 #1 #3
23512 {
23513 \if_int_compare:w \l__sort_top_int = \l__sort_max_int
23514 \__sort_too_long_error:NNw #2 #3
23515 \fi:
23516 \tex_toks:D \l__sort_top_int {##1}
23517 \int_incr:N \l__sort_top_int
23518 }
23519 \int_set:Nn \l__sort_length_int
23520 { \l__sort_top_int - \l__sort_min_int }
23521 \cs_set:Npn \__sort_compare:nn ##1 ##2 {#4}
23522 \int_set:Nn \l__sort_block_int { 1 }
23523 \__sort_level:
23524 }
23525 \cs_new_protected:Npn \tl_sort:Nn { \__sort_tl:NNn \tl_set_eq:NN }
23526 \cs_generate_variant:Nn \tl_sort:Nn { c }
23527 \cs_new_protected:Npn \tl_gsort:Nn { \__sort_tl:NNn \tl_gset_eq:NN }
23528 \cs_generate_variant:Nn \tl_gsort:Nn { c }
23529 \cs_new_protected:Npn \__sort_tl:NNn #1#2#3
23530 {
23531 \group_begin:
23532 \__sort_main:NNNn \tl_map_inline:Nn \tl_map_break:n #2 {#3}
23533 \__kernel_tl_gset:Nx \g__sort_tmp_tl
23534 { \__sort_tl_toks:w \l__sort_min_int \__sort_sep: }
23535 \group_end:
23536 #1 #2 \g__sort_tmp_tl
23537 \tl_gclear:N \g__sort_tmp_tl
23538 \prg_break_point:
23539 }
23540 \cs_new:Npn \__sort_tl_toks:w #1 \__sort_sep:
23541 {
23542 \if_int_compare:w #1 < \l__sort_top_int
23543 { \tex_the:D \tex_toks:D #1 }
23544 \exp_after:wN \__sort_tl_toks:w
23545 \int_value:w \int_eval:n { #1 + 1 } \exp_after:wN \__sort_sep:
23546 \fi:
23547 }
23548 \cs_new_protected:Npn \seq_sort:Nn
23549 { \__sort_seq:NNNNn \seq_map_inline:Nn \seq_map_break:n \seq_set_eq:NN }
23550 \cs_generate_variant:Nn \seq_sort:Nn { c }
23551 \cs_new_protected:Npn \seq_gsort:Nn
23552 { \__sort_seq:NNNNn \seq_map_inline:Nn \seq_map_break:n \seq_gset_eq:NN }
23553 \cs_generate_variant:Nn \seq_gsort:Nn { c }
23554 \cs_new_protected:Npn \clist_sort:Nn
23555 {
23556 \__sort_seq:NNNNn \clist_map_inline:Nn \clist_map_break:n
23557 \clist_set_from_seq:NN
23558 }
23559 \cs_generate_variant:Nn \clist_sort:Nn { c }
23560 \cs_new_protected:Npn \clist_gsort:Nn
23561 {
23562 \__sort_seq:NNNNn \clist_map_inline:Nn \clist_map_break:n
23563 \clist_gset_from_seq:NN
23564 }
23565 \cs_generate_variant:Nn \clist_gsort:Nn { c }
23566 \cs_new_protected:Npn \__sort_seq:NNNNn #1#2#3#4#5
23567 {
23568 \group_begin:
23569 \__sort_main:NNNn #1 #2 #4 {#5}
23570 \seq_gclear:N \g__sort_tmp_seq
23571 \int_step_inline:nnn
23572 \l__sort_min_int { \l__sort_top_int - 1 }
23573 {
23574 \seq_gput_right:Ne \g__sort_tmp_seq
23575 { \tex_the:D \tex_toks:D ##1 }
23576 }
23577 \group_end:
23578 #3 #4 \g__sort_tmp_seq
23579 \seq_gclear:N \g__sort_tmp_seq
23580 \prg_break_point:
23581 }
23582 \cs_new_protected:Npn \__sort_level:
23583 {
23584 \if_int_compare:w \l__sort_block_int < \l__sort_length_int
23585 \l__sort_end_int \l__sort_min_int
23586 \__sort_merge_blocks:
23587 \tex_advance:D \l__sort_block_int \l__sort_block_int
23588 \exp_after:wN \__sort_level:
23589 \fi:
23590 }
23591 \cs_new_protected:Npn \__sort_merge_blocks:
23592 {
23593 \l__sort_begin_int \l__sort_end_int
23594 \tex_advance:D \l__sort_end_int \l__sort_block_int
23595 \if_int_compare:w \l__sort_end_int < \l__sort_top_int
23596 \l__sort_A_int \l__sort_end_int
23597 \tex_advance:D \l__sort_end_int \l__sort_block_int
23598 \if_int_compare:w \l__sort_end_int > \l__sort_top_int
23599 \l__sort_end_int \l__sort_top_int
23600 \fi:
23601 \l__sort_B_int \l__sort_A_int
23602 \l__sort_C_int \l__sort_top_int
23603 \__sort_copy_block:
23604 \int_decr:N \l__sort_A_int
23605 \int_decr:N \l__sort_B_int
23606 \int_decr:N \l__sort_C_int
23607 \exp_after:wN \__sort_merge_blocks_aux:
23608 \exp_after:wN \__sort_merge_blocks:
23609 \fi:
23610 }
23611 \cs_new_protected:Npn \__sort_copy_block:
23612 {
23613 \tex_toks:D \l__sort_C_int \tex_toks:D \l__sort_B_int
23614 \int_incr:N \l__sort_C_int
23615 \int_incr:N \l__sort_B_int
23616 \if_int_compare:w \l__sort_B_int = \l__sort_end_int
23617 \use_i:nn
23618 \fi:
23619 \__sort_copy_block:
23620 }
23621 \cs_new_protected:Npn \__sort_merge_blocks_aux:
23622 {
23623 \exp_after:wN \__sort_compare:nn \exp_after:wN
23624 { \tex_the:D \tex_toks:D \exp_after:wN \l__sort_A_int \exp_after:wN }
23625 \exp_after:wN { \tex_the:D \tex_toks:D \l__sort_C_int }
23626 \prg_do_nothing:
23627 \__sort_return_mark:w
23628 \__sort_return_mark:w
23629 \s__sort_mark
23630 \__sort_return_none_error:
23631 }
23632 \cs_new_protected:Npn \sort_return_same:
23633 #1 \__sort_return_mark:w #2 \s__sort_mark
23634 {
23635 #1
23636 #2
23637 \__sort_return_two_error:
23638 \__sort_return_mark:w
23639 \s__sort_mark
23640 \__sort_return_same:w
23641 }
23642 \cs_new_protected:Npn \sort_return_swapped:
23643 #1 \__sort_return_mark:w #2 \s__sort_mark
23644 {
23645 #1
23646 #2
23647 \__sort_return_two_error:
23648 \__sort_return_mark:w
23649 \s__sort_mark
23650 \__sort_return_swapped:w
23651 }
23652 \cs_new_protected:Npn \__sort_return_mark:w #1 \s__sort_mark { }
23653 \cs_new_protected:Npn \__sort_return_none_error:
23654 {
23655 \msg_error:nnee { sort } { return-none }
23656 { \tex_the:D \tex_toks:D \l__sort_A_int }
23657 { \tex_the:D \tex_toks:D \l__sort_C_int }
23658 \__sort_return_same:w \__sort_return_none_error:
23659 }
23660 \cs_new_protected:Npn \__sort_return_two_error:
23661 {
23662 \msg_error:nnee { sort } { return-two }
23663 { \tex_the:D \tex_toks:D \l__sort_A_int }
23664 { \tex_the:D \tex_toks:D \l__sort_C_int }
23665 }
23666 \cs_new_protected:Npn \__sort_return_same:w #1 \__sort_return_none_error:
23667 {
23668 \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int
23669 \int_decr:N \l__sort_B_int
23670 \int_decr:N \l__sort_C_int
23671 \if_int_compare:w \l__sort_C_int < \l__sort_top_int
23672 \use_i:nn
23673 \fi:
23674 \__sort_merge_blocks_aux:
23675 }
23676 \cs_new_protected:Npn \__sort_return_swapped:w #1 \__sort_return_none_error:
23677 {
23678 \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_A_int
23679 \int_decr:N \l__sort_B_int
23680 \int_decr:N \l__sort_A_int
23681 \if_int_compare:w \l__sort_A_int < \l__sort_begin_int
23682 \__sort_merge_blocks_end: \use_i:nn
23683 \fi:
23684 \__sort_merge_blocks_aux:
23685 }
23686 \cs_new_protected:Npn \__sort_merge_blocks_end:
23687 {
23688 \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int
23689 \int_decr:N \l__sort_B_int
23690 \int_decr:N \l__sort_C_int
23691 \if_int_compare:w \l__sort_B_int < \l__sort_begin_int
23692 \use_i:nn
23693 \fi:
23694 \__sort_merge_blocks_end:
23695 }
23696 \cs_new:Npn \tl_sort:nN #1#2
23697 {
23698 \exp_not:f
23699 {
23700 \tl_if_blank:nF {#1}
23701 {
23702 \__sort_quick_prepare:Nnnn #2 { } { }
23703 #1
23704 { \prg_break_point: \__sort_quick_prepare_end:NNNnw }
23705 \s__sort_stop
23706 }
23707 }
23708 }
23709 \cs_new:Npn \__sort_quick_prepare:Nnnn #1#2#3#4
23710 {
23711 \prg_break: #4 \prg_break_point:
23712 \__sort_quick_prepare:Nnnn #1 { #2 #3 } { #1 {#4} }
23713 }
23714 \cs_new:Npn \__sort_quick_prepare_end:NNNnw #1#2#3#4#5 \s__sort_stop
23715 {
23716 \__sort_quick_split:NnNn #4 \__sort_quick_end:nnTFNn { }
23717 \s__sort_mark { \__sort_quick_cleanup:w \exp_stop_f: }
23718 \s__sort_mark \s__sort_stop
23719 }
23720 \cs_new:Npn \__sort_quick_cleanup:w #1 \s__sort_mark \s__sort_stop {#1}
23721 \cs_new:Npn \__sort_quick_split:NnNn #1#2#3#4
23722 {
23723 #3 {#2} {#4} \__sort_quick_only_ii:NnnnnNn
23724 \__sort_quick_only_i:NnnnnNn
23725 \__sort_quick_single_end:nnnwnw
23726 { #3 {#4} } { } { } {#2}
23727 }
23728 \cs_new:Npn \__sort_quick_only_i:NnnnnNn #1#2#3#4#5#6#7
23729 {
23730 #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn
23731 \__sort_quick_only_i:NnnnnNn
23732 \__sort_quick_only_i_end:nnnwnw
23733 { #6 {#7} } { #3 #2 } { } {#5}
23734 }
23735 \cs_new:Npn \__sort_quick_only_ii:NnnnnNn #1#2#3#4#5#6#7
23736 {
23737 #6 {#5} {#7} \__sort_quick_only_ii:NnnnnNn
23738 \__sort_quick_split_i:NnnnnNn
23739 \__sort_quick_only_ii_end:nnnwnw
23740 { #6 {#7} } { } { #4 #2 } {#5}
23741 }
23742 \cs_new:Npn \__sort_quick_split_i:NnnnnNn #1#2#3#4#5#6#7
23743 {
23744 #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn
23745 \__sort_quick_split_i:NnnnnNn
23746 \__sort_quick_split_end:nnnwnw
23747 { #6 {#7} } { #3 #2 } {#4} {#5}
23748 }
23749 \cs_new:Npn \__sort_quick_split_ii:NnnnnNn #1#2#3#4#5#6#7
23750 {
23751 #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn
23752 \__sort_quick_split_i:NnnnnNn
23753 \__sort_quick_split_end:nnnwnw
23754 { #6 {#7} } {#3} { #4 #2 } {#5}
23755 }
23756 \cs_new:Npn \__sort_quick_end:nnTFNn #1#2#3#4#5#6 {#5}
23757 \cs_new:Npn \__sort_quick_single_end:nnnwnw #1#2#3#4 \s__sort_mark #5#6 \s__sort_stop
23758 { #5 {#3} #6 \s__sort_stop }
23759 \cs_new:Npn \__sort_quick_only_i_end:nnnwnw #1#2#3#4 \s__sort_mark #5#6 \s__sort_stop
23760 {
23761 \__sort_quick_split:NnNn #1
23762 \__sort_quick_end:nnTFNn { } \s__sort_mark {#5}
23763 {#3}
23764 #6 \s__sort_stop
23765 }
23766 \cs_new:Npn \__sort_quick_only_ii_end:nnnwnw #1#2#3#4 \s__sort_mark #5#6 \s__sort_stop
23767 {
23768 \__sort_quick_split:NnNn #2
23769 \__sort_quick_end:nnTFNn { } \s__sort_mark { #5 {#3} }
23770 #6 \s__sort_stop
23771 }
23772 \cs_new:Npn \__sort_quick_split_end:nnnwnw #1#2#3#4 \s__sort_mark #5#6 \s__sort_stop
23773 {
23774 \__sort_quick_split:NnNn #2 \__sort_quick_end:nnTFNn { } \s__sort_mark
23775 {
23776 \__sort_quick_split:NnNn #1
23777 \__sort_quick_end:nnTFNn { } \s__sort_mark {#5}
23778 {#3}
23779 }
23780 #6 \s__sort_stop
23781 }
23782 \cs_new_protected:Npn \__sort_error:
23783 {
23784 \cs_set_eq:NN \__sort_merge_blocks_aux: \prg_do_nothing:
23785 \cs_set_eq:NN \__sort_merge_blocks: \prg_do_nothing:
23786 \cs_set_protected:Npn \__sort_level: { \group_end: \prg_break: }
23787 }
23788 \cs_new_protected:Npn \__sort_disable_toksdef:
23789 { \cs_set_eq:NN \toksdef \__sort_disabled_toksdef:n }
23790 \cs_new_protected:Npn \__sort_disabled_toksdef:n #1
23791 {
23792 \msg_error:nne { sort } { toksdef }
23793 { \token_to_str:N #1 }
23794 \__sort_error:
23795 \tex_toksdef:D #1
23796 }
23797 \msg_new:nnnn { sort } { toksdef }
23798 { Allocation~of~\iow_char:N\\toks~registers~impossible~while~sorting. }
23799 {
23800 The~comparison~code~used~for~sorting~a~list~has~attempted~to~
23801 define~#1~as~a~new~\iow_char:N\\toks~register~using~
23802 \iow_char:N\\newtoks~
23803 or~a~similar~command.~The~list~will~not~be~sorted.
23804 }
23805 \cs_new_protected:Npn \__sort_too_long_error:NNw #1#2 \fi:
23806 {
23807 \fi:
23808 \msg_error:nneee { sort } { too-large }
23809 { \token_to_str:N #2 }
23810 { \int_eval:n { \l__sort_true_max_int - \l__sort_min_int } }
23811 { \int_eval:n { \l__sort_top_int - \l__sort_min_int } }
23812 #1 \__sort_error:
23813 }
23814 \msg_new:nnnn { sort } { too-large }
23815 { The~list~#1~is~too~long~to~be~sorted~by~TeX. }
23816 {
23817 TeX~has~#2~toks~registers~still~available:~
23818 this~only~allows~to~sort~with~up~to~#3~
23819 items.~The~list~will~not~be~sorted.
23820 }
23821 \msg_new:nnnn { sort } { return-none }
23822 { The~comparison~code~did~not~return. }
23823 {
23824 When~sorting~a~list,~the~code~to~compare~items~#1~and~#2~
23825 did~not~call~
23826 \iow_char:N\\sort_return_same: ~nor~
23827 \iow_char:N\\sort_return_swapped: .~
23828 Exactly~one~of~these~should~be~called.
23829 }
23830 \msg_new:nnnn { sort } { return-two }
23831 { The~comparison~code~returned~multiple~times. }
23832 {
23833 When~sorting~a~list,~the~code~to~compare~items~#1~and~#2~called~
23834 \iow_char:N\\sort_return_same: ~or~
23835 \iow_char:N\\sort_return_swapped: ~multiple~times.~
23836 Exactly~one~of~these~should~be~called.
23837 }
23838 \prop_gput:Nnn \g_msg_module_name_prop { sort } { LaTeX }
23839 \prop_gput:Nnn \g_msg_module_type_prop { sort } { }
23840 %% File: l3str-convert.dtx
23841 \cs_new_protected:Npn \__str_tmp:w { }
23842 \tl_new:N \l__str_tmp_tl
23843 \tl_new:N \g__str_result_tl
23844 \int_const:Nn \c__str_replacement_char_int { "FFFD }
23845 \int_const:Nn \c__str_max_byte_int { 255 }
23846 \scan_new:N \s__str
23847 \quark_new:N \q__str_nil
23848 \prop_new:N \g__str_alias_prop
23849 \prop_gput:Nnn \g__str_alias_prop { latin1 } { iso88591 }
23850 \prop_gput:Nnn \g__str_alias_prop { latin2 } { iso88592 }
23851 \prop_gput:Nnn \g__str_alias_prop { latin3 } { iso88593 }
23852 \prop_gput:Nnn \g__str_alias_prop { latin4 } { iso88594 }
23853 \prop_gput:Nnn \g__str_alias_prop { latin5 } { iso88599 }
23854 \prop_gput:Nnn \g__str_alias_prop { latin6 } { iso885910 }
23855 \prop_gput:Nnn \g__str_alias_prop { latin7 } { iso885913 }
23856 \prop_gput:Nnn \g__str_alias_prop { latin8 } { iso885914 }
23857 \prop_gput:Nnn \g__str_alias_prop { latin9 } { iso885915 }
23858 \prop_gput:Nnn \g__str_alias_prop { latin10 } { iso885916 }
23859 \prop_gput:Nnn \g__str_alias_prop { utf16le } { utf16 }
23860 \prop_gput:Nnn \g__str_alias_prop { utf16be } { utf16 }
23861 \prop_gput:Nnn \g__str_alias_prop { utf32le } { utf32 }
23862 \prop_gput:Nnn \g__str_alias_prop { utf32be } { utf32 }
23863 \prop_gput:Nnn \g__str_alias_prop { hexadecimal } { hex }
23864 \bool_lazy_any:nTF
23865 {
23866 \sys_if_engine_luatex_p:
23867 \sys_if_engine_xetex_p:
23868 }
23869 {
23870 \prop_gput:Nnn \g__str_alias_prop { default } { }
23871 }
23872 {
23873 \prop_gput:Nnn \g__str_alias_prop { default } { utf8 }
23874 }
23875 \bool_new:N \g__str_error_bool
23876 \flag_new:N \l__str_byte_flag
23877 \flag_new:N \l__str_error_flag
23878 \prg_new_conditional:Npnn \__str_if_contains_char:Nn #1#2 { T , TF }
23879 {
23880 \exp_after:wN \__str_if_contains_char_aux:nn \exp_after:wN {#1} {#2}
23881 { \prg_break:n { ? \fi: } }
23882 \prg_break_point:
23883 \prg_return_false:
23884 }
23885 \cs_new:Npn \__str_if_contains_char_aux:nn #1#2
23886 { \__str_if_contains_char_auxi:nN {#2} #1 }
23887 \prg_new_conditional:Npnn \__str_if_contains_char:nn #1#2 { TF }
23888 {
23889 \__str_if_contains_char_auxi:nN {#2} #1 { \prg_break:n { ? \fi: } }
23890 \prg_break_point:
23891 \prg_return_false:
23892 }
23893 \cs_new:Npn \__str_if_contains_char_auxi:nN #1#2
23894 {
23895 \if_charcode:w #1 #2
23896 \exp_after:wN \__str_if_contains_char_true:
23897 \fi:
23898 \__str_if_contains_char_auxi:nN {#1}
23899 }
23900 \cs_new:Npn \__str_if_contains_char_true:
23901 { \prg_break:n { \prg_return_true: \use_none:n } }
23902 \prg_new_conditional:Npnn \__str_octal_use:N #1 { TF }
23903 {
23904 \if_int_compare:w 1 < '1 \token_to_str:N #1 \exp_stop_f:
23905 #1 \prg_return_true:
23906 \else:
23907 \prg_return_false:
23908 \fi:
23909 }
23910 \prg_new_conditional:Npnn \__str_hexadecimal_use:N #1 { TF }
23911 {
23912 \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f:
23913 #1 \prg_return_true:
23914 \else:
23915 \if_case:w \int_eval:n { \exp_after:wN ` \token_to_str:N #1 - `a }
23916 A
23917 \or: B
23918 \or: C
23919 \or: D
23920 \or: E
23921 \or: F
23922 \else:
23923 \prg_return_false:
23924 \exp_after:wN \use_none:n
23925 \fi:
23926 \prg_return_true:
23927 \fi:
23928 }
23929 \group_begin:
23930 \__kernel_tl_set:Nx \l__str_tmp_tl { \tl_to_str:n { 0123456789ABCDEF } }
23931 \tl_map_inline:Nn \l__str_tmp_tl
23932 {
23933 \tl_map_inline:Nn \l__str_tmp_tl
23934 {
23935 \tl_const:ce { c__str_byte_ \int_eval:n {"#1##1} _tl }
23936 { \char_generate:nn { "#1##1 } { 12 } #1 ##1 }
23937 }
23938 }
23939 \group_end:
23940 \tl_const:cn { c__str_byte_-1_tl } { { } \use_none:n { } }
23941 \cs_new:Npn \__str_output_byte:n #1
23942 { \__str_output_byte:w #1 \__str_output_end: }
23943 \cs_new:Npn \__str_output_byte:w
23944 {
23945 \exp_after:wN \exp_after:wN
23946 \exp_after:wN \use_i:nnn
23947 \cs:w c__str_byte_ \int_eval:w
23948 }
23949 \cs_new:Npn \__str_output_hexadecimal:n #1
23950 {
23951 \exp_after:wN \exp_after:wN
23952 \exp_after:wN \use_none:n
23953 \cs:w c__str_byte_ \int_eval:n {#1} _tl \cs_end:
23954 }
23955 \cs_new:Npn \__str_output_end:
23956 { \scan_stop: _tl \cs_end: }
23957 \cs_new:Npn \__str_output_byte_pair_be:n #1
23958 {
23959 \exp_args:Nf \__str_output_byte_pair:nnN
23960 { \int_div_truncate:nn { #1 } { "100 } } {#1} \use:nn
23961 }
23962 \cs_new:Npn \__str_output_byte_pair_le:n #1
23963 {
23964 \exp_args:Nf \__str_output_byte_pair:nnN
23965 { \int_div_truncate:nn { #1 } { "100 } } {#1} \use_ii_i:nn
23966 }
23967 \cs_new:Npn \__str_output_byte_pair:nnN #1#2#3
23968 {
23969 #3
23970 { \__str_output_byte:n { #1 } }
23971 { \__str_output_byte:n { #2 - #1 * "100 } }
23972 }
23973 \cs_new_protected:Npn \__str_convert_gmap:N #1
23974 {
23975 \__kernel_tl_gset:Nx \g__str_result_tl
23976 {
23977 \exp_after:wN \__str_convert_gmap_loop:NN
23978 \exp_after:wN #1
23979 \g__str_result_tl { ? \prg_break: }
23980 \prg_break_point:
23981 }
23982 }
23983 \cs_new:Npn \__str_convert_gmap_loop:NN #1#2
23984 {
23985 \use_none:n #2
23986 #1#2
23987 \__str_convert_gmap_loop:NN #1
23988 }
23989 \cs_new_protected:Npn \__str_convert_gmap_internal:N #1
23990 {
23991 \__kernel_tl_gset:Nx \g__str_result_tl
23992 {
23993 \exp_after:wN \__str_convert_gmap_internal_loop:Nww
23994 \exp_after:wN #1
23995 \g__str_result_tl \s__str \s__str_stop \prg_break: \s__str
23996 \prg_break_point:
23997 }
23998 }
23999 \cs_new:Npn \__str_convert_gmap_internal_loop:Nww #1 #2 \s__str #3 \s__str
24000 {
24001 \__str_use_none_delimit_by_s_stop:w #3 \s__str_stop
24002 #1 {#3}
24003 \__str_convert_gmap_internal_loop:Nww #1
24004 }
24005 \cs_new_protected:Npn \__str_if_flag_error:Nne #1
24006 {
24007 \flag_if_raised:NTF #1
24008 { \msg_error:nne { str } }
24009 { \use_none:nn }
24010 }
24011 \cs_new_protected:Npn \__str_if_flag_no_error:Nne #1#2#3
24012 { \flag_if_raised:NT #1 { \bool_gset_true:N \g__str_error_bool } }
24013 \cs_new:Npn \__str_if_flag_times:NT #1#2
24014 { \flag_if_raised:NT #1 { #2~(x \flag_height:N #1 ) } }
24015 \cs_new_protected:Npn \str_set_convert:Nnnn
24016 { \__str_convert:nNNnnn { } \tl_set_eq:NN }
24017 \cs_new_protected:Npn \str_gset_convert:Nnnn
24018 { \__str_convert:nNNnnn { } \tl_gset_eq:NN }
24019 \prg_new_protected_conditional:Npnn
24020 \str_set_convert:Nnnn #1#2#3#4 { T , F , TF }
24021 {
24022 \bool_gset_false:N \g__str_error_bool
24023 \__str_convert:nNNnnn
24024 { \cs_set_eq:NN \__str_if_flag_error:Nne \__str_if_flag_no_error:Nne }
24025 \tl_set_eq:NN #1 {#2} {#3} {#4}
24026 \bool_if:NTF \g__str_error_bool \prg_return_false: \prg_return_true:
24027 }
24028 \prg_new_protected_conditional:Npnn
24029 \str_gset_convert:Nnnn #1#2#3#4 { T , F , TF }
24030 {
24031 \bool_gset_false:N \g__str_error_bool
24032 \__str_convert:nNNnnn
24033 { \cs_set_eq:NN \__str_if_flag_error:Nne \__str_if_flag_no_error:Nne }
24034 \tl_gset_eq:NN #1 {#2} {#3} {#4}
24035 \bool_if:NTF \g__str_error_bool \prg_return_false: \prg_return_true:
24036 }
24037 \cs_new_protected:Npn \__str_convert:nNNnnn #1#2#3#4#5#6
24038 {
24039 \group_begin:
24040 #1
24041 \__kernel_tl_gset:Nx \g__str_result_tl { \__kernel_str_to_other_fast:n {#4} }
24042 \exp_after:wN \__str_convert:wwwnn
24043 \tl_to_str:n {#5} /// \s__str_stop
24044 { decode } { unescape }
24045 \prg_do_nothing:
24046 \__str_convert_decode_:
24047 \exp_after:wN \__str_convert:wwwnn
24048 \tl_to_str:n {#6} /// \s__str_stop
24049 { encode } { escape }
24050 \use_ii_i:nn
24051 \__str_convert_encode_:
24052 \__kernel_tl_gset:Nx \g__str_result_tl
24053 { \tl_to_str:V \g__str_result_tl }
24054 \group_end:
24055 #2 #3 \g__str_result_tl
24056 }
24057 \cs_new_protected:Npn \__str_convert:wwwnn
24058 #1 / #2 // #3 \s__str_stop #4#5
24059 {
24060 \__str_convert:nnn {enc} {#4} {#1}
24061 \__str_convert:nnn {esc} {#5} {#2}
24062 \exp_args:Ncc \__str_convert:NNnNN
24063 { __str_convert_#4_#1: } { __str_convert_#5_#2: } {#2}
24064 }
24065 \cs_new_protected:Npn \__str_convert:NNnNN #1#2#3#4#5
24066 {
24067 \if_meaning:w #1 #5
24068 \tl_if_empty:nF {#3}
24069 { \msg_error:nne { str } { native-escaping } {#3} }
24070 #1
24071 \else:
24072 #4 #2 #1
24073 \fi:
24074 }
24075 \cs_new_protected:Npn \__str_convert:nnn #1#2#3
24076 {
24077 \cs_if_exist:cF { __str_convert_#2_#3: }
24078 {
24079 \exp_args:Ne \__str_convert:nnnn
24080 { \__str_convert_lowercase_alphanum:n {#3} }
24081 {#1} {#2} {#3}
24082 }
24083 }
24084 \cs_new_protected:Npn \__str_convert:nnnn #1#2#3#4
24085 {
24086 \cs_if_exist:cF { __str_convert_#3_#1: }
24087 {
24088 \prop_get:NnNF \g__str_alias_prop {#1} \l__str_tmp_tl
24089 { \tl_set:Nn \l__str_tmp_tl {#1} }
24090 \cs_if_exist:cF { __str_convert_#3_ \l__str_tmp_tl : }
24091 {
24092 \file_if_exist:nTF { l3str-#2- \l__str_tmp_tl .def }
24093 {
24094 \group_begin:
24095 \cctab_select:N \c_code_cctab
24096 \file_input:n { l3str-#2- \l__str_tmp_tl .def }
24097 \group_end:
24098 }
24099 {
24100 \tl_clear:N \l__str_tmp_tl
24101 \msg_error:nnee { str } { unknown-#2 } {#4} {#1}
24102 }
24103 }
24104 \cs_if_exist:cF { __str_convert_#3_#1: }
24105 {
24106 \cs_gset_eq:cc { __str_convert_#3_#1: }
24107 { __str_convert_#3_ \l__str_tmp_tl : }
24108 }
24109 }
24110 \cs_gset_eq:cc { __str_convert_#3_#4: } { __str_convert_#3_#1: }
24111 }
24112 \cs_new:Npn \__str_convert_lowercase_alphanum:n #1
24113 {
24114 \exp_after:wN \__str_convert_lowercase_alphanum_loop:N
24115 \tl_to_str:n {#1} { ? \prg_break: }
24116 \prg_break_point:
24117 }
24118 \cs_new:Npn \__str_convert_lowercase_alphanum_loop:N #1
24119 {
24120 \use_none:n #1
24121 \if_int_compare:w `#1 > `Z \exp_stop_f:
24122 \if_int_compare:w `#1 > `z \exp_stop_f: \else:
24123 \if_int_compare:w `#1 < `a \exp_stop_f: \else:
24124 #1
24125 \fi:
24126 \fi:
24127 \else:
24128 \if_int_compare:w `#1 < `A \exp_stop_f:
24129 \if_int_compare:w 1 < 1#1 \exp_stop_f:
24130 #1
24131 \fi:
24132 \else:
24133 \__str_output_byte:n { `#1 + `a - `A }
24134 \fi:
24135 \fi:
24136 \__str_convert_lowercase_alphanum_loop:N
24137 }
24138 \bool_lazy_any:nTF
24139 {
24140 \sys_if_engine_luatex_p:
24141 \sys_if_engine_xetex_p:
24142 }
24143 {
24144 \cs_new:Npn \__str_filter_bytes:n #1
24145 {
24146 \__str_filter_bytes_aux:N #1
24147 { ? \prg_break: }
24148 \prg_break_point:
24149 }
24150 \cs_new:Npn \__str_filter_bytes_aux:N #1
24151 {
24152 \use_none:n #1
24153 \if_int_compare:w `#1 < 256 \exp_stop_f:
24154 #1
24155 \else:
24156 \flag_raise:N \l__str_byte_flag
24157 \fi:
24158 \__str_filter_bytes_aux:N
24159 }
24160 }
24161 { \cs_new_eq:NN \__str_filter_bytes:n \use:n }
24162 \bool_lazy_any:nTF
24163 {
24164 \sys_if_engine_luatex_p:
24165 \sys_if_engine_xetex_p:
24166 }
24167 {
24168 \cs_new_protected:Npn \__str_convert_unescape_:
24169 {
24170 \flag_clear:N \l__str_byte_flag
24171 \__kernel_tl_gset:Nx \g__str_result_tl
24172 { \exp_args:No \__str_filter_bytes:n \g__str_result_tl }
24173 \__str_if_flag_error:Nne \l__str_byte_flag { non-byte } { bytes }
24174 }
24175 }
24176 { \cs_new_protected:Npn \__str_convert_unescape_: { } }
24177 \cs_new_eq:NN \__str_convert_unescape_bytes: \__str_convert_unescape_:
24178 \cs_new_protected:Npn \__str_convert_escape_: { }
24179 \cs_new_eq:NN \__str_convert_escape_bytes: \__str_convert_escape_:
24180 \cs_new_protected:Npn \__str_convert_decode_:
24181 { \__str_convert_gmap:N \__str_decode_native_char:N }
24182 \cs_new:Npn \__str_decode_native_char:N #1
24183 { #1 \s__str \int_value:w `#1 \s__str }
24184 \bool_lazy_any:nTF
24185 {
24186 \sys_if_engine_luatex_p:
24187 \sys_if_engine_xetex_p:
24188 }
24189 {
24190 \cs_new_protected:Npn \__str_convert_encode_:
24191 { \__str_convert_gmap_internal:N \__str_encode_native_char:n }
24192 \cs_new:Npn \__str_encode_native_char:n #1
24193 { \char_generate:nn {#1} {12} }
24194 }
24195 {
24196 \cs_new_protected:Npn \__str_convert_encode_:
24197 {
24198 \flag_clear:N \l__str_error_flag
24199 \__str_convert_gmap_internal:N \__str_encode_native_char:n
24200 \__str_if_flag_error:Nne \l__str_error_flag
24201 { native-overflow } { }
24202 }
24203 \cs_new:Npn \__str_encode_native_char:n #1
24204 {
24205 \if_int_compare:w #1 > \c__str_max_byte_int
24206 \flag_raise:N \l__str_error_flag
24207 ?
24208 \else:
24209 \char_generate:nn {#1} {12}
24210 \fi:
24211 }
24212 \msg_new:nnnn { str } { native-overflow }
24213 { Character~code~too~large~for~this~engine. }
24214 {
24215 This~engine~only~support~8-bit~characters:~
24216 valid~character~codes~are~in~the~range~[0,255].~
24217 To~manipulate~arbitrary~Unicode,~use~LuaTeX~or~XeTeX.
24218 }
24219 }
24220 \cs_new_protected:Npn \__str_convert_decode_clist:
24221 {
24222 \clist_gset:No \g__str_result_tl \g__str_result_tl
24223 \__kernel_tl_gset:Nx \g__str_result_tl
24224 {
24225 \exp_args:No \clist_map_function:nN
24226 \g__str_result_tl \__str_decode_clist_char:n
24227 }
24228 }
24229 \cs_new:Npn \__str_decode_clist_char:n #1
24230 { #1 \s__str \int_eval:n {#1} \s__str }
24231 \cs_new_protected:Npn \__str_convert_encode_clist:
24232 {
24233 \__str_convert_gmap_internal:N \__str_encode_clist_char:n
24234 \__kernel_tl_gset:Nx \g__str_result_tl { \tl_tail:N \g__str_result_tl }
24235 }
24236 \cs_new:Npn \__str_encode_clist_char:n #1 { , #1 }
24237 \cs_new_protected:Npn \__str_declare_eight_bit_encoding:nnnn #1
24238 {
24239 \tl_set:Nn \l__str_tmp_tl {#1}
24240 \cs_new_protected:cpn { __str_convert_decode_#1: }
24241 { \__str_convert_decode_eight_bit:n {#1} }
24242 \cs_new_protected:cpn { __str_convert_encode_#1: }
24243 { \__str_convert_encode_eight_bit:n {#1} }
24244 \exp_args:Ncc \__str_declare_eight_bit_aux:NNnnn
24245 { g__str_decode_#1_intarray } { g__str_encode_#1_intarray }
24246 }
24247 \cs_new_protected:Npn \__str_declare_eight_bit_aux:NNnnn #1#2#3#4#5
24248 {
24249 \intarray_new:Nn #1 { 256 }
24250 \int_step_inline:nnn { 0 } { 255 }
24251 { \intarray_gset:Nnn #1 { 1 + ##1 } {##1} }
24252 \__str_declare_eight_bit_loop:Nnn #1
24253 #4 { \s__str_stop \prg_break: } { }
24254 \prg_break_point:
24255 \__str_declare_eight_bit_loop:Nn #1
24256 #5 { \s__str_stop \prg_break: }
24257 \prg_break_point:
24258 \intarray_new:Nn #2 {#3}
24259 \int_step_inline:nnn { 0 } { 255 }
24260 {
24261 \int_compare:nNnF { \intarray_item:Nn #1 { 1 + ##1 } } = { -1 }
24262 {
24263 \intarray_gset:Nnn #2
24264 {
24265 1 +
24266 \int_mod:nn { \intarray_item:Nn #1 { 1 + ##1 } }
24267 { \intarray_count:N #2 }
24268 }
24269 {##1}
24270 }
24271 }
24272 }
24273 \cs_new_protected:Npn \__str_declare_eight_bit_loop:Nnn #1#2#3
24274 {
24275 \__str_use_none_delimit_by_s_stop:w #2 \s__str_stop
24276 \intarray_gset:Nnn #1 { 1 + "#2 } { "#3 }
24277 \__str_declare_eight_bit_loop:Nnn #1
24278 }
24279 \cs_new_protected:Npn \__str_declare_eight_bit_loop:Nn #1#2
24280 {
24281 \__str_use_none_delimit_by_s_stop:w #2 \s__str_stop
24282 \intarray_gset:Nnn #1 { 1 + "#2 } { -1 }
24283 \__str_declare_eight_bit_loop:Nn #1
24284 }
24285 \cs_new_protected:Npn \__str_convert_decode_eight_bit:n #1
24286 {
24287 \cs_set:Npe \__str_tmp:w
24288 {
24289 \exp_not:N \__str_decode_eight_bit_aux:Nn
24290 \exp_not:c { g__str_decode_#1_intarray }
24291 }
24292 \flag_clear:N \l__str_error_flag
24293 \__str_convert_gmap:N \__str_tmp:w
24294 \__str_if_flag_error:Nne \l__str_error_flag { decode-8-bit } {#1}
24295 }
24296 \cs_new:Npn \__str_decode_eight_bit_aux:Nn #1#2
24297 {
24298 #2 \s__str
24299 \exp_args:Nf \__str_decode_eight_bit_aux:n
24300 { \intarray_item:Nn #1 { 1 + `#2 } }
24301 \s__str
24302 }
24303 \cs_new:Npn \__str_decode_eight_bit_aux:n #1
24304 {
24305 \if_int_compare:w #1 < \c_zero_int
24306 \flag_raise:N \l__str_error_flag
24307 \int_value:w \c__str_replacement_char_int
24308 \else:
24309 #1
24310 \fi:
24311 }
24312 \int_new:N \l__str_modulo_int
24313 \cs_new_protected:Npn \__str_convert_encode_eight_bit:n #1
24314 {
24315 \cs_set:Npe \__str_tmp:w
24316 {
24317 \exp_not:N \__str_encode_eight_bit_aux:NNn
24318 \exp_not:c { g__str_encode_#1_intarray }
24319 \exp_not:c { g__str_decode_#1_intarray }
24320 }
24321 \flag_clear:N \l__str_error_flag
24322 \__str_convert_gmap_internal:N \__str_tmp:w
24323 \__str_if_flag_error:Nne \l__str_error_flag { encode-8-bit } {#1}
24324 }
24325 \cs_new:Npn \__str_encode_eight_bit_aux:NNn #1#2#3
24326 {
24327 \exp_args:Nf \__str_encode_eight_bit_aux:nnN
24328 {
24329 \intarray_item:Nn #1
24330 { 1 + \int_mod:nn {#3} { \intarray_count:N #1 } }
24331 }
24332 {#3}
24333 #2
24334 }
24335 \cs_new:Npn \__str_encode_eight_bit_aux:nnN #1#2#3
24336 {
24337 \int_compare:nNnTF { \intarray_item:Nn #3 { 1 + #1 } } = {#2}
24338 { \__str_output_byte:n {#1} }
24339 { \flag_raise:N \l__str_error_flag }
24340 }
24341 \msg_new:nnn { str } { unknown-esc }
24342 { Escaping~scheme~'#1'~(filtered:~'#2')~unknown. }
24343 \msg_new:nnn { str } { unknown-enc }
24344 { Encoding~scheme~'#1'~(filtered:~'#2')~unknown. }
24345 \msg_new:nnnn { str } { native-escaping }
24346 { The~'native'~encoding~scheme~does~not~support~any~escaping. }
24347 {
24348 Since~native~strings~do~not~consist~in~bytes,~
24349 none~of~the~escaping~methods~make~sense.~
24350 The~specified~escaping,~'#1',~will~be~ignored.
24351 }
24352 \msg_new:nnn { str } { file-not-found }
24353 { File~'l3str-#1.def'~not~found. }
24354 \bool_lazy_any:nT
24355 {
24356 \sys_if_engine_luatex_p:
24357 \sys_if_engine_xetex_p:
24358 }
24359 {
24360 \msg_new:nnnn { str } { non-byte }
24361 { String~invalid~in~escaping~'#1':~it~may~only~contain~bytes. }
24362 {
24363 Some~characters~in~the~string~you~asked~to~convert~are~not~
24364 8-bit~characters.~Perhaps~the~string~is~a~'native'~Unicode~string?~
24365 If~it~is,~try~using\\
24366 \\
24367 \iow_indent:n
24368 {
24369 \iow_char:N\\str_set_convert:Nnnn \\
24370 \ \ <str~var>~\{~<string>~\}~\{~native~\}~\{~<target~encoding>~\}
24371 }
24372 }
24373 }
24374 \msg_new:nnnn { str } { decode-8-bit }
24375 { Invalid~string~in~encoding~'#1'. }
24376 {
24377 LaTeX~came~across~a~byte~which~is~not~defined~to~represent~
24378 any~character~in~the~encoding~'#1'.
24379 }
24380 \msg_new:nnnn { str } { encode-8-bit }
24381 { Unicode~string~cannot~be~converted~to~encoding~'#1'. }
24382 {
24383 The~encoding~'#1'~only~contains~a~subset~of~all~Unicode~characters.~
24384 LaTeX~was~asked~to~convert~a~string~to~that~encoding,~but~that~
24385 string~contains~a~character~that~'#1'~does~not~support.
24386 }
24387 \cs_new_protected:Npn \__str_convert_unescape_hex:
24388 {
24389 \group_begin:
24390 \flag_clear:N \l__str_error_flag
24391 \int_set:Nn \tex_escapechar:D { 92 }
24392 \__kernel_tl_gset:Nx \g__str_result_tl
24393 {
24394 \__str_output_byte:w "
24395 \exp_last_unbraced:Nf \__str_unescape_hex_auxi:N
24396 { \tl_to_str:N \g__str_result_tl }
24397 0 { ? 0 - 1 \prg_break: }
24398 \prg_break_point:
24399 \__str_output_end:
24400 }
24401 \__str_if_flag_error:Nne \l__str_error_flag { unescape-hex } { }
24402 \group_end:
24403 }
24404 \cs_new:Npn \__str_unescape_hex_auxi:N #1
24405 {
24406 \use_none:n #1
24407 \__str_hexadecimal_use:NTF #1
24408 { \__str_unescape_hex_auxii:N }
24409 {
24410 \flag_raise:N \l__str_error_flag
24411 \__str_unescape_hex_auxi:N
24412 }
24413 }
24414 \cs_new:Npn \__str_unescape_hex_auxii:N #1
24415 {
24416 \use_none:n #1
24417 \__str_hexadecimal_use:NTF #1
24418 {
24419 \__str_output_end:
24420 \__str_output_byte:w " \__str_unescape_hex_auxi:N
24421 }
24422 {
24423 \flag_raise:N \l__str_error_flag
24424 \__str_unescape_hex_auxii:N
24425 }
24426 }
24427 \msg_new:nnnn { str } { unescape-hex }
24428 { String~invalid~in~escaping~'hex':~only~hexadecimal~digits~allowed. }
24429 {
24430 Some~characters~in~the~string~you~asked~to~convert~are~not~
24431 hexadecimal~digits~(0-9,~A-F,~a-f)~nor~spaces.
24432 }
24433 \cs_set_protected:Npn \__str_tmp:w #1#2#3
24434 {
24435 \cs_new_protected:cpn { __str_convert_unescape_#2: }
24436 {
24437 \group_begin:
24438 \flag_clear:N \l__str_byte_flag
24439 \flag_clear:N \l__str_error_flag
24440 \int_set:Nn \tex_escapechar:D { 92 }
24441 \__kernel_tl_gset:Nx \g__str_result_tl
24442 {
24443 \exp_after:wN #3 \g__str_result_tl
24444 #1 ? { ? \prg_break: }
24445 \prg_break_point:
24446 }
24447 \__str_if_flag_error:Nne \l__str_byte_flag { non-byte } { #2 }
24448 \__str_if_flag_error:Nne \l__str_error_flag { unescape-#2 } { }
24449 \group_end:
24450 }
24451 \cs_new:Npn #3 ##1#1##2##3
24452 {
24453 \__str_filter_bytes:n {##1}
24454 \use_none:n ##3
24455 \__str_output_byte:w "
24456 \__str_hexadecimal_use:NTF ##2
24457 {
24458 \__str_hexadecimal_use:NTF ##3
24459 { }
24460 {
24461 \flag_raise:N \l__str_error_flag
24462 * 0 + `#1 \use_i:nn
24463 }
24464 }
24465 {
24466 \flag_raise:N \l__str_error_flag
24467 0 + `#1 \use_i:nn
24468 }
24469 \__str_output_end:
24470 \use_i:nnn #3 ##2##3
24471 }
24472 \msg_new:nnnn { str } { unescape-#2 }
24473 { String~invalid~in~escaping~'#2'. }
24474 {
24475 LaTeX~came~across~the~escape~character~'#1'~not~followed~by~
24476 two~hexadecimal~digits.~This~is~invalid~in~the~escaping~'#2'.
24477 }
24478 }
24479 \exp_after:wN \__str_tmp:w \c_hash_str { name }
24480 \__str_unescape_name_loop:wNN
24481 \exp_after:wN \__str_tmp:w \c_percent_str { url }
24482 \__str_unescape_url_loop:wNN
24483 \group_begin:
24484 \char_set_catcode_other:N \^^J
24485 \char_set_catcode_other:N \^^M
24486 \cs_set_protected:Npn \__str_tmp:w #1
24487 {
24488 \cs_new_protected:Npn \__str_convert_unescape_string:
24489 {
24490 \group_begin:
24491 \flag_clear:N \l__str_byte_flag
24492 \flag_clear:N \l__str_error_flag
24493 \int_set:Nn \tex_escapechar:D { 92 }
24494 \__kernel_tl_gset:Nx \g__str_result_tl
24495 {
24496 \exp_after:wN \__str_unescape_string_newlines:wN
24497 \g__str_result_tl \prg_break: ^^M ?
24498 \prg_break_point:
24499 }
24500 \__kernel_tl_gset:Nx \g__str_result_tl
24501 {
24502 \exp_after:wN \__str_unescape_string_loop:wNNN
24503 \g__str_result_tl #1 ?? { ? \prg_break: }
24504 \prg_break_point:
24505 }
24506 \__str_if_flag_error:Nne \l__str_byte_flag { non-byte } { string }
24507 \__str_if_flag_error:Nne \l__str_error_flag { unescape-string } { }
24508 \group_end:
24509 }
24510 }
24511 \exp_args:No \__str_tmp:w { \c_backslash_str }
24512 \exp_last_unbraced:NNNNo
24513 \cs_new:Npn \__str_unescape_string_loop:wNNN #1 \c_backslash_str #2#3#4
24514 {
24515 \__str_filter_bytes:n {#1}
24516 \use_none:n #4
24517 \__str_output_byte:w '
24518 \__str_octal_use:NTF #2
24519 {
24520 \__str_octal_use:NTF #3
24521 {
24522 \__str_octal_use:NTF #4
24523 {
24524 \if_int_compare:w #2 > 3 \exp_stop_f:
24525 - 256
24526 \fi:
24527 \__str_unescape_string_repeat:NNNNNN
24528 }
24529 { \__str_unescape_string_repeat:NNNNNN ? }
24530 }
24531 { \__str_unescape_string_repeat:NNNNNN ?? }
24532 }
24533 {
24534 \str_case_e:nnF {#2}
24535 {
24536 { \c_backslash_str } { 134 }
24537 { ( } { 50 }
24538 { ) } { 51 }
24539 { r } { 15 }
24540 { f } { 14 }
24541 { n } { 12 }
24542 { t } { 11 }
24543 { b } { 10 }
24544 { ^^J } { 0 - 1 }
24545 }
24546 {
24547 \flag_raise:N \l__str_error_flag
24548 0 - 1 \use_i:nn
24549 }
24550 }
24551 \__str_output_end:
24552 \use_i:nn \__str_unescape_string_loop:wNNN #2#3#4
24553 }
24554 \cs_new:Npn \__str_unescape_string_repeat:NNNNNN #1#2#3#4#5#6
24555 { \__str_output_end: \__str_unescape_string_loop:wNNN }
24556 \cs_new:Npn \__str_unescape_string_newlines:wN #1 ^^M #2
24557 {
24558 #1
24559 \if_charcode:w ^^J #2 \else: ^^J \fi:
24560 \__str_unescape_string_newlines:wN #2
24561 }
24562 \msg_new:nnnn { str } { unescape-string }
24563 { String~invalid~in~escaping~'string'. }
24564 {
24565 LaTeX~came~across~an~escape~character~'\c_backslash_str'~
24566 not~followed~by~any~of:~'n',~'r',~'t',~'b',~'f',~'(',~')',~
24567 '\c_backslash_str',~one~to~three~octal~digits,~or~the~end~
24568 of~a~line.
24569 }
24570 \group_end:
24571 \cs_new_protected:Npn \__str_convert_escape_hex:
24572 { \__str_convert_gmap:N \__str_escape_hex_char:N }
24573 \cs_new:Npn \__str_escape_hex_char:N #1
24574 { \__str_output_hexadecimal:n { `#1 } }
24575 \str_const:Nn \c__str_escape_name_not_str { ! " $ & ' } %$
24576 \str_const:Nn \c__str_escape_name_str { {}/<>[] }
24577 \cs_new_protected:Npn \__str_convert_escape_name:
24578 { \__str_convert_gmap:N \__str_escape_name_char:n }
24579 \cs_new:Npn \__str_escape_name_char:n #1
24580 {
24581 \__str_if_escape_name:nTF {#1} {#1}
24582 { \c_hash_str \__str_output_hexadecimal:n {`#1} }
24583 }
24584 \prg_new_conditional:Npnn \__str_if_escape_name:n #1 { TF }
24585 {
24586 \if_int_compare:w `#1 < "2A \exp_stop_f:
24587 \__str_if_contains_char:NnTF \c__str_escape_name_not_str {#1}
24588 \prg_return_true: \prg_return_false:
24589 \else:
24590 \if_int_compare:w `#1 > "7E \exp_stop_f:
24591 \prg_return_false:
24592 \else:
24593 \__str_if_contains_char:NnTF \c__str_escape_name_str {#1}
24594 \prg_return_false: \prg_return_true:
24595 \fi:
24596 \fi:
24597 }
24598 \str_const:Ne \c__str_escape_string_str
24599 { \c_backslash_str ( ) }
24600 \cs_new_protected:Npn \__str_convert_escape_string:
24601 { \__str_convert_gmap:N \__str_escape_string_char:N }
24602 \cs_new:Npn \__str_escape_string_char:N #1
24603 {
24604 \__str_if_escape_string:NTF #1
24605 {
24606 \__str_if_contains_char:NnT
24607 \c__str_escape_string_str {#1}
24608 { \c_backslash_str }
24609 #1
24610 }
24611 {
24612 \c_backslash_str
24613 \int_div_truncate:nn {`#1} {64}
24614 \int_mod:nn { \int_div_truncate:nn {`#1} { 8 } } { 8 }
24615 \int_mod:nn {`#1} { 8 }
24616 }
24617 }
24618 \prg_new_conditional:Npnn \__str_if_escape_string:N #1 { TF }
24619 {
24620 \if_int_compare:w `#1 < "27 \exp_stop_f:
24621 \prg_return_false:
24622 \else:
24623 \if_int_compare:w `#1 > "7A \exp_stop_f:
24624 \prg_return_false:
24625 \else:
24626 \prg_return_true:
24627 \fi:
24628 \fi:
24629 }
24630 \cs_new_protected:Npn \__str_convert_escape_url:
24631 { \__str_convert_gmap:N \__str_escape_url_char:n }
24632 \cs_new:Npn \__str_escape_url_char:n #1
24633 {
24634 \__str_if_escape_url:nTF {#1} {#1}
24635 { \c_percent_str \__str_output_hexadecimal:n { `#1 } }
24636 }
24637 \prg_new_conditional:Npnn \__str_if_escape_url:n #1 { TF }
24638 {
24639 \if_int_compare:w `#1 < "30 \exp_stop_f:
24640 \__str_if_contains_char:nnTF { "-. } {#1}
24641 \prg_return_true: \prg_return_false:
24642 \else:
24643 \if_int_compare:w `#1 > "7E \exp_stop_f:
24644 \prg_return_false:
24645 \else:
24646 \__str_if_contains_char:nnTF { : ; = ? @ [ ] } {#1}
24647 \prg_return_false: \prg_return_true:
24648 \fi:
24649 \fi:
24650 }
24651 \cs_new_protected:cpn { __str_convert_encode_utf8: }
24652 { \__str_convert_gmap_internal:N \__str_encode_utf_viii_char:n }
24653 \cs_new:Npn \__str_encode_utf_viii_char:n #1
24654 {
24655 \__str_encode_utf_viii_loop:wwnnw #1 \__str_sep: - 1 + 0 * \__str_sep:
24656 { 128 } { 0 }
24657 { 32 } { 192 }
24658 { 16 } { 224 }
24659 { 8 } { 240 }
24660 \s__str_stop
24661 }
24662 \cs_new:Npn \__str_encode_utf_viii_loop:wwnnw
24663 #1 \__str_sep: #2 \__str_sep: #3#4 #5 \s__str_stop
24664 {
24665 \if_int_compare:w #1 < #3 \exp_stop_f:
24666 \__str_output_byte:n { #1 + #4 }
24667 \exp_after:wN \__str_use_none_delimit_by_s_stop:w
24668 \fi:
24669 \exp_after:wN \__str_encode_utf_viii_loop:wwnnw
24670 \int_value:w \int_div_truncate:nn {#1} {64} \__str_sep: #1 \__str_sep:
24671 #5 \s__str_stop
24672 \__str_output_byte:n { #2 - 64 * ( #1 - 2 ) }
24673 }
24674 \flag_clear_new:N \l__str_missing_flag
24675 \flag_clear_new:N \l__str_extra_flag
24676 \flag_clear_new:N \l__str_overlong_flag
24677 \flag_clear_new:N \l__str_overflow_flag
24678 \msg_new:nnnn { str } { utf8-decode }
24679 {
24680 Invalid~UTF-8~string:
24681 \exp_last_unbraced:Nf \use_none:n
24682 {
24683 \__str_if_flag_times:NT \l__str_missing_flag { ,~missing~continuation~byte }
24684 \__str_if_flag_times:NT \l__str_extra_flag { ,~extra~continuation~byte }
24685 \__str_if_flag_times:NT \l__str_overlong_flag { ,~overlong~form }
24686 \__str_if_flag_times:NT \l__str_overflow_flag { ,~code~point~too~large }
24687 }
24688 .
24689 }
24690 {
24691 In~the~UTF-8~encoding,~each~Unicode~character~consists~in~
24692 1~to~4~bytes,~with~the~following~bit~pattern: \\
24693 \iow_indent:n
24694 {
24695 Code~point~\ \ \ \ <~128:~0xxxxxxx \\
24696 Code~point~\ \ \ <~2048:~110xxxxx~10xxxxxx \\
24697 Code~point~\ \ <~65536:~1110xxxx~10xxxxxx~10xxxxxx \\
24698 Code~point~ <~1114112:~11110xxx~10xxxxxx~10xxxxxx~10xxxxxx \\
24699 }
24700 Bytes~of~the~form~10xxxxxx~are~called~continuation~bytes.
24701 \flag_if_raised:NT \l__str_missing_flag
24702 {
24703 \\\\
24704 A~leading~byte~(in~the~range~[192,255])~was~not~followed~by~
24705 the~appropriate~number~of~continuation~bytes.
24706 }
24707 \flag_if_raised:NT \l__str_extra_flag
24708 {
24709 \\\\
24710 LaTeX~came~across~a~continuation~byte~when~it~was~not~expected.
24711 }
24712 \flag_if_raised:NT \l__str_overlong_flag
24713 {
24714 \\\\
24715 Every~Unicode~code~point~must~be~expressed~in~the~shortest~
24716 possible~form.~For~instance,~'0xC0'~'0x83'~is~not~a~valid~
24717 representation~for~the~code~point~3.
24718 }
24719 \flag_if_raised:NT \l__str_overflow_flag
24720 {
24721 \\\\
24722 Unicode~limits~code~points~to~the~range~[0,1114111].
24723 }
24724 }
24725 \prop_gput:Nnn \g_msg_module_name_prop { str } { LaTeX }
24726 \prop_gput:Nnn \g_msg_module_type_prop { str } { }
24727 \cs_new_protected:cpn { __str_convert_decode_utf8: }
24728 {
24729 \flag_clear:N \l__str_error_flag
24730 \flag_clear:N \l__str_missing_flag
24731 \flag_clear:N \l__str_extra_flag
24732 \flag_clear:N \l__str_overlong_flag
24733 \flag_clear:N \l__str_overflow_flag
24734 \__kernel_tl_gset:Nx \g__str_result_tl
24735 {
24736 \exp_after:wN \__str_decode_utf_viii_start:N \g__str_result_tl
24737 { \prg_break: \__str_decode_utf_viii_end: }
24738 \prg_break_point:
24739 }
24740 \__str_if_flag_error:Nne \l__str_error_flag { utf8-decode } { }
24741 }
24742 \cs_new:Npn \__str_decode_utf_viii_loop:N #1
24743 {
24744 #1
24745 \if_int_compare:w `#1 < "C0 \exp_stop_f:
24746 \s__str
24747 \if_int_compare:w `#1 < "80 \exp_stop_f:
24748 \int_value:w `#1
24749 \else:
24750 \flag_raise:N \l__str_extra_flag
24751 \flag_raise:N \l__str_error_flag
24752 \int_use:N \c__str_replacement_char_int
24753 \fi:
24754 \else:
24755 \exp_after:wN \__str_decode_utf_viii_continuation:wwN
24756 \int_value:w \int_eval:n { `#1 - "C0 } \exp_after:wN
24757 \fi:
24758 \s__str
24759 \__str_use_none_delimit_by_s_stop:w {"80} {"800} {"10000} {"110000} \s__str_stop
24760 \__str_decode_utf_viii_loop:N
24761 }
24762 \cs_new_eq:NN \__str_decode_utf_viii_start:N
24763 \__str_decode_utf_viii_loop:N
24764 \cs_new:Npn \__str_decode_utf_viii_continuation:wwN
24765 #1 \s__str #2 \__str_decode_utf_viii_loop:N #3
24766 {
24767 \use_none:n #3
24768 \if_int_compare:w `#3 <
24769 \if_int_compare:w `#3 < "80 \exp_stop_f: - \fi:
24770 "C0 \exp_stop_f:
24771 #3
24772 \exp_after:wN \__str_decode_utf_viii_aux:wNnnwN
24773 \int_value:w \int_eval:n { #1 * "40 + `#3 - "80 } \exp_after:wN
24774 \else:
24775 \s__str
24776 \flag_raise:N \l__str_missing_flag
24777 \flag_raise:N \l__str_error_flag
24778 \int_use:N \c__str_replacement_char_int
24779 \fi:
24780 \s__str
24781 #2
24782 \__str_decode_utf_viii_loop:N #3
24783 }
24784 \cs_new:Npn \__str_decode_utf_viii_aux:wNnnwN
24785 #1 \s__str #2#3#4 #5 \__str_decode_utf_viii_loop:N #6
24786 {
24787 \if_int_compare:w #1 < #4 \exp_stop_f:
24788 \s__str
24789 \if_int_compare:w #1 < #3 \exp_stop_f:
24790 \flag_raise:N \l__str_overlong_flag
24791 \flag_raise:N \l__str_error_flag
24792 \int_use:N \c__str_replacement_char_int
24793 \else:
24794 #1
24795 \fi:
24796 \else:
24797 \if_meaning:w \s__str_stop #5
24798 \__str_decode_utf_viii_overflow:w #1
24799 \fi:
24800 \exp_after:wN \__str_decode_utf_viii_continuation:wwN
24801 \int_value:w \int_eval:n { #1 - #4 } \exp_after:wN
24802 \fi:
24803 \s__str
24804 #2 {#4} #5
24805 \__str_decode_utf_viii_loop:N
24806 }
24807 \cs_new:Npn \__str_decode_utf_viii_overflow:w #1 \fi: #2 \fi:
24808 {
24809 \fi: \fi:
24810 \flag_raise:N \l__str_overflow_flag
24811 \flag_raise:N \l__str_error_flag
24812 \int_use:N \c__str_replacement_char_int
24813 }
24814 \cs_new:Npn \__str_decode_utf_viii_end:
24815 {
24816 \s__str
24817 \flag_raise:N \l__str_missing_flag
24818 \flag_raise:N \l__str_error_flag
24819 \int_use:N \c__str_replacement_char_int \s__str
24820 \prg_break:
24821 }
24822 \sys_if_engine_uptex:T
24823 {
24824 \cs_new_eq:NN \__str_decode_utf_viii_start_auxi:N
24825 \__str_decode_utf_viii_start:N
24826 \cs_gset:Npn \__str_decode_utf_viii_start:N #1
24827 {
24828 \if_int_compare:w \tex_kcatcode:D `#1 > 15 \exp_stop_f:
24829 \exp_after:wN \__str_decode_utf_viii_start_auxii:N
24830 \else:
24831 \exp_after:wN \__str_decode_utf_viii_start_auxi:N
24832 \fi:
24833 #1
24834 }
24835 \cs_new:Npn \__str_decode_utf_viii_start_auxii:N #1
24836 {
24837 #1
24838 \s__str
24839 \int_eval:n {`#1}
24840 \s__str
24841 \prg_break: \__str_decode_utf_viii_end:
24842 }
24843 }
24844 \group_begin:
24845 \char_set_catcode_other:N \^^fe
24846 \char_set_catcode_other:N \^^ff
24847 \cs_new_protected:cpn { __str_convert_encode_utf16: }
24848 {
24849 \__str_encode_utf_xvi_aux:N \__str_output_byte_pair_be:n
24850 \tl_gput_left:Ne \g__str_result_tl { ^^fe ^^ff }
24851 }
24852 \cs_new_protected:cpn { __str_convert_encode_utf16be: }
24853 { \__str_encode_utf_xvi_aux:N \__str_output_byte_pair_be:n }
24854 \cs_new_protected:cpn { __str_convert_encode_utf16le: }
24855 { \__str_encode_utf_xvi_aux:N \__str_output_byte_pair_le:n }
24856 \cs_new_protected:Npn \__str_encode_utf_xvi_aux:N #1
24857 {
24858 \flag_clear:N \l__str_error_flag
24859 \cs_set_eq:NN \__str_tmp:w #1
24860 \__str_convert_gmap_internal:N \__str_encode_utf_xvi_char:n
24861 \__str_if_flag_error:Nne \l__str_error_flag { utf16-encode } { }
24862 }
24863 \cs_new:Npn \__str_encode_utf_xvi_char:n #1
24864 {
24865 \if_int_compare:w #1 < "D800 \exp_stop_f:
24866 \__str_tmp:w {#1}
24867 \else:
24868 \if_int_compare:w #1 < "10000 \exp_stop_f:
24869 \if_int_compare:w #1 < "E000 \exp_stop_f:
24870 \flag_raise:N \l__str_error_flag
24871 \__str_tmp:w { \c__str_replacement_char_int }
24872 \else:
24873 \__str_tmp:w {#1}
24874 \fi:
24875 \else:
24876 \exp_args:Nf \__str_tmp:w { \int_div_truncate:nn {#1} {"400} + "D7C0 }
24877 \exp_args:Nf \__str_tmp:w { \int_mod:nn {#1} {"400} + "DC00 }
24878 \fi:
24879 \fi:
24880 }
24881 \flag_clear_new:N \l__str_missing_flag
24882 \flag_clear_new:N \l__str_extra_flag
24883 \flag_clear_new:N \l__str_end_flag
24884 \msg_new:nnnn { str } { utf16-encode }
24885 { Unicode~string~cannot~be~expressed~in~UTF-16:~surrogate. }
24886 {
24887 Surrogate~code~points~(in~the~range~[U+D800,~U+DFFF])~
24888 can~be~expressed~in~the~UTF-8~and~UTF-32~encodings,~
24889 but~not~in~the~UTF-16~encoding.
24890 }
24891 \msg_new:nnnn { str } { utf16-decode }
24892 {
24893 Invalid~UTF-16~string:
24894 \exp_last_unbraced:Nf \use_none:n
24895 {
24896 \__str_if_flag_times:NT \l__str_missing_flag { ,~missing~trail~surrogate }
24897 \__str_if_flag_times:NT \l__str_extra_flag { ,~extra~trail~surrogate }
24898 \__str_if_flag_times:NT \l__str_end_flag { ,~odd~number~of~bytes }
24899 }
24900 .
24901 }
24902 {
24903 In~the~UTF-16~encoding,~each~Unicode~character~is~encoded~as~
24904 2~or~4~bytes: \\
24905 \iow_indent:n
24906 {
24907 Code~point~in~[U+0000,~U+D7FF]:~two~bytes \\
24908 Code~point~in~[U+D800,~U+DFFF]:~illegal \\
24909 Code~point~in~[U+E000,~U+FFFF]:~two~bytes \\
24910 Code~point~in~[U+10000,~U+10FFFF]:~
24911 a~lead~surrogate~and~a~trail~surrogate \\
24912 }
24913 Lead~surrogates~are~pairs~of~bytes~in~the~range~[0xD800,~0xDBFF],~
24914 and~trail~surrogates~are~in~the~range~[0xDC00,~0xDFFF].
24915 \flag_if_raised:NT \l__str_missing_flag
24916 {
24917 \\\\
24918 A~lead~surrogate~was~not~followed~by~a~trail~surrogate.
24919 }
24920 \flag_if_raised:NT \l__str_extra_flag
24921 {
24922 \\\\
24923 LaTeX~came~across~a~trail~surrogate~when~it~was~not~expected.
24924 }
24925 \flag_if_raised:NT \l__str_end_flag
24926 {
24927 \\\\
24928 The~string~contained~an~odd~number~of~bytes.~This~is~invalid:~
24929 the~basic~code~unit~for~UTF-16~is~16~bits~(2~bytes).
24930 }
24931 }
24932 \cs_new_protected:cpn { __str_convert_decode_utf16be: }
24933 { \__str_decode_utf_xvi:Nw 1 \g__str_result_tl \s__str_stop }
24934 \cs_new_protected:cpn { __str_convert_decode_utf16le: }
24935 { \__str_decode_utf_xvi:Nw 2 \g__str_result_tl \s__str_stop }
24936 \cs_new_protected:cpn { __str_convert_decode_utf16: }
24937 {
24938 \exp_after:wN \__str_decode_utf_xvi_bom:NN
24939 \g__str_result_tl \s__str_stop \s__str_stop \s__str_stop
24940 }
24941 \cs_new_protected:Npn \__str_decode_utf_xvi_bom:NN #1#2
24942 {
24943 \str_if_eq:nnTF { #1#2 } { ^^ff ^^fe }
24944 { \__str_decode_utf_xvi:Nw 2 }
24945 {
24946 \str_if_eq:nnTF { #1#2 } { ^^fe ^^ff }
24947 { \__str_decode_utf_xvi:Nw 1 }
24948 { \__str_decode_utf_xvi:Nw 1 #1#2 }
24949 }
24950 }
24951 \cs_new_protected:Npn \__str_decode_utf_xvi:Nw #1#2 \s__str_stop
24952 {
24953 \flag_clear:N \l__str_error_flag
24954 \flag_clear:N \l__str_missing_flag
24955 \flag_clear:N \l__str_extra_flag
24956 \flag_clear:N \l__str_end_flag
24957 \cs_set:Npn \__str_tmp:w ##1 ##2 { ` ## #1 }
24958 \__kernel_tl_gset:Nx \g__str_result_tl
24959 {
24960 \exp_after:wN \__str_decode_utf_xvi_pair:NN
24961 #2 \q__str_nil \q__str_nil
24962 \prg_break_point:
24963 }
24964 \__str_if_flag_error:Nne \l__str_error_flag { utf16-decode } { }
24965 }
24966 \cs_new:Npn \__str_decode_utf_xvi_pair:NN #1#2
24967 {
24968 \if_meaning:w \q__str_nil #2
24969 \__str_decode_utf_xvi_pair_end:Nw #1
24970 \fi:
24971 \if_case:w
24972 \int_eval:n { ( \__str_tmp:w #1#2 - "D6 ) / 4 } \scan_stop:
24973 \or: \exp_after:wN \__str_decode_utf_xvi_quad:NNwNN
24974 \or: \exp_after:wN \__str_decode_utf_xvi_extra:NNw
24975 \fi:
24976 #1#2 \s__str
24977 \int_eval:n { "100 * \__str_tmp:w #1#2 + \__str_tmp:w #2#1 } \s__str
24978 \__str_decode_utf_xvi_pair:NN
24979 }
24980 \cs_new:Npn \__str_decode_utf_xvi_quad:NNwNN
24981 #1#2 #3 \__str_decode_utf_xvi_pair:NN #4#5
24982 {
24983 \if_meaning:w \q__str_nil #5
24984 \__str_decode_utf_xvi_error:nNN { missing } #1#2
24985 \__str_decode_utf_xvi_pair_end:Nw #4
24986 \fi:
24987 \if_int_compare:w
24988 \if_int_compare:w \__str_tmp:w #4#5 < "DC \exp_stop_f:
24989 0 = 1
24990 \else:
24991 \__str_tmp:w #4#5 < "E0
24992 \fi:
24993 \exp_stop_f:
24994 #1 #2 #4 #5 \s__str
24995 \int_eval:n
24996 {
24997 ( "100 * \__str_tmp:w #1#2 + \__str_tmp:w #2#1 - "D7F7 ) * "400
24998 + "100 * \__str_tmp:w #4#5 + \__str_tmp:w #5#4
24999 }
25000 \s__str
25001 \exp_after:wN \use_i:nnn
25002 \else:
25003 \__str_decode_utf_xvi_error:nNN { missing } #1#2
25004 \fi:
25005 \__str_decode_utf_xvi_pair:NN #4#5
25006 }
25007 \cs_new:Npn \__str_decode_utf_xvi_pair_end:Nw #1 \fi:
25008 {
25009 \fi:
25010 \if_meaning:w \q__str_nil #1
25011 \else:
25012 \__str_decode_utf_xvi_error:nNN { end } #1 \prg_do_nothing:
25013 \fi:
25014 \prg_break:
25015 }
25016 \cs_new:Npn \__str_decode_utf_xvi_extra:NNw #1#2 \s__str #3 \s__str
25017 { \__str_decode_utf_xvi_error:nNN { extra } #1#2 }
25018 \cs_new:Npn \__str_decode_utf_xvi_error:nNN #1#2#3
25019 {
25020 \flag_raise:N \l__str_error_flag
25021 \flag_raise:c { l__str_#1_flag }
25022 #2 #3 \s__str
25023 \int_use:N \c__str_replacement_char_int \s__str
25024 }
25025 \group_end:
25026 \group_begin:
25027 \char_set_catcode_other:N \^^00
25028 \char_set_catcode_other:N \^^fe
25029 \char_set_catcode_other:N \^^ff
25030 \cs_new_protected:cpn { __str_convert_encode_utf32: }
25031 {
25032 \__str_convert_gmap_internal:N \__str_encode_utf_xxxii_be:n
25033 \tl_gput_left:Ne \g__str_result_tl { ^^00 ^^00 ^^fe ^^ff }
25034 }
25035 \cs_new_protected:cpn { __str_convert_encode_utf32be: }
25036 { \__str_convert_gmap_internal:N \__str_encode_utf_xxxii_be:n }
25037 \cs_new_protected:cpn { __str_convert_encode_utf32le: }
25038 { \__str_convert_gmap_internal:N \__str_encode_utf_xxxii_le:n }
25039 \cs_new:Npn \__str_encode_utf_xxxii_be:n #1
25040 {
25041 \exp_args:Nf \__str_encode_utf_xxxii_be_aux:nn
25042 { \int_div_truncate:nn {#1} { "100 } } {#1}
25043 }
25044 \cs_new:Npn \__str_encode_utf_xxxii_be_aux:nn #1#2
25045 {
25046 ^^00
25047 \__str_output_byte_pair_be:n {#1}
25048 \__str_output_byte:n { #2 - #1 * "100 }
25049 }
25050 \cs_new:Npn \__str_encode_utf_xxxii_le:n #1
25051 {
25052 \exp_args:Nf \__str_encode_utf_xxxii_le_aux:nn
25053 { \int_div_truncate:nn {#1} { "100 } } {#1}
25054 }
25055 \cs_new:Npn \__str_encode_utf_xxxii_le_aux:nn #1#2
25056 {
25057 \__str_output_byte:n { #2 - #1 * "100 }
25058 \__str_output_byte_pair_le:n {#1}
25059 ^^00
25060 }
25061 \flag_clear_new:N \l__str_overflow_flag
25062 \flag_clear_new:N \l__str_end_flag
25063 \msg_new:nnnn { str } { utf32-decode }
25064 {
25065 Invalid~UTF-32~string:
25066 \exp_last_unbraced:Nf \use_none:n
25067 {
25068 \__str_if_flag_times:NT \l__str_overflow_flag { ,~code~point~too~large }
25069 \__str_if_flag_times:NT \l__str_end_flag { ,~truncated~string }
25070 }
25071 .
25072 }
25073 {
25074 In~the~UTF-32~encoding,~every~Unicode~character~
25075 (in~the~range~[U+0000,~U+10FFFF])~is~encoded~as~4~bytes.
25076 \flag_if_raised:NT \l__str_overflow_flag
25077 {
25078 \\\\
25079 LaTeX~came~across~a~code~point~larger~than~1114111,~
25080 the~maximum~code~point~defined~by~Unicode.~
25081 Perhaps~the~string~was~not~encoded~in~the~UTF-32~encoding?
25082 }
25083 \flag_if_raised:NT \l__str_end_flag
25084 {
25085 \\\\
25086 The~length~of~the~string~is~not~a~multiple~of~4.~
25087 Perhaps~the~string~was~truncated?
25088 }
25089 }
25090 \cs_new_protected:cpn { __str_convert_decode_utf32be: }
25091 { \__str_decode_utf_xxxii:Nw 1 \g__str_result_tl \s__str_stop }
25092 \cs_new_protected:cpn { __str_convert_decode_utf32le: }
25093 { \__str_decode_utf_xxxii:Nw 2 \g__str_result_tl \s__str_stop }
25094 \cs_new_protected:cpn { __str_convert_decode_utf32: }
25095 {
25096 \exp_after:wN \__str_decode_utf_xxxii_bom:NNNN \g__str_result_tl
25097 \s__str_stop \s__str_stop \s__str_stop \s__str_stop \s__str_stop
25098 }
25099 \cs_new_protected:Npn \__str_decode_utf_xxxii_bom:NNNN #1#2#3#4
25100 {
25101 \str_if_eq:nnTF { #1#2#3#4 } { ^^ff ^^fe ^^00 ^^00 }
25102 { \__str_decode_utf_xxxii:Nw 2 }
25103 {
25104 \str_if_eq:nnTF { #1#2#3#4 } { ^^00 ^^00 ^^fe ^^ff }
25105 { \__str_decode_utf_xxxii:Nw 1 }
25106 { \__str_decode_utf_xxxii:Nw 1 #1#2#3#4 }
25107 }
25108 }
25109 \cs_new_protected:Npn \__str_decode_utf_xxxii:Nw #1#2 \s__str_stop
25110 {
25111 \flag_clear:N \l__str_overflow_flag
25112 \flag_clear:N \l__str_end_flag
25113 \flag_clear:N \l__str_error_flag
25114 \cs_set:Npn \__str_tmp:w ##1 ##2 { ` ## #1 }
25115 \__kernel_tl_gset:Nx \g__str_result_tl
25116 {
25117 \exp_after:wN \__str_decode_utf_xxxii_loop:NNNN
25118 #2 \s__str_stop \s__str_stop \s__str_stop \s__str_stop
25119 \prg_break_point:
25120 }
25121 \__str_if_flag_error:Nne \l__str_error_flag { utf32-decode } { }
25122 }
25123 \cs_new:Npn \__str_decode_utf_xxxii_loop:NNNN #1#2#3#4
25124 {
25125 \if_meaning:w \s__str_stop #4
25126 \exp_after:wN \__str_decode_utf_xxxii_end:w
25127 \fi:
25128 #1#2#3#4 \s__str
25129 \if_int_compare:w \__str_tmp:w #1#4 > \c_zero_int
25130 \flag_raise:N \l__str_overflow_flag
25131 \flag_raise:N \l__str_error_flag
25132 \int_use:N \c__str_replacement_char_int
25133 \else:
25134 \if_int_compare:w \__str_tmp:w #2#3 > 16 \exp_stop_f:
25135 \flag_raise:N \l__str_overflow_flag
25136 \flag_raise:N \l__str_error_flag
25137 \int_use:N \c__str_replacement_char_int
25138 \else:
25139 \int_eval:n
25140 { \__str_tmp:w #2#3*"10000 + \__str_tmp:w #3#2*"100 + \__str_tmp:w #4#1 }
25141 \fi:
25142 \fi:
25143 \s__str
25144 \__str_decode_utf_xxxii_loop:NNNN
25145 }
25146 \cs_new:Npn \__str_decode_utf_xxxii_end:w #1 \s__str_stop
25147 {
25148 \tl_if_empty:nF {#1}
25149 {
25150 \flag_raise:N \l__str_end_flag
25151 \flag_raise:N \l__str_error_flag
25152 #1 \s__str
25153 \int_use:N \c__str_replacement_char_int \s__str
25154 }
25155 \prg_break:
25156 }
25157 \group_end:
25158 \cs_new:Npn \str_convert_pdfname:n #1
25159 {
25160 \exp_args:Ne \tl_to_str:n
25161 { \str_map_function:nN {#1} \__str_convert_pdfname:n }
25162 }
25163 \sys_if_engine_opentype:TF
25164 {
25165 \cs_new:Npn \__str_convert_pdfname:n #1
25166 {
25167 \int_compare:nNnTF { `#1 } > { "7F }
25168 { \__str_convert_pdfname_bytes:n {#1} }
25169 { \__str_escape_name_char:n {#1} }
25170 }
25171 \cs_new:Npn \__str_convert_pdfname_bytes:n #1
25172 {
25173 \exp_args:Ne \__str_convert_pdfname_bytes_aux:n
25174 { \__kernel_codepoint_to_bytes:n {`#1} }
25175 }
25176 \cs_new:Npn \__str_convert_pdfname_bytes_aux:n #1
25177 { \__str_convert_pdfname_bytes_aux:nnnn #1 }
25178 \cs_new:Npe \__str_convert_pdfname_bytes_aux:nnnn #1#2#3#4
25179 {
25180 \c_hash_str \exp_not:N \__str_output_hexadecimal:n {#1}
25181 \c_hash_str \exp_not:N \__str_output_hexadecimal:n {#2}
25182 \exp_not:N \tl_if_blank:nF {#3}
25183 {
25184 \c_hash_str \exp_not:N \__str_output_hexadecimal:n {#3}
25185 \exp_not:N \tl_if_blank:nF {#4}
25186 {
25187 \c_hash_str \exp_not:N \__str_output_hexadecimal:n {#4}
25188 }
25189 }
25190 }
25191 }
25192 { \cs_new_eq:NN \__str_convert_pdfname:n \__str_escape_name_char:n }
25193 %% File: l3str-format.dtx
25194 \cs_generate_variant:Nn \use:nn { nf }
25195 \cs_generate_variant:Nn \use:nnn { fnf }
25196 \cs_generate_variant:Nn \tl_to_str:n { f }
25197 \prg_new_conditional:Npnn \__str_format_if_digit:N #1 { TF }
25198 {
25199 \if_int_compare:w 9 < 1 #1 \exp_stop_f:
25200 \prg_return_true: \else: \prg_return_false: \fi:
25201 }
25202 \cs_new:Npn \__str_format_put:nw #1 #2 \s__str_stop { #2 \s__str_stop #1 }
25203 \cs_generate_variant:Nn \__str_format_put:nw { o , f }
25204 \prg_new_conditional:Npnn \__str_format_if_in:nN #1#2 { TF }
25205 {
25206 \__str_format_if_in_aux:NN #2 #1
25207 { #2 \prg_return_false: \exp_after:wN \prg_break: \else: }
25208 \prg_break_point:
25209 }
25210 \cs_new:Npn \__str_format_if_in_aux:NN #1#2
25211 {
25212 \if_charcode:w #1 #2
25213 \prg_return_true:
25214 \exp_after:wN \prg_break:
25215 \fi:
25216 \__str_format_if_in_aux:NN #1
25217 }
25218 \cs_new:Npn \__str_format_parse:n #1
25219 {
25220 \exp_last_unbraced:Nf \__str_format_parse_auxi:NN
25221 { \__kernel_str_to_other:n {#1} } \s__str_stop \s__str_stop {#1}
25222 }
25223 \cs_new:Npe \__str_format_parse_auxi:NN #1#2
25224 {
25225 \exp_not:N \__str_format_if_in:nNTF { < > = ^ } #2
25226 { \exp_not:N \__str_format_parse_auxiii:nN { #1 #2 } }
25227 {
25228 \exp_not:N \__str_format_parse_auxii:nN
25229 { \c_catcode_other_space_tl } #1 #2
25230 }
25231 }
25232 \cs_new:Npn \__str_format_parse_auxii:nN #1#2
25233 {
25234 \__str_format_if_in:nNTF { < > = ^ } #2
25235 { \__str_format_parse_auxiii:nN { #1 #2 } }
25236 { \__str_format_parse_auxiii:nN { #1 ? } #2 }
25237 }
25238 \cs_new:Npe \__str_format_parse_auxiii:nN #1#2
25239 {
25240 \exp_not:N \__str_format_if_in:nNTF
25241 { + - \c_catcode_other_space_tl }
25242 #2
25243 { \exp_not:N \__str_format_parse_auxiv:nwN { #1 #2 } ; }
25244 { \exp_not:N \__str_format_parse_auxiv:nwN { #1 ? } ; #2 }
25245 }
25246 \cs_new:Npn \__str_format_parse_auxiv:nwN #1#2; #3
25247 {
25248 \__str_format_if_digit:NTF #3
25249 { \__str_format_parse_auxiv:nwN {#1} #2 #3 ; }
25250 { \__str_format_parse_auxv:nN { #1 {#2} } #3 }
25251 }
25252 \cs_new:Npn \__str_format_parse_auxv:nN #1#2
25253 {
25254 \token_if_eq_charcode:NNTF . #2
25255 { \__str_format_parse_auxvi:nwN {#1} 0 ; }
25256 { \__str_format_parse_auxvii:nN { #1 { } } #2 }
25257 }
25258 \cs_new:Npn \__str_format_parse_auxvi:nwN #1#2; #3
25259 {
25260 \__str_format_if_digit:NTF #3
25261 { \__str_format_parse_auxvi:nwN {#1} #2 #3 ; }
25262 { \__str_format_parse_auxvii:nN { #1 {#2} } #3 }
25263 }
25264 \cs_new:Npn \__str_format_parse_auxvii:nN #1#2
25265 {
25266 \token_if_eq_meaning:NNTF \s__str_stop #2
25267 { \__str_format_parse_end:nwn { #1 ? } #2 }
25268 { \__str_format_parse_end:nwn { #1 #2 } }
25269 }
25270 \cs_new:Npn \__str_format_parse_end:nwn #1 #2 \s__str_stop \s__str_stop #3
25271 {
25272 \tl_if_empty:nF {#2}
25273 { \msg_expandable_error:nnn { str } { invalid-format } {#3} }
25274 #1
25275 }
25276 \cs_new:cpn { __str_format_align_<:nnnN } #1#2#3#4
25277 {
25278 \use:nf { #2 #1 }
25279 {
25280 \prg_replicate:nn
25281 { \int_max:nn { #3 - \__str_count:n { #2 #1 } } { 0 } }
25282 {#4}
25283 }
25284 }
25285 \cs_new:cpn { __str_format_align_>:nnnN } #1#2#3#4
25286 {
25287 \prg_replicate:nn
25288 { \int_max:nn { #3 - \__str_count:n { #2 #1 } } { 0 } }
25289 {#4}
25290 #2 #1
25291 }
25292 \cs_new:cpn { __str_format_align_^:nnnN } #1#2#3#4
25293 {
25294 \use:fnf
25295 {
25296 \prg_replicate:nn
25297 {
25298 \int_max:nn { 0 }
25299 { #3 - \__str_count:n { #2 #1 } - 1 }
25300 / 2
25301 }
25302 {#4}
25303 }
25304 { #2 #1 }
25305 {
25306 \prg_replicate:nn
25307 {
25308 \int_max:nn { 0 }
25309 { #3 - \__str_count:n { #2 #1 } }
25310 / 2
25311 }
25312 {#4}
25313 }
25314 }
25315 \cs_new:cpn { __str_format_align_=:nnnN } #1#2#3#4
25316 {
25317 \use:nf {#2}
25318 {
25319 \prg_replicate:nn
25320 { \int_max:nn { #3 - \__str_count:n { #2 #1 } } { 0 } }
25321 {#4}
25322 }
25323 #1
25324 }
25325 \cs_new:Npn \tl_format:Nn { \exp_args:No \tl_format:nn }
25326 \cs_generate_variant:Nn \tl_format:Nn { c }
25327 \cs_new:Npn \tl_format:nn #1#2
25328 {
25329 \tl_to_str:f
25330 {
25331 \exp_last_unbraced:Nf \__str_format_tl:NNNnnNn
25332 { \__str_format_parse:n {#2} }
25333 {#1}
25334 }
25335 }
25336 \cs_new:Npn \__str_format_tl:NNNnnNn #1#2#3#4#5#6
25337 {
25338 \token_if_eq_charcode:NNTF #2 =
25339 {
25340 \msg_expandable_error:nnnn
25341 { str } { invalid-align-format } {#2} {tl}
25342 \__str_format_put:nw { #1 < }
25343 }
25344 {
25345 \token_if_eq_charcode:NNTF #2 ?
25346 { \__str_format_put:nw { #1 < } }
25347 { \__str_format_put:nw { #1 #2 } }
25348 }
25349 \token_if_eq_charcode:NNF #3 ?
25350 {
25351 \msg_expandable_error:nnnn
25352 { str } { invalid-sign-format } {#3} {tl}
25353 }
25354 \__str_format_put:nw { {#4} }
25355 \tl_if_empty:nTF {#5}
25356 { \__str_format_put:nw { \__str_range:nnn { {1} {-1} } } }
25357 { \__str_format_put:nw { \__str_range:nnn { {1} {#5} } } }
25358 \token_if_eq_charcode:NNF #6 s
25359 {
25360 \token_if_eq_charcode:NNF #6 ?
25361 {
25362 \msg_expandable_error:nnnn
25363 { str } { invalid-style-format } {#6} {tl}
25364 }
25365 }
25366 \__str_format_tl_s:NNnnNNn
25367 \s__str_stop
25368 }
25369 \cs_new:Npn \__str_format_tl_s:NNnnNNn #1#2#3#4#5#6#7
25370 {
25371 \exp_args:Nc \exp_args:Nf
25372 { __str_format_align_#6:nnnN }
25373 { \exp_args:Nf #2 { \__kernel_str_to_other:n {#7} } #3 }
25374 { }
25375 {#4} #5
25376 }
25377 \cs_new:Npn \seq_format:Nn #1#2
25378 {
25379 \tl_to_str:f
25380 {
25381 \__str_format_seq:ff
25382 { \exp_after:wN \use_i:nn \exp_after:wN \exp_stop_f: #1 }
25383 { \__str_format_parse:n {#2} }
25384 }
25385 }
25386 \cs_generate_variant:Nn \seq_format:Nn { c }
25387 \cs_new:Npn \__str_format_seq:nn #1#2
25388 {
25389 \__str_format_seq_loop:nnNn { } {#2}
25390 #1
25391 { ? \__str_format_seq_end:w } { }
25392 }
25393 \cs_generate_variant:Nn \__str_format_seq:nn { ff }
25394 \cs_new:Npn \__str_format_seq_loop:nnNn #1#2#3#4
25395 {
25396 \use_none:n #3
25397 \exp_args:Nf \__str_format_seq_loop:nnNn
25398 { \use:nf {#1} { \__str_format_tl:NNNnnNn #2 {#4} } }
25399 {#2}
25400 }
25401 \cs_new:Npn \__str_format_seq_end:w #1#2#3#4 { \use_ii:nnn #3 }
25402 \cs_new:Npn \int_format:nn #1
25403 { \exp_args:Nf \__str_format_int:nn { \int_eval:n {#1} } }
25404 \cs_new:Npn \__str_format_int:nn #1#2
25405 {
25406 \tl_to_str:f
25407 {
25408 \exp_last_unbraced:Nf \__str_format_int:NNNnnNn
25409 { \__str_format_parse:n {#2} }
25410 {#1}
25411 }
25412 }
25413 \cs_new:Npn \__str_format_int:NNNnnNn #1#2#3#4#5#6#7
25414 {
25415 \token_if_eq_charcode:NNTF #2 ?
25416 { \__str_format_put:nw { #1 > } }
25417 { \__str_format_put:nw { #1 #2 } }
25418 \int_compare:nNnTF {#7} < 0
25419 { \__str_format_put:nw { - } }
25420 {
25421 \str_case:nnF {#3}
25422 {
25423 { ~ } { \__str_format_put:ow { \c_catcode_other_space_tl } }
25424 { + } { \__str_format_put:nw { + } }
25425 }
25426 { \__str_format_put:nw { { } } }
25427 }
25428 \__str_format_put:nw { {#4} }
25429 \tl_if_empty:nF {#5}
25430 {
25431 \msg_expandable_error:nnnn
25432 { str } { invalid-precision-format } {#5} {int}
25433 }
25434 \str_case:nnF {#6}
25435 {
25436 { ? } { \__str_format_int:NwnnNNn \use:n }
25437 { d } { \__str_format_int:NwnnNNn \use:n }
25438 { b } { \__str_format_int:NwnnNNn \int_to_bin:n }
25439 { o } { \__str_format_int:NwnnNNn \int_to_oct:n }
25440 { X } { \__str_format_int:NwnnNNn \int_to_Hex:n }
25441 }
25442 {
25443 \msg_expandable_error:nnnn
25444 { str } { invalid-style-format } {#6} { int }
25445 \__str_format_int:NwnnNNn \use:n
25446 }
25447 \s__str_stop {#7}
25448 }
25449 \cs_new:Npn \__str_format_int:NwnnNNn #1#2 \s__str_stop #3#4#5#6#7
25450 {
25451 \exp_args:Nc \exp_args:Nf
25452 { __str_format_align_#6:nnnN }
25453 { #1 { \int_abs:n {#7} } }
25454 {#4}
25455 {#3} #5
25456 }
25457 \cs_new:Npn \fp_format:nn #1
25458 { \exp_args:Nf \__str_format_fp:nn { \fp_to_tl:n {#1} } }
25459 \cs_new:Npn \__str_format_fp:nn #1#2
25460 {
25461 \tl_to_str:f
25462 {
25463 \exp_last_unbraced:Nf \__str_format_fp:NNNnnNn
25464 { \__str_format_parse:n {#2} }
25465 {#1}
25466 }
25467 }
25468 \cs_new:Npn \__str_format_fp:NNNnnNn
25469 #1#2#3#4#5#6#7
25470 {
25471 \token_if_eq_charcode:NNTF #2 ?
25472 { \__str_format_put:nw { #1 > } }
25473 { \__str_format_put:nw { #1 #2 } }
25474 \tl_if_head_eq_charcode:nNTF {#7} -
25475 { \__str_format_put:nw { - } }
25476 {
25477 \str_case:nnF {#3}
25478 {
25479 { ~ } { \__str_format_put:ow { \c_catcode_other_space_tl } }
25480 { + } { \__str_format_put:nw { + } }
25481 }
25482 { \__str_format_put:nw { { } } }
25483 }
25484 \__str_format_put:nw { {#4} }
25485 \tl_if_empty:nTF {#5}
25486 {
25487 \token_if_eq_meaning:NNTF #6 ?
25488 { \__str_format_put:nw { { } } }
25489 { \__str_format_put:nw { { 6} } }
25490 }
25491 { \__str_format_put:nw { {#5} } }
25492 \str_case:nnF {#6}
25493 {
25494 { e } { \__str_format_fp:wnnnNNn \__str_format_fp_e:nn }
25495 { f } { \__str_format_fp:wnnnNNn \__str_format_fp_f:nn }
25496 { g } { \__str_format_fp:wnnnNNn \__str_format_fp_g:nn }
25497 { ? } { \__str_format_fp:wnnnNNn \__str_format_fp_g:nn }
25498 }
25499 {
25500 \msg_expandable_error:nnnn
25501 { str } { invalid-style-format } {#6} { fp }
25502 \__str_format_fp:wnnnNNn \__str_format_fp_g:nn
25503 }
25504 \s__str_stop {#7}
25505 }
25506 \cs_new:Npn \__str_format_fp:wnnnNNn
25507 #1 \s__str_stop #2 #3 #4 #5#6 #7
25508 {
25509 \exp_args:Nc \exp_args:Nf
25510 { __str_format_align_#6:nnnN }
25511 { #1 {#7} {#2} }
25512 {#4}
25513 {#3} #5
25514 }
25515 \cs_new:Npn \__str_format_fp_round:nn #1 #2
25516 { \fp_to_tl:n { abs ( round ( #1 , #2 - logb(#1) - 1 ) ) } }
25517 \cs_new:Npn \__str_format_fp_e:nn #1#2
25518 {
25519 \exp_args:Nf \__str_format_fp_e_aux:nn
25520 { \__str_format_fp_round:nn {#1} { #2 + 1 } }
25521 {#2}
25522 }
25523 \cs_new:Npn \__str_format_fp_e_aux:nn #1#2
25524 {
25525 \str_case:nnF {#1}
25526 {
25527 { inf } { inf }
25528 { nan } { nan }
25529 }
25530 {
25531 \exp_last_unbraced:Nf \__str_format_fp_e_aux:wwn
25532 { \fp_to_scientific:n {#1} } ;
25533 {#2}
25534 }
25535 }
25536 \cs_new:Npn \__str_format_fp_e_aux:wwn #1 . #2 e #3 ; #4
25537 {
25538 \__str_format_put:nw { e #3 }
25539 \int_compare:nNnTF {#4} < \c__fp_prec_int
25540 {
25541 \__str_format_put:fw { \str_range:nnn { #2 } { 1 } { #4 } }
25542 \__str_format_put:nw { #1 . }
25543 }
25544 {
25545 \__str_format_put:fw
25546 { \prg_replicate:nn { #4 - \c__fp_prec_int + 1 } { 0 } }
25547 \__str_format_put:nw { #1 . #2 }
25548 }
25549 \use_none:n \s__str_stop
25550 }
25551 \cs_new:Npn \__str_format_fp_f:nn #1#2
25552 {
25553 \exp_args:Nf \__str_format_fp_f_aux:nn
25554 { \fp_to_tl:n { abs ( round ( #1 , #2 ) ) } }
25555 {#2}
25556 }
25557 \cs_new:Npn \__str_format_fp_f_aux:nn #1#2
25558 {
25559 \str_case:nnF {#1}
25560 {
25561 { inf } { inf }
25562 { nan } { nan }
25563 }
25564 {
25565 \exp_last_unbraced:Nf \__str_format_fp_f_aux:wwwn
25566 { \fp_to_decimal:n {#1} } . . ; {#2}
25567 }
25568 }
25569 \cs_new:Npn \__str_format_fp_f_aux:wwwn #1 . #2 . #3 ; #4
25570 {
25571 \use:nf { #1 . #2 }
25572 { \prg_replicate:nn { #4 - \__str_count:n {#2} } {0} }
25573 }
25574 \cs_new:Npn \__str_format_fp_g:nn #1#2
25575 {
25576 \tl_if_empty:nTF {#2} { \fp_to_tl:n { abs(#1) } }
25577 {
25578 \exp_args:Nf \__str_format_fp_g_aux:nn
25579 { \__str_format_fp_round:nn {#1} { \int_max:nn {1} {#2} } }
25580 { \int_max:nn {1} {#2} }
25581 }
25582 }
25583 \cs_new:Npn \__str_format_fp_g_aux:nn #1#2
25584 {
25585 \str_case:nnF {#1}
25586 {
25587 { 0 } { 0 }
25588 { inf } { inf }
25589 { nan } { nan }
25590 }
25591 {
25592 \fp_compare:nTF { 1e-4 <= #1 < 1e#2 }
25593 { \fp_to_decimal:n {#1} }
25594 {
25595 \exp_last_unbraced:Nf \__str_format_fp_trim:w
25596 { \fp_to_scientific:n {#1} }
25597 }
25598 }
25599 }
25600 \cs_new:Npn \__str_format_fp_trim:w #1 e
25601 {
25602 \__str_format_fp_trim_loop:w #1
25603 ; \__str_format_fp_trim_loop:w 0; \__str_format_fp_trim_dot:w .; \s__str_stop e
25604 }
25605 \cs_new:Npn \__str_format_fp_trim_loop:w #1 0; #2 { #2 #1 ; #2 }
25606 \cs_new:Npn \__str_format_fp_trim_dot:w #1 .; { \__str_format_fp_trim_end:w #1 ; }
25607 \cs_new:Npn \__str_format_fp_trim_end:w #1 ; #2 \s__str_stop { #1 }
25608 \msg_new:nnn { str } { invalid-format }
25609 { Invalid~format~'#1'. }
25610 \msg_new:nnn { str } { invalid-align-format }
25611 { Invalid~alignment~'#1'~for~type~'#2'. }
25612 \msg_new:nnn { str } { invalid-sign-format }
25613 { Invalid~sign~'#1'~for~type~'#2'. }
25614 \msg_new:nnn { str } { invalid-precision-format }
25615 { Invalid~precision~'#1'~for~type~'#2'. }
25616 \msg_new:nnn { str } { invalid-style-format }
25617 { Invalid~style~'#1'~for~type~'#2'. }
25618 %% File: l3tl-analysis.dtx
25619 \scan_new:N \s__tl
25620 \cs_new_eq:NN \l__tl_analysis_token ?
25621 \cs_new_eq:NN \l__tl_analysis_char_token ?
25622 \tl_new:N \l__tl_peek_code_tl
25623 \group_begin:
25624 \char_set_active_eq:NN \ \scan_stop:
25625 \tl_const:Ne \c__tl_peek_catcodes_tl
25626 {
25627 \char_generate:nn { 32 } { 3 } 3
25628 \char_generate:nn { 32 } { 4 } 4
25629 \char_generate:nn { 32 } { 7 } 7
25630 \char_generate:nn { 32 } { 8 } 8
25631 \c_space_tl \token_to_str:N A
25632 \char_generate:nn { 32 } { 11 } \token_to_str:N B
25633 \char_generate:nn { 32 } { 12 } \token_to_str:N C
25634 \char_generate:nn { 32 } { 13 } \token_to_str:N D
25635 }
25636 \group_end:
25637 \int_new:N \l__tl_analysis_normal_int
25638 \int_new:N \l__tl_analysis_index_int
25639 \int_new:N \l__tl_analysis_nesting_int
25640 \int_new:N \l__tl_analysis_type_int
25641 \tl_new:N \g__tl_analysis_result_tl
25642 \cs_new:Npn \__tl_analysis_extract_charcode:
25643 {
25644 \exp_after:wN \__tl_analysis_extract_charcode_aux:w
25645 \token_to_meaning:N \l__tl_analysis_token
25646 }
25647 \cs_new:Npn \__tl_analysis_extract_charcode_aux:w #1 ~ #2 ~ { ` }
25648 \bool_lazy_and:nnT
25649 { \cs_if_exist_p:N \tex_luatexversion:D }
25650 { \int_compare_p:nNn { \int_div_truncate:nn { \tex_luatexversion:D } { 100 } } > 1 }
25651 {
25652 \cs_gset:Npn \__tl_analysis_extract_charcode_aux:w #1 + #2 ~ ' #3 ' {"#2}
25653 }
25654 \cs_new:Npe \__tl_analysis_cs_space_count:NN #1 #2
25655 {
25656 \exp_not:N \exp_after:wN #1
25657 \exp_not:N \int_value:w \exp_not:N \int_eval:w 0
25658 \exp_not:N \exp_after:wN \exp_not:N \__tl_analysis_cs_space_count:w
25659 \exp_not:N \token_to_str:N #2
25660 \exp_not:N \fi: \exp_not:N \__tl_analysis_cs_space_count_end:w
25661 \exp_not:N \__tl_sep: \c_space_tl !
25662 }
25663 \cs_new:Npn \__tl_analysis_cs_space_count:w #1 ~
25664 {
25665 \if_false: #1 #1 \fi:
25666 + 1
25667 \__tl_analysis_cs_space_count:w
25668 }
25669 \cs_new:Npn \__tl_analysis_cs_space_count_end:w \__tl_sep: #1 \fi: #2 !
25670 {
25671 \exp_after:wN \__tl_sep: \int_value:w
25672 \str_count_ignore_spaces:n {#1} \__tl_sep:
25673 }
25674 \cs_new_protected:Npn \__tl_analysis:n #1
25675 {
25676 \group_begin:
25677 \group_align_safe_begin:
25678 \__tl_analysis_a:n {#1}
25679 \__tl_analysis_b:n {#1}
25680 \group_align_safe_end:
25681 \group_end:
25682 }
25683 \group_begin:
25684 \char_set_catcode_active:N \^^@
25685 \cs_new_protected:Npn \__tl_analysis_disable:n #1
25686 {
25687 \tex_lccode:D 0 = #1 \exp_stop_f:
25688 \tex_lowercase:D { \tex_let:D ^^@ } \tex_undefined:D
25689 }
25690 \bool_lazy_or:nnT
25691 { \sys_if_engine_ptex_p: }
25692 { \sys_if_engine_uptex_p: }
25693 {
25694 \cs_gset_protected:Npn \__tl_analysis_disable:n #1
25695 {
25696 \if_int_compare:w 256 > #1 \exp_stop_f:
25697 \tex_lccode:D 0 = #1 \exp_stop_f:
25698 \tex_lowercase:D { \tex_let:D ^^@ } \tex_undefined:D
25699 \fi:
25700 }
25701 }
25702 \group_end:
25703 \group_begin:
25704 \char_set_catcode_active:N \^^@
25705 \cs_new_protected:Npn \__tl_analysis_disable_char:N #1
25706 {
25707 \tex_lccode:D `#1 = 32 \exp_stop_f:
25708 \tex_lowercase:D { \if_meaning:w #1 } \tex_undefined:D
25709 \tex_let:D #1 \tex_undefined:D
25710 \fi:
25711 }
25712 \bool_lazy_or:nnT
25713 { \sys_if_engine_ptex_p: }
25714 { \sys_if_engine_uptex_p: }
25715 {
25716 \cs_gset_protected:Npn \__tl_analysis_disable_char:N #1
25717 {
25718 \if_int_compare:w 256 > `#1 \exp_stop_f:
25719 \tex_lccode:D `#1 = 32 \exp_stop_f:
25720 \tex_lowercase:D { \if_meaning:w #1 } \tex_undefined:D
25721 \tex_let:D #1 \tex_undefined:D
25722 \fi:
25723 \fi:
25724 }
25725 }
25726 \group_end:
25727 \cs_new_protected:Npn \__tl_analysis_a:n #1
25728 {
25729 \__tl_analysis_disable:n { 32 }
25730 \int_set:Nn \tex_escapechar:D { 92 }
25731 \int_zero:N \l__tl_analysis_normal_int
25732 \int_zero:N \l__tl_analysis_index_int
25733 \int_zero:N \l__tl_analysis_nesting_int
25734 \if_false: { \fi: \__tl_analysis_a_loop:w #1 }
25735 \int_decr:N \l__tl_analysis_index_int
25736 }
25737 \cs_new_protected:Npn \__tl_analysis_a_loop:w
25738 { \tex_futurelet:D \l__tl_analysis_token \__tl_analysis_a_type:w }
25739 \cs_new_protected:Npn \__tl_analysis_a_type:w
25740 {
25741 \l__tl_analysis_type_int =
25742 \if_meaning:w \l__tl_analysis_token \c_space_token
25743 0
25744 \else:
25745 \if_catcode:w \exp_not:N \l__tl_analysis_token \c_group_begin_token
25746 1
25747 \else:
25748 \if_catcode:w \exp_not:N \l__tl_analysis_token \c_group_end_token
25749 - 1
25750 \else:
25751 2
25752 \fi:
25753 \fi:
25754 \fi:
25755 \exp_stop_f:
25756 \if_case:w \l__tl_analysis_type_int
25757 \exp_after:wN \__tl_analysis_a_space:w
25758 \or: \exp_after:wN \__tl_analysis_a_bgroup:w
25759 \or: \exp_after:wN \__tl_analysis_a_safe:N
25760 \else: \exp_after:wN \__tl_analysis_a_egroup:w
25761 \fi:
25762 }
25763 \cs_new_protected:Npn \__tl_analysis_a_space:w
25764 {
25765 \tex_afterassignment:D \__tl_analysis_a_space_test:w
25766 \exp_after:wN \cs_set_eq:NN
25767 \exp_after:wN \l__tl_analysis_char_token
25768 \token_to_str:N
25769 }
25770 \cs_new_protected:Npn \__tl_analysis_a_space_test:w
25771 {
25772 \if_meaning:w \l__tl_analysis_char_token \c_space_token
25773 \tex_toks:D \l__tl_analysis_index_int { \exp_not:n { ~ } }
25774 \__tl_analysis_a_store:
25775 \else:
25776 \int_incr:N \l__tl_analysis_normal_int
25777 \fi:
25778 \__tl_analysis_a_loop:w
25779 }
25780 \group_begin:
25781 \char_set_catcode_group_begin:N \^^@ % {
25782 \cs_new_protected:Npn \__tl_analysis_a_bgroup:w
25783 { \__tl_analysis_a_group:nw { \exp_after:wN ^^@ \if_false: } \fi: } }
25784 \char_set_catcode_group_end:N \^^@
25785 \cs_new_protected:Npn \__tl_analysis_a_egroup:w
25786 { \__tl_analysis_a_group:nw { \if_false: { \fi: ^^@ } } % }
25787 \group_end:
25788 \cs_new_protected:Npn \__tl_analysis_a_group:nw #1
25789 {
25790 \tex_lccode:D 0 = \__tl_analysis_extract_charcode: \scan_stop:
25791 \tex_lowercase:D { \tex_toks:D \l__tl_analysis_index_int {#1} }
25792 \if_int_compare:w \tex_lccode:D 0 = \tex_escapechar:D
25793 \int_set:Nn \tex_escapechar:D { 139 - \tex_escapechar:D }
25794 \fi:
25795 \__tl_analysis_disable:n { \tex_lccode:D 0 }
25796 \tex_futurelet:D \l__tl_analysis_token \__tl_analysis_a_group_aux:w
25797 }
25798 \cs_new_protected:Npn \__tl_analysis_a_group_aux:w
25799 {
25800 \if_meaning:w \l__tl_analysis_token \tex_undefined:D
25801 \exp_after:wN \__tl_analysis_a_safe:N
25802 \else:
25803 \exp_after:wN \__tl_analysis_a_group_auxii:w
25804 \fi:
25805 }
25806 \cs_new_protected:Npn \__tl_analysis_a_group_auxii:w
25807 {
25808 \tex_afterassignment:D \__tl_analysis_a_group_test:w
25809 \exp_after:wN \cs_set_eq:NN
25810 \exp_after:wN \l__tl_analysis_char_token
25811 \token_to_str:N
25812 }
25813 \cs_new_protected:Npn \__tl_analysis_a_group_test:w
25814 {
25815 \if_charcode:w \l__tl_analysis_token \l__tl_analysis_char_token
25816 \__tl_analysis_a_store:
25817 \else:
25818 \int_incr:N \l__tl_analysis_normal_int
25819 \fi:
25820 \__tl_analysis_a_loop:w
25821 }
25822 \cs_new_protected:Npn \__tl_analysis_a_store:
25823 {
25824 \tex_advance:D \l__tl_analysis_nesting_int \l__tl_analysis_type_int
25825 \if_int_compare:w \tex_lccode:D 0 = `\ \exp_stop_f:
25826 \tex_advance:D \l__tl_analysis_type_int \l__tl_analysis_type_int
25827 \fi:
25828 \tex_skip:D \l__tl_analysis_index_int
25829 = \l__tl_analysis_normal_int sp
25830 plus \l__tl_analysis_type_int sp \scan_stop:
25831 \int_incr:N \l__tl_analysis_index_int
25832 \int_zero:N \l__tl_analysis_normal_int
25833 \if_int_compare:w \l__tl_analysis_nesting_int = - \c_one_int
25834 \cs_set_eq:NN \__tl_analysis_a_loop:w \scan_stop:
25835 \fi:
25836 }
25837 \cs_new_protected:Npn \__tl_analysis_a_safe:N #1
25838 {
25839 \if_charcode:w
25840 \scan_stop:
25841 \exp_after:wN \use_none:n \token_to_str:N #1 \prg_do_nothing:
25842 \scan_stop:
25843 \exp_after:wN \use_i:nn
25844 \else:
25845 \exp_after:wN \use_ii:nn
25846 \fi:
25847 {
25848 \__tl_analysis_disable_char:N #1
25849 \int_incr:N \l__tl_analysis_normal_int
25850 }
25851 { \__tl_analysis_cs_space_count:NN \__tl_analysis_a_cs:ww #1 }
25852 \__tl_analysis_a_loop:w
25853 }
25854 \cs_new_protected:Npn \__tl_analysis_a_cs:ww #1 \__tl_sep: #2 \__tl_sep:
25855 {
25856 \if_int_compare:w #1 > \c_zero_int
25857 \tex_skip:D \l__tl_analysis_index_int
25858 = \int_eval:n { \l__tl_analysis_normal_int + 1 } sp \exp_stop_f:
25859 \tex_advance:D \l__tl_analysis_index_int #1 \exp_stop_f:
25860 \else:
25861 \tex_advance:D
25862 \fi:
25863 \l__tl_analysis_normal_int #2 \exp_stop_f:
25864 }
25865 \cs_new_protected:Npn \__tl_analysis_b:n #1
25866 {
25867 \__kernel_tl_gset:Nx \g__tl_analysis_result_tl
25868 {
25869 \__tl_analysis_b_loop:w 0 \__tl_sep: #1
25870 \prg_break_point:
25871 }
25872 }
25873 \cs_new:Npn \__tl_analysis_b_loop:w #1 \__tl_sep:
25874 {
25875 \exp_after:wN \__tl_analysis_b_normals:ww
25876 \int_value:w \tex_skip:D #1 \__tl_sep: #1 \__tl_sep:
25877 }
25878 \cs_new:Npn \__tl_analysis_b_normals:ww #1 \__tl_sep:
25879 {
25880 \if_int_compare:w #1 = \c_zero_int
25881 \__tl_analysis_b_special:w
25882 \fi:
25883 \__tl_analysis_b_normal:wwN #1 \__tl_sep:
25884 }
25885 \cs_new:Npn \__tl_analysis_b_normal:wwN #1 \__tl_sep: #2 \__tl_sep: #3
25886 {
25887 \exp_not:n { \exp_not:n { #3 } } \s__tl
25888 \if_charcode:w
25889 \scan_stop:
25890 \exp_after:wN \use_none:n \token_to_str:N #3 \prg_do_nothing:
25891 \scan_stop:
25892 \exp_after:wN \__tl_analysis_b_char:Nn
25893 \exp_after:wN \__tl_analysis_b_char_aux:nww
25894 \else:
25895 \exp_after:wN \__tl_analysis_b_cs:Nww
25896 \fi:
25897 #3 #1 \__tl_sep: #2 \__tl_sep:
25898 }
25899 \cs_new:Npe \__tl_analysis_b_char:Nn #1#2
25900 {
25901 \exp_not:N \if_meaning:w #2 \exp_not:N \tex_undefined:D
25902 \token_to_str:N D \exp_not:N \else:
25903 \exp_not:N \if_catcode:w #2 \c_catcode_other_token
25904 \token_to_str:N C \exp_not:N \else:
25905 \exp_not:N \if_catcode:w #2 \c_catcode_letter_token
25906 \token_to_str:N B \exp_not:N \else:
25907 \exp_not:N \if_catcode:w #2 \c_math_toggle_token 3
25908 \exp_not:N \else:
25909 \exp_not:N \if_catcode:w #2 \c_alignment_token 4
25910 \exp_not:N \else:
25911 \exp_not:N \if_catcode:w #2 \c_math_superscript_token 7
25912 \exp_not:N \else:
25913 \exp_not:N \if_catcode:w #2 \c_math_subscript_token 8
25914 \exp_not:N \else:
25915 \exp_not:N \if_catcode:w #2 \c_space_token
25916 \token_to_str:N A \exp_not:N \else:
25917 6
25918 \exp_not:n { \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: }
25919 #1 {#2}
25920 }
25921 \cs_new:Npn \__tl_analysis_b_char_aux:nww #1
25922 {
25923 \int_value:w `#1 \s__tl
25924 \exp_after:wN \__tl_analysis_b_normals:ww
25925 \int_value:w \int_eval:w - 1 +
25926 }
25927 \cs_new:Npn \__tl_analysis_b_cs:Nww #1
25928 {
25929 0 -1 \s__tl
25930 \__tl_analysis_cs_space_count:NN \__tl_analysis_b_cs_test:ww #1
25931 }
25932 \cs_new:Npn \__tl_analysis_b_cs_test:ww
25933 #1 \__tl_sep: #2 \__tl_sep: #3 \__tl_sep: #4 \__tl_sep:
25934 {
25935 \exp_after:wN \__tl_analysis_b_normals:ww
25936 \int_value:w \int_eval:w
25937 \if_int_compare:w #1 = \c_zero_int
25938 #3
25939 \else:
25940 \tex_skip:D \int_eval:n { #4 + #1 } \exp_stop_f:
25941 \fi:
25942 - #2
25943 \exp_after:wN \__tl_sep:
25944 \int_value:w \int_eval:n { #4 + #1 } \__tl_sep:
25945 }
25946 \group_begin:
25947 \char_set_catcode_other:N A
25948 \cs_new:Npn \__tl_analysis_b_special:w
25949 \fi: \__tl_analysis_b_normal:wwN 0 \__tl_sep: #1 \__tl_sep:
25950 {
25951 \fi:
25952 \if_int_compare:w #1 = \l__tl_analysis_index_int
25953 \exp_after:wN \prg_break:
25954 \fi:
25955 \tex_the:D \tex_toks:D #1 \s__tl
25956 \if_case:w \tex_gluestretch:D \tex_skip:D #1 \exp_stop_f:
25957 \token_to_str:N A
25958 \or: 1
25959 \or: 1
25960 \else: 2
25961 \fi:
25962 \if_int_odd:w \tex_gluestretch:D \tex_skip:D #1 \exp_stop_f:
25963 \exp_after:wN \__tl_analysis_b_special_char:wN \int_value:w
25964 \else:
25965 \exp_after:wN \__tl_analysis_b_special_space:w \int_value:w
25966 \fi:
25967 \int_eval:n { 1 + #1 } \exp_after:wN \__tl_sep:
25968 \token_to_str:N
25969 }
25970 \group_end:
25971 \cs_new:Npn \__tl_analysis_b_special_char:wN #1 \__tl_sep: #2
25972 {
25973 \int_value:w `#2 \s__tl
25974 \__tl_analysis_b_loop:w #1 \__tl_sep:
25975 }
25976 \use:e
25977 {
25978 \cs_new:Npn \exp_not:N \__tl_analysis_b_special_space:w
25979 #1 \exp_not:N \__tl_sep: \c_space_tl
25980 }
25981 {
25982 32 \s__tl
25983 \__tl_analysis_b_loop:w #1 \__tl_sep:
25984 }
25985 \cs_new_protected:Npn \tl_analysis_map_inline:Nn #1
25986 { \exp_args:No \tl_analysis_map_inline:nn #1 }
25987 \cs_new_protected:Npn \tl_analysis_map_inline:nn #1
25988 {
25989 \__tl_analysis:n {#1}
25990 \int_gincr:N \g__kernel_prg_map_int
25991 \exp_args:Nc \__tl_analysis_map:Nn
25992 { __tl_analysis_map_inline_ \int_use:N \g__kernel_prg_map_int :wNw }
25993 }
25994 \cs_new_protected:Npn \__tl_analysis_map:Nn #1#2
25995 {
25996 \cs_gset_protected:Npn #1 ##1##2##3 {#2}
25997 \exp_after:wN \__tl_analysis_map:NwNw \exp_after:wN #1
25998 \g__tl_analysis_result_tl
25999 \s__tl { ? \tl_map_break: } \s__tl
26000 \prg_break_point:Nn \tl_map_break:
26001 { \int_gdecr:N \g__kernel_prg_map_int }
26002 }
26003 \cs_new_protected:Npn \__tl_analysis_map:NwNw #1 #2 \s__tl #3 #4 \s__tl
26004 {
26005 \use_none:n #3
26006 #1 {#2} {#4} {#3}
26007 \__tl_analysis_map:NwNw #1
26008 }
26009 \cs_new_protected:Npn \tl_analysis_show:N
26010 { \__tl_analysis_show:NNnnN \msg_show:nneeee \tl_show:N {} {} }
26011 \cs_new_protected:Npn \tl_analysis_log:N
26012 {
26013 \__tl_analysis_show:NNnnN \msg_log:nneeee \tl_log:N
26014 { \iow_newline: >~ . } { . }
26015 }
26016 \cs_new_protected:Npn \__tl_analysis_show:NNnnN #1#2#3#4#5
26017 {
26018 \tl_if_exist:NTF #5
26019 {
26020 \exp_args:No \__tl_analysis:n {#5}
26021 #1 { tl } { show-analysis }
26022 { \token_to_str:N #5 } { \__tl_analysis_show: } {#3} {#4}
26023 }
26024 { #2 #3 }
26025 }
26026 \cs_new_protected:Npn \tl_analysis_show:n
26027 { \__tl_analysis_show:Nnnn \msg_show:nneeee {} {} }
26028 \cs_new_protected:Npn \tl_analysis_log:n
26029 { \__tl_analysis_show:Nnnn \msg_log:nneeee { \iow_newline: >~ . } { . } }
26030 \cs_new_protected:Npn \__tl_analysis_show:Nnnn #1#2#3#4
26031 {
26032 \__tl_analysis:n {#4}
26033 #1 { tl } { show-analysis } { } { \__tl_analysis_show: } {#2} {#3}
26034 }
26035 \cs_new:Npn \__tl_analysis_show:
26036 {
26037 \exp_after:wN \__tl_analysis_show_loop:wNw \g__tl_analysis_result_tl
26038 \s__tl { ? \prg_break: } \s__tl
26039 \prg_break_point:
26040 }
26041 \cs_new:Npn \__tl_analysis_show_loop:wNw #1 \s__tl #2 #3 \s__tl
26042 {
26043 \use_none:n #2
26044 \iow_newline: > \use:nn { ~ } { ~ }
26045 \if_int_compare:w "#2 = \c_zero_int
26046 \exp_after:wN \__tl_analysis_show_cs:n
26047 \else:
26048 \if_int_compare:w "#2 = 13 \exp_stop_f:
26049 \exp_after:wN \exp_after:wN
26050 \exp_after:wN \__tl_analysis_show_active:n
26051 \else:
26052 \exp_after:wN \exp_after:wN
26053 \exp_after:wN \__tl_analysis_show_normal:n
26054 \fi:
26055 \fi:
26056 {#1}
26057 \__tl_analysis_show_loop:wNw
26058 }
26059 \cs_new:Npn \__tl_analysis_show_normal:n #1
26060 {
26061 \exp_after:wN \token_to_str:N #1 ~
26062 ( \exp_after:wN \token_to_meaning:N #1 )
26063 }
26064 \cs_new:Npn \__tl_analysis_show_value:N #1
26065 {
26066 \token_if_expandable:NF #1
26067 {
26068 \token_if_chardef:NTF #1 \prg_break: { }
26069 \token_if_mathchardef:NTF #1 \prg_break: { }
26070 \token_if_dim_register:NTF #1 \prg_break: { }
26071 \token_if_int_register:NTF #1 \prg_break: { }
26072 \token_if_skip_register:NTF #1 \prg_break: { }
26073 \token_if_toks_register:NTF #1 \prg_break: { }
26074 \use_none:nnn
26075 \prg_break_point:
26076 \use:n { \exp_after:wN = \tex_the:D #1 }
26077 }
26078 }
26079 \cs_new:Npn \__tl_analysis_show_cs:n #1
26080 { \exp_args:No \__tl_analysis_show_long:nn {#1} { control~sequence= } }
26081 \cs_new:Npn \__tl_analysis_show_active:n #1
26082 { \exp_args:No \__tl_analysis_show_long:nn {#1} { active~character= } }
26083 \cs_new:Npn \__tl_analysis_show_long:nn #1
26084 {
26085 \__tl_analysis_show_long_aux:oofn
26086 { \token_to_str:N #1 }
26087 { \token_to_meaning:N #1 }
26088 { \__tl_analysis_show_value:N #1 }
26089 }
26090 \cs_new:Npn \__tl_analysis_show_long_aux:nnnn #1#2#3#4
26091 {
26092 \int_compare:nNnTF
26093 { \str_count:n { #1 ~ ( #4 #2 #3 ) } }
26094 > { \l_iow_line_count_int - 3 }
26095 {
26096 \str_range:nnn { #1 ~ ( #4 #2 #3 ) } { 1 }
26097 {
26098 \l_iow_line_count_int - 3
26099 - \str_count:N \c__tl_analysis_show_etc_str
26100 }
26101 \c__tl_analysis_show_etc_str
26102 }
26103 { #1 ~ ( #4 #2 #3 ) }
26104 }
26105 \cs_generate_variant:Nn \__tl_analysis_show_long_aux:nnnn { oof }
26106 \cs_new:Npn \peek_analysis_map_break:
26107 { \prg_map_break:Nn \peek_analysis_map_break: { } }
26108 \cs_new:Npn \peek_analysis_map_break:n
26109 { \prg_map_break:Nn \peek_analysis_map_break: }
26110 \int_new:N \l__tl_peek_charcode_int
26111 \cs_new:Npn \__tl_analysis_char_arg:Nw
26112 {
26113 \if_meaning:w \l__tl_analysis_token \c_space_token
26114 \exp_after:wN \__tl_analysis_char_arg_aux:Nw
26115 \fi:
26116 }
26117 \cs_new:Npn \__tl_analysis_char_arg_aux:Nw #1 ~ { #1 { ~ } }
26118 \cs_new_protected:Npn \peek_analysis_map_inline:n #1
26119 {
26120 \group_align_safe_begin:
26121 \int_gincr:N \g__kernel_prg_map_int
26122 \cs_set_protected:cpn
26123 { __tl_analysis_map_ \int_use:N \g__kernel_prg_map_int :nnN }
26124 ##1##2##3
26125 {
26126 \group_end:
26127 #1
26128 \__tl_peek_analysis_loop:NNn
26129 \prg_break_point:Nn \peek_analysis_map_break:
26130 {
26131 \int_gdecr:N \g__kernel_prg_map_int
26132 \group_align_safe_end:
26133 }
26134 }
26135 \__tl_peek_analysis_loop:NNn ? ? ?
26136 }
26137 \cs_new_protected:Npn \__tl_peek_analysis_loop:NNn #1#2#3
26138 {
26139 \group_begin:
26140 \tl_set:Ne \l__tl_peek_code_tl
26141 {
26142 \exp_not:c
26143 { __tl_analysis_map_ \int_use:N \g__kernel_prg_map_int :nnN }
26144 }
26145 \int_set:Nn \tex_escapechar:D { `\\ }
26146 \peek_after:Nw \__tl_peek_analysis_test:
26147 }
26148 \cs_new_protected:Npn \__tl_peek_analysis_test:
26149 {
26150 \if_case:w
26151 \if_catcode:w \exp_not:N \l_peek_token { \c_max_int \fi:
26152 \if_catcode:w \exp_not:N \l_peek_token } \c_max_int \fi:
26153 \if_meaning:w \l_peek_token \c_space_token \c_max_int \fi:
26154 \exp_after:wN \if_meaning:w \exp_not:N \l_peek_token \l_peek_token
26155 \c_one_int
26156 \fi:
26157 \c_zero_int
26158 \exp_after:wN \exp_after:wN
26159 \exp_after:wN \__tl_peek_analysis_exp:N
26160 \exp_after:wN \exp_not:N
26161 \or:
26162 \exp_after:wN \__tl_peek_analysis_nonexp:N
26163 \else:
26164 \exp_after:wN \__tl_peek_analysis_special:
26165 \fi:
26166 }
26167 \cs_new_protected:Npn \__tl_peek_analysis_exp:N #1
26168 {
26169 \cs_set_nopar:Npe \l__tl_peek_code_tl
26170 {
26171 \tex_let:D \exp_not:N #1 \l__tl_peek_code_tl
26172 \l__tl_peek_code_tl
26173 {
26174 \exp_not:n { \__kernel_exp_not:w \exp_after:wN }
26175 { \exp_not:N \exp_not:N \exp_not:N #1 }
26176 }
26177 \exp_after:wN \__tl_peek_analysis_exp_aux:Nw
26178 \token_to_str:N #1 { } \s__tl
26179 }
26180 \l__tl_peek_code_tl
26181 }
26182 \cs_new:Npe \__tl_peek_analysis_exp_aux:Nw #1#2 \s__tl
26183 {
26184 \exp_not:N \if_meaning:w \scan_stop: #2 \scan_stop:
26185 { \exp_not:N \int_value:w `#1 ~ } \token_to_str:N D
26186 \exp_not:N \else:
26187 { -1 } 0
26188 \exp_not:N \fi:
26189 }
26190 \cs_new_protected:Npn \__tl_peek_analysis_nonexp:N #1
26191 {
26192 \if_charcode:w
26193 \scan_stop:
26194 \exp_after:wN \use_none:n \token_to_str:N #1 \prg_do_nothing:
26195 \scan_stop:
26196 \exp_after:wN \__tl_peek_analysis_char:N
26197 \else:
26198 \exp_after:wN \__tl_peek_analysis_cs:N
26199 \fi:
26200 #1
26201 }
26202 \cs_new_protected:Npn \__tl_peek_analysis_cs:N #1
26203 { \l__tl_peek_code_tl { \exp_not:n {#1} } { -1 } 0 }
26204 \group_begin:
26205 \char_set_active_eq:NN \ \scan_stop:
26206 \cs_new_protected:Npe \__tl_peek_analysis_char:N #1
26207 {
26208 \cs_set_eq:NN
26209 \char_generate:nn { 32 } { 13 }
26210 \exp_not:N \tex_undefined:D
26211 \tex_lccode:D `#1 = 32 \exp_stop_f:
26212 \tex_lowercase:D
26213 {
26214 \tl_put_right:Ne \exp_not:N \l__tl_peek_code_tl
26215 { \exp_not:n { \__tl_analysis_b_char:Nn \use_none:n } {#1} }
26216 }
26217 \exp_not:n
26218 {
26219 \exp_after:wN \__tl_peek_analysis_char:w
26220 \int_value:w
26221 }
26222 `#1
26223 \exp_not:n { \exp_after:wN \s__tl \l__tl_peek_code_tl }
26224 #1
26225 }
26226 \group_end:
26227 \cs_new_protected:Npn \__tl_peek_analysis_char:w #1 \s__tl #2#3#4
26228 {
26229 \if_charcode:w 6 #3
26230 \else:
26231 \if_charcode:w D #3
26232 \else:
26233 \exp_args:NNNo
26234 \fi:
26235 \fi:
26236 #2 { \exp_not:n {#4} } {#1} #3
26237 }
26238 \cs_new_protected:Npn \__tl_peek_analysis_special:
26239 {
26240 \tex_let:D \l__tl_analysis_token = ~ \l_peek_token
26241 \int_set:Nn \l__tl_peek_charcode_int
26242 { \__tl_analysis_extract_charcode: }
26243 \if_int_compare:w \l__tl_peek_charcode_int = \tex_escapechar:D
26244 \int_set:Nn \tex_escapechar:D { `\/ }
26245 \fi:
26246 \char_set_active_eq:nN { \l__tl_peek_charcode_int } \scan_stop:
26247 \char_set_active_eq:nN { \tex_escapechar:D } \scan_stop:
26248 \cs_set_eq:cN { } \scan_stop:
26249 \tex_futurelet:D \l__tl_analysis_token
26250 \__tl_peek_analysis_retest:
26251 }
26252 \cs_new_protected:Npn \__tl_peek_analysis_retest:
26253 {
26254 \if_meaning:w \l__tl_analysis_token \scan_stop:
26255 \exp_after:wN \__tl_peek_analysis_nonexp:N
26256 \else:
26257 \exp_after:wN \__tl_peek_analysis_str:
26258 \fi:
26259 }
26260 \cs_new_protected:Npn \__tl_peek_analysis_str:
26261 {
26262 \exp_after:wN \tex_futurelet:D
26263 \exp_after:wN \l__tl_analysis_token
26264 \exp_after:wN \__tl_peek_analysis_str:w
26265 \token_to_str:N
26266 }
26267 \cs_new_protected:Npn \__tl_peek_analysis_str:w
26268 { \__tl_analysis_char_arg:Nw \__tl_peek_analysis_str:n }
26269 \cs_new_protected:Npn \__tl_peek_analysis_str:n #1
26270 {
26271 \int_case:nnF { `#1 }
26272 {
26273 { \l__tl_peek_charcode_int }
26274 { \__tl_peek_analysis_explicit:n {#1} }
26275 { \tex_escapechar:D } { \__tl_peek_analysis_escape: }
26276 }
26277 { \__tl_peek_analysis_active_str:n {#1} }
26278 }
26279 \cs_new_protected:Npn \__tl_peek_analysis_active_str:n #1
26280 {
26281 \tl_put_right:Ne \l__tl_peek_code_tl
26282 {
26283 { \char_generate:nn { `#1 } { 13 } }
26284 { \int_value:w `#1 }
26285 \token_to_str:N D
26286 }
26287 \l__tl_peek_code_tl
26288 }
26289 \cs_new_protected:Npn \__tl_peek_analysis_explicit:n #1
26290 {
26291 \tl_put_right:Ne \l__tl_peek_code_tl
26292 {
26293 \if_meaning:w \l_peek_token \c_space_token
26294 { ~ } { 32 } \token_to_str:N A
26295 \else:
26296 \if_catcode:w \l_peek_token \c_group_begin_token
26297 {
26298 \exp_not:N \exp_after:wN
26299 \char_generate:nn { `#1 } { 1 }
26300 \exp_not:N \if_false:
26301 \if_false: { \fi: }
26302 \exp_not:N \fi:
26303 }
26304 { \int_value:w `#1 }
26305 1
26306 \else:
26307 {
26308 \exp_not:N \if_false:
26309 { \if_false: } \fi:
26310 \exp_not:N \fi:
26311 \char_generate:nn { `#1 } { 2 }
26312 }
26313 { \int_value:w `#1 }
26314 2
26315 \fi:
26316 \fi:
26317 }
26318 \l__tl_peek_code_tl
26319 }
26320 \cs_new_protected:Npn \__tl_peek_analysis_escape:
26321 {
26322 \tl_clear:N \l__tl_tmpa_tl
26323 \tex_futurelet:D \l__tl_analysis_token
26324 \__tl_peek_analysis_collect:w
26325 }
26326 \cs_new_protected:Npn \__tl_peek_analysis_collect:w
26327 { \__tl_analysis_char_arg:Nw \__tl_peek_analysis_collect:n }
26328 \cs_new_protected:Npn \__tl_peek_analysis_collect:n #1
26329 {
26330 \tl_put_right:Nn \l__tl_tmpa_tl {#1}
26331 \__tl_peek_analysis_collect_loop:
26332 }
26333 \cs_new_protected:Npn \__tl_peek_analysis_collect_loop:
26334 {
26335 \exp_after:wN \if_meaning:w
26336 \cs:w
26337 \if_cs_exist:w \l__tl_tmpa_tl \cs_end:
26338 \l__tl_tmpa_tl
26339 \else:
26340 c_one % anything short
26341 \fi:
26342 \cs_end:
26343 \l_peek_token
26344 \__tl_peek_analysis_collect_end:NNNN
26345 \fi:
26346 \tex_futurelet:D \l__tl_analysis_token
26347 \__tl_peek_analysis_collect:w
26348 }
26349 \cs_new_protected:Npn \__tl_peek_analysis_collect_end:NNNN #1#2#3#4
26350 {
26351 #1
26352 \tl_put_right:Ne \l__tl_peek_code_tl
26353 {
26354 { \exp_not:N \exp_not:n { \exp_not:c { \l__tl_tmpa_tl } } }
26355 { -1 }
26356 0
26357 }
26358 \l__tl_peek_code_tl
26359 }
26360 \tl_const:Ne \c__tl_analysis_show_etc_str % (
26361 { \token_to_str:N \ETC.) }
26362 \msg_new:nnn { tl } { show-analysis }
26363 {
26364 The~token~list~ \tl_if_empty:nF {#1} { #1 ~ }
26365 \tl_if_empty:nTF {#2}
26366 { is~empty #3 }
26367 { contains~the~tokens: #2 #4 }
26368 }
26369 %% File: l3benchmark.dtx
26370 \fp_new:N \g_benchmark_duration_target_fp
26371 \fp_gset:Nn \g_benchmark_duration_target_fp { 1 }
26372 \int_new:N \g__benchmark_nesting_int
26373 \cs_new_protected:Npn \__benchmark_raw:nN #1
26374 {
26375 \int_gincr:N \g__benchmark_nesting_int
26376 \exp_args:Nc \__benchmark_raw_aux:N
26377 { g__benchmark_ \int_use:N \g__benchmark_nesting_int _int }
26378 \__benchmark_raw_aux:
26379 #1
26380 \__benchmark_raw_end:N
26381 }
26382 \cs_new_protected:Npn \__benchmark_raw_aux:N #1
26383 {
26384 \int_gzero_new:N #1
26385 \cs_gset_protected:Npn \__benchmark_raw_aux: { \int_gset:Nn #1 { \sys_timer: } }
26386 }
26387 \cs_new_protected:Npn \__benchmark_raw_end:N #1
26388 {
26389 \int_gset:Nn #1
26390 {
26391 \sys_timer: -
26392 \int_use:c { g__benchmark_ \int_use:N \g__benchmark_nesting_int _int }
26393 }
26394 \int_gdecr:N \g__benchmark_nesting_int
26395 }
26396 \cs_new_eq:NN \__benchmark_tmp:w ?
26397 \cs_new_protected:Npn \__benchmark_raw_replicate:nnN #1
26398 {
26399 \int_compare:nNnTF {#1} > { 500000 }
26400 { \__benchmark_raw_replicate_large:nnN {#1} }
26401 { \__benchmark_raw_replicate_small:nnN {#1} }
26402 }
26403 \cs_new_protected:Npn \__benchmark_raw_replicate_large:nnN #1#2
26404 {
26405 \cs_set:Npe \__benchmark_tmp:w ##1 { \prg_replicate:nn { 5000 } {##1} }
26406 \exp_args:Nno \__benchmark_raw_replicate:nnN { #1 / 5000 }
26407 { \__benchmark_tmp:w {#2} }
26408 }
26409 \cs_new_protected:Npn \__benchmark_raw_replicate_small:nnN #1#2
26410 {
26411 \cs_set:Npe \__benchmark_tmp:w ##1##2 { \prg_replicate:nn {#1} {##1} }
26412 \__benchmark_raw:nN { \__benchmark_tmp:w {#2} { } } \g__benchmark_time_int
26413 \exp_args:No \__benchmark_raw_replicate_aux:nnN
26414 { \int_use:N \g__benchmark_time_int } {#2}
26415 }
26416 \cs_new_protected:Npn \__benchmark_raw_replicate_aux:nnN #1#2#3
26417 {
26418 \__benchmark_raw:nN { \__benchmark_tmp:w { } {#2} } \g__benchmark_time_int
26419 \int_gset:Nn #3 { #1 - \g__benchmark_time_int }
26420 \cs_set_eq:NN \__benchmark_tmp:w \prg_do_nothing:
26421 }
26422 \fp_new:N \g_benchmark_time_fp
26423 \fp_new:N \g_benchmark_ops_fp
26424 \int_new:N \g__benchmark_duration_int
26425 \int_new:N \g__benchmark_time_int
26426 \int_new:N \g__benchmark_time_a_int
26427 \int_new:N \g__benchmark_time_b_int
26428 \int_new:N \g__benchmark_time_c_int
26429 \int_new:N \g__benchmark_time_d_int
26430 \int_new:N \g__benchmark_repeat_int
26431 \tl_new:N \g__benchmark_code_tl
26432 \cs_new_protected:Npn \benchmark_once:n #1
26433 {
26434 \benchmark_once_silent:n {#1}
26435 \__benchmark_display:
26436 }
26437 \cs_new_protected:Npn \benchmark_once_silent:n #1
26438 {
26439 \__benchmark_measure_op:
26440 \__benchmark_raw:nN {#1} \g__benchmark_time_int
26441 \fp_gset:Nn \g_benchmark_time_fp { \g__benchmark_time_int / 65536 }
26442 \fp_gset:Nn \g_benchmark_ops_fp { \g_benchmark_time_fp / \g__benchmark_one_op_fp }
26443 }
26444 \cs_new_protected:Npn \benchmark:n #1
26445 {
26446 \benchmark_silent:n {#1}
26447 \__benchmark_display:
26448 }
26449 \cs_new_protected:Npn \benchmark_silent:n #1
26450 {
26451 \__benchmark_measure_op:
26452 \tl_gset:Nn \g__benchmark_code_tl {#1}
26453 \__benchmark_aux:
26454 \fp_gset:Nn \g_benchmark_ops_fp { \g_benchmark_time_fp / \g__benchmark_one_op_fp }
26455 }
26456 \cs_new_protected:Npn \__benchmark_aux:
26457 {
26458 \int_gset:Nn \g__benchmark_repeat_int { 1 }
26459 \__benchmark_raw:nN { \g__benchmark_code_tl } \g__benchmark_time_int
26460 \int_compare:nNnF \g__benchmark_time_int < { \g__benchmark_duration_int / 2 }
26461 { \prg_break: }
26462 \bool_until_do:nn
26463 {
26464 \int_compare_p:nNn \g__benchmark_time_int > { \g__benchmark_duration_int / 32 }
26465 || \int_compare_p:nNn \g__benchmark_repeat_int > { \c_max_int / 4 }
26466 }
26467 {
26468 \int_gset:Nn \g__benchmark_repeat_int { 4 * \g__benchmark_repeat_int }
26469 \__benchmark_run:N \g__benchmark_time_int
26470 }
26471 \int_gset:Nn \g__benchmark_repeat_int
26472 {
26473 \fp_to_int:n
26474 {
26475 max ( 1 , min ( \c_max_int ,
26476 \g__benchmark_duration_int * \g__benchmark_repeat_int /
26477 \int_eval:n { 4 * \g__benchmark_time_int } ) )
26478 }
26479 }
26480 \int_compare:nNnTF \g__benchmark_repeat_int = 1
26481 { \int_gset_eq:NN \g__benchmark_time_a_int \g__benchmark_time_int }
26482 { \__benchmark_run:N \g__benchmark_time_a_int }
26483 \__benchmark_run:N \g__benchmark_time_b_int
26484 \__benchmark_run:N \g__benchmark_time_c_int
26485 \__benchmark_run:N \g__benchmark_time_d_int
26486 \int_gset:Nn \g__benchmark_time_int
26487 {
26488 \int_min:nn
26489 { \int_min:nn \g__benchmark_time_a_int \g__benchmark_time_b_int }
26490 { \int_min:nn \g__benchmark_time_c_int \g__benchmark_time_d_int }
26491 }
26492 \prg_break_point:
26493 \int_compare:nNnT \g__benchmark_time_int < 3 { \int_gzero:N \g__benchmark_time_int }
26494 \fp_gset:Nn \g_benchmark_time_fp
26495 { \g__benchmark_time_int / \g__benchmark_repeat_int / 65536 }
26496 }
26497 \cs_new_protected:Npn \__benchmark_run:N
26498 { \exp_args:NNo \__benchmark_raw_replicate:nnN \g__benchmark_repeat_int { \g__benchmark_code_tl } }
26499 \fp_new:N \g__benchmark_one_op_fp
26500 \cs_new_protected:Npn \__benchmark_measure_op:
26501 {
26502 \int_gset:Nn \g__benchmark_duration_int
26503 { \fp_to_int:n { 65536 * \g_benchmark_duration_target_fp } / 4 }
26504 \tl_gset:Nn \g__benchmark_code_tl
26505 { \int_gadd:Nn \g__benchmark_duration_int { 0 } }
26506 \__benchmark_aux:
26507 \fp_gset:Nn \g__benchmark_one_op_fp { max(\g_benchmark_time_fp, 1e-8) }
26508 \int_gset:Nn \g__benchmark_duration_int
26509 { \fp_to_int:n { 65536 * \g_benchmark_duration_target_fp } }
26510 }
26511 \cs_new:Npn \__benchmark_fp_to_tl:N #1
26512 {
26513 \fp_compare:nTF { abs(#1) < 1000 }
26514 { \fp_to_tl:n { round(#1, 2 - logb(#1)) } }
26515 {
26516 \exp_args:Nf \__benchmark_fp_to_tl_aux:nN
26517 { \fp_to_int:n { logb(#1) } } #1
26518 }
26519 }
26520 \cs_new:Npn \__benchmark_fp_to_tl_aux:nN #1#2
26521 { \fp_to_tl:n { round(#2 * 1e-#1, 2) } e#1 }
26522 \cs_new_protected:Npn \__benchmark_display:
26523 {
26524 \iow_term:e
26525 {
26526 \__benchmark_fp_to_tl:N \g_benchmark_time_fp \c_space_tl seconds \c_space_tl
26527 ( \__benchmark_fp_to_tl:N \g_benchmark_ops_fp \c_space_tl ops)
26528 }
26529 }
26530 \int_new:N \g__benchmark_tictoc_int
26531 \seq_new:N \g__benchmark_tictoc_seq
26532 \tl_new:N \l__benchmark_tictoc_pop_tl
26533 \cs_new:Npn \__benchmark_tictoc_prefix:
26534 {
26535 (l3benchmark) \c_space_tl
26536 + \prg_replicate:nn { \g__benchmark_tictoc_int } { -+ } \c_space_tl
26537 }
26538 \cs_new_protected:Npn \benchmark_tic:
26539 {
26540 \iow_term:e { \__benchmark_tictoc_prefix: TIC }
26541 \exp_args:NNf \seq_gput_right:Nn \g__benchmark_tictoc_seq { \sys_timer: }
26542 \int_gincr:N \g__benchmark_tictoc_int
26543 }
26544 \cs_new:Npn \benchmark_toc:
26545 {
26546 \seq_gpop_right:NNTF \g__benchmark_tictoc_seq \l__benchmark_tictoc_pop_tl
26547 { \__benchmark_toc: }
26548 { \msg_error:nn { benchmark } { toc-first } }
26549 }
26550 \cs_new_protected:Npn \__benchmark_toc:
26551 {
26552 \int_gdecr:N \g__benchmark_tictoc_int
26553 \fp_gset:Nn \g_benchmark_time_fp
26554 { ( \sys_timer: - \l__benchmark_tictoc_pop_tl ) / 65536 }
26555 \iow_term:e
26556 {
26557 \__benchmark_tictoc_prefix:
26558 TOC: \c_space_tl
26559 \__benchmark_fp_to_tl:N \g_benchmark_time_fp \c_space_tl s
26560 }
26561 }
26562 \msg_new:nnn { benchmark } { toc-first }
26563 {
26564 \token_to_str:N \benchmark_toc: \c_space_tl without~
26565 \token_to_str:N \benchmark_tic: \c_space_tl !
26566 }
26567 %% File: l3regex.dtx
26568 \cs_new_eq:NN \__regex_int_eval:w \tex_numexpr:D
26569 \cs_new_eq:NN \__regex_sep: \__kernel_int_sep:
26570 \cs_new_protected:Npn \__regex_standard_escapechar:
26571 { \int_set:Nn \tex_escapechar:D { `\\ } }
26572 \cs_new:Npn \__regex_toks_use:w { \tex_the:D \tex_toks:D }
26573 \cs_new_protected:Npn \__regex_toks_clear:N #1
26574 { \tex_toks:D #1 = { } }
26575 \cs_new_eq:NN \__regex_toks_set:Nn \tex_toks:D
26576 \cs_new_protected:Npn \__regex_toks_set:No #1
26577 { \tex_toks:D #1 = \exp_after:wN }
26578 \cs_new_protected:Npn \__regex_toks_memcpy:NNn #1#2#3
26579 {
26580 \prg_replicate:nn {#3}
26581 {
26582 \tex_toks:D #1 = \tex_toks:D #2
26583 \int_incr:N #1
26584 \int_incr:N #2
26585 }
26586 }
26587 \cs_if_exist:NTF \tex_etokspre:D
26588 { \cs_new_eq:NN \__regex_toks_put_left:Ne \tex_etokspre:D }
26589 {
26590 \cs_new_protected:Npn \__regex_toks_put_left:Ne #1#2
26591 { \tex_toks:D #1 = \tex_expanded:D {{ #2 \tex_the:D \tex_toks:D #1 }} }
26592 }
26593 \cs_if_exist:NTF \tex_etoksapp:D
26594 { \cs_new_eq:NN \__regex_toks_put_right:Ne \tex_etoksapp:D }
26595 {
26596 \cs_new_protected:Npn \__regex_toks_put_right:Ne #1#2
26597 { \tex_toks:D #1 = \tex_expanded:D {{ \tex_the:D \tex_toks:D #1 #2 }} }
26598 }
26599 \cs_if_exist:NTF \tex_toksapp:D
26600 { \cs_new_eq:NN \__regex_toks_put_right:Nn \tex_toksapp:D }
26601 {
26602 \cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2
26603 { \tex_toks:D #1 = \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } }
26604 }
26605 \cs_new:Npn \__regex_curr_cs_to_str:
26606 {
26607 \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N
26608 \l__regex_curr_token_tl
26609 }
26610 \cs_new:Npn \__regex_intarray_item:NnF #1#2
26611 { \exp_args:No \__regex_intarray_item_aux:nNF { \tex_the:D \__regex_int_eval:w #2 } #1 }
26612 \cs_new:Npn \__regex_intarray_item_aux:nNF #1#2
26613 {
26614 \if_int_compare:w #1 > \c_zero_int
26615 \exp_after:wN \use_ii:nnn
26616 \fi:
26617 \use_ii:nn { \__kernel_intarray_item:Nn #2 {#1} }
26618 }
26619 \cs_new:Npn \__regex_maplike_break:
26620 { \prg_map_break:Nn \__regex_maplike_break: { } }
26621 \cs_new:Npn \__regex_tl_odd_items:n #1 { \__regex_tl_even_items:n { ? #1 } }
26622 \cs_new:Npn \__regex_tl_even_items:n #1
26623 {
26624 \__regex_tl_even_items_loop:nn #1 \q__regex_nil \q__regex_nil
26625 \prg_break_point:
26626 }
26627 \cs_new:Npn \__regex_tl_even_items_loop:nn #1#2
26628 {
26629 \__regex_use_none_delimit_by_q_nil:w #2 \prg_break: \q__regex_nil
26630 { \exp_not:n {#2} }
26631 \__regex_tl_even_items_loop:nn
26632 }
26633 \cs_new:Npn \__regex_tmp:w { }
26634 \tl_new:N \l__regex_tmpa_tl
26635 \tl_new:N \l__regex_tmpb_tl
26636 \int_new:N \l__regex_tmpa_int
26637 \int_new:N \l__regex_tmpb_int
26638 \int_new:N \l__regex_tmpc_int
26639 \bool_new:N \l__regex_tmp_bool
26640 \seq_new:N \l__regex_tmp_seq
26641 \tl_new:N \g__regex_tmp_tl
26642 \tl_new:N \l__regex_build_tl
26643 \tl_const:Nn \c__regex_no_match_regex
26644 {
26645 \__regex_branch:n
26646 { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool }
26647 }
26648 \int_new:N \l__regex_balance_int
26649 \int_const:Nn \c__regex_ascii_min_int { 0 }
26650 \int_const:Nn \c__regex_ascii_max_control_int { 31 }
26651 \int_const:Nn \c__regex_ascii_max_int { 127 }
26652 \int_const:Nn \c__regex_ascii_lower_int { `a - `A }
26653 \quark_new:N \q__regex_recursion_stop
26654 \quark_new:N \q__regex_nil
26655 \cs_new:Npn \__regex_use_none_delimit_by_q_recursion_stop:w
26656 #1 \q__regex_recursion_stop { }
26657 \cs_new:Npn \__regex_use_i_delimit_by_q_recursion_stop:nw
26658 #1 #2 \q__regex_recursion_stop {#1}
26659 \cs_new:Npn \__regex_use_none_delimit_by_q_nil:w #1 \q__regex_nil { }
26660 \__kernel_quark_new_conditional:Nn \__regex_quark_if_nil:N { F }
26661 \cs_new_protected:Npn \__regex_break_true:w
26662 #1 \__regex_break_point:TF #2 #3 {#2}
26663 \cs_new_protected:Npn \__regex_break_point:TF #1 #2 { #2 }
26664 \cs_new_protected:Npn \__regex_item_reverse:n #1
26665 {
26666 #1
26667 \__regex_break_point:TF { } \__regex_break_true:w
26668 }
26669 \cs_new_protected:Npn \__regex_item_caseful_equal:n #1
26670 {
26671 \if_int_compare:w #1 = \l__regex_curr_char_int
26672 \exp_after:wN \__regex_break_true:w
26673 \fi:
26674 }
26675 \cs_new_protected:Npn \__regex_item_caseful_range:nn #1 #2
26676 {
26677 \reverse_if:N \if_int_compare:w #1 > \l__regex_curr_char_int
26678 \reverse_if:N \if_int_compare:w #2 < \l__regex_curr_char_int
26679 \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w
26680 \fi:
26681 \fi:
26682 }
26683 \cs_new_protected:Npn \__regex_item_caseless_equal:n #1
26684 {
26685 \if_int_compare:w #1 = \l__regex_curr_char_int
26686 \exp_after:wN \__regex_break_true:w
26687 \fi:
26688 \__regex_maybe_compute_ccc:
26689 \if_int_compare:w #1 = \l__regex_case_changed_char_int
26690 \exp_after:wN \__regex_break_true:w
26691 \fi:
26692 }
26693 \cs_new_protected:Npn \__regex_item_caseless_range:nn #1 #2
26694 {
26695 \reverse_if:N \if_int_compare:w #1 > \l__regex_curr_char_int
26696 \reverse_if:N \if_int_compare:w #2 < \l__regex_curr_char_int
26697 \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w
26698 \fi:
26699 \fi:
26700 \__regex_maybe_compute_ccc:
26701 \reverse_if:N \if_int_compare:w #1 > \l__regex_case_changed_char_int
26702 \reverse_if:N \if_int_compare:w #2 < \l__regex_case_changed_char_int
26703 \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w
26704 \fi:
26705 \fi:
26706 }
26707 \cs_new_protected:Npn \__regex_compute_case_changed_char:
26708 {
26709 \int_set_eq:NN \l__regex_case_changed_char_int \l__regex_curr_char_int
26710 \if_int_compare:w \l__regex_curr_char_int > `Z \exp_stop_f:
26711 \if_int_compare:w \l__regex_curr_char_int > `z \exp_stop_f: \else:
26712 \if_int_compare:w \l__regex_curr_char_int < `a \exp_stop_f: \else:
26713 \int_sub:Nn \l__regex_case_changed_char_int \c__regex_ascii_lower_int
26714 \fi:
26715 \fi:
26716 \else:
26717 \if_int_compare:w \l__regex_curr_char_int < `A \exp_stop_f: \else:
26718 \int_add:Nn \l__regex_case_changed_char_int \c__regex_ascii_lower_int
26719 \fi:
26720 \fi:
26721 \cs_set_eq:NN \__regex_maybe_compute_ccc: \prg_do_nothing:
26722 }
26723 \cs_new_eq:NN \__regex_maybe_compute_ccc: \__regex_compute_case_changed_char:
26724 \cs_new_eq:NN \__regex_item_equal:n ?
26725 \cs_new_eq:NN \__regex_item_range:nn ?
26726 \cs_new_protected:Npn \__regex_item_catcode:
26727 {
26728 "
26729 \if_case:w \l__regex_curr_catcode_int
26730 1 \or: 4 \or: 10 \or: 40
26731 \or: 100 \or: \or: 1000 \or: 4000
26732 \or: 10000 \or: \or: 100000 \or: 400000
26733 \or: 1000000 \or: 4000000 \else: 1*0
26734 \fi:
26735 }
26736 \prg_new_protected_conditional:Npnn \__regex_item_catcode:n #1 { T }
26737 {
26738 \if_int_odd:w \__regex_int_eval:w #1 / \__regex_item_catcode: \scan_stop:
26739 \prg_return_true:
26740 \else:
26741 \prg_return_false:
26742 \fi:
26743 }
26744 \cs_new_protected:Npn \__regex_item_catcode_reverse:nT #1#2
26745 { \__regex_item_catcode:nT {#1} { \__regex_item_reverse:n {#2} } }
26746 \cs_new_protected:Npn \__regex_item_exact:nn #1#2
26747 {
26748 \if_int_compare:w #1 = \l__regex_curr_catcode_int
26749 \if_int_compare:w #2 = \l__regex_curr_char_int
26750 \exp_after:wN \exp_after:wN \exp_after:wN \__regex_break_true:w
26751 \fi:
26752 \fi:
26753 }
26754 \cs_new_protected:Npn \__regex_item_exact_cs:n #1
26755 {
26756 \int_compare:nNnTF \l__regex_curr_catcode_int = \c_zero_int
26757 {
26758 \__kernel_tl_set:Nx \l__regex_tmpa_tl
26759 { \scan_stop: \__regex_curr_cs_to_str: \scan_stop: }
26760 \tl_if_in:noTF { \scan_stop: #1 \scan_stop: }
26761 \l__regex_tmpa_tl
26762 { \__regex_break_true:w } { }
26763 }
26764 { }
26765 }
26766 \cs_new_protected:Npn \__regex_item_cs:n #1
26767 {
26768 \int_compare:nNnT \l__regex_curr_catcode_int = \c_zero_int
26769 {
26770 \group_begin:
26771 \__regex_single_match:
26772 \__regex_disable_submatches:
26773 \__regex_build_for_cs:n {#1}
26774 \bool_set_eq:NN \l__regex_saved_success_bool
26775 \g__regex_success_bool
26776 \exp_args:Ne \__regex_match_cs:n { \__regex_curr_cs_to_str: }
26777 \if_meaning:w \c_true_bool \g__regex_success_bool
26778 \group_insert_after:N \__regex_break_true:w
26779 \fi:
26780 \bool_gset_eq:NN \g__regex_success_bool
26781 \l__regex_saved_success_bool
26782 \group_end:
26783 }
26784 }
26785 \cs_new_protected:Npn \__regex_prop_d:
26786 { \__regex_item_caseful_range:nn { `0 } { `9 } }
26787 \cs_new_protected:Npn \__regex_prop_h:
26788 {
26789 \__regex_item_caseful_equal:n { `\ }
26790 \__regex_item_caseful_equal:n { `\^^I }
26791 }
26792 \cs_new_protected:Npn \__regex_prop_s:
26793 {
26794 \__regex_item_caseful_equal:n { `\ }
26795 \__regex_item_caseful_equal:n { `\^^I }
26796 \__regex_item_caseful_equal:n { `\^^J }
26797 \__regex_item_caseful_equal:n { `\^^L }
26798 \__regex_item_caseful_equal:n { `\^^M }
26799 }
26800 \cs_new_protected:Npn \__regex_prop_v:
26801 { \__regex_item_caseful_range:nn { `\^^J } { `\^^M } } % lf, vtab, ff, cr
26802 \cs_new_protected:Npn \__regex_prop_w:
26803 {
26804 \__regex_item_caseful_range:nn { `a } { `z }
26805 \__regex_item_caseful_range:nn { `A } { `Z }
26806 \__regex_item_caseful_range:nn { `0 } { `9 }
26807 \__regex_item_caseful_equal:n { `_ }
26808 }
26809 \cs_new_protected:Npn \__regex_prop_N:
26810 {
26811 \__regex_item_reverse:n
26812 { \__regex_item_caseful_equal:n { `\^^J } }
26813 }
26814 \cs_new_protected:Npn \__regex_posix_alnum:
26815 { \__regex_posix_alpha: \__regex_posix_digit: }
26816 \cs_new_protected:Npn \__regex_posix_alpha:
26817 { \__regex_posix_lower: \__regex_posix_upper: }
26818 \cs_new_protected:Npn \__regex_posix_ascii:
26819 {
26820 \__regex_item_caseful_range:nn
26821 \c__regex_ascii_min_int
26822 \c__regex_ascii_max_int
26823 }
26824 \cs_new_eq:NN \__regex_posix_blank: \__regex_prop_h:
26825 \cs_new_protected:Npn \__regex_posix_cntrl:
26826 {
26827 \__regex_item_caseful_range:nn
26828 \c__regex_ascii_min_int
26829 \c__regex_ascii_max_control_int
26830 \__regex_item_caseful_equal:n \c__regex_ascii_max_int
26831 }
26832 \cs_new_eq:NN \__regex_posix_digit: \__regex_prop_d:
26833 \cs_new_protected:Npn \__regex_posix_graph:
26834 { \__regex_item_caseful_range:nn { `! } { `\~ } }
26835 \cs_new_protected:Npn \__regex_posix_lower:
26836 { \__regex_item_caseful_range:nn { `a } { `z } }
26837 \cs_new_protected:Npn \__regex_posix_print:
26838 { \__regex_item_caseful_range:nn { `\ } { `\~ } }
26839 \cs_new_protected:Npn \__regex_posix_punct:
26840 {
26841 \__regex_item_caseful_range:nn { `! } { `/ }
26842 \__regex_item_caseful_range:nn { `: } { `@ }
26843 \__regex_item_caseful_range:nn { `[ } { `` }
26844 \__regex_item_caseful_range:nn { `\{ } { `\~ }
26845 }
26846 \cs_new_protected:Npn \__regex_posix_space:
26847 {
26848 \__regex_item_caseful_equal:n { `\ }
26849 \__regex_item_caseful_range:nn { `\^^I } { `\^^M }
26850 }
26851 \cs_new_protected:Npn \__regex_posix_upper:
26852 { \__regex_item_caseful_range:nn { `A } { `Z } }
26853 \cs_new_eq:NN \__regex_posix_word: \__regex_prop_w:
26854 \cs_new_protected:Npn \__regex_posix_xdigit:
26855 {
26856 \__regex_posix_digit:
26857 \__regex_item_caseful_range:nn { `A } { `F }
26858 \__regex_item_caseful_range:nn { `a } { `f }
26859 }
26860 \cs_new_protected:Npn \__regex_escape_use:nnnn #1#2#3#4
26861 {
26862 \group_begin:
26863 \tl_clear:N \l__regex_tmpa_tl
26864 \cs_set:Npn \__regex_escape_unescaped:N ##1 { #1 }
26865 \cs_set:Npn \__regex_escape_escaped:N ##1 { #2 }
26866 \cs_set:Npn \__regex_escape_raw:N ##1 { #3 }
26867 \__regex_standard_escapechar:
26868 \__kernel_tl_gset:Nx \g__regex_tmp_tl
26869 { \__kernel_str_to_other_fast:n {#4} }
26870 \tl_put_right:Ne \l__regex_tmpa_tl
26871 {
26872 \exp_after:wN \__regex_escape_loop:N \g__regex_tmp_tl
26873 \scan_stop: \prg_break_point:
26874 }
26875 \exp_after:wN
26876 \group_end:
26877 \l__regex_tmpa_tl
26878 }
26879 \cs_new:Npn \__regex_escape_loop:N #1
26880 {
26881 \cs_if_exist_use:cF { __regex_escape_\token_to_str:N #1:w }
26882 { \__regex_escape_unescaped:N #1 }
26883 \__regex_escape_loop:N
26884 }
26885 \cs_new:cpn { __regex_escape_ \c_backslash_str :w }
26886 \__regex_escape_loop:N #1
26887 {
26888 \cs_if_exist_use:cF { __regex_escape_/\token_to_str:N #1:w }
26889 { \__regex_escape_escaped:N #1 }
26890 \__regex_escape_loop:N
26891 }
26892 \cs_new_eq:NN \__regex_escape_unescaped:N ?
26893 \cs_new_eq:NN \__regex_escape_escaped:N ?
26894 \cs_new_eq:NN \__regex_escape_raw:N ?
26895 \cs_new_eq:cN { __regex_escape_ \iow_char:N\\scan_stop: :w } \prg_break:
26896 \cs_new:cpn { __regex_escape_/ \iow_char:N\\scan_stop: :w }
26897 {
26898 \msg_expandable_error:nn { regex } { trailing-backslash }
26899 \prg_break:
26900 }
26901 \cs_new:cpn { __regex_escape_~:w } { }
26902 \cs_new:cpe { __regex_escape_/a:w }
26903 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^G }
26904 \cs_new:cpe { __regex_escape_/t:w }
26905 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^I }
26906 \cs_new:cpe { __regex_escape_/n:w }
26907 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^J }
26908 \cs_new:cpe { __regex_escape_/f:w }
26909 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^L }
26910 \cs_new:cpe { __regex_escape_/r:w }
26911 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^M }
26912 \cs_new:cpe { __regex_escape_/e:w }
26913 { \exp_not:N \__regex_escape_raw:N \iow_char:N \^^[ }
26914 \cs_new:cpn { __regex_escape_/x:w } \__regex_escape_loop:N
26915 {
26916 \exp_after:wN \__regex_escape_x_end:w
26917 \int_value:w "0 \__regex_escape_x_test:N
26918 }
26919 \cs_new:Npn \__regex_escape_x_end:w #1 \__regex_sep:
26920 {
26921 \int_compare:nNnTF {#1} > \c_max_char_int
26922 {
26923 \msg_expandable_error:nnff { regex } { x-overflow }
26924 {#1} { \int_to_Hex:n {#1} }
26925 }
26926 {
26927 \exp_last_unbraced:Nf \__regex_escape_raw:N
26928 { \char_generate:nn {#1} { 12 } }
26929 }
26930 }
26931 \cs_new:Npn \__regex_escape_x_test:N #1
26932 {
26933 \if_meaning:w \scan_stop: #1
26934 \exp_after:wN \use_i:nnn \exp_after:wN \__regex_sep:
26935 \fi:
26936 \use:n
26937 {
26938 \if_charcode:w \c_space_token #1
26939 \exp_after:wN \__regex_escape_x_test:N
26940 \else:
26941 \exp_after:wN \__regex_escape_x_testii:N
26942 \exp_after:wN #1
26943 \fi:
26944 }
26945 }
26946 \cs_new:Npn \__regex_escape_x_testii:N #1
26947 {
26948 \if_charcode:w \c_left_brace_str #1
26949 \exp_after:wN \__regex_escape_x_loop:N
26950 \else:
26951 \__regex_hexadecimal_use:NTF #1
26952 { \exp_after:wN \__regex_escape_x:N }
26953 { \__regex_sep: \exp_after:wN \__regex_escape_loop:N \exp_after:wN #1 }
26954 \fi:
26955 }
26956 \cs_new:Npn \__regex_escape_x:N #1
26957 {
26958 \if_meaning:w \scan_stop: #1
26959 \exp_after:wN \use_i:nnn \exp_after:wN \__regex_sep:
26960 \fi:
26961 \use:n
26962 {
26963 \__regex_hexadecimal_use:NTF #1
26964 { \__regex_sep: \__regex_escape_loop:N }
26965 { \__regex_sep: \__regex_escape_loop:N #1 }
26966 }
26967 }
26968 \cs_new:Npn \__regex_escape_x_loop:N #1
26969 {
26970 \if_meaning:w \scan_stop: #1
26971 \exp_after:wN \use_ii:nnn
26972 \fi:
26973 \use_ii:nn
26974 { \__regex_sep: \__regex_escape_x_loop_error:n { } {#1} }
26975 {
26976 \__regex_hexadecimal_use:NTF #1
26977 { \__regex_escape_x_loop:N }
26978 {
26979 \token_if_eq_charcode:NNTF \c_space_token #1
26980 { \__regex_escape_x_loop:N }
26981 {
26982 \__regex_sep:
26983 \exp_after:wN
26984 \token_if_eq_charcode:NNTF \c_right_brace_str #1
26985 { \__regex_escape_loop:N }
26986 { \__regex_escape_x_loop_error:n {#1} }
26987 }
26988 }
26989 }
26990 }
26991 \cs_new:Npn \__regex_escape_x_loop_error:n #1
26992 {
26993 \msg_expandable_error:nnn { regex } { x-missing-rbrace } {#1}
26994 \__regex_escape_loop:N #1
26995 }
26996 \cs_new:Npn \__regex_hexadecimal_use:NTF #1
26997 {
26998 \if_int_compare:w \c_one_int < "1 \token_to_str:N #1 \exp_stop_f:
26999 #1
27000 \else:
27001 \if_case:w
27002 \__regex_int_eval:w \exp_after:wN ` \token_to_str:N #1 - `a \scan_stop:
27003 A
27004 \or: B
27005 \or: C
27006 \or: D
27007 \or: E
27008 \or: F
27009 \else:
27010 \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
27011 \fi:
27012 \fi:
27013 \use_i:nn
27014 }
27015 \prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF }
27016 {
27017 \if:w
27018 T
27019 \if_int_compare:w `#1 > `Z \exp_stop_f:
27020 \if_int_compare:w `#1 > `z \exp_stop_f:
27021 \if_int_compare:w `#1 < \c__regex_ascii_max_int
27022 \else: F \fi:
27023 \else:
27024 \if_int_compare:w `#1 < `a \exp_stop_f:
27025 \else: F \fi:
27026 \fi:
27027 \else:
27028 \if_int_compare:w `#1 > `9 \exp_stop_f:
27029 \if_int_compare:w `#1 < `A \exp_stop_f:
27030 \else: F \fi:
27031 \else:
27032 \if_int_compare:w `#1 < `0 \exp_stop_f:
27033 \if_int_compare:w `#1 < `\ \exp_stop_f:
27034 F \fi:
27035 \else: F \fi:
27036 \fi:
27037 \fi:
27038 T
27039 \prg_return_true:
27040 \else:
27041 \prg_return_false:
27042 \fi:
27043 }
27044 \prg_new_conditional:Npnn \__regex_char_if_alphanumeric:N #1 { TF }
27045 {
27046 \if:w
27047 T
27048 \if_int_compare:w `#1 > `Z \exp_stop_f:
27049 \if_int_compare:w `#1 > `z \exp_stop_f:
27050 F
27051 \else:
27052 \if_int_compare:w `#1 < `a \exp_stop_f:
27053 F \fi:
27054 \fi:
27055 \else:
27056 \if_int_compare:w `#1 > `9 \exp_stop_f:
27057 \if_int_compare:w `#1 < `A \exp_stop_f:
27058 F \fi:
27059 \else:
27060 \if_int_compare:w `#1 < `0 \exp_stop_f:
27061 F \fi:
27062 \fi:
27063 \fi:
27064 T
27065 \prg_return_true:
27066 \else:
27067 \prg_return_false:
27068 \fi:
27069 }
27070 \int_new:N \l__regex_group_level_int
27071 \int_new:N \l__regex_mode_int
27072 \int_const:Nn \c__regex_cs_in_class_mode_int { -6 }
27073 \int_const:Nn \c__regex_cs_mode_int { -2 }
27074 \int_const:Nn \c__regex_outer_mode_int { 0 }
27075 \int_const:Nn \c__regex_catcode_mode_int { 2 }
27076 \int_const:Nn \c__regex_class_mode_int { 3 }
27077 \int_const:Nn \c__regex_catcode_in_class_mode_int { 6 }
27078 \int_new:N \l__regex_catcodes_int
27079 \int_new:N \l__regex_default_catcodes_int
27080 \bool_new:N \l__regex_catcodes_bool
27081 \int_const:Nn \c__regex_catcode_C_int { "1 }
27082 \int_const:Nn \c__regex_catcode_B_int { "4 }
27083 \int_const:Nn \c__regex_catcode_E_int { "10 }
27084 \int_const:Nn \c__regex_catcode_M_int { "40 }
27085 \int_const:Nn \c__regex_catcode_T_int { "100 }
27086 \int_const:Nn \c__regex_catcode_P_int { "1000 }
27087 \int_const:Nn \c__regex_catcode_U_int { "4000 }
27088 \int_const:Nn \c__regex_catcode_D_int { "10000 }
27089 \int_const:Nn \c__regex_catcode_S_int { "100000 }
27090 \int_const:Nn \c__regex_catcode_L_int { "400000 }
27091 \int_const:Nn \c__regex_catcode_O_int { "1000000 }
27092 \int_const:Nn \c__regex_catcode_A_int { "4000000 }
27093 \int_const:Nn \c__regex_all_catcodes_int { "5515155 }
27094 \cs_new_eq:NN \l__regex_tmp_regex \c__regex_no_match_regex
27095 \seq_new:N \l__regex_show_prefix_seq
27096 \int_new:N \l__regex_show_lines_int
27097 \cs_new:Npn \__regex_two_if_eq:NNNNTF #1#2#3#4
27098 {
27099 \if_meaning:w #1 #3
27100 \if:w #2 #4
27101 \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
27102 \fi:
27103 \fi:
27104 \use_ii:nn
27105 }
27106 \cs_new_protected:Npn \__regex_get_digits:NTFw #1#2#3#4#5
27107 {
27108 \__regex_if_raw_digit:NNTF #4 #5
27109 { #1 = #5 \__regex_get_digits_loop:nw {#2} }
27110 { #3 #4 #5 }
27111 }
27112 \cs_new:Npn \__regex_get_digits_loop:nw #1#2#3
27113 {
27114 \__regex_if_raw_digit:NNTF #2 #3
27115 { #3 \__regex_get_digits_loop:nw {#1} }
27116 { \scan_stop: #1 #2 #3 }
27117 }
27118 \cs_new:Npn \__regex_if_raw_digit:NNTF #1#2
27119 {
27120 \if_meaning:w \__regex_compile_raw:N #1
27121 \if_int_compare:w \c_one_int < 1 #2 \exp_stop_f:
27122 \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
27123 \fi:
27124 \fi:
27125 \use_ii:nn
27126 }
27127 \prg_new_conditional:Npnn \__regex_if_in_class: { TF }
27128 {
27129 \if_int_odd:w \l__regex_mode_int
27130 \prg_return_true:
27131 \else:
27132 \prg_return_false:
27133 \fi:
27134 }
27135 \cs_new:Npn \__regex_if_in_cs:TF
27136 {
27137 \if_int_odd:w \l__regex_mode_int
27138 \else:
27139 \if_int_compare:w \l__regex_mode_int < \c__regex_outer_mode_int
27140 \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nnn
27141 \fi:
27142 \fi:
27143 \use_ii:nn
27144 }
27145 \cs_new:Npn \__regex_if_in_class_or_catcode:TF
27146 {
27147 \if_int_odd:w \l__regex_mode_int
27148 \else:
27149 \if_int_compare:w \l__regex_mode_int > \c__regex_outer_mode_int
27150 \else:
27151 \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
27152 \fi:
27153 \fi:
27154 \use_i:nn
27155 }
27156 \prg_new_conditional:Npnn \__regex_if_within_catcode: { TF }
27157 {
27158 \if_int_compare:w \l__regex_mode_int > \c__regex_outer_mode_int
27159 \prg_return_true:
27160 \else:
27161 \prg_return_false:
27162 \fi:
27163 }
27164 \cs_new_protected:Npn \__regex_chk_c_allowed:T
27165 {
27166 \if_int_compare:w \l__regex_mode_int = \c__regex_outer_mode_int
27167 \else:
27168 \if_int_compare:w \l__regex_mode_int = \c__regex_class_mode_int
27169 \else:
27170 \msg_error:nn { regex } { c-bad-mode }
27171 \exp_after:wN \use_i:nnn
27172 \fi:
27173 \fi:
27174 \use:n
27175 }
27176 \cs_new_protected:Npn \__regex_mode_quit_c:
27177 {
27178 \if_int_compare:w \l__regex_mode_int = \c__regex_catcode_mode_int
27179 \int_set_eq:NN \l__regex_mode_int \c__regex_outer_mode_int
27180 \else:
27181 \if_int_compare:w \l__regex_mode_int =
27182 \c__regex_catcode_in_class_mode_int
27183 \int_set_eq:NN \l__regex_mode_int \c__regex_class_mode_int
27184 \fi:
27185 \fi:
27186 }
27187 \cs_new_protected:Npn \__regex_compile:w
27188 {
27189 \group_begin:
27190 \tl_build_begin:N \l__regex_build_tl
27191 \int_zero:N \l__regex_group_level_int
27192 \int_set_eq:NN \l__regex_default_catcodes_int
27193 \c__regex_all_catcodes_int
27194 \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int
27195 \cs_set:Npn \__regex_item_equal:n { \__regex_item_caseful_equal:n }
27196 \cs_set:Npn \__regex_item_range:nn { \__regex_item_caseful_range:nn }
27197 \tl_build_put_right:Nn \l__regex_build_tl
27198 { \__regex_branch:n { \if_false: } \fi: }
27199 }
27200 \cs_new_protected:Npn \__regex_compile_end:
27201 {
27202 \__regex_if_in_class:TF
27203 {
27204 \msg_error:nn { regex } { missing-rbrack }
27205 \use:c { __regex_compile_]: }
27206 \prg_do_nothing: \prg_do_nothing:
27207 }
27208 { }
27209 \if_int_compare:w \l__regex_group_level_int > \c_zero_int
27210 \msg_error:nne { regex } { missing-rparen }
27211 { \int_use:N \l__regex_group_level_int }
27212 \prg_replicate:nn
27213 \l__regex_group_level_int
27214 {
27215 \tl_build_put_right:Nn \l__regex_build_tl
27216 {
27217 \if_false: { \fi: }
27218 \if_false: { \fi: } { 1 } { 0 } \c_true_bool
27219 }
27220 \tl_build_end:N \l__regex_build_tl
27221 \exp_args:NNNo
27222 \group_end:
27223 \tl_build_put_right:Nn \l__regex_build_tl
27224 { \l__regex_build_tl }
27225 }
27226 \fi:
27227 \tl_build_put_right:Nn \l__regex_build_tl { \if_false: { \fi: } }
27228 \tl_build_end:N \l__regex_build_tl
27229 \exp_args:NNNe
27230 \group_end:
27231 \tl_set:Nn \l__regex_tmp_regex { \l__regex_build_tl }
27232 }
27233 \cs_new_protected:Npn \__regex_compile:n #1
27234 {
27235 \__regex_compile:w
27236 \__regex_standard_escapechar:
27237 \int_set_eq:NN \l__regex_mode_int \c__regex_outer_mode_int
27238 \__regex_escape_use:nnnn
27239 {
27240 \__regex_char_if_special:NTF ##1
27241 \__regex_compile_special:N \__regex_compile_raw:N ##1
27242 }
27243 {
27244 \__regex_char_if_alphanumeric:NTF ##1
27245 \__regex_compile_escaped:N \__regex_compile_raw:N ##1
27246 }
27247 { \__regex_compile_raw:N ##1 }
27248 { #1 }
27249 \prg_do_nothing: \prg_do_nothing:
27250 \prg_do_nothing: \prg_do_nothing:
27251 \int_compare:nNnT \l__regex_mode_int = \c__regex_catcode_mode_int
27252 { \msg_error:nn { regex } { c-trailing } }
27253 \int_compare:nNnT \l__regex_mode_int < \c__regex_outer_mode_int
27254 {
27255 \msg_error:nn { regex } { c-missing-rbrace }
27256 \__regex_compile_end_cs:
27257 \prg_do_nothing: \prg_do_nothing:
27258 \prg_do_nothing: \prg_do_nothing:
27259 }
27260 \__regex_compile_end:
27261 }
27262 \cs_new_protected:Npn \__regex_compile_use:n #1
27263 {
27264 \tl_if_single_token:nT {#1}
27265 {
27266 \exp_after:wN \__regex_compile_use_aux:w
27267 \token_to_meaning:N #1 ~ \q__regex_nil
27268 }
27269 \__regex_compile:n {#1} \l__regex_tmp_regex
27270 }
27271 \cs_new_protected:Npn \__regex_compile_use_aux:w #1 ~ #2 \q__regex_nil
27272 {
27273 \str_if_eq:nnT { #1 ~ } { macro:->\__regex_branch:n }
27274 { \use_ii:nnn }
27275 }
27276 \cs_new_protected:Npn \__regex_compile_special:N #1
27277 {
27278 \cs_if_exist_use:cF { __regex_compile_#1: }
27279 { \__regex_compile_raw:N #1 }
27280 }
27281 \cs_new_protected:Npn \__regex_compile_escaped:N #1
27282 {
27283 \cs_if_exist_use:cF { __regex_compile_/#1: }
27284 { \__regex_compile_raw:N #1 }
27285 }
27286 \cs_new_protected:Npn \__regex_compile_one:n #1
27287 {
27288 \__regex_mode_quit_c:
27289 \__regex_if_in_class:TF { }
27290 {
27291 \tl_build_put_right:Nn \l__regex_build_tl
27292 { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: }
27293 }
27294 \tl_build_put_right:Ne \l__regex_build_tl
27295 {
27296 \if_int_compare:w \l__regex_catcodes_int <
27297 \c__regex_all_catcodes_int
27298 \__regex_item_catcode:nT { \int_use:N \l__regex_catcodes_int }
27299 { \exp_not:N \exp_not:n {#1} }
27300 \else:
27301 \exp_not:N \exp_not:n {#1}
27302 \fi:
27303 }
27304 \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int
27305 \__regex_if_in_class:TF { } { \__regex_compile_quantifier:w }
27306 }
27307 \cs_new_protected:Npn \__regex_compile_abort_tokens:n #1
27308 {
27309 \use:e
27310 {
27311 \exp_args:No \tl_map_function:nN { \tl_to_str:n {#1} }
27312 \__regex_compile_raw:N
27313 }
27314 }
27315 \cs_generate_variant:Nn \__regex_compile_abort_tokens:n { e }
27316 \cs_new_protected:Npn \__regex_compile_if_quantifier:TFw #1#2#3#4
27317 {
27318 \token_if_eq_meaning:NNTF #3 \__regex_compile_special:N
27319 { \cs_if_exist:cTF { __regex_compile_quantifier_#4:w } }
27320 { \use_ii:nn }
27321 {#1} {#2} #3 #4
27322 }
27323 \cs_new_protected:Npn \__regex_compile_quantifier:w #1#2
27324 {
27325 \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N
27326 {
27327 \cs_if_exist_use:cF { __regex_compile_quantifier_#2:w }
27328 { \__regex_compile_quantifier_none: #1 #2 }
27329 }
27330 { \__regex_compile_quantifier_none: #1 #2 }
27331 }
27332 \cs_new_protected:Npn \__regex_compile_quantifier_none:
27333 {
27334 \tl_build_put_right:Nn \l__regex_build_tl
27335 { \if_false: { \fi: } { 1 } { 0 } \c_false_bool }
27336 }
27337 \cs_new_protected:Npn \__regex_compile_quantifier_abort:eNN #1#2#3
27338 {
27339 \__regex_compile_quantifier_none:
27340 \msg_warning:nnee { regex } { invalid-quantifier } {#1} {#3}
27341 \__regex_compile_abort_tokens:e {#1}
27342 #2 #3
27343 }
27344 \cs_new_protected:Npn \__regex_compile_quantifier_laziness:nnNN #1#2#3#4
27345 {
27346 \__regex_two_if_eq:NNNNTF #3 #4 \__regex_compile_special:N ?
27347 {
27348 \tl_build_put_right:Nn \l__regex_build_tl
27349 { \if_false: { \fi: } { #1 } { #2 } \c_true_bool }
27350 }
27351 {
27352 \tl_build_put_right:Nn \l__regex_build_tl
27353 { \if_false: { \fi: } { #1 } { #2 } \c_false_bool }
27354 #3 #4
27355 }
27356 }
27357 \cs_new_protected:cpn { __regex_compile_quantifier_?:w }
27358 { \__regex_compile_quantifier_laziness:nnNN { 0 } { 1 } }
27359 \cs_new_protected:cpn { __regex_compile_quantifier_*:w }
27360 { \__regex_compile_quantifier_laziness:nnNN { 0 } { -1 } }
27361 \cs_new_protected:cpn { __regex_compile_quantifier_+:w }
27362 { \__regex_compile_quantifier_laziness:nnNN { 1 } { -1 } }
27363 \cs_new_protected:cpn { __regex_compile_quantifier_ \c_left_brace_str :w }
27364 {
27365 \__regex_get_digits:NTFw \l__regex_tmpa_int
27366 { \__regex_compile_quantifier_braced_auxi:w }
27367 { \__regex_compile_quantifier_abort:eNN { \c_left_brace_str } }
27368 }
27369 \cs_new_protected:Npn \__regex_compile_quantifier_braced_auxi:w #1#2
27370 {
27371 \str_case_e:nnF { #1 #2 }
27372 {
27373 { \__regex_compile_special:N \c_right_brace_str }
27374 {
27375 \exp_args:No \__regex_compile_quantifier_laziness:nnNN
27376 { \int_use:N \l__regex_tmpa_int } 0
27377 }
27378 { \__regex_compile_special:N , }
27379 {
27380 \__regex_get_digits:NTFw \l__regex_tmpb_int
27381 { \__regex_compile_quantifier_braced_auxiii:w }
27382 { \__regex_compile_quantifier_braced_auxii:w }
27383 }
27384 }
27385 {
27386 \__regex_compile_quantifier_abort:eNN
27387 { \c_left_brace_str \int_use:N \l__regex_tmpa_int }
27388 #1 #2
27389 }
27390 }
27391 \cs_new_protected:Npn \__regex_compile_quantifier_braced_auxii:w #1#2
27392 {
27393 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N \c_right_brace_str
27394 {
27395 \exp_args:No \__regex_compile_quantifier_laziness:nnNN
27396 { \int_use:N \l__regex_tmpa_int } { -1 }
27397 }
27398 {
27399 \__regex_compile_quantifier_abort:eNN
27400 { \c_left_brace_str \int_use:N \l__regex_tmpa_int , }
27401 #1 #2
27402 }
27403 }
27404 \cs_new_protected:Npn \__regex_compile_quantifier_braced_auxiii:w #1#2
27405 {
27406 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N \c_right_brace_str
27407 {
27408 \if_int_compare:w \l__regex_tmpa_int >
27409 \l__regex_tmpb_int
27410 \msg_error:nnee { regex } { backwards-quantifier }
27411 { \int_use:N \l__regex_tmpa_int }
27412 { \int_use:N \l__regex_tmpb_int }
27413 \int_zero:N \l__regex_tmpb_int
27414 \else:
27415 \int_sub:Nn \l__regex_tmpb_int \l__regex_tmpa_int
27416 \fi:
27417 \exp_args:Noo \__regex_compile_quantifier_laziness:nnNN
27418 { \int_use:N \l__regex_tmpa_int }
27419 { \int_use:N \l__regex_tmpb_int }
27420 }
27421 {
27422 \__regex_compile_quantifier_abort:eNN
27423 {
27424 \c_left_brace_str
27425 \int_use:N \l__regex_tmpa_int ,
27426 \int_use:N \l__regex_tmpb_int
27427 }
27428 #1 #2
27429 }
27430 }
27431 \cs_new_protected:Npn \__regex_compile_raw_error:N #1
27432 {
27433 \msg_error:nne { regex } { bad-escape } {#1}
27434 \__regex_compile_raw:N #1
27435 }
27436 \cs_new_protected:Npn \__regex_compile_raw:N #1#2#3
27437 {
27438 \__regex_if_in_class:TF
27439 {
27440 \__regex_two_if_eq:NNNNTF #2 #3 \__regex_compile_special:N -
27441 { \__regex_compile_range:Nw #1 }
27442 {
27443 \__regex_compile_one:n
27444 { \__regex_item_equal:n { \int_value:w `#1 } }
27445 #2 #3
27446 }
27447 }
27448 {
27449 \__regex_compile_one:n
27450 { \__regex_item_equal:n { \int_value:w `#1 } }
27451 #2 #3
27452 }
27453 }
27454 \cs_new_protected:Npn \__regex_if_end_range:NNTF #1#2
27455 {
27456 \if_meaning:w \__regex_compile_raw:N #1
27457 \else:
27458 \if_meaning:w \__regex_compile_special:N #1
27459 \if_charcode:w ] #2
27460 \use_i:nn
27461 \fi:
27462 \else:
27463 \exp_after:wN \exp_after:wN \exp_after:wN \use_iii:nnn
27464 \fi:
27465 \fi:
27466 \use_i:nn
27467 }
27468 \cs_new_protected:Npn \__regex_compile_range:Nw #1#2#3
27469 {
27470 \__regex_if_end_range:NNTF #2 #3
27471 {
27472 \if_int_compare:w `#1 > `#3 \exp_stop_f:
27473 \msg_error:nnee { regex } { range-backwards } {#1} {#3}
27474 \else:
27475 \tl_build_put_right:Ne \l__regex_build_tl
27476 {
27477 \if_int_compare:w `#1 = `#3 \exp_stop_f:
27478 \__regex_item_equal:n
27479 \else:
27480 \__regex_item_range:nn { \int_value:w `#1 }
27481 \fi:
27482 { \int_value:w `#3 }
27483 }
27484 \fi:
27485 }
27486 {
27487 \msg_warning:nnee { regex } { range-missing-end }
27488 {#1} { \c_backslash_str #3 }
27489 \tl_build_put_right:Ne \l__regex_build_tl
27490 {
27491 \__regex_item_equal:n { \int_value:w `#1 \exp_stop_f: }
27492 \__regex_item_equal:n { \int_value:w `- \exp_stop_f: }
27493 }
27494 #2#3
27495 }
27496 }
27497 \cs_new_protected:cpe { __regex_compile_.: }
27498 {
27499 \exp_not:N \__regex_if_in_class:TF
27500 { \__regex_compile_raw:N . }
27501 { \__regex_compile_one:n \exp_not:c { __regex_prop_.: } }
27502 }
27503 \cs_new_protected:cpn { __regex_prop_.: }
27504 {
27505 \if_int_compare:w \l__regex_curr_char_int > - 2 \exp_stop_f:
27506 \exp_after:wN \__regex_break_true:w
27507 \fi:
27508 }
27509 \cs_set_protected:Npn \__regex_tmp:w #1#2
27510 {
27511 \cs_new_protected:cpe { __regex_compile_/#1: }
27512 { \__regex_compile_one:n \exp_not:c { __regex_prop_#1: } }
27513 \cs_new_protected:cpe { __regex_compile_/#2: }
27514 {
27515 \__regex_compile_one:n
27516 { \__regex_item_reverse:n { \exp_not:c { __regex_prop_#1: } } }
27517 }
27518 }
27519 \__regex_tmp:w d D
27520 \__regex_tmp:w h H
27521 \__regex_tmp:w s S
27522 \__regex_tmp:w v V
27523 \__regex_tmp:w w W
27524 \cs_new_protected:cpn { __regex_compile_/N: }
27525 { \__regex_compile_one:n \__regex_prop_N: }
27526 \cs_new_protected:Npn \__regex_compile_anchor_letter:NNN #1#2#3
27527 {
27528 \__regex_if_in_class_or_catcode:TF { \__regex_compile_raw_error:N #1 }
27529 {
27530 \tl_build_put_right:Nn \l__regex_build_tl
27531 { \__regex_assertion:Nn #2 {#3} }
27532 }
27533 }
27534 \cs_new_protected:cpn { __regex_compile_/A: }
27535 { \__regex_compile_anchor_letter:NNN A \c_true_bool \__regex_A_test: }
27536 \cs_new_protected:cpn { __regex_compile_/G: }
27537 { \__regex_compile_anchor_letter:NNN G \c_true_bool \__regex_G_test: }
27538 \cs_new_protected:cpn { __regex_compile_/Z: }
27539 { \__regex_compile_anchor_letter:NNN Z \c_true_bool \__regex_Z_test: }
27540 \cs_new_protected:cpn { __regex_compile_/z: }
27541 { \__regex_compile_anchor_letter:NNN z \c_true_bool \__regex_Z_test: }
27542 \cs_new_protected:cpn { __regex_compile_/b: }
27543 { \__regex_compile_anchor_letter:NNN b \c_true_bool \__regex_b_test: }
27544 \cs_new_protected:cpn { __regex_compile_/B: }
27545 { \__regex_compile_anchor_letter:NNN B \c_false_bool \__regex_b_test: }
27546 \cs_set_protected:Npn \__regex_tmp:w #1#2
27547 {
27548 \cs_new_protected:cpn { __regex_compile_#1: }
27549 {
27550 \__regex_if_in_class_or_catcode:TF { \__regex_compile_raw:N #1 }
27551 {
27552 \tl_build_put_right:Nn \l__regex_build_tl
27553 { \__regex_assertion:Nn \c_true_bool {#2} }
27554 }
27555 }
27556 }
27557 \exp_args:Ne \__regex_tmp:w { \iow_char:N \^ } { \__regex_A_test: }
27558 \exp_args:Ne \__regex_tmp:w { \iow_char:N \$ } { \__regex_Z_test: }
27559 \cs_new_protected:cpn { __regex_compile_]: }
27560 {
27561 \__regex_if_in_class:TF
27562 {
27563 \if_int_compare:w \l__regex_mode_int >
27564 \c__regex_catcode_in_class_mode_int
27565 \tl_build_put_right:Nn \l__regex_build_tl { \if_false: { \fi: } }
27566 \fi:
27567 \tex_advance:D \l__regex_mode_int - 15 \exp_stop_f:
27568 \tex_divide:D \l__regex_mode_int 13 \exp_stop_f:
27569 \if_int_odd:w \l__regex_mode_int \else:
27570 \exp_after:wN \__regex_compile_quantifier:w
27571 \fi:
27572 }
27573 { \__regex_compile_raw:N ] }
27574 }
27575 \cs_new_protected:cpn { __regex_compile_[: }
27576 {
27577 \__regex_if_in_class:TF
27578 { \__regex_compile_class_posix_test:w }
27579 {
27580 \__regex_if_within_catcode:TF
27581 {
27582 \exp_after:wN \__regex_compile_class_catcode:w
27583 \int_use:N \l__regex_catcodes_int \__regex_sep:
27584 }
27585 { \__regex_compile_class_normal:w }
27586 }
27587 }
27588 \cs_new_protected:Npn \__regex_compile_class_normal:w
27589 {
27590 \__regex_compile_class:TFNN
27591 { \__regex_class:NnnnN \c_true_bool }
27592 { \__regex_class:NnnnN \c_false_bool }
27593 }
27594 \cs_new_protected:Npn \__regex_compile_class_catcode:w #1 \__regex_sep:
27595 {
27596 \if_int_compare:w \l__regex_mode_int = \c__regex_catcode_mode_int
27597 \tl_build_put_right:Nn \l__regex_build_tl
27598 { \__regex_class:NnnnN \c_true_bool { \if_false: } \fi: }
27599 \fi:
27600 \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int
27601 \__regex_compile_class:TFNN
27602 { \__regex_item_catcode:nT {#1} }
27603 { \__regex_item_catcode_reverse:nT {#1} }
27604 }
27605 \cs_new_protected:Npn \__regex_compile_class:TFNN #1#2#3#4
27606 {
27607 \l__regex_mode_int = \int_value:w \l__regex_mode_int 3 \exp_stop_f:
27608 \__regex_two_if_eq:NNNNTF #3 #4 \__regex_compile_special:N ^
27609 {
27610 \tl_build_put_right:Nn \l__regex_build_tl { #2 { \if_false: } \fi: }
27611 \__regex_compile_class:NN
27612 }
27613 {
27614 \tl_build_put_right:Nn \l__regex_build_tl { #1 { \if_false: } \fi: }
27615 \__regex_compile_class:NN #3 #4
27616 }
27617 }
27618 \cs_new_protected:Npn \__regex_compile_class:NN #1#2
27619 {
27620 \token_if_eq_charcode:NNTF #2 ]
27621 { \__regex_compile_raw:N #2 }
27622 { #1 #2 }
27623 }
27624 \cs_new_protected:Npn \__regex_compile_class_posix_test:w #1#2
27625 {
27626 \token_if_eq_meaning:NNT \__regex_compile_special:N #1
27627 {
27628 \str_case:nn { #2 }
27629 {
27630 : { \__regex_compile_class_posix:NNNNw }
27631 = {
27632 \msg_warning:nne { regex }
27633 { posix-unsupported } { = }
27634 }
27635 . {
27636 \msg_warning:nne { regex }
27637 { posix-unsupported } { . }
27638 }
27639 }
27640 }
27641 \__regex_compile_raw:N [ #1 #2
27642 }
27643 \cs_new_protected:Npn \__regex_compile_class_posix:NNNNw #1#2#3#4#5#6
27644 {
27645 \__regex_two_if_eq:NNNNTF #5 #6 \__regex_compile_special:N ^
27646 {
27647 \bool_set_false:N \l__regex_tmp_bool
27648 \__kernel_tl_set:Nx \l__regex_tmpa_tl { \if_false: } \fi:
27649 \__regex_compile_class_posix_loop:w
27650 }
27651 {
27652 \bool_set_true:N \l__regex_tmp_bool
27653 \__kernel_tl_set:Nx \l__regex_tmpa_tl { \if_false: } \fi:
27654 \__regex_compile_class_posix_loop:w #5 #6
27655 }
27656 }
27657 \cs_new:Npn \__regex_compile_class_posix_loop:w #1#2
27658 {
27659 \token_if_eq_meaning:NNTF \__regex_compile_raw:N #1
27660 { #2 \__regex_compile_class_posix_loop:w }
27661 { \if_false: { \fi: } \__regex_compile_class_posix_end:w #1 #2 }
27662 }
27663 \cs_new_protected:Npn \__regex_compile_class_posix_end:w #1#2#3#4
27664 {
27665 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N :
27666 { \__regex_two_if_eq:NNNNTF #3 #4 \__regex_compile_special:N ] }
27667 { \use_ii:nn }
27668 {
27669 \cs_if_exist:cTF { __regex_posix_ \l__regex_tmpa_tl : }
27670 {
27671 \__regex_compile_one:n
27672 {
27673 \bool_if:NTF \l__regex_tmp_bool \use:n \__regex_item_reverse:n
27674 { \exp_not:c { __regex_posix_ \l__regex_tmpa_tl : } }
27675 }
27676 }
27677 {
27678 \msg_warning:nne { regex } { posix-unknown }
27679 { \l__regex_tmpa_tl }
27680 \__regex_compile_abort_tokens:e
27681 {
27682 [: \bool_if:NF \l__regex_tmp_bool { ^ }
27683 \l__regex_tmpa_tl :]
27684 }
27685 }
27686 }
27687 {
27688 \msg_error:nnee { regex } { posix-missing-close }
27689 { [: \l__regex_tmpa_tl } { #2 #4 }
27690 \__regex_compile_abort_tokens:e { [: \l__regex_tmpa_tl }
27691 #1 #2 #3 #4
27692 }
27693 }
27694 \cs_new_protected:Npn \__regex_compile_group_begin:N #1
27695 {
27696 \tl_build_put_right:Nn \l__regex_build_tl { #1 { \if_false: } \fi: }
27697 \__regex_mode_quit_c:
27698 \group_begin:
27699 \tl_build_begin:N \l__regex_build_tl
27700 \int_set_eq:NN \l__regex_default_catcodes_int \l__regex_catcodes_int
27701 \int_incr:N \l__regex_group_level_int
27702 \tl_build_put_right:Nn \l__regex_build_tl
27703 { \__regex_branch:n { \if_false: } \fi: }
27704 }
27705 \cs_new_protected:Npn \__regex_compile_group_end:
27706 {
27707 \if_int_compare:w \l__regex_group_level_int > \c_zero_int
27708 \tl_build_put_right:Nn \l__regex_build_tl { \if_false: { \fi: } }
27709 \tl_build_end:N \l__regex_build_tl
27710 \exp_args:NNNe
27711 \group_end:
27712 \tl_build_put_right:Nn \l__regex_build_tl { \l__regex_build_tl }
27713 \int_set_eq:NN \l__regex_catcodes_int \l__regex_default_catcodes_int
27714 \exp_after:wN \__regex_compile_quantifier:w
27715 \else:
27716 \msg_warning:nn { regex } { extra-rparen }
27717 \exp_after:wN \__regex_compile_raw:N \exp_after:wN )
27718 \fi:
27719 }
27720 \cs_new_protected:cpn { __regex_compile_(: }
27721 {
27722 \__regex_if_in_class:TF { \__regex_compile_raw:N ( }
27723 {
27724 \if_int_compare:w \l__regex_mode_int =
27725 \c__regex_catcode_in_class_mode_int
27726 \msg_error:nn { regex } { c-lparen-in-class }
27727 \exp_after:wN \__regex_compile_raw:N \exp_after:wN (
27728 \else:
27729 \exp_after:wN \__regex_compile_lparen:w
27730 \fi:
27731 }
27732 }
27733 \cs_new_protected:Npn \__regex_compile_lparen:w #1#2#3#4
27734 {
27735 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N ?
27736 {
27737 \cs_if_exist_use:cF
27738 { __regex_compile_special_group_\token_to_str:N #4 :w }
27739 {
27740 \msg_warning:nne { regex } { special-group-unknown }
27741 { (? #4 }
27742 \__regex_compile_group_begin:N \__regex_group:nnnN
27743 \__regex_compile_raw:N ? #3 #4
27744 }
27745 }
27746 {
27747 \__regex_compile_group_begin:N \__regex_group:nnnN
27748 #1 #2 #3 #4
27749 }
27750 }
27751 \cs_new_protected:cpn { __regex_compile_|: }
27752 {
27753 \__regex_if_in_class:TF { \__regex_compile_raw:N | }
27754 {
27755 \tl_build_put_right:Nn \l__regex_build_tl
27756 { \if_false: { \fi: } \__regex_branch:n { \if_false: } \fi: }
27757 }
27758 }
27759 \cs_new_protected:cpn { __regex_compile_): }
27760 {
27761 \__regex_if_in_class:TF { \__regex_compile_raw:N ) }
27762 { \__regex_compile_group_end: }
27763 }
27764 \cs_new_protected:cpn { __regex_compile_special_group_::w }
27765 { \__regex_compile_group_begin:N \__regex_group_no_capture:nnnN }
27766 \cs_new_protected:cpn { __regex_compile_special_group_|:w }
27767 { \__regex_compile_group_begin:N \__regex_group_resetting:nnnN }
27768 \cs_new_protected:Npn \__regex_compile_special_group_i:w #1#2
27769 {
27770 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N )
27771 {
27772 \cs_set:Npn \__regex_item_equal:n
27773 { \__regex_item_caseless_equal:n }
27774 \cs_set:Npn \__regex_item_range:nn
27775 { \__regex_item_caseless_range:nn }
27776 }
27777 {
27778 \msg_warning:nne { regex } { unknown-option } { (?i #2 }
27779 \__regex_compile_raw:N (
27780 \__regex_compile_raw:N ?
27781 \__regex_compile_raw:N i
27782 #1 #2
27783 }
27784 }
27785 \cs_new_protected:cpn { __regex_compile_special_group_-:w } #1#2#3#4
27786 {
27787 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_raw:N i
27788 { \__regex_two_if_eq:NNNNTF #3 #4 \__regex_compile_special:N ) }
27789 { \use_ii:nn }
27790 {
27791 \cs_set:Npn \__regex_item_equal:n
27792 { \__regex_item_caseful_equal:n }
27793 \cs_set:Npn \__regex_item_range:nn
27794 { \__regex_item_caseful_range:nn }
27795 }
27796 {
27797 \msg_warning:nne { regex } { unknown-option } { (?-#2#4 }
27798 \__regex_compile_raw:N (
27799 \__regex_compile_raw:N ?
27800 \__regex_compile_raw:N -
27801 #1 #2 #3 #4
27802 }
27803 }
27804 \cs_new_protected:cpn { __regex_compile_/c: }
27805 { \__regex_chk_c_allowed:T { \__regex_compile_c_test:NN } }
27806 \cs_new_protected:Npn \__regex_compile_c_test:NN #1#2
27807 {
27808 \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N
27809 {
27810 \int_if_exist:cTF { c__regex_catcode_#2_int }
27811 {
27812 \int_set_eq:Nc \l__regex_catcodes_int
27813 { c__regex_catcode_#2_int }
27814 \l__regex_mode_int
27815 = \if_case:w \l__regex_mode_int
27816 \c__regex_catcode_mode_int
27817 \else:
27818 \c__regex_catcode_in_class_mode_int
27819 \fi:
27820 \token_if_eq_charcode:NNT C #2 { \__regex_compile_c_C:NN }
27821 }
27822 }
27823 { \cs_if_exist_use:cF { __regex_compile_c_#2:w } }
27824 {
27825 \msg_error:nne { regex } { c-missing-category } {#2}
27826 #1 #2
27827 }
27828 }
27829 \cs_new_protected:Npn \__regex_compile_c_C:NN #1#2
27830 {
27831 \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N
27832 {
27833 \token_if_eq_charcode:NNTF #2 .
27834 { \use_none:n }
27835 { \token_if_eq_charcode:NNF #2 ( } % )
27836 }
27837 { \use:n }
27838 { \msg_error:nnn { regex } { c-C-invalid } {#2} }
27839 #1 #2
27840 }
27841 \cs_new_protected:cpn { __regex_compile_c_[:w } #1#2
27842 {
27843 \l__regex_mode_int
27844 = \if_case:w \l__regex_mode_int
27845 \c__regex_catcode_mode_int
27846 \else:
27847 \c__regex_catcode_in_class_mode_int
27848 \fi:
27849 \int_zero:N \l__regex_catcodes_int
27850 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_special:N ^
27851 {
27852 \bool_set_false:N \l__regex_catcodes_bool
27853 \__regex_compile_c_lbrack_loop:NN
27854 }
27855 {
27856 \bool_set_true:N \l__regex_catcodes_bool
27857 \__regex_compile_c_lbrack_loop:NN
27858 #1 #2
27859 }
27860 }
27861 \cs_new_protected:Npn \__regex_compile_c_lbrack_loop:NN #1#2
27862 {
27863 \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N
27864 {
27865 \int_if_exist:cTF { c__regex_catcode_#2_int }
27866 {
27867 \exp_args:Nc \__regex_compile_c_lbrack_add:N
27868 { c__regex_catcode_#2_int }
27869 \__regex_compile_c_lbrack_loop:NN
27870 }
27871 }
27872 {
27873 \token_if_eq_charcode:NNTF #2 ]
27874 { \__regex_compile_c_lbrack_end: }
27875 }
27876 {
27877 \msg_error:nne { regex } { c-missing-rbrack } {#2}
27878 \__regex_compile_c_lbrack_end:
27879 #1 #2
27880 }
27881 }
27882 \cs_new_protected:Npn \__regex_compile_c_lbrack_add:N #1
27883 {
27884 \if_int_odd:w \__regex_int_eval:w \l__regex_catcodes_int / #1 \scan_stop:
27885 \else:
27886 \int_add:Nn \l__regex_catcodes_int {#1}
27887 \fi:
27888 }
27889 \cs_new_protected:Npn \__regex_compile_c_lbrack_end:
27890 {
27891 \if_meaning:w \c_false_bool \l__regex_catcodes_bool
27892 \int_set:Nn \l__regex_catcodes_int
27893 { \c__regex_all_catcodes_int - \l__regex_catcodes_int }
27894 \fi:
27895 }
27896 \cs_new_protected:cpn { __regex_compile_c_ \c_left_brace_str :w }
27897 {
27898 \__regex_compile:w
27899 \__regex_disable_submatches:
27900 \l__regex_mode_int
27901 = \if_case:w \l__regex_mode_int
27902 \c__regex_cs_mode_int
27903 \else:
27904 \c__regex_cs_in_class_mode_int
27905 \fi:
27906 }
27907 \cs_new_protected:cpn { __regex_compile_ \c_left_brace_str : }
27908 {
27909 \__regex_if_in_cs:TF
27910 { \msg_error:nnn { regex } { cu-lbrace } { c } }
27911 { \exp_after:wN \__regex_compile_raw:N \c_left_brace_str }
27912 }
27913 \flag_new:N \l__regex_cs_flag
27914 \cs_new_protected:cpn { __regex_compile_ \c_right_brace_str : }
27915 {
27916 \__regex_if_in_cs:TF
27917 { \__regex_compile_end_cs: }
27918 { \exp_after:wN \__regex_compile_raw:N \c_right_brace_str }
27919 }
27920 \cs_new_protected:Npn \__regex_compile_end_cs:
27921 {
27922 \__regex_compile_end:
27923 \flag_clear:N \l__regex_cs_flag
27924 \__kernel_tl_set:Nx \l__regex_tmpa_tl
27925 {
27926 \exp_after:wN \__regex_compile_cs_aux:Nn \l__regex_tmp_regex
27927 \q__regex_nil \q__regex_nil \q__regex_recursion_stop
27928 }
27929 \exp_args:Ne \__regex_compile_one:n
27930 {
27931 \flag_if_raised:NTF \l__regex_cs_flag
27932 { \__regex_item_cs:n { \exp_not:o \l__regex_tmp_regex } }
27933 {
27934 \__regex_item_exact_cs:n
27935 { \tl_tail:N \l__regex_tmpa_tl }
27936 }
27937 }
27938 }
27939 \cs_new:Npn \__regex_compile_cs_aux:Nn #1#2
27940 {
27941 \cs_if_eq:NNTF #1 \__regex_branch:n
27942 {
27943 \scan_stop:
27944 \__regex_compile_cs_aux:NNnnnN #2
27945 \q__regex_nil \q__regex_nil \q__regex_nil
27946 \q__regex_nil \q__regex_nil \q__regex_nil \q__regex_recursion_stop
27947 \__regex_compile_cs_aux:Nn
27948 }
27949 {
27950 \__regex_quark_if_nil:NF #1 { \flag_ensure_raised:N \l__regex_cs_flag }
27951 \__regex_use_none_delimit_by_q_recursion_stop:w
27952 }
27953 }
27954 \cs_new:Npn \__regex_compile_cs_aux:NNnnnN #1#2#3#4#5#6
27955 {
27956 \bool_lazy_all:nTF
27957 {
27958 { \cs_if_eq_p:NN #1 \__regex_class:NnnnN }
27959 {#2}
27960 { \tl_if_head_eq_meaning_p:nN {#3} \__regex_item_caseful_equal:n }
27961 { \int_compare_p:nNn { \tl_count:n {#3} } = { 2 } }
27962 { \int_compare_p:nNn {#5} = \c_zero_int }
27963 }
27964 {
27965 \prg_replicate:nn {#4}
27966 { \char_generate:nn { \use_ii:nn #3 } {12} }
27967 \__regex_compile_cs_aux:NNnnnN
27968 }
27969 {
27970 \__regex_quark_if_nil:NF #1
27971 {
27972 \flag_ensure_raised:N \l__regex_cs_flag
27973 \__regex_use_i_delimit_by_q_recursion_stop:nw
27974 }
27975 \__regex_use_none_delimit_by_q_recursion_stop:w
27976 }
27977 }
27978 \cs_new_protected:cpn { __regex_compile_/u: } #1#2
27979 {
27980 \__regex_if_in_class_or_catcode:TF
27981 { \__regex_compile_raw_error:N u #1 #2 }
27982 {
27983 \__regex_two_if_eq:NNNNTF #1 #2 \__regex_compile_raw:N r
27984 { \__regex_compile_u_brace:NNN \__regex_compile_ur_end: }
27985 { \__regex_compile_u_brace:NNN \__regex_compile_u_end: #1 #2 }
27986 }
27987 }
27988 \cs_new:Npn \__regex_compile_u_brace:NNN #1#2#3
27989 {
27990 \__regex_two_if_eq:NNNNTF #2 #3 \__regex_compile_special:N \c_left_brace_str
27991 {
27992 \tl_set:Nn \l__regex_tmpb_tl {#1}
27993 \__kernel_tl_set:Nx \l__regex_tmpa_tl { \if_false: } \fi:
27994 \__regex_compile_u_loop:NN
27995 }
27996 {
27997 \msg_error:nn { regex } { u-missing-lbrace }
27998 \token_if_eq_meaning:NNTF #1 \__regex_compile_ur_end:
27999 { \__regex_compile_raw:N u \__regex_compile_raw:N r }
28000 { \__regex_compile_raw:N u }
28001 #2 #3
28002 }
28003 }
28004 \cs_new:Npn \__regex_compile_u_loop:NN #1#2
28005 {
28006 \token_if_eq_meaning:NNTF #1 \__regex_compile_raw:N
28007 { #2 \__regex_compile_u_loop:NN }
28008 {
28009 \token_if_eq_meaning:NNTF #1 \__regex_compile_special:N
28010 {
28011 \exp_after:wN \token_if_eq_charcode:NNTF \c_right_brace_str #2
28012 { \if_false: { \fi: } \l__regex_tmpb_tl }
28013 {
28014 \if_charcode:w \c_left_brace_str #2
28015 \msg_expandable_error:nnn { regex } { cu-lbrace } { u }
28016 \else:
28017 #2
28018 \fi:
28019 \__regex_compile_u_loop:NN
28020 }
28021 }
28022 {
28023 \if_false: { \fi: }
28024 \msg_error:nne { regex } { u-missing-rbrace } {#2}
28025 \l__regex_tmpb_tl
28026 #1 #2
28027 }
28028 }
28029 }
28030 \cs_new_protected:Npn \__regex_compile_ur_end:
28031 {
28032 \group_begin:
28033 \cs_set:Npn \__regex_group:nnnN { \__regex_group_no_capture:nnnN }
28034 \cs_set:Npn \__regex_group_resetting:nnnN { \__regex_group_no_capture:nnnN }
28035 \exp_args:NNe
28036 \group_end:
28037 \__regex_compile_ur:n { \use:c { \l__regex_tmpa_tl } }
28038 }
28039 \cs_new_protected:Npn \__regex_compile_ur:n #1
28040 {
28041 \tl_if_empty:oTF { \__regex_compile_ur_aux:w #1 {} ? ? \q__regex_nil }
28042 { \__regex_compile_if_quantifier:TFw }
28043 { \use_i:nn }
28044 {
28045 \tl_build_put_right:Nn \l__regex_build_tl
28046 { \__regex_group_no_capture:nnnN { \if_false: } \fi: #1 }
28047 \__regex_compile_quantifier:w
28048 }
28049 { \tl_build_put_right:Nn \l__regex_build_tl { \use_ii:nn #1 } }
28050 }
28051 \cs_new:Npn \__regex_compile_ur_aux:w \__regex_branch:n #1#2#3 \q__regex_nil {#2}
28052 \cs_new_protected:Npn \__regex_compile_u_end:
28053 {
28054 \__regex_compile_if_quantifier:TFw
28055 {
28056 \tl_build_put_right:Nn \l__regex_build_tl
28057 {
28058 \__regex_group_no_capture:nnnN { \if_false: } \fi:
28059 \__regex_branch:n { \if_false: } \fi:
28060 }
28061 \__regex_compile_u_payload:
28062 \tl_build_put_right:Nn \l__regex_build_tl { \if_false: { \fi: } }
28063 \__regex_compile_quantifier:w
28064 }
28065 { \__regex_compile_u_payload: }
28066 }
28067 \cs_new_protected:Npn \__regex_compile_u_payload:
28068 {
28069 \tl_set:Nv \l__regex_tmpa_tl { \l__regex_tmpa_tl }
28070 \if_int_compare:w \l__regex_mode_int = \c__regex_outer_mode_int
28071 \__regex_compile_u_not_cs:
28072 \else:
28073 \__regex_compile_u_in_cs:
28074 \fi:
28075 }
28076 \cs_new_protected:Npn \__regex_compile_u_in_cs:
28077 {
28078 \__kernel_tl_gset:Nx \g__regex_tmp_tl
28079 {
28080 \exp_args:No \__kernel_str_to_other_fast:n
28081 { \l__regex_tmpa_tl }
28082 }
28083 \tl_build_put_right:Ne \l__regex_build_tl
28084 {
28085 \tl_map_function:NN \g__regex_tmp_tl
28086 \__regex_compile_u_in_cs_aux:n
28087 }
28088 }
28089 \cs_new:Npn \__regex_compile_u_in_cs_aux:n #1
28090 {
28091 \__regex_class:NnnnN \c_true_bool
28092 { \__regex_item_caseful_equal:n { \int_value:w `#1 } }
28093 { 1 } { 0 } \c_false_bool
28094 }
28095 \cs_new_protected:Npn \__regex_compile_u_not_cs:
28096 {
28097 \tl_analysis_map_inline:Nn \l__regex_tmpa_tl
28098 {
28099 \tl_build_put_right:Ne \l__regex_build_tl
28100 {
28101 \__regex_class:NnnnN \c_true_bool
28102 {
28103 \if_int_compare:w "##3 = \c_zero_int
28104 \__regex_item_exact_cs:n
28105 { \exp_after:wN \cs_to_str:N ##1 }
28106 \else:
28107 \__regex_item_exact:nn { \int_value:w "##3 } { ##2 }
28108 \fi:
28109 }
28110 { 1 } { 0 } \c_false_bool
28111 }
28112 }
28113 }
28114 \cs_new_protected:cpn { __regex_compile_/K: }
28115 {
28116 \int_compare:nNnTF \l__regex_mode_int = \c__regex_outer_mode_int
28117 { \tl_build_put_right:Nn \l__regex_build_tl { \__regex_command_K: } }
28118 { \__regex_compile_raw_error:N K }
28119 }
28120 \cs_new:Npn \__regex_clean_bool:n #1
28121 {
28122 \tl_if_single:nTF {#1}
28123 { \bool_if:NTF #1 \c_true_bool \c_false_bool }
28124 { \c_true_bool }
28125 }
28126 \cs_new:Npn \__regex_clean_int:n #1
28127 {
28128 \tl_if_head_eq_meaning:nNTF {#1} -
28129 { - \exp_args:No \__regex_clean_int:n { \use_none:n #1 } }
28130 { \int_eval:n { 0 \str_map_function:nN {#1} \__regex_clean_int_aux:N } }
28131 }
28132 \cs_new:Npn \__regex_clean_int_aux:N #1
28133 {
28134 \if_int_compare:w \c_one_int < 1 #1 ~
28135 #1
28136 \else:
28137 \str_map_break:n
28138 \fi:
28139 }
28140 \cs_new:Npn \__regex_clean_regex:n #1
28141 {
28142 \__regex_clean_regex_loop:w #1
28143 \__regex_branch:n { \q_recursion_tail } \q_recursion_stop
28144 }
28145 \cs_new:Npn \__regex_clean_regex_loop:w #1 \__regex_branch:n #2
28146 {
28147 \quark_if_recursion_tail_stop:n {#2}
28148 \__regex_branch:n { \__regex_clean_branch:n {#2} }
28149 \__regex_clean_regex_loop:w
28150 }
28151 \cs_new:Npn \__regex_clean_branch:n #1
28152 {
28153 \__regex_clean_branch_loop:n #1
28154 ? ? ? ? ? ? \prg_break_point:
28155 }
28156 \cs_new:Npn \__regex_clean_branch_loop:n #1
28157 {
28158 \tl_if_single:nF {#1} \prg_break:
28159 \token_case_meaning:NnF #1
28160 {
28161 \__regex_command_K: { #1 \__regex_clean_branch_loop:n }
28162 \__regex_assertion:Nn { #1 \__regex_clean_assertion:Nn }
28163 \__regex_class:NnnnN { #1 \__regex_clean_class:NnnnN }
28164 \__regex_group:nnnN { #1 \__regex_clean_group:nnnN }
28165 \__regex_group_no_capture:nnnN { #1 \__regex_clean_group:nnnN }
28166 \__regex_group_resetting:nnnN { #1 \__regex_clean_group:nnnN }
28167 }
28168 \prg_break:
28169 }
28170 \cs_new:Npn \__regex_clean_assertion:Nn #1#2
28171 {
28172 \__regex_clean_bool:n {#1}
28173 \tl_if_single:nF {#2} { { \__regex_A_test: } \prg_break: }
28174 \token_case_meaning:NnTF #2
28175 {
28176 \__regex_A_test: { }
28177 \__regex_G_test: { }
28178 \__regex_Z_test: { }
28179 \__regex_b_test: { }
28180 }
28181 { {#2} }
28182 { { \__regex_A_test: } \prg_break: }
28183 \__regex_clean_branch_loop:n
28184 }
28185 \cs_new:Npn \__regex_clean_class:NnnnN #1#2#3#4#5
28186 {
28187 \__regex_clean_bool:n {#1}
28188 { \__regex_clean_class:n {#2} }
28189 { \int_max:nn \c_zero_int { \__regex_clean_int:n {#3} } }
28190 { \int_max:nn { -\c_one_int } { \__regex_clean_int:n {#4} } }
28191 \__regex_clean_bool:n {#5}
28192 \__regex_clean_branch_loop:n
28193 }
28194 \cs_new:Npn \__regex_clean_group:nnnN #1#2#3#4
28195 {
28196 { \__regex_clean_regex:n {#1} }
28197 { \int_max:nn \c_zero_int { \__regex_clean_int:n {#2} } }
28198 { \int_max:nn { -\c_one_int } { \__regex_clean_int:n {#3} } }
28199 \__regex_clean_bool:n {#4}
28200 \__regex_clean_branch_loop:n
28201 }
28202 \cs_new:Npn \__regex_clean_class:n #1
28203 { \__regex_clean_class_loop:nnn #1 ????? \prg_break_point: }
28204 \cs_new:Npn \__regex_clean_class_loop:nnn #1#2#3
28205 {
28206 \tl_if_single:nF {#1} \prg_break:
28207 \token_case_meaning:NnTF #1
28208 {
28209 \__regex_item_cs:n { #1 { \__regex_clean_regex:n {#2} } }
28210 \__regex_item_exact_cs:n { #1 { \__regex_clean_exact_cs:n {#2} } }
28211 \__regex_item_caseful_equal:n { #1 { \__regex_clean_int:n {#2} } }
28212 \__regex_item_caseless_equal:n { #1 { \__regex_clean_int:n {#2} } }
28213 \__regex_item_reverse:n { #1 { \__regex_clean_class:n {#2} } }
28214 }
28215 { \__regex_clean_class_loop:nnn {#3} }
28216 {
28217 \token_case_meaning:NnTF #1
28218 {
28219 \__regex_item_caseful_range:nn { }
28220 \__regex_item_caseless_range:nn { }
28221 \__regex_item_exact:nn { }
28222 }
28223 {
28224 #1 { \__regex_clean_int:n {#2} } { \__regex_clean_int:n {#3} }
28225 \__regex_clean_class_loop:nnn
28226 }
28227 {
28228 \token_case_meaning:NnTF #1
28229 {
28230 \__regex_item_catcode:nT { }
28231 \__regex_item_catcode_reverse:nT { }
28232 }
28233 {
28234 #1 { \__regex_clean_int:n {#2} } { \__regex_clean_class:n {#3} }
28235 \__regex_clean_class_loop:nnn
28236 }
28237 {
28238 \exp_args:Ne \str_case:nnTF
28239 {
28240 \exp_args:Ne \str_range:nnn
28241 { \cs_to_str:N #1 } \c_one_int { 13 }
28242 }
28243 {
28244 { __regex_prop_ } { }
28245 { __regex_posix } { }
28246 }
28247 {
28248 #1
28249 \__regex_clean_class_loop:nnn {#2} {#3}
28250 }
28251 \prg_break:
28252 }
28253 }
28254 }
28255 }
28256 \cs_new:Npn \__regex_clean_exact_cs:n #1
28257 {
28258 \exp_last_unbraced:Nf \use_none:n
28259 {
28260 \__regex_clean_exact_cs:w #1
28261 \scan_stop: \q_recursion_tail \scan_stop:
28262 \q_recursion_stop
28263 }
28264 }
28265 \cs_new:Npn \__regex_clean_exact_cs:w #1 \scan_stop:
28266 {
28267 \quark_if_recursion_tail_stop:n {#1}
28268 \scan_stop: \tl_to_str:n {#1}
28269 \__regex_clean_exact_cs:w
28270 }
28271 \cs_new_protected:Npn \__regex_show:N #1
28272 {
28273 \group_begin:
28274 \tl_build_begin:N \l__regex_build_tl
28275 \cs_set_protected:Npn \__regex_branch:n
28276 {
28277 \seq_pop_right:NN \l__regex_show_prefix_seq
28278 \l__regex_tmpa_tl
28279 \__regex_show_one:n { +-branch }
28280 \seq_put_right:No \l__regex_show_prefix_seq
28281 \l__regex_tmpa_tl
28282 \use:n
28283 }
28284 \cs_set_protected:Npn \__regex_group:nnnN
28285 { \__regex_show_group_aux:nnnnN { } }
28286 \cs_set_protected:Npn \__regex_group_no_capture:nnnN
28287 { \__regex_show_group_aux:nnnnN { ~(no~capture) } }
28288 \cs_set_protected:Npn \__regex_group_resetting:nnnN
28289 { \__regex_show_group_aux:nnnnN { ~(resetting) } }
28290 \cs_set_eq:NN \__regex_class:NnnnN \__regex_show_class:NnnnN
28291 \cs_set_protected:Npn \__regex_command_K:
28292 { \__regex_show_one:n { reset~match~start~(\iow_char:N\\K) } }
28293 \cs_set_protected:Npn \__regex_assertion:Nn ##1##2
28294 {
28295 \__regex_show_one:n
28296 { \bool_if:NF ##1 { negative~ } assertion:~##2 }
28297 }
28298 \cs_set:Npn \__regex_b_test: { word~boundary }
28299 \cs_set:Npn \__regex_Z_test: { anchor~at~end~(\iow_char:N\\Z) }
28300 \cs_set:Npn \__regex_A_test: { anchor~at~start~(\iow_char:N\\A) }
28301 \cs_set:Npn \__regex_G_test: { anchor~at~start~of~match~(\iow_char:N\\G) }
28302 \cs_set_protected:Npn \__regex_item_caseful_equal:n ##1
28303 { \__regex_show_one:n { char~code~\__regex_show_char:n{##1} } }
28304 \cs_set_protected:Npn \__regex_item_caseful_range:nn ##1##2
28305 {
28306 \__regex_show_one:n
28307 { range~[\__regex_show_char:n{##1}, \__regex_show_char:n{##2}] }
28308 }
28309 \cs_set_protected:Npn \__regex_item_caseless_equal:n ##1
28310 { \__regex_show_one:n { char~code~\__regex_show_char:n{##1}~(caseless) } }
28311 \cs_set_protected:Npn \__regex_item_caseless_range:nn ##1##2
28312 {
28313 \__regex_show_one:n
28314 { Range~[\__regex_show_char:n{##1}, \__regex_show_char:n{##2}]~(caseless) }
28315 }
28316 \cs_set_protected:Npn \__regex_item_catcode:nT
28317 { \__regex_show_item_catcode:NnT \c_true_bool }
28318 \cs_set_protected:Npn \__regex_item_catcode_reverse:nT
28319 { \__regex_show_item_catcode:NnT \c_false_bool }
28320 \cs_set_protected:Npn \__regex_item_reverse:n
28321 { \__regex_show_scope:nn { Reversed~match } }
28322 \cs_set_protected:Npn \__regex_item_exact:nn ##1##2
28323 { \__regex_show_one:n { char~\__regex_show_char:n{##2},~catcode~##1 } }
28324 \cs_set_eq:NN \__regex_item_exact_cs:n \__regex_show_item_exact_cs:n
28325 \cs_set_protected:Npn \__regex_item_cs:n
28326 { \__regex_show_scope:nn { control~sequence } }
28327 \cs_set:cpn { __regex_prop_.: } { \__regex_show_one:n { any~token } }
28328 \seq_clear:N \l__regex_show_prefix_seq
28329 \__regex_show_push:n { ~ }
28330 \cs_if_exist_use:N #1
28331 \tl_build_end:N \l__regex_build_tl
28332 \exp_args:NNNo
28333 \group_end:
28334 \tl_set:Nn \l__regex_tmpa_tl { \l__regex_build_tl }
28335 }
28336 \cs_new:Npn \__regex_show_char:n #1
28337 {
28338 \int_eval:n {#1}
28339 \int_compare:nT { 32 <= #1 <= 126 }
28340 { ~ ( \char_generate:nn {#1} {12} ) }
28341 }
28342 \cs_new_protected:Npn \__regex_show_one:n #1
28343 {
28344 \int_incr:N \l__regex_show_lines_int
28345 \tl_build_put_right:Ne \l__regex_build_tl
28346 {
28347 \exp_not:N \iow_newline:
28348 \seq_map_function:NN \l__regex_show_prefix_seq \use:n
28349 #1
28350 }
28351 }
28352 \cs_new_protected:Npn \__regex_show_push:n #1
28353 { \seq_put_right:Ne \l__regex_show_prefix_seq { #1 ~ } }
28354 \cs_new_protected:Npn \__regex_show_pop:
28355 { \seq_pop_right:NN \l__regex_show_prefix_seq \l__regex_tmpa_tl }
28356 \cs_new_protected:Npn \__regex_show_scope:nn #1#2
28357 {
28358 \__regex_show_one:n {#1}
28359 \__regex_show_push:n { ~ }
28360 #2
28361 \__regex_show_pop:
28362 }
28363 \cs_new_protected:Npn \__regex_show_group_aux:nnnnN #1#2#3#4#5
28364 {
28365 \__regex_show_one:n { ,-group~begin #1 }
28366 \__regex_show_push:n { | }
28367 \use_ii:nn #2
28368 \__regex_show_pop:
28369 \__regex_show_one:n
28370 { `-group~end \__regex_msg_repeated:nnN {#3} {#4} #5 }
28371 }
28372 \cs_new:Npn \__regex_show_class:NnnnN #1#2#3#4#5
28373 {
28374 \group_begin:
28375 \tl_build_begin:N \l__regex_build_tl
28376 \int_zero:N \l__regex_show_lines_int
28377 \__regex_show_push:n {~}
28378 #2
28379 \int_compare:nTF { \l__regex_show_lines_int = \c_zero_int }
28380 {
28381 \group_end:
28382 \__regex_show_one:n { \bool_if:NTF #1 { Fail } { Pass } }
28383 }
28384 {
28385 \bool_if:nTF
28386 { #1 && \int_compare_p:n { \l__regex_show_lines_int = \c_one_int } }
28387 {
28388 \group_end:
28389 #2
28390 \tl_build_put_right:Nn \l__regex_build_tl
28391 { \__regex_msg_repeated:nnN {#3} {#4} #5 }
28392 }
28393 {
28394 \tl_build_end:N \l__regex_build_tl
28395 \exp_args:NNNo
28396 \group_end:
28397 \tl_set:Nn \l__regex_tmpa_tl \l__regex_build_tl
28398 \__regex_show_one:n
28399 {
28400 \bool_if:NTF #1 { Match } { Don't~match }
28401 \__regex_msg_repeated:nnN {#3} {#4} #5
28402 }
28403 \tl_build_put_right:Ne \l__regex_build_tl
28404 { \exp_not:o \l__regex_tmpa_tl }
28405 }
28406 }
28407 }
28408 \cs_new_protected:Npn \__regex_show_item_catcode:NnT #1#2
28409 {
28410 \seq_set_split:Nnn \l__regex_tmp_seq { } { CBEMTPUDSLOA }
28411 \seq_set_filter:NNn \l__regex_tmp_seq \l__regex_tmp_seq
28412 { \int_if_odd_p:n { #2 / \int_use:c { c__regex_catcode_##1_int } } }
28413 \__regex_show_scope:nn
28414 {
28415 categories~
28416 \seq_map_function:NN \l__regex_tmp_seq \use:n
28417 , ~
28418 \bool_if:NF #1 { negative~ } class
28419 }
28420 }
28421 \cs_new_protected:Npn \__regex_show_item_exact_cs:n #1
28422 {
28423 \seq_set_split:Nnn \l__regex_tmp_seq { \scan_stop: } {#1}
28424 \seq_set_map_e:NNn \l__regex_tmp_seq
28425 \l__regex_tmp_seq { \iow_char:N\\##1 }
28426 \__regex_show_one:n
28427 { control~sequence~ \seq_use:Nn \l__regex_tmp_seq { ~or~ } }
28428 }
28429 \int_new:N \l__regex_min_state_int
28430 \int_set:Nn \l__regex_min_state_int { 1 }
28431 \int_new:N \l__regex_max_state_int
28432 \int_new:N \l__regex_left_state_int
28433 \int_new:N \l__regex_right_state_int
28434 \seq_new:N \l__regex_left_state_seq
28435 \seq_new:N \l__regex_right_state_seq
28436 \int_new:N \l__regex_capturing_group_int
28437 \cs_new_protected:Npn \__regex_build:n
28438 { \__regex_build_aux:Nn \c_true_bool }
28439 \cs_new_protected:Npn \__regex_build:N
28440 { \__regex_build_aux:NN \c_true_bool }
28441 \cs_new_protected:Npn \__regex_build_aux:Nn #1#2
28442 {
28443 \__regex_compile:n {#2}
28444 \__regex_build_aux:NN #1 \l__regex_tmp_regex
28445 }
28446 \cs_new_protected:Npn \__regex_build_aux:NN #1#2
28447 {
28448 \__regex_standard_escapechar:
28449 \int_zero:N \l__regex_capturing_group_int
28450 \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int
28451 \__regex_build_new_state:
28452 \__regex_build_new_state:
28453 \__regex_toks_put_right:Nn \l__regex_left_state_int
28454 { \__regex_action_start_wildcard:N #1 }
28455 \__regex_group:nnnN {#2} { 1 } { 0 } \c_false_bool
28456 \__regex_toks_put_right:Nn \l__regex_right_state_int
28457 { \__regex_action_success: }
28458 }
28459 \int_new:N \g__regex_case_int
28460 \int_new:N \l__regex_case_max_group_int
28461 \cs_new_protected:Npn \__regex_case_build:n #1
28462 {
28463 \__regex_case_build_aux:Nn \c_true_bool {#1}
28464 \int_gzero:N \g__regex_case_int
28465 }
28466 \cs_generate_variant:Nn \__regex_case_build:n { e }
28467 \cs_new_protected:Npn \__regex_case_build_aux:Nn #1#2
28468 {
28469 \__regex_standard_escapechar:
28470 \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int
28471 \__regex_build_new_state:
28472 \__regex_build_new_state:
28473 \__regex_toks_put_right:Nn \l__regex_left_state_int
28474 { \__regex_action_start_wildcard:N #1 }
28475 %
28476 \__regex_build_new_state:
28477 \__regex_toks_put_left:Ne \l__regex_left_state_int
28478 { \__regex_action_submatch:nN \c_zero_int < }
28479 \__regex_push_lr_states:
28480 \int_zero:N \l__regex_case_max_group_int
28481 \int_gzero:N \g__regex_case_int
28482 \tl_map_inline:nn {#2}
28483 {
28484 \int_gincr:N \g__regex_case_int
28485 \__regex_case_build_loop:n {##1}
28486 }
28487 \int_set_eq:NN \l__regex_capturing_group_int \l__regex_case_max_group_int
28488 \__regex_pop_lr_states:
28489 }
28490 \cs_new_protected:Npn \__regex_case_build_loop:n #1
28491 {
28492 \int_set_eq:NN \l__regex_capturing_group_int \c_one_int
28493 \__regex_compile_use:n {#1}
28494 \int_set:Nn \l__regex_case_max_group_int
28495 { \int_max:nn \l__regex_case_max_group_int \l__regex_capturing_group_int }
28496 \seq_pop:NN \l__regex_right_state_seq \l__regex_tmpa_tl
28497 \int_set:Nn \l__regex_right_state_int \l__regex_tmpa_tl
28498 \__regex_toks_put_left:Ne \l__regex_right_state_int
28499 {
28500 \__regex_action_submatch:nN \c_zero_int >
28501 \int_gset:Nn \g__regex_case_int
28502 { \int_use:N \g__regex_case_int }
28503 \__regex_action_success:
28504 }
28505 \__regex_toks_clear:N \l__regex_max_state_int
28506 \seq_push:No \l__regex_right_state_seq
28507 { \int_use:N \l__regex_max_state_int }
28508 \int_incr:N \l__regex_max_state_int
28509 }
28510 \cs_new_protected:Npn \__regex_build_for_cs:n #1
28511 {
28512 \int_set_eq:NN \l__regex_min_state_int \l__regex_max_state_int
28513 \__regex_build_new_state:
28514 \__regex_build_new_state:
28515 \__regex_push_lr_states:
28516 #1
28517 \__regex_pop_lr_states:
28518 \__regex_toks_put_right:Nn \l__regex_right_state_int
28519 {
28520 \if_int_compare:w -2 = \l__regex_curr_char_int
28521 \exp_after:wN \__regex_action_success:
28522 \fi:
28523 }
28524 }
28525 \cs_new_protected:Npn \__regex_push_lr_states:
28526 {
28527 \seq_push:No \l__regex_left_state_seq
28528 { \int_use:N \l__regex_left_state_int }
28529 \seq_push:No \l__regex_right_state_seq
28530 { \int_use:N \l__regex_right_state_int }
28531 }
28532 \cs_new_protected:Npn \__regex_pop_lr_states:
28533 {
28534 \seq_pop:NN \l__regex_left_state_seq \l__regex_tmpa_tl
28535 \int_set:Nn \l__regex_left_state_int \l__regex_tmpa_tl
28536 \seq_pop:NN \l__regex_right_state_seq \l__regex_tmpa_tl
28537 \int_set:Nn \l__regex_right_state_int \l__regex_tmpa_tl
28538 }
28539 \cs_new_protected:Npn \__regex_build_transition_left:NNN #1#2#3
28540 { \__regex_toks_put_left:Ne #2 { #1 { \tex_the:D \__regex_int_eval:w #3 - #2 } } }
28541 \cs_new_protected:Npn \__regex_build_transition_right:nNn #1#2#3
28542 { \__regex_toks_put_right:Ne #2 { #1 { \tex_the:D \__regex_int_eval:w #3 - #2 } } }
28543 \cs_new_protected:Npn \__regex_build_new_state:
28544 {
28545 \__regex_toks_clear:N \l__regex_max_state_int
28546 \int_set_eq:NN \l__regex_left_state_int \l__regex_right_state_int
28547 \int_set_eq:NN \l__regex_right_state_int \l__regex_max_state_int
28548 \int_incr:N \l__regex_max_state_int
28549 }
28550 \cs_new_protected:Npn \__regex_build_transitions_laziness:NNNNN #1#2#3#4#5
28551 {
28552 \__regex_build_new_state:
28553 \__regex_toks_put_right:Ne \l__regex_left_state_int
28554 {
28555 \if_meaning:w \c_true_bool #1
28556 #2 { \tex_the:D \__regex_int_eval:w #3 - \l__regex_left_state_int }
28557 #4 { \tex_the:D \__regex_int_eval:w #5 - \l__regex_left_state_int }
28558 \else:
28559 #4 { \tex_the:D \__regex_int_eval:w #5 - \l__regex_left_state_int }
28560 #2 { \tex_the:D \__regex_int_eval:w #3 - \l__regex_left_state_int }
28561 \fi:
28562 }
28563 }
28564 \cs_new_protected:Npn \__regex_class:NnnnN #1#2#3#4#5
28565 {
28566 \cs_set:Npe \__regex_tests_action_cost:n ##1
28567 {
28568 \exp_not:n { \exp_not:n {#2} }
28569 \bool_if:NTF #1
28570 { \__regex_break_point:TF { \__regex_action_cost:n {##1} } { } }
28571 { \__regex_break_point:TF { } { \__regex_action_cost:n {##1} } }
28572 }
28573 \if_case:w - #4 \exp_stop_f:
28574 \__regex_class_repeat:n {#3}
28575 \or: \__regex_class_repeat:nN {#3} #5
28576 \else: \__regex_class_repeat:nnN {#3} {#4} #5
28577 \fi:
28578 }
28579 \cs_new:Npn \__regex_tests_action_cost:n { \__regex_action_cost:n }
28580 \cs_new_protected:Npn \__regex_class_repeat:n #1
28581 {
28582 \prg_replicate:nn {#1}
28583 {
28584 \__regex_build_new_state:
28585 \__regex_build_transition_right:nNn \__regex_tests_action_cost:n
28586 \l__regex_left_state_int \l__regex_right_state_int
28587 }
28588 }
28589 \cs_new_protected:Npn \__regex_class_repeat:nN #1#2
28590 {
28591 \if_int_compare:w #1 = \c_zero_int
28592 \__regex_build_transitions_laziness:NNNNN #2
28593 \__regex_action_free:n \l__regex_right_state_int
28594 \__regex_tests_action_cost:n \l__regex_left_state_int
28595 \else:
28596 \__regex_class_repeat:n {#1}
28597 \int_set_eq:NN \l__regex_tmpa_int \l__regex_left_state_int
28598 \__regex_build_transitions_laziness:NNNNN #2
28599 \__regex_action_free:n \l__regex_right_state_int
28600 \__regex_action_free:n \l__regex_tmpa_int
28601 \fi:
28602 }
28603 \cs_new_protected:Npn \__regex_class_repeat:nnN #1#2#3
28604 {
28605 \__regex_class_repeat:n {#1}
28606 \int_set:Nn \l__regex_tmpa_int
28607 { \l__regex_max_state_int + #2 - \c_one_int }
28608 \prg_replicate:nn { #2 }
28609 {
28610 \__regex_build_transitions_laziness:NNNNN #3
28611 \__regex_action_free:n \l__regex_tmpa_int
28612 \__regex_tests_action_cost:n \l__regex_right_state_int
28613 }
28614 }
28615 \cs_new_protected:Npn \__regex_group_aux:nnnnN #1#2#3#4#5
28616 {
28617 \if_int_compare:w #3 = \c_zero_int
28618 \__regex_build_new_state:
28619 \__regex_build_transition_right:nNn \__regex_action_free_group:n
28620 \l__regex_left_state_int \l__regex_right_state_int
28621 \fi:
28622 \__regex_build_new_state:
28623 \__regex_push_lr_states:
28624 #2
28625 \__regex_pop_lr_states:
28626 \if_case:w - #4 \exp_stop_f:
28627 \__regex_group_repeat:nn {#1} {#3}
28628 \or: \__regex_group_repeat:nnN {#1} {#3} #5
28629 \else: \__regex_group_repeat:nnnN {#1} {#3} {#4} #5
28630 \fi:
28631 }
28632 \cs_new_protected:Npn \__regex_group:nnnN #1
28633 {
28634 \exp_args:No \__regex_group_aux:nnnnN
28635 { \int_use:N \l__regex_capturing_group_int }
28636 {
28637 \int_incr:N \l__regex_capturing_group_int
28638 #1
28639 }
28640 }
28641 \cs_new_protected:Npn \__regex_group_no_capture:nnnN
28642 { \__regex_group_aux:nnnnN { -1 } }
28643 \cs_new_protected:Npn \__regex_group_resetting:nnnN #1
28644 {
28645 \__regex_group_aux:nnnnN { -1 }
28646 {
28647 \exp_args:Noo \__regex_group_resetting_loop:nnNn
28648 { \int_use:N \l__regex_capturing_group_int }
28649 { \int_use:N \l__regex_capturing_group_int }
28650 #1
28651 { ?? \prg_break:n } { }
28652 \prg_break_point:
28653 }
28654 }
28655 \cs_new_protected:Npn \__regex_group_resetting_loop:nnNn #1#2#3#4
28656 {
28657 \use_none:nn #3 { \int_set:Nn \l__regex_capturing_group_int {#1} }
28658 \int_set:Nn \l__regex_capturing_group_int {#2}
28659 #3 {#4}
28660 \exp_args:Ne \__regex_group_resetting_loop:nnNn
28661 { \int_max:nn {#1} \l__regex_capturing_group_int }
28662 {#2}
28663 }
28664 \cs_new_protected:Npn \__regex_branch:n #1
28665 {
28666 \__regex_build_new_state:
28667 \seq_get:NN \l__regex_left_state_seq \l__regex_tmpa_tl
28668 \int_set:Nn \l__regex_left_state_int \l__regex_tmpa_tl
28669 \__regex_build_transition_right:nNn \__regex_action_free:n
28670 \l__regex_left_state_int \l__regex_right_state_int
28671 #1
28672 \seq_get:NN \l__regex_right_state_seq \l__regex_tmpa_tl
28673 \__regex_build_transition_right:nNn \__regex_action_free:n
28674 \l__regex_right_state_int \l__regex_tmpa_tl
28675 }
28676 \cs_new_protected:Npn \__regex_group_repeat:nn #1#2
28677 {
28678 \if_int_compare:w #2 = \c_zero_int
28679 \int_set:Nn \l__regex_max_state_int
28680 { \l__regex_left_state_int - \c_one_int }
28681 \__regex_build_new_state:
28682 \else:
28683 \__regex_group_repeat_aux:n {#2}
28684 \__regex_group_submatches:nNN {#1}
28685 \l__regex_tmpa_int \l__regex_right_state_int
28686 \__regex_build_new_state:
28687 \fi:
28688 }
28689 \cs_new_protected:Npn \__regex_group_submatches:nNN #1#2#3
28690 {
28691 \if_int_compare:w #1 > - \c_one_int
28692 \__regex_toks_put_left:Ne #2 { \__regex_action_submatch:nN {#1} < }
28693 \__regex_toks_put_left:Ne #3 { \__regex_action_submatch:nN {#1} > }
28694 \fi:
28695 }
28696 \cs_new_protected:Npn \__regex_group_repeat_aux:n #1
28697 {
28698 \__regex_build_transition_right:nNn \__regex_action_free:n
28699 \l__regex_right_state_int \l__regex_max_state_int
28700 \int_set_eq:NN \l__regex_tmpa_int \l__regex_left_state_int
28701 \int_set_eq:NN \l__regex_tmpb_int \l__regex_max_state_int
28702 \if_int_compare:w \__regex_int_eval:w #1 > \c_one_int
28703 \int_set:Nn \l__regex_tmpc_int
28704 {
28705 ( #1 - \c_one_int )
28706 * ( \l__regex_tmpb_int - \l__regex_tmpa_int )
28707 }
28708 \int_add:Nn \l__regex_right_state_int \l__regex_tmpc_int
28709 \int_add:Nn \l__regex_max_state_int \l__regex_tmpc_int
28710 \__regex_toks_memcpy:NNn
28711 \l__regex_tmpb_int
28712 \l__regex_tmpa_int
28713 \l__regex_tmpc_int
28714 \fi:
28715 }
28716 \cs_new_protected:Npn \__regex_group_repeat:nnN #1#2#3
28717 {
28718 \if_int_compare:w #2 = \c_zero_int
28719 \__regex_group_submatches:nNN {#1}
28720 \l__regex_left_state_int \l__regex_right_state_int
28721 \int_set:Nn \l__regex_tmpa_int
28722 { \l__regex_left_state_int - \c_one_int }
28723 \__regex_build_transition_right:nNn \__regex_action_free:n
28724 \l__regex_right_state_int \l__regex_tmpa_int
28725 \__regex_build_new_state:
28726 \if_meaning:w \c_true_bool #3
28727 \__regex_build_transition_left:NNN \__regex_action_free:n
28728 \l__regex_tmpa_int \l__regex_right_state_int
28729 \else:
28730 \__regex_build_transition_right:nNn \__regex_action_free:n
28731 \l__regex_tmpa_int \l__regex_right_state_int
28732 \fi:
28733 \else:
28734 \__regex_group_repeat_aux:n {#2}
28735 \__regex_group_submatches:nNN {#1}
28736 \l__regex_tmpa_int \l__regex_right_state_int
28737 \if_meaning:w \c_true_bool #3
28738 \__regex_build_transition_right:nNn \__regex_action_free_group:n
28739 \l__regex_right_state_int \l__regex_tmpa_int
28740 \else:
28741 \__regex_build_transition_left:NNN \__regex_action_free_group:n
28742 \l__regex_right_state_int \l__regex_tmpa_int
28743 \fi:
28744 \__regex_build_new_state:
28745 \fi:
28746 }
28747 \cs_new_protected:Npn \__regex_group_repeat:nnnN #1#2#3#4
28748 {
28749 \__regex_group_submatches:nNN {#1}
28750 \l__regex_left_state_int \l__regex_right_state_int
28751 \__regex_group_repeat_aux:n { #2 + #3 }
28752 \if_meaning:w \c_true_bool #4
28753 \int_set_eq:NN \l__regex_left_state_int \l__regex_max_state_int
28754 \prg_replicate:nn { #3 }
28755 {
28756 \int_sub:Nn \l__regex_left_state_int
28757 { \l__regex_tmpb_int - \l__regex_tmpa_int }
28758 \__regex_build_transition_left:NNN \__regex_action_free:n
28759 \l__regex_left_state_int \l__regex_max_state_int
28760 }
28761 \else:
28762 \prg_replicate:nn { #3 - \c_one_int }
28763 {
28764 \int_sub:Nn \l__regex_right_state_int
28765 { \l__regex_tmpb_int - \l__regex_tmpa_int }
28766 \__regex_build_transition_right:nNn \__regex_action_free:n
28767 \l__regex_right_state_int \l__regex_max_state_int
28768 }
28769 \if_int_compare:w #2 = \c_zero_int
28770 \int_set:Nn \l__regex_right_state_int
28771 { \l__regex_left_state_int - \c_one_int }
28772 \else:
28773 \int_sub:Nn \l__regex_right_state_int
28774 { \l__regex_tmpb_int - \l__regex_tmpa_int }
28775 \fi:
28776 \__regex_build_transition_right:nNn \__regex_action_free:n
28777 \l__regex_right_state_int \l__regex_max_state_int
28778 \fi:
28779 \__regex_build_new_state:
28780 }
28781 \cs_new_protected:Npn \__regex_assertion:Nn #1#2
28782 {
28783 \__regex_build_new_state:
28784 \__regex_toks_put_right:Ne \l__regex_left_state_int
28785 {
28786 \exp_not:n {#2}
28787 \__regex_break_point:TF
28788 \bool_if:NF #1 { { } }
28789 {
28790 \__regex_action_free:n
28791 {
28792 \tex_the:D \__regex_int_eval:w
28793 \l__regex_right_state_int - \l__regex_left_state_int
28794 }
28795 }
28796 \bool_if:NT #1 { { } }
28797 }
28798 }
28799 \cs_new_protected:Npn \__regex_b_test:
28800 {
28801 \group_begin:
28802 \int_set_eq:NN \l__regex_curr_char_int \l__regex_last_char_int
28803 \__regex_prop_w:
28804 \__regex_break_point:TF
28805 { \group_end: \__regex_item_reverse:n { \__regex_prop_w: } }
28806 { \group_end: \__regex_prop_w: }
28807 }
28808 \cs_new_protected:Npn \__regex_Z_test:
28809 {
28810 \if_int_compare:w -2 = \l__regex_curr_char_int
28811 \exp_after:wN \__regex_break_true:w
28812 \fi:
28813 }
28814 \cs_new_protected:Npn \__regex_A_test:
28815 {
28816 \if_int_compare:w -2 = \l__regex_last_char_int
28817 \exp_after:wN \__regex_break_true:w
28818 \fi:
28819 }
28820 \cs_new_protected:Npn \__regex_G_test:
28821 {
28822 \if_int_compare:w \l__regex_curr_pos_int = \l__regex_start_pos_int
28823 \exp_after:wN \__regex_break_true:w
28824 \fi:
28825 }
28826 \cs_new_protected:Npn \__regex_command_K:
28827 {
28828 \__regex_build_new_state:
28829 \__regex_toks_put_right:Ne \l__regex_left_state_int
28830 {
28831 \__regex_action_submatch:nN \c_zero_int <
28832 \bool_set_true:N \l__regex_fresh_thread_bool
28833 \__regex_action_free:n
28834 {
28835 \tex_the:D \__regex_int_eval:w
28836 \l__regex_right_state_int - \l__regex_left_state_int
28837 }
28838 \bool_set_false:N \l__regex_fresh_thread_bool
28839 }
28840 }
28841 \int_new:N \l__regex_min_pos_int
28842 \int_new:N \l__regex_max_pos_int
28843 \int_new:N \l__regex_curr_pos_int
28844 \int_new:N \l__regex_start_pos_int
28845 \int_new:N \l__regex_success_pos_int
28846 \int_new:N \l__regex_curr_char_int
28847 \int_new:N \l__regex_curr_catcode_int
28848 \tl_new:N \l__regex_curr_token_tl
28849 \int_new:N \l__regex_last_char_int
28850 \int_new:N \l__regex_last_char_success_int
28851 \int_new:N \l__regex_case_changed_char_int
28852 \int_new:N \l__regex_curr_state_int
28853 \tl_new:N \l__regex_curr_submatches_tl
28854 \tl_new:N \l__regex_success_submatches_tl
28855 \int_new:N \l__regex_step_int
28856 \int_new:N \l__regex_min_thread_int
28857 \int_new:N \l__regex_max_thread_int
28858 \intarray_new:Nn \g__regex_state_active_intarray { 65536 }
28859 \intarray_new:Nn \g__regex_thread_info_intarray { 65536 }
28860 \tl_new:N \l__regex_matched_analysis_tl
28861 \tl_new:N \l__regex_curr_analysis_tl
28862 \tl_new:N \l__regex_every_match_tl
28863 \bool_new:N \l__regex_fresh_thread_bool
28864 \bool_new:N \l__regex_empty_success_bool
28865 \cs_new_eq:NN \__regex_if_two_empty_matches:F \use:n
28866 \bool_new:N \g__regex_success_bool
28867 \bool_new:N \l__regex_saved_success_bool
28868 \bool_new:N \l__regex_match_success_bool
28869 \cs_new_protected:Npn \__regex_match:n #1
28870 {
28871 \__regex_match_init:
28872 \__regex_match_once_init:
28873 \tl_analysis_map_inline:nn {#1}
28874 { \__regex_match_one_token:nnN {##1} {##2} ##3 }
28875 \__regex_match_one_token:nnN { } { -2 } F
28876 \prg_break_point:Nn \__regex_maplike_break: { }
28877 }
28878 \cs_new_protected:Npn \__regex_match_cs:n #1
28879 {
28880 \int_set_eq:NN \l__regex_min_thread_int \l__regex_max_thread_int
28881 \__regex_match_init:
28882 \__regex_match_once_init:
28883 \str_map_inline:nn {#1}
28884 {
28885 \tl_if_blank:nTF {##1}
28886 { \__regex_match_one_token:nnN {##1} {`##1} A }
28887 { \__regex_match_one_token:nnN {##1} {`##1} C }
28888 }
28889 \__regex_match_one_token:nnN { } { -2 } F
28890 \prg_break_point:Nn \__regex_maplike_break: { }
28891 }
28892 \cs_new_protected:Npn \__regex_match_init:
28893 {
28894 \bool_gset_false:N \g__regex_success_bool
28895 \int_step_inline:nnn
28896 \l__regex_min_state_int { \l__regex_max_state_int - \c_one_int }
28897 {
28898 \__kernel_intarray_gset:Nnn
28899 \g__regex_state_active_intarray {##1} \c_one_int
28900 }
28901 \int_zero:N \l__regex_step_int
28902 \int_set:Nn \l__regex_min_pos_int { 2 }
28903 \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int
28904 \int_set:Nn \l__regex_last_char_success_int { -2 }
28905 \tl_build_begin:N \l__regex_matched_analysis_tl
28906 \tl_clear:N \l__regex_curr_analysis_tl
28907 \int_set_eq:NN \l__regex_min_submatch_int \c_one_int
28908 \int_set_eq:NN \l__regex_submatch_int \l__regex_min_submatch_int
28909 \bool_set_false:N \l__regex_empty_success_bool
28910 }
28911 \cs_new_protected:Npn \__regex_match_once_init:
28912 {
28913 \if_meaning:w \c_true_bool \l__regex_empty_success_bool
28914 \cs_set:Npn \__regex_if_two_empty_matches:F
28915 {
28916 \int_compare:nNnF
28917 \l__regex_start_pos_int = \l__regex_curr_pos_int
28918 }
28919 \else:
28920 \cs_set_eq:NN \__regex_if_two_empty_matches:F \use:n
28921 \fi:
28922 \int_set_eq:NN \l__regex_start_pos_int \l__regex_success_pos_int
28923 \bool_set_false:N \l__regex_match_success_bool
28924 \tl_set:Ne \l__regex_curr_submatches_tl
28925 { \prg_replicate:nn { 2 * \l__regex_capturing_group_int } { 0 , } }
28926 \int_set_eq:NN \l__regex_max_thread_int \l__regex_min_thread_int
28927 \__regex_store_state:n { \l__regex_min_state_int }
28928 \int_set:Nn \l__regex_curr_pos_int { \l__regex_start_pos_int - \c_one_int }
28929 \int_set_eq:NN \l__regex_curr_char_int \l__regex_last_char_success_int
28930 \tl_build_get_intermediate:NN \l__regex_matched_analysis_tl \l__regex_tmpa_tl
28931 \exp_args:NNf \__regex_match_once_init_aux:
28932 \tl_map_inline:nn
28933 { \exp_after:wN \l__regex_tmpa_tl \l__regex_curr_analysis_tl }
28934 { \__regex_match_one_token:nnN ##1 }
28935 \prg_break_point:Nn \__regex_maplike_break: { }
28936 }
28937 \cs_new_protected:Npn \__regex_match_once_init_aux:
28938 {
28939 \tl_build_begin:N \l__regex_matched_analysis_tl
28940 \tl_clear:N \l__regex_curr_analysis_tl
28941 }
28942 \cs_new_protected:Npn \__regex_single_match:
28943 {
28944 \tl_set:Nn \l__regex_every_match_tl
28945 {
28946 \bool_gset_eq:NN
28947 \g__regex_success_bool
28948 \l__regex_match_success_bool
28949 \__regex_maplike_break:
28950 }
28951 }
28952 \cs_new_protected:Npn \__regex_multi_match:n #1
28953 {
28954 \tl_set:Nn \l__regex_every_match_tl
28955 {
28956 \if_meaning:w \c_false_bool \l__regex_match_success_bool
28957 \exp_after:wN \__regex_maplike_break:
28958 \fi:
28959 \bool_gset_true:N \g__regex_success_bool
28960 #1
28961 \__regex_match_once_init:
28962 }
28963 }
28964 \cs_new_protected:Npn \__regex_match_one_token:nnN #1#2#3
28965 {
28966 \int_add:Nn \l__regex_step_int { 2 }
28967 \int_incr:N \l__regex_curr_pos_int
28968 \int_set_eq:NN \l__regex_last_char_int \l__regex_curr_char_int
28969 \cs_set_eq:NN \__regex_maybe_compute_ccc: \__regex_compute_case_changed_char:
28970 \tl_set:Nn \l__regex_curr_token_tl {#1}
28971 \int_set:Nn \l__regex_curr_char_int {#2}
28972 \int_set:Nn \l__regex_curr_catcode_int { "#3 }
28973 \tl_build_put_right:Ne \l__regex_matched_analysis_tl
28974 { \exp_not:o \l__regex_curr_analysis_tl }
28975 \tl_set:Nn \l__regex_curr_analysis_tl { { {#1} {#2} #3 } }
28976 \use:e
28977 {
28978 \int_set_eq:NN \l__regex_max_thread_int \l__regex_min_thread_int
28979 \int_step_function:nnN
28980 \l__regex_min_thread_int
28981 { \l__regex_max_thread_int - \c_one_int }
28982 \__regex_match_one_active:n
28983 }
28984 \prg_break_point:
28985 \bool_set_false:N \l__regex_fresh_thread_bool
28986 \if_int_compare:w \l__regex_max_thread_int > \l__regex_min_thread_int
28987 \if_int_compare:w -2 < \l__regex_curr_char_int
28988 \exp_after:wN \use_i:nn
28989 \fi:
28990 \fi:
28991 \l__regex_every_match_tl
28992 }
28993 \cs_new:Npn \__regex_match_one_active:n #1
28994 {
28995 \__regex_use_state_and_submatches:w
28996 \__kernel_intarray_range_to_clist:Nnn
28997 \g__regex_thread_info_intarray
28998 { \c_one_int + #1 * (\l__regex_capturing_group_int * 2 + \c_one_int) }
28999 { (\c_one_int + #1) * (\l__regex_capturing_group_int * 2 + \c_one_int) }
29000 \__regex_sep:
29001 }
29002 \cs_new_protected:Npn \__regex_use_state:
29003 {
29004 \__kernel_intarray_gset:Nnn \g__regex_state_active_intarray
29005 \l__regex_curr_state_int \l__regex_step_int
29006 \__regex_toks_use:w \l__regex_curr_state_int
29007 \__kernel_intarray_gset:Nnn \g__regex_state_active_intarray
29008 \l__regex_curr_state_int
29009 { \__regex_int_eval:w \l__regex_step_int + \c_one_int \scan_stop: }
29010 }
29011 \cs_new_protected:Npn \__regex_use_state_and_submatches:w #1 , #2 \__regex_sep:
29012 {
29013 \int_set:Nn \l__regex_curr_state_int {#1}
29014 \if_int_compare:w
29015 \__kernel_intarray_item:Nn \g__regex_state_active_intarray
29016 \l__regex_curr_state_int
29017 < \l__regex_step_int
29018 \tl_set:Nn \l__regex_curr_submatches_tl { #2 , }
29019 \exp_after:wN \__regex_use_state:
29020 \fi:
29021 \scan_stop:
29022 }
29023 \cs_new_protected:Npn \__regex_action_start_wildcard:N #1
29024 {
29025 \bool_set_true:N \l__regex_fresh_thread_bool
29026 \__regex_action_free:n {1}
29027 \bool_set_false:N \l__regex_fresh_thread_bool
29028 \bool_if:NT #1 { \__regex_action_cost:n {0} }
29029 }
29030 \cs_new_protected:Npn \__regex_action_free:n
29031 { \__regex_action_free_aux:nn { > \l__regex_step_int \else: } }
29032 \cs_new_protected:Npn \__regex_action_free_group:n
29033 { \__regex_action_free_aux:nn { < \l__regex_step_int } }
29034 \cs_new_protected:Npn \__regex_action_free_aux:nn #1#2
29035 {
29036 \use:e
29037 {
29038 \int_add:Nn \l__regex_curr_state_int {#2}
29039 \exp_not:n
29040 {
29041 \if_int_compare:w
29042 \__kernel_intarray_item:Nn \g__regex_state_active_intarray
29043 \l__regex_curr_state_int
29044 #1
29045 \exp_after:wN \__regex_use_state:
29046 \fi:
29047 }
29048 \int_set:Nn \l__regex_curr_state_int
29049 { \int_use:N \l__regex_curr_state_int }
29050 \tl_set:Nn \exp_not:N \l__regex_curr_submatches_tl
29051 { \exp_not:o \l__regex_curr_submatches_tl }
29052 }
29053 }
29054 \cs_new_protected:Npn \__regex_action_cost:n #1
29055 {
29056 \exp_args:No \__regex_store_state:n
29057 { \tex_the:D \__regex_int_eval:w \l__regex_curr_state_int + #1 }
29058 }
29059 \cs_new_protected:Npn \__regex_store_state:n #1
29060 {
29061 \exp_args:No \__regex_store_submatches:nn
29062 \l__regex_curr_submatches_tl {#1}
29063 \int_incr:N \l__regex_max_thread_int
29064 }
29065 \cs_new_protected:Npn \__regex_store_submatches:nn #1#2
29066 {
29067 \__kernel_intarray_gset_range_from_clist:Nnn
29068 \g__regex_thread_info_intarray
29069 {
29070 \__regex_int_eval:w
29071 \c_one_int + \l__regex_max_thread_int *
29072 (\l__regex_capturing_group_int * 2 + \c_one_int)
29073 }
29074 { #2 , #1 }
29075 }
29076 \cs_new_protected:Npn \__regex_disable_submatches:
29077 {
29078 \cs_set_protected:Npn \__regex_store_submatches:n ##1 { }
29079 \cs_set_protected:Npn \__regex_action_submatch:nN ##1##2 { }
29080 }
29081 \cs_new_protected:Npn \__regex_action_submatch:nN #1#2
29082 {
29083 \exp_after:wN \__regex_action_submatch_aux:w
29084 \l__regex_curr_submatches_tl \__regex_sep: {#1} #2
29085 }
29086 \cs_new_protected:Npn \__regex_action_submatch_aux:w #1 \__regex_sep: #2#3
29087 {
29088 \tl_set:Ne \l__regex_curr_submatches_tl
29089 {
29090 \prg_replicate:nn
29091 { #2 \if_meaning:w > #3 + \l__regex_capturing_group_int \fi: }
29092 { \__regex_action_submatch_auxii:w }
29093 \__regex_action_submatch_auxiii:w
29094 #1
29095 }
29096 }
29097 \cs_new:Npn \__regex_action_submatch_auxii:w
29098 #1 \__regex_action_submatch_auxiii:w #2 ,
29099 { #2 , #1 \__regex_action_submatch_auxiii:w }
29100 \cs_new:Npn \__regex_action_submatch_auxiii:w #1 ,
29101 { \int_use:N \l__regex_curr_pos_int , }
29102 \cs_new_protected:Npn \__regex_action_success:
29103 {
29104 \__regex_if_two_empty_matches:F
29105 {
29106 \bool_set_true:N \l__regex_match_success_bool
29107 \bool_set_eq:NN \l__regex_empty_success_bool
29108 \l__regex_fresh_thread_bool
29109 \int_set_eq:NN \l__regex_success_pos_int \l__regex_curr_pos_int
29110 \int_set_eq:NN \l__regex_last_char_success_int \l__regex_last_char_int
29111 \tl_build_begin:N \l__regex_matched_analysis_tl
29112 \tl_set_eq:NN \l__regex_success_submatches_tl
29113 \l__regex_curr_submatches_tl
29114 \prg_break:
29115 }
29116 }
29117 \int_new:N \l__regex_replacement_csnames_int
29118 \tl_new:N \l__regex_replacement_category_tl
29119 \seq_new:N \l__regex_replacement_category_seq
29120 \tl_new:N \g__regex_balance_tl
29121 \cs_new:Npn \__regex_replacement_balance_one_match:n #1
29122 { - \__regex_submatch_balance:n {#1} }
29123 \cs_new:Npn \__regex_replacement_do_one_match:n #1
29124 {
29125 \__regex_query_range:nn
29126 { \__kernel_intarray_item:Nn \g__regex_submatch_prev_intarray {#1} }
29127 { \__kernel_intarray_item:Nn \g__regex_submatch_begin_intarray {#1} }
29128 }
29129 \cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} }
29130 \cs_new_eq:NN \__regex_replacement_exp_not:V \exp_not:V
29131 \cs_new:Npn \__regex_query_range:nn #1#2
29132 {
29133 \exp_after:wN \__regex_query_range_loop:ww
29134 \int_value:w \__regex_int_eval:w #1 \exp_after:wN \__regex_sep:
29135 \int_value:w \__regex_int_eval:w #2 \__regex_sep:
29136 \prg_break_point:
29137 }
29138 \cs_new:Npn \__regex_query_range_loop:ww #1 \__regex_sep: #2 \__regex_sep:
29139 {
29140 \if_int_compare:w #1 < #2 \exp_stop_f:
29141 \else:
29142 \prg_break:n
29143 \fi:
29144 \__regex_toks_use:w #1 \exp_stop_f:
29145 \exp_after:wN \__regex_query_range_loop:ww
29146 \int_value:w \__regex_int_eval:w #1 + \c_one_int \__regex_sep: #2 \__regex_sep:
29147 }
29148 \cs_new:Npn \__regex_query_submatch:n #1
29149 {
29150 \__regex_query_range:nn
29151 { \__kernel_intarray_item:Nn \g__regex_submatch_begin_intarray {#1} }
29152 { \__kernel_intarray_item:Nn \g__regex_submatch_end_intarray {#1} }
29153 }
29154 \cs_new_protected:Npn \__regex_submatch_balance:n #1
29155 {
29156 \tex_the:D \__regex_int_eval:w
29157 \__regex_intarray_item:NnF \g__regex_balance_intarray
29158 {
29159 \__kernel_intarray_item:Nn
29160 \g__regex_submatch_end_intarray {#1}
29161 }
29162 \c_zero_int
29163 -
29164 \__regex_intarray_item:NnF \g__regex_balance_intarray
29165 {
29166 \__kernel_intarray_item:Nn
29167 \g__regex_submatch_begin_intarray {#1}
29168 }
29169 \c_zero_int
29170 \scan_stop:
29171 }
29172 \cs_new_protected:Npn \__regex_replacement:n
29173 { \__regex_replacement_apply:Nn \__regex_replacement_set:n }
29174 \cs_new_protected:Npn \__regex_replacement_apply:Nn #1#2
29175 {
29176 \group_begin:
29177 \tl_build_begin:N \l__regex_build_tl
29178 \int_zero:N \l__regex_balance_int
29179 \tl_gclear:N \g__regex_balance_tl
29180 \__regex_escape_use:nnnn
29181 {
29182 \if_charcode:w \c_right_brace_str ##1
29183 \__regex_replacement_rbrace:N
29184 \else:
29185 \if_charcode:w \c_left_brace_str ##1
29186 \__regex_replacement_lbrace:N
29187 \else:
29188 \__regex_replacement_normal:n
29189 \fi:
29190 \fi:
29191 ##1
29192 }
29193 { \__regex_replacement_escaped:N ##1 }
29194 { \__regex_replacement_normal:n ##1 }
29195 {#2}
29196 \prg_do_nothing: \prg_do_nothing:
29197 \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero_int
29198 \msg_error:nne { regex } { replacement-missing-rbrace }
29199 { \int_use:N \l__regex_replacement_csnames_int }
29200 \tl_build_put_right:Ne \l__regex_build_tl
29201 { \prg_replicate:nn \l__regex_replacement_csnames_int \cs_end: }
29202 \fi:
29203 \seq_if_empty:NF \l__regex_replacement_category_seq
29204 {
29205 \msg_error:nne { regex } { replacement-missing-rparen }
29206 { \seq_count:N \l__regex_replacement_category_seq }
29207 \seq_clear:N \l__regex_replacement_category_seq
29208 }
29209 \tl_gput_right:Ne \g__regex_balance_tl
29210 { + \int_use:N \l__regex_balance_int }
29211 \tl_build_end:N \l__regex_build_tl
29212 \exp_args:NNo
29213 \group_end:
29214 #1 \l__regex_build_tl
29215 }
29216 \cs_generate_variant:Nn \__regex_replacement:n { e }
29217 \cs_new_protected:Npn \__regex_replacement_set:n #1
29218 {
29219 \cs_set:Npn \__regex_replacement_do_one_match:n ##1
29220 {
29221 \__regex_query_range:nn
29222 {
29223 \__kernel_intarray_item:Nn
29224 \g__regex_submatch_prev_intarray {##1}
29225 }
29226 {
29227 \__kernel_intarray_item:Nn
29228 \g__regex_submatch_begin_intarray {##1}
29229 }
29230 #1
29231 }
29232 \exp_args:Nno \use:n
29233 { \cs_gset:Npn \__regex_replacement_balance_one_match:n ##1 }
29234 {
29235 \g__regex_balance_tl
29236 - \__regex_submatch_balance:n {##1}
29237 }
29238 }
29239 \tl_new:N \g__regex_case_replacement_tl
29240 \tl_new:N \g__regex_case_balance_tl
29241 \cs_new_protected:Npn \__regex_case_replacement:n #1
29242 {
29243 \tl_gset:Nn \g__regex_case_balance_tl
29244 {
29245 \if_case:w
29246 \__kernel_intarray_item:Nn
29247 \g__regex_submatch_case_intarray {##1}
29248 }
29249 \tl_gset_eq:NN \g__regex_case_replacement_tl \g__regex_case_balance_tl
29250 \tl_map_tokens:nn {#1}
29251 { \__regex_replacement_apply:Nn \__regex_case_replacement_aux:n }
29252 \tl_gset:No \g__regex_balance_tl
29253 { \g__regex_case_balance_tl \fi: }
29254 \exp_args:No \__regex_replacement_set:n
29255 { \g__regex_case_replacement_tl \fi: }
29256 }
29257 \cs_generate_variant:Nn \__regex_case_replacement:n { e }
29258 \cs_new_protected:Npn \__regex_case_replacement_aux:n #1
29259 {
29260 \tl_gput_right:Nn \g__regex_case_replacement_tl { \or: #1 }
29261 \tl_gput_right:No \g__regex_case_balance_tl
29262 { \exp_after:wN \or: \g__regex_balance_tl }
29263 }
29264 \cs_new_protected:Npn \__regex_replacement_put:n
29265 { \tl_build_put_right:Nn \l__regex_build_tl }
29266 \cs_new_protected:Npn \__regex_replacement_normal:n #1
29267 {
29268 \int_compare:nNnTF \l__regex_replacement_csnames_int > \c_zero_int
29269 { \exp_args:No \__regex_replacement_put:n { \token_to_str:N #1 } }
29270 {
29271 \tl_if_empty:NTF \l__regex_replacement_category_tl
29272 { \__regex_replacement_normal_aux:N #1 }
29273 { % (
29274 \token_if_eq_charcode:NNTF #1 )
29275 {
29276 \seq_pop:NN \l__regex_replacement_category_seq
29277 \l__regex_replacement_category_tl
29278 }
29279 {
29280 \use:c { __regex_replacement_c_ \l__regex_replacement_category_tl :w }
29281 ? #1
29282 }
29283 }
29284 }
29285 }
29286 \cs_new_protected:Npn \__regex_replacement_normal_aux:N #1
29287 {
29288 \token_if_eq_charcode:NNTF #1 \c_space_token
29289 { \__regex_replacement_c_S:w }
29290 {
29291 \exp_after:wN \exp_after:wN
29292 \if_case:w \tex_catcode:D `#1 \exp_stop_f:
29293 \__regex_replacement_c_O:w
29294 \or: \__regex_replacement_c_B:w
29295 \or: \__regex_replacement_c_E:w
29296 \or: \__regex_replacement_c_M:w
29297 \or: \__regex_replacement_c_T:w
29298 \or: \__regex_replacement_c_O:w
29299 \or: \__regex_replacement_c_P:w
29300 \or: \__regex_replacement_c_U:w
29301 \or: \__regex_replacement_c_D:w
29302 \or: \__regex_replacement_c_O:w
29303 \or: \__regex_replacement_c_S:w
29304 \or: \__regex_replacement_c_L:w
29305 \or: \__regex_replacement_c_O:w
29306 \or: \__regex_replacement_c_A:w
29307 \else: \__regex_replacement_c_O:w
29308 \fi:
29309 }
29310 ? #1
29311 }
29312 \cs_new_protected:Npn \__regex_replacement_escaped:N #1
29313 {
29314 \cs_if_exist_use:cF { __regex_replacement_#1:w }
29315 {
29316 \if_int_compare:w \c_one_int < 1#1 \exp_stop_f:
29317 \__regex_replacement_put_submatch:n {#1}
29318 \else:
29319 \__regex_replacement_normal:n {#1}
29320 \fi:
29321 }
29322 }
29323 \cs_new_protected:Npn \__regex_replacement_put_submatch:n #1
29324 {
29325 \if_int_compare:w #1 < \l__regex_capturing_group_int
29326 \__regex_replacement_put_submatch_aux:n {#1}
29327 \else:
29328 \msg_expandable_error:nnff { regex } { submatch-too-big }
29329 {#1} { \int_eval:n { \l__regex_capturing_group_int - \c_one_int } }
29330 \fi:
29331 }
29332 \cs_new_protected:Npn \__regex_replacement_put_submatch_aux:n #1
29333 {
29334 \tl_build_put_right:Nn \l__regex_build_tl
29335 { \__regex_query_submatch:n { \__regex_int_eval:w #1 + ##1 \scan_stop: } }
29336 \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero_int
29337 \tl_gput_right:Nn \g__regex_balance_tl
29338 { + \__regex_submatch_balance:n { \__regex_int_eval:w #1 + ##1 \scan_stop: } }
29339 \fi:
29340 }
29341 \cs_new_protected:Npn \__regex_replacement_g:w #1#2
29342 {
29343 \token_if_eq_meaning:NNTF #1 \__regex_replacement_lbrace:N
29344 { \l__regex_tmpa_int = \__regex_replacement_g_digits:NN }
29345 { \__regex_replacement_error:NNN g #1 #2 }
29346 }
29347 \cs_new:Npn \__regex_replacement_g_digits:NN #1#2
29348 {
29349 \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n
29350 {
29351 \if_int_compare:w \c_one_int < 1#2 \exp_stop_f:
29352 #2
29353 \exp_after:wN \use_i:nnn
29354 \exp_after:wN \__regex_replacement_g_digits:NN
29355 \else:
29356 \exp_stop_f:
29357 \exp_after:wN \__regex_replacement_error:NNN
29358 \exp_after:wN g
29359 \fi:
29360 }
29361 {
29362 \exp_stop_f:
29363 \if_meaning:w \__regex_replacement_rbrace:N #1
29364 \exp_args:No \__regex_replacement_put_submatch:n
29365 { \int_use:N \l__regex_tmpa_int }
29366 \exp_after:wN \use_none:nn
29367 \else:
29368 \exp_after:wN \__regex_replacement_error:NNN
29369 \exp_after:wN g
29370 \fi:
29371 }
29372 #1 #2
29373 }
29374 \cs_new_protected:Npn \__regex_replacement_c:w #1#2
29375 {
29376 \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n
29377 {
29378 \cs_if_exist:cTF { __regex_replacement_c_#2:w }
29379 { \__regex_replacement_cat:NNN #2 }
29380 { \__regex_replacement_error:NNN c #1#2 }
29381 }
29382 {
29383 \token_if_eq_meaning:NNTF #1 \__regex_replacement_lbrace:N
29384 { \__regex_replacement_cu_aux:Nw \__regex_replacement_exp_not:N }
29385 { \__regex_replacement_error:NNN c #1#2 }
29386 }
29387 }
29388 \cs_new_protected:Npn \__regex_replacement_cu_aux:Nw #1
29389 {
29390 \if_case:w \l__regex_replacement_csnames_int
29391 \tl_build_put_right:Nn \l__regex_build_tl
29392 { \exp_not:n { \exp_after:wN #1 \cs:w } }
29393 \else:
29394 \tl_build_put_right:Nn \l__regex_build_tl
29395 { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } }
29396 \fi:
29397 \int_incr:N \l__regex_replacement_csnames_int
29398 }
29399 \cs_new_protected:Npn \__regex_replacement_u:w #1#2
29400 {
29401 \token_if_eq_meaning:NNTF #1 \__regex_replacement_lbrace:N
29402 { \__regex_replacement_cu_aux:Nw \__regex_replacement_exp_not:V }
29403 { \__regex_replacement_error:NNN u #1#2 }
29404 }
29405 \cs_new_protected:Npn \__regex_replacement_rbrace:N #1
29406 {
29407 \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero_int
29408 \tl_build_put_right:Nn \l__regex_build_tl { \cs_end: }
29409 \int_decr:N \l__regex_replacement_csnames_int
29410 \else:
29411 \__regex_replacement_normal:n {#1}
29412 \fi:
29413 }
29414 \cs_new_protected:Npn \__regex_replacement_lbrace:N #1
29415 {
29416 \if_int_compare:w \l__regex_replacement_csnames_int > \c_zero_int
29417 \msg_error:nnn { regex } { cu-lbrace } { u }
29418 \else:
29419 \__regex_replacement_normal:n {#1}
29420 \fi:
29421 }
29422 \cs_new_protected:Npn \__regex_replacement_cat:NNN #1#2#3
29423 {
29424 \token_if_eq_meaning:NNTF \prg_do_nothing: #3
29425 { \msg_error:nn { regex } { replacement-catcode-end } }
29426 {
29427 \int_compare:nNnTF \l__regex_replacement_csnames_int > \c_zero_int
29428 {
29429 \msg_error:nnnn
29430 { regex } { replacement-catcode-in-cs } {#1} {#3}
29431 #2 #3
29432 }
29433 {
29434 \__regex_two_if_eq:NNNNTF #2 #3 \__regex_replacement_normal:n (
29435 {
29436 \seq_push:NV \l__regex_replacement_category_seq
29437 \l__regex_replacement_category_tl
29438 \tl_set:Nn \l__regex_replacement_category_tl {#1}
29439 }
29440 {
29441 \token_if_eq_meaning:NNT #2 \__regex_replacement_escaped:N
29442 {
29443 \__regex_char_if_alphanumeric:NTF #3
29444 {
29445 \msg_error:nnnn
29446 { regex } { replacement-catcode-escaped }
29447 {#1} {#3}
29448 }
29449 { }
29450 }
29451 \use:c { __regex_replacement_c_#1:w } #2 #3
29452 }
29453 }
29454 }
29455 }
29456 \group_begin:
29457 \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3
29458 {
29459 \tex_lccode:D \c_zero_int = `#3 \scan_stop:
29460 \tex_lowercase:D { \__regex_replacement_put:n {#1} }
29461 }
29462 \char_set_catcode_active:N \^^@
29463 \cs_new_protected:Npn \__regex_replacement_c_A:w
29464 { \__regex_replacement_char:nNN { \exp_not:n { \exp_not:N ^^@ } } }
29465 \char_set_catcode_group_begin:N \^^@
29466 \cs_new_protected:Npn \__regex_replacement_c_B:w
29467 {
29468 \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero_int
29469 \int_incr:N \l__regex_balance_int
29470 \fi:
29471 \__regex_replacement_char:nNN
29472 { \exp_not:n { \exp_after:wN ^^@ \if_false: } \fi: } }
29473 }
29474 \cs_new_protected:Npn \__regex_replacement_c_C:w #1#2
29475 {
29476 \tl_build_put_right:Nn \l__regex_build_tl
29477 { \exp_not:N \__regex_replacement_exp_not:N \exp_not:c {#2} }
29478 }
29479 \char_set_catcode_math_subscript:N \^^@
29480 \cs_new_protected:Npn \__regex_replacement_c_D:w
29481 { \__regex_replacement_char:nNN { ^^@ } }
29482 \char_set_catcode_group_end:N \^^@
29483 \cs_new_protected:Npn \__regex_replacement_c_E:w
29484 {
29485 \if_int_compare:w \l__regex_replacement_csnames_int = \c_zero_int
29486 \int_decr:N \l__regex_balance_int
29487 \fi:
29488 \__regex_replacement_char:nNN
29489 { \exp_not:n { \if_false: { \fi: ^^@ } }
29490 }
29491 \char_set_catcode_letter:N \^^@
29492 \cs_new_protected:Npn \__regex_replacement_c_L:w
29493 { \__regex_replacement_char:nNN { ^^@ } }
29494 \char_set_catcode_math_toggle:N \^^@
29495 \cs_new_protected:Npn \__regex_replacement_c_M:w
29496 { \__regex_replacement_char:nNN { ^^@ } }
29497 \char_set_catcode_other:N \^^@
29498 \cs_new_protected:Npn \__regex_replacement_c_O:w
29499 { \__regex_replacement_char:nNN { ^^@ } }
29500 \char_set_catcode_parameter:N \^^@
29501 \cs_new_protected:Npn \__regex_replacement_c_P:w
29502 {
29503 \__regex_replacement_char:nNN
29504 { \exp_not:n { \exp_not:n { ^^@^^@^^@^^@ } } }
29505 }
29506 \cs_new_protected:Npn \__regex_replacement_c_S:w #1#2
29507 {
29508 \if_int_compare:w `#2 = \c_zero_int
29509 \msg_error:nn { regex } { replacement-null-space }
29510 \fi:
29511 \tex_lccode:D `\ = `#2 \scan_stop:
29512 \tex_lowercase:D { \__regex_replacement_put:n {~} }
29513 }
29514 \char_set_catcode_alignment:N \^^@
29515 \cs_new_protected:Npn \__regex_replacement_c_T:w
29516 { \__regex_replacement_char:nNN { ^^@ } }
29517 \char_set_catcode_math_superscript:N \^^@
29518 \cs_new_protected:Npn \__regex_replacement_c_U:w
29519 { \__regex_replacement_char:nNN { ^^@ } }
29520 \group_end:
29521 \cs_new_protected:Npn \__regex_replacement_error:NNN #1#2#3
29522 {
29523 \msg_error:nne { regex } { replacement-#1 } {#3}
29524 #2 #3
29525 }
29526 \cs_new_protected:Npn \regex_new:N #1
29527 { \cs_new_eq:NN #1 \c__regex_no_match_regex }
29528 \regex_new:N \l_tmpa_regex
29529 \regex_new:N \l_tmpb_regex
29530 \regex_new:N \g_tmpa_regex
29531 \regex_new:N \g_tmpb_regex
29532 \cs_new_protected:Npn \regex_set:Nn #1#2
29533 {
29534 \__regex_compile:n {#2}
29535 \tl_set_eq:NN #1 \l__regex_tmp_regex
29536 }
29537 \cs_new_protected:Npn \regex_gset:Nn #1#2
29538 {
29539 \__regex_compile:n {#2}
29540 \tl_gset_eq:NN #1 \l__regex_tmp_regex
29541 }
29542 \cs_new_protected:Npn \regex_const:Nn #1#2
29543 {
29544 \__regex_compile:n {#2}
29545 \tl_const:Ne #1 { \exp_not:o \l__regex_tmp_regex }
29546 }
29547 \cs_new_protected:Npn \regex_show:n { \__regex_show:Nn \msg_show:nneeee }
29548 \cs_new_protected:Npn \regex_log:n { \__regex_show:Nn \msg_log:nneeee }
29549 \cs_new_protected:Npn \__regex_show:Nn #1#2
29550 {
29551 \__regex_compile:n {#2}
29552 \__regex_show:N \l__regex_tmp_regex
29553 #1 { regex } { show }
29554 { \tl_to_str:n {#2} } { }
29555 { \l__regex_tmpa_tl } { }
29556 }
29557 \cs_new_protected:Npn \regex_show:N { \__regex_show:NN \msg_show:nneeee }
29558 \cs_new_protected:Npn \regex_log:N { \__regex_show:NN \msg_log:nneeee }
29559 \cs_new_protected:Npn \__regex_show:NN #1#2
29560 {
29561 \__kernel_chk_tl_type:NnnT #2 { regex }
29562 { \exp_args:No \__regex_clean_regex:n {#2} }
29563 {
29564 \__regex_show:N #2
29565 #1 { regex } { show }
29566 { } { \token_to_str:N #2 }
29567 { \l__regex_tmpa_tl } { }
29568 }
29569 }
29570 \prg_new_protected_conditional:Npnn \regex_if_match:nn #1#2 { T , F , TF }
29571 {
29572 \__regex_if_match:nn { \__regex_build:n {#1} } {#2}
29573 \__regex_return:
29574 }
29575 \prg_generate_conditional_variant:Nnn \regex_if_match:nn { nV } { T , F , TF }
29576 \prg_new_protected_conditional:Npnn \regex_if_match:Nn #1#2 { T , F , TF }
29577 {
29578 \__regex_if_match:nn { \__regex_build:N #1 } {#2}
29579 \__regex_return:
29580 }
29581 \prg_generate_conditional_variant:Nnn \regex_if_match:Nn { NV } { T , F , TF }
29582 \cs_new_protected:Npn \regex_count:nnN #1
29583 { \__regex_count:nnN { \__regex_build:n {#1} } }
29584 \cs_new_protected:Npn \regex_count:NnN #1
29585 { \__regex_count:nnN { \__regex_build:N #1 } }
29586 \cs_generate_variant:Nn \regex_count:nnN { nV }
29587 \cs_generate_variant:Nn \regex_count:NnN { NV }
29588 \cs_new_protected:Npn \regex_match_case:nnTF #1#2#3
29589 {
29590 \__regex_match_case:nnTF {#1} {#2}
29591 {
29592 \tl_item:nn {#1} { 2 * \g__regex_case_int }
29593 #3
29594 }
29595 }
29596 \cs_new_protected:Npn \regex_match_case:nn #1#2
29597 { \regex_match_case:nnTF {#1} {#2} { } { } }
29598 \cs_new_protected:Npn \regex_match_case:nnT #1#2#3
29599 { \regex_match_case:nnTF {#1} {#2} {#3} { } }
29600 \cs_new_protected:Npn \regex_match_case:nnF #1#2
29601 { \regex_match_case:nnTF {#1} {#2} { } }
29602 \cs_set_protected:Npn \__regex_tmp:w #1#2#3
29603 {
29604 \cs_new_protected:Npn #2 ##1 { #1 { \__regex_build:n {##1} } }
29605 \cs_new_protected:Npn #3 ##1 { #1 { \__regex_build:N ##1 } }
29606 \prg_new_protected_conditional:Npnn #2 ##1##2##3 { T , F , TF }
29607 { #1 { \__regex_build:n {##1} } {##2} ##3 \__regex_return: }
29608 \prg_new_protected_conditional:Npnn #3 ##1##2##3 { T , F , TF }
29609 { #1 { \__regex_build:N ##1 } {##2} ##3 \__regex_return: }
29610 \cs_generate_variant:Nn #2 { nV }
29611 \prg_generate_conditional_variant:Nnn #2 { nV } { T , F , TF }
29612 \cs_generate_variant:Nn #3 { NV }
29613 \prg_generate_conditional_variant:Nnn #3 { NV } { T , F , TF }
29614 }
29615 \__regex_tmp:w \__regex_extract_once:nnN
29616 \regex_extract_once:nnN \regex_extract_once:NnN
29617 \__regex_tmp:w \__regex_extract_all:nnN
29618 \regex_extract_all:nnN \regex_extract_all:NnN
29619 \__regex_tmp:w \__regex_replace_once:nnN
29620 \regex_replace_once:nnN \regex_replace_once:NnN
29621 \__regex_tmp:w \__regex_replace_all:nnN
29622 \regex_replace_all:nnN \regex_replace_all:NnN
29623 \__regex_tmp:w \__regex_split:nnN \regex_split:nnN \regex_split:NnN
29624 \cs_new_protected:Npn \regex_replace_case_once:nNTF #1#2
29625 {
29626 \int_if_odd:nTF { \tl_count:n {#1} }
29627 {
29628 \msg_error:nneeee { regex } { case-odd }
29629 { \token_to_str:N \regex_replace_case_once:nN(TF) } { code }
29630 { \tl_count:n {#1} } { \tl_to_str:n {#1} }
29631 \use_ii:nn
29632 }
29633 {
29634 \__regex_replace_once_aux:nnN
29635 { \__regex_case_build:e { \__regex_tl_odd_items:n {#1} } }
29636 { \__regex_replacement:e { \tl_item:nn {#1} { 2 * \g__regex_case_int } } }
29637 #2
29638 \bool_if:NTF \g__regex_success_bool
29639 }
29640 }
29641 \cs_new_protected:Npn \regex_replace_case_once:nN #1#2
29642 { \regex_replace_case_once:nNTF {#1} {#2} { } { } }
29643 \cs_new_protected:Npn \regex_replace_case_once:nNT #1#2#3
29644 { \regex_replace_case_once:nNTF {#1} {#2} {#3} { } }
29645 \cs_new_protected:Npn \regex_replace_case_once:nNF #1#2
29646 { \regex_replace_case_once:nNTF {#1} {#2} { } }
29647 \cs_new_protected:Npn \regex_replace_case_all:nNTF #1#2
29648 {
29649 \int_if_odd:nTF { \tl_count:n {#1} }
29650 {
29651 \msg_error:nneeee { regex } { case-odd }
29652 { \token_to_str:N \regex_replace_case_all:nN(TF) } { code }
29653 { \tl_count:n {#1} } { \tl_to_str:n {#1} }
29654 \use_ii:nn
29655 }
29656 {
29657 \__regex_replace_all_aux:nnN
29658 { \__regex_case_build:e { \__regex_tl_odd_items:n {#1} } }
29659 { \__regex_case_replacement:e { \__regex_tl_even_items:n {#1} } }
29660 #2
29661 \bool_if:NTF \g__regex_success_bool
29662 }
29663 }
29664 \cs_new_protected:Npn \regex_replace_case_all:nN #1#2
29665 { \regex_replace_case_all:nNTF {#1} {#2} { } { } }
29666 \cs_new_protected:Npn \regex_replace_case_all:nNT #1#2#3
29667 { \regex_replace_case_all:nNTF {#1} {#2} {#3} { } }
29668 \cs_new_protected:Npn \regex_replace_case_all:nNF #1#2
29669 { \regex_replace_case_all:nNTF {#1} {#2} { } }
29670 \int_new:N \l__regex_match_count_int
29671 \flag_new:N \l__regex_begin_flag
29672 \flag_new:N \l__regex_end_flag
29673 \int_new:N \l__regex_min_submatch_int
29674 \int_new:N \l__regex_submatch_int
29675 \int_new:N \l__regex_zeroth_submatch_int
29676 \intarray_new:Nn \g__regex_submatch_prev_intarray { 65536 }
29677 \intarray_new:Nn \g__regex_submatch_begin_intarray { 65536 }
29678 \intarray_new:Nn \g__regex_submatch_end_intarray { 65536 }
29679 \intarray_new:Nn \g__regex_submatch_case_intarray { 65536 }
29680 \intarray_new:Nn \g__regex_balance_intarray { 65536 }
29681 \int_new:N \l__regex_added_begin_int
29682 \int_new:N \l__regex_added_end_int
29683 \cs_new_protected:Npn \__regex_return:
29684 {
29685 \if_meaning:w \c_true_bool \g__regex_success_bool
29686 \prg_return_true:
29687 \else:
29688 \prg_return_false:
29689 \fi:
29690 }
29691 \cs_new_protected:Npn \__regex_query_set:n #1
29692 {
29693 \int_zero:N \l__regex_balance_int
29694 \int_zero:N \l__regex_curr_pos_int
29695 \__regex_query_set_aux:nN { } F
29696 \tl_analysis_map_inline:nn {#1}
29697 { \__regex_query_set_aux:nN {##1} ##3 }
29698 \__regex_query_set_aux:nN { } F
29699 \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int
29700 }
29701 \cs_new_protected:Npn \__regex_query_set_aux:nN #1#2
29702 {
29703 \int_incr:N \l__regex_curr_pos_int
29704 \__regex_toks_set:Nn \l__regex_curr_pos_int {#1}
29705 \__kernel_intarray_gset:Nnn \g__regex_balance_intarray
29706 \l__regex_curr_pos_int \l__regex_balance_int
29707 \if_case:w "#2 \exp_stop_f:
29708 \or: \int_incr:N \l__regex_balance_int
29709 \or: \int_decr:N \l__regex_balance_int
29710 \fi:
29711 }
29712 \cs_new_protected:Npn \__regex_if_match:nn #1#2
29713 {
29714 \group_begin:
29715 \__regex_disable_submatches:
29716 \__regex_single_match:
29717 #1
29718 \__regex_match:n {#2}
29719 \group_end:
29720 }
29721 \cs_new_protected:Npn \__regex_match_case:nnTF #1#2
29722 {
29723 \int_if_odd:nTF { \tl_count:n {#1} }
29724 {
29725 \msg_error:nneeee { regex } { case-odd }
29726 { \token_to_str:N \regex_match_case:nn(TF) } { code }
29727 { \tl_count:n {#1} } { \tl_to_str:n {#1} }
29728 \use_ii:nn
29729 }
29730 {
29731 \__regex_if_match:nn
29732 { \__regex_case_build:e { \__regex_tl_odd_items:n {#1} } }
29733 {#2}
29734 \bool_if:NTF \g__regex_success_bool
29735 }
29736 }
29737 \cs_new:Npn \__regex_match_case_aux:nn #1#2 { \exp_not:n { {#1} } }
29738 \cs_new_protected:Npn \__regex_count:nnN #1#2#3
29739 {
29740 \group_begin:
29741 \__regex_disable_submatches:
29742 \int_zero:N \l__regex_match_count_int
29743 \__regex_multi_match:n { \int_incr:N \l__regex_match_count_int }
29744 #1
29745 \__regex_match:n {#2}
29746 \exp_args:NNNo
29747 \group_end:
29748 \int_set:Nn #3 { \int_use:N \l__regex_match_count_int }
29749 }
29750 \cs_new_protected:Npn \__regex_extract_once:nnN #1#2#3
29751 {
29752 \group_begin:
29753 \__regex_single_match:
29754 #1
29755 \__regex_match:n {#2}
29756 \__regex_extract:
29757 \__regex_query_set:n {#2}
29758 \__regex_group_end_extract_seq:N #3
29759 }
29760 \cs_new_protected:Npn \__regex_extract_all:nnN #1#2#3
29761 {
29762 \group_begin:
29763 \__regex_multi_match:n { \__regex_extract: }
29764 #1
29765 \__regex_match:n {#2}
29766 \__regex_query_set:n {#2}
29767 \__regex_group_end_extract_seq:N #3
29768 }
29769 \cs_new_protected:Npn \__regex_split:nnN #1#2#3
29770 {
29771 \group_begin:
29772 \__regex_multi_match:n
29773 {
29774 \if_int_compare:w
29775 \l__regex_start_pos_int < \l__regex_success_pos_int
29776 \__regex_extract:
29777 \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray
29778 \l__regex_zeroth_submatch_int \c_zero_int
29779 \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray
29780 \l__regex_zeroth_submatch_int
29781 {
29782 \__kernel_intarray_item:Nn \g__regex_submatch_begin_intarray
29783 \l__regex_zeroth_submatch_int
29784 }
29785 \__kernel_intarray_gset:Nnn \g__regex_submatch_begin_intarray
29786 \l__regex_zeroth_submatch_int
29787 \l__regex_start_pos_int
29788 \fi:
29789 }
29790 #1
29791 \__regex_match:n {#2}
29792 \__regex_query_set:n {#2}
29793 \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray
29794 \l__regex_submatch_int \c_zero_int
29795 \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray
29796 \l__regex_submatch_int
29797 \l__regex_max_pos_int
29798 \__kernel_intarray_gset:Nnn \g__regex_submatch_begin_intarray
29799 \l__regex_submatch_int
29800 \l__regex_start_pos_int
29801 \int_incr:N \l__regex_submatch_int
29802 \if_meaning:w \c_true_bool \l__regex_empty_success_bool
29803 \if_int_compare:w \l__regex_start_pos_int = \l__regex_max_pos_int
29804 \int_decr:N \l__regex_submatch_int
29805 \fi:
29806 \fi:
29807 \__regex_group_end_extract_seq:N #3
29808 }
29809 \cs_new_protected:Npn \__regex_group_end_extract_seq:N #1
29810 {
29811 \flag_clear:N \l__regex_begin_flag
29812 \flag_clear:N \l__regex_end_flag
29813 \cs_set_eq:NN \__regex_tmp:w \scan_stop:
29814 \__kernel_tl_gset:Nx \g__regex_tmp_tl
29815 {
29816 \int_step_function:nnN \l__regex_min_submatch_int
29817 { \l__regex_submatch_int - \c_one_int } \__regex_extract_seq_aux:n
29818 \__regex_tmp:w
29819 }
29820 \int_set:Nn \l__regex_added_begin_int
29821 { \flag_height:N \l__regex_begin_flag }
29822 \int_set:Nn \l__regex_added_end_int
29823 { \flag_height:N \l__regex_end_flag }
29824 \tex_afterassignment:D \__regex_extract_check:w
29825 \__kernel_tl_gset:Nx \g__regex_tmp_tl
29826 { \g__regex_tmp_tl \if_false: { \fi: } }
29827 \int_compare:nNnT
29828 { \l__regex_added_begin_int + \l__regex_added_end_int } > \c_zero_int
29829 {
29830 \msg_error:nneee { regex } { result-unbalanced }
29831 { splitting~or~extracting~submatches }
29832 { \int_use:N \l__regex_added_begin_int }
29833 { \int_use:N \l__regex_added_end_int }
29834 }
29835 \group_end:
29836 \__regex_extract_seq:N #1
29837 }
29838 \cs_gset_protected:Npn \__regex_extract_seq:N #1
29839 {
29840 \seq_clear:N #1
29841 \cs_set_eq:NN \__regex_tmp:w \__regex_extract_seq_loop:Nw
29842 \exp_after:wN \__regex_extract_seq:NNn
29843 \exp_after:wN #1
29844 \g__regex_tmp_tl \use_none:nnn
29845 }
29846 \cs_new_protected:Npn \__regex_extract_seq:NNn #1#2#3
29847 { #3 #2 #1 \prg_do_nothing: }
29848 \cs_new_protected:Npn \__regex_extract_seq_loop:Nw #1#2 \__regex_tmp:w #3
29849 {
29850 \seq_put_right:No #1 {#2}
29851 #3 \__regex_extract_seq_loop:Nw #1 \prg_do_nothing:
29852 }
29853 \cs_new:Npn \__regex_extract_seq_aux:n #1
29854 {
29855 \__regex_tmp:w { }
29856 \exp_after:wN \__regex_extract_seq_aux:ww
29857 \int_value:w \__regex_submatch_balance:n {#1} \__regex_sep: #1 \__regex_sep:
29858 }
29859 \cs_new:Npn \__regex_extract_seq_aux:ww #1 \__regex_sep: #2 \__regex_sep:
29860 {
29861 \if_int_compare:w #1 < \c_zero_int
29862 \prg_replicate:nn {-#1}
29863 {
29864 \flag_raise:N \l__regex_begin_flag
29865 \exp_not:n { { \if_false: } \fi: }
29866 }
29867 \fi:
29868 \__regex_query_submatch:n {#2}
29869 \if_int_compare:w #1 > \c_zero_int
29870 \prg_replicate:nn {#1}
29871 {
29872 \flag_raise:N \l__regex_end_flag
29873 \exp_not:n { \if_false: { \fi: } }
29874 }
29875 \fi:
29876 }
29877 \cs_new_protected:Npn \__regex_extract_check:w
29878 {
29879 \exp_after:wN \__regex_extract_check:n
29880 \exp_after:wN { \if_false: } \fi:
29881 }
29882 \cs_new_protected:Npn \__regex_extract_check:n #1
29883 {
29884 \tl_if_empty:nF {#1}
29885 {
29886 \int_incr:N \l__regex_added_begin_int
29887 \int_incr:N \l__regex_added_end_int
29888 \tex_afterassignment:D \__regex_extract_check:w
29889 \__kernel_tl_gset:Nx \g__regex_tmp_tl
29890 {
29891 \exp_after:wN \__regex_extract_check_loop:w
29892 \g__regex_tmp_tl
29893 \__regex_tmp:w \__regex_extract_check_end:w
29894 #1
29895 }
29896 }
29897 }
29898 \cs_new:Npn \__regex_extract_check_loop:w #1 \__regex_tmp:w #2
29899 {
29900 #2
29901 \exp_not:o {#1}
29902 \__regex_tmp:w { }
29903 \__regex_extract_check_loop:w \prg_do_nothing:
29904 }
29905 \cs_new:Npn \__regex_extract_check_end:w
29906 \exp_not:o #1#2 \__regex_extract_check_loop:w #3 \__regex_tmp:w
29907 {
29908 { \exp_not:o {#1} }
29909 #3
29910 \if_false: { \fi: }
29911 \__regex_tmp:w
29912 }
29913 \cs_new_protected:Npn \__regex_extract:
29914 {
29915 \if_meaning:w \c_true_bool \g__regex_success_bool
29916 \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int
29917 \prg_replicate:nn \l__regex_capturing_group_int
29918 {
29919 \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray
29920 \l__regex_submatch_int \c_zero_int
29921 \__kernel_intarray_gset:Nnn \g__regex_submatch_case_intarray
29922 \l__regex_submatch_int \c_zero_int
29923 \int_incr:N \l__regex_submatch_int
29924 }
29925 \__kernel_intarray_gset:Nnn \g__regex_submatch_prev_intarray
29926 \l__regex_zeroth_submatch_int \l__regex_start_pos_int
29927 \__kernel_intarray_gset:Nnn \g__regex_submatch_case_intarray
29928 \l__regex_zeroth_submatch_int \g__regex_case_int
29929 \int_zero:N \l__regex_tmpa_int
29930 \exp_after:wN \__regex_extract_aux:w \l__regex_success_submatches_tl
29931 \prg_break_point: \__regex_use_none_delimit_by_q_recursion_stop:w ,
29932 \q__regex_recursion_stop
29933 \fi:
29934 }
29935 \cs_new_protected:Npn \__regex_extract_aux:w #1 ,
29936 {
29937 \prg_break: #1 \prg_break_point:
29938 \if_int_compare:w \l__regex_tmpa_int < \l__regex_capturing_group_int
29939 \__kernel_intarray_gset:Nnn \g__regex_submatch_begin_intarray
29940 { \__regex_int_eval:w \l__regex_zeroth_submatch_int + \l__regex_tmpa_int } {#1}
29941 \else:
29942 \__kernel_intarray_gset:Nnn \g__regex_submatch_end_intarray
29943 {
29944 \__regex_int_eval:w
29945 \l__regex_zeroth_submatch_int + \l__regex_tmpa_int
29946 - \l__regex_capturing_group_int
29947 }
29948 {#1}
29949 \fi:
29950 \int_incr:N \l__regex_tmpa_int
29951 \__regex_extract_aux:w
29952 }
29953 \cs_new_protected:Npn \__regex_replace_once:nnN #1#2
29954 { \__regex_replace_once_aux:nnN {#1} { \__regex_replacement:n {#2} } }
29955 \cs_new_protected:Npn \__regex_replace_once_aux:nnN #1#2#3
29956 {
29957 \group_begin:
29958 \__regex_single_match:
29959 #1
29960 \exp_args:No \__regex_match:n {#3}
29961 \bool_if:NTF \g__regex_success_bool
29962 {
29963 \__regex_extract:
29964 \exp_args:No \__regex_query_set:n {#3}
29965 #2
29966 \int_set:Nn \l__regex_balance_int
29967 { \__regex_replacement_balance_one_match:n \l__regex_zeroth_submatch_int }
29968 \__kernel_tl_set:Nx \l__regex_tmpa_tl
29969 {
29970 \__regex_replacement_do_one_match:n \l__regex_zeroth_submatch_int
29971 \__regex_query_range:nn
29972 {
29973 \__kernel_intarray_item:Nn \g__regex_submatch_end_intarray
29974 \l__regex_zeroth_submatch_int
29975 }
29976 \l__regex_max_pos_int
29977 }
29978 \__regex_group_end_replace:N #3
29979 }
29980 { \group_end: }
29981 }
29982 \cs_new_protected:Npn \__regex_replace_all:nnN #1#2
29983 { \__regex_replace_all_aux:nnN {#1} { \__regex_replacement:n {#2} } }
29984 \cs_new_protected:Npn \__regex_replace_all_aux:nnN #1#2#3
29985 {
29986 \group_begin:
29987 \__regex_multi_match:n { \__regex_extract: }
29988 #1
29989 \exp_args:No \__regex_match:n {#3}
29990 \exp_args:No \__regex_query_set:n {#3}
29991 #2
29992 \int_set:Nn \l__regex_balance_int
29993 {
29994 \c_zero_int
29995 \int_step_function:nnnN
29996 \l__regex_min_submatch_int
29997 \l__regex_capturing_group_int
29998 { \l__regex_submatch_int - \c_one_int }
29999 \__regex_replacement_balance_one_match:n
30000 }
30001 \__kernel_tl_set:Nx \l__regex_tmpa_tl
30002 {
30003 \int_step_function:nnnN
30004 \l__regex_min_submatch_int
30005 \l__regex_capturing_group_int
30006 { \l__regex_submatch_int - \c_one_int }
30007 \__regex_replacement_do_one_match:n
30008 \__regex_query_range:nn
30009 \l__regex_start_pos_int \l__regex_max_pos_int
30010 }
30011 \__regex_group_end_replace:N #3
30012 }
30013 \cs_new_protected:Npn \__regex_group_end_replace:N #1
30014 {
30015 \int_set:Nn \l__regex_added_begin_int
30016 { \int_max:nn { - \l__regex_balance_int } \c_zero_int }
30017 \int_set:Nn \l__regex_added_end_int
30018 { \int_max:nn \l__regex_balance_int \c_zero_int }
30019 \__regex_group_end_replace_try:
30020 \int_compare:nNnT { \l__regex_added_begin_int + \l__regex_added_end_int }
30021 > \c_zero_int
30022 {
30023 \msg_error:nneee { regex } { result-unbalanced }
30024 { replacing } { \int_use:N \l__regex_added_begin_int }
30025 { \int_use:N \l__regex_added_end_int }
30026 }
30027 \group_end:
30028 \tl_set_eq:NN #1 \g__regex_tmp_tl
30029 }
30030 \cs_new_protected:Npn \__regex_group_end_replace_try:
30031 {
30032 \tex_afterassignment:D \__regex_group_end_replace_check:w
30033 \__kernel_tl_gset:Nx \g__regex_tmp_tl
30034 {
30035 \prg_replicate:nn \l__regex_added_begin_int { { \if_false: } \fi: }
30036 \l__regex_tmpa_tl
30037 \prg_replicate:nn \l__regex_added_end_int { \if_false: { \fi: } }
30038 \if_false: { \fi: }
30039 }
30040 }
30041 \cs_new_protected:Npn \__regex_group_end_replace_check:w
30042 {
30043 \exp_after:wN \__regex_group_end_replace_check:n
30044 \exp_after:wN { \if_false: } \fi:
30045 }
30046 \cs_new_protected:Npn \__regex_group_end_replace_check:n #1
30047 {
30048 \tl_if_empty:nF {#1}
30049 {
30050 \int_incr:N \l__regex_added_begin_int
30051 \int_incr:N \l__regex_added_end_int
30052 \__regex_group_end_replace_try:
30053 }
30054 }
30055 \tl_new:N \l__regex_peek_true_tl
30056 \tl_new:N \l__regex_peek_false_tl
30057 \tl_new:N \l__regex_replacement_tl
30058 \tl_new:N \l__regex_input_tl
30059 \cs_new_eq:NN \__regex_input_item:n ?
30060 \cs_new_protected:Npn \peek_regex:nTF #1
30061 {
30062 \__regex_peek:nnTF
30063 { \__regex_build_aux:Nn \c_false_bool {#1} }
30064 { \__regex_peek_end: }
30065 }
30066 \cs_new_protected:Npn \peek_regex:nT #1#2
30067 { \peek_regex:nTF {#1} {#2} { } }
30068 \cs_new_protected:Npn \peek_regex:nF #1 { \peek_regex:nTF {#1} { } }
30069 \cs_new_protected:Npn \peek_regex:NTF #1
30070 {
30071 \__regex_peek:nnTF
30072 { \__regex_build_aux:NN \c_false_bool #1 }
30073 { \__regex_peek_end: }
30074 }
30075 \cs_new_protected:Npn \peek_regex:NT #1#2
30076 { \peek_regex:NTF #1 {#2} { } }
30077 \cs_new_protected:Npn \peek_regex:NF #1 { \peek_regex:NTF {#1} { } }
30078 \cs_new_protected:Npn \peek_regex_remove_once:nTF #1
30079 {
30080 \__regex_peek:nnTF
30081 { \__regex_build_aux:Nn \c_false_bool {#1} }
30082 { \__regex_peek_remove_end:n {##1} }
30083 }
30084 \cs_new_protected:Npn \peek_regex_remove_once:nT #1#2
30085 { \peek_regex_remove_once:nTF {#1} {#2} { } }
30086 \cs_new_protected:Npn \peek_regex_remove_once:nF #1
30087 { \peek_regex_remove_once:nTF {#1} { } }
30088 \cs_new_protected:Npn \peek_regex_remove_once:NTF #1
30089 {
30090 \__regex_peek:nnTF
30091 { \__regex_build_aux:NN \c_false_bool #1 }
30092 { \__regex_peek_remove_end:n {##1} }
30093 }
30094 \cs_new_protected:Npn \peek_regex_remove_once:NT #1#2
30095 { \peek_regex_remove_once:NTF #1 {#2} { } }
30096 \cs_new_protected:Npn \peek_regex_remove_once:NF #1
30097 { \peek_regex_remove_once:NTF #1 { } }
30098 \cs_new_protected:Npn \__regex_peek:nnTF #1
30099 {
30100 \__regex_peek_aux:nnTF
30101 {
30102 \__regex_disable_submatches:
30103 #1
30104 }
30105 }
30106 \cs_new_protected:Npn \__regex_peek_aux:nnTF #1#2#3#4
30107 {
30108 \group_begin:
30109 \tl_set:Nn \l__regex_peek_true_tl { \group_end: #3 }
30110 \tl_set:Nn \l__regex_peek_false_tl { \group_end: #4 }
30111 \__regex_single_match:
30112 #1
30113 \__regex_match_init:
30114 \tl_build_begin:N \l__regex_input_tl
30115 \__regex_match_once_init:
30116 \peek_analysis_map_inline:n
30117 {
30118 \tl_build_put_right:Nn \l__regex_input_tl
30119 { \__regex_input_item:n {##1} }
30120 \__regex_match_one_token:nnN {##1} {##2} ##3
30121 \use_none:nnn
30122 \prg_break_point:Nn \__regex_maplike_break:
30123 { \peek_analysis_map_break:n {#2} }
30124 }
30125 }
30126 \cs_new_protected:Npn \__regex_peek_end:
30127 {
30128 \bool_if:NTF \g__regex_success_bool
30129 { \__regex_peek_reinsert:N \l__regex_peek_true_tl }
30130 { \__regex_peek_reinsert:N \l__regex_peek_false_tl }
30131 }
30132 \cs_new_protected:Npn \__regex_peek_remove_end:n #1
30133 {
30134 \bool_if:NTF \g__regex_success_bool
30135 { \exp_after:wN \l__regex_peek_true_tl #1 }
30136 { \__regex_peek_reinsert:N \l__regex_peek_false_tl }
30137 }
30138 \cs_new_protected:Npn \__regex_peek_reinsert:N #1
30139 {
30140 \tl_build_end:N \l__regex_input_tl
30141 \cs_set_eq:NN \__regex_input_item:n \__regex_reinsert_item:n
30142 \exp_after:wN #1 \exp:w \l__regex_input_tl \exp_end:
30143 }
30144 \cs_new_protected:Npn \__regex_reinsert_item:n #1
30145 {
30146 \exp_after:wN \exp_after:wN
30147 \exp_after:wN \exp_end:
30148 \exp_after:wN \exp_after:wN
30149 #1
30150 \exp:w
30151 }
30152 \cs_new_protected:Npn \peek_regex_replace_once:nnTF #1
30153 { \__regex_peek_replace:nnTF { \__regex_build_aux:Nn \c_false_bool {#1} } }
30154 \cs_new_protected:Npn \peek_regex_replace_once:nnT #1#2#3
30155 { \peek_regex_replace_once:nnTF {#1} {#2} {#3} { } }
30156 \cs_new_protected:Npn \peek_regex_replace_once:nnF #1#2
30157 { \peek_regex_replace_once:nnTF {#1} {#2} { } }
30158 \cs_new_protected:Npn \peek_regex_replace_once:nn #1#2
30159 { \peek_regex_replace_once:nnTF {#1} {#2} { } { } }
30160 \cs_new_protected:Npn \peek_regex_replace_once:NnTF #1
30161 { \__regex_peek_replace:nnTF { \__regex_build_aux:NN \c_false_bool #1 } }
30162 \cs_new_protected:Npn \peek_regex_replace_once:NnT #1#2#3
30163 { \peek_regex_replace_once:NnTF #1 {#2} {#3} { } }
30164 \cs_new_protected:Npn \peek_regex_replace_once:NnF #1#2
30165 { \peek_regex_replace_once:NnTF #1 {#2} { } }
30166 \cs_new_protected:Npn \peek_regex_replace_once:Nn #1#2
30167 { \peek_regex_replace_once:NnTF #1 {#2} { } { } }
30168 \cs_new_protected:Npn \__regex_peek_replace:nnTF #1#2
30169 {
30170 \tl_set:Nn \l__regex_replacement_tl {#2}
30171 \__regex_peek_aux:nnTF {#1} { \__regex_peek_replace_end: }
30172 }
30173 \cs_new_protected:Npn \__regex_peek_replace_end:
30174 {
30175 \bool_if:NTF \g__regex_success_bool
30176 {
30177 \__regex_extract:
30178 \__regex_query_set_from_input_tl:
30179 \cs_set_eq:NN \__regex_replacement_put:n \__regex_peek_replacement_put:n
30180 \cs_set_eq:NN \__regex_replacement_put_submatch_aux:n
30181 \__regex_peek_replacement_put_submatch_aux:n
30182 \cs_set_eq:NN \__regex_input_item:n \__regex_reinsert_item:n
30183 \cs_set_eq:NN \__regex_replacement_exp_not:N \__regex_peek_replacement_token:n
30184 \cs_set_eq:NN \__regex_replacement_exp_not:V \__regex_peek_replacement_var:N
30185 \exp_args:No \__regex_replacement:n { \l__regex_replacement_tl }
30186 \use:e
30187 {
30188 \exp_not:n { \exp_after:wN \l__regex_peek_true_tl \exp:w }
30189 \__regex_replacement_do_one_match:n \l__regex_zeroth_submatch_int
30190 \__regex_query_range:nn
30191 {
30192 \__kernel_intarray_item:Nn \g__regex_submatch_end_intarray
30193 \l__regex_zeroth_submatch_int
30194 }
30195 \l__regex_max_pos_int
30196 \exp_end:
30197 }
30198 }
30199 { \__regex_peek_reinsert:N \l__regex_peek_false_tl }
30200 }
30201 \cs_new_protected:Npn \__regex_query_set_from_input_tl:
30202 {
30203 \tl_build_end:N \l__regex_input_tl
30204 \int_zero:N \l__regex_curr_pos_int
30205 \cs_set_eq:NN \__regex_input_item:n \__regex_query_set_item:n
30206 \__regex_query_set_item:n { }
30207 \l__regex_input_tl
30208 \__regex_query_set_item:n { }
30209 \int_set_eq:NN \l__regex_max_pos_int \l__regex_curr_pos_int
30210 }
30211 \cs_new_protected:Npn \__regex_query_set_item:n #1
30212 {
30213 \int_incr:N \l__regex_curr_pos_int
30214 \__regex_toks_set:Nn \l__regex_curr_pos_int { \__regex_input_item:n {#1} }
30215 }
30216 \cs_new_protected:Npn \__regex_peek_replacement_put:n #1
30217 {
30218 \if_case:w \l__regex_replacement_csnames_int
30219 \tl_build_put_right:Nn \l__regex_build_tl
30220 { \exp_not:N \__regex_reinsert_item:n {#1} }
30221 \else:
30222 \tl_build_put_right:Nn \l__regex_build_tl {#1}
30223 \fi:
30224 }
30225 \cs_new_protected:Npn \__regex_peek_replacement_token:n #1
30226 { \exp_after:wN \exp_end: \exp_after:wN #1 \exp:w }
30227 \cs_new_protected:Npn \__regex_peek_replacement_put_submatch_aux:n #1
30228 {
30229 \if_case:w \l__regex_replacement_csnames_int
30230 \tl_build_put_right:Nn \l__regex_build_tl
30231 { \__regex_query_submatch:n { \__regex_int_eval:w #1 + ##1 \scan_stop: } }
30232 \else:
30233 \tl_build_put_right:Nn \l__regex_build_tl
30234 {
30235 \exp:w
30236 \__regex_query_submatch:n { \__regex_int_eval:w #1 + ##1 \scan_stop: }
30237 \exp_end:
30238 }
30239 \fi:
30240 }
30241 \cs_new_protected:Npn \__regex_peek_replacement_var:N #1
30242 {
30243 \exp_after:wN \exp_last_unbraced:NV
30244 \exp_after:wN \exp_end:
30245 \exp_after:wN #1
30246 \exp:w
30247 }
30248 \use:e
30249 {
30250 \msg_new:nnn { regex } { trailing-backslash }
30251 { Trailing~'\iow_char:N\\'~in~regex~or~replacement. }
30252 \msg_new:nnn { regex } { x-missing-rbrace }
30253 {
30254 Missing~brace~'\iow_char:N\}'~in~regex~
30255 '...\iow_char:N\\x\iow_char:N\{...##1'.
30256 }
30257 \msg_new:nnn { regex } { x-overflow }
30258 {
30259 Character~code~##1~too~large~in~
30260 \iow_char:N\\x\iow_char:N\{##2\iow_char:N\}~regex.
30261 }
30262 }
30263 \msg_new:nnnn { regex } { invalid-quantifier }
30264 { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. }
30265 {
30266 The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~
30267 The~only~valid~quantifiers~are~'*',~'?',~'+',~'{<int>}',~
30268 '{<min>,}'~and~'{<min>,<max>}',~optionally~followed~by~'?'.
30269 }
30270 \msg_new:nnnn { regex } { missing-rbrack }
30271 { Missing~right~bracket~inserted~in~regular~expression. }
30272 {
30273 LaTeX~was~given~a~regular~expression~where~a~character~class~
30274 was~started~with~'[',~but~the~matching~']'~is~missing.
30275 }
30276 \msg_new:nnnn { regex } { missing-rparen }
30277 {
30278 Missing~right~
30279 \int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } ~
30280 inserted~in~regular~expression.
30281 }
30282 {
30283 LaTeX~was~given~a~regular~expression~with~\int_eval:n {#1} ~
30284 more~left~parentheses~than~right~parentheses.
30285 }
30286 \msg_new:nnnn { regex } { extra-rparen }
30287 { Extra~right~parenthesis~ignored~in~regular~expression. }
30288 {
30289 LaTeX~came~across~a~closing~parenthesis~when~no~submatch~group~
30290 was~open.~The~parenthesis~will~be~ignored.
30291 }
30292 \msg_new:nnnn { regex } { bad-escape }
30293 {
30294 Invalid~escape~'\iow_char:N\\#1'~
30295 \__regex_if_in_cs:TF { within~a~control~sequence. }
30296 {
30297 \__regex_if_in_class:TF
30298 { in~a~character~class. }
30299 { following~a~category~test. }
30300 }
30301 }
30302 {
30303 The~escape~sequence~'\iow_char:N\\#1'~may~not~appear~
30304 \__regex_if_in_cs:TF
30305 {
30306 within~a~control~sequence~test~introduced~by~
30307 '\iow_char:N\\c\iow_char:N\{'.
30308 }
30309 {
30310 \__regex_if_in_class:TF
30311 { within~a~character~class~ }
30312 { following~a~category~test~such~as~'\iow_char:N\\cL'~ }
30313 because~it~does~not~match~exactly~one~character.
30314 }
30315 }
30316 \msg_new:nnnn { regex } { range-missing-end }
30317 { Invalid~end-point~for~range~'#1-#2'~in~character~class. }
30318 {
30319 The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~
30320 end-point~for~a~range:~alphanumeric~characters~should~not~be~
30321 escaped,~and~non-alphanumeric~characters~should~be~escaped.
30322 }
30323 \msg_new:nnnn { regex } { range-backwards }
30324 { Range~'[#1-#2]'~out~of~order~in~character~class. }
30325 {
30326 In~ranges~of~characters~'[x-y]'~appearing~in~character~classes,~
30327 the~first~character~code~must~not~be~larger~than~the~second.~
30328 Here,~'#1'~has~character~code~\int_eval:n {`#1},~while~
30329 '#2'~has~character~code~\int_eval:n {`#2}.
30330 }
30331 \msg_new:nnnn { regex } { c-bad-mode }
30332 { Invalid~nested~'\iow_char:N\\c'~escape~in~regular~expression. }
30333 {
30334 The~'\iow_char:N\\c'~escape~cannot~be~used~within~
30335 a~control~sequence~test~'\iow_char:N\\c{...}'~
30336 nor~another~category~test.~
30337 To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'.
30338 }
30339 \msg_new:nnnn { regex } { c-C-invalid }
30340 { '\iow_char:N\\cC'~should~be~followed~by~'.'~or~'(',~not~'#1'. }
30341 {
30342 The~'\iow_char:N\\cC'~construction~restricts~the~next~item~to~be~a~
30343 control~sequence~or~the~next~group~to~be~made~of~control~sequences.~
30344 It~only~makes~sense~to~follow~it~by~'.'~or~by~a~group.
30345 }
30346 \msg_new:nnnn { regex } { cu-lbrace }
30347 { Left~braces~must~be~escaped~in~'\iow_char:N\\#1{...}'. }
30348 {
30349 Constructions~such~as~'\iow_char:N\\#1{...\iow_char:N\{...}'~are~
30350 not~allowed~and~should~be~replaced~by~
30351 '\iow_char:N\\#1{...\token_to_str:N\{...}'.
30352 }
30353 \msg_new:nnnn { regex } { c-lparen-in-class }
30354 { Catcode~test~cannot~apply~to~group~in~character~class }
30355 {
30356 Construction~such~as~'\iow_char:N\\cL(abc)'~are~not~allowed~inside~a~
30357 class~'[...]'~because~classes~do~not~match~multiple~characters~at~once.
30358 }
30359 \msg_new:nnnn { regex } { c-missing-rbrace }
30360 { Missing~right~brace~inserted~for~'\iow_char:N\\c'~escape. }
30361 {
30362 LaTeX~was~given~a~regular~expression~where~a~
30363 '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~
30364 with~a~closing~brace~'\iow_char:N\}'.
30365 }
30366 \msg_new:nnnn { regex } { c-missing-rbrack }
30367 { Missing~right~bracket~inserted~for~'\iow_char:N\\c'~escape. }
30368 {
30369 A~construction~'\iow_char:N\\c[...'~appears~in~a~
30370 regular~expression,~but~the~closing~']'~is~not~present.
30371 }
30372 \msg_new:nnnn { regex } { c-missing-category }
30373 { Invalid~character~'#1'~following~'\iow_char:N\\c'~escape. }
30374 {
30375 In~regular~expressions,~the~'\iow_char:N\\c'~escape~sequence~
30376 may~only~be~followed~by~a~left~brace,~a~left~bracket,~or~a~
30377 capital~letter~representing~a~character~category,~namely~
30378 one~of~'ABCDELMOPSTU'.
30379 }
30380 \msg_new:nnnn { regex } { c-trailing }
30381 { Trailing~category~code~escape~'\iow_char:N\\c'... }
30382 {
30383 A~regular~expression~ends~with~'\iow_char:N\\c'~followed~
30384 by~a~letter.~It~will~be~ignored.
30385 }
30386 \msg_new:nnnn { regex } { u-missing-lbrace }
30387 { Missing~left~brace~following~'\iow_char:N\\u'~escape. }
30388 {
30389 The~'\iow_char:N\\u'~escape~sequence~must~be~followed~by~
30390 a~brace~group~with~the~name~of~the~variable~to~use.
30391 }
30392 \msg_new:nnnn { regex } { u-missing-rbrace }
30393 { Missing~right~brace~inserted~for~'\iow_char:N\\u'~escape. }
30394 {
30395 LaTeX~
30396 \str_if_eq:eeTF { } {#2}
30397 { reached~the~end~of~the~string~ }
30398 { encountered~an~escaped~alphanumeric~character '\iow_char:N\\#2'~ }
30399 when~parsing~the~argument~of~an~
30400 '\iow_char:N\\u\iow_char:N\{...\}'~escape.
30401 }
30402 \msg_new:nnnn { regex } { posix-unsupported }
30403 { POSIX~collating~element~'[#1 ~ #1]'~not~supported. }
30404 {
30405 The~'[.foo.]'~and~'[=bar=]'~syntaxes~have~a~special~meaning~
30406 in~POSIX~regular~expressions.~This~is~not~supported~by~LaTeX.~
30407 Maybe~you~forgot~to~escape~a~left~bracket~in~a~character~class?
30408 }
30409 \msg_new:nnnn { regex } { posix-unknown }
30410 { POSIX~class~'[:#1:]'~unknown. }
30411 {
30412 '[:#1:]'~is~not~among~the~known~POSIX~classes~
30413 '[:alnum:]',~'[:alpha:]',~'[:ascii:]',~'[:blank:]',~
30414 '[:cntrl:]',~'[:digit:]',~'[:graph:]',~'[:lower:]',~
30415 '[:print:]',~'[:punct:]',~'[:space:]',~'[:upper:]',~
30416 '[:word:]',~and~'[:xdigit:]'.
30417 }
30418 \msg_new:nnnn { regex } { posix-missing-close }
30419 { Missing~closing~':]'~for~POSIX~class. }
30420 { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. }
30421 \msg_new:nnnn { regex } { result-unbalanced }
30422 { Missing~brace~inserted~when~#1. }
30423 {
30424 LaTeX~was~asked~to~do~some~regular~expression~operation,~
30425 and~the~resulting~token~list~would~not~have~the~same~number~
30426 of~begin-group~and~end-group~tokens.~Braces~were~inserted:~
30427 #2~left,~#3~right.
30428 }
30429 \msg_new:nnnn { regex } { unknown-option }
30430 { Unknown~option~'#1'~for~regular~expressions. }
30431 {
30432 The~only~available~option~is~'case-insensitive',~toggled~by~
30433 '(?i)'~and~'(?-i)'.
30434 }
30435 \msg_new:nnnn { regex } { special-group-unknown }
30436 { Unknown~special~group~'#1~...'~in~a~regular~expression. }
30437 {
30438 The~only~valid~constructions~starting~with~'(?'~are~
30439 '(?:~...~)',~'(?|~...~)',~'(?i)',~and~'(?-i)'.
30440 }
30441 \msg_new:nnnn { regex } { replacement-c }
30442 { Misused~'\iow_char:N\\c'~command~in~a~replacement~text. }
30443 {
30444 In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~
30445 can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~
30446 or~a~brace~group,~not~by~'#1'.
30447 }
30448 \msg_new:nnnn { regex } { replacement-u }
30449 { Misused~'\iow_char:N\\u'~command~in~a~replacement~text. }
30450 {
30451 In~a~replacement~text,~the~'\iow_char:N\\u'~escape~sequence~
30452 must~be~~followed~by~a~brace~group~holding~the~name~of~the~
30453 variable~to~use.
30454 }
30455 \msg_new:nnnn { regex } { replacement-g }
30456 {
30457 Missing~brace~for~the~'\iow_char:N\\g'~construction~
30458 in~a~replacement~text.
30459 }
30460 {
30461 In~the~replacement~text~for~a~regular~expression~search,~
30462 submatches~are~represented~either~as~'\iow_char:N \\g{dd..d}',~
30463 or~'\\d',~where~'d'~are~single~digits.~Here,~a~brace~is~missing.
30464 }
30465 \msg_new:nnnn { regex } { replacement-catcode-end }
30466 {
30467 Missing~character~for~the~'\iow_char:N\\c<category><character>'~
30468 construction~in~a~replacement~text.
30469 }
30470 {
30471 In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~
30472 can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~representing~
30473 the~character~category.~Then,~a~character~must~follow.~LaTeX~
30474 reached~the~end~of~the~replacement~when~looking~for~that.
30475 }
30476 \msg_new:nnnn { regex } { replacement-catcode-escaped }
30477 {
30478 Escaped~letter~or~digit~after~category~code~in~replacement~text.
30479 }
30480 {
30481 In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~
30482 can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~representing~
30483 the~character~category.~Then,~a~character~must~follow,~not~
30484 '\iow_char:N\\#2'.
30485 }
30486 \msg_new:nnnn { regex } { replacement-catcode-in-cs }
30487 {
30488 Category~code~'\iow_char:N\\c#1#3'~ignored~inside~
30489 '\iow_char:N\\c\{...\}'~in~a~replacement~text.
30490 }
30491 {
30492 In~a~replacement~text,~the~category~codes~of~the~argument~of~
30493 '\iow_char:N\\c\{...\}'~are~ignored~when~building~the~control~
30494 sequence~name.
30495 }
30496 \msg_new:nnnn { regex } { replacement-null-space }
30497 { TeX~cannot~build~a~space~token~with~character~code~0. }
30498 {
30499 You~asked~for~a~character~token~with~category~space,~
30500 and~character~code~0,~for~instance~through~
30501 '\iow_char:N\\cS\iow_char:N\\x00'.~
30502 This~specific~case~is~impossible~and~will~be~replaced~
30503 by~a~normal~space.
30504 }
30505 \msg_new:nnnn { regex } { replacement-missing-rbrace }
30506 { Missing~right~brace~inserted~in~replacement~text. }
30507 {
30508 There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~
30509 missing~right~\int_compare:nTF { #1 = 1 } { brace } { braces } .
30510 }
30511 \msg_new:nnnn { regex } { replacement-missing-rparen }
30512 { Missing~right~parenthesis~inserted~in~replacement~text. }
30513 {
30514 There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~
30515 missing~right~
30516 \int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } .
30517 }
30518 \msg_new:nnn { regex } { submatch-too-big }
30519 { Submatch~#1~used~but~regex~only~has~#2~group(s) }
30520 \msg_new:nnnn { regex } { backwards-quantifier }
30521 { Quantifer~"{#1,#2}"~is~backwards. }
30522 { The~values~given~in~a~quantifier~must~be~in~order. }
30523 \msg_new:nnnn { regex } { case-odd }
30524 { #1~with~odd~number~of~items }
30525 {
30526 There~must~be~a~#2~part~for~each~regex:~
30527 found~odd~number~of~items~(#3)~in\\
30528 \iow_indent:n {#4}
30529 }
30530 \msg_new:nnn { regex } { show }
30531 {
30532 >~Compiled~regex~
30533 \tl_if_empty:nTF {#1} { variable~ #2 } { {#1} } :
30534 #3
30535 }
30536 \prop_gput:Nnn \g_msg_module_name_prop { regex } { LaTeX }
30537 \prop_gput:Nnn \g_msg_module_type_prop { regex } { }
30538 \cs_new:Npn \__regex_msg_repeated:nnN #1#2#3
30539 {
30540 \str_if_eq:eeF { #1 #2 } { 1 0 }
30541 {
30542 , ~ repeated ~
30543 \int_case:nnF {#2}
30544 {
30545 { -1 } { #1~or~more~times,~\bool_if:NTF #3 { lazy } { greedy } }
30546 { 0 } { #1~times }
30547 }
30548 {
30549 between~#1~and~\int_eval:n {#1+#2}~times,~
30550 \bool_if:NTF #3 { lazy } { greedy }
30551 }
30552 }
30553 }
30554 \cs_new_protected:Npn \__regex_trace_push:nnN #1#2#3
30555 { \__regex_trace:nne {#1} {#2} { entering~ \token_to_str:N #3 } }
30556 \cs_new_protected:Npn \__regex_trace_pop:nnN #1#2#3
30557 { \__regex_trace:nne {#1} {#2} { leaving~ \token_to_str:N #3 } }
30558 \cs_new_protected:Npn \__regex_trace:nne #1#2#3
30559 {
30560 \int_compare:nNnF
30561 { \int_use:c { g__regex_trace_#1_int } } < {#2}
30562 { \iow_term:e { Trace:~#3 } }
30563 }
30564 \int_new:N \g__regex_trace_regex_int
30565 \cs_new_protected:Npn \__regex_trace_states:n #1
30566 {
30567 \int_step_inline:nnn
30568 \l__regex_min_state_int
30569 { \l__regex_max_state_int - \c_one_int }
30570 {
30571 \__regex_trace:nne { regex } {#1}
30572 { \iow_char:N \\toks ##1 = { \__regex_toks_use:w ##1 } }
30573 }
30574 }
30575 %% File: l3box.dtx
30576 \cs_new_eq:NN \__box_dim_eval:w \tex_dimexpr:D
30577 \cs_new:Npn \__box_dim_eval:n #1
30578 { \__box_dim_eval:w #1 \scan_stop: }
30579 \cs_new_protected:Npn \box_new:N #1
30580 {
30581 \__kernel_chk_if_free_cs:N #1
30582 \cs:w newbox \cs_end: #1
30583 }
30584 \cs_generate_variant:Nn \box_new:N { c }
30585 \cs_new_protected:Npn \box_clear:N #1
30586 { \box_set_eq:NN #1 \c_empty_box }
30587 \cs_new_protected:Npn \box_gclear:N #1
30588 { \box_gset_eq:NN #1 \c_empty_box }
30589 \cs_generate_variant:Nn \box_clear:N { c }
30590 \cs_generate_variant:Nn \box_gclear:N { c }
30591 \cs_new_protected:Npn \box_clear_new:N #1
30592 { \box_if_exist:NTF #1 { \box_clear:N #1 } { \box_new:N #1 } }
30593 \cs_new_protected:Npn \box_gclear_new:N #1
30594 { \box_if_exist:NTF #1 { \box_gclear:N #1 } { \box_new:N #1 } }
30595 \cs_generate_variant:Nn \box_clear_new:N { c }
30596 \cs_generate_variant:Nn \box_gclear_new:N { c }
30597 \cs_new_protected:Npn \box_set_eq:NN #1#2
30598 { \tex_setbox:D #1 \tex_copy:D #2 }
30599 \cs_new_protected:Npn \box_gset_eq:NN #1#2
30600 { \tex_global:D \tex_setbox:D #1 \tex_copy:D #2 }
30601 \cs_generate_variant:Nn \box_set_eq:NN { c , Nc , cc }
30602 \cs_generate_variant:Nn \box_gset_eq:NN { c , Nc , cc }
30603 \cs_new_protected:Npn \box_set_eq_drop:NN #1#2
30604 { \tex_setbox:D #1 \tex_box:D #2 }
30605 \cs_new_protected:Npn \box_gset_eq_drop:NN #1#2
30606 { \tex_global:D \tex_setbox:D #1 \tex_box:D #2 }
30607 \cs_generate_variant:Nn \box_set_eq_drop:NN { c , Nc , cc }
30608 \cs_generate_variant:Nn \box_gset_eq_drop:NN { c , Nc , cc }
30609 \prg_new_eq_conditional:NNn \box_if_exist:N \cs_if_exist:N
30610 { TF , T , F , p }
30611 \prg_new_eq_conditional:NNn \box_if_exist:c \cs_if_exist:c
30612 { TF , T , F , p }
30613 \cs_new_eq:NN \box_ht:N \tex_ht:D
30614 \cs_new_eq:NN \box_dp:N \tex_dp:D
30615 \cs_new_eq:NN \box_wd:N \tex_wd:D
30616 \cs_generate_variant:Nn \box_ht:N { c }
30617 \cs_generate_variant:Nn \box_dp:N { c }
30618 \cs_generate_variant:Nn \box_wd:N { c }
30619 \cs_new_protected:Npn \box_ht_plus_dp:N #1
30620 { \__box_dim_eval:n { \box_ht:N #1 + \box_dp:N #1 } }
30621 \cs_generate_variant:Nn \box_ht_plus_dp:N { c }
30622 \cs_new_protected:Npn \box_set_dp:Nn #1#2
30623 {
30624 \tex_setbox:D #1 = \tex_copy:D #1
30625 \box_dp:N #1 \__box_dim_eval:n {#2}
30626 }
30627 \cs_generate_variant:Nn \box_set_dp:Nn { c }
30628 \cs_new_protected:Npn \box_gset_dp:Nn #1#2
30629 { \box_dp:N #1 \__box_dim_eval:n {#2} }
30630 \cs_generate_variant:Nn \box_gset_dp:Nn { c }
30631 \cs_new_protected:Npn \box_set_ht:Nn #1#2
30632 {
30633 \tex_setbox:D #1 = \tex_copy:D #1
30634 \box_ht:N #1 \__box_dim_eval:n {#2}
30635 }
30636 \cs_generate_variant:Nn \box_set_ht:Nn { c }
30637 \cs_new_protected:Npn \box_gset_ht:Nn #1#2
30638 { \box_ht:N #1 \__box_dim_eval:n {#2} }
30639 \cs_generate_variant:Nn \box_gset_ht:Nn { c }
30640 \cs_new_protected:Npn \box_set_wd:Nn #1#2
30641 {
30642 \tex_setbox:D #1 = \tex_copy:D #1
30643 \box_wd:N #1 \__box_dim_eval:n {#2}
30644 }
30645 \cs_generate_variant:Nn \box_set_wd:Nn { c }
30646 \cs_new_protected:Npn \box_gset_wd:Nn #1#2
30647 { \box_wd:N #1 \__box_dim_eval:n {#2} }
30648 \cs_generate_variant:Nn \box_gset_wd:Nn { c }
30649 \cs_new_eq:NN \box_use_drop:N \tex_box:D
30650 \cs_new_eq:NN \box_use:N \tex_copy:D
30651 \cs_generate_variant:Nn \box_use_drop:N { c }
30652 \cs_generate_variant:Nn \box_use:N { c }
30653 \cs_new_protected:Npn \box_move_left:nn #1#2
30654 { \tex_moveleft:D \__box_dim_eval:n {#1} #2 }
30655 \cs_new_protected:Npn \box_move_right:nn #1#2
30656 { \tex_moveright:D \__box_dim_eval:n {#1} #2 }
30657 \cs_new_protected:Npn \box_move_up:nn #1#2
30658 { \tex_raise:D \__box_dim_eval:n {#1} #2 }
30659 \cs_new_protected:Npn \box_move_down:nn #1#2
30660 { \tex_lower:D \__box_dim_eval:n {#1} #2 }
30661 \cs_new_eq:NN \if_hbox:N \tex_ifhbox:D
30662 \cs_new_eq:NN \if_vbox:N \tex_ifvbox:D
30663 \cs_new_eq:NN \if_box_empty:N \tex_ifvoid:D
30664 \prg_new_conditional:Npnn \box_if_horizontal:N #1 { p , T , F , TF }
30665 { \if_hbox:N #1 \prg_return_true: \else: \prg_return_false: \fi: }
30666 \prg_new_conditional:Npnn \box_if_vertical:N #1 { p , T , F , TF }
30667 { \if_vbox:N #1 \prg_return_true: \else: \prg_return_false: \fi: }
30668 \prg_generate_conditional_variant:Nnn \box_if_horizontal:N
30669 { c } { p , T , F , TF }
30670 \prg_generate_conditional_variant:Nnn \box_if_vertical:N
30671 { c } { p , T , F , TF }
30672 \prg_new_conditional:Npnn \box_if_empty:N #1 { p , T , F , TF }
30673 { \if_box_empty:N #1 \prg_return_true: \else: \prg_return_false: \fi: }
30674 \prg_generate_conditional_variant:Nnn \box_if_empty:N
30675 { c } { p , T , F , TF }
30676 \cs_new_protected:Npn \box_set_to_last:N #1
30677 { \tex_setbox:D #1 \tex_lastbox:D }
30678 \cs_new_protected:Npn \box_gset_to_last:N #1
30679 { \tex_global:D \tex_setbox:D #1 \tex_lastbox:D }
30680 \cs_generate_variant:Nn \box_set_to_last:N { c }
30681 \cs_generate_variant:Nn \box_gset_to_last:N { c }
30682 \box_new:N \c_empty_box
30683 \box_new:N \l_tmpa_box
30684 \box_new:N \l_tmpb_box
30685 \box_new:N \g_tmpa_box
30686 \box_new:N \g_tmpb_box
30687 \cs_new_protected:Npn \box_show:N #1
30688 { \box_show:Nnn #1 \c_max_int \c_max_int }
30689 \cs_generate_variant:Nn \box_show:N { c }
30690 \cs_new_protected:Npn \box_show:Nnn #1#2#3
30691 { \__box_show:NNff 1 #1 { \int_eval:n {#2} } { \int_eval:n {#3} } }
30692 \cs_generate_variant:Nn \box_show:Nnn { c }
30693 \cs_new_protected:Npn \box_log:N #1
30694 { \box_log:Nnn #1 \c_max_int \c_max_int }
30695 \cs_generate_variant:Nn \box_log:N { c }
30696 \cs_new_protected:Npn \box_log:Nnn
30697 { \exp_args:No \__box_log:nNnn { \tex_the:D \tex_interactionmode:D } }
30698 \cs_new_protected:Npn \__box_log:nNnn #1#2#3#4
30699 {
30700 \int_gset:Nn \tex_interactionmode:D { 0 }
30701 \__box_show:NNff 0 #2 { \int_eval:n {#3} } { \int_eval:n {#4} }
30702 \int_gset:Nn \tex_interactionmode:D {#1}
30703 }
30704 \cs_generate_variant:Nn \box_log:Nnn { c }
30705 \cs_new_protected:Npn \__box_show:NNnn #1#2#3#4
30706 {
30707 \box_if_exist:NTF #2
30708 {
30709 \group_begin:
30710 \int_set:Nn \tex_showboxbreadth:D {#3}
30711 \int_set:Nn \tex_showboxdepth:D {#4}
30712 \int_set:Nn \tex_tracingonline:D {#1}
30713 \int_set:Nn \tex_errorcontextlines:D { -1 }
30714 \tex_showbox:D \use:n {#2}
30715 \group_end:
30716 }
30717 {
30718 \msg_error:nne { kernel } { variable-not-defined }
30719 { \token_to_str:N #2 }
30720 }
30721 }
30722 \cs_generate_variant:Nn \__box_show:NNnn { NNff }
30723 \cs_new_protected:Npn \hbox:n #1
30724 { \tex_hbox:D \scan_stop: { \color_group_begin: #1 \color_group_end: } }
30725 \cs_new_protected:Npn \hbox_set:Nn #1#2
30726 {
30727 \tex_setbox:D #1 \tex_hbox:D
30728 { \color_group_begin: #2 \color_group_end: }
30729 }
30730 \cs_new_protected:Npn \hbox_gset:Nn #1#2
30731 {
30732 \tex_global:D \tex_setbox:D #1 \tex_hbox:D
30733 { \color_group_begin: #2 \color_group_end: }
30734 }
30735 \cs_generate_variant:Nn \hbox_set:Nn { c }
30736 \cs_generate_variant:Nn \hbox_gset:Nn { c }
30737 \cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3
30738 {
30739 \tex_setbox:D #1 \tex_hbox:D to \__box_dim_eval:n {#2}
30740 { \color_group_begin: #3 \color_group_end: }
30741 }
30742 \cs_new_protected:Npn \hbox_gset_to_wd:Nnn #1#2#3
30743 {
30744 \tex_global:D \tex_setbox:D #1 \tex_hbox:D to \__box_dim_eval:n {#2}
30745 { \color_group_begin: #3 \color_group_end: }
30746 }
30747 \cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c }
30748 \cs_generate_variant:Nn \hbox_gset_to_wd:Nnn { c }
30749 \cs_new_protected:Npn \hbox_set:Nw #1
30750 {
30751 \tex_setbox:D #1 \tex_hbox:D
30752 \c_group_begin_token
30753 \color_group_begin:
30754 }
30755 \cs_new_protected:Npn \hbox_gset:Nw #1
30756 {
30757 \tex_global:D \tex_setbox:D #1 \tex_hbox:D
30758 \c_group_begin_token
30759 \color_group_begin:
30760 }
30761 \cs_generate_variant:Nn \hbox_set:Nw { c }
30762 \cs_generate_variant:Nn \hbox_gset:Nw { c }
30763 \cs_new_protected:Npn \hbox_set_end:
30764 {
30765 \color_group_end:
30766 \c_group_end_token
30767 }
30768 \cs_new_eq:NN \hbox_gset_end: \hbox_set_end:
30769 \cs_new_protected:Npn \hbox_set_to_wd:Nnw #1#2
30770 {
30771 \tex_setbox:D #1 \tex_hbox:D to \__box_dim_eval:n {#2}
30772 \c_group_begin_token
30773 \color_group_begin:
30774 }
30775 \cs_new_protected:Npn \hbox_gset_to_wd:Nnw #1#2
30776 {
30777 \tex_global:D \tex_setbox:D #1 \tex_hbox:D to \__box_dim_eval:n {#2}
30778 \c_group_begin_token
30779 \color_group_begin:
30780 }
30781 \cs_generate_variant:Nn \hbox_set_to_wd:Nnw { c }
30782 \cs_generate_variant:Nn \hbox_gset_to_wd:Nnw { c }
30783 \cs_new_protected:Npn \hbox_to_wd:nn #1#2
30784 {
30785 \tex_hbox:D to \__box_dim_eval:n {#1}
30786 { \color_group_begin: #2 \color_group_end: }
30787 }
30788 \cs_new_protected:Npn \hbox_to_zero:n #1
30789 {
30790 \tex_hbox:D to \c_zero_dim
30791 { \color_group_begin: #1 \color_group_end: }
30792 }
30793 \cs_new_protected:Npn \hbox_overlap_center:n #1
30794 { \hbox_to_zero:n { \tex_hss:D #1 \tex_hss:D } }
30795 \cs_new_protected:Npn \hbox_overlap_left:n #1
30796 { \hbox_to_zero:n { \tex_hss:D #1 } }
30797 \cs_new_protected:Npn \hbox_overlap_right:n #1
30798 { \hbox_to_zero:n { #1 \tex_hss:D } }
30799 \cs_new_eq:NN \hbox_unpack:N \tex_unhcopy:D
30800 \cs_new_eq:NN \hbox_unpack_drop:N \tex_unhbox:D
30801 \cs_generate_variant:Nn \hbox_unpack:N { c }
30802 \cs_generate_variant:Nn \hbox_unpack_drop:N { c }
30803 \cs_new_protected:Npn \vbox:n #1
30804 { \tex_vbox:D { \color_group_begin: #1 \par \color_group_end: } }
30805 \cs_new_protected:Npn \vbox_top:n #1
30806 { \tex_vtop:D { \color_group_begin: #1 \par \color_group_end: } }
30807 \cs_new_protected:Npn \vbox:w
30808 { \tex_vbox:D \c_group_begin_token \color_group_begin: }
30809 \cs_new_protected:Npn \vbox_top:w
30810 { \tex_vtop:D \c_group_begin_token \color_group_begin: }
30811 \cs_new_protected:Npn \vbox_end:
30812 {
30813 \par
30814 \color_group_end:
30815 \c_group_end_token
30816 }
30817 \dim_new:N \l__box_delta_dim
30818 \dim_new:N \l__box_voffset_dim
30819 \cs_new_protected:Npn \vbox_center:nw
30820 { \__box_vcenter:nnw { } }
30821 \cs_new_protected:Npn \vbox_center:w
30822 { \__box_vcenter:nnw { } \c_zero_dim }
30823 \cs_new_protected:Npn \vbox_center_to_ht:nw #1
30824 { \__box_vcenter:nnw { to \__box_dim_eval:n {#1} } \c_zero_dim }
30825 \cs_new_protected:Npn \__box_vcenter:nnw #1#2
30826 {
30827 \dim_set:Nn \l__box_voffset_dim {#2}
30828 \tex_setbox:D \l__box_tmp_box \tex_vbox:D #1
30829 \c_group_begin_token
30830 \group_insert_after:N \__box_vcenter_aux:
30831 \color_group_begin:
30832 }
30833 \cs_new_protected:Npn \__box_vcenter_aux:
30834 { \__box_vcenter_calc:n \l__box_voffset_dim }
30835 \cs_new_protected:Npn \vbox_center:nn
30836 { \__box_vcenter:Nnnn \vbox_set:Nn { } }
30837 \cs_new_protected:Npn \vbox_center:n
30838 { \__box_vcenter:Nnnn \vbox_set:Nn { } \c_zero_dim }
30839 \cs_new_protected:Npn \vbox_center_to_ht:nn #1
30840 { \__box_vcenter:Nnnn \vbox_set_to_ht:Nnn { {#1} } \c_zero_dim }
30841 \cs_new_protected:Npn \__box_vcenter:Nnnn #1#2#3#4
30842 {
30843 #1 \l__box_tmp_box #2 {#4}
30844 \__box_vcenter_calc:n {#3}
30845 }
30846 \cs_new_protected:Npn \__box_vcenter_calc:n #1
30847 {
30848 \dim_set:Nn \l__box_delta_dim
30849 { \box_ht:N \l__box_tmp_box + \box_dp:N \l__box_tmp_box }
30850 \tex_ht:D \l__box_tmp_box \__box_dim_eval:n
30851 {
30852 \__box_dim_eval:n
30853 { \tex_ifodd:D \l__box_delta_dim 1sp + \tex_fi:D \l__box_delta_dim }
30854 / 2
30855 + (#1)
30856 }
30857 \tex_dp:D \l__box_tmp_box \__box_dim_eval:n
30858 { \l__box_delta_dim - \box_ht:N \l__box_tmp_box }
30859 \box_use_drop:N \l__box_tmp_box
30860 }
30861 \cs_new_protected:Npn \vbox_to_ht:nn #1#2
30862 { \__box_to_ht:Nnn \tex_vbox:D {#1} {#2} }
30863 \cs_new_protected:Npn \vbox_top_to_ht:nn #1#2
30864 { \__box_to_ht:Nnn \tex_vtop:D {#1} {#2} }
30865 \cs_new_protected:Npn \__box_to_ht:Nnn #1#2#3
30866 {
30867 #1 to \__box_dim_eval:n {#2}
30868 { \color_group_begin: #3 \par \color_group_end: }
30869 }
30870 \cs_new_protected:Npn \vbox_to_ht:nw #1
30871 { \__box_to_ht:Nnw \tex_vbox:D {#1} }
30872 \cs_new_protected:Npn \vbox_top_to_ht:nw #1
30873 { \__box_to_ht:Nnw \tex_vtop:D {#1} }
30874 \cs_new_protected:Npn \__box_to_ht:Nnw #1#2
30875 {
30876 #1 to \__box_dim_eval:n {#2}
30877 \c_group_begin_token
30878 \color_group_begin:
30879 }
30880 \cs_new_protected:Npn \vbox_to_zero:n #1
30881 { \vbox_to_ht:nn { 0pt } {#1} }
30882 \cs_new_protected:Npn \vbox:nw
30883 { \__box_voffset:Nnnw \tex_vbox:D { } }
30884 \cs_new_protected:Npn \vbox_top:nw
30885 { \__box_voffset:Nnnw \tex_vtop:D { } }
30886 \cs_new_protected:Npn \__box_voffset:Nnnw #1#2#3
30887 {
30888 \dim_set:Nn \l__box_voffset_dim {#3}
30889 \tex_setbox:D \l__box_tmp_box #1 #2
30890 \c_group_begin_token
30891 \group_insert_after:N \__box_voffset_aux:
30892 \color_group_begin:
30893 }
30894 \cs_new_protected:Npn \__box_voffset_aux:
30895 { \__box_voffset_calc:n \l__box_voffset_dim }
30896 \cs_new_protected:Npn \vbox:nn
30897 { \__box_voffset:Nnnn \vbox_set:Nn { } }
30898 \cs_new_protected:Npn \vbox_top:nn
30899 { \__box_voffset:Nnnn \vbox_set_top:Nn { } }
30900 \cs_new_protected:Npn \__box_voffset:Nnnn #1#2#3#4
30901 {
30902 #1 \l__box_tmp_box #2 {#4}
30903 \__box_voffset_calc:n {#3}
30904 }
30905 \cs_new_protected:Npn \__box_voffset_calc:n #1
30906 {
30907 \box_set_ht:Nn \l__box_tmp_box
30908 { \box_ht:N \l__box_tmp_box + (#1) }
30909 \box_set_dp:Nn \l__box_tmp_box
30910 { \box_dp:N \l__box_tmp_box - (#1) }
30911 \box_use_drop:N \l__box_tmp_box
30912 }
30913 \cs_new_protected:Npn \vbox_set:Nn #1#2
30914 {
30915 \tex_setbox:D #1 \tex_vbox:D
30916 { \color_group_begin: #2 \par \color_group_end: }
30917 }
30918 \cs_new_protected:Npn \vbox_gset:Nn #1#2
30919 {
30920 \tex_global:D \tex_setbox:D #1 \tex_vbox:D
30921 { \color_group_begin: #2 \par \color_group_end: }
30922 }
30923 \cs_generate_variant:Nn \vbox_set:Nn { c }
30924 \cs_generate_variant:Nn \vbox_gset:Nn { c }
30925 \cs_new_protected:Npn \vbox_set_top:Nn #1#2
30926 {
30927 \tex_setbox:D #1 \tex_vtop:D
30928 { \color_group_begin: #2 \par \color_group_end: }
30929 }
30930 \cs_new_protected:Npn \vbox_gset_top:Nn #1#2
30931 {
30932 \tex_global:D \tex_setbox:D #1 \tex_vtop:D
30933 { \color_group_begin: #2 \par \color_group_end: }
30934 }
30935 \cs_generate_variant:Nn \vbox_set_top:Nn { c }
30936 \cs_generate_variant:Nn \vbox_gset_top:Nn { c }
30937 \cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3
30938 {
30939 \tex_setbox:D #1 \tex_vbox:D to \__box_dim_eval:n {#2}
30940 { \color_group_begin: #3 \par \color_group_end: }
30941 }
30942 \cs_new_protected:Npn \vbox_gset_to_ht:Nnn #1#2#3
30943 {
30944 \tex_global:D \tex_setbox:D #1 \tex_vbox:D to \__box_dim_eval:n {#2}
30945 { \color_group_begin: #3 \par \color_group_end: }
30946 }
30947 \cs_generate_variant:Nn \vbox_set_to_ht:Nnn { c }
30948 \cs_generate_variant:Nn \vbox_gset_to_ht:Nnn { c }
30949 \cs_new_protected:Npn \vbox_set:Nw #1
30950 {
30951 \tex_setbox:D #1 \tex_vbox:D
30952 \c_group_begin_token
30953 \color_group_begin:
30954 }
30955 \cs_new_protected:Npn \vbox_gset:Nw #1
30956 {
30957 \tex_global:D \tex_setbox:D #1 \tex_vbox:D
30958 \c_group_begin_token
30959 \color_group_begin:
30960 }
30961 \cs_generate_variant:Nn \vbox_set:Nw { c }
30962 \cs_generate_variant:Nn \vbox_gset:Nw { c }
30963 \cs_new_eq:NN \vbox_set_end: \vbox_end:
30964 \cs_new_eq:NN \vbox_gset_end: \vbox_end:
30965 \cs_new_protected:Npn \vbox_set_to_ht:Nnw #1#2
30966 {
30967 \tex_setbox:D #1 \tex_vbox:D to \__box_dim_eval:n {#2}
30968 \c_group_begin_token
30969 \color_group_begin:
30970 }
30971 \cs_new_protected:Npn \vbox_gset_to_ht:Nnw #1#2
30972 {
30973 \tex_global:D \tex_setbox:D #1 \tex_vbox:D to \__box_dim_eval:n {#2}
30974 \c_group_begin_token
30975 \color_group_begin:
30976 }
30977 \cs_generate_variant:Nn \vbox_set_to_ht:Nnw { c }
30978 \cs_generate_variant:Nn \vbox_gset_to_ht:Nnw { c }
30979 \cs_new_eq:NN \vbox_unpack:N \tex_unvcopy:D
30980 \cs_new_eq:NN \vbox_unpack_drop:N \tex_unvbox:D
30981 \cs_generate_variant:Nn \vbox_unpack:N { c }
30982 \cs_generate_variant:Nn \vbox_unpack_drop:N { c }
30983 \cs_new_protected:Npn \vbox_set_split_to_ht:NNn #1#2#3
30984 { \tex_setbox:D #1 \tex_vsplit:D #2 to \__box_dim_eval:n {#3} }
30985 \cs_generate_variant:Nn \vbox_set_split_to_ht:NNn { c , Nc , cc }
30986 \cs_new_protected:Npn \vbox_gset_split_to_ht:NNn #1#2#3
30987 {
30988 \tex_global:D \tex_setbox:D #1
30989 \tex_vsplit:D #2 to \__box_dim_eval:n {#3}
30990 }
30991 \cs_generate_variant:Nn \vbox_gset_split_to_ht:NNn { c , Nc , cc }
30992 \fp_new:N \l__box_angle_fp
30993 \fp_new:N \l__box_cos_fp
30994 \fp_new:N \l__box_sin_fp
30995 \dim_new:N \l__box_top_dim
30996 \dim_new:N \l__box_bottom_dim
30997 \dim_new:N \l__box_left_dim
30998 \dim_new:N \l__box_right_dim
30999 \dim_new:N \l__box_top_new_dim
31000 \dim_new:N \l__box_bottom_new_dim
31001 \dim_new:N \l__box_left_new_dim
31002 \dim_new:N \l__box_right_new_dim
31003 \box_new:N \l__box_tmp_box
31004 \cs_new_protected:Npn \box_rotate:Nn #1#2
31005 { \__box_rotate:NnN #1 {#2} \hbox_set:Nn }
31006 \cs_generate_variant:Nn \box_rotate:Nn { c }
31007 \cs_new_protected:Npn \box_grotate:Nn #1#2
31008 { \__box_rotate:NnN #1 {#2} \hbox_gset:Nn }
31009 \cs_generate_variant:Nn \box_grotate:Nn { c }
31010 \cs_new_protected:Npn \__box_rotate:NnN #1#2#3
31011 {
31012 #3 #1
31013 {
31014 \fp_set:Nn \l__box_angle_fp {#2}
31015 \fp_set:Nn \l__box_sin_fp { sind ( \l__box_angle_fp ) }
31016 \fp_set:Nn \l__box_cos_fp { cosd ( \l__box_angle_fp ) }
31017 \__box_rotate:N #1
31018 }
31019 }
31020 \cs_new_protected:Npn \__box_rotate:N #1
31021 {
31022 \dim_set:Nn \l__box_top_dim { \box_ht:N #1 }
31023 \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 }
31024 \dim_set:Nn \l__box_right_dim { \box_wd:N #1 }
31025 \dim_zero:N \l__box_left_dim
31026 \fp_compare:nNnTF \l__box_sin_fp > \c_zero_fp
31027 {
31028 \fp_compare:nNnTF \l__box_cos_fp > \c_zero_fp
31029 { \__box_rotate_quadrant_one: }
31030 { \__box_rotate_quadrant_two: }
31031 }
31032 {
31033 \fp_compare:nNnTF \l__box_cos_fp < \c_zero_fp
31034 { \__box_rotate_quadrant_three: }
31035 { \__box_rotate_quadrant_four: }
31036 }
31037 \hbox_set:Nn \l__box_tmp_box { \box_use:N #1 }
31038 \hbox_set:Nn \l__box_tmp_box
31039 {
31040 \dim_horizontal:n { -\l__box_left_new_dim }
31041 \hbox:n
31042 {
31043 \__box_backend_rotate:Nn
31044 \l__box_tmp_box
31045 \l__box_angle_fp
31046 }
31047 }
31048 \box_set_ht:Nn \l__box_tmp_box { \l__box_top_new_dim }
31049 \box_set_dp:Nn \l__box_tmp_box { -\l__box_bottom_new_dim }
31050 \box_set_wd:Nn \l__box_tmp_box
31051 { \l__box_right_new_dim - \l__box_left_new_dim }
31052 \box_use_drop:N \l__box_tmp_box
31053 }
31054 \cs_new_protected:Npn \__box_rotate_xdir:nnN #1#2#3
31055 {
31056 \dim_set:Nn #3
31057 {
31058 \fp_to_dim:n
31059 {
31060 \l__box_cos_fp * \dim_to_fp:n {#1}
31061 - \l__box_sin_fp * \dim_to_fp:n {#2}
31062 }
31063 }
31064 }
31065 \cs_new_protected:Npn \__box_rotate_ydir:nnN #1#2#3
31066 {
31067 \dim_set:Nn #3
31068 {
31069 \fp_to_dim:n
31070 {
31071 \l__box_sin_fp * \dim_to_fp:n {#1}
31072 + \l__box_cos_fp * \dim_to_fp:n {#2}
31073 }
31074 }
31075 }
31076 \cs_new_protected:Npn \__box_rotate_quadrant_one:
31077 {
31078 \__box_rotate_ydir:nnN \l__box_right_dim \l__box_top_dim
31079 \l__box_top_new_dim
31080 \__box_rotate_ydir:nnN \l__box_left_dim \l__box_bottom_dim
31081 \l__box_bottom_new_dim
31082 \__box_rotate_xdir:nnN \l__box_left_dim \l__box_top_dim
31083 \l__box_left_new_dim
31084 \__box_rotate_xdir:nnN \l__box_right_dim \l__box_bottom_dim
31085 \l__box_right_new_dim
31086 }
31087 \cs_new_protected:Npn \__box_rotate_quadrant_two:
31088 {
31089 \__box_rotate_ydir:nnN \l__box_right_dim \l__box_bottom_dim
31090 \l__box_top_new_dim
31091 \__box_rotate_ydir:nnN \l__box_left_dim \l__box_top_dim
31092 \l__box_bottom_new_dim
31093 \__box_rotate_xdir:nnN \l__box_right_dim \l__box_top_dim
31094 \l__box_left_new_dim
31095 \__box_rotate_xdir:nnN \l__box_left_dim \l__box_bottom_dim
31096 \l__box_right_new_dim
31097 }
31098 \cs_new_protected:Npn \__box_rotate_quadrant_three:
31099 {
31100 \__box_rotate_ydir:nnN \l__box_left_dim \l__box_bottom_dim
31101 \l__box_top_new_dim
31102 \__box_rotate_ydir:nnN \l__box_right_dim \l__box_top_dim
31103 \l__box_bottom_new_dim
31104 \__box_rotate_xdir:nnN \l__box_right_dim \l__box_bottom_dim
31105 \l__box_left_new_dim
31106 \__box_rotate_xdir:nnN \l__box_left_dim \l__box_top_dim
31107 \l__box_right_new_dim
31108 }
31109 \cs_new_protected:Npn \__box_rotate_quadrant_four:
31110 {
31111 \__box_rotate_ydir:nnN \l__box_left_dim \l__box_top_dim
31112 \l__box_top_new_dim
31113 \__box_rotate_ydir:nnN \l__box_right_dim \l__box_bottom_dim
31114 \l__box_bottom_new_dim
31115 \__box_rotate_xdir:nnN \l__box_left_dim \l__box_bottom_dim
31116 \l__box_left_new_dim
31117 \__box_rotate_xdir:nnN \l__box_right_dim \l__box_top_dim
31118 \l__box_right_new_dim
31119 }
31120 \fp_new:N \l__box_scale_x_fp
31121 \fp_new:N \l__box_scale_y_fp
31122 \cs_new_protected:Npn \box_resize_to_wd_and_ht_plus_dp:Nnn #1#2#3
31123 {
31124 \__box_resize_to_wd_and_ht_plus_dp:NnnN #1 {#2} {#3}
31125 \hbox_set:Nn
31126 }
31127 \cs_generate_variant:Nn \box_resize_to_wd_and_ht_plus_dp:Nnn { c }
31128 \cs_new_protected:Npn \box_gresize_to_wd_and_ht_plus_dp:Nnn #1#2#3
31129 {
31130 \__box_resize_to_wd_and_ht_plus_dp:NnnN #1 {#2} {#3}
31131 \hbox_gset:Nn
31132 }
31133 \cs_generate_variant:Nn \box_gresize_to_wd_and_ht_plus_dp:Nnn { c }
31134 \cs_new_protected:Npn \__box_resize_to_wd_and_ht_plus_dp:NnnN #1#2#3#4
31135 {
31136 #4 #1
31137 {
31138 \__box_resize_set_corners:N #1
31139 \fp_set:Nn \l__box_scale_x_fp
31140 { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } }
31141 \fp_set:Nn \l__box_scale_y_fp
31142 {
31143 \dim_to_fp:n {#3}
31144 / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim }
31145 }
31146 \__box_resize:N #1
31147 }
31148 }
31149 \cs_new_protected:Npn \__box_resize_set_corners:N #1
31150 {
31151 \dim_set:Nn \l__box_top_dim { \box_ht:N #1 }
31152 \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 }
31153 \dim_set:Nn \l__box_right_dim { \box_wd:N #1 }
31154 \dim_zero:N \l__box_left_dim
31155 }
31156 \cs_new_protected:Npn \__box_resize:N #1
31157 {
31158 \__box_resize:NNN \l__box_right_new_dim
31159 \l__box_scale_x_fp \l__box_right_dim
31160 \__box_resize:NNN \l__box_bottom_new_dim
31161 \l__box_scale_y_fp \l__box_bottom_dim
31162 \__box_resize:NNN \l__box_top_new_dim
31163 \l__box_scale_y_fp \l__box_top_dim
31164 \__box_resize_common:N #1
31165 }
31166 \cs_new_protected:Npn \__box_resize:NNN #1#2#3
31167 {
31168 \dim_set:Nn #1
31169 { \fp_to_dim:n { \fp_abs:n { #2 } * \dim_to_fp:n { #3 } } }
31170 }
31171 \cs_new_protected:Npn \box_resize_to_ht:Nn #1#2
31172 { \__box_resize_to_ht:NnN #1 {#2} \hbox_set:Nn }
31173 \cs_generate_variant:Nn \box_resize_to_ht:Nn { c }
31174 \cs_new_protected:Npn \box_gresize_to_ht:Nn #1#2
31175 { \__box_resize_to_ht:NnN #1 {#2} \hbox_gset:Nn }
31176 \cs_generate_variant:Nn \box_gresize_to_ht:Nn { c }
31177 \cs_new_protected:Npn \__box_resize_to_ht:NnN #1#2#3
31178 {
31179 #3 #1
31180 {
31181 \__box_resize_set_corners:N #1
31182 \fp_set:Nn \l__box_scale_y_fp
31183 {
31184 \dim_to_fp:n {#2}
31185 / \dim_to_fp:n { \l__box_top_dim }
31186 }
31187 \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp
31188 \__box_resize:N #1
31189 }
31190 }
31191 \cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2
31192 { \__box_resize_to_ht_plus_dp:NnN #1 {#2} \hbox_set:Nn }
31193 \cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c }
31194 \cs_new_protected:Npn \box_gresize_to_ht_plus_dp:Nn #1#2
31195 { \__box_resize_to_ht_plus_dp:NnN #1 {#2} \hbox_gset:Nn }
31196 \cs_generate_variant:Nn \box_gresize_to_ht_plus_dp:Nn { c }
31197 \cs_new_protected:Npn \__box_resize_to_ht_plus_dp:NnN #1#2#3
31198 {
31199 #3 #1
31200 {
31201 \__box_resize_set_corners:N #1
31202 \fp_set:Nn \l__box_scale_y_fp
31203 {
31204 \dim_to_fp:n {#2}
31205 / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim }
31206 }
31207 \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp
31208 \__box_resize:N #1
31209 }
31210 }
31211 \cs_new_protected:Npn \box_resize_to_wd:Nn #1#2
31212 { \__box_resize_to_wd:NnN #1 {#2} \hbox_set:Nn }
31213 \cs_generate_variant:Nn \box_resize_to_wd:Nn { c }
31214 \cs_new_protected:Npn \box_gresize_to_wd:Nn #1#2
31215 { \__box_resize_to_wd:NnN #1 {#2} \hbox_gset:Nn }
31216 \cs_generate_variant:Nn \box_gresize_to_wd:Nn { c }
31217 \cs_new_protected:Npn \__box_resize_to_wd:NnN #1#2#3
31218 {
31219 #3 #1
31220 {
31221 \__box_resize_set_corners:N #1
31222 \fp_set:Nn \l__box_scale_x_fp
31223 { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } }
31224 \fp_set_eq:NN \l__box_scale_y_fp \l__box_scale_x_fp
31225 \__box_resize:N #1
31226 }
31227 }
31228 \cs_new_protected:Npn \box_resize_to_wd_and_ht:Nnn #1#2#3
31229 { \__box_resize_to_wd_and_ht:NnnN #1 {#2} {#3} \hbox_set:Nn }
31230 \cs_generate_variant:Nn \box_resize_to_wd_and_ht:Nnn { c }
31231 \cs_new_protected:Npn \box_gresize_to_wd_and_ht:Nnn #1#2#3
31232 { \__box_resize_to_wd_and_ht:NnnN #1 {#2} {#3} \hbox_gset:Nn }
31233 \cs_generate_variant:Nn \box_gresize_to_wd_and_ht:Nnn { c }
31234 \cs_new_protected:Npn \__box_resize_to_wd_and_ht:NnnN #1#2#3#4
31235 {
31236 #4 #1
31237 {
31238 \__box_resize_set_corners:N #1
31239 \fp_set:Nn \l__box_scale_x_fp
31240 { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } }
31241 \fp_set:Nn \l__box_scale_y_fp
31242 {
31243 \dim_to_fp:n {#3}
31244 / \dim_to_fp:n { \l__box_top_dim }
31245 }
31246 \__box_resize:N #1
31247 }
31248 }
31249 \cs_new_protected:Npn \box_scale:Nnn #1#2#3
31250 { \__box_scale:NnnN #1 {#2} {#3} \hbox_set:Nn }
31251 \cs_generate_variant:Nn \box_scale:Nnn { c }
31252 \cs_new_protected:Npn \box_gscale:Nnn #1#2#3
31253 { \__box_scale:NnnN #1 {#2} {#3} \hbox_gset:Nn }
31254 \cs_generate_variant:Nn \box_gscale:Nnn { c }
31255 \cs_new_protected:Npn \__box_scale:NnnN #1#2#3#4
31256 {
31257 #4 #1
31258 {
31259 \fp_set:Nn \l__box_scale_x_fp {#2}
31260 \fp_set:Nn \l__box_scale_y_fp {#3}
31261 \__box_scale:N #1
31262 }
31263 }
31264 \cs_new_protected:Npn \__box_scale:N #1
31265 {
31266 \dim_set:Nn \l__box_top_dim { \box_ht:N #1 }
31267 \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 }
31268 \dim_set:Nn \l__box_right_dim { \box_wd:N #1 }
31269 \dim_zero:N \l__box_left_dim
31270 \dim_set:Nn \l__box_top_new_dim
31271 { \fp_abs:n { \l__box_scale_y_fp } \l__box_top_dim }
31272 \dim_set:Nn \l__box_bottom_new_dim
31273 { \fp_abs:n { \l__box_scale_y_fp } \l__box_bottom_dim }
31274 \dim_set:Nn \l__box_right_new_dim
31275 { \fp_abs:n { \l__box_scale_x_fp } \l__box_right_dim }
31276 \__box_resize_common:N #1
31277 }
31278 \cs_new_protected:Npn \box_autosize_to_wd_and_ht:Nnn #1#2#3
31279 { \__box_autosize:NnnnN #1 {#2} {#3} { \box_ht:N #1 } \hbox_set:Nn }
31280 \cs_generate_variant:Nn \box_autosize_to_wd_and_ht:Nnn { c }
31281 \cs_new_protected:Npn \box_gautosize_to_wd_and_ht:Nnn #1#2#3
31282 { \__box_autosize:NnnnN #1 {#2} {#3} { \box_ht:N #1 } \hbox_gset:Nn }
31283 \cs_generate_variant:Nn \box_gautosize_to_wd_and_ht:Nnn { c }
31284 \cs_new_protected:Npn \box_autosize_to_wd_and_ht_plus_dp:Nnn #1#2#3
31285 {
31286 \__box_autosize:NnnnN #1 {#2} {#3} { \box_ht:N #1 + \box_dp:N #1 }
31287 \hbox_set:Nn
31288 }
31289 \cs_generate_variant:Nn \box_autosize_to_wd_and_ht_plus_dp:Nnn { c }
31290 \cs_new_protected:Npn \box_gautosize_to_wd_and_ht_plus_dp:Nnn #1#2#3
31291 {
31292 \__box_autosize:NnnnN #1 {#2} {#3} { \box_ht:N #1 + \box_dp:N #1 }
31293 \hbox_gset:Nn
31294 }
31295 \cs_generate_variant:Nn \box_gautosize_to_wd_and_ht_plus_dp:Nnn { c }
31296 \cs_new_protected:Npn \__box_autosize:NnnnN #1#2#3#4#5
31297 {
31298 #5 #1
31299 {
31300 \fp_set:Nn \l__box_scale_x_fp { ( \dim_to_fp:n {#2} ) / \box_wd:N #1 }
31301 \fp_set:Nn \l__box_scale_y_fp
31302 { ( \dim_to_fp:n {#3} ) / ( \dim_to_fp:n {#4} ) }
31303 \fp_compare:nNnTF \l__box_scale_x_fp > \l__box_scale_y_fp
31304 { \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp }
31305 { \fp_set_eq:NN \l__box_scale_y_fp \l__box_scale_x_fp }
31306 \__box_scale:N #1
31307 }
31308 }
31309 \cs_new_protected:Npn \__box_resize_common:N #1
31310 {
31311 \hbox_set:Nn \l__box_tmp_box
31312 {
31313 \__box_backend_scale:Nnn
31314 #1
31315 \l__box_scale_x_fp
31316 \l__box_scale_y_fp
31317 }
31318 \fp_compare:nNnTF \l__box_scale_y_fp > \c_zero_fp
31319 {
31320 \box_set_ht:Nn \l__box_tmp_box { \l__box_top_new_dim }
31321 \box_set_dp:Nn \l__box_tmp_box { -\l__box_bottom_new_dim }
31322 }
31323 {
31324 \box_set_dp:Nn \l__box_tmp_box { \l__box_top_new_dim }
31325 \box_set_ht:Nn \l__box_tmp_box { -\l__box_bottom_new_dim }
31326 }
31327 \fp_compare:nNnTF \l__box_scale_x_fp < \c_zero_fp
31328 {
31329 \hbox_to_wd:nn { \l__box_right_new_dim }
31330 {
31331 \dim_horizontal:N \l__box_right_new_dim
31332 \box_use_drop:N \l__box_tmp_box
31333 \tex_hss:D
31334 }
31335 }
31336 {
31337 \box_set_wd:Nn \l__box_tmp_box { \l__box_right_new_dim }
31338 \hbox:n
31339 {
31340 \dim_horizontal:n{ 0pt }
31341 \box_use_drop:N \l__box_tmp_box
31342 \tex_hss:D
31343 }
31344 }
31345 }
31346 \cs_new_protected:Npn \__box_rule_horizontal:nn #1#2
31347 {
31348 \tex_hrule:D
31349 height \__box_dim_eval:n {#1}
31350 depth \__box_dim_eval:n {#2}
31351 \scan_stop:
31352 }
31353 \cs_new_protected:Npn \__box_rule_vertical:n #1
31354 { \tex_vrule:D width \__box_dim_eval:n {#1} \scan_stop: }
31355 \cs_new_protected:Npn \box_frame:Nnn #1#2#3
31356 {
31357 \__box_frame:eeNN { \dim_eval:n {#2} } { \dim_eval:n {#3} }
31358 #1 \hbox_set:Nn
31359 }
31360 \cs_generate_variant:Nn \box_frame:Nnn { c }
31361 \cs_new_protected:Npn \box_gframe:Nnn #1#2#3
31362 {
31363 \__box_frame:eeNN { \dim_eval:n {#2} } { \dim_eval:n {#3} }
31364 #1 \hbox_gset:Nn
31365 }
31366 \cs_generate_variant:Nn \box_gframe:Nnn { c }
31367 \cs_new_protected:Npn \__box_frame:nnNN #1#2#3#4
31368 {
31369 #4 #3
31370 {
31371 \dim_horizontal:n { #1 + #2 }
31372 \box_use:N #3
31373 \dim_horizontal:n { -\box_wd:N #3 - #1 - #2 }
31374 \box_move_down:nn { \box_dp:N #3 + #1 + #2 }
31375 {
31376 \vbox:n
31377 {
31378 \__box_rule_horizontal:nn {#2} { \c_zero_dim }
31379 \hbox:n
31380 {
31381 \__box_rule_vertical:n {#2}
31382 \dim_horizontal:n { #1 * 2 + \box_wd:N #3 }
31383 \vbox:n
31384 {
31385 \dim_vertical:n
31386 { #1 * 2 + \box_dp:N #3 + \box_ht:N #3 }
31387 }
31388 \__box_rule_vertical:n {#2}
31389 }
31390 \__box_rule_horizontal:nn {#2} { \c_zero_dim }
31391 }
31392 }
31393 }
31394 }
31395 \cs_generate_variant:Nn \__box_frame:nnNN { ee }
31396 \cs_new_protected:Npn \box_underline:Nnn #1#2#3
31397 {
31398 \__box_underline:eeNN
31399 { \dim_eval:n {#2} } { \dim_eval:n {#3} }
31400 #1 \hbox_set:Nn
31401 }
31402 \cs_generate_variant:Nn \box_underline:Nnn { c }
31403 \cs_new_protected:Npn \box_gunderline:Nnn #1#2#3
31404 {
31405 \__box_underline:eeNN
31406 { \dim_eval:n {#2} } { \dim_eval:n {#3} }
31407 #1 \hbox_gset:Nn
31408 }
31409 \cs_generate_variant:Nn \box_gunderline:Nnn { c }
31410 \cs_new_protected:Npn \__box_underline:nnNN #1#2#3#4
31411 {
31412 #4 #3
31413 {
31414 \box_use:N #3
31415 \dim_horizontal:n { -\box_wd:N #3 }
31416 \box_move_down:nn { \box_dp:N #3 + #1 + #2 }
31417 {
31418 \vbox:n
31419 {
31420 \hbox:n { \dim_horizontal:n { \box_wd:N #3 } }
31421 \__box_rule_horizontal:nn {#2} { \c_zero_dim }
31422 }
31423 }
31424 }
31425 }
31426 \cs_generate_variant:Nn \__box_underline:nnNN { ee }
31427 \cs_new_protected:Npn \box_set_clipped:N #1
31428 { \hbox_set:Nn #1 { \__box_backend_clip:N #1 } }
31429 \cs_generate_variant:Nn \box_set_clipped:N { c }
31430 \cs_new_protected:Npn \box_gset_clipped:N #1
31431 { \hbox_gset:Nn #1 { \__box_backend_clip:N #1 } }
31432 \cs_generate_variant:Nn \box_gset_clipped:N { c }
31433 \cs_new_protected:Npn \box_set_trim:Nnnnn #1#2#3#4#5
31434 { \__box_set_trim:NnnnnN #1 {#2} {#3} {#4} {#5} \box_set_eq:NN }
31435 \cs_generate_variant:Nn \box_set_trim:Nnnnn { c }
31436 \cs_new_protected:Npn \box_gset_trim:Nnnnn #1#2#3#4#5
31437 { \__box_set_trim:NnnnnN #1 {#2} {#3} {#4} {#5} \box_gset_eq:NN }
31438 \cs_generate_variant:Nn \box_gset_trim:Nnnnn { c }
31439 \cs_new_protected:Npn \__box_set_trim:NnnnnN #1#2#3#4#5#6
31440 {
31441 \hbox_set:Nn \l__box_tmp_box
31442 {
31443 \dim_horizontal:n { -#2 }
31444 \box_use:N #1
31445 \dim_horizontal:n { -#4 }
31446 }
31447 \dim_compare:nNnTF { \box_dp:N #1 } > {#3}
31448 {
31449 \hbox_set:Nn \l__box_tmp_box
31450 {
31451 \box_move_down:nn \c_zero_dim
31452 { \box_use_drop:N \l__box_tmp_box }
31453 }
31454 \box_set_dp:Nn \l__box_tmp_box { \box_dp:N #1 - (#3) }
31455 }
31456 {
31457 \hbox_set:Nn \l__box_tmp_box
31458 {
31459 \box_move_down:nn { (#3) - \box_dp:N #1 }
31460 { \box_use_drop:N \l__box_tmp_box }
31461 }
31462 \box_set_dp:Nn \l__box_tmp_box \c_zero_dim
31463 }
31464 \dim_compare:nNnTF { \box_ht:N \l__box_tmp_box } > {#5}
31465 {
31466 \hbox_set:Nn \l__box_tmp_box
31467 {
31468 \box_move_up:nn \c_zero_dim
31469 { \box_use_drop:N \l__box_tmp_box }
31470 }
31471 \box_set_ht:Nn \l__box_tmp_box
31472 { \box_ht:N \l__box_tmp_box - (#5) }
31473 }
31474 {
31475 \hbox_set:Nn \l__box_tmp_box
31476 {
31477 \box_move_up:nn { (#5) - \box_ht:N \l__box_tmp_box }
31478 { \box_use_drop:N \l__box_tmp_box }
31479 }
31480 \box_set_ht:Nn \l__box_tmp_box \c_zero_dim
31481 }
31482 #6 #1 \l__box_tmp_box
31483 }
31484 \cs_new_protected:Npn \box_set_viewport:Nnnnn #1#2#3#4#5
31485 { \__box_set_viewport:NnnnnN #1 {#2} {#3} {#4} {#5} \box_set_eq:NN }
31486 \cs_generate_variant:Nn \box_set_viewport:Nnnnn { c }
31487 \cs_new_protected:Npn \box_gset_viewport:Nnnnn #1#2#3#4#5
31488 { \__box_set_viewport:NnnnnN #1 {#2} {#3} {#4} {#5} \box_gset_eq:NN }
31489 \cs_generate_variant:Nn \box_gset_viewport:Nnnnn { c }
31490 \cs_new_protected:Npn \__box_set_viewport:NnnnnN #1#2#3#4#5#6
31491 {
31492 \hbox_set:Nn \l__box_tmp_box
31493 {
31494 \dim_horizontal:n { -#2 }
31495 \box_use:N #1
31496 \dim_horizontal:n { #4 - \box_wd:N #1 }
31497 }
31498 \dim_compare:nNnTF {#3} < \c_zero_dim
31499 {
31500 \hbox_set:Nn \l__box_tmp_box
31501 {
31502 \box_move_down:nn \c_zero_dim
31503 { \box_use_drop:N \l__box_tmp_box }
31504 }
31505 \box_set_dp:Nn \l__box_tmp_box { - \__box_dim_eval:n {#3} }
31506 }
31507 {
31508 \hbox_set:Nn \l__box_tmp_box
31509 { \box_move_down:nn {#3} { \box_use_drop:N \l__box_tmp_box } }
31510 \box_set_dp:Nn \l__box_tmp_box \c_zero_dim
31511 }
31512 \dim_compare:nNnTF {#5} > \c_zero_dim
31513 {
31514 \hbox_set:Nn \l__box_tmp_box
31515 {
31516 \box_move_up:nn \c_zero_dim
31517 { \box_use_drop:N \l__box_tmp_box }
31518 }
31519 \box_set_ht:Nn \l__box_tmp_box
31520 {
31521 (#5)
31522 \dim_compare:nNnT {#3} > \c_zero_dim
31523 { - (#3) }
31524 }
31525 }
31526 {
31527 \hbox_set:Nn \l__box_tmp_box
31528 {
31529 \box_move_up:nn { - \__box_dim_eval:n {#5} }
31530 { \box_use_drop:N \l__box_tmp_box }
31531 }
31532 \box_set_ht:Nn \l__box_tmp_box \c_zero_dim
31533 }
31534 #6 #1 \l__box_tmp_box
31535 }
31536 %% File: l3color.dtx
31537 \cs_new_eq:NN \color_group_begin: \group_begin:
31538 \cs_new_eq:NN \color_group_end: \group_end:
31539 \cs_new_protected:Npn \color_ensure_current:
31540 { \__color_select:N \l__color_current_tl }
31541 \scan_new:N \s__color_stop
31542 \cs_new_protected:Npn \__color_select:N #1
31543 {
31544 \exp_after:wN \__color_select:nn #1
31545 \group_insert_after:N \__color_backend_reset:
31546 }
31547 \cs_new_protected:Npn \__color_select_math:N #1
31548 { \exp_after:wN \__color_select:nn #1 }
31549 \cs_new_protected:Npn \__color_select:nn #1#2
31550 { \use:c { __color_backend_select_ #1 :n } {#2} }
31551 \tl_new:N \l__color_current_tl
31552 \tl_set:Nn \l__color_current_tl { { gray } { 0 } }
31553 \int_new:N \l__color_tmp_int
31554 \tl_new:N \l__color_tmp_tl
31555 \scan_new:N \s__color_mark
31556 \bool_new:N \l__color_ignore_error_bool
31557 \prg_new_conditional:Npnn \color_if_exist:n #1 { p , T, F, TF }
31558 {
31559 \prop_if_exist:cTF { l__color_named_ #1 _prop }
31560 {
31561 \prop_if_empty:cTF { l__color_named_ #1 _prop }
31562 \prg_return_false:
31563 \prg_return_true:
31564 }
31565 \prg_return_false:
31566 }
31567 \cs_new:Npn \__color_model:N #1 { \exp_after:wN \use_i:nn #1 }
31568 \cs_new:Npn \__color_values:N #1 { \exp_after:wN \use_ii:nn #1 }
31569 \cs_new_protected:Npn \__color_extract:nNN #1#2#3
31570 {
31571 \tl_set_eq:Nc #2 { l__color_named_ #1 _tl }
31572 \prop_get:cVN { l__color_named_ #1 _prop } #2 #3
31573 }
31574 \cs_generate_variant:Nn \__color_extract:nNN { V }
31575 \cs_new_protected:Npn \__color_convert:nnN #1#2#3
31576 { \__color_convert:nnVN {#1} {#2} #3 #3 }
31577 \cs_generate_variant:Nn \__color_convert:nnN { VV }
31578 \cs_generate_variant:Nn \exp_last_unbraced:Nf { c }
31579 \cs_new_protected:Npn \__color_convert:nnnN #1#2#3#4
31580 {
31581 \tl_set:Ne #4
31582 {
31583 \cs_if_exist_use:cTF { __color_convert_ #1 _ #2 :w }
31584 { #3 \s__color_stop }
31585 {
31586 \cs_if_exist:cTF { __color_convert_ \use:c { c__color_fallback_ #1 _tl } _ #2 :w }
31587 {
31588 \exp_last_unbraced:cf
31589 { __color_convert_ \use:c { c__color_fallback_ #1 _tl } _ #2 :w }
31590 { \use:c { __color_convert_ #1 _ \use:c { c__color_fallback_ #1 _tl } :w } #3 \s__color_stop }
31591 \s__color_stop
31592 }
31593 {
31594 \exp_last_unbraced:cf
31595 { __color_convert_ \use:c { c__color_fallback_ #2 _tl } _ #2 :w }
31596 {
31597 \cs_if_exist_use:cTF { __color_convert_ #1 _ \use:c { c__color_fallback_ #2 _tl } :w }
31598 { #3 \s__color_stop }
31599 {
31600 \exp_last_unbraced:cf
31601 { __color_convert_ \use:c { c__color_fallback_ #1 _tl } _ \use:c { c__color_fallback_ #2 _tl } :w }
31602 { \use:c { __color_convert_ #1 _ \use:c { c__color_fallback_ #1 _tl } :w } #3 \s__color_stop }
31603 \s__color_stop
31604 }
31605 }
31606 \s__color_stop
31607 }
31608 }
31609 }
31610 }
31611 \cs_generate_variant:Nn \__color_convert:nnnN { nV , nnV }
31612 \cs_new:Npn \__color_convert_gray_gray:w #1 \s__color_stop
31613 { #1 }
31614 \cs_new:Npn \__color_convert_gray_rgb:w #1 \s__color_stop
31615 { #1 ~ #1 ~ #1 }
31616 \cs_new:Npn \__color_convert_gray_cmyk:w #1 \s__color_stop
31617 { 0 ~ 0 ~ 0 ~ \fp_eval:n { 1 - #1 } }
31618 \cs_new:Npn \__color_convert_rgb_gray:w #1 ~ #2 ~ #3 \s__color_stop
31619 { \fp_eval:n { 0.3 * #1 + 0.59 * #2 + 0.11 * #3 } }
31620 \cs_new:Npn \__color_convert_rgb_rgb:w #1 \s__color_stop
31621 { #1 }
31622 \cs_new:Npn \__color_convert_rgb_cmyk:w #1 ~ #2 ~ #3 \s__color_stop
31623 {
31624 \exp_args:Neee \__color_convert_rgb_cmyk:nnn
31625 { \fp_eval:n { 1 - #1 } }
31626 { \fp_eval:n { 1 - #2 } }
31627 { \fp_eval:n { 1 - #3 } }
31628 }
31629 \cs_new:Npn \__color_convert_rgb_cmyk:nnn #1#2#3
31630 {
31631 \exp_args:Ne \__color_convert_rgb_cmyk:nnnn
31632 { \fp_eval:n { min( #1, #2 , #3 ) } } {#1} {#2} {#3}
31633 }
31634 \cs_new:Npn \__color_convert_rgb_cmyk:nnnn #1#2#3#4
31635 {
31636 \fp_eval:n { min ( 1 , max ( 0 , #2 - #1 ) ) } \c_space_tl
31637 \fp_eval:n { min ( 1 , max ( 0 , #3 - #1 ) ) } \c_space_tl
31638 \fp_eval:n { min ( 1 , max ( 0 , #4 - #1 ) ) } \c_space_tl
31639 #1
31640 }
31641 \cs_new:Npn \__color_convert_cmyk_gray:w #1 ~ #2 ~ #3 ~ #4 \s__color_stop
31642 { \fp_eval:n { 1 - min ( 1 , 0.3 * #1 + 0.59 * #2 + 0.11 * #3 + #4 ) } }
31643 \cs_new:Npn \__color_convert_cmyk_rgb:w #1 ~ #2 ~ #3 ~ #4 \s__color_stop
31644 {
31645 \fp_eval:n { 1 - min ( 1 , #1 + #4 ) } \c_space_tl
31646 \fp_eval:n { 1 - min ( 1 , #2 + #4 ) } \c_space_tl
31647 \fp_eval:n { 1 - min ( 1 , #3 + #4 ) }
31648 }
31649 \cs_new:Npn \__color_convert_cmyk_cmyk:w #1 \s__color_stop
31650 { #1 }
31651 \tl_new:N \l__color_model_tl
31652 \tl_new:N \l__color_value_tl
31653 \tl_new:N \l__color_next_model_tl
31654 \tl_new:N \l__color_next_value_tl
31655 \cs_new_protected:Npe \__color_parse:nN #1#2
31656 {
31657 \tl_set:Ne \exp_not:c { l__color_named_ . _tl }
31658 { \exp_not:N \__color_model:N \exp_not:N \l__color_current_tl }
31659 \prop_put:NVe \exp_not:c { l__color_named_ . _prop }
31660 \exp_not:c { l__color_named_ . _tl }
31661 { \exp_not:N \__color_values:N \exp_not:N \l__color_current_tl }
31662 \exp_not:N \exp_args:Ne \exp_not:N \__color_parse_aux:nN
31663 { \exp_not:N \tl_to_str:n {#1} } #2
31664 }
31665 \cs_new_protected:Npn \__color_parse_aux:nN #1#2
31666 {
31667 \color_if_exist:nTF {#1}
31668 { \__color_parse_set_eq:Nn #2 {#1} }
31669 { \__color_parse:Nw #2#1 ! \s__color_stop }
31670 \__color_check_model:N #2
31671 }
31672 \cs_new_protected:Npn \__color_parse_set_eq:Nn #1#2
31673 {
31674 \tl_if_empty:NTF \l_color_fixed_model_tl
31675 { \exp_args:Nv \__color_parse_set_eq:nNn { l__color_named_ #2 _tl } }
31676 { \exp_args:NV \__color_parse_set_eq:nNn \l_color_fixed_model_tl }
31677 #1 {#2}
31678 }
31679 \cs_new_protected:Npn \__color_parse_set_eq:nNn #1#2#3
31680 {
31681 \prop_get:cnNTF
31682 { l__color_named_ #3 _prop } {#1}
31683 \l__color_value_tl
31684 { \tl_set:Ne #2 { {#1} { \l__color_value_tl } } }
31685 {
31686 \tl_set_eq:Nc \l__color_model_tl { l__color_named_ #3 _tl }
31687 \prop_get:cVN { l__color_named_ #3 _prop } \l__color_model_tl
31688 \l__color_value_tl
31689 \__color_convert:nnN
31690 \l__color_model_tl {#1} \l__color_value_tl
31691 \tl_set:Ne #2
31692 {
31693 {#1}
31694 { \l__color_value_tl }
31695 }
31696 }
31697 }
31698 \cs_new_protected:Npn \__color_parse:Nw #1#2 ! #3 \s__color_stop
31699 {
31700 \color_if_exist:nTF {#2}
31701 {
31702 \tl_if_blank:nTF {#3}
31703 { \__color_parse_set_eq:Nn #1 {#2} }
31704 { \__color_parse_loop_init:Nnn #1 {#2} {#3} }
31705 }
31706 {
31707 \msg_error:nnn { color } { unknown-color } {#2}
31708 \tl_set:Nn \l__color_current_tl { { gray } { 0 } }
31709 }
31710 }
31711 \cs_new_protected:Npn \__color_parse_loop_init:Nnn #1#2#3
31712 {
31713 \group_begin:
31714 \__color_extract:nNN {#2} \l__color_model_tl \l__color_value_tl
31715 \__color_parse_loop:w #3 ! ! ! ! \s__color_stop
31716 \tl_set:Ne \l__color_tmp_tl
31717 { { \l__color_model_tl } { \l__color_value_tl } }
31718 \exp_args:NNNV \group_end:
31719 \tl_set:Nn #1 \l__color_tmp_tl
31720 }
31721 \cs_new_protected:Npn \__color_parse_loop:w #1 ! #2 ! #3 ! #4 ! #5 \s__color_stop
31722 {
31723 \tl_if_blank:nF {#1}
31724 {
31725 \bool_lazy_and:nnTF
31726 { \fp_compare_p:nNn {#1} > { 0 } }
31727 { \fp_compare_p:nNn {#1} < { 100 } }
31728 {
31729 \use:e
31730 {
31731 \__color_parse_loop:nn {#1}
31732 { \tl_if_blank:nTF {#2} { white } {#2} }
31733 }
31734 }
31735 { \__color_parse_loop_check:nn {#1} {#2} }
31736 }
31737 \tl_if_blank:nF {#3}
31738 { \__color_parse_loop:w #3 ! #4 ! #5 \s__color_stop }
31739 \__color_parse_end:
31740 }
31741 \cs_new_protected:Npn \__color_parse_loop_check:nn #1#2
31742 {
31743 \bool_if:NF \l__color_ignore_error_bool
31744 {
31745 \bool_lazy_or:nnT
31746 { \fp_compare_p:nNn {#1} < { 0 } }
31747 { \fp_compare_p:nNn {#1} > { 100 } }
31748 { \msg_error:nnnnn { color } { out-of-range } {#1} { 0 } { 100 } }
31749 }
31750 \fp_compare:nNnF {#1} > \c_zero_fp
31751 {
31752 \tl_if_blank:nTF {#2}
31753 { \__color_extract:nNN { white } }
31754 { \__color_extract:nNN {#2} }
31755 \l__color_model_tl \l__color_value_tl
31756 }
31757 }
31758 \cs_new_protected:Npn \__color_parse_loop:nn #1#2
31759 {
31760 \color_if_exist:nTF {#2}
31761 {
31762 \__color_extract:nNN {#2} \l__color_next_model_tl \l__color_next_value_tl
31763 \tl_if_eq:NNF \l__color_model_tl \l__color_next_model_tl
31764 {
31765 \str_if_eq:VnTF \l__color_model_tl { gray }
31766 { \__color_parse_gray:n {#2} }
31767 { \__color_parse_std:n {#2} }
31768 }
31769 \tl_set:Ne \l__color_value_tl
31770 {
31771 \__color_parse_mix:NVVn
31772 \l__color_model_tl \l__color_value_tl \l__color_next_value_tl {#1}
31773 }
31774 }
31775 {
31776 \msg_error:nnn { color } { unknown-color } {#2}
31777 \__color_extract:nNN { black } \l__color_model_tl \l__color_value_tl
31778 \__color_parse_break:w
31779 }
31780 }
31781 \cs_new_protected:Npn \__color_parse_gray:n #1
31782 {
31783 \tl_set_eq:NN \l__color_model_tl \l__color_next_model_tl
31784 \tl_set:Nn \l__color_next_model_tl { gray }
31785 \exp_args:NnV \__color_convert:nnN { gray } \l__color_model_tl
31786 \l__color_value_tl
31787 \prop_get:cVN { l__color_named_ #1 _prop } \l__color_model_tl
31788 \l__color_next_value_tl
31789 }
31790 \cs_new_protected:Npn \__color_parse_std:n #1
31791 {
31792 \prop_get:cVNF { l__color_named_ #1 _prop }
31793 \l__color_model_tl
31794 \l__color_next_value_tl
31795 {
31796 \__color_convert:VVN
31797 \l__color_next_model_tl
31798 \l__color_model_tl
31799 \l__color_next_value_tl
31800 }
31801 }
31802 \cs_new_protected:Npn \__color_parse_break:w #1 \__color_parse_end: { }
31803 \cs_new_protected:Npn \__color_parse_end: { }
31804 \cs_new:Npn \__color_parse_mix:Nnnn #1#2#3#4
31805 {
31806 \exp_args:Nf \__color_parse_mix:nNnn
31807 { \fp_eval:n { #4 / 100 } }
31808 #1 {#2} {#3}
31809 }
31810 \cs_generate_variant:Nn \__color_parse_mix:Nnnn { NVV }
31811 \cs_new:Npn \__color_parse_mix:nNnn #1#2#3#4
31812 {
31813 \use:c { __color_parse_mix_ #2 :nw } {#1}
31814 #3 \s__color_mark #4 \s__color_stop
31815 }
31816 \cs_new:Npn \__color_parse_mix_gray:nw #1#2 \s__color_mark #3 \s__color_stop
31817 { \fp_eval:n { #2 * #1 + #3 * ( 1 - #1 ) } }
31818 \cs_new:Npn \__color_parse_mix_rgb:nw
31819 #1#2 ~ #3 ~ #4 \s__color_mark #5 ~ #6 ~ #7 \s__color_stop
31820 {
31821 \fp_eval:n { #2 * #1 + #5 * ( 1 - #1 ) } \c_space_tl
31822 \fp_eval:n { #3 * #1 + #6 * ( 1 - #1 ) } \c_space_tl
31823 \fp_eval:n { #4 * #1 + #7 * ( 1 - #1 ) }
31824 }
31825 \cs_new:Npn \__color_parse_mix_cmyk:nw
31826 #1#2 ~ #3 ~ #4 ~ #5 \s__color_mark #6 ~ #7 ~ #8 ~ #9 \s__color_stop
31827 {
31828 \fp_eval:n { #2 * #1 + #6 * ( 1 - #1 ) } \c_space_tl
31829 \fp_eval:n { #3 * #1 + #7 * ( 1 - #1 ) } \c_space_tl
31830 \fp_eval:n { #4 * #1 + #8 * ( 1 - #1 ) } \c_space_tl
31831 \fp_eval:n { #5 * #1 + #9 * ( 1 - #1 ) }
31832 }
31833 \cs_new:Npn \__color_parse_model_gray:w #1 , #2 \s__color_stop
31834 { { gray } { \__color_parse_number:n {#1} } }
31835 \cs_new:Npn \__color_parse_model_rgb:w #1 , #2 , #3 , #4 \s__color_stop
31836 {
31837 { rgb }
31838 {
31839 \__color_parse_number:n {#1} ~
31840 \__color_parse_number:n {#2} ~
31841 \__color_parse_number:n {#3}
31842 }
31843 }
31844 \cs_new:Npn \__color_parse_model_cmyk:w #1 , #2 , #3 , #4 , #5 \s__color_stop
31845 {
31846 { cmyk }
31847 {
31848 \__color_parse_number:n {#1} ~
31849 \__color_parse_number:n {#2} ~
31850 \__color_parse_number:n {#3} ~
31851 \__color_parse_number:n {#4}
31852 }
31853 }
31854 \cs_new:Npn \__color_parse_number:n #1
31855 { \__color_parse_number:w #1 . 0 . \s__color_stop }
31856 \cs_new:Npn \__color_parse_number:w #1 . #2 . #3 \s__color_stop
31857 { \tl_if_blank:nTF {#1} { 0 } {#1} . #2 }
31858 \cs_new:Npn \__color_parse_model_Gray:w #1 , #2 \s__color_stop
31859 { { gray } { \fp_eval:n { #1 / 15 } } }
31860 \cs_new:Npn \__color_parse_model_hsb:w #1 , #2 , #3 , #4 \s__color_stop
31861 { \__color_parse_model_hsb:nnn {#1} {#2} {#3} }
31862 \cs_new:Npn \__color_parse_model_Hsb:w #1 , #2 , #3 , #4 \s__color_stop
31863 {
31864 \exp_args:Ne \__color_parse_model_hsb:nnn { \fp_eval:n { #1 / 360 } }
31865 {#2} {#3}
31866 }
31867 \cs_new:Npn \__color_parse_model_hsb:nnn #1#2#3
31868 {
31869 { rgb }
31870 {
31871 \exp_args:Ne \__color_parse_model_hsb_aux:nnn
31872 { \fp_eval:n { 6 * (#1) } } {#2} {#3}
31873 }
31874 }
31875 \cs_new:Npn \__color_parse_model_hsb_aux:nnn #1#2#3
31876 {
31877 \exp_args:Nee \__color_parse_model_hsb_aux:nnnn
31878 { \fp_eval:n { floor(#1) } } { \fp_eval:n { #1 - floor(#1) } }
31879 {#2} {#3}
31880 }
31881 \cs_new:Npn \__color_parse_model_hsb_aux:nnnn #1#2#3#4
31882 {
31883 \use:e
31884 {
31885 \exp_not:N \__color_parse_model_hsb_aux:nnnnn
31886 { \__color_parse_number:n {#4} }
31887 { \fp_eval:n { round(#4 * (1 - #3) ,5) } }
31888 { \fp_eval:n { round(#4 * ( 1 - #3 * #2 ) ,5) } }
31889 { \fp_eval:n { round(#4 * ( 1 - #3 * (1 - #2) ) ,5) } }
31890 {#1}
31891 }
31892 }
31893 \cs_new:Npn \__color_parse_model_hsb_aux:nnnnn #1#2#3#4#5
31894 { \use:c { __color_parse_model_hsb_ #5 :nnnn } {#1} {#2} {#3} {#4} }
31895 \cs_new:cpn { __color_parse_model_hsb_0:nnnn } #1#2#3#4 { #1 ~ #4 ~ #2 }
31896 \cs_new:cpn { __color_parse_model_hsb_1:nnnn } #1#2#3#4 { #3 ~ #1 ~ #2 }
31897 \cs_new:cpn { __color_parse_model_hsb_2:nnnn } #1#2#3#4 { #2 ~ #1 ~ #4 }
31898 \cs_new:cpn { __color_parse_model_hsb_3:nnnn } #1#2#3#4 { #2 ~ #3 ~ #1 }
31899 \cs_new:cpn { __color_parse_model_hsb_4:nnnn } #1#2#3#4 { #4 ~ #2 ~ #1 }
31900 \cs_new:cpn { __color_parse_model_hsb_5:nnnn } #1#2#3#4 { #1 ~ #2 ~ #3 }
31901 \cs_new:cpn { __color_parse_model_hsb_6:nnnn } #1#2#3#4 { #1 ~ #2 ~ #2 }
31902 \cs_new:Npn \__color_parse_model_HSB:w #1 , #2 , #3 , #4 \s__color_stop
31903 {
31904 \exp_args:Neee \__color_parse_model_hsb:nnn
31905 { \fp_eval:n { round((#1) / 240,5) } }
31906 { \fp_eval:n { round((#2) / 240,5) } }
31907 { \fp_eval:n { round((#3) / 240,5) } }
31908 }
31909 \cs_new:Npn \__color_parse_model_HTML:w #1 , #2 \s__color_stop
31910 { \__color_parse_model_HTML_aux:w #1 0 0 0 0 0 0 \s__color_stop }
31911 \cs_new:Npn \__color_parse_model_HTML_aux:w #1#2#3#4#5#6#7 \s__color_stop
31912 {
31913 { rgb }
31914 {
31915 \fp_eval:n { round(\int_from_hex:n {#1#2} / 255,5) } ~
31916 \fp_eval:n { round(\int_from_hex:n {#3#4} / 255,5) } ~
31917 \fp_eval:n { round(\int_from_hex:n {#5#6} / 255,5) }
31918 }
31919 }
31920 \cs_new:Npn \__color_parse_model_RGB:w #1 , #2 , #3 , #4 \s__color_stop
31921 {
31922 { rgb }
31923 {
31924 \fp_eval:n { round((#1) / 255,5) } ~
31925 \fp_eval:n { round((#2) / 255,5) } ~
31926 \fp_eval:n { round((#3) / 255,5) }
31927 }
31928 }
31929 \cs_new:Npn \__color_parse_model_wave:w #1 , #2 \s__color_stop
31930 {
31931 { rgb }
31932 {
31933 \fp_compare:nNnTF {#1} < { 420 }
31934 { \__color_parse_model_wave_auxi:nn {#1} { 0.3 + 0.7 * (#1 - 380) / 40 }
31935 }
31936 {
31937 \fp_compare:nNnTF {#1} > { 700 }
31938 { \__color_parse_model_wave_auxi:nn {#1} { 0.3 + 0.7 * (#1 - 780) / -80 } }
31939 { \__color_parse_model_wave_auxi:nn {#1} { 1 } }
31940 }
31941 }
31942 }
31943 \cs_new:Npn \__color_parse_model_wave_auxi:nn #1#2
31944 {
31945 \fp_compare:nNnTF {#1} < { 440 }
31946 {
31947 \__color_parse_model_wave_auxii:nn
31948 { 4 + \__color_parse_model_wave_rho:n { (#1 - 440) / -60 } }
31949 {#2}
31950 }
31951 {
31952 \fp_compare:nNnTF {#1} < { 490 }
31953 {
31954 \__color_parse_model_wave_auxii:nn
31955 { 4 - \__color_parse_model_wave_rho:n { (#1 - 440) / 50 } }
31956 {#2}
31957 }
31958 {
31959 \fp_compare:nNnTF {#1} < { 510 }
31960 {
31961 \__color_parse_model_wave_auxii:nn
31962 { 2 + \__color_parse_model_wave_rho:n { (#1 - 510) / -20 } }
31963 {#2}
31964 }
31965 {
31966 \fp_compare:nNnTF {#1} < { 580 }
31967 {
31968 \__color_parse_model_wave_auxii:nn
31969 { 2 - \__color_parse_model_wave_rho:n { (#1 - 510) / 70 } }
31970 {#2}
31971 }
31972 {
31973 \fp_compare:nNnTF {#1} < { 645 }
31974 {
31975 \__color_parse_model_wave_auxii:nn
31976 { \__color_parse_model_wave_rho:n { (#1 - 645) / -65 } }
31977 {#2}
31978 }
31979 { \__color_parse_model_wave_auxii:nn { 0 } {#2} }
31980 }
31981 }
31982 }
31983 }
31984 }
31985 \cs_new:Npn \__color_parse_model_wave_auxii:nn #1#2
31986 {
31987 \exp_args:Neee \__color_parse_model_hsb_aux:nnn
31988 { \fp_eval:n {#1} }
31989 { 1 }
31990 { \__color_parse_model_wave_rho:n {#2} }
31991 }
31992 \cs_new:Npn \__color_parse_model_wave_rho:n #1
31993 { \fp_eval:n { min(1, max(0,#1) ) } }
31994 \cs_new:Npn \__color_parse_model_cmy:w #1 , #2 , #3 , #4 \s__color_stop
31995 {
31996 { cmyk }
31997 { \__color_convert_rgb_cmyk:nnn {#1} {#2} {#3} }
31998 }
31999 \cs_new:Npn \__color_parse_model_tHsb:w #1 , #2 , #3 , #4 \s__color_stop
32000 {
32001 \exp_args:Ne \__color_parse_model_hsb:nnn
32002 { \__color_parse_model_tHsb:n {#1} } {#2} {#3}
32003 }
32004 \cs_new:Npn \__color_parse_model_tHsb:n #1
32005 {
32006 \__color_parse_model_tHsb:nw {#1}
32007 0 , 0 ;
32008 60 , 30 ;
32009 120 , 60 ;
32010 180 , 120 ;
32011 210 , 180 ;
32012 240 , 240 ;
32013 360 , 360 ;
32014 \q_recursion_tail , ;
32015 \q_recursion_stop
32016 }
32017 \cs_new:Npn \__color_parse_model_tHsb:nw #1 #2 , #3 ; #4 , #5 ;
32018 {
32019 \quark_if_recursion_tail_stop_do:nn {#4} { 0 }
32020 \fp_compare:nNnTF {#1} > {#4}
32021 { \__color_parse_model_tHsb:nw {#1} #4 , #5 ; }
32022 {
32023 \use_i_delimit_by_q_recursion_stop:nw
32024 { \fp_eval:n { ((#1 - #2) / (#4 - #2) * (#5 - #3) + #3) / 360 } }
32025 }
32026 }
32027 \cs_new:cpn { __color_parse_model_&spot:w } #1 , #2 \s__color_stop
32028 { { gray } { #1 } }
32029 \cs_new:Npn \__color_parse_model_linearrgb:nnn #1#2#3
32030 {
32031 { rgb }
32032 {
32033 \__color_parse_model_linearrgb_aux:n { #1 } ~
32034 \__color_parse_model_linearrgb_aux:n { #2 } ~
32035 \__color_parse_model_linearrgb_aux:n { #3 }
32036 }
32037 }
32038 \cs_new:Npn \__color_parse_model_linearrgb_aux:n #1
32039 {
32040 \fp_compare:nNnTF { #1 } < { 0.0031308 }
32041 { \fp_eval:n { 12.92 * max(0, #1) } }
32042 { \fp_eval:n { 1.055 * min(1, #1) ^ 0.4166666666666667 - 0.055 } }
32043 }
32044 \cs_new:Npn \__color_parse_model_oklab:nnn #1#2#3
32045 {
32046 \exp_args:Neee \__color_parse_model_cbrtlms:nnn
32047 { \fp_eval:n { #1 + 0.3963377774 * #2 + 0.2158037573 * #3 } }
32048 { \fp_eval:n { #1 - 0.1055613458 * #2 - 0.0638541728 * #3 } }
32049 { \fp_eval:n { #1 - 0.0894841775 * #2 - 1.2914855480 * #3 } }
32050 }
32051 \cs_new:Npn \__color_parse_model_cbrtlms:nnn #1#2#3
32052 {
32053 \exp_args:Neee \__color_parse_model_lms:nnn
32054 { \fp_eval:n { #1 ^ 3 } }
32055 { \fp_eval:n { #2 ^ 3 } }
32056 { \fp_eval:n { #3 ^ 3 } }
32057 }
32058 \cs_new:Npn \__color_parse_model_lms:nnn #1#2#3
32059 {
32060 \exp_args:Neee \__color_parse_model_linearrgb:nnn
32061 { \fp_eval:n { 4.0767416621 * #1 - 3.3077115913 * #2 + 0.2309699292 * #3 } }
32062 { \fp_eval:n { -1.2684380046 * #1 + 2.6097574011 * #2 - 0.3413193965 * #3 } }
32063 { \fp_eval:n { -0.0041960863 * #1 - 0.7034186147 * #2 + 1.7076147010 * #3 } }
32064 }
32065 \cs_new:Npn \__color_parse_model_oklab:w #1 , #2 , #3 , #4 \s__color_stop
32066 { \__color_parse_model_oklab:nnn { #1 } { #2 } { #3 } }
32067 \cs_new:Npn \__color_parse_model_oklch:w #1 , #2 , #3 , #4 \s__color_stop
32068 {
32069 \exp_args:Nnee \__color_parse_model_oklab:nnn
32070 {#1}
32071 { \fp_eval:n { #2 * cosd(#3) } }
32072 { \fp_eval:n { #2 * sind(#3) } }
32073 }
32074 \tl_new:N \l_color_fixed_model_tl
32075 \cs_new_protected:Npn \__color_check_model:N #1
32076 {
32077 \tl_if_empty:NF \l_color_fixed_model_tl
32078 {
32079 \exp_after:wN \__color_check_model:nn #1
32080 \tl_if_eq:NNF \l__color_model_tl \l_color_fixed_model_tl
32081 {
32082 \__color_convert:VVN \l__color_model_tl \l_color_fixed_model_tl
32083 \l__color_value_tl
32084 }
32085 \tl_set:Ne #1
32086 { { \l_color_fixed_model_tl } { \l__color_value_tl } }
32087 }
32088 }
32089 \cs_new_protected:Npn \__color_check_model:nn #1#2
32090 {
32091 \tl_set:Nn \l__color_model_tl {#1}
32092 \tl_set:Nn \l__color_value_tl {#2}
32093 }
32094 \cs_new_protected:Npe \__color_finalize_current:
32095 {
32096 \tl_set:Ne \exp_not:c { l__color_named_ . _tl }
32097 { \exp_not:N \__color_model:N \exp_not:N \l__color_current_tl }
32098 \prop_clear:N \exp_not:c { l__color_named_ . _prop }
32099 \prop_put:NVe \exp_not:c { l__color_named_ . _prop }
32100 \exp_not:c { l__color_named_ . _tl }
32101 { \exp_not:N \__color_values:N \exp_not:N \l__color_current_tl }
32102 }
32103 \cs_new_protected:Npn \color_select:n #1
32104 {
32105 \__color_parse:nN {#1} \l__color_current_tl
32106 \__color_finalize_current:
32107 \__color_select:N \l__color_current_tl
32108 }
32109 \cs_generate_variant:Nn \color_select:n { V }
32110 \cs_new_protected:Npn \color_select:nn #1#2
32111 {
32112 \__color_select_main:Nnn \l__color_current_tl {#1} {#2}
32113 \__color_finalize_current:
32114 \__color_select:N \l__color_current_tl
32115 }
32116 \cs_generate_variant:Nn \color_select:nn { nV , V , VV }
32117 \cs_new_protected:Npn \__color_select_main:Nnn #1#2#3
32118 {
32119 \use:e
32120 {
32121 \exp_not:N \__color_select_main:Nw \exp_not:N #1
32122 \exp_not:n {#2} / / \exp_not:N \s__color_mark
32123 #3 / / \exp_not:N \s__color_stop
32124 }
32125 }
32126 \cs_new_protected:Npn \__color_select_main:Nw
32127 #1 #2 / #3 / #4 \s__color_mark #5 / #6 / #7 \s__color_stop
32128 {
32129 \__color_select:nnN {#2} {#5} #1
32130 \bool_lazy_or:nnF
32131 { \tl_if_empty_p:N \l_color_fixed_model_tl }
32132 { \str_if_eq_p:nV {#2} \l_color_fixed_model_tl }
32133 { \__color_select_loop:Nw #1 #3 / #4 \s__color_mark #6 / #7 \s__color_stop }
32134 }
32135 \cs_new_protected:Npn \__color_select_loop:Nw
32136 #1 #2 / #3 \s__color_mark #4 / #5 \s__color_stop
32137 {
32138 \str_if_eq:nVTF {#2} \l_color_fixed_model_tl
32139 { \__color_select:nnN {#2} {#4} #1 }
32140 {
32141 \tl_if_blank:nTF {#2}
32142 { \exp_after:wN \__color_select_swap:Nnn \exp_after:wN #1 #1 }
32143 { \__color_select_loop:Nw #1 #3 \s__color_mark #5 \s__color_stop }
32144 }
32145 }
32146 \cs_new_protected:Npn \__color_select:nnN #1#2#3
32147 {
32148 \cs_if_exist:cTF { __color_parse_model_ #1 :w }
32149 {
32150 \tl_set:Ne #3
32151 { \use:c { __color_parse_model_ #1 :w } #2 , 0 , 0 , 0 , 0 \s__color_stop }
32152 }
32153 { \msg_error:nnn { color } { unknown-model } {#1} }
32154 }
32155 \cs_new_protected:Npn \__color_select_swap:Nnn #1#2#3
32156 {
32157 \__color_convert:nVnN {#2} \l_color_fixed_model_tl {#3} \l__color_value_tl
32158 \tl_set:Ne #1
32159 { { \l_color_fixed_model_tl } { \l__color_value_tl } }
32160 }
32161 \tl_new:N \l_color_math_active_tl
32162 \tl_set:Nn \l_color_math_active_tl { ' }
32163 \seq_new:N \g__color_math_seq
32164 \cs_new_protected:Npn \color_math:nn #1#2
32165 {
32166 \__color_math:nn {#2}
32167 { \__color_parse:nN {#1} \l__color_current_tl }
32168 }
32169 \cs_new_protected:Npn \color_math:nnn #1#2#3
32170 {
32171 \__color_math:nn {#3}
32172 { \__color_select_main:Nnn \l__color_current_tl {#1} {#2} }
32173 }
32174 \cs_new_protected:Npn \__color_math:nn #1#2
32175 {
32176 \seq_gpush:NV \g__color_math_seq \l__color_current_tl
32177 #2
32178 \__color_select_math:N \l__color_current_tl
32179 #1
32180 \__color_math_scan:w
32181 }
32182 \cs_new_protected:Npn \__color_math_scan:w
32183 {
32184 \peek_remove_filler:n
32185 {
32186 \group_align_safe_begin:
32187 \peek_catcode:NTF \c_alignment_token
32188 {
32189 \group_align_safe_end:
32190 \__color_math_scan_end:
32191 }
32192 {
32193 \group_align_safe_end:
32194 \__color_math_scan_auxi:
32195 }
32196 }
32197 }
32198 \cs_new_protected:Npn \__color_math_scan_auxi:
32199 {
32200 \token_case_catcode:NnTF \l_peek_token
32201 {
32202 \c_math_subscript_token { }
32203 \c_math_superscript_token { }
32204 }
32205 { \__color_math_scripts:Nw }
32206 {
32207 \token_case_meaning:NnTF \l_peek_token
32208 {
32209 \tex_limits:D { \tex_limits:D }
32210 \tex_nolimits:D { \tex_nolimits:D }
32211 \tex_displaylimits:D { \tex_displaylimits:D }
32212 }
32213 { \__color_math_scan:w \use_none:n }
32214 { \__color_math_scan_auxii: }
32215 }
32216 }
32217 \cs_new_protected:Npn \__color_math_scan_auxii:
32218 {
32219 \tl_map_inline:Nn \l_color_math_active_tl
32220 {
32221 \token_if_eq_meaning:NNT \l_peek_token ##1
32222 {
32223 \tl_map_break:n
32224 {
32225 \use_i:nn
32226 { \__color_math_scan_auxiii:N ##1 }
32227 }
32228 }
32229 \__color_math_scan_end:
32230 }
32231 }
32232 \cs_new_protected:Npn \__color_math_scan_auxiii:N #1
32233 {
32234 \exp_after:wN \exp_after:wN \exp_after:wN \__color_math_scan:w
32235 \char_generate:nn { `#1 } { 13 }
32236 }
32237 \cs_new_protected:Npn \__color_math_scan_end:
32238 {
32239 \__color_backend_reset:
32240 \seq_gpop:NN \g__color_math_seq \l__color_current_tl
32241 }
32242 \cs_new_protected:Npn \__color_math_scripts:Nw #1
32243 {
32244 #1
32245 \c_group_begin_token
32246 \c_group_begin_token
32247 \seq_get:NN \g__color_math_seq \l__color_current_tl
32248 \__color_select:N \l__color_current_tl
32249 \group_insert_after:N \c_group_end_token
32250 \group_insert_after:N \__color_math_scan:w
32251 \peek_remove_filler:n
32252 {
32253 \peek_catcode_remove:NF \c_group_begin_token
32254 { \__color_math_script_aux:N }
32255 }
32256 }
32257 \cs_new_protected:Npn \__color_math_script_aux:N #1 { #1 \c_group_end_token }
32258 \cs_new_protected:Npn \color_fill:n #1
32259 {
32260 \__color_parse:nN {#1} \l__color_current_tl
32261 \exp_after:wN \__color_draw:nnn \l__color_current_tl { fill }
32262 }
32263 \cs_new_protected:Npn \color_stroke:n #1
32264 {
32265 \__color_parse:nN {#1} \l__color_current_tl
32266 \exp_after:wN \__color_draw:nnn \l__color_current_tl { stroke }
32267 }
32268 \cs_new_protected:Npn \color_fill:nn #1#2
32269 {
32270 \__color_select_main:Nnn \l__color_current_tl {#1} {#2}
32271 \exp_after:wN \__color_draw:nnn \l__color_current_tl { fill }
32272 }
32273 \cs_new_protected:Npn \color_stroke:nn #1#2
32274 {
32275 \__color_select_main:Nnn \l__color_current_tl {#1} {#2}
32276 \exp_after:wN \__color_draw:nnn \l__color_current_tl { stroke }
32277 }
32278 \cs_new_protected:Npn \__color_draw:nnn #1#2#3
32279 {
32280 \use:c { __color_backend_ #3 _ #1 :n } {#2}
32281 \exp_args:Nc \group_insert_after:N { __color_backend_ #3 _ reset: }
32282 }
32283 \tl_new:N \l__color_named_tl
32284 \cs_new_protected:Npn \color_set:nn #1#2
32285 {
32286 \exp_args:NV \__color_set:nnn
32287 \l_color_fixed_model_tl {#1} {#2}
32288 }
32289 \cs_new_protected:Npn \__color_set:nnn #1#2#3
32290 {
32291 \tl_clear:N \l_color_fixed_model_tl
32292 \__color_set:nn {#2} {#3}
32293 \tl_set:Nn \l_color_fixed_model_tl {#1}
32294 }
32295 \cs_new_protected:Npn \__color_set:nn #1#2
32296 {
32297 \str_if_eq:nnF {#1} { . }
32298 {
32299 \__color_parse:nN {#2} \l__color_named_tl
32300 \tl_clear_new:c { l__color_named_ #1 _tl }
32301 \tl_set:ce { l__color_named_ #1 _tl }
32302 { \__color_model:N \l__color_named_tl }
32303 \prop_clear_new:c { l__color_named_ #1 _prop }
32304 \prop_put:cve { l__color_named_ #1 _prop } { l__color_named_ #1 _tl }
32305 { \__color_values:N \l__color_named_tl }
32306 \__color_set:nnw {#1} {#2} #2 ! \s__color_stop
32307 }
32308 }
32309 \cs_new_protected:Npn \__color_set:nnw #1#2#3 ! #4 \s__color_stop
32310 {
32311 \clist_map_inline:nn { cmyk , gray , rgb }
32312 {
32313 \prop_get:cnNT { l__color_named_ #3 _prop } {##1} \l__color_tmp_tl
32314 {
32315 \prop_if_in:cnF { l__color_named_ #1 _prop } {##1}
32316 {
32317 \group_begin:
32318 \bool_set_true:N \l__color_ignore_error_bool
32319 \tl_set:cn { l__color_named_ #3 _tl } {##1}
32320 \__color_parse:nN {#2} \l__color_tmp_tl
32321 \exp_args:NNNV \group_end:
32322 \tl_set:Nn \l__color_tmp_tl \l__color_tmp_tl
32323 \prop_put:cee { l__color_named_ #1 _prop }
32324 { \__color_model:N \l__color_tmp_tl }
32325 { \__color_values:N \l__color_tmp_tl }
32326 }
32327 }
32328 }
32329 }
32330 \cs_new_protected:Npn \color_set:nnn #1#2#3
32331 {
32332 \str_if_eq:nnF {#1} { . }
32333 {
32334 \tl_clear_new:c { l__color_named_ #1 _tl }
32335 \prop_clear_new:c { l__color_named_ #1 _prop }
32336 \exp_args:Ne \__color_set_aux:nnn { \tl_to_str:n {#2} }
32337 {#1} {#3}
32338 }
32339 }
32340 \cs_new_protected:Npe \__color_set_aux:nnn #1#2#3
32341 {
32342 \exp_not:N \__color_set_colon:nnw {#2} {#3}
32343 #1 \c_colon_str \c_colon_str \exp_not:N \s__color_stop
32344 }
32345 \use:e
32346 {
32347 \cs_new_protected:Npn \exp_not:N \__color_set_colon:nnw
32348 #1#2 #3 \c_colon_str #4 \c_colon_str
32349 #5 \exp_not:N \s__color_stop
32350 }
32351 {
32352 \tl_if_blank:nTF {#4}
32353 { \__color_set_loop:nw {#1} #3 }
32354 { \__color_set_loop:nw {#1} #4 }
32355 / / \s__color_mark #2 / / \s__color_stop
32356 }
32357 \cs_new_protected:Npn \__color_set_loop:nw
32358 #1#2 / #3 \s__color_mark #4 / #5 \s__color_stop
32359 {
32360 \tl_if_blank:nF {#2}
32361 {
32362 \__color_select:nnN {#2} {#4} \l__color_named_tl
32363 \tl_set:Ne \l__color_tmp_tl { \__color_model:N \l__color_named_tl }
32364 \tl_if_empty:cT { l__color_named_ #1 _tl }
32365 { \tl_set_eq:cN { l__color_named_ #1 _tl } \l__color_tmp_tl }
32366 \prop_put:cVe { l__color_named_ #1 _prop } \l__color_tmp_tl
32367 { \__color_values:N \l__color_named_tl }
32368 \__color_set_loop:nw {#1} #3 \s__color_mark #5 \s__color_stop
32369 }
32370 }
32371 \cs_new_protected:Npn \color_set_eq:nn #1#2
32372 {
32373 \color_if_exist:nTF {#2}
32374 {
32375 \tl_clear_new:c { l__color_named_ #1 _tl }
32376 \prop_clear_new:c { l__color_named_ #1 _prop }
32377 \str_if_eq:nnTF {#2} { . }
32378 {
32379 \tl_set:ce { l__color_named_ #1 _tl }
32380 { \__color_model:N \l__color_current_tl }
32381 \prop_put:cve { l__color_named_ #1 _prop } { l__color_named_ #1 _tl }
32382 { \__color_values:N \l__color_current_tl }
32383 }
32384 {
32385 \tl_set_eq:cc { l__color_named_ #1 _tl } { l__color_named_ #2 _tl }
32386 \prop_set_eq:cc { l__color_named_ #1 _prop } { l__color_named_ #2 _prop }
32387 }
32388 }
32389 {
32390 \msg_error:nnn { color } { unknown-color } {#2}
32391 }
32392 }
32393 \color_set:nnn { black } { gray } { 0 }
32394 \color_set:nnn { white } { gray } { 1 }
32395 \color_set:nnn { cyan } { cmyk } { 1 , 0 , 0 , 0 }
32396 \color_set:nnn { magenta } { cmyk } { 0 , 1 , 0 , 0 }
32397 \color_set:nnn { yellow } { cmyk } { 0 , 0 , 1 , 0 }
32398 \color_set:nnn { red } { rgb } { 1 , 0 , 0 }
32399 \color_set:nnn { green } { rgb } { 0 , 1 , 0 }
32400 \color_set:nnn { blue } { rgb } { 0 , 0 , 1 }
32401 \prop_new:c { l__color_named_._prop }
32402 \tl_new:c { l__color_named_._tl }
32403 \tl_set:ce { l__color_named_._tl } { \__color_model:N \l__color_current_tl }
32404 \prop_put:cve { l__color_named_._prop } { l__color_named_._tl }
32405 { \__color_values:N \l__color_current_tl }
32406 \cs_new_protected:Npn \color_export:nnN #1#2#3
32407 {
32408 \group_begin:
32409 \tl_if_exist:cT { c__color_export_ #2 _tl }
32410 { \tl_set_eq:Nc \l_color_fixed_model_tl { c__color_export_ #2 _tl } }
32411 \__color_parse:nN {#1} #3
32412 \__color_export:nN {#2} #3
32413 \exp_args:NNNV \group_end:
32414 \tl_set:Nn #3 #3
32415 }
32416 \cs_new_protected:Npn \color_export:nnnN #1#2#3#4
32417 {
32418 \__color_select_main:Nnn #4 {#1} {#2}
32419 \__color_export:nN {#3} #4
32420 }
32421 \cs_new_protected:Npn \__color_export:nN #1#2
32422 { \exp_after:wN \__color_export:nnnN #2 {#1} #2 }
32423 \cs_new:Npn \__color_export:nnnN #1#2#3#4
32424 {
32425 \cs_if_exist_use:cF { __color_export_format_ #3 :nnN }
32426 {
32427 \msg_error:nnn { color } { unknown-export-format } {#3}
32428 \use_none:nnn
32429 }
32430 {#1} {#2} #4
32431 }
32432 \cs_new_protected:Npn \__color_export_format_backend:nnN #1#2#3
32433 { \tl_set:Nn #3 { {#1} {#2} } }
32434 \cs_new_protected:Npn \__color_export:nnnNN #1#2#3#4#5
32435 {
32436 \str_if_eq:nnTF {#2} {#1}
32437 { #5 #4 #3 \s__color_stop }
32438 {
32439 \__color_convert:nnnN {#2} {#1} {#3} #4
32440 \exp_after:wN #5 \exp_after:wN #4
32441 #4 \s__color_stop
32442 }
32443 }
32444 \tl_const:cn { c__color_export_comma-sep-cmyk_tl } { cmyk }
32445 \tl_const:cn { c__color_export_comma-sep-rgb_tl } { rgb }
32446 \tl_const:Nn \c__color_export_HTML_tl { rgb }
32447 \tl_const:cn { c__color_export_space-sep-cmyk_tl } { cmyk }
32448 \tl_const:cn { c__color_export_space-sep-rgb_tl } { rgb }
32449 \group_begin:
32450 \cs_set_protected:Npn \__color_tmp:w #1#2
32451 {
32452 \cs_new_protected:cpe { __color_export_format_ #1 :nnN } ##1##2##3
32453 {
32454 \exp_not:N \__color_export:nnnNN {#2} {##1} {##2} ##3
32455 \exp_not:c { __color_export_ #1 :Nw }
32456 }
32457 }
32458 \__color_tmp:w { comma-sep-cmyk } { cmyk }
32459 \__color_tmp:w { comma-sep-rgb } { rgb }
32460 \__color_tmp:w { HTML } { rgb }
32461 \__color_tmp:w { space-sep-cmyk } { cmyk }
32462 \__color_tmp:w { space-sep-rgb } { rgb }
32463 \group_end:
32464 \cs_new_protected:cpn { __color_export_comma-sep-cmyk:Nw }
32465 #1#2 ~ #3 ~ #4 ~ #5 \s__color_stop
32466 { \tl_set:Nn #1 { #2 , #3 , #4 , #5 } }
32467 \cs_new_protected:cpn { __color_export_space-sep-cmyk:Nw } #1#2 \s__color_stop
32468 { \tl_set:Nn #1 {#2} }
32469 \cs_new_protected:cpn { __color_export_comma-sep-rgb:Nw } #1#2 ~ #3 ~ #4 \s__color_stop
32470 { \tl_set:Ne #1 { #2 , #3 , #4 } }
32471 \cs_new_protected:Npn \__color_export_HTML:Nw #1#2 ~ #3 ~ #4 \s__color_stop
32472 {
32473 \tl_set:Ne #1
32474 {
32475 \__color_export_HTML:n {#2}
32476 \__color_export_HTML:n {#3}
32477 \__color_export_HTML:n {#4}
32478 }
32479 }
32480 \cs_new:Npn \__color_export_HTML:n #1
32481 {
32482 \fp_compare:nNnTF {#1} = { 0 }
32483 { 00 }
32484 {
32485 \fp_compare:nNnT { #1 * 255 } < { 16 } { 0 }
32486 \int_to_Hex:n { \fp_to_int:n { #1 * 255 } }
32487 }
32488 }
32489 \cs_new_protected:cpn { __color_export_space-sep-rgb:Nw } #1#2 \s__color_stop
32490 { \tl_set:Nn #1 {#2} }
32491 \prop_new:N \l__color_tmp_prop
32492 \int_new:N \g__color_model_int
32493 \tl_const:Nn \c__color_fallback_cmyk_tl { cmyk }
32494 \tl_const:Nn \c__color_fallback_gray_tl { gray }
32495 \tl_const:Nn \c__color_fallback_rgb_tl { rgb }
32496 \prop_new:N \g__color_colorants_prop
32497 \prop_gput:Nnn \g__color_colorants_prop { black } { Black }
32498 \prop_gput:Nnn \g__color_colorants_prop { blue } { Blue }
32499 \prop_gput:Nnn \g__color_colorants_prop { cyan } { Cyan }
32500 \prop_gput:Nnn \g__color_colorants_prop { green } { Green }
32501 \prop_gput:Nnn \g__color_colorants_prop { magenta } { Magenta }
32502 \prop_gput:Nnn \g__color_colorants_prop { none } { None }
32503 \prop_gput:Nnn \g__color_colorants_prop { red } { Red }
32504 \prop_gput:Nnn \g__color_colorants_prop { yellow } { Yellow }
32505 \tl_const:Nn \c__color_model_whitepoint_CIELAB_a_tl { 1.0985 ~ 1 ~ 0.3558 }
32506 \tl_const:Nn \c__color_model_whitepoint_CIELAB_b_tl { 0.9807 ~ 1 ~ 1.1822 }
32507 \tl_const:Nn \c__color_model_whitepoint_CIELAB_e_tl { 1 ~ 1 ~ 1 }
32508 \tl_const:cn { c__color_model_whitepoint_CIELAB_d50_tl } { 0.9642 ~ 1 ~ 0.8251 }
32509 \tl_const:cn { c__color_model_whitepoint_CIELAB_d55_tl } { 0.9568 ~ 1 ~ 0.9214 }
32510 \tl_const:cn { c__color_model_whitepoint_CIELAB_d65_tl } { 0.9504 ~ 1 ~ 1.0888 }
32511 \tl_const:cn { c__color_model_whitepoint_CIELAB_d75_tl } { 0.9497 ~ 1 ~ 1.2261 }
32512 \tl_const:Nn \c__color_model_range_CIELAB_tl { 0 ~ 100 ~ -128 ~ 127 ~ -128 ~ 127 }
32513 \prop_new:N \g__color_alternative_model_prop
32514 \clist_map_inline:nn { cyan , magenta , yellow , black }
32515 { \prop_gput:Nnn \g__color_alternative_model_prop {#1} { cmyk } }
32516 \clist_map_inline:nn { red , green , blue }
32517 { \prop_gput:Nnn \g__color_alternative_model_prop {#1} { rgb } }
32518 \prop_new:N \g__color_alternative_values_prop
32519 \prop_gput:Nnn \g__color_alternative_values_prop { cyan } { 1 , 0 , 0 , 0 }
32520 \prop_gput:Nnn \g__color_alternative_values_prop { magenta } { 0 , 1 , 0 , 0 }
32521 \prop_gput:Nnn \g__color_alternative_values_prop { yellow } { 0 , 0 , 1 , 0 }
32522 \prop_gput:Nnn \g__color_alternative_values_prop { black } { 0 , 0 , 0 , 1 }
32523 \prop_gput:Nnn \g__color_alternative_values_prop { red } { 1 , 0 , 0 }
32524 \prop_gput:Nnn \g__color_alternative_values_prop { green } { 0 , 1 , 0 }
32525 \prop_gput:Nnn \g__color_alternative_values_prop { blue } { 0 , 0 , 1 }
32526 \cs_new_protected:Npn \color_model_new:nnn #1#2#3
32527 {
32528 \exp_args:Nee \__color_model_new:nnn
32529 { \tl_to_str:n {#1} }
32530 { \str_casefold:n {#2} } {#3}
32531 }
32532 \cs_new_protected:Npn \__color_model_new:nnn #1#2#3
32533 {
32534 \cs_if_exist:cTF { __color_parse_model_ #1 :w }
32535 {
32536 \msg_error:nnn { color } { model-already-defined } {#1}
32537 }
32538 {
32539 \cs_if_exist:cTF { __color_model_ #2 :n }
32540 {
32541 \prop_set_from_keyval:Nn \l__color_tmp_prop {#3}
32542 \use:c { __color_model_ #2 :n } {#1}
32543 }
32544 {
32545 \msg_error:nnn { color } { unknown-model-type } {#2}
32546 }
32547 }
32548 }
32549 \cs_new_protected:Npn \__color_model_init:nnn #1#2#3
32550 {
32551 \int_gincr:N \g__color_model_int
32552 \clist_map_inline:nn { fill , stroke , select }
32553 {
32554 \cs_new_protected:cpe { __color_backend_ ##1 _ #1 :n } ####1
32555 {
32556 \exp_not:c { __color_backend_ ##1 _ #2 :nn }
32557 { color \int_use:N \g__color_model_int } {####1}
32558 }
32559 }
32560 \cs_new_protected:cpe { __color_model_ #1 _white: }
32561 {
32562 \prop_put:Nnn \exp_not:N \l__color_named_white_prop {#1}
32563 { \exp_not:n {#3} }
32564 \exp_not:N \int_compare:nNnF { \tex_currentgrouplevel:D } = 0
32565 { \group_insert_after:N \exp_not:c { __color_model_ #1 _ white: } }
32566 }
32567 \use:c { __color_model_ #1 _white: }
32568 }
32569 \cs_generate_variant:Nn \__color_model_init:nnn { nne }
32570 \cs_new_protected:Npn \__color_model_separation:n #1
32571 {
32572 \prop_get:NnNTF \l__color_tmp_prop { name }
32573 \l__color_tmp_tl
32574 {
32575 \exp_args:NV \__color_model_separation:nn
32576 \l__color_tmp_tl {#1}
32577 }
32578 {
32579 \msg_error:nnn { color }
32580 { separation-requires-name } {#1}
32581 }
32582 }
32583 \cs_new_protected:Npn \__color_model_separation:nn #1#2
32584 {
32585 \prop_get:NnNTF \l__color_tmp_prop { alternative-model }
32586 \l__color_tmp_tl
32587 {
32588 \exp_args:NV \__color_model_separation:nnn
32589 \l__color_tmp_tl {#2} {#1}
32590 }
32591 {
32592 \msg_error:nnn { color }
32593 { separation-alternative-model } {#2}
32594 }
32595 }
32596 \cs_new_protected:Npn \__color_model_separation:nnn #1#2#3
32597 {
32598 \cs_if_exist:cTF { __color_model_separation_ #1 :nnnnnn }
32599 {
32600 \prop_get:NnNTF \l__color_tmp_prop { alternative-values }
32601 \l__color_tmp_tl
32602 {
32603 \exp_after:wN \__color_model_separation:w \l__color_tmp_tl
32604 , 0 , 0 , 0 , 0 \s__color_stop {#2} {#3} {#1}
32605 }
32606 {
32607 \msg_error:nnn { color }
32608 { separation-alternative-values } {#2}
32609 }
32610 }
32611 {
32612 \msg_error:nnn { color }
32613 { unknown-alternative-model } {#1}
32614 }
32615 }
32616 \cs_new_protected:Npn \__color_model_separation:w
32617 #1 , #2 , #3 , #4 , #5 \s__color_stop #6#7#8
32618 {
32619 \__color_model_init:nnn {#6} { separation } { 0 }
32620 \cs_new_eq:cN { __color_parse_mix_ #6 :nw } \__color_parse_mix_gray:nw
32621 \cs_new:cpn { __color_parse_model_ #6 :w } ##1 , ##2 \s__color_stop
32622 { {#6} { \__color_parse_number:n {##1} } }
32623 \use:c { __color_model_separation_ #8 :nnnnnn }
32624 {#6} {#7} {#1} {#2} {#3} {#4}
32625 \prop_gput:Nnn \g__color_alternative_model_prop {#6} {#8}
32626 \prop_gput:Nne \g__color_colorants_prop {#6}
32627 { \str_convert_pdfname:n {#7} }
32628 }
32629 \cs_new_protected:Npn \__color_model_separation_cmyk:nnnnnn #1#2#3#4#5#6
32630 {
32631 \tl_const:cn { c__color_fallback_ #1 _tl } { cmyk }
32632 \cs_new:cpn { __color_convert_ #1 _cmyk:w } ##1 \s__color_stop
32633 {
32634 \fp_eval:n {##1 * #3} ~
32635 \fp_eval:n {##1 * #4} ~
32636 \fp_eval:n {##1 * #5} ~
32637 \fp_eval:n {##1 * #6}
32638 }
32639 \cs_new:cpn { __color_convert_cmyk_ #1 :w } ##1 \s__color_stop { 1 }
32640 \prop_gput:Nnn \g__color_alternative_values_prop {#1} { #3 , #4 , #5 , #6 }
32641 \__color_backend_separation_init:nnnnn {#2} { /DeviceCMYK } { }
32642 { 0 ~ 0 ~ 0 ~ 0 } { #3 ~ #4 ~ #5 ~ #6 }
32643 }
32644 \cs_new_protected:Npn \__color_model_separation_rgb:nnnnnn #1#2#3#4#5#6
32645 {
32646 \tl_const:cn { c__color_fallback_ #1 _tl } { rgb }
32647 \cs_new:cpn { __color_convert_ #1 _rgb:w } ##1 \s__color_stop
32648 {
32649 \fp_eval:n {##1 * #3} ~
32650 \fp_eval:n {##1 * #4} ~
32651 \fp_eval:n {##1 * #5}
32652 }
32653 \cs_new:cpn { __color_convert_rgb_ #1 :w } ##1 \s__color_stop { 1 }
32654 \prop_gput:Nnn \g__color_alternative_values_prop {#1} { #3 , #4 , #5 }
32655 \__color_backend_separation_init:nnnnn {#2} { /DeviceRGB } { }
32656 { 0 ~ 0 ~ 0 } { #3 ~ #4 ~ #5 }
32657 }
32658 \cs_new_protected:Npn \__color_model_separation_gray:nnnnnn #1#2#3#4#5#6
32659 {
32660 \tl_const:cn { c__color_fallback_ #1 _tl } { gray }
32661 \cs_new:cpn { __color_convert_ #1 _gray:w } ##1 \s__color_stop
32662 { \fp_eval:n {##1 * #3} }
32663 \cs_new:cpn { __color_convert_gray_ #1 :w } ##1 \s__color_stop { 1 }
32664 \prop_gput:Nnn \g__color_alternative_values_prop {#1} {#3}
32665 \__color_backend_separation_init:nnnnn {#2} { /DeviceGray } { } { 0 } {#3}
32666 }
32667 \cs_new_protected:Npn \__color_model_convert:nnn #1#2#3
32668 {
32669 \cs_new:cpe { __color_convert_ #1 _ #3 :w } ##1 \s__color_stop
32670 {
32671 \exp_not:N \exp_args:NNe \exp_not:N \use:nn
32672 \exp_not:c { __color_convert_ #2 _ #3 :w }
32673 { \exp_not:c { __color_convert_ #1 _ #2 :w } ##1 \s__color_stop }
32674 \c_space_tl \exp_not:N \s__color_stop
32675 }
32676 }
32677 \cs_new_protected:Npn \__color_model_separation_CIELAB:nnnnnn #1#2#3#4#5#6
32678 {
32679 \prop_get:NnNF \l__color_tmp_prop { illuminant }
32680 \l__color_tmp_tl
32681 {
32682 \msg_error:nnn { color }
32683 { CIELAB-requires-illuminant } {#1}
32684 \tl_set:Nn \l__color_tmp_tl { d50 }
32685 }
32686 \exp_args:NV \__color_model_separation_CIELAB:nnnnnnn
32687 \l__color_tmp_tl {#1} {#2} {#3} {#4} {#5} {#6}
32688 }
32689 \cs_new_protected:Npn \__color_model_separation_CIELAB:nnnnnnn #1#2#3#4#5#6#7
32690 {
32691 \tl_if_exist:cTF { c__color_model_whitepoint_CIELAB_ #1 _tl }
32692 {
32693 \__color_backend_separation_init_CIELAB:nnn {#1} {#3} { #4 ~ #5 ~ #6 }
32694 \tl_const:cn { c__color_fallback_ #2 _tl } { gray }
32695 \cs_new:cpn { __color_convert_ #2 _gray:w } ##1 \s__color_stop
32696 { 0 }
32697 \cs_new:cpn { __color_convert_gray_ #2 :w } ##1 \s__color_stop
32698 { 1 }
32699 }
32700 {
32701 \msg_error:nnn { color }
32702 { unknown-CIELAB-illuminant } {#1}
32703 }
32704 }
32705 \cs_new_protected:Npn \__color_model_devicen:n #1
32706 {
32707 \prop_get:NnNTF \l__color_tmp_prop { names }
32708 \l__color_tmp_tl
32709 {
32710 \exp_args:NV \__color_model_devicen:nn
32711 \l__color_tmp_tl {#1}
32712 }
32713 {
32714 \msg_error:nnn { color }
32715 { DeviceN-requires-names } {#1}
32716 }
32717 }
32718 \cs_new_protected:Npn \__color_model_devicen:nn #1#2
32719 {
32720 \tl_clear:N \l__color_model_tl
32721 \clist_map_inline:nn {#1}
32722 {
32723 \prop_get:NnNTF \g__color_alternative_model_prop {##1}
32724 \l__color_tmp_tl
32725 {
32726 \tl_if_empty:NTF \l__color_model_tl
32727 { \tl_set_eq:NN \l__color_model_tl \l__color_tmp_tl }
32728 {
32729 \str_if_eq:VVF \l__color_model_tl \l__color_tmp_tl
32730 {
32731 \msg_error:nnn { color }
32732 { DeviceN-inconsistent-alternative }
32733 {#2}
32734 \clist_map_break:n { \use_none:nnnn }
32735 }
32736 }
32737 }
32738 {
32739 \str_if_eq:nnF {##1} { none }
32740 {
32741 \msg_error:nnn { color }
32742 { DeviceN-no-alternative }
32743 {#2}
32744 }
32745 }
32746 }
32747 \tl_if_empty:NTF \l__color_model_tl
32748 {
32749 \msg_error:nnn { color }
32750 { DeviceN-no-alternative } {#2}
32751 }
32752 { \exp_args:NV \__color_model_devicen:nnn \l__color_model_tl {#1} {#2} }
32753 }
32754 \cs_new_protected:Npn \__color_model_devicen:nnn #1#2#3
32755 {
32756 \exp_args:Ne \__color_model_devicen:nnnn
32757 { \clist_count:n {#2} } {#1} {#2} {#3}
32758 }
32759 \cs_new_protected:Npn \__color_model_devicen:nnnn #1#2#3#4
32760 {
32761 \__color_model_init:nne {#4} { devicen }
32762 {
32763 0 \prg_replicate:nn { #1 - 1 } { ~ 0 }
32764 }
32765 \cs_if_exist_use:cF { __color_model_devicen_parse_ #1 :nn }
32766 { \__color_model_devicen_parse_generic:nn }
32767 {#4} {#1}
32768 \__color_model_devicen_init:nnn {#1} {#2} {#3}
32769 \__color_model_devicen_convert:nnne {#4} {#2} {#3}
32770 {
32771 1 \prg_replicate:nn { #1 - 1 } { ~ 1 }
32772 }
32773 }
32774 \cs_new_protected:cpn { __color_model_devicen_parse_1:nn } #1#2
32775 {
32776 \cs_new:cpn { __color_parse_model_ #1 :w } ##1 , ##2 \s__color_stop
32777 { {#1} { \__color_parse_number:n {##1} } }
32778 \cs_new_eq:cN { __color_parse_mix_ #1 :nw } \__color_parse_mix_gray:nw
32779 }
32780 \cs_new_protected:cpn { __color_model_devicen_parse_2:nn } #1#2
32781 {
32782 \cs_new:cpn { __color_parse_model_ #1 :w } ##1 , ##2 , ##3 \s__color_stop
32783 { {#1} { \__color_parse_number:n {##1} ~ \__color_parse_number:n {##2} } }
32784 \cs_new:cpn { __color_parse_mix_ #1 :nw }
32785 ##1##2 ~ ##3 \s__color_mark ##4 ~ ##5 \s__color_stop
32786 {
32787 \fp_eval:n { ##2 * ##1 + ##4 * ( 1 - ##1 ) } \c_space_tl
32788 \fp_eval:n { ##3 * ##1 + ##5 * ( 1 - ##1 ) }
32789 }
32790 }
32791 \cs_new_protected:cpn { __color_model_devicen_parse_3:nn } #1#2
32792 {
32793 \cs_new:cpn { __color_parse_model_ #1 :w } ##1 , ##2 , ##3 , ##4 \s__color_stop
32794 {
32795 {#1}
32796 {
32797 \__color_parse_number:n {##1} ~
32798 \__color_parse_number:n {##2} ~
32799 \__color_parse_number:n {##3}
32800 }
32801 }
32802 \cs_new_eq:cN { __color_parse_mix_ #1 :nw } \__color_parse_mix_rgb:nw
32803 }
32804 \cs_new_protected:cpn { __color_model_devicen_parse_4:nn } #1#2
32805 {
32806 \cs_new:cpn { __color_parse_model_ #1 :w }
32807 ##1 , ##2 , ##3 , ##4 , ##5 \s__color_stop
32808 {
32809 {#1}
32810 {
32811 \__color_parse_number:n {##1} ~
32812 \__color_parse_number:n {##2} ~
32813 \__color_parse_number:n {##3} ~
32814 \__color_parse_number:n {##4}
32815 }
32816 }
32817 \cs_new_eq:cN { __color_parse_mix_ #1 :nw } \__color_parse_mix_cmyk:nw
32818 }
32819 \cs_new_protected:Npn \__color_model_devicen_parse_generic:nn #1#2
32820 {
32821 \cs_new:cpn { __color_parse_model_ #1 :w } ##1 , ##2 \s__color_stop
32822 {
32823 {#1}
32824 { \__color_model_devicen_parse:nw {#2} ##1 , ##2 , \q_nil , \s__color_stop }
32825 }
32826 \cs_new:cpe { __color_parse_mix_ #1 :nw }
32827 ##1 ##2 \s__color_mark ##3 \s__color_stop
32828 {
32829 \exp_not:N \__color_model_devicen_mix:nw {##1}
32830 ##2 \c_space_tl \exp_not:N \q_nil \c_space_tl \exp_not:N \s__color_mark
32831 ##3 \c_space_tl \exp_not:N \q_nil \c_space_tl \exp_not:N \s__color_stop
32832 }
32833 }
32834 \cs_new:Npn \__color_model_devicen_parse:nw #1#2 , #3 \s__color_stop
32835 {
32836 \int_compare:nNnT {#1} > 0
32837 {
32838 \quark_if_nil:nTF {#2}
32839 { \prg_replicate:nn {#1} { 0 ~ } }
32840 {
32841 \__color_parse_number:n {#2}
32842 \int_compare:nNnT {#1} > 1 { ~ }
32843 \exp_args:Nf \__color_model_devicen_parse:nw
32844 { \int_eval:n { #1 - 1 } } #3 \s__color_stop
32845 }
32846 }
32847 }
32848 \cs_new:Npn \__color_model_devicen_mix:nw #1#2 ~ #3 \s__color_mark #4 ~ #5 \s__color_stop
32849 {
32850 \fp_eval:n { #2 * #1 + #4 * ( 1 - #1 ) }
32851 \quark_if_nil:oF { \tl_head:w #3 \q_stop }
32852 {
32853 \c_space_tl
32854 \__color_model_devicen_mix:nw {#1} #3 \s__color_mark #5 \s__color_stop
32855 }
32856 }
32857 \cs_new_protected:Npn \__color_model_devicen_init:nnn #1#2#3
32858 {
32859 \exp_args:Ne \__color_model_devicen_init:nnnn
32860 {
32861 \str_case:nn {#2}
32862 {
32863 { cmyk } { 4 }
32864 { gray } { 1 }
32865 { rgb } { 3 }
32866 }
32867 }
32868 {#1} {#2} {#3}
32869 }
32870 \cs_new_protected:Npn \__color_model_devicen_init:nnnn #1#2#3#4
32871 {
32872 \tl_set:Ne \l__color_tmp_tl
32873 { \prg_replicate:nn {#1} { 1.0 ~ } }
32874 \int_zero:N \l__color_tmp_int
32875 \clist_map_inline:nn {#4}
32876 {
32877 \int_incr:N \l__color_tmp_int
32878 \prop_get:NnN \g__color_alternative_values_prop {##1}
32879 \l__color_value_tl
32880 \exp_after:wN \__color_model_devicen_transform:w
32881 \l__color_value_tl , 0 , 0 , 0 , \s__color_stop {#1} {#2}
32882 }
32883 \tl_put_right:Ne \l__color_tmp_tl
32884 {
32885 \prg_replicate:nn {#1}
32886 { neg ~ 1.0 ~ add ~ #1 ~ -1 ~ roll ~ }
32887 \int_eval:n { #2 + #1 } ~ #1 ~ roll
32888 \prg_replicate:nn {#2} { ~ pop } ~
32889 #1 ~ 1 ~ roll
32890 }
32891 \use:e
32892 {
32893 \__color_backend_devicen_init:nnn
32894 {
32895 \clist_map_function:nN {#4}
32896 \__color_model_devicen_colorant:n
32897 }
32898 {
32899 \str_case:nn {#3}
32900 {
32901 { cmyk } { /DeviceCMYK }
32902 { gray } { /DeviceGray }
32903 { rgb } { /DeviceRGB }
32904 }
32905 }
32906 { \exp_not:V \l__color_tmp_tl }
32907 }
32908 }
32909 \cs_new_protected:Npn \__color_model_devicen_transform:w
32910 #1 , #2 , #3 , #4 , #5 \s__color_stop #6#7
32911 {
32912 \use:c { __color_model_devicen_transform_ #6 :nnnnn }
32913 {#1} {#2} {#3} {#4} {#7}
32914 }
32915 \cs_new_protected:cpn { __color_model_devicen_transform_1:nnnnn } #1#2#3#4#5
32916 { \__color_model_devicen_transform:nnn {#5} { 1 } {#1} }
32917 \cs_new_protected:cpn { __color_model_devicen_transform_3:nnnnn } #1#2#3#4#5
32918 {
32919 \clist_map_inline:nn { #1 , #2 , #3 }
32920 { \__color_model_devicen_transform:nnn {#5} { 3 } {##1} }
32921 }
32922 \cs_new_protected:cpn { __color_model_devicen_transform_4:nnnnn } #1#2#3#4#5
32923 {
32924 \clist_map_inline:nn { #1 , #2 , #3 , #4 }
32925 { \__color_model_devicen_transform:nnn {#5} { 4 } {##1} }
32926 }
32927 \cs_new_protected:Npn \__color_model_devicen_transform:nnn #1#2#3
32928 {
32929 \tl_put_right:Ne \l__color_tmp_tl
32930 {
32931 \fp_compare:nNnF {#3} = \c_zero_fp
32932 {
32933 \int_eval:n { #1 - \l__color_tmp_int + #2 } ~ index ~
32934 -#3 ~ mul ~ 1.0 ~ add ~ mul ~
32935 }
32936 #2 ~ -1 ~ roll ~
32937 }
32938 }
32939 \cs_new:Npn \__color_model_devicen_colorant:n #1
32940 {
32941 / \prop_item:Nn \g__color_colorants_prop {#1} ~
32942 }
32943 \cs_new_protected:Npn \__color_model_devicen_convert:nnnn #1#2#3
32944 {
32945 \use:c { __color_model_devicen_convert_ #2 :nnn } {#1} {#3}
32946 }
32947 \cs_generate_variant:Nn \__color_model_devicen_convert:nnnn { nnne }
32948 \cs_new_protected:Npn \__color_model_devicen_convert_cmyk:nnn #1#2
32949 {
32950 \tl_const:cn { c__color_fallback_ #1 _tl } { cmyk }
32951 \__color_model_devicen_convert:nnnnn {#1} { cmyk } { 4 } {#2}
32952 }
32953 \cs_new_protected:Npn \__color_model_devicen_convert_gray:nnn #1#2
32954 {
32955 \tl_const:cn { c__color_fallback_ #1 _tl } { gray }
32956 \__color_model_devicen_convert:nnnnn {#1} { gray } { 1 } {#2}
32957 }
32958 \cs_new_protected:Npn \__color_model_devicen_convert_rgb:nnn #1#2
32959 {
32960 \tl_const:cn { c__color_fallback_ #1 _tl } { rgb }
32961 \__color_model_devicen_convert:nnnnn {#1} { rgb } { 3 } {#2}
32962 }
32963 \cs_new_protected:Npn \__color_model_devicen_convert:nnnnn #1#2#3#4#5
32964 {
32965 \cs_new:cpn { __color_convert_ #2 _ #1 :w } ##1 \s__color_stop {#5}
32966 \cs_new:cpe { __color_convert_ #1 _ #2 :w } ##1 \s__color_stop
32967 {
32968 \exp_not:c { __color_convert_devicen_ #2 : \prg_replicate:nn {#3} { n } w }
32969 \prg_replicate:nn {#3} { { 1 } }
32970 ##1 ~ \exp_not:N \s__color_mark
32971 \clist_map_function:nN {#4} \__color_model_devicen_convert:n
32972 {}
32973 \exp_not:N \s__color_stop
32974 }
32975 }
32976 \cs_new:Npn \__color_model_devicen_convert:n #1
32977 {
32978 {
32979 \exp_args:Ne \__color_model_devicen_convert_aux:n
32980 { \prop_item:Nn \g__color_alternative_values_prop {#1} }
32981 }
32982 }
32983 \cs_new:Npn \__color_model_devicen_convert_aux:n #1
32984 { \__color_model_devicen_convert_aux:w #1 , , , , \s__color_stop }
32985 \cs_new:Npn \__color_model_devicen_convert_aux:w #1 , #2 , #3 , #4 , #5 \s__color_stop
32986 {
32987 {#1}
32988 \tl_if_blank:nF {#2}
32989 {
32990 {#2}
32991 \tl_if_blank:nF {#3}
32992 {
32993 {#3}
32994 \tl_if_blank:nF {#4} { {#4} }
32995 }
32996 }
32997 }
32998 \cs_new:Npn \__color_convert_devicen_cmyk:nnnnw
32999 #1#2#3#4#5 ~ #6 \s__color_mark #7#8 \s__color_stop
33000 {
33001 \__color_convert_devicen_cmyk:nnnnnnnnn {#5} {#1} {#2} {#3} {#4} #7
33002 #6 \s__color_mark #8 \s__color_stop
33003 }
33004 \cs_new:Npn \__color_convert_devicen_cmyk:nnnnnnnnn #1#2#3#4#5#6#7#8#9
33005 {
33006 \use:e
33007 {
33008 \exp_not:N \__color_convert_devicen_cmyk_aux:nnnnw
33009 { \fp_eval:n { #2 * (1 - (#1 * #6)) } }
33010 { \fp_eval:n { #3 * (1 - (#1 * #7)) } }
33011 { \fp_eval:n { #4 * (1 - (#1 * #8)) } }
33012 { \fp_eval:n { #5 * (1 - (#1 * #9)) } }
33013 }
33014 }
33015 \cs_new:Npn \__color_convert_devicen_cmyk_aux:nnnnw
33016 #1#2#3#4 #5 \s__color_mark #6 \s__color_stop
33017 {
33018 \tl_if_blank:nTF {#5}
33019 {
33020 \fp_eval:n { 1 - #1 } ~
33021 \fp_eval:n { 1 - #2 } ~
33022 \fp_eval:n { 1 - #3 } ~
33023 \fp_eval:n { 1 - #4 }
33024 }
33025 {
33026 \__color_convert_devicen_cmyk:nnnnw {#1} {#2} {#3} {#4}
33027 #5 \s__color_mark #6 \s__color_stop
33028 }
33029 }
33030 \cs_new:Npn \__color_convert_devicen_gray:nw
33031 #1#2 ~ #3 \s__color_mark #4#5 \s__color_stop
33032 {
33033 \__color_convert_devicen_gray:nnn {#2} {#1} #4
33034 #3 \s__color_mark #5 \s__color_stop
33035 }
33036 \cs_new:Npn \__color_convert_devicen_gray:nnn #1#2#3
33037 {
33038 \exp_arsgs:Ne \__color_convert_devicen_gray_aux:nw
33039 { \fp_eval:n { #2 * (1 - (#1 * #3)) } }
33040 }
33041 \cs_new:Npn \__color_convert_devicen_gray_aux:nw
33042 #1 #2 \s__color_mark #3 \s__color_stop
33043 {
33044 \tl_if_blank:nTF {#2}
33045 { \fp_eval:n { 1 - #1 } }
33046 {
33047 \__color_convert_devicen_gray:nw {#1}
33048 #2 \s__color_mark #3 \s__color_stop
33049 }
33050 }
33051 \cs_new:Npn \__color_convert_devicen_rgb:nnnw
33052 #1#2#3#4 ~ #5 \s__color_mark #6#7 \s__color_stop
33053 {
33054 \__color_convert_devicen_rgb:nnnnnnn {#4} {#1} {#2} {#3} #6
33055 #5 \s__color_mark #7 \s__color_stop
33056 }
33057 \cs_new:Npn \__color_convert_devicen_rgb:nnnnnnn #1#2#3#4#5#6#7
33058 {
33059 \use:e
33060 {
33061 \exp_not:N \__color_convert_devicen_rgb_aux:nnnw
33062 { \fp_eval:n { #2 * (1 - (#1 * #5)) } }
33063 { \fp_eval:n { #3 * (1 - (#1 * #6)) } }
33064 { \fp_eval:n { #4 * (1 - (#1 * #7)) } }
33065 }
33066 }
33067 \cs_new:Npn \__color_convert_devicen_rgb_aux:nnnw
33068 #1#2#3 #4 \s__color_mark #5 \s__color_stop
33069 {
33070 \tl_if_blank:nTF {#4}
33071 {
33072 \fp_eval:n { 1 - #1 } ~
33073 \fp_eval:n { 1 - #2 } ~
33074 \fp_eval:n { 1 - #3 }
33075 }
33076 {
33077 \__color_convert_devicen_rgb:nnnw {#1} {#2} {#3}
33078 #4 \s__color_mark #5 \s__color_stop
33079 }
33080 }
33081 \prop_const_from_keyval:Nn \c__color_icc_colorspace_signatures_prop
33082 {
33083 47524159 = {1} {1} {0} {},
33084 52474220 = {3} {0~0~0} {1~1~1} {},
33085 434D594B = {4} {0~0~0~1} {0~0~0~0} {},
33086 4C616220 = {3} {0~0~0} {100~0~0} {0~100~-128~127~-128~127}
33087 }
33088 \cs_new_protected:Npn \__color_model_iccbased:n #1
33089 {
33090 \prop_get:NnNTF \l__color_tmp_prop { file }
33091 \l__color_tmp_tl
33092 {
33093 \exp_args:NV \__color_model_iccbased:nn
33094 \l__color_tmp_tl {#1}
33095 }
33096 {
33097 \msg_error:nnn { color }
33098 { ICCBased-requires-file } {#1}
33099 }
33100 }
33101 \cs_new_protected:Npn \__color_model_iccbased:nn #1#2
33102 {
33103 \prop_get:NeNTF \c__color_icc_colorspace_signatures_prop
33104 { \file_hex_dump:nnn { #1 } { 17 } { 20 } } \l__color_tmp_tl
33105 {
33106 \exp_last_unbraced:NV \__color_model_iccbased_aux:nnnnnn
33107 \l__color_tmp_tl { #2 } { #1 }
33108 }
33109 {
33110 \msg_error:nnn { color }
33111 { ICCBased-unsupported-colorspace } {#2}
33112 }
33113 }
33114 \cs_new_protected:Npn \__color_model_iccbased_aux:nnnnnn #1#2#3#4#5#6
33115 {
33116 \__color_model_init:nnn {#5} { iccbased } {#3}
33117 \tl_const:cn { c__color_fallback_ #5 _tl } { gray }
33118 \cs_new:cpn { __color_convert_ #5 _gray:w } ##1 \s__color_stop { 0 }
33119 \cs_new:cpn { __color_convert_gray_ #5 :w } ##1 \s__color_stop { #2 }
33120 \use:c { __color_model_devicen_parse_ #1 :nn } {#5} {#1}
33121 \exp_args:Ne \__color_backend_iccbased_init:nnn
33122 { \file_full_name:n {#6} } {#1} {#4}
33123 }
33124 \cs_new_protected:Npn \color_profile_apply:nn #1#2
33125 {
33126 \exp_args:Ne \__color_profile_apply:nn
33127 { \file_full_name:n {#1} } {#2}
33128 }
33129 \cs_new_protected:Npn \__color_profile_apply:nn #1#2
33130 {
33131 \cs_if_exist_use:cF { __color_profile_apply_ \tl_to_str:n {#2} :n }
33132 {
33133 \msg_error:nnn { color } { ICC-Device-unknown } {#2}
33134 \use_none:n
33135 }
33136 {#1}
33137 }
33138 \cs_new_protected:Npn \__color_profile_apply_gray:n #1
33139 {
33140 \int_gincr:N \g__color_model_int
33141 \__color_backend_iccbased_device:nnn {#1} { Gray } { 1 }
33142 }
33143 \cs_new_protected:Npn \__color_profile_apply_rgb:n #1
33144 {
33145 \int_gincr:N \g__color_model_int
33146 \__color_backend_iccbased_device:nnn {#1} { RGB } { 3 }
33147 }
33148 \cs_new_protected:Npn \__color_profile_apply_cmyk:n #1
33149 {
33150 \int_gincr:N \g__color_model_int
33151 \__color_backend_iccbased_device:nnn {#1} { CMYK } { 4 }
33152 }
33153 \cs_new_protected:Npn \color_show:n
33154 { \__color_show:Nn \msg_show:nneeee }
33155 \cs_new_protected:Npn \color_log:n
33156 { \__color_show:Nn \msg_log:nneeee }
33157 \cs_new_protected:Npn \__color_show:Nn #1#2
33158 {
33159 #1 { color } { show }
33160 {#2}
33161 {
33162 \color_if_exist:nT {#2}
33163 {
33164 \exp_args:Nv \__color_show:n { l__color_named_ #2 _tl }
33165 \prop_map_function:cN
33166 { l__color_named_ #2 _prop }
33167 \msg_show_item_unbraced:nn
33168 }
33169 }
33170 { }
33171 { }
33172 }
33173 \cs_new:Npn \__color_show:n #1
33174 {
33175 \msg_show_item_unbraced:nn { model } {#1}
33176 }
33177 \msg_new:nnnn { color } { CIELAB-requires-illuminant }
33178 { CIELAB~color~space~'#1'~require~an~illuminant. }
33179 {
33180 LaTeX~has~been~asked~to~create~a~separation~color~space~using~
33181 CIELAB~specifications,~but~no~\\ \\
33182 \iow_indent:n { illuminant~=~<basis> }
33183 \\ \\
33184 key~was~given~with~the~correct~information.~LaTeX~will~use~illuminant~
33185 'd50'~for~recovery.
33186 }
33187 \msg_new:nnnn { color } { conversion-not-available }
33188 { No~model~conversion~available~from~'#1'~to~'#2'. }
33189 {
33190 LaTeX~has~been~asked~to~convert~a~color~from~model~'#1'~
33191 to~model'#2',~but~there~is~no~method~available~to~do~that.
33192 }
33193 \msg_new:nnnn { color } { DeviceN-inconsistent-alternative }
33194 { DeviceN~color~spaces~require~a~single~alternative~space. }
33195 {
33196 LaTeX~has~been~asked~to~create~a~DeviceN~color~space~'#1',~
33197 but~the~constituent~colors~do~not~have~a~common~alternative~
33198 color.
33199 }
33200 \msg_new:nnnn { color } { DeviceN-no-alternative }
33201 { DeviceN~color~spaces~require~an~alternative~space. }
33202 {
33203 LaTeX~has~been~asked~to~create~a~DeviceN~color~space~'#1',~
33204 but~the~constituent~colors~do~not~all~have~a~device-based~alternative.
33205 }
33206 \msg_new:nnnn { color } { DeviceN-requires-names }
33207 { DeviceN~color~space~'#1'~require~a~list~of~names. }
33208 {
33209 LaTeX~has~been~asked~to~create~a~DeviceN~color~space,~
33210 but~no~\\ \\
33211 \iow_indent:n { names~=~<names> }
33212 \\ \\
33213 key~was~given~with~the~correct~information.
33214 }
33215 \msg_new:nnnn { color } { ICC-Device-unknown }
33216 { Unknown~device~color~space~'#1'. }
33217 {
33218 LaTeX~has~been~asked~to~apply~an~ICC~profile~but~the~device~color~space~
33219 '#1'~is~unknown.
33220 }
33221 \msg_new:nnnn { color } { ICCBased-unsupported-colorspace }
33222 { ICCBased~color~space~'#1'~uses~an~unsupported~data~color~space. }
33223 {
33224 LaTeX~has~been~asked~to~create~a~ICCBased~colorspace,~but~the~
33225 used~data~colorspace~is~not~supported.~ICC~profiles~used~for~
33226 defining~a~ICCBased~colorspace~should~use~a~Lab,~RGB,~or~
33227 CMYK~data~colorspace.~LaTeX~will~ignore~this~request.
33228 }
33229 \msg_new:nnnn { color } { ICCBased-requires-file }
33230 { ICCBased~color~space~'#1'~require~an~file. }
33231 {
33232 LaTeX~has~been~asked~to~create~an~ICCBased~color~space,~but~no~\\ \\
33233 \iow_indent:n { file~=~<name> }
33234 \\ \\
33235 key~was~given~with~the~correct~information.~LaTeX~will~ignore~this~
33236 request.
33237 }
33238 \msg_new:nnnn { color } { model-already-defined }
33239 { Color~model~'#1'~already~defined. }
33240 {
33241 LaTeX~was~asked~to~define~a~new~color~model~called~'#1',~but~
33242 this~color~model~already~exists.
33243 }
33244 \msg_new:nnnn { color } { out-of-range }
33245 { Input~value~#1~out~of~range~[#2,~#3]. }
33246 {
33247 LaTeX~was~expecting~a~value~in~the~range~[#2,~#3]~as~part~of~a~color,~
33248 but~you~gave~#1.~LaTeX~will~assume~you~meant~the~limit~of~the~range~
33249 and~continue.
33250 }
33251 \msg_new:nnnn { color } { separation-alternative-model }
33252 { Separation~color~space~'#1'~require~an~alternative~model. }
33253 {
33254 LaTeX~has~been~asked~to~create~a~separation~color~space,~
33255 but~no~\\ \\
33256 \iow_indent:n { alternative-model~=~<model> }
33257 \\ \\
33258 key~was~given~with~the~correct~information.
33259 }
33260 \msg_new:nnnn { color } { separation-alternative-values }
33261 { Separation~color~space~'#1'~require~values~for~the~alternative~space. }
33262 {
33263 LaTeX~has~been~asked~to~create~a~separation~color~space,~
33264 but~no~\\ \\
33265 \iow_indent:n { alternative-values~=~<model> }
33266 \\ \\
33267 key~was~given~with~the~correct~information.
33268 }
33269 \msg_new:nnnn { color } { separation-requires-name }
33270 { Separation~color~space~'#1'~require~a~formal~name. }
33271 {
33272 LaTeX~has~been~asked~to~create~a~separation~color~space,~
33273 but~no~\\ \\
33274 \iow_indent:n { name~=~<formal~name> }
33275 \\ \\
33276 key~was~given~with~the~correct~information.
33277 }
33278 \msg_new:nnn { color } { unhandled-model }
33279 {
33280 Unhandled~color~model~in~LaTeX2e~value~"#1":
33281 \\ \\
33282 falling~back~on~grayscale.
33283 }
33284 \msg_new:nnnn { color } { unknown-color }
33285 { Unknown~color~'#1'. }
33286 {
33287 LaTeX~has~been~asked~to~use~a~color~named~'#1',~
33288 but~this~has~never~been~defined.
33289 }
33290 \msg_new:nnnn { color } { unknown-alternative-model }
33291 { Separation~color~space~'#1'~require~an~valid~alternative~space. }
33292 {
33293 LaTeX~has~been~asked~to~create~a~separation~color~space,~
33294 but~the~model~given~as\\ \\
33295 \iow_indent:n { alternative-model~=~<model> }
33296 \\ \\
33297 is~unknown.
33298 }
33299 \msg_new:nnnn { color } { unknown-export-format }
33300 { Unknown~export~format~'#1'. }
33301 {
33302 LaTeX~has~been~asked~to~export~a~color~in~format~'#1',~
33303 but~this~has~never~been~defined.
33304 }
33305 \msg_new:nnnn { color } { unknown-CIELAB-illuminant }
33306 { Unknown~illuminant~model~'#1'. }
33307 {
33308 LaTeX~has~been~asked~to~use~create~a~color~space~using~CIELAB~
33309 illuminant~'#1',~but~this~does~not~exist.
33310 }
33311 \msg_new:nnnn { color } { unknown-model }
33312 { Unknown~color~model~'#1'. }
33313 {
33314 LaTeX~has~been~asked~to~use~a~color~model~called~'#1',~
33315 but~this~model~is~not~set~up.
33316 }
33317 \msg_new:nnnn { color } { unknown-model-type }
33318 { Unknown~color~model~type~'#1'. }
33319 {
33320 LaTeX~has~been~asked~to~create~a~new~color~model~called~'#1',~
33321 but~this~type~of~model~was~never~set~up.
33322 }
33323 \prop_gput:Nnn \g_msg_module_name_prop { color } { LaTeX }
33324 \prop_gput:Nnn \g_msg_module_type_prop { color } { }
33325 \msg_new:nnn { color } { show }
33326 {
33327 The~color~#1~
33328 \tl_if_empty:nTF {#2}
33329 { is~undefined. }
33330 { has~the~properties: #2 }
33331 }
33332 %% File: l3graphics.dtx
33333 \dim_new:N \l__graphics_tmp_dim
33334 \ior_new:N \l__graphics_tmp_ior
33335 \tl_new:N \l__graphics_tmp_tl
33336 \scan_new:N \s__graphics_stop
33337 \tl_new:N \l__graphics_pagebox_tl
33338 \keys_define:nn { graphics }
33339 {
33340 decodearray .str_set:N =
33341 \l__graphics_decodearray_str ,
33342 draft .bool_set:N =
33343 \l__graphics_draft_bool ,
33344 interpolate .bool_set:N =
33345 \l__graphics_interpolate_bool ,
33346 pagebox .choices:nn =
33347 { art , bleed , crop , media , trim }
33348 {
33349 \tl_set:Ne \l__graphics_pagebox_tl
33350 { \l_keys_choice_tl box }
33351 } ,
33352 pagebox .initial:n =
33353 crop ,
33354 page .int_set:N =
33355 \l__graphics_page_int ,
33356 pdf-attr .str_set:N =
33357 \l__graphics_pdf_str ,
33358 type .str_set:N =
33359 \l__graphics_type_str
33360 }
33361 \dim_new:N \l__graphics_llx_dim
33362 \dim_new:N \l__graphics_lly_dim
33363 \dim_new:N \l__graphics_urx_dim
33364 \dim_new:N \l__graphics_ury_dim
33365 \cs_new_protected:Npn \__graphics_bb_save:n #1
33366 {
33367 \dim_if_exist:cTF { c__graphics_ #1 _urx_dim }
33368 { \msg_error:nnn { graphic } { bb-already-cached } {#1} }
33369 {
33370 \dim_compare:nNnF \l__graphics_llx_dim = { 0pt }
33371 { \dim_const:cn { c__graphics_ #1 _llx_dim } { \l__graphics_llx_dim } }
33372 \dim_compare:nNnF \l__graphics_lly_dim = { 0pt }
33373 { \dim_const:cn { c__graphics_ #1 _lly_dim } { \l__graphics_lly_dim } }
33374 \dim_const:cn { c__graphics_ #1 _urx_dim } { \l__graphics_urx_dim }
33375 \dim_const:cn { c__graphics_ #1 _ury_dim } { \l__graphics_ury_dim }
33376 }
33377 }
33378 \cs_generate_variant:Nn \__graphics_bb_save:n { e }
33379 \cs_new_protected:Npn \__graphics_bb_restore:nF #1#2
33380 {
33381 \dim_if_exist:cTF { c__graphics_ #1 _urx_dim }
33382 {
33383 \dim_set_eq:Nc \l__graphics_urx_dim { c__graphics_ #1 _urx_dim }
33384 \dim_set_eq:Nc \l__graphics_ury_dim { c__graphics_ #1 _ury_dim }
33385 \dim_if_exist:cTF { c__graphics_ #1 _llx_dim }
33386 { \dim_set_eq:Nc \l__graphics_llx_dim { c__graphics_ #1 _llx_dim } }
33387 { \dim_zero:N \l__graphics_llx_dim }
33388 \dim_if_exist:cTF { c__graphics_ #1 _lly_dim }
33389 { \dim_set_eq:Nc \l__graphics_lly_dim { c__graphics_ #1 _lly_dim } }
33390 { \dim_zero:N \l__graphics_lly_dim }
33391 }
33392 {#2}
33393 }
33394 \cs_generate_variant:Nn \__graphics_bb_restore:nF { e }
33395 \cs_new_protected:Npn \__graphics_extract_bb:n #1
33396 {
33397 \int_compare:nNnTF \l__graphics_page_int > 0
33398 { \__graphics_extract_bb_auxi:Vn \l__graphics_page_int {#1} }
33399 { \__graphics_extract_bb_auxii:nnn {#1} { } { } }
33400 }
33401 \cs_new_protected:Npn \__graphics_extract_bb_auxi:nn #1#2
33402 { \__graphics_extract_bb_auxii:nnn {#2} { :P #1 } { -p~#1~ } }
33403 \cs_generate_variant:Nn \__graphics_extract_bb_auxi:nn { Vn }
33404 \cs_new_protected:Npn \__graphics_extract_bb_auxii:nnn #1#2#3
33405 {
33406 \tl_if_empty:NTF \l__graphics_pagebox_tl
33407 { \__graphics_extract_bb_auxiv:nnn }
33408 { \__graphics_extract_bb_auxiii:Vnnn \l__graphics_pagebox_tl }
33409 {#1} {#2} {#3}
33410 }
33411 \cs_new_protected:Npn \__graphics_extract_bb_auxiii:nnnn #1#2#3#4
33412 { \__graphics_extract_bb_auxiv:nnn {#2} { : #1 #3 } { #4 -B~#1~ } }
33413 \cs_generate_variant:Nn \__graphics_extract_bb_auxiii:nnnn { V }
33414 \cs_new_protected:Npn \__graphics_extract_bb_auxiv:nnn #1#2#3
33415 {
33416 \__graphics_read_bb_auxi:nnnn {#1} {#2}
33417 { \ior_shell_open:Nn \l__graphics_tmp_ior { extractbb~#3-O~#1 } }
33418 { pipe-failed }
33419 }
33420 \cs_new_protected:Npn \__graphics_read_bb:n #1
33421 {
33422 \__graphics_read_bb_auxi:nnnn {#1} { }
33423 { \ior_open:Nn \l__graphics_tmp_ior {#1} }
33424 { graphic-not-found }
33425 }
33426 \cs_new_protected:Npn \__graphics_read_bb_auxi:nnnn #1#2#3#4
33427 {
33428 \__graphics_bb_restore:nF {#1#2}
33429 { \__graphics_read_bb_auxii:nnnn {#3} {#4} {#1} {#2} }
33430 }
33431 \cs_new_protected:Npe \__graphics_read_bb_auxii:nnnn #1#2#3#4
33432 {
33433 #1
33434 \exp_not:N \ior_if_eof:NTF \exp_not:N \l__graphics_tmp_ior
33435 { \msg_error:nnn { graphics } {#2} {#3} }
33436 {
33437 \ior_str_map_inline:Nn \exp_not:N \l__graphics_tmp_ior
33438 {
33439 \exp_not:N \__graphics_read_bb_auxiii:w
33440 ##1 ~ \c_colon_str \s__graphics_stop
33441 }
33442 \__graphics_bb_save:n {#3#4}
33443 }
33444 \ior_close:N \exp_not:N \l__graphics_tmp_ior
33445 }
33446 \use:e
33447 {
33448 \cs_new_protected:Npn \exp_not:N \__graphics_read_bb_auxiii:w
33449 #1 \c_colon_str #2 \s__graphics_stop
33450 {
33451 \exp_not:N \str_if_eq:nnT
33452 { \c_percent_str \c_percent_str BoundingBox }
33453 {#1}
33454 { \exp_not:N \__graphics_read_bb_auxiv:w #2 ( ) \s__graphics_stop }
33455 }
33456 }
33457 \cs_new_protected:Npn \__graphics_read_bb_auxiv:w #1 ( #2 ) #3 \s__graphics_stop
33458 {
33459 \str_if_eq:nnF {#2} { atend }
33460 {
33461 \tl_set_rescan:Nne \l__graphics_tmp_tl
33462 {
33463 \char_set_catcode_space:n { 9 }
33464 \char_set_catcode_space:n { 32 }
33465 }
33466 { \use:n #1 }
33467 \exp_after:wN \__graphics_read_bb_auxv:w \l__graphics_tmp_tl \s__graphics_stop
33468 }
33469 }
33470 \cs_new_protected:Npn \__graphics_read_bb_auxv:w #1~#2~#3~#4~#5 \s__graphics_stop
33471 {
33472 \dim_set:Nn \l__graphics_llx_dim { #1 bp }
33473 \dim_set:Nn \l__graphics_lly_dim { #2 bp }
33474 \dim_set:Nn \l__graphics_urx_dim { #3 bp }
33475 \dim_set:Nn \l__graphics_ury_dim { #4 bp }
33476 \ior_map_break:
33477 }
33478 \str_new:N \l__graphics_final_name_str
33479 \str_new:N \l__graphics_full_name_str
33480 \box_new:N \l__graphics_tmp_box
33481 \str_new:N \l__graphics_dir_str
33482 \str_new:N \l__graphics_name_str
33483 \str_new:N \l__graphics_ext_str
33484 \seq_new:N \l_graphics_search_path_seq
33485 \seq_new:N \l_graphics_search_ext_seq
33486 \prop_new:N \l_graphics_ext_type_prop
33487 \prop_put:Nnn \l_graphics_ext_type_prop { .ps } { eps }
33488 \seq_new:N \g__graphics_record_seq
33489 \cs_new_protected:Npn \graphics_include:nn #1#2
33490 {
33491 \group_begin:
33492 \keys_set:nn { graphics } {#1}
33493 \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
33494 \file_get_full_name:nNTF {#2} \l__graphics_full_name_str
33495 {
33496 \str_if_eq:eeTF { \l__graphics_full_name_str } { #2 .tex }
33497 { \msg_error:nnn { graphics } { graphic-not-found } {#2} }
33498 { \__graphics_include: }
33499 }
33500 { \msg_error:nnn { graphics } { graphic-not-found } {#2} }
33501 \group_end:
33502 }
33503 \cs_generate_variant:Nn \graphics_include:nn { nV }
33504 \cs_new_protected:Npn \__graphics_include:
33505 {
33506 \str_if_empty:NTF \l__graphics_type_str
33507 {
33508 \file_parse_full_name:VNNN \l__graphics_full_name_str
33509 \l__graphics_dir_str \l__graphics_name_str \l__graphics_ext_str
33510 \__graphics_include_auxi:e
33511 {
33512 \exp_args:Ne \str_tail:n
33513 { \str_casefold:V \l__graphics_ext_str }
33514 }
33515 }
33516 { \__graphics_include_auxi:e { \l__graphics_type_str } }
33517 }
33518 \cs_new_protected:Npn \__graphics_include_auxi:n #1
33519 {
33520 \prop_get:NnNF \l_graphics_ext_type_prop { .#1 } \l__graphics_tmp_tl
33521 { \tl_set:Nn \l__graphics_tmp_tl {#1} }
33522 \exp_args:NV \__graphics_include_auxii:n \l__graphics_tmp_tl
33523 }
33524 \cs_generate_variant:Nn \__graphics_include_auxi:n { e }
33525 \cs_new_protected:Npn \__graphics_include_auxii:n #1
33526 {
33527 \mode_leave_vertical:
33528 \cs_if_exist:cTF { __graphics_backend_include_ #1 :n }
33529 {
33530 \tl_set_eq:NN \l__graphics_final_name_str \l__graphics_full_name_str
33531 \str_set:Ne \l__graphics_full_name_str
33532 { \exp_args:NV \__kernel_file_name_quote:n \l__graphics_full_name_str }
33533 \exp_args:NnV \use:c { __graphics_backend_getbb_ #1 :n }
33534 \l__graphics_full_name_str
33535 \seq_gput_right:NV \g__graphics_record_seq \l__graphics_final_name_str
33536 \clist_if_exist:NT \@filelist
33537 { \exp_args:NV \@addtofilelist \l__graphics_final_name_str }
33538 \bool_if:NTF \l__graphics_draft_bool
33539 { \__graphics_include_auxiii:n }
33540 { \__graphics_include_auxiv:n }
33541 {#1}
33542 }
33543 { \msg_error:nnn { graphics } { unsupported-graphic-type } {#1} }
33544 }
33545 \cs_new_protected:Npn \__graphics_include_auxiii:n #1
33546 {
33547 \hbox_to_wd:nn { \l__graphics_urx_dim - \l__graphics_llx_dim }
33548 {
33549 \tex_vrule:D
33550 \tex_hss:D
33551 \vbox_to_ht:nn
33552 { \l__graphics_ury_dim - \l__graphics_lly_dim }
33553 {
33554 \tex_hrule:D width
33555 \dim_eval:n { \l__graphics_urx_dim - \l__graphics_llx_dim }
33556 \tex_vss:D
33557 \hbox_to_wd:nn
33558 { \l__graphics_urx_dim - \l__graphics_llx_dim }
33559 {
33560 \ttfamily
33561 \tex_hss:D \l__graphics_full_name_str \tex_hss:D
33562 }
33563 \tex_vss:D
33564 \tex_hrule:D
33565 }
33566 \tex_hss:D
33567 \tex_vrule:D
33568 }
33569 }
33570 \cs_new_protected:Npn \__graphics_include_auxiv:n #1
33571 {
33572 \hbox_set:Nn \l__graphics_tmp_box
33573 {
33574 \exp_args:NnV \use:c { __graphics_backend_include_ #1 :n }
33575 \l__graphics_full_name_str
33576 }
33577 \box_set_dp:Nn \l__graphics_tmp_box { 0pt }
33578 \box_set_ht:Nn \l__graphics_tmp_box
33579 { \l__graphics_ury_dim - \l__graphics_lly_dim }
33580 \box_set_wd:Nn \l__graphics_tmp_box
33581 { \l__graphics_urx_dim - \l__graphics_llx_dim }
33582 \box_use_drop:N \l__graphics_tmp_box
33583 }
33584 \cs_new_protected:Npn \graphics_show_list: { \__graphics_list:N \msg_show:nneeee }
33585 \cs_new_protected:Npn \graphics_log_list: { \__graphics_list:N \msg_log:nneeee }
33586 \cs_new_protected:Npn \__graphics_list:N #1
33587 {
33588 \seq_remove_duplicates:N \g__graphics_record_seq
33589 #1 { kernel } { file-list }
33590 { \seq_map_function:NN \g__graphics_record_seq \__graphics_list_aux:n }
33591 { } { } { }
33592 }
33593 \cs_new:Npn \__graphics_list_aux:n #1 { \iow_newline: #1 }
33594 \cs_new_protected:Npn \graphics_get_full_name:nN #1#2
33595 {
33596 \graphics_get_full_name:nNF {#1} #2
33597 { \tl_set:Nn #2 { \q_no_value } }
33598 }
33599 \prg_new_protected_conditional:Npnn \graphics_get_full_name:nN #1#2
33600 { T , F , TF }
33601 {
33602 \group_begin:
33603 \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
33604 \file_get_full_name:nNTF {#1} \l__graphics_full_name_str
33605 {
33606 \str_if_eq:eeTF { \l__graphics_full_name_str } { #1 .tex }
33607 { \__graphics_get_full_name:n {#1} }
33608 {
33609 \file_parse_full_name:VNNN \l__graphics_full_name_str
33610 \l__graphics_dir_str \l__graphics_name_str \l__graphics_ext_str
33611 \seq_map_inline:Nn \l_graphics_search_ext_seq
33612 {
33613 \str_if_eq:nVT {##1} \l__graphics_ext_str
33614 { \seq_map_break:n { \use_none:nn } }
33615 }
33616 \__graphics_get_full_name:n {#1}
33617 }
33618 }
33619 { \__graphics_get_full_name:n {#1} }
33620 \exp_args:NNNV \group_end:
33621 \tl_set:Nn #2 \l__graphics_full_name_str
33622 \tl_if_empty:NTF #2
33623 { \prg_return_false: }
33624 { \prg_return_true: }
33625 }
33626 \cs_new_protected:Npn \__graphics_get_full_name:n #1
33627 {
33628 \str_clear:N \l__graphics_full_name_str
33629 \seq_map_inline:Nn \l_graphics_search_ext_seq
33630 {
33631 \file_get_full_name:nNT { #1 ##1 } \l__graphics_full_name_str
33632 { \seq_map_break:n { \use_none:nn } }
33633 }
33634 \use:n
33635 { \str_clear:N \l__graphics_full_name_str }
33636 }
33637 \cs_new_protected:Npn \graphics_get_pagecount:nN #1#2
33638 {
33639 \group_begin:
33640 \seq_set_eq:NN \l_file_search_path_seq \l_graphics_search_path_seq
33641 \file_get_full_name:nNTF {#1} \l__graphics_full_name_str
33642 {
33643 \int_if_exist:cF { c__graphics_ \l__graphics_full_name_str _pages_int }
33644 {
33645 \exp_args:NV \__graphics_backend_get_pagecount:n
33646 \l__graphics_full_name_str
33647 }
33648 \tl_set:Nv #2 { c__graphics_ \l__graphics_full_name_str _pages_int }
33649 }
33650 {
33651 \tl_set:Nn #2 { 0 }
33652 \msg_error:nnn { graphics } { graphic-not-found } {#1}
33653 }
33654 \exp_args:NNNV \group_end:
33655 \tl_set:Nn #2 #2
33656 }
33657 \cs_new_protected:Npe \__graphics_get_pagecount:n #1
33658 {
33659 \exp_not:N \ior_shell_open:Nn \exp_not:N \l__graphics_tmp_ior
33660 { extractbb~-O~#1 }
33661 \exp_not:N \ior_if_eof:NTF \exp_not:N \l__graphics_tmp_ior
33662 { \msg_error:nnn { graphics } { pipe-failed } }
33663 {
33664 \ior_str_map_inline:Nn \exp_not:N \l__graphics_tmp_ior
33665 {
33666 \exp_not:N \__graphics_get_pagecount:nw {#1}
33667 ##1 ~ \c_colon_str \c_colon_str \s__graphics_stop
33668 }
33669 \exp_not:N \int_if_exist:cF { c__graphics_ #1 _pages_int }
33670 { \int_const:cn { c__graphics_ #1 _pages_int } { 1 } }
33671 }
33672 \ior_close:N \exp_not:N \l__graphics_tmp_ior
33673 }
33674 \use:e
33675 {
33676 \cs_new_protected:Npn \exp_not:N \__graphics_get_pagecount:nw
33677 #1#2 \c_colon_str #3 \c_colon_str #4 \s__graphics_stop
33678 {
33679 \exp_not:N \str_if_eq:nnT
33680 { \c_percent_str \c_percent_str Pages }
33681 {#2}
33682 {
33683 \int_const:cn { c__graphics_ #1 _pages_int } {#3}
33684 \exp_not:N \ior_map_break:
33685 }
33686 }
33687 }
33688 \msg_new:nnnn { graphics } { graphic-not-found }
33689 { Image~file~'#1'~not~found. }
33690 {
33691 LaTeX~tried~to~open~graphic~file~'#1',~
33692 but~the~file~could~not~be~read.
33693 }
33694 \msg_new:nnnn { graphics } { pipe-failed }
33695 { Cannot~run~piped~system~commands. }
33696 {
33697 LaTeX~tried~to~call~a~system~process~but~this~was~not~possible.\\
33698 Try~the~"--shell-escape"~(or~"--enable-pipes")~option.
33699 }
33700 \msg_new:nnnn { graphics } { unsupported-graphic-type }
33701 { Image~type~'#1'~not~supported~by~current~driver. }
33702 {
33703 LaTeX~was~asked~to~include~an~graphic~of~type~'#1',~
33704 but~this~is~not~supported~by~the~current~driver~(production~route).
33705 }
33706 %% File: l3opacity.dtx
33707 \cs_if_exist:NT \@expl@finalise@setup@@
33708 {
33709 \tl_gput_right:Nn \@expl@finalise@setup@@
33710 { \declare@file@substitution { l3opacity.sty } { null.tex } }
33711 }
33712 \fp_new:N \l__opacity_tmp_fp
33713 \cs_new_protected:Npn \opacity_select:n #1
33714 {
33715 \__opacity_select:nNn {#1} \__opacity_backend_select:n
33716 { \group_insert_after:N \__opacity_backend_reset: }
33717 }
33718 \cs_new_protected:Npn \opacity_fill:n #1
33719 {
33720 \__opacity_select:nNn {#1} \__opacity_backend_fill:n
33721 { \group_insert_after:N \__opacity_backend_reset_fill: }
33722 }
33723 \cs_new_protected:Npn \opacity_stroke:n #1
33724 {
33725 \__opacity_select:nNn {#1} \__opacity_backend_stroke:n
33726 { \group_insert_after:N \__opacity_backend_reset_stroke: }
33727 }
33728 \cs_new_protected:Npn \opacity_begin:n #1
33729 { \__opacity_select:nN {#1} \__opacity_backend_select:n }
33730 \cs_new_protected:Npn \opacity_fill_begin:n #1
33731 { \__opacity_select:nN {#1} \__opacity_backend_fill:n }
33732 \cs_new_protected:Npn \opacity_stroke_begin:n #1
33733 { \__opacity_select:nN {#1} \__opacity_backend_stroke:n }
33734 \cs_new_protected:Npn \opacity_end:
33735 { \__opacity_backend_reset: }
33736 \cs_new_protected:Npn \opacity_fill_end:
33737 { \__opacity_backend_reset_fill: }
33738 \cs_new_protected:Npn \opacity_stroke_end:
33739 { \__opacity_backend_reset_stroke: }
33740 \cs_new_protected:Npn \__opacity_select:nNn #1#2#3
33741 {
33742 \fp_set:Nn \l__opacity_tmp_fp {#1}
33743 \bool_lazy_or:nnTF
33744 { \fp_compare_p:nNn \l__opacity_tmp_fp < \c_zero_fp }
33745 { \fp_compare_p:nNn \l__opacity_tmp_fp > \c_one_fp }
33746 { \msg_error:nnn { opacity } { out-of-range } {#1} }
33747 {
33748 \exp_args:Ne #2 { \fp_use:N \l__opacity_tmp_fp }
33749 #3
33750 }
33751 }
33752 \cs_new_protected:Npn \__opacity_select:nN #1#2
33753 { \__opacity_select:nNn {#1} #2 { } }
33754 \msg_new:nnnn { opacity } { out-of-range }
33755 { Opacity~value~out~of~range. }
33756 {
33757 LaTeX~was~asked~to~set~opacity~of~#1,~but~only~values~in~the~range~
33758 0~to~1~are~supported.
33759 }
33760 %% File: l3pdf.dtx
33761 \scan_new:N \s__pdf_stop
33762 \bool_new:N \g__pdf_init_bool
33763 \bool_lazy_and:nnT
33764 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
33765 { \tl_if_exist_p:N \@expl@finalise@setup@@ }
33766 {
33767 \tl_gput_right:Nn \@expl@finalise@setup@@
33768 {
33769 \tl_gput_right:Nn \@kernel@after@begindocument
33770 { \bool_gset_true:N \g__pdf_init_bool }
33771 }
33772 }
33773 \cs_new_protected:Npn \pdf_uncompress:
33774 {
33775 \bool_if:NF \g__pdf_init_bool
33776 {
33777 \__pdf_backend_compresslevel:n { 0 }
33778 \__pdf_backend_compress_objects:n { \c_false_bool }
33779 }
33780 }
33781 \int_new:N \g__pdf_backend_object_int
33782 \cs_new_protected:Npn \pdf_object_new:n #1
33783 {
33784 \__pdf_backend_object_new:
33785 \__pdf_object_record:nN {#1} \g__pdf_backend_object_int
33786 }
33787 \cs_new_protected:Npn \pdf_object_write:nnn #1#2#3
33788 {
33789 \exp_args:Ne \__pdf_backend_object_write:nnn
33790 { \__pdf_object_retrieve:n {#1} } {#2} {#3}
33791 \bool_gset_true:N \g__pdf_init_bool
33792 }
33793 \cs_generate_variant:Nn \pdf_object_write:nnn { nne , nnx }
33794 \cs_new:Npn \pdf_object_ref:n #1
33795 {
33796 \exp_args:Ne \__pdf_backend_object_ref:n
33797 { \__pdf_object_retrieve:n {#1} }
33798 }
33799 \cs_new:Npn \__kernel_pdf_object_id:n #1
33800 {
33801 \exp_args:Ne \__pdf_backend_object_id:n
33802 { \__pdf_object_retrieve:n {#1} }
33803 }
33804 \sys_if_engine_luatex:F
33805 {
33806 \cs_new_protected:Npn \__pdf_object_record:nN #1#2
33807 {
33808 \int_const:cn
33809 { c__pdf_object_ #1 _int } {#2}
33810 }
33811 \cs_new:Npn \__pdf_object_retrieve:n #1
33812 {
33813 \int_if_exist:cTF { c__pdf_object_ #1 _int }
33814 {
33815 \int_use:c
33816 { c__pdf_object_ #1 _int }
33817 }
33818 { 0 }
33819 }
33820 }
33821 \prg_new_conditional:Npnn \pdf_object_if_exist:n #1 { p , T , F , TF }
33822 {
33823 \int_compare:nNnTF { \__pdf_object_retrieve:n {#1} } = 0
33824 \prg_return_false:
33825 \prg_return_true:
33826 }
33827 \cs_new_protected:Npn \pdf_object_new_indexed:nn #1#2
33828 {
33829 \__pdf_backend_object_new:
33830 \__pdf_object_record:neN {#1}
33831 { \int_eval:n {#2} } \g__pdf_backend_object_int
33832 }
33833 \cs_new_protected:Npn \pdf_object_write_indexed:nnnn #1#2#3#4
33834 {
33835 \exp_args:Ne \__pdf_backend_object_write:nnn
33836 { \__pdf_object_retrieve:ne {#1} { \int_eval:n {#2} } } {#3} {#4}
33837 \bool_gset_true:N \g__pdf_init_bool
33838 }
33839 \cs_generate_variant:Nn \pdf_object_write_indexed:nnnn { nnne }
33840 \cs_new:Npn \pdf_object_ref_indexed:nn #1#2
33841 {
33842 \exp_args:Ne \__pdf_backend_object_ref:n
33843 { \__pdf_object_retrieve:ne {#1} { \int_eval:n {#2} } }
33844 }
33845 \cs_new:Npn \__kernel_pdf_object_id_indexed:nn #1#2
33846 {
33847 \exp_args:Ne \__pdf_backend_object_id:n
33848 { \__pdf_object_retrieve:ne {#1} { \int_eval:n {#2} } }
33849 }
33850 \sys_if_engine_luatex:F
33851 {
33852 \cs_new_protected:Npn \__pdf_object_record:nnN #1#2#3
33853 {
33854 \use:e
33855 {
33856 \__pdf_object_record:NnN
33857 \__pdf_object_index_split:nn {#1} {#2}
33858 \exp_not:N #3
33859 }
33860 }
33861 \cs_new_protected:Npn \__pdf_object_record:NnN #1#2#3
33862 {
33863 \intarray_if_exist:NF #1
33864 { \intarray_new:Nn #1 \c__pdf_object_block_size_int }
33865 \intarray_gset:Nnn #1 {#2} #3
33866 }
33867 \cs_new:Npn \__pdf_object_retrieve:nn #1#2
33868 {
33869 \use:e
33870 {
33871 \exp_not:N \__pdf_object_retrieve:Nn
33872 \__pdf_object_index_split:nn {#1} {#2}
33873 }
33874 }
33875 \cs_new:Npn \__pdf_object_retrieve:Nn #1#2
33876 { \intarray_item:Nn #1 {#2} }
33877 \cs_new:Npn \__pdf_object_index_split:nn #1#2
33878 {
33879 \exp_not:c
33880 {
33881 g__pdf_object_ #1 _
33882 \int_eval:n
33883 {
33884 \int_div_truncate:nn { #2 - 1 }
33885 \c__pdf_object_block_size_int + 1
33886 }
33887 _intarray
33888 }
33889 {
33890 \int_eval:n
33891 { \int_mod:nn { #2 - 1 } \c__pdf_object_block_size_int + 1 }
33892 }
33893 }
33894 \int_const:Nn \c__pdf_object_block_size_int { 10000 }
33895 }
33896 \cs_generate_variant:Nn \__pdf_object_record:nnN { ne }
33897 \cs_generate_variant:Nn \__pdf_object_retrieve:nn { ne }
33898 \cs_new_protected:Npn \pdf_object_unnamed_write:nn #1#2
33899 {
33900 \exp_args:Ne \__pdf_backend_object_now:nn {#1} {#2}
33901 \bool_gset_true:N \g__pdf_init_bool
33902 }
33903 \cs_generate_variant:Nn \pdf_object_unnamed_write:nn { ne , nx }
33904 \cs_new:Npn \pdf_object_ref_last: { \__pdf_backend_object_last: }
33905 \cs_new:Npn \pdf_pageobject_ref:n #1
33906 { \exp_args:Ne \__pdf_backend_pageobject_ref:n {#1} }
33907 \prg_new_conditional:Npnn \pdf_version_compare:Nn #1#2 { p , T , F , TF }
33908 { \use:c { __pdf_version_compare_ #1 :w } #2 . . \s__pdf_stop }
33909 \cs_new:cpn { __pdf_version_compare_=:w } #1 . #2 . #3 \s__pdf_stop
33910 {
33911 \bool_lazy_and:nnTF
33912 { \int_compare_p:nNn \__pdf_backend_version_major: = {#1} }
33913 { \int_compare_p:nNn \__pdf_backend_version_minor: = {#2} }
33914 { \prg_return_true: }
33915 { \prg_return_false: }
33916 }
33917 \cs_new:cpn { __pdf_version_compare_<:w } #1 . #2 . #3 \s__pdf_stop
33918 {
33919 \bool_lazy_or:nnTF
33920 { \int_compare_p:nNn \__pdf_backend_version_major: < {#1} }
33921 {
33922 \bool_lazy_and_p:nn
33923 { \int_compare_p:nNn \__pdf_backend_version_major: = {#1} }
33924 { \int_compare_p:nNn \__pdf_backend_version_minor: < {#2} }
33925 }
33926 { \prg_return_true: }
33927 { \prg_return_false: }
33928 }
33929 \cs_new:cpn { __pdf_version_compare_>:w } #1 . #2 . #3 \s__pdf_stop
33930 {
33931 \bool_lazy_or:nnTF
33932 { \int_compare_p:nNn \__pdf_backend_version_major: > {#1} }
33933 {
33934 \bool_lazy_and_p:nn
33935 { \int_compare_p:nNn \__pdf_backend_version_major: = {#1} }
33936 { \int_compare_p:nNn \__pdf_backend_version_minor: > {#2} }
33937 }
33938 { \prg_return_true: }
33939 { \prg_return_false: }
33940 }
33941 \cs_new_protected:Npn \pdf_version_gset:n #1
33942 { \__pdf_version_gset:w #1 . . \s__pdf_stop }
33943 \cs_new_protected:Npn \pdf_version_min_gset:n #1
33944 {
33945 \pdf_version_compare:NnT < {#1}
33946 { \__pdf_version_gset:w #1 . . \s__pdf_stop }
33947 }
33948 \cs_new_protected:Npn \__pdf_version_gset:w #1 . #2 . #3\s__pdf_stop
33949 {
33950 \bool_if:NF \g__pdf_init_bool
33951 {
33952 \__pdf_backend_version_major_gset:n {#1}
33953 \__pdf_backend_version_minor_gset:n {#2}
33954 }
33955 }
33956 \cs_new:Npn \pdf_version:
33957 { \__pdf_backend_version_major: . \__pdf_backend_version_minor: }
33958 \cs_new:Npn \pdf_version_major: { \__pdf_backend_version_major: }
33959 \cs_new:Npn \pdf_version_minor: { \__pdf_backend_version_minor: }
33960 \cs_new_protected:Npn \pdf_pagesize_gset:nn #1#2
33961 { \__pdf_backend_pagesize_gset:nn {#1} {#2} }
33962 \cs_new_protected:Npn \pdf_destination:nn #1#2
33963 { \__pdf_backend_destination:nn {#1} {#2} }
33964 \cs_new_protected:Npn \pdf_destination:nnnn #1#2#3#4
33965 {
33966 \hbox_to_zero:n
33967 { \__pdf_backend_destination:nnnn {#1} {#2} {#3} {#4} }
33968 }
33969 \cs_if_exist:NT \@kernel@before@begindocument
33970 {
33971 \tl_gput_right:Nn \@kernel@before@begindocument
33972 {
33973 \bool_lazy_all:nT
33974 {
33975 { \cs_if_exist_p:N \stockheight }
33976 { \cs_if_exist_p:N \stockwidth }
33977 { \cs_if_exist_p:N \IfPDFManagementActiveTF }
33978 { \IfPDFManagementActiveTF { \c_true_bool } { \c_false_bool } }
33979 { \int_compare_p:nNn \tex_mag:D = { 1000 } }
33980 }
33981 {
33982 \bool_lazy_and:nnTF
33983 { \dim_compare_p:nNn \stockheight > { 0pt } }
33984 { \dim_compare_p:nNn \stockwidth > { 0pt } }
33985 {
33986 \__pdf_backend_pagesize_gset:nn
33987 \stockwidth \stockheight
33988 }
33989 {
33990 \bool_lazy_or:nnF
33991 { \dim_compare_p:nNn \stockheight < { 0pt } }
33992 { \dim_compare_p:nNn \stockwidth < { 0pt } }
33993 {
33994 \bool_lazy_and:nnT
33995 { \dim_compare_p:nNn \paperheight > { 0pt } }
33996 { \dim_compare_p:nNn \paperwidth > { 0pt } }
33997 {
33998 \__pdf_backend_pagesize_gset:nn
33999 \paperwidth \paperheight
34000 }
34001 }
34002 }
34003 }
34004 }
34005 }
34006 %% File: l3coffins.dtx
34007 \box_new:N \l__coffin_tmp_box
34008 \dim_new:N \l__coffin_tmp_dim
34009 \tl_new:N \l__coffin_tmp_tl
34010 \prop_const_from_keyval:Nn \c__coffin_corners_prop
34011 {
34012 tl = { 0pt } { 0pt } ,
34013 tr = { 0pt } { 0pt } ,
34014 bl = { 0pt } { 0pt } ,
34015 br = { 0pt } { 0pt } ,
34016 }
34017 \prop_const_from_keyval:Nn \c__coffin_poles_prop
34018 {
34019 l = { 0pt } { 0pt } { 0pt } { 1000pt } ,
34020 hc = { 0pt } { 0pt } { 0pt } { 1000pt } ,
34021 r = { 0pt } { 0pt } { 0pt } { 1000pt } ,
34022 b = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34023 vc = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34024 t = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34025 B = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34026 H = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34027 T = { 0pt } { 0pt } { 1000pt } { 0pt } ,
34028 }
34029 \fp_new:N \l__coffin_slope_A_fp
34030 \fp_new:N \l__coffin_slope_B_fp
34031 \bool_new:N \l__coffin_error_bool
34032 \dim_new:N \l__coffin_offset_x_dim
34033 \dim_new:N \l__coffin_offset_y_dim
34034 \dim_new:N \l__coffin_x_dim
34035 \dim_new:N \l__coffin_y_dim
34036 \dim_new:N \l__coffin_x_prime_dim
34037 \dim_new:N \l__coffin_y_prime_dim
34038 \cs_new_eq:NN \__coffin_to_value:N \tex_number:D
34039 \prg_new_conditional:Npnn \coffin_if_exist:N #1 { p , T , F , TF }
34040 {
34041 \cs_if_exist:NTF #1
34042 {
34043 \cs_if_exist:cTF { coffin ~ \__coffin_to_value:N #1 ~ poles }
34044 { \prg_return_true: }
34045 { \prg_return_false: }
34046 }
34047 { \prg_return_false: }
34048 }
34049 \prg_generate_conditional_variant:Nnn \coffin_if_exist:N
34050 { c } { p , T , F , TF }
34051 \cs_new_protected:Npn \__coffin_if_exist:NT #1#2
34052 {
34053 \coffin_if_exist:NTF #1
34054 { #2 }
34055 {
34056 \msg_error:nne { coffin } { unknown }
34057 { \token_to_str:N #1 }
34058 }
34059 }
34060 \cs_new_protected:Npn \coffin_clear:N #1
34061 {
34062 \__coffin_if_exist:NT #1
34063 {
34064 \box_clear:N #1
34065 \__coffin_reset_structure:N #1
34066 }
34067 }
34068 \cs_generate_variant:Nn \coffin_clear:N { c }
34069 \cs_new_protected:Npn \coffin_gclear:N #1
34070 {
34071 \__coffin_if_exist:NT #1
34072 {
34073 \box_gclear:N #1
34074 \__coffin_greset_structure:N #1
34075 }
34076 }
34077 \cs_generate_variant:Nn \coffin_gclear:N { c }
34078 \cs_new_protected:Npn \coffin_new:N #1
34079 {
34080 \box_new:N #1
34081 \debug_suspend:
34082 \prop_gclear_new:c { coffin ~ \__coffin_to_value:N #1 ~ corners }
34083 \prop_gclear_new:c { coffin ~ \__coffin_to_value:N #1 ~ poles }
34084 \prop_gset_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ corners }
34085 \c__coffin_corners_prop
34086 \prop_gset_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ poles }
34087 \c__coffin_poles_prop
34088 \debug_resume:
34089 }
34090 \cs_generate_variant:Nn \coffin_new:N { c }
34091 \cs_new_protected:Npn \hcoffin_set:Nn #1#2
34092 {
34093 \__coffin_if_exist:NT #1
34094 {
34095 \hbox_set:Nn #1
34096 {
34097 \color_ensure_current:
34098 #2
34099 }
34100 \coffin_reset_poles:N #1
34101 }
34102 }
34103 \cs_generate_variant:Nn \hcoffin_set:Nn { c }
34104 \cs_new_protected:Npn \hcoffin_gset:Nn #1#2
34105 {
34106 \__coffin_if_exist:NT #1
34107 {
34108 \hbox_gset:Nn #1
34109 {
34110 \color_ensure_current:
34111 #2
34112 }
34113 \coffin_greset_poles:N #1
34114 }
34115 }
34116 \cs_generate_variant:Nn \hcoffin_gset:Nn { c }
34117 \cs_new_protected:Npn \vcoffin_set:Nnn #1#2#3
34118 {
34119 \__coffin_set_vertical:NnnNNN #1 {#2} {#3}
34120 \vbox_set:Nn \coffin_reset_poles:N \__coffin_set_pole:Nnn
34121 }
34122 \cs_generate_variant:Nn \vcoffin_set:Nnn { c }
34123 \cs_new_protected:Npn \vcoffin_gset:Nnn #1#2#3
34124 {
34125 \__coffin_set_vertical:NnnNNN #1 {#2} {#3}
34126 \vbox_gset:Nn \coffin_greset_poles:N \__coffin_gset_pole:Nnn
34127 }
34128 \cs_generate_variant:Nn \vcoffin_gset:Nnn { c }
34129 \cs_new_protected:Npn \__coffin_set_vertical:NnnNNN #1#2#3#4#5#6
34130 {
34131 \__coffin_if_exist:NT #1
34132 {
34133 #4 #1
34134 {
34135 \dim_set:Nn \tex_hsize:D {#2}
34136 \__coffin_set_vertical_aux:
34137 #3
34138 }
34139 #5 #1
34140 \vbox_set_top:Nn \l__coffin_tmp_box { \vbox_unpack:N #1 }
34141 #6 #1 { T }
34142 {
34143 { 0pt }
34144 {
34145 \dim_eval:n
34146 { \box_ht:N #1 - \box_ht:N \l__coffin_tmp_box }
34147 }
34148 { 1000pt }
34149 { 0pt }
34150 }
34151 \box_clear:N \l__coffin_tmp_box
34152 }
34153 }
34154 \cs_new_protected:Npe \__coffin_set_vertical_aux:
34155 {
34156 \bool_lazy_and:nnT
34157 { \cs_if_exist_p:N \fmtname }
34158 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
34159 {
34160 \dim_set_eq:NN \exp_not:N \linewidth \tex_hsize:D
34161 \dim_set_eq:NN \exp_not:N \columnwidth \tex_hsize:D
34162 }
34163 }
34164 \cs_new_protected:Npn \hcoffin_set:Nw #1
34165 {
34166 \__coffin_if_exist:NT #1
34167 {
34168 \hbox_set:Nw #1 \color_ensure_current:
34169 \cs_set_protected:Npn \hcoffin_set_end:
34170 {
34171 \hbox_set_end:
34172 \coffin_reset_poles:N #1
34173 }
34174 }
34175 }
34176 \cs_generate_variant:Nn \hcoffin_set:Nw { c }
34177 \cs_new_protected:Npn \hcoffin_gset:Nw #1
34178 {
34179 \__coffin_if_exist:NT #1
34180 {
34181 \hbox_gset:Nw #1 \color_ensure_current:
34182 \cs_set_protected:Npn \hcoffin_gset_end:
34183 {
34184 \hbox_gset_end:
34185 \coffin_greset_poles:N #1
34186 }
34187 }
34188 }
34189 \cs_generate_variant:Nn \hcoffin_gset:Nw { c }
34190 \cs_new_protected:Npn \hcoffin_set_end: { }
34191 \cs_new_protected:Npn \hcoffin_gset_end: { }
34192 \cs_new_protected:Npn \vcoffin_set:Nnw #1#2
34193 {
34194 \__coffin_set_vertical:NnNNNNNw #1 {#2} \vbox_set:Nw
34195 \vcoffin_set_end:
34196 \vbox_set_end: \coffin_reset_poles:N \__coffin_set_pole:Nnn
34197 }
34198 \cs_generate_variant:Nn \vcoffin_set:Nnw { c }
34199 \cs_new_protected:Npn \vcoffin_gset:Nnw #1#2
34200 {
34201 \__coffin_set_vertical:NnNNNNNw #1 {#2} \vbox_gset:Nw
34202 \vcoffin_gset_end:
34203 \vbox_gset_end: \coffin_greset_poles:N \__coffin_gset_pole:Nnn
34204 }
34205 \cs_generate_variant:Nn \vcoffin_gset:Nnw { c }
34206 \cs_new_protected:Npn \__coffin_set_vertical:NnNNNNNw #1#2#3#4#5#6#7
34207 {
34208 \__coffin_if_exist:NT #1
34209 {
34210 #3 #1
34211 \dim_set:Nn \tex_hsize:D {#2}
34212 \__coffin_set_vertical_aux:
34213 \cs_set_protected:Npn #4
34214 {
34215 #5
34216 #6 #1
34217 \vbox_set_top:Nn \l__coffin_tmp_box { \vbox_unpack:N #1 }
34218 #7 #1 { T }
34219 {
34220 { 0pt }
34221 {
34222 \dim_eval:n
34223 { \box_ht:N #1 - \box_ht:N \l__coffin_tmp_box }
34224 }
34225 { 1000pt }
34226 { 0pt }
34227 }
34228 \box_clear:N \l__coffin_tmp_box
34229 }
34230 }
34231 }
34232 \cs_new_protected:Npn \vcoffin_set_end: { }
34233 \cs_new_protected:Npn \vcoffin_gset_end: { }
34234 \cs_new_protected:Npn \coffin_set_eq:NN #1#2
34235 {
34236 \__coffin_if_exist:NT #2
34237 {
34238 \box_set_eq:NN #1 #2
34239 \prop_set_eq:cc { coffin ~ \__coffin_to_value:N #1 ~ corners }
34240 { coffin ~ \__coffin_to_value:N #2 ~ corners }
34241 \prop_set_eq:cc { coffin ~ \__coffin_to_value:N #1 ~ poles }
34242 { coffin ~ \__coffin_to_value:N #2 ~ poles }
34243 }
34244 }
34245 \cs_generate_variant:Nn \coffin_set_eq:NN { c , Nc , cc }
34246 \cs_new_protected:Npn \coffin_gset_eq:NN #1#2
34247 {
34248 \__coffin_if_exist:NT #2
34249 {
34250 \box_gset_eq:NN #1 #2
34251 \prop_gset_eq:cc { coffin ~ \__coffin_to_value:N #1 ~ corners }
34252 { coffin ~ \__coffin_to_value:N #2 ~ corners }
34253 \prop_gset_eq:cc { coffin ~ \__coffin_to_value:N #1 ~ poles }
34254 { coffin ~ \__coffin_to_value:N #2 ~ poles }
34255 }
34256 }
34257 \cs_generate_variant:Nn \coffin_gset_eq:NN { c , Nc , cc }
34258 \coffin_new:N \c_empty_coffin
34259 \coffin_new:N \l__coffin_aligned_coffin
34260 \coffin_new:N \l__coffin_aligned_internal_coffin
34261 \coffin_new:N \l_tmpa_coffin
34262 \coffin_new:N \l_tmpb_coffin
34263 \coffin_new:N \g_tmpa_coffin
34264 \coffin_new:N \g_tmpb_coffin
34265 \cs_new_eq:NN \coffin_dp:N \box_dp:N
34266 \cs_new_eq:NN \coffin_dp:c \box_dp:c
34267 \cs_new_eq:NN \coffin_ht:N \box_ht:N
34268 \cs_new_eq:NN \coffin_ht:c \box_ht:c
34269 \cs_new_eq:NN \coffin_ht_plus_dp:N \box_ht_plus_dp:N
34270 \cs_new_eq:NN \coffin_ht_plus_dp:c \box_ht_plus_dp:c
34271 \cs_new_eq:NN \coffin_wd:N \box_wd:N
34272 \cs_new_eq:NN \coffin_wd:c \box_wd:c
34273 \cs_new:Npn \coffin_pole:Nn #1#2
34274 {
34275 \exp_args:Ne \__coffin_pole:nNn
34276 { \prop_item:cn { coffin ~ \__coffin_to_value:N #1 ~ poles } {#2} }
34277 #1 {#2}
34278 }
34279 \cs_new:Npn \__coffin_pole:nNn #1#2#3
34280 {
34281 \tl_if_blank:nTF {#1}
34282 {
34283 \msg_expandable_error:nnee { coffin } { unknown-pole }
34284 { \exp_not:n {#3} } { \token_to_str:N #2 }
34285 { 0pt } { 0pt } { 0pt } { 0pt }
34286 }
34287 {#1}
34288 }
34289 \cs_new_protected:Npn \__coffin_reset_structure:N #1
34290 {
34291 \prop_set_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ corners }
34292 \c__coffin_corners_prop
34293 \prop_set_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ poles }
34294 \c__coffin_poles_prop
34295 }
34296 \cs_new_protected:Npn \__coffin_greset_structure:N #1
34297 {
34298 \prop_gset_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ corners }
34299 \c__coffin_corners_prop
34300 \prop_gset_eq:cN { coffin ~ \__coffin_to_value:N #1 ~ poles }
34301 \c__coffin_poles_prop
34302 }
34303 \cs_new_protected:Npn \coffin_set_horizontal_pole:Nnn #1#2#3
34304 { \__coffin_set_horizontal_pole:NnnN #1 {#2} {#3} \prop_put:cne }
34305 \cs_generate_variant:Nn \coffin_set_horizontal_pole:Nnn { c }
34306 \cs_new_protected:Npn \coffin_gset_horizontal_pole:Nnn #1#2#3
34307 { \__coffin_set_horizontal_pole:NnnN #1 {#2} {#3} \prop_gput:cne }
34308 \cs_generate_variant:Nn \coffin_gset_horizontal_pole:Nnn { c }
34309 \cs_new_protected:Npn \__coffin_set_horizontal_pole:NnnN #1#2#3#4
34310 {
34311 \__coffin_if_exist:NT #1
34312 {
34313 #4 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34314 {#2}
34315 {
34316 { 0pt } { \dim_eval:n {#3} }
34317 { 1000pt } { 0pt }
34318 }
34319 }
34320 }
34321 \cs_new_protected:Npn \coffin_set_vertical_pole:Nnn #1#2#3
34322 { \__coffin_set_vertical_pole:NnnN #1 {#2} {#3} \prop_put:cne }
34323 \cs_generate_variant:Nn \coffin_set_vertical_pole:Nnn { c }
34324 \cs_new_protected:Npn \coffin_gset_vertical_pole:Nnn #1#2#3
34325 { \__coffin_set_vertical_pole:NnnN #1 {#2} {#3} \prop_gput:cne }
34326 \cs_generate_variant:Nn \coffin_gset_vertical_pole:Nnn { c }
34327 \cs_new_protected:Npn \__coffin_set_vertical_pole:NnnN #1#2#3#4
34328 {
34329 \__coffin_if_exist:NT #1
34330 {
34331 #4 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34332 {#2}
34333 {
34334 { \dim_eval:n {#3} } { 0pt }
34335 { 0pt } { 1000pt }
34336 }
34337 }
34338 }
34339 \cs_new_protected:Npn \__coffin_set_pole:Nnn #1#2#3
34340 {
34341 \prop_put:cne { coffin ~ \__coffin_to_value:N #1 ~ poles }
34342 {#2} {#3}
34343 }
34344 \cs_new_protected:Npn \__coffin_gset_pole:Nnn #1#2#3
34345 {
34346 \prop_gput:cne { coffin ~ \__coffin_to_value:N #1 ~ poles }
34347 {#2} {#3}
34348 }
34349 \cs_new_protected:Npn \coffin_reset_poles:N #1
34350 {
34351 \__coffin_reset_structure:N #1
34352 \__coffin_update_corners:N #1
34353 \__coffin_update_poles:N #1
34354 }
34355 \cs_new_protected:Npn \coffin_greset_poles:N #1
34356 {
34357 \__coffin_greset_structure:N #1
34358 \__coffin_gupdate_corners:N #1
34359 \__coffin_gupdate_poles:N #1
34360 }
34361 \cs_new_protected:Npn \__coffin_update_corners:N #1
34362 { \__coffin_update_corners:NN #1 \prop_put:Nne }
34363 \cs_new_protected:Npn \__coffin_gupdate_corners:N #1
34364 { \__coffin_update_corners:NN #1 \prop_gput:Nne }
34365 \cs_new_protected:Npn \__coffin_update_corners:NN #1#2
34366 {
34367 \exp_args:Nc \__coffin_update_corners:NNN
34368 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34369 #1 #2
34370 }
34371 \cs_new_protected:Npn \__coffin_update_corners:NNN #1#2#3
34372 {
34373 #3 #1
34374 { tl }
34375 { { 0pt } { \dim_eval:n { \box_ht:N #2 } } }
34376 #3 #1
34377 { tr }
34378 {
34379 { \dim_eval:n { \box_wd:N #2 } }
34380 { \dim_eval:n { \box_ht:N #2 } }
34381 }
34382 #3 #1
34383 { bl }
34384 { { 0pt } { \dim_eval:n { -\box_dp:N #2 } } }
34385 #3 #1
34386 { br }
34387 {
34388 { \dim_eval:n { \box_wd:N #2 } }
34389 { \dim_eval:n { -\box_dp:N #2 } }
34390 }
34391 }
34392 \cs_new_protected:Npn \__coffin_update_poles:N #1
34393 { \__coffin_update_poles:NN #1 \prop_put:Nne }
34394 \cs_new_protected:Npn \__coffin_gupdate_poles:N #1
34395 { \__coffin_update_poles:NN #1 \prop_gput:Nne }
34396 \cs_new_protected:Npn \__coffin_update_poles:NN #1#2
34397 {
34398 \exp_args:Nc \__coffin_update_poles:NNN
34399 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34400 #1 #2
34401 }
34402 \cs_new_protected:Npn \__coffin_update_poles:NNN #1#2#3
34403 {
34404 #3 #1 { hc }
34405 {
34406 { \dim_eval:n { 0.5 \box_wd:N #2 } }
34407 { 0pt } { 0pt } { 1000pt }
34408 }
34409 #3 #1 { r }
34410 {
34411 { \dim_eval:n { \box_wd:N #2 } }
34412 { 0pt } { 0pt } { 1000pt }
34413 }
34414 #3 #1 { vc }
34415 {
34416 { 0pt }
34417 { \dim_eval:n { ( \box_ht:N #2 - \box_dp:N #2 ) / 2 } }
34418 { 1000pt }
34419 { 0pt }
34420 }
34421 #3 #1 { t }
34422 {
34423 { 0pt }
34424 { \dim_eval:n { \box_ht:N #2 } }
34425 { 1000pt }
34426 { 0pt }
34427 }
34428 #3 #1 { b }
34429 {
34430 { 0pt }
34431 { \dim_eval:n { -\box_dp:N #2 } }
34432 { 1000pt }
34433 { 0pt }
34434 }
34435 }
34436 \cs_new_protected:Npn \__coffin_calculate_intersection:Nnn #1#2#3
34437 {
34438 \bool_set_false:N \l__coffin_error_bool
34439 \use:e
34440 {
34441 \__coffin_calculate_intersection:nnnnnnnn
34442 \coffin_pole:Nn #1 {#2}
34443 \coffin_pole:Nn #1 {#3}
34444 }
34445 \bool_if:NT \l__coffin_error_bool
34446 {
34447 \msg_error:nn { coffin } { no-pole-intersection }
34448 \dim_zero:N \l__coffin_x_dim
34449 \dim_zero:N \l__coffin_y_dim
34450 }
34451 }
34452 \cs_new_protected:Npn \__coffin_calculate_intersection:nnnnnnnn
34453 #1#2#3#4#5#6#7#8
34454 {
34455 \dim_compare:nNnTF {#3} = \c_zero_dim
34456 {
34457 \dim_set:Nn \l__coffin_x_dim {#1}
34458 \dim_compare:nNnTF {#7} = \c_zero_dim
34459 { \bool_set_true:N \l__coffin_error_bool }
34460 {
34461 \dim_set:Nn \l__coffin_y_dim
34462 {
34463 \dim_compare:nNnTF {#8} = \c_zero_dim
34464 {#6}
34465 {
34466 \fp_to_dim:n
34467 {
34468 ( \dim_to_fp:n {#8} / \dim_to_fp:n {#7} )
34469 * ( \dim_to_fp:n {#1} - \dim_to_fp:n {#5} )
34470 + \dim_to_fp:n {#6}
34471 }
34472 }
34473 }
34474 }
34475 }
34476 {
34477 \dim_compare:nNnTF {#4} = \c_zero_dim
34478 {
34479 \dim_set:Nn \l__coffin_y_dim {#2}
34480 \dim_compare:nNnTF {#8} = { \c_zero_dim }
34481 { \bool_set_true:N \l__coffin_error_bool }
34482 {
34483 \dim_set:Nn \l__coffin_x_dim
34484 {
34485 \dim_compare:nNnTF {#7} = \c_zero_dim
34486 {#5}
34487 {
34488 \fp_to_dim:n
34489 {
34490 ( \dim_to_fp:n {#7} / \dim_to_fp:n {#8} )
34491 * ( \dim_to_fp:n {#4} - \dim_to_fp:n {#6} )
34492 + \dim_to_fp:n {#5}
34493 }
34494 }
34495 }
34496 }
34497 }
34498 {
34499 \use:e
34500 {
34501 \__coffin_calculate_intersection:nnnnnn
34502 { \dim_to_fp:n {#4} / \dim_to_fp:n {#3} }
34503 { \dim_to_fp:n {#8} / \dim_to_fp:n {#7} }
34504 }
34505 {#1} {#2} {#5} {#6}
34506 }
34507 }
34508 }
34509 \cs_new_protected:Npn \__coffin_calculate_intersection:nnnnnn #1#2#3#4#5#6
34510 {
34511 \fp_compare:nNnTF {#1} = {#2}
34512 { \bool_set_true:N \l__coffin_error_bool }
34513 {
34514 \dim_set:Nn \l__coffin_x_dim
34515 {
34516 \fp_to_dim:n
34517 {
34518 (
34519 #1 * \dim_to_fp:n {#3}
34520 - #2 * \dim_to_fp:n {#5}
34521 - \dim_to_fp:n {#4}
34522 + \dim_to_fp:n {#6}
34523 )
34524 /
34525 ( #1 - #2 )
34526 }
34527 }
34528 \dim_set:Nn \l__coffin_y_dim
34529 {
34530 \fp_to_dim:n
34531 {
34532 #1 * ( \l__coffin_x_dim - \dim_to_fp:n {#3} )
34533 + \dim_to_fp:n {#4}
34534 }
34535 }
34536 }
34537 }
34538 \fp_new:N \l__coffin_sin_fp
34539 \fp_new:N \l__coffin_cos_fp
34540 \prop_new:N \l__coffin_bounding_prop
34541 \prop_new:N \l__coffin_corners_prop
34542 \prop_new:N \l__coffin_poles_prop
34543 \dim_new:N \l__coffin_bounding_shift_dim
34544 \dim_new:N \l__coffin_left_corner_dim
34545 \dim_new:N \l__coffin_right_corner_dim
34546 \dim_new:N \l__coffin_bottom_corner_dim
34547 \dim_new:N \l__coffin_top_corner_dim
34548 \cs_new_protected:Npn \coffin_rotate:Nn #1#2
34549 { \__coffin_rotate:NnNNN #1 {#2} \box_rotate:Nn \prop_set_eq:cN \hbox_set:Nn }
34550 \cs_generate_variant:Nn \coffin_rotate:Nn { c }
34551 \cs_new_protected:Npn \coffin_grotate:Nn #1#2
34552 { \__coffin_rotate:NnNNN #1 {#2} \box_grotate:Nn \prop_gset_eq:cN \hbox_gset:Nn }
34553 \cs_generate_variant:Nn \coffin_grotate:Nn { c }
34554 \cs_new_protected:Npn \__coffin_rotate:NnNNN #1#2#3#4#5
34555 {
34556 \fp_set:Nn \l__coffin_sin_fp { sind ( #2 ) }
34557 \fp_set:Nn \l__coffin_cos_fp { cosd ( #2 ) }
34558 \prop_set_eq:Nc \l__coffin_corners_prop
34559 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34560 \prop_set_eq:Nc \l__coffin_poles_prop
34561 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34562 \prop_map_inline:Nn \l__coffin_corners_prop
34563 { \__coffin_rotate_corner:Nnnn #1 {##1} ##2 }
34564 \prop_map_inline:Nn \l__coffin_poles_prop
34565 { \__coffin_rotate_pole:Nnnnnn #1 {##1} ##2 }
34566 \__coffin_set_bounding:N #1
34567 \prop_map_inline:Nn \l__coffin_bounding_prop
34568 { \__coffin_rotate_bounding:nnn {##1} ##2 }
34569 \__coffin_find_corner_maxima:N #1
34570 \__coffin_find_bounding_shift:
34571 #3 #1 {#2}
34572 \hbox_set:Nn \l__coffin_tmp_box
34573 {
34574 \dim_horizontal:n
34575 { \l__coffin_bounding_shift_dim - \l__coffin_left_corner_dim }
34576 \box_move_down:nn { \l__coffin_bottom_corner_dim }
34577 { \box_use:N #1 }
34578 }
34579 \box_set_ht:Nn \l__coffin_tmp_box
34580 { \l__coffin_top_corner_dim - \l__coffin_bottom_corner_dim }
34581 \box_set_dp:Nn \l__coffin_tmp_box { 0pt }
34582 \box_set_wd:Nn \l__coffin_tmp_box
34583 { \l__coffin_right_corner_dim - \l__coffin_left_corner_dim }
34584 #5 #1 { \box_use_drop:N \l__coffin_tmp_box }
34585 \prop_map_inline:Nn \l__coffin_corners_prop
34586 { \__coffin_shift_corner:Nnnn #1 {##1} ##2 }
34587 \prop_map_inline:Nn \l__coffin_poles_prop
34588 { \__coffin_shift_pole:Nnnnnn #1 {##1} ##2 }
34589 #4 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34590 \l__coffin_corners_prop
34591 #4 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34592 \l__coffin_poles_prop
34593 }
34594 \cs_new_protected:Npn \__coffin_set_bounding:N #1
34595 {
34596 \prop_put:Nne \l__coffin_bounding_prop { tl }
34597 { { 0pt } { \dim_eval:n { \box_ht:N #1 } } }
34598 \prop_put:Nne \l__coffin_bounding_prop { tr }
34599 {
34600 { \dim_eval:n { \box_wd:N #1 } }
34601 { \dim_eval:n { \box_ht:N #1 } }
34602 }
34603 \dim_set:Nn \l__coffin_tmp_dim { -\box_dp:N #1 }
34604 \prop_put:Nne \l__coffin_bounding_prop { bl }
34605 { { 0pt } { \dim_use:N \l__coffin_tmp_dim } }
34606 \prop_put:Nne \l__coffin_bounding_prop { br }
34607 {
34608 { \dim_eval:n { \box_wd:N #1 } }
34609 { \dim_use:N \l__coffin_tmp_dim }
34610 }
34611 }
34612 \cs_new_protected:Npn \__coffin_rotate_bounding:nnn #1#2#3
34613 {
34614 \__coffin_rotate_vector:nnNN {#2} {#3} \l__coffin_x_dim \l__coffin_y_dim
34615 \prop_put:Nne \l__coffin_bounding_prop {#1}
34616 { { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim } }
34617 }
34618 \cs_new_protected:Npn \__coffin_rotate_corner:Nnnn #1#2#3#4
34619 {
34620 \__coffin_rotate_vector:nnNN {#3} {#4} \l__coffin_x_dim \l__coffin_y_dim
34621 \prop_put:Nne \l__coffin_corners_prop {#2}
34622 { { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim } }
34623 }
34624 \cs_new_protected:Npn \__coffin_rotate_pole:Nnnnnn #1#2#3#4#5#6
34625 {
34626 \__coffin_rotate_vector:nnNN {#3} {#4} \l__coffin_x_dim \l__coffin_y_dim
34627 \__coffin_rotate_vector:nnNN {#5} {#6}
34628 \l__coffin_x_prime_dim \l__coffin_y_prime_dim
34629 \prop_put:Nne \l__coffin_poles_prop {#2}
34630 {
34631 { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim }
34632 { \dim_use:N \l__coffin_x_prime_dim }
34633 { \dim_use:N \l__coffin_y_prime_dim }
34634 }
34635 }
34636 \cs_new_protected:Npn \__coffin_rotate_vector:nnNN #1#2#3#4
34637 {
34638 \dim_set:Nn #3
34639 {
34640 \fp_to_dim:n
34641 {
34642 \dim_to_fp:n {#1} * \l__coffin_cos_fp
34643 - \dim_to_fp:n {#2} * \l__coffin_sin_fp
34644 }
34645 }
34646 \dim_set:Nn #4
34647 {
34648 \fp_to_dim:n
34649 {
34650 \dim_to_fp:n {#1} * \l__coffin_sin_fp
34651 + \dim_to_fp:n {#2} * \l__coffin_cos_fp
34652 }
34653 }
34654 }
34655 \cs_new_protected:Npn \__coffin_find_corner_maxima:N #1
34656 {
34657 \dim_set:Nn \l__coffin_top_corner_dim { -\c_max_dim }
34658 \dim_set:Nn \l__coffin_right_corner_dim { -\c_max_dim }
34659 \dim_set:Nn \l__coffin_bottom_corner_dim { \c_max_dim }
34660 \dim_set:Nn \l__coffin_left_corner_dim { \c_max_dim }
34661 \prop_map_inline:Nn \l__coffin_corners_prop
34662 { \__coffin_find_corner_maxima_aux:nn ##2 }
34663 }
34664 \cs_new_protected:Npn \__coffin_find_corner_maxima_aux:nn #1#2
34665 {
34666 \dim_set:Nn \l__coffin_left_corner_dim
34667 { \dim_min:nn { \l__coffin_left_corner_dim } {#1} }
34668 \dim_set:Nn \l__coffin_right_corner_dim
34669 { \dim_max:nn { \l__coffin_right_corner_dim } {#1} }
34670 \dim_set:Nn \l__coffin_bottom_corner_dim
34671 { \dim_min:nn { \l__coffin_bottom_corner_dim } {#2} }
34672 \dim_set:Nn \l__coffin_top_corner_dim
34673 { \dim_max:nn { \l__coffin_top_corner_dim } {#2} }
34674 }
34675 \cs_new_protected:Npn \__coffin_find_bounding_shift:
34676 {
34677 \dim_set:Nn \l__coffin_bounding_shift_dim { \c_max_dim }
34678 \prop_map_inline:Nn \l__coffin_bounding_prop
34679 { \__coffin_find_bounding_shift_aux:nn ##2 }
34680 }
34681 \cs_new_protected:Npn \__coffin_find_bounding_shift_aux:nn #1#2
34682 {
34683 \dim_set:Nn \l__coffin_bounding_shift_dim
34684 { \dim_min:nn { \l__coffin_bounding_shift_dim } {#1} }
34685 }
34686 \cs_new_protected:Npn \__coffin_shift_corner:Nnnn #1#2#3#4
34687 {
34688 \prop_put:Nne \l__coffin_corners_prop {#2}
34689 {
34690 { \dim_eval:n { #3 - \l__coffin_left_corner_dim } }
34691 { \dim_eval:n { #4 - \l__coffin_bottom_corner_dim } }
34692 }
34693 }
34694 \cs_new_protected:Npn \__coffin_shift_pole:Nnnnnn #1#2#3#4#5#6
34695 {
34696 \prop_put:Nne \l__coffin_poles_prop {#2}
34697 {
34698 { \dim_eval:n { #3 - \l__coffin_left_corner_dim } }
34699 { \dim_eval:n { #4 - \l__coffin_bottom_corner_dim } }
34700 {#5} {#6}
34701 }
34702 }
34703 \fp_new:N \l__coffin_scale_x_fp
34704 \fp_new:N \l__coffin_scale_y_fp
34705 \dim_new:N \l__coffin_scaled_total_height_dim
34706 \dim_new:N \l__coffin_scaled_width_dim
34707 \cs_new_protected:Npn \coffin_resize:Nnn #1#2#3
34708 {
34709 \__coffin_resize:NnnNN #1 {#2} {#3}
34710 \box_resize_to_wd_and_ht_plus_dp:Nnn
34711 \prop_set_eq:cN
34712 }
34713 \cs_generate_variant:Nn \coffin_resize:Nnn { c }
34714 \cs_new_protected:Npn \coffin_gresize:Nnn #1#2#3
34715 {
34716 \__coffin_resize:NnnNN #1 {#2} {#3}
34717 \box_gresize_to_wd_and_ht_plus_dp:Nnn
34718 \prop_gset_eq:cN
34719 }
34720 \cs_generate_variant:Nn \coffin_gresize:Nnn { c }
34721 \cs_new_protected:Npn \__coffin_resize:NnnNN #1#2#3#4#5
34722 {
34723 \fp_set:Nn \l__coffin_scale_x_fp
34724 { \dim_to_fp:n {#2} / \dim_to_fp:n { \coffin_wd:N #1 } }
34725 \fp_set:Nn \l__coffin_scale_y_fp
34726 {
34727 \dim_to_fp:n {#3}
34728 / \dim_to_fp:n { \coffin_ht:N #1 + \coffin_dp:N #1 }
34729 }
34730 #4 #1 {#2} {#3}
34731 \__coffin_resize_common:NnnN #1 {#2} {#3} #5
34732 }
34733 \cs_new_protected:Npn \__coffin_resize_common:NnnN #1#2#3#4
34734 {
34735 \prop_set_eq:Nc \l__coffin_corners_prop
34736 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34737 \prop_set_eq:Nc \l__coffin_poles_prop
34738 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34739 \prop_map_inline:Nn \l__coffin_corners_prop
34740 { \__coffin_scale_corner:Nnnn #1 {##1} ##2 }
34741 \prop_map_inline:Nn \l__coffin_poles_prop
34742 { \__coffin_scale_pole:Nnnnnn #1 {##1} ##2 }
34743 \fp_compare:nNnT \l__coffin_scale_x_fp < \c_zero_fp
34744 {
34745 \prop_map_inline:Nn \l__coffin_corners_prop
34746 { \__coffin_x_shift_corner:Nnnn #1 {##1} ##2 }
34747 \prop_map_inline:Nn \l__coffin_poles_prop
34748 { \__coffin_x_shift_pole:Nnnnnn #1 {##1} ##2 }
34749 }
34750 #4 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34751 \l__coffin_corners_prop
34752 #4 { coffin ~ \__coffin_to_value:N #1 ~ poles }
34753 \l__coffin_poles_prop
34754 }
34755 \cs_new_protected:Npn \coffin_scale:Nnn #1#2#3
34756 { \__coffin_scale:NnnNN #1 {#2} {#3} \box_scale:Nnn \prop_set_eq:cN }
34757 \cs_generate_variant:Nn \coffin_scale:Nnn { c }
34758 \cs_new_protected:Npn \coffin_gscale:Nnn #1#2#3
34759 { \__coffin_scale:NnnNN #1 {#2} {#3} \box_gscale:Nnn \prop_gset_eq:cN }
34760 \cs_generate_variant:Nn \coffin_gscale:Nnn { c }
34761 \cs_new_protected:Npn \__coffin_scale:NnnNN #1#2#3#4#5
34762 {
34763 \fp_set:Nn \l__coffin_scale_x_fp {#2}
34764 \fp_set:Nn \l__coffin_scale_y_fp {#3}
34765 #4 #1 { \l__coffin_scale_x_fp } { \l__coffin_scale_y_fp }
34766 \dim_set:Nn \l__coffin_tmp_dim
34767 { \coffin_ht:N #1 + \coffin_dp:N #1 }
34768 \dim_set:Nn \l__coffin_scaled_total_height_dim
34769 { \fp_abs:n { \l__coffin_scale_y_fp } \l__coffin_tmp_dim }
34770 \dim_set:Nn \l__coffin_scaled_width_dim
34771 { -\fp_abs:n { \l__coffin_scale_x_fp } \coffin_wd:N #1 }
34772 \__coffin_resize_common:NnnN #1
34773 { \l__coffin_scaled_width_dim } { \l__coffin_scaled_total_height_dim }
34774 #5
34775 }
34776 \cs_new_protected:Npn \__coffin_scale_vector:nnNN #1#2#3#4
34777 {
34778 \dim_set:Nn #3
34779 { \fp_to_dim:n { \dim_to_fp:n {#1} * \l__coffin_scale_x_fp } }
34780 \dim_set:Nn #4
34781 { \fp_to_dim:n { \dim_to_fp:n {#2} * \l__coffin_scale_y_fp } }
34782 }
34783 \cs_new_protected:Npn \__coffin_scale_corner:Nnnn #1#2#3#4
34784 {
34785 \__coffin_scale_vector:nnNN {#3} {#4} \l__coffin_x_dim \l__coffin_y_dim
34786 \prop_put:Nne \l__coffin_corners_prop {#2}
34787 { { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim } }
34788 }
34789 \cs_new_protected:Npn \__coffin_scale_pole:Nnnnnn #1#2#3#4#5#6
34790 {
34791 \__coffin_scale_vector:nnNN {#3} {#4} \l__coffin_x_dim \l__coffin_y_dim
34792 \prop_put:Nne \l__coffin_poles_prop {#2}
34793 {
34794 { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim }
34795 {#5} {#6}
34796 }
34797 }
34798 \cs_new_protected:Npn \__coffin_x_shift_corner:Nnnn #1#2#3#4
34799 {
34800 \prop_put:Nne \l__coffin_corners_prop {#2}
34801 {
34802 { \dim_eval:n { #3 + \box_wd:N #1 } } {#4}
34803 }
34804 }
34805 \cs_new_protected:Npn \__coffin_x_shift_pole:Nnnnnn #1#2#3#4#5#6
34806 {
34807 \prop_put:Nne \l__coffin_poles_prop {#2}
34808 {
34809 { \dim_eval:n { #3 + \box_wd:N #1 } } {#4}
34810 {#5} {#6}
34811 }
34812 }
34813 \cs_new_protected:Npn \coffin_join:NnnNnnnn #1#2#3#4#5#6#7#8
34814 {
34815 \__coffin_join:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
34816 \coffin_set_eq:NN
34817 }
34818 \cs_generate_variant:Nn \coffin_join:NnnNnnnn { c , Nnnc , cnnc }
34819 \cs_new_protected:Npn \coffin_gjoin:NnnNnnnn #1#2#3#4#5#6#7#8
34820 {
34821 \__coffin_join:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
34822 \coffin_gset_eq:NN
34823 }
34824 \cs_generate_variant:Nn \coffin_gjoin:NnnNnnnn { c , Nnnc , cnnc }
34825 \cs_new_protected:Npn \__coffin_join:NnnNnnnnN #1#2#3#4#5#6#7#8#9
34826 {
34827 \__coffin_align:NnnNnnnnN
34828 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l__coffin_aligned_coffin
34829 \hbox_set:Nn \l__coffin_aligned_coffin
34830 {
34831 \dim_compare:nNnT { \l__coffin_offset_x_dim } < \c_zero_dim
34832 { \dim_horizontal:n { -\l__coffin_offset_x_dim } }
34833 \hbox_unpack:N \l__coffin_aligned_coffin
34834 \dim_set:Nn \l__coffin_tmp_dim
34835 { \l__coffin_offset_x_dim - \box_wd:N #1 + \box_wd:N #4 }
34836 \dim_compare:nNnT \l__coffin_tmp_dim < \c_zero_dim
34837 { \dim_horizontal:n { -\l__coffin_tmp_dim } }
34838 }
34839 \__coffin_reset_structure:N \l__coffin_aligned_coffin
34840 \prop_clear:c
34841 {
34842 coffin ~ \__coffin_to_value:N \l__coffin_aligned_coffin
34843 \c_space_tl corners
34844 }
34845 \__coffin_update_poles:N \l__coffin_aligned_coffin
34846 \dim_compare:nNnTF \l__coffin_offset_x_dim < \c_zero_dim
34847 {
34848 \__coffin_offset_poles:Nnn #1 { -\l__coffin_offset_x_dim } { 0pt }
34849 \__coffin_offset_poles:Nnn #4 { 0pt } { \l__coffin_offset_y_dim }
34850 \__coffin_offset_corners:Nnn #1 { -\l__coffin_offset_x_dim } { 0pt }
34851 \__coffin_offset_corners:Nnn #4 { 0pt } { \l__coffin_offset_y_dim }
34852 }
34853 {
34854 \__coffin_offset_poles:Nnn #1 { 0pt } { 0pt }
34855 \__coffin_offset_poles:Nnn #4
34856 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim }
34857 \__coffin_offset_corners:Nnn #1 { 0pt } { 0pt }
34858 \__coffin_offset_corners:Nnn #4
34859 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim }
34860 }
34861 \__coffin_update_TB_poles:NNnN #1 #4 { \l__coffin_offset_y_dim } \l__coffin_aligned_coffin
34862 #9 #1 \l__coffin_aligned_coffin
34863 }
34864 \cs_new_protected:Npn \coffin_attach:NnnNnnnn #1#2#3#4#5#6#7#8
34865 {
34866 \__coffin_attach:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
34867 \coffin_set_eq:NN
34868 }
34869 \cs_generate_variant:Nn \coffin_attach:NnnNnnnn { c , Nnnc , cnnc }
34870 \cs_new_protected:Npn \coffin_gattach:NnnNnnnn #1#2#3#4#5#6#7#8
34871 {
34872 \__coffin_attach:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
34873 \coffin_gset_eq:NN
34874 }
34875 \cs_generate_variant:Nn \coffin_gattach:NnnNnnnn { c , Nnnc , cnnc }
34876 \cs_new_protected:Npn \__coffin_attach:NnnNnnnnN #1#2#3#4#5#6#7#8#9
34877 {
34878 \__coffin_align:NnnNnnnnN
34879 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l__coffin_aligned_coffin
34880 \box_set_ht:Nn \l__coffin_aligned_coffin { \box_ht:N #1 }
34881 \box_set_dp:Nn \l__coffin_aligned_coffin { \box_dp:N #1 }
34882 \box_set_wd:Nn \l__coffin_aligned_coffin { \box_wd:N #1 }
34883 \__coffin_reset_structure:N \l__coffin_aligned_coffin
34884 \prop_set_eq:cc
34885 {
34886 coffin ~ \__coffin_to_value:N \l__coffin_aligned_coffin
34887 \c_space_tl corners
34888 }
34889 { coffin ~ \__coffin_to_value:N #1 ~ corners }
34890 \__coffin_update_poles:N \l__coffin_aligned_coffin
34891 \__coffin_offset_poles:Nnn #1 { 0pt } { 0pt }
34892 \__coffin_offset_poles:Nnn #4
34893 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim }
34894 \__coffin_update_TB_poles:NNnN #1 #4 { \l__coffin_offset_y_dim } \l__coffin_aligned_coffin
34895 #9 #1 \l__coffin_aligned_coffin
34896 }
34897 \cs_new_protected:Npn \__coffin_attach_mark:NnnNnnnn #1#2#3#4#5#6#7#8
34898 {
34899 \__coffin_align:NnnNnnnnN
34900 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l__coffin_aligned_coffin
34901 \box_set_ht:Nn \l__coffin_aligned_coffin { \box_ht:N #1 }
34902 \box_set_dp:Nn \l__coffin_aligned_coffin { \box_dp:N #1 }
34903 \box_set_wd:Nn \l__coffin_aligned_coffin { \box_wd:N #1 }
34904 \box_set_eq:NN #1 \l__coffin_aligned_coffin
34905 }
34906 \cs_new_protected:Npn \__coffin_align:NnnNnnnnN #1#2#3#4#5#6#7#8#9
34907 {
34908 \__coffin_calculate_intersection:Nnn #4 {#5} {#6}
34909 \dim_set:Nn \l__coffin_x_prime_dim { \l__coffin_x_dim }
34910 \dim_set:Nn \l__coffin_y_prime_dim { \l__coffin_y_dim }
34911 \__coffin_calculate_intersection:Nnn #1 {#2} {#3}
34912 \dim_set:Nn \l__coffin_offset_x_dim
34913 { \l__coffin_x_dim - \l__coffin_x_prime_dim + #7 }
34914 \dim_set:Nn \l__coffin_offset_y_dim
34915 { \l__coffin_y_dim - \l__coffin_y_prime_dim + #8 }
34916 \hbox_set:Nn \l__coffin_aligned_internal_coffin
34917 {
34918 \box_use:N #1
34919 \dim_horizontal:n { -\box_wd:N #1 }
34920 \dim_horizontal:n { \l__coffin_offset_x_dim }
34921 \box_move_up:nn { \l__coffin_offset_y_dim } { \box_use:N #4 }
34922 }
34923 \coffin_set_eq:NN #9 \l__coffin_aligned_internal_coffin
34924 }
34925 \cs_new_protected:Npn \__coffin_offset_poles:Nnn #1#2#3
34926 {
34927 \prop_map_inline:cn { coffin ~ \__coffin_to_value:N #1 ~ poles }
34928 { \__coffin_offset_pole:Nnnnnnn #1 {##1} ##2 {#2} {#3} }
34929 }
34930 \cs_new_protected:Npn \__coffin_offset_pole:Nnnnnnn #1#2#3#4#5#6#7#8
34931 {
34932 \dim_set:Nn \l__coffin_x_dim { #3 + #7 }
34933 \dim_set:Nn \l__coffin_y_dim { #4 + #8 }
34934 \tl_if_in:nnTF {#2} { - }
34935 { \tl_set:Nn \l__coffin_tmp_tl { {#2} } }
34936 { \tl_set:Nn \l__coffin_tmp_tl { { #1 - #2 } } }
34937 \exp_last_unbraced:NNo \__coffin_set_pole:Nnn \l__coffin_aligned_coffin
34938 { \l__coffin_tmp_tl }
34939 {
34940 { \dim_use:N \l__coffin_x_dim } { \dim_use:N \l__coffin_y_dim }
34941 {#5} {#6}
34942 }
34943 }
34944 \cs_new_protected:Npn \__coffin_offset_corners:Nnn #1#2#3
34945 {
34946 \prop_map_inline:cn { coffin ~ \__coffin_to_value:N #1 ~ corners }
34947 { \__coffin_offset_corner:Nnnnn #1 {##1} ##2 {#2} {#3} }
34948 }
34949 \cs_new_protected:Npn \__coffin_offset_corner:Nnnnn #1#2#3#4#5#6
34950 {
34951 \prop_put:cne
34952 {
34953 coffin ~ \__coffin_to_value:N \l__coffin_aligned_coffin
34954 \c_space_tl corners
34955 }
34956 { #1 - #2 }
34957 {
34958 { \dim_eval:n { #3 + #5 } }
34959 { \dim_eval:n { #4 + #6 } }
34960 }
34961 }
34962 \cs_new_protected:Npn \__coffin_update_TB_poles:NNnN #1#2#3#4
34963 {
34964 \__coffin_update_TB_aux:NNnNnN #1 #2 {#3} #4 { T } \dim_max:nn
34965 \__coffin_update_TB_aux:NNnNnN #1 #2 {#3} #4 { B } \dim_min:nn
34966 }
34967 \cs_new_protected:Npn \__coffin_update_TB_aux:NNnNnN #1#2#3#4#5#6
34968 {
34969 \__coffin_extract_pole_y:NnN #1 {#5} \l__coffin_y_dim
34970 \__coffin_extract_pole_y:NnN #2 {#5} \l__coffin_y_prime_dim
34971 \dim_set:Nn \l__coffin_y_dim
34972 { #6 { \l__coffin_y_dim } { \l__coffin_y_prime_dim + #3 } }
34973 \__coffin_set_pole:Nnn #4 {#5}
34974 {
34975 { 0pt }
34976 { \dim_use:N \l__coffin_y_dim }
34977 { 1000pt }
34978 { 0pt }
34979 }
34980 }
34981 \cs_new_protected:Npn \__coffin_extract_pole_y:NnN #1#2#3
34982 {
34983 \use:e
34984 {
34985 \__coffin_extract_pole_y_aux:nnnnN
34986 \coffin_pole:Nn #1 {#2}
34987 \exp_not:N #3
34988 }
34989 }
34990 \cs_new_protected:Npn \__coffin_extract_pole_y_aux:nnnnN #1#2#3#4#5 { \dim_set:Nn #5 {#2} }
34991 \coffin_new:N \c__coffin_empty_coffin
34992 \tex_setbox:D \c__coffin_empty_coffin = \tex_hbox:D { }
34993 \cs_new_protected:Npn \coffin_typeset:Nnnnn #1#2#3#4#5
34994 {
34995 \mode_leave_vertical:
34996 \__coffin_align:NnnNnnnnN \c__coffin_empty_coffin { H } { l }
34997 #1 {#2} {#3} {#4} {#5} \l__coffin_aligned_coffin
34998 \box_use_drop:N \l__coffin_aligned_coffin
34999 }
35000 \cs_generate_variant:Nn \coffin_typeset:Nnnnn { c }
35001 \coffin_new:N \l__coffin_display_coffin
35002 \coffin_new:N \l__coffin_display_coord_coffin
35003 \coffin_new:N \l__coffin_display_pole_coffin
35004 \prop_new:N \l__coffin_display_handles_prop
35005 \prop_put:Nnn \l__coffin_display_handles_prop { tl }
35006 { { b } { r } { -1 } { 1 } }
35007 \prop_put:Nnn \l__coffin_display_handles_prop { thc }
35008 { { b } { hc } { 0 } { 1 } }
35009 \prop_put:Nnn \l__coffin_display_handles_prop { tr }
35010 { { b } { l } { 1 } { 1 } }
35011 \prop_put:Nnn \l__coffin_display_handles_prop { vcl }
35012 { { vc } { r } { -1 } { 0 } }
35013 \prop_put:Nnn \l__coffin_display_handles_prop { vchc }
35014 { { vc } { hc } { 0 } { 0 } }
35015 \prop_put:Nnn \l__coffin_display_handles_prop { vcr }
35016 { { vc } { l } { 1 } { 0 } }
35017 \prop_put:Nnn \l__coffin_display_handles_prop { bl }
35018 { { t } { r } { -1 } { -1 } }
35019 \prop_put:Nnn \l__coffin_display_handles_prop { bhc }
35020 { { t } { hc } { 0 } { -1 } }
35021 \prop_put:Nnn \l__coffin_display_handles_prop { br }
35022 { { t } { l } { 1 } { -1 } }
35023 \prop_put:Nnn \l__coffin_display_handles_prop { Tl }
35024 { { t } { r } { -1 } { -1 } }
35025 \prop_put:Nnn \l__coffin_display_handles_prop { Thc }
35026 { { t } { hc } { 0 } { -1 } }
35027 \prop_put:Nnn \l__coffin_display_handles_prop { Tr }
35028 { { t } { l } { 1 } { -1 } }
35029 \prop_put:Nnn \l__coffin_display_handles_prop { Hl }
35030 { { vc } { r } { -1 } { 1 } }
35031 \prop_put:Nnn \l__coffin_display_handles_prop { Hhc }
35032 { { vc } { hc } { 0 } { 1 } }
35033 \prop_put:Nnn \l__coffin_display_handles_prop { Hr }
35034 { { vc } { l } { 1 } { 1 } }
35035 \prop_put:Nnn \l__coffin_display_handles_prop { Bl }
35036 { { b } { r } { -1 } { -1 } }
35037 \prop_put:Nnn \l__coffin_display_handles_prop { Bhc }
35038 { { b } { hc } { 0 } { -1 } }
35039 \prop_put:Nnn \l__coffin_display_handles_prop { Br }
35040 { { b } { l } { 1 } { -1 } }
35041 \dim_new:N \l__coffin_display_offset_dim
35042 \dim_set:Nn \l__coffin_display_offset_dim { 2pt }
35043 \dim_new:N \l__coffin_display_x_dim
35044 \dim_new:N \l__coffin_display_y_dim
35045 \prop_new:N \l__coffin_display_poles_prop
35046 \tl_new:N \l__coffin_display_font_tl
35047 \bool_lazy_and:nnT
35048 { \cs_if_exist_p:N \fmtname }
35049 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
35050 {
35051 \tl_set:Nn \l__coffin_display_font_tl
35052 { \sffamily \tiny }
35053 }
35054 \cs_new_protected:Npn \__coffin_rule:nn #1#2
35055 {
35056 \mode_leave_vertical:
35057 \hbox:n { \tex_vrule:D width #1 height #2 \scan_stop: }
35058 }
35059 \cs_new_protected:Npn \coffin_mark_handle:Nnnn #1#2#3#4
35060 {
35061 \hcoffin_set:Nn \l__coffin_display_pole_coffin
35062 {
35063 \color_select:n {#4}
35064 \__coffin_rule:nn { 1pt } { 1pt }
35065 }
35066 \__coffin_attach_mark:NnnNnnnn #1 {#2} {#3}
35067 \l__coffin_display_pole_coffin { hc } { vc } { 0pt } { 0pt }
35068 \hcoffin_set:Nn \l__coffin_display_coord_coffin
35069 {
35070 \color_select:n {#4}
35071 \l__coffin_display_font_tl
35072 ( \tl_to_str:n { #2 , #3 } )
35073 }
35074 \prop_get:NnN \l__coffin_display_handles_prop
35075 { #2 #3 } \l__coffin_tmp_tl
35076 \quark_if_no_value:NTF \l__coffin_tmp_tl
35077 {
35078 \prop_get:NnN \l__coffin_display_handles_prop
35079 { #3 #2 } \l__coffin_tmp_tl
35080 \quark_if_no_value:NTF \l__coffin_tmp_tl
35081 {
35082 \__coffin_attach_mark:NnnNnnnn #1 {#2} {#3}
35083 \l__coffin_display_coord_coffin { l } { vc }
35084 { 1pt } { 0pt }
35085 }
35086 {
35087 \exp_last_unbraced:No \__coffin_mark_handle_aux:nnnnNnn
35088 \l__coffin_tmp_tl #1 {#2} {#3}
35089 }
35090 }
35091 {
35092 \exp_last_unbraced:No \__coffin_mark_handle_aux:nnnnNnn
35093 \l__coffin_tmp_tl #1 {#2} {#3}
35094 }
35095 }
35096 \cs_new_protected:Npn \__coffin_mark_handle_aux:nnnnNnn #1#2#3#4#5#6#7
35097 {
35098 \__coffin_attach_mark:NnnNnnnn #5 {#6} {#7}
35099 \l__coffin_display_coord_coffin {#1} {#2}
35100 { #3 \l__coffin_display_offset_dim }
35101 { #4 \l__coffin_display_offset_dim }
35102 }
35103 \cs_generate_variant:Nn \coffin_mark_handle:Nnnn { c }
35104 \cs_new_protected:Npn \coffin_display_handles:Nn #1#2
35105 {
35106 \hcoffin_set:Nn \l__coffin_display_pole_coffin
35107 {
35108 \color_select:n {#2}
35109 \__coffin_rule:nn { 1pt } { 1pt }
35110 }
35111 \prop_set_eq:Nc \l__coffin_display_poles_prop
35112 { coffin ~ \__coffin_to_value:N #1 ~ poles }
35113 \str_if_eq:eeT
35114 { \coffin_pole:Nn #1 { H } }
35115 { \coffin_pole:Nn #1 { T } }
35116 { \prop_remove:Nn \l__coffin_display_poles_prop { T } }
35117 \str_if_eq:eeT
35118 { \coffin_pole:Nn #1 { H } }
35119 { \coffin_pole:Nn #1 { B } }
35120 { \prop_remove:Nn \l__coffin_display_poles_prop { B } }
35121 \coffin_set_eq:NN \l__coffin_display_coffin #1
35122 \prop_map_inline:Nn \l__coffin_display_poles_prop
35123 {
35124 \prop_remove:Nn \l__coffin_display_poles_prop {##1}
35125 \__coffin_display_handles_aux:nnnnnn {##1} ##2 {#2}
35126 }
35127 \box_use_drop:N \l__coffin_display_coffin
35128 }
35129 \cs_new_protected:Npn \__coffin_display_handles_aux:nnnnnn #1#2#3#4#5#6
35130 {
35131 \prop_map_inline:Nn \l__coffin_display_poles_prop
35132 {
35133 \bool_set_false:N \l__coffin_error_bool
35134 \__coffin_calculate_intersection:nnnnnnnn {#2} {#3} {#4} {#5} ##2
35135 \bool_if:NF \l__coffin_error_bool
35136 {
35137 \dim_set:Nn \l__coffin_display_x_dim { \l__coffin_x_dim }
35138 \dim_set:Nn \l__coffin_display_y_dim { \l__coffin_y_dim }
35139 \__coffin_display_attach:Nnnnn
35140 \l__coffin_display_pole_coffin { hc } { vc }
35141 { 0pt } { 0pt }
35142 \hcoffin_set:Nn \l__coffin_display_coord_coffin
35143 {
35144 \color_select:n {#6}
35145 \l__coffin_display_font_tl
35146 ( \tl_to_str:n { #1 , ##1 } )
35147 }
35148 \prop_get:NnN \l__coffin_display_handles_prop
35149 { #1 ##1 } \l__coffin_tmp_tl
35150 \quark_if_no_value:NTF \l__coffin_tmp_tl
35151 {
35152 \prop_get:NnN \l__coffin_display_handles_prop
35153 { ##1 #1 } \l__coffin_tmp_tl
35154 \quark_if_no_value:NTF \l__coffin_tmp_tl
35155 {
35156 \__coffin_display_attach:Nnnnn
35157 \l__coffin_display_coord_coffin { l } { vc }
35158 { 1pt } { 0pt }
35159 }
35160 {
35161 \exp_last_unbraced:No
35162 \__coffin_display_handles_aux:nnnn
35163 \l__coffin_tmp_tl
35164 }
35165 }
35166 {
35167 \exp_last_unbraced:No \__coffin_display_handles_aux:nnnn
35168 \l__coffin_tmp_tl
35169 }
35170 }
35171 }
35172 }
35173 \cs_new_protected:Npn \__coffin_display_handles_aux:nnnn #1#2#3#4
35174 {
35175 \__coffin_display_attach:Nnnnn
35176 \l__coffin_display_coord_coffin {#1} {#2}
35177 { #3 \l__coffin_display_offset_dim }
35178 { #4 \l__coffin_display_offset_dim }
35179 }
35180 \cs_generate_variant:Nn \coffin_display_handles:Nn { c }
35181 \cs_new_protected:Npn \__coffin_display_attach:Nnnnn #1#2#3#4#5
35182 {
35183 \__coffin_calculate_intersection:Nnn #1 {#2} {#3}
35184 \dim_set:Nn \l__coffin_x_prime_dim { \l__coffin_x_dim }
35185 \dim_set:Nn \l__coffin_y_prime_dim { \l__coffin_y_dim }
35186 \dim_set:Nn \l__coffin_offset_x_dim
35187 { \l__coffin_display_x_dim - \l__coffin_x_prime_dim + #4 }
35188 \dim_set:Nn \l__coffin_offset_y_dim
35189 { \l__coffin_display_y_dim - \l__coffin_y_prime_dim + #5 }
35190 \hbox_set:Nn \l__coffin_aligned_coffin
35191 {
35192 \box_use:N \l__coffin_display_coffin
35193 \dim_horizontal:n { -\box_wd:N \l__coffin_display_coffin }
35194 \dim_horizontal:n { \l__coffin_offset_x_dim }
35195 \box_move_up:nn { \l__coffin_offset_y_dim } { \box_use:N #1 }
35196 }
35197 \box_set_ht:Nn \l__coffin_aligned_coffin
35198 { \box_ht:N \l__coffin_display_coffin }
35199 \box_set_dp:Nn \l__coffin_aligned_coffin
35200 { \box_dp:N \l__coffin_display_coffin }
35201 \box_set_wd:Nn \l__coffin_aligned_coffin
35202 { \box_wd:N \l__coffin_display_coffin }
35203 \box_set_eq:NN \l__coffin_display_coffin \l__coffin_aligned_coffin
35204 }
35205 \cs_new_protected:Npn \coffin_show_structure:N
35206 { \__coffin_show_structure:NN \msg_show:nneeee }
35207 \cs_generate_variant:Nn \coffin_show_structure:N { c }
35208 \cs_new_protected:Npn \coffin_log_structure:N
35209 { \__coffin_show_structure:NN \msg_log:nneeee }
35210 \cs_generate_variant:Nn \coffin_log_structure:N { c }
35211 \cs_new_protected:Npn \__coffin_show_structure:NN #1#2
35212 {
35213 \__coffin_if_exist:NT #2
35214 {
35215 #1 { coffin } { show }
35216 { \token_to_str:N #2 }
35217 {
35218 \iow_newline: >~ ht ~=~ \dim_eval:n { \coffin_ht:N #2 }
35219 \iow_newline: >~ dp ~=~ \dim_eval:n { \coffin_dp:N #2 }
35220 \iow_newline: >~ wd ~=~ \dim_eval:n { \coffin_wd:N #2 }
35221 }
35222 {
35223 \prop_map_function:cN
35224 { coffin ~ \__coffin_to_value:N #2 ~ poles }
35225 \msg_show_item_unbraced:nn
35226 }
35227 { }
35228 }
35229 }
35230 \cs_new_protected:Npn \coffin_show:N #1
35231 { \coffin_show:Nnn #1 \c_max_int \c_max_int }
35232 \cs_generate_variant:Nn \coffin_show:N { c }
35233 \cs_new_protected:Npn \coffin_log:N #1
35234 { \coffin_log:Nnn #1 \c_max_int \c_max_int }
35235 \cs_generate_variant:Nn \coffin_log:N { c }
35236 \cs_new_protected:Npn \coffin_show:Nnn
35237 { \__coffin_show:NNNnn \msg_term:nneeee \box_show:Nnn }
35238 \cs_generate_variant:Nn \coffin_show:Nnn { c }
35239 \cs_new_protected:Npn \coffin_log:Nnn
35240 { \__coffin_show:NNNnn \msg_log:nneeee \box_show:Nnn }
35241 \cs_generate_variant:Nn \coffin_log:Nnn { c }
35242 \cs_new_protected:Npn \__coffin_show:NNNnn #1#2#3#4#5
35243 {
35244 \__coffin_if_exist:NT #3
35245 {
35246 \__coffin_show_structure:NN #1 #3
35247 #2 #3 {#4} {#5}
35248 }
35249 }
35250 \msg_new:nnnn { coffin } { no-pole-intersection }
35251 { No~intersection~between~coffin~poles. }
35252 {
35253 LaTeX~was~asked~to~find~the~intersection~between~two~poles,~
35254 but~they~do~not~have~a~unique~meeting~point:~
35255 the~value~(0pt,~0pt)~will~be~used.
35256 }
35257 \msg_new:nnnn { coffin } { unknown }
35258 { Unknown~coffin~'#1'. }
35259 { The~coffin~'#1'~was~never~defined. }
35260 \msg_new:nnn { coffin } { unknown-pole }
35261 { Pole~'#1'~unknown~for~coffin~'#2'. }
35262 \msg_new:nnn { coffin } { show }
35263 {
35264 Size~of~coffin~#1 : #2 \\
35265 Poles~of~coffin~#1 : #3 .
35266 }
35267 %% File: l3luatex.dtx
35268 \cs_new_eq:NN \__lua_escape:n \tex_luaescapestring:D
35269 \cs_new_eq:NN \__lua_now:n \tex_directlua:D
35270 \cs_new_eq:NN \__lua_shipout:n \tex_latelua:D
35271 \cs_undefine:N \lua_escape:e
35272 \cs_undefine:N \lua_now:e
35273 \cs_new:Npn \lua_now:e #1 { \__lua_now:n {#1} }
35274 \cs_new:Npn \lua_now:n #1 { \lua_now:e { \exp_not:n {#1} } }
35275 \cs_new_protected:Npn \lua_shipout_e:n #1 { \__lua_shipout:n {#1} }
35276 \cs_new_protected:Npn \lua_shipout:n #1
35277 { \lua_shipout_e:n { \exp_not:n {#1} } }
35278 \cs_new:Npn \lua_escape:e #1 { \__lua_escape:n {#1} }
35279 \cs_new:Npn \lua_escape:n #1 { \lua_escape:e { \exp_not:n {#1} } }
35280 \str_new:N \l__lua_err_msg_str
35281 \cs_new_protected:Npn \lua_load_module:n #1
35282 {
35283 \bool_if:nF { \__lua_load_module_p:n { #1 } }
35284 {
35285 \msg_error:nnnV
35286 { luatex } { module-not-found } { #1 } \l__lua_err_msg_str
35287 }
35288 }
35289 \sys_if_engine_luatex:F
35290 {
35291 \clist_map_inline:nn
35292 {
35293 \lua_escape:n , \lua_escape:e ,
35294 \lua_now:n , \lua_now:e
35295 }
35296 {
35297 \cs_gset:Npn #1 ##1
35298 {
35299 \msg_expandable_error:nnn
35300 { luatex } { luatex-required } { #1 }
35301 }
35302 }
35303 \clist_map_inline:nn
35304 { \lua_shipout_e:n , \lua_shipout:n, \lua_load_module:n }
35305 {
35306 \cs_gset_protected:Npn #1 ##1
35307 {
35308 \msg_error:nnn
35309 { luatex } { luatex-required } { #1 }
35310 }
35311 }
35312 }
35313 \msg_new:nnnn { luatex } { luatex-required }
35314 { LuaTeX~engine~not~in~use!~Ignoring~#1. }
35315 {
35316 The~feature~you~are~using~is~only~available~
35317 with~the~LuaTeX~engine.~LaTeX3~ignored~'#1'.
35318 }
35319 \msg_new:nnnn { luatex } { module-not-found }
35320 { Lua~module~`#1'~not~found. }
35321 {
35322 The~file~`#1.lua'~could~not~be~found.~Please~ensure~
35323 that~the~file~was~properly~installed~and~that~the~
35324 filename~database~is~current. \\ \\
35325 The~Lua~loader~provided~this~additional~information: \\
35326 #2
35327 }
35328 \prop_gput:Nnn \g_msg_module_name_prop { luatex } { LaTeX }
35329 \prop_gput:Nnn \g_msg_module_type_prop { luatex } { }
35330 %% File: l3unicode.dtx
35331 \sys_if_engine_opentype:TF
35332 {
35333 \cs_new:Npn \codepoint_str_generate:n #1
35334 {
35335 \int_compare:nNnTF {#1} = { `\ }
35336 { ~ }
35337 { \char_generate:nn {#1} { 12 } }
35338 }
35339 \cs_new:Npn \codepoint_generate:nn #1#2
35340 {
35341 \int_compare:nNnTF {#1} = { `\ }
35342 { ~ }
35343 {
35344 \__kernel_exp_not:w \exp_after:wN \exp_after:wN \exp_after:wN
35345 { \char_generate:nn {#1} {#2} }
35346 }
35347 }
35348 }
35349 {
35350 \cs_new:Npn \codepoint_str_generate:n #1
35351 {
35352 \int_compare:nNnTF {#1} = { `\ }
35353 { ~ }
35354 {
35355 \use:e
35356 {
35357 \exp_not:N \__codepoint_str_generate:nnnn
35358 \__kernel_codepoint_to_bytes:n {#1}
35359 }
35360 }
35361 }
35362 \cs_new:Npn \__codepoint_str_generate:nnnn #1#2#3#4
35363 {
35364 \char_generate:nn {#1} { 12 }
35365 \tl_if_blank:nF {#2}
35366 {
35367 \char_generate:nn {#2} { 12 }
35368 \tl_if_blank:nF {#3}
35369 {
35370 \char_generate:nn {#3} { 12 }
35371 \tl_if_blank:nF {#4}
35372 { \char_generate:nn {#4} { 12 } }
35373 }
35374 }
35375 }
35376 \cs_new:Npn \codepoint_generate:nn #1#2
35377 {
35378 \int_compare:nNnTF {#1} = { `\ }
35379 { ~ }
35380 {
35381 \int_compare:nNnTF {#1} < { "80 }
35382 {
35383 \__kernel_exp_not:w \exp_after:wN \exp_after:wN \exp_after:wN
35384 { \char_generate:nn {#1} {#2} }
35385 }
35386 {
35387 \use:e
35388 {
35389 \exp_not:N \__codepoint_generate:nnnn
35390 \__kernel_codepoint_to_bytes:n {#1}
35391 }
35392 }
35393 }
35394 }
35395 \cs_new:Npn \__codepoint_generate:nnnn #1#2#3#4
35396 {
35397 \__kernel_exp_not:w \exp_after:wN
35398 {
35399 \tex_expanded:D
35400 {
35401 \__codepoint_generate:n {#1}
35402 \__codepoint_generate:n {#2}
35403 \tl_if_blank:nF {#3}
35404 {
35405 \__codepoint_generate:n {#3}
35406 \tl_if_blank:nF {#4}
35407 { \__codepoint_generate:n {#4} }
35408 }
35409 }
35410 }
35411 }
35412 \cs_new:Npn \__codepoint_generate:n #1
35413 {
35414 \__kernel_exp_not:w \exp_after:wN \exp_after:wN \exp_after:wN
35415 { \char_generate:nn {#1} { 13 } }
35416 }
35417 }
35418 \cs_new:Npn \__kernel_codepoint_to_bytes:n #1
35419 {
35420 \exp_args:Nf \__codepoint_to_bytes_auxi:n
35421 { \int_eval:n {#1} }
35422 }
35423 \cs_new:Npn \__codepoint_to_bytes_auxi:n #1
35424 {
35425 \if_int_compare:w #1 > "80 \exp_stop_f:
35426 \if_int_compare:w #1 < "800 \exp_stop_f:
35427 \__codepoint_to_bytes_outputi:nw
35428 { \__codepoint_to_bytes_auxii:Nnn C {#1} { 64 } }
35429 \__codepoint_to_bytes_outputii:nw
35430 { \__codepoint_to_bytes_auxiii:n {#1} }
35431 \else:
35432 \if_int_compare:w #1 < "10000 \exp_stop_f:
35433 \__codepoint_to_bytes_outputi:nw
35434 { \__codepoint_to_bytes_auxii:Nnn E {#1} { 64 * 64 } }
35435 \__codepoint_to_bytes_outputii:nw
35436 {
35437 \__codepoint_to_bytes_auxiii:n
35438 { \int_div_truncate:nn {#1} { 64 } }
35439 }
35440 \__codepoint_to_bytes_outputiii:nw
35441 { \__codepoint_to_bytes_auxiii:n {#1} }
35442 \else:
35443 \__codepoint_to_bytes_outputi:nw
35444 {
35445 \__codepoint_to_bytes_auxii:Nnn F
35446 {#1} { 64 * 64 * 64 }
35447 }
35448 \__codepoint_to_bytes_outputii:nw
35449 {
35450 \__codepoint_to_bytes_auxiii:n
35451 { \int_div_truncate:nn {#1} { 64 * 64 } }
35452 }
35453 \__codepoint_to_bytes_outputiii:nw
35454 {
35455 \__codepoint_to_bytes_auxiii:n
35456 { \int_div_truncate:nn {#1} { 64 } }
35457 }
35458 \__codepoint_to_bytes_outputiv:nw
35459 { \__codepoint_to_bytes_auxiii:n {#1} }
35460 \fi:
35461 \fi:
35462 \else:
35463 \__codepoint_to_bytes_outputi:nw {#1}
35464 \fi:
35465 \__codepoint_to_bytes_end: { } { } { } { }
35466 }
35467 \cs_new:Npn \__codepoint_to_bytes_auxii:Nnn #1#2#3
35468 { "#10 + \int_div_truncate:nn {#2} {#3} }
35469 \cs_new:Npn \__codepoint_to_bytes_auxiii:n #1
35470 { \int_mod:nn {#1} { 64 } + 128 }
35471 \cs_new:Npn \__codepoint_to_bytes_outputi:nw
35472 #1 #2 \__codepoint_to_bytes_end: #3
35473 { \__codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { } {#2} }
35474 \cs_new:Npn \__codepoint_to_bytes_outputii:nw
35475 #1 #2 \__codepoint_to_bytes_end: #3#4
35476 { \__codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { {#3} } {#2} }
35477 \cs_new:Npn \__codepoint_to_bytes_outputiii:nw
35478 #1 #2 \__codepoint_to_bytes_end: #3#4#5
35479 {
35480 \__codepoint_to_bytes_output:fnn
35481 { \int_eval:n {#1} } { {#3} {#4} } {#2}
35482 }
35483 \cs_new:Npn \__codepoint_to_bytes_outputiv:nw
35484 #1 #2 \__codepoint_to_bytes_end: #3#4#5#6
35485 {
35486 \__codepoint_to_bytes_output:fnn
35487 { \int_eval:n {#1} } { {#3} {#4} {#5} } {#2}
35488 }
35489 \cs_new:Npn \__codepoint_to_bytes_output:nnn #1#2#3
35490 {
35491 #3
35492 \__codepoint_to_bytes_end: #2 {#1}
35493 }
35494 \cs_generate_variant:Nn \__codepoint_to_bytes_output:nnn { f }
35495 \cs_new:Npn \__codepoint_to_bytes_end: { }
35496 \sys_if_engine_luatex:TF
35497 {
35498 \cs_new:Npn \codepoint_to_category:n #1
35499 {
35500 \__kernel_codepoint_data:wn \int_eval:n { #1 } { category }
35501 }
35502 }
35503 {
35504 \cs_new:Npn \codepoint_to_category:n #1
35505 {
35506 \cs:w
35507 c__codepoint_category_
35508 \tex_romannumeral:D
35509 \__kernel_codepoint_data:nn { category } {#1}
35510 _str
35511 \cs_end:
35512 }
35513 }
35514 \cs_new:Npn \codepoint_to_nfd:n #1
35515 { \exp_args:Ne \__codepoint_to_nfd:n { \int_eval:n {#1} } }
35516 \cs_new:Npn \__codepoint_to_nfd:n #1
35517 { \__codepoint_to_nfd:nn {#1} { \char_value_catcode:n {#1} } }
35518 \sys_if_engine_opentype:F
35519 {
35520 \cs_gset:Npn \__codepoint_to_nfd:n #1
35521 {
35522 \int_compare:nNnTF {#1} > { "80 }
35523 { \__codepoint_to_nfd:nn {#1} { 12 } }
35524 { \__codepoint_to_nfd:nn {#1} { \char_value_catcode:n {#1} } }
35525 }
35526 }
35527 \cs_new:Npn \__codepoint_to_nfd:nn #1#2
35528 {
35529 \exp_args:Ne \__codepoint_to_nfd:nnn
35530 { \__codepoint_nfd:n {#1} } {#1} {#2}
35531 }
35532 \cs_new:Npn \__codepoint_to_nfd:nnn #1#2#3 { \__codepoint_to_nfd:nnnn #1 {#2} {#3} }
35533 \cs_new:Npn \__codepoint_to_nfd:nnnn #1#2#3#4
35534 {
35535 \int_compare:nNnTF {#1} = {#3}
35536 { \codepoint_generate:nn {#1} {#4} }
35537 {
35538 \__codepoint_to_nfd:nn {#1} {#4}
35539 \tl_if_blank:nF {#2}
35540 { \__codepoint_to_nfd:nn {#2} {#4} }
35541 }
35542 }
35543 \int_const:Nn \c__codepoint_block_size_int { 64 }
35544 \ior_new:N \g__codepoint_data_ior
35545 \sys_if_engine_luatex:F
35546 {
35547 \group_begin:
35548 \clist_map_inline:nn
35549 { category , grapheme , lowercase , uppercase , wordbreak }
35550 {
35551 \cs_set_nopar:cpn { l__codepoint_ #1 _block_clist } { }
35552 \cs_set_nopar:cpn { l__codepoint_ #1 _block_tl } { 1 }
35553 \cs_set_nopar:cpn { l__codepoint_ #1 _pos_tl } { 0 }
35554 \cs_set_nopar:cpn { l__codepoint_ #1 _next_tl } { 0 }
35555 \intarray_new:cn { g__codepoint_ #1 _index_intarray }
35556 { \int_div_truncate:nn { "110000 } \c__codepoint_block_size_int }
35557 }
35558 \cs_set_nopar:Npn \l__codepoint_matched_block_tl { 0 }
35559 \cs_set_nopar:Npn \l__codepoint_uppercase_default_tl { 0 }
35560 \cs_set_nopar:Npn \l__codepoint_lowercase_default_tl { 0 }
35561 \cs_set_protected:Npn \__codepoint_data_auxi:w #1#2#3
35562 {
35563 \quark_if_recursion_tail_stop:n {#3}
35564 \cs_set_nopar:cpn { l__codepoint_ #2 _ #3 _tl } {#1}
35565 \str_const:cn { c__codepoint_ #2 _ \tex_romannumeral:D #1 _str } {#3}
35566 \exp_args:Ne \__codepoint_data_auxi:w { \int_eval:n { #1 + 1 } } {#2}
35567 }
35568 \__codepoint_data_auxi:w { 1 } { category }
35569 { Lu } { Ll } { Lt } { Lm } { Lo }
35570 { Mn } { Me } { Mc }
35571 { Nd } { Nl } { No }
35572 { Zs } { Zl } { Zp }
35573 { Cc } { Cf } { Co } { Cs } { Cn }
35574 { Pd } { Ps } { Pe } { Pc } { Po } { Pi } { Pf }
35575 { Sm } { Sc } { Sk } { So }
35576 \q_recursion_tail
35577 \q_recursion_stop
35578 \cs_set_eq:NN \l__codepoint_category_default_tl \l__codepoint_category_Cn_tl
35579 \__codepoint_data_auxi:w { 1 } { grapheme }
35580 { Control }
35581 { CR } { LF } { ZWJ }
35582 { Extend }
35583 { L } { LV } { LVT } { T } { V }
35584 { Prepend }
35585 { Regional_Indicator }
35586 { SpacingMark }
35587 { Other }
35588 \q_recursion_tail
35589 \q_recursion_stop
35590 \cs_set_eq:NN \l__codepoint_grapheme_default_tl \l__codepoint_grapheme_Other_tl
35591 \__codepoint_data_auxi:w { 1 } { wordbreak }
35592 { Double_Quote } { Single_Quote }
35593 { CR } { LF } { Newline }
35594 { WSegSpace } { ZWJ }
35595 { Extend } { ExtendNumLet }
35596 { Regional_Indicator }
35597 { Format }
35598 { Katakana }
35599 { ALetter } { MidLetter } { Hebrew_Letter }
35600 { Numeric }{ MidNum } { MidNumLet }
35601 { Other }
35602 \q_recursion_tail
35603 \q_recursion_stop
35604 \cs_set_eq:NN \l__codepoint_wordbreak_default_tl \l__codepoint_wordbreak_Other_tl
35605 \cs_set_protected:Npn \__codepoint_data_auxi:w #1 ;~ #2 ~ #3 \q_stop
35606 { \__codepoint_data_auxii:w #1 .. \q_stop {#2} }
35607 \cs_set_protected:Npn \__codepoint_data_auxii:w #1 .. #2 \q_stop
35608 { \__codepoint_data_auxiii:w #1 ~ .. #2 ~ \q_stop }
35609 \cs_set_protected:Npn \__codepoint_data_auxiii:w #1 ~ #2 .. #3 ~ #4 \q_stop #5#6
35610 {
35611 \cs_set_nopar:cpe { l__codepoint_ #6 _ \tex_romannumeral:D "#1 _tl }
35612 {
35613 {#3}
35614 { \use:c { l__codepoint_ #6 _ #5 _tl } }
35615 }
35616 }
35617 \cs_set_protected:Npn \__codepoint_data_auxvi:w #1#2
35618 {
35619 \ior_open:Nn \g__codepoint_data_ior {#1}
35620 \ior_str_map_inline:Nn \g__codepoint_data_ior
35621 {
35622 \str_if_eq:eeF { \tl_head:w ##1 \c_hash_str \q_stop } { \c_hash_str }
35623 {
35624 \tl_if_blank:nF {##1}
35625 { \__codepoint_data_auxi:w ##1 \q_stop {#2} }
35626 }
35627 }
35628 \ior_close:N \g__codepoint_data_ior
35629 }
35630 \__codepoint_data_auxvi:w { GraphemeBreakProperty.txt } { grapheme }
35631 \__codepoint_data_auxvi:w { WordBreakProperty.txt } { wordbreak }
35632 \cs_set_protected:Npn \__codepoint_data_property:nnnn #1#2#3#4
35633 {
35634 \int_compare:nNnT {#3} > { \use:c { l__codepoint_ #4 _next_tl } }
35635 {
35636 \__codepoint_range:nnv {#3} {#4}
35637 { l__codepoint_ #4 _default_tl }
35638 }
35639 \__codepoint_add:nn {#4} {#2}
35640 \tl_set:ce { l__codepoint_ #4 _next_tl } { \int_eval:n { #3 + 1 } }
35641 \tl_if_blank:nF {#1}
35642 {
35643 \__codepoint_range:nnn {"#1} {#4} {#2}
35644 \__codepoint_add:nn {#4} {#2}
35645 \tl_set:ce { l__codepoint_ #4 _next_tl } { \int_eval:n { "#1 + 1 } }
35646 }
35647 }
35648 \cs_set_protected:Npn \__codepoint_data_auxi:w
35649 #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 ; #8 ; #9 ;
35650 {
35651 \tl_if_blank:nF {#6}
35652 {
35653 \tl_if_head_eq_charcode:nNF {#6} < % >
35654 { \__codepoint_data_auxii:w #1 ; #6 ~ \q_stop }
35655 }
35656 \__codepoint_data_auxiii:w #1 ; #2 ; #3 ;
35657 }
35658 \cs_set_protected:Npn \__codepoint_data_auxii:w #1 ; #2 ~ #3 \q_stop
35659 {
35660 \tl_const:ce
35661 { c__codepoint_nfd_ \codepoint_str_generate:n {"#1} _tl }
35662 {
35663 {"#2}
35664 { \tl_if_blank:nF {#3} {"#3} }
35665 }
35666 }
35667 \cs_set_protected:Npn \__codepoint_data_auxiii:w
35668 #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 ; #8 ; #9 ~ \q_stop
35669 {
35670 \use:e
35671 {
35672 \__codepoint_data_auxiv:w
35673 #1 ; #2 ;
35674 \__codepoint_data_category:n {#3} ;
35675 \__codepoint_data_offset:nn {#1} {#7} ;
35676 \__codepoint_data_offset:nn {#1} {#8} ;
35677 #9;
35678 }
35679 }
35680 \cs_set:Npn \__codepoint_data_category:n #1
35681 { \use:c { l__codepoint_category_ #1 _tl } }
35682 \cs_set:Npn \__codepoint_data_offset:nn #1#2
35683 {
35684 \tl_if_blank:nTF {#2}
35685 { 0 }
35686 { \int_eval:n { "#2 - "#1 } }
35687 }
35688 \cs_set_protected:Npn \__codepoint_data_auxiv:w #1 ; #2 ; #3 ; #4 ; #5 ; #6 ;
35689 {
35690 \int_compare:nNnT {"#1} > \l__codepoint_category_next_tl
35691 {
35692 \__codepoint_data_auxv:nnnnw {#1} {#3} {#4} {#5}
35693 #2 Last> \q_stop
35694 }
35695 \__codepoint_add:nn { category } {#3}
35696 \__codepoint_add:nn { uppercase } {#4}
35697 \__codepoint_add:nn { lowercase } {#5}
35698 \int_compare:nNnF {#4} = { \__codepoint_data_offset:nn {#1} {#6} }
35699 {
35700 \tl_const:ce
35701 { c__codepoint_titlecase_ \codepoint_str_generate:n {"#1} _tl }
35702 { {"#6} { } { } }
35703 }
35704 \__codepoint_data_auxvi:nn { grapheme } {"#1}
35705 \__codepoint_data_auxvi:nn { wordbreak } {"#1}
35706 \int_compare:nNnT {"#1} = { "AC00 }
35707 {
35708 \int_step_inline:nnn { "AC01 } { "D7A2 }
35709 { \__codepoint_data_auxvi:nn { grapheme } {##1} }
35710 }
35711 \tl_set:Ne \l__codepoint_category_next_tl
35712 { \int_eval:n { "#1 + 1 } }
35713 \tl_set_eq:NN \l__codepoint_lowercase_next_tl \l__codepoint_category_next_tl
35714 \tl_set_eq:NN \l__codepoint_uppercase_next_tl \l__codepoint_category_next_tl
35715 }
35716 \cs_set_protected:Npn \__codepoint_add:nn #1#2
35717 {
35718 \clist_put_right:cn { l__codepoint_ #1 _block_clist } {#2}
35719 \int_compare:nNnT { \clist_count:c { l__codepoint_ #1 _block_clist } }
35720 = \c__codepoint_block_size_int
35721 { \__codepoint_save_blocks:nn {#1} { 1 } }
35722 }
35723 \cs_set_protected:Npn \__codepoint_data_auxv:nnnnw #1#2#3#4#5 Last> #6 \q_stop
35724 {
35725 \tl_if_blank:nTF {#6}
35726 {
35727 \__codepoint_range:nno {"#1} { category }
35728 \l__codepoint_category_default_tl
35729 \__codepoint_range:nnn {"#1} { uppercase } { 0 }
35730 \__codepoint_range:nnn {"#1} { lowercase } { 0 }
35731 }
35732 {
35733 \__codepoint_range:nnn {"#1} { category } {#2}
35734 \__codepoint_range:nnn {"#1} { uppercase } {#3}
35735 \__codepoint_range:nnn {"#1} { lowercase } {#4}
35736 }
35737 }
35738 \cs_set_protected:Npn \__codepoint_data_auxvi:nn #1#2
35739 {
35740 \cs_if_exist:cT
35741 { l__codepoint_ #1 _ \tex_romannumeral:D #2 _tl }
35742 {
35743 \exp_after:wN \exp_after:wN \exp_after:wN \__codepoint_data_property:nnnn
35744 \cs:w
35745 l__codepoint_ #1 _ \tex_romannumeral:D #2 _tl
35746 \cs_end: {#2} {#1}
35747 }
35748 }
35749 \cs_set_protected:Npn \__codepoint_range:nnn #1#2
35750 {
35751 \exp_args:Nf \__codepoint_range_aux:nnn
35752 { \int_eval:n { #1 - \use:c { l__codepoint_ #2 _next_tl } } }
35753 {#2}
35754 }
35755 \cs_set_protected:Npn \__codepoint_range:nno { \exp_args:Nnno \__codepoint_range:nnn }
35756 \cs_set_protected:Npn \__codepoint_range:nnv { \exp_args:Nnnv \__codepoint_range:nnn }
35757 \cs_set_protected:Npn \__codepoint_range_aux:nnn #1#2
35758 {
35759 \exp_args:Nf \__codepoint_range:nnnn
35760 {
35761 \int_min:nn
35762 {#1}
35763 {
35764 \c__codepoint_block_size_int
35765 - \clist_count:c { l__codepoint_ #2 _block_clist }
35766 }
35767 }
35768 {#1} {#2}
35769 }
35770 \cs_set_protected:Npn \__codepoint_range:nnnn #1#2#3#4
35771 {
35772 \prg_replicate:nn {#1}
35773 { \clist_put_right:cn { l__codepoint_ #3 _block_clist } {#4} }
35774 \int_compare:nNnT { \clist_count:c { l__codepoint_ #3 _block_clist } }
35775 = \c__codepoint_block_size_int
35776 { \__codepoint_save_blocks:nn {#3} { 1 } }
35777 \int_compare:nNnF
35778 { \int_div_truncate:nn { #2 - #1 } \c__codepoint_block_size_int } = 0
35779 {
35780 \tl_set:ce { l__codepoint_ #3 _block_clist }
35781 {
35782 \exp_args:NNe \use:nn \use_none:n
35783 { \prg_replicate:nn { \c__codepoint_block_size_int } { , #4 } }
35784 }
35785 \__codepoint_save_blocks:nn {#3}
35786 { \int_div_truncate:nn { (#2 - #1) } \c__codepoint_block_size_int }
35787 }
35788 \prg_replicate:nn
35789 { \int_mod:nn { #2 - #1 } \c__codepoint_block_size_int }
35790 { \clist_put_right:ce { l__codepoint_ #3 _block_clist } {#4} }
35791 }
35792 \cs_set_protected:Npn \__codepoint_save_blocks:nn #1#2
35793 {
35794 \tl_set_eq:Nc \l__codepoint_matched_block_tl { l__codepoint_ #1 _block_tl }
35795 \int_step_inline:nn { \tl_use:c { l__codepoint_ #1 _block_tl } - 1 }
35796 {
35797 \tl_if_eq:ccT { l__codepoint_ #1 _block_clist }
35798 { l__codepoint_ #1 _block_ ##1 _clist }
35799 { \tl_set:Nn \l__codepoint_matched_block_tl {##1} }
35800 }
35801 \int_compare:nNnT
35802 { \tl_use:c { l__codepoint_ #1 _block_tl } } = \l__codepoint_matched_block_tl
35803 {
35804 \clist_set_eq:cc
35805 {
35806 l__codepoint_ #1 _block_
35807 \tl_use:c { l__codepoint_ #1 _block_tl } _clist
35808 }
35809 { l__codepoint_ #1 _block_clist }
35810 \tl_set:ce { l__codepoint_ #1 _block_tl }
35811 { \int_eval:n { \tl_use:c { l__codepoint_ #1 _block_tl } + 1 } }
35812 }
35813 \int_step_inline:nnn
35814 { \tl_use:c { l__codepoint_ #1 _pos_tl } + 1 }
35815 { \tl_use:c { l__codepoint_ #1 _pos_tl } + #2 }
35816 {
35817 \exp_args:Nc \__kernel_intarray_gset:Nnn
35818 { g__codepoint_ #1 _index_intarray }
35819 {##1}
35820 \l__codepoint_matched_block_tl
35821 }
35822 \tl_set:ce { l__codepoint_ #1 _pos_tl }
35823 { \int_eval:n { \tl_use:c { l__codepoint_ #1 _pos_tl } + #2 } }
35824 \clist_clear:c { l__codepoint_ #1 _block_clist }
35825 }
35826 \cs_set_protected:Npn \__codepoint_finalize_blocks:n #1
35827 {
35828 \clist_map_inline:nn {#1}
35829 {
35830 \exp_args:Nnnv \__codepoint_range:nnn { "110000 } {##1}
35831 { l__codepoint_ ##1 _default_tl }
35832 \__codepoint_finalize_blocks_aux:n {##1}
35833 }
35834 }
35835 \cs_set_protected:Npn \__codepoint_finalize_blocks_aux:n #1
35836 {
35837 \cs_gset_eq:cc { c__codepoint_ #1 _index_intarray } { g__codepoint_ #1 _index_intarray }
35838 \cs_undefine:c { g__codepoint_ #1 _index_intarray }
35839 \intarray_new:cn { g__codepoint_ #1 _blocks_intarray }
35840 { ( \tl_use:c { l__codepoint_ #1 _block_tl } - 1 ) * \c__codepoint_block_size_int }
35841 \int_step_inline:nn { \tl_use:c { l__codepoint_ #1 _block_tl } - 1 }
35842 {
35843 \exp_args:Nv \__codepoint_finalize_blocks:nnn
35844 { l__codepoint_ #1 _block_ ##1 _clist }
35845 {##1} {#1}
35846 }
35847 \cs_gset_eq:cc { c__codepoint_ #1 _blocks_intarray }
35848 { g__codepoint_ #1 _blocks_intarray }
35849 \cs_undefine:c { g__codepoint_ #1 _blocks_intarray }
35850 }
35851 \cs_set_protected:Npn \__codepoint_finalize_blocks:nnn #1#2#3
35852 {
35853 \exp_args:Nnf \__codepoint_finalize_blocks:nnnw { 1 }
35854 { \int_eval:n { ( #2 - 1 ) * \c__codepoint_block_size_int } }
35855 {#3}
35856 #1 , \q_recursion_tail , \q_recursion_stop
35857 }
35858 \cs_set_protected:Npn \__codepoint_finalize_blocks:nnnw #1#2#3#4 ,
35859 {
35860 \quark_if_recursion_tail_stop:n {#4}
35861 \intarray_gset:cnn { g__codepoint_ #3 _blocks_intarray }
35862 { #1 + #2 }
35863 {#4}
35864 \exp_args:Nf \__codepoint_finalize_blocks:nnnw
35865 { \int_eval:n { #1 + 1 } } {#2} {#3}
35866 }
35867 \ior_open:Nn \g__codepoint_data_ior { UnicodeData.txt }
35868 \char_set_catcode_space:n { `\ }%
35869 \ior_map_variable:NNn \g__codepoint_data_ior \l__codepoint_tmpa_tl
35870 {%
35871 \if_meaning:w \l__codepoint_tmpa_tl \c_space_tl
35872 \exp_after:wN \ior_map_break:
35873 \fi:
35874 \exp_after:wN \__codepoint_data_auxi:w \l__codepoint_tmpa_tl \q_stop
35875 }%
35876 \char_set_catcode_ignore:n { `\ }%
35877 \__codepoint_finalize_blocks:n
35878 { category , grapheme , lowercase , uppercase , wordbreak }
35879 \group_end:
35880 \cs_new:Npn \__kernel_codepoint_data:nn #1#2
35881 {
35882 \exp_args:Nf \__codepoint_data:nnn
35883 {
35884 \int_eval:n
35885 {
35886 \c__codepoint_block_size_int *
35887 (
35888 \intarray_item:cn { c__codepoint_ #1 _index_intarray }
35889 {
35890 \int_div_truncate:nn {#2}
35891 \c__codepoint_block_size_int
35892 + 1
35893 }
35894 - 1
35895 )
35896 }
35897 }
35898 {#2} {#1}
35899 }
35900 \cs_new:Npn \__codepoint_data:nnn #1#2#3
35901 {
35902 \intarray_item:cn { c__codepoint_ #3 _blocks_intarray }
35903 { #1 + \int_mod:nn {#2} \c__codepoint_block_size_int + 1 }
35904 }
35905 }
35906 \group_begin:
35907 \ior_open:Nn \g__codepoint_data_ior { CaseFolding.txt }
35908 \cs_set_protected:Npn \__codepoint_data_auxi:w #1 ;~ #2 ;~ #3 ; #4 \q_stop
35909 {
35910 \if:w \tl_head:n { #2 ? } C
35911 \reverse_if:N \if_int_compare:w
35912 \__codepoint_lowercase_base_mapping:n { "#1 }
35913 = "#3 ~
35914 \tl_const:ce
35915 { c__codepoint_casefold_ \codepoint_str_generate:n {"#1} _tl }
35916 { {"#3} { } { } }
35917 \fi:
35918 \else:
35919 \if:w \tl_head:n { #2 ? } F
35920 \__codepoint_data_auxii:w #1 ~ #3 ~ \q_stop
35921 \fi:
35922 \fi:
35923 }
35924 \sys_if_engine_luatex:TF
35925 {
35926 \cs_set:Npn \__codepoint_lowercase_base_mapping:n #1
35927 {
35928 \__kernel_codepoint_data:wn #1 { lowercase }
35929 }
35930 }
35931 {
35932 \cs_set:Npn \__codepoint_lowercase_base_mapping:n #1
35933 {
35934 \int_eval:n { \__kernel_codepoint_data:nn { lowercase } {#1} + #1 }
35935 }
35936 }
35937 \cs_set_protected:Npn \__codepoint_data_auxii:w #1 ~ #2 ~ #3 ~ #4 \q_stop
35938 {
35939 \tl_const:ce { c__codepoint_casefold_ \codepoint_str_generate:n {"#1} _tl }
35940 {
35941 {"#2}
35942 {"#3}
35943 { \tl_if_blank:nF {#4} { " \int_to_Hex:n {"#4} } }
35944 }
35945 }
35946 \ior_str_map_inline:Nn \g__codepoint_data_ior
35947 {
35948 \reverse_if:N \if:w \c_hash_str \tl_head:w #1 \c_hash_str \q_stop
35949 \__codepoint_data_auxi:w #1 \q_stop
35950 \fi:
35951 }
35952 \ior_close:N \g__codepoint_data_ior
35953 \ior_open:Nn \g__codepoint_data_ior { SpecialCasing.txt }
35954 \cs_set_protected:Npn \__codepoint_data_auxi:w
35955 #1 ;~ #2 ;~ #3 ;~ #4 ; #5 \q_stop
35956 {
35957 \use:n { \__codepoint_data_auxii:w #1 ~ lower ~ #2 ~ } ~ \q_stop
35958 \use:n { \__codepoint_data_auxii:w #1 ~ upper ~ #4 ~ } ~ \q_stop
35959 \str_if_eq:nnF {#3} {#4}
35960 { \use:n { \__codepoint_data_auxii:w #1 ~ title ~ #3 ~ } ~ \q_stop }
35961 }
35962 \cs_set_protected:Npn \__codepoint_data_auxii:w
35963 #1 ~ #2 ~ #3 ~ #4 ~ #5 \q_stop
35964 {
35965 \tl_if_empty:nF {#4}
35966 {
35967 \tl_const:ce { c__codepoint_ #2 case_ \codepoint_str_generate:n {"#1} _tl }
35968 {
35969 {"#3}
35970 {"#4}
35971 { \tl_if_blank:nF {#5} {"#5} }
35972 }
35973 }
35974 }
35975 \ior_str_map_inline:Nn \g__codepoint_data_ior
35976 {
35977 \str_if_eq:eeTF { \tl_head:w #1 \c_hash_str \q_stop } { \c_hash_str }
35978 {
35979 \str_if_eq:eeT
35980 {#1}
35981 { \c_hash_str \c_space_tl Conditional~Mappings }
35982 { \ior_map_break: }
35983 }
35984 { \__codepoint_data_auxi:w #1 \q_stop }
35985 }
35986 \ior_close:N \g__codepoint_data_ior
35987 \group_end:
35988 \cs_new:Npn \__kernel_codepoint_case:nn #1#2
35989 {
35990 \exp_args:Ne \__codepoint_case:nnn
35991 { \codepoint_str_generate:n {#2} } {#1} {#2}
35992 }
35993 \cs_new:Npn \__codepoint_case:nnn #1#2#3
35994 {
35995 \cs_if_exist:cTF { c__codepoint_ #2 _ #1 _tl }
35996 {
35997 \tl_use:c
35998 { c__codepoint_ #2 _ #1 _tl }
35999 }
36000 { \use:c { __codepoint_ #2 :n } {#3} }
36001 }
36002 \cs_new:Npn \__codepoint_uppercase:n { \__codepoint_case:nn { uppercase } }
36003 \cs_new:Npn \__codepoint_lowercase:n { \__codepoint_case:nn { lowercase } }
36004 \sys_if_engine_luatex:TF
36005 {
36006 \cs_new:Npn \__codepoint_titlecase:n { \__codepoint_case:nn { titlecase } }
36007 }
36008 {
36009 \cs_new:Npn \__codepoint_titlecase:n { \__codepoint_case:nn { uppercase } }
36010 }
36011 \cs_new:Npn \__codepoint_casefold:n { \__codepoint_case:nn { lowercase } }
36012 \sys_if_engine_luatex:TF
36013 {
36014 \cs_new:Npn \__codepoint_case:nn #1#2
36015 {
36016 { \__kernel_codepoint_data:wn \int_eval:n {#2} {#1} }
36017 { }
36018 { }
36019 }
36020 }
36021 {
36022 \cs_new:Npn \__codepoint_case:nn #1#2
36023 {
36024 { \int_eval:n { \__kernel_codepoint_data:nn {#1} {#2} + #2 } }
36025 { }
36026 { }
36027 }
36028 }
36029 \sys_if_engine_luatex:TF
36030 {
36031 \cs_new:Npn \__kernel_codepoint_to_grapheme_class:n #1
36032 {
36033 \__kernel_codepoint_data:wn \int_eval:n {#1} { grapheme }
36034 }
36035 \cs_new:Npn \__kernel_codepoint_to_wordbreak_class:n #1
36036 {
36037 \__kernel_codepoint_data:wn \int_eval:n {#1} { wordbreak }
36038 }
36039 }
36040 {
36041 \cs_new:Npn \__kernel_codepoint_to_grapheme_class:n #1
36042 {
36043 \cs:w
36044 c__codepoint_grapheme_
36045 \tex_romannumeral:D
36046 \__kernel_codepoint_data:nn { grapheme } {#1}
36047 _str
36048 \cs_end:
36049 }
36050 \cs_new:Npn \__kernel_codepoint_to_wordbreak_class:n #1
36051 {
36052 \cs:w
36053 c__codepoint_wordbreak_
36054 \tex_romannumeral:D
36055 \__kernel_codepoint_data:nn { wordbreak } {#1}
36056 _str
36057 \cs_end:
36058 }
36059 }
36060 \sys_if_engine_luatex:TF
36061 {
36062 \cs_new:Npn \__codepoint_nfd:n #1
36063 { \__codepoint_nfd:w \__int_eval:w #1 \__int_eval_end: }
36064 }
36065 {
36066 \cs_new:Npn \__codepoint_nfd:n #1
36067 { \exp_args:Ne \__codepoint_nfd:nn { \codepoint_str_generate:n {#1} } {#1} }
36068 \cs_new:Npn \__codepoint_nfd:nn #1#2
36069 {
36070 \tl_if_exist:cTF { c__codepoint_nfd_ #1 _tl }
36071 { \tl_use:c { c__codepoint_nfd_ #1 _tl } }
36072 { {#2} { } }
36073 }
36074 }
36075 %% File: l3text.dtx
36076 \cs_generate_variant:Nn \tl_if_head_eq_meaning_p:nN { o }
36077 \scan_new:N \s__text_stop
36078 \quark_new:N \q__text_nil
36079 \__kernel_quark_new_conditional:Nn \__text_quark_if_nil:n { TF }
36080 \quark_new:N \q__text_recursion_tail
36081 \quark_new:N \q__text_recursion_stop
36082 \cs_new:Npn \__text_use_i_delimit_by_q_recursion_stop:nw
36083 #1 #2 \q__text_recursion_stop {#1}
36084 \__kernel_quark_new_test:N \__text_if_q_recursion_tail_stop_do:Nn
36085 \__kernel_quark_new_test:N \__text_if_q_recursion_tail_stop_do:nn
36086 \scan_new:N \s__text_recursion_tail
36087 \scan_new:N \s__text_recursion_stop
36088 \cs_new:Npn \__text_use_i_delimit_by_s_recursion_stop:nw
36089 #1 #2 \s__text_recursion_stop {#1}
36090 \cs_new:Npn \__text_if_s_recursion_tail_stop_do:Nn #1
36091 {
36092 \bool_lazy_and:nnTF
36093 { \cs_if_eq_p:NN \s__text_recursion_tail #1 }
36094 { \str_if_eq_p:nn { \s__text_recursion_tail } {#1} }
36095 { \__text_use_i_delimit_by_s_recursion_stop:nw }
36096 { \use_none:n }
36097 }
36098 \cs_new_eq:NN \__text_sep: \__kernel_int_sep:
36099 \group_begin:
36100 \char_set_catcode_active:n { 0 }
36101 \cs_new:Npn \__text_token_to_explicit:N #1
36102 {
36103 \if_catcode:w \exp_not:N #1
36104 \if_catcode:w \scan_stop: \exp_not:N #1
36105 \scan_stop:
36106 \else:
36107 \exp_not:N ^^@
36108 \fi:
36109 \exp_after:wN \__text_token_to_explicit_cs:N
36110 \else:
36111 \exp_after:wN \__text_token_to_explicit_char:N
36112 \fi:
36113 #1
36114 }
36115 \group_end:
36116 \cs_new:Npn \__text_token_to_explicit_cs:N #1
36117 {
36118 \exp_after:wN \if_meaning:w \exp_not:N #1 #1
36119 \exp_after:wN \use:nn \exp_after:wN
36120 \__text_token_to_explicit_cs_aux:N
36121 \else:
36122 \exp_after:wN \exp_not:n
36123 \fi:
36124 {#1}
36125 }
36126 \cs_new:Npn \__text_token_to_explicit_cs_aux:N #1
36127 {
36128 \bool_lazy_or:nnTF
36129 { \token_if_chardef_p:N #1 }
36130 { \token_if_mathchardef_p:N #1 }
36131 {
36132 \char_generate:nn {#1}
36133 {
36134 \if_int_compare:w \char_value_catcode:n {#1} = 10 \exp_stop_f:
36135 10
36136 \else:
36137 12
36138 \fi:
36139 }
36140 }
36141 {#1}
36142 }
36143 \cs_new:Npn \__text_token_to_explicit_char:N #1
36144 {
36145 \if:w
36146 \if_catcode:w ^ \exp_args:No \str_tail:n { \token_to_str:N #1 } ^
36147 \token_to_str:N #1 #1
36148 \else:
36149 AB
36150 \fi:
36151 \exp_after:wN \exp_not:n
36152 \else:
36153 \exp_after:wN \__text_token_to_explicit:n
36154 \fi:
36155 {#1}
36156 }
36157 \cs_new:Npn \__text_token_to_explicit:n #1
36158 {
36159 \exp_after:wN \__text_token_to_explicit_auxi:w
36160 \int_value:w
36161 \if_catcode:w \c_group_begin_token #1 1 \else:
36162 \if_catcode:w \c_group_end_token #1 2 \else:
36163 \if_catcode:w \c_math_toggle_token #1 3 \else:
36164 \if_catcode:w ## #1 6 \else:
36165 \if_catcode:w ^ #1 7 \else:
36166 \if_catcode:w \c_math_subscript_token #1 8 \else:
36167 \if_catcode:w \c_space_token #1 10 \else:
36168 \if_catcode:w A #1 11 \else:
36169 \if_catcode:w + #1 12 \else:
36170 4 \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi:
36171 \exp_after:wN \__text_sep:
36172 \token_to_meaning:N #1 \s__text_stop
36173 }
36174 \cs_new:Npn \__text_token_to_explicit_auxi:w #1 \__text_sep: #2 \s__text_stop
36175 {
36176 \char_generate:nn
36177 {
36178 \if_int_compare:w #1 < 9 \exp_stop_f:
36179 \exp_after:wN \__text_token_to_explicit_auxii:w
36180 \else:
36181 \exp_after:wN \__text_token_to_explicit_auxiii:w
36182 \fi:
36183 #2
36184 }
36185 {#1}
36186 }
36187 \exp_last_unbraced:NNNNo \cs_new:Npn \__text_token_to_explicit_auxii:w
36188 #1 { \tl_to_str:n { character ~ } } { ` }
36189 \cs_new:Npn \__text_token_to_explicit_auxiii:w #1 ~ #2 ~ { ` }
36190 \cs_new:Npn \__text_char_catcode:N #1
36191 {
36192 \if_catcode:w \exp_not:N #1 \c_math_toggle_token
36193 3
36194 \else:
36195 \if_catcode:w \exp_not:N #1 \c_alignment_token
36196 4
36197 \else:
36198 \if_catcode:w \exp_not:N #1 \c_math_superscript_token
36199 7
36200 \else:
36201 \if_catcode:w \exp_not:N #1 \c_math_subscript_token
36202 8
36203 \else:
36204 \if_catcode:w \exp_not:N #1 \c_space_token
36205 10
36206 \else:
36207 \if_catcode:w \exp_not:N #1 \c_catcode_letter_token
36208 11
36209 \else:
36210 \if_catcode:w \exp_not:N #1 \c_catcode_other_token
36211 12
36212 \else:
36213 13
36214 \fi:
36215 \fi:
36216 \fi:
36217 \fi:
36218 \fi:
36219 \fi:
36220 \fi:
36221 }
36222 \prg_new_conditional:Npnn \__text_if_expandable:N #1 { T , F , TF }
36223 {
36224 \token_if_expandable:NTF #1
36225 {
36226 \bool_lazy_any:nTF
36227 {
36228 { \token_if_protected_macro_p:N #1 }
36229 { \token_if_protected_long_macro_p:N #1 }
36230 { \token_if_eq_meaning_p:NN \q__text_recursion_tail #1 }
36231 }
36232 { \prg_return_false: }
36233 { \prg_return_true: }
36234 }
36235 { \prg_return_false: }
36236 }
36237 \sys_if_engine_opentype:TF
36238 {
36239 \cs_new:Npn \__text_codepoint_process:nN #1#2 { #1 {#2} }
36240 }
36241 {
36242 \cs_new:Npe \__text_codepoint_process:nN #1#2
36243 {
36244 \exp_not:N \int_compare:nNnTF {`#2} > { "80 }
36245 {
36246 \sys_if_engine_pdftex:TF
36247 { \exp_not:N \__text_codepoint_process_aux:nN }
36248 {
36249 \exp_not:N \int_compare:nNnTF {`#2} > { "FF }
36250 { \exp_not:N \use:n }
36251 { \exp_not:N \__text_codepoint_process_aux:nN }
36252 }
36253 }
36254 { \exp_not:N \use:n }
36255 {#1} #2
36256 }
36257 \cs_new:Npn \__text_codepoint_process_aux:nN #1#2
36258 {
36259 \int_compare:nNnTF { `#2 } < { "E0 }
36260 { \__text_codepoint_process:nNN }
36261 {
36262 \int_compare:nNnTF { `#2 } < { "F0 }
36263 { \__text_codepoint_process:nNNN }
36264 { \__text_codepoint_process:nNNNN }
36265 }
36266 {#1} #2
36267 }
36268 \cs_new:Npn \__text_codepoint_process:nNN #1#2#3
36269 { #1 {#2#3} }
36270 \cs_new:Npn \__text_codepoint_process:nNNN #1#2#3#4
36271 { #1 {#2#3#4} }
36272 \cs_new:Npn \__text_codepoint_process:nNNNN #1#2#3#4#5
36273 { #1 {#2#3#4#5} }
36274 }
36275 \sys_if_engine_opentype:TF
36276 {
36277 \prg_new_conditional:Npnn
36278 \__text_codepoint_compare:nNn #1#2#3 { TF , p }
36279 {
36280 \int_compare:nNnTF {`#1} #2 {#3}
36281 \prg_return_true: \prg_return_false:
36282 }
36283 \cs_new:Npn \__text_codepoint_from_chars:Nw #1 {`#1}
36284 }
36285 {
36286 \prg_new_conditional:Npnn
36287 \__text_codepoint_compare:nNn #1#2#3 { TF , p }
36288 {
36289 \int_compare:nNnTF { \__text_codepoint_from_chars:Nw #1 }
36290 #2 {#3}
36291 \prg_return_true: \prg_return_false:
36292 }
36293 \cs_new:Npe \__text_codepoint_from_chars:Nw #1
36294 {
36295 \exp_not:N \if_int_compare:w `#1 > "80 \exp_not:N \exp_stop_f:
36296 \sys_if_engine_pdftex:TF
36297 {
36298 \exp_not:N \exp_after:wN
36299 \exp_not:N \__text_codepoint_from_chars_aux:Nw
36300 }
36301 {
36302 \exp_not:N \if_int_compare:w `#1 > "FF \exp_not:N \exp_stop_f:
36303 \exp_not:N \exp_after:wN \exp_not:N \exp_after:wN
36304 \exp_not:N \exp_after:wN
36305 \exp_not:N \__text_codepoint_from_chars:N
36306 \exp_not:N \else:
36307 \exp_not:N \exp_after:wN \exp_not:N \exp_after:wN
36308 \exp_not:N \exp_after:wN
36309 \exp_not:N \__text_codepoint_from_chars_aux:Nw
36310 \exp_not:N \fi:
36311 }
36312 \exp_not:N \else:
36313 \exp_not:N \exp_after:wN \exp_not:N \__text_codepoint_from_chars:N
36314 \exp_not:N \fi:
36315 #1
36316 }
36317 \cs_new:Npn \__text_codepoint_from_chars_aux:Nw #1
36318 {
36319 \if_int_compare:w `#1 < "E0 \exp_stop_f:
36320 \exp_after:wN \__text_codepoint_from_chars:NN
36321 \else:
36322 \if_int_compare:w `#1 < "F0 \exp_stop_f:
36323 \exp_after:wN \exp_after:wN \exp_after:wN
36324 \__text_codepoint_from_chars:NNN
36325 \else:
36326 \exp_after:wN \exp_after:wN \exp_after:wN
36327 \__text_codepoint_from_chars:NNNN
36328 \fi:
36329 \fi:
36330 #1
36331 }
36332 \cs_new:Npn \__text_codepoint_from_chars:N #1 {`#1}
36333 \cs_new:Npn \__text_codepoint_from_chars:NN #1#2
36334 { (`#1 - "C0) * "40 + `#2 - "80 }
36335 \cs_new:Npn \__text_codepoint_from_chars:NNN #1#2#3
36336 { (`#1 - "E0) * "1000 + (`#2 - "80) * "40 + `#3 - "80 }
36337 \cs_new:Npn \__text_codepoint_from_chars:NNNN #1#2#3#4
36338 {
36339 (`#1 - "F0) * "40000
36340 + (`#2 - "80) * "1000
36341 + (`#3 - "80) * "40
36342 + `#4 - "80
36343 }
36344 }
36345 \tl_new:N \l_text_accents_tl
36346 \tl_new:N \l_text_letterlike_tl
36347 \tl_new:N \l_text_case_exclude_arg_tl
36348 \tl_set:Ne \l_text_case_exclude_arg_tl
36349 {
36350 \exp_not:n { \begin \cite \end \label \ref }
36351 \exp_not:c { cite ~ }
36352 \exp_not:n { \babelshorthand }
36353 }
36354 \tl_new:N \l_text_math_arg_tl
36355 \tl_set:Nn \l_text_math_arg_tl { \ensuremath }
36356 \tl_new:N \l_text_math_delims_tl
36357 \tl_set:Nn \l_text_math_delims_tl { $ $ \( \) }
36358 \tl_new:N \l_text_expand_exclude_tl
36359 \tl_set:Nn \l_text_expand_exclude_tl
36360 { \begin \cite \end \label \ref }
36361 \bool_lazy_and:nnT
36362 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
36363 { \tl_if_exist_p:N \@expl@finalise@setup@@ }
36364 {
36365 \tl_gput_right:Nn \@expl@finalise@setup@@
36366 {
36367 \tl_gput_right:Nn \@kernel@after@begindocument
36368 {
36369 \group_begin:
36370 \cs_set_protected:Npn \__text_tmp:w #1
36371 {
36372 \tl_clear:N \l_text_expand_exclude_tl
36373 \tl_map_inline:nn {#1}
36374 {
36375 \bool_lazy_any:nF
36376 {
36377 { \token_if_protected_macro_p:N ##1 }
36378 { \token_if_protected_long_macro_p:N ##1 }
36379 {
36380 \str_if_eq_p:ee
36381 { \cs_replacement_spec:N ##1 }
36382 { \exp_not:n { \protect ##1 } \c_space_tl }
36383 }
36384 }
36385 { \tl_put_right:Nn \l_text_expand_exclude_tl {##1} }
36386 }
36387 }
36388 \exp_args:NV \__text_tmp:w \l_text_expand_exclude_tl
36389 \exp_args:NNNV \group_end:
36390 \tl_set:Nn \l_text_expand_exclude_tl \l_text_expand_exclude_tl
36391 }
36392 }
36393 }
36394 \tl_new:N \l__text_math_mode_tl
36395 \tex_global:D \tex_chardef:D \c__text_chardef_space_token = `\ %
36396 \tex_global:D \tex_mathchardef:D \c__text_mathchardef_space_token = `\ %
36397 \tex_global:D \tex_chardef:D \c__text_chardef_group_begin_token = `\{ % `\}
36398 \tex_global:D \tex_mathchardef:D \c__text_mathchardef_group_begin_token = `\{ % `\} `\{
36399 \tex_global:D \tex_chardef:D \c__text_chardef_group_end_token = `\} % `\{
36400 \tex_global:D \tex_mathchardef:D \c__text_mathchardef_group_end_token = `\} %
36401 \cs_new:Npn \text_expand:n #1
36402 {
36403 \__kernel_exp_not:w \exp_after:wN
36404 {
36405 \exp:w
36406 \__text_expand:n {#1}
36407 }
36408 }
36409 \cs_new:Npn \__text_expand:n #1
36410 {
36411 \group_align_safe_begin:
36412 \__text_expand_loop:w #1
36413 \s__text_recursion_tail \s__text_recursion_stop
36414 \__text_expand_result:n { }
36415 }
36416 \cs_new:Npn \__text_expand_store:n #1
36417 { \__text_expand_store:nw {#1} }
36418 \cs_generate_variant:Nn \__text_expand_store:n { o }
36419 \cs_new:Npn \__text_expand_store:nw #1#2 \__text_expand_result:n #3
36420 { #2 \__text_expand_result:n { #3 #1 } }
36421 \cs_new:Npn \__text_expand_end:w #1 \__text_expand_result:n #2
36422 {
36423 \group_align_safe_end:
36424 \exp_end:
36425 #2
36426 }
36427 \cs_new:Npn \__text_expand_loop:w #1 \s__text_recursion_stop
36428 {
36429 \tl_if_head_is_N_type:nTF {#1}
36430 { \__text_expand_N_type:N }
36431 {
36432 \tl_if_head_is_group:nTF {#1}
36433 { \__text_expand_group:n }
36434 { \__text_expand_space:w }
36435 }
36436 #1 \s__text_recursion_stop
36437 }
36438 \cs_new:Npn \__text_expand_group:n #1
36439 {
36440 \__text_expand_store:o
36441 {
36442 \exp_after:wN
36443 {
36444 \exp:w
36445 \__text_expand:n {#1}
36446 }
36447 }
36448 \__text_expand_loop:w
36449 }
36450 \exp_last_unbraced:NNo \cs_new:Npn \__text_expand_space:w \c_space_tl
36451 {
36452 \__text_expand_store:n { ~ }
36453 \__text_expand_loop:w
36454 }
36455 \cs_new:Npn \__text_expand_N_type:N #1
36456 {
36457 \__text_if_s_recursion_tail_stop_do:Nn #1
36458 { \__text_expand_end:w }
36459 \exp_after:wN \__text_expand_math_search:NNN
36460 \exp_after:wN #1 \l_text_math_delims_tl
36461 \q__text_recursion_tail \q__text_recursion_tail
36462 \q__text_recursion_stop
36463 }
36464 \cs_new:Npn \__text_expand_math_search:NNN #1#2#3
36465 {
36466 \__text_if_q_recursion_tail_stop_do:Nn #2
36467 { \__text_expand_explicit:N #1 }
36468 \token_if_eq_meaning:NNTF #1 #2
36469 {
36470 \__text_use_i_delimit_by_q_recursion_stop:nw
36471 {
36472 \__text_expand_store:n {#1}
36473 \__text_expand_math_loop:Nw #3
36474 }
36475 }
36476 { \__text_expand_math_search:NNN #1 }
36477 }
36478 \cs_new:Npn \__text_expand_math_loop:Nw #1#2 \s__text_recursion_stop
36479 {
36480 \tl_if_head_is_N_type:nTF {#2}
36481 { \__text_expand_math_N_type:NN }
36482 {
36483 \tl_if_head_is_group:nTF {#2}
36484 { \__text_expand_math_group:Nn }
36485 { \__text_expand_math_space:Nw }
36486 }
36487 #1#2 \s__text_recursion_stop
36488 }
36489 \cs_new:Npn \__text_expand_math_N_type:NN #1#2
36490 {
36491 \__text_if_s_recursion_tail_stop_do:Nn #2
36492 { \__text_expand_end:w }
36493 \token_if_eq_meaning:NNF #2 \exp_not:N
36494 { \__text_expand_store:n {#2} }
36495 \token_if_eq_meaning:NNTF #2 #1
36496 { \__text_expand_loop:w }
36497 { \__text_expand_math_loop:Nw #1 }
36498 }
36499 \cs_new:Npn \__text_expand_math_group:Nn #1#2
36500 {
36501 \__text_expand_store:n { {#2} }
36502 \__text_expand_math_loop:Nw #1
36503 }
36504 \exp_after:wN \cs_new:Npn \exp_after:wN \__text_expand_math_space:Nw
36505 \exp_after:wN # \exp_after:wN 1 \c_space_tl
36506 {
36507 \__text_expand_store:n { ~ }
36508 \__text_expand_math_loop:Nw #1
36509 }
36510 \cs_new:Npn \__text_expand_explicit:N #1
36511 {
36512 \token_if_cs:NTF #1
36513 { \__text_expand_exclude:N #1 }
36514 {
36515 \bool_lazy_and:nnTF
36516 { \token_if_active_p:N #1 }
36517 {
36518 ! \bool_lazy_any_p:n
36519 {
36520 { \token_if_protected_macro_p:N #1 }
36521 { \token_if_protected_long_macro_p:N #1 }
36522 { \tl_if_head_eq_meaning_p:oN {#1} \UTFviii@two@octets }
36523 { \tl_if_head_eq_meaning_p:oN {#1} \UTFviii@three@octets }
36524 { \tl_if_head_eq_meaning_p:oN {#1} \UTFviii@four@octets }
36525 { \tl_if_head_eq_meaning_p:oN {#1} \active@prefix }
36526 }
36527 }
36528 { \exp_after:wN \__text_expand_loop:w #1 }
36529 {
36530 \str_if_eq:nnTF {#1} { \exp_stop_f: }
36531 { \__text_expand_store:n { ~ } }
36532 { \__text_expand_store:n {#1} }
36533 \__text_expand_loop:w
36534 }
36535 }
36536 }
36537 \cs_new:Npn \__text_expand_exclude:N #1
36538 {
36539 \cs_if_eq:NNTF #1 \text_case_switch:nnnn
36540 { \__text_expand_exclude_switch:Nnnnn #1 }
36541 {
36542 \exp_args:Ne \__text_expand_exclude:nN
36543 {
36544 \exp_not:V \l_text_math_arg_tl
36545 \exp_not:V \l_text_expand_exclude_tl
36546 \exp_not:V \l_text_case_exclude_arg_tl
36547 }
36548 #1
36549 }
36550 }
36551 \cs_new:Npn \__text_expand_exclude_switch:Nnnnn #1#2#3#4#5
36552 {
36553 \__text_expand_store:n { #1 {#2} {#3} {#4} {#5} }
36554 \__text_expand_loop:w
36555 }
36556 \cs_new:Npn \__text_expand_exclude:nN #1#2
36557 {
36558 \__text_expand_exclude:NN #2 #1
36559 \q__text_recursion_tail \q__text_recursion_stop
36560 }
36561 \cs_new:Npn \__text_expand_exclude:NN #1#2
36562 {
36563 \__text_if_q_recursion_tail_stop_do:Nn #2
36564 { \__text_expand_accent:N #1 }
36565 \str_if_eq:nnTF {#1} {#2}
36566 {
36567 \__text_use_i_delimit_by_q_recursion_stop:nw
36568 { \__text_expand_exclude:Nw #1 }
36569 }
36570 { \__text_expand_exclude:NN #1 }
36571 }
36572 \cs_new:Npn \__text_expand_exclude:Nw #1#2#
36573 { \__text_expand_exclude:Nnn #1 {#2} }
36574 \cs_new:Npn \__text_expand_exclude:Nnn #1#2#3
36575 {
36576 \__text_expand_store:n { #1#2 {#3} }
36577 \__text_expand_loop:w
36578 }
36579 \cs_new:Npn \__text_expand_accent:N #1
36580 {
36581 \exp_after:wN \__text_expand_accent:NN \exp_after:wN
36582 #1 \l_text_accents_tl
36583 \q__text_recursion_tail \q__text_recursion_stop
36584 }
36585 \cs_new:Npn \__text_expand_accent:NN #1#2
36586 {
36587 \__text_if_q_recursion_tail_stop_do:Nn #2
36588 { \__text_expand_letterlike:N #1 }
36589 \cs_if_eq:NNTF #2 #1
36590 {
36591 \__text_use_i_delimit_by_q_recursion_stop:nw
36592 {
36593 \__text_expand_store:n {#1}
36594 \__text_expand_loop:w
36595 }
36596 }
36597 { \__text_expand_accent:NN #1 }
36598 }
36599 \cs_new:Npn \__text_expand_letterlike:N #1
36600 {
36601 \exp_after:wN \__text_expand_letterlike:NN \exp_after:wN
36602 #1 \l_text_letterlike_tl
36603 \q__text_recursion_tail \q__text_recursion_stop
36604 }
36605 \cs_new:Npn \__text_expand_letterlike:NN #1#2
36606 {
36607 \__text_if_q_recursion_tail_stop_do:Nn #2
36608 { \__text_expand_cs:N #1 }
36609 \cs_if_eq:NNTF #2 #1
36610 {
36611 \__text_use_i_delimit_by_q_recursion_stop:nw
36612 {
36613 \__text_expand_store:n {#1}
36614 \__text_expand_loop:w
36615 }
36616 }
36617 { \__text_expand_letterlike:NN #1 }
36618 }
36619 \cs_new:Npe \__text_expand_cs:N #1
36620 {
36621 \exp_not:N \str_if_eq:nnTF {#1} { \exp_not:N \protect }
36622 { \exp_not:N \__text_expand_protect:w }
36623 {
36624 \bool_lazy_and:nnTF
36625 { \cs_if_exist_p:N \fmtname }
36626 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
36627 { \exp_not:N \__text_expand_testopt:N #1 }
36628 { \exp_not:N \__text_expand_replace:N #1 }
36629 }
36630 }
36631 \cs_new:Npn \__text_expand_protect:w #1 \s__text_recursion_stop
36632 {
36633 \tl_if_head_is_N_type:nTF {#1}
36634 { \__text_expand_protect:N }
36635 {
36636 \__text_expand_store:n { \protect }
36637 \__text_expand_loop:w
36638 }
36639 #1 \s__text_recursion_stop
36640 }
36641 \cs_new:Npn \__text_expand_protect:N #1
36642 {
36643 \__text_if_s_recursion_tail_stop_do:Nn #1
36644 {
36645 \__text_expand_store:n { \protect }
36646 \__text_expand_end:w
36647 }
36648 \exp_args:Ne \__text_expand_protect:nN
36649 { \cs_to_str:N #1 } #1
36650 }
36651 \cs_new:Npn \__text_expand_protect:nN #1#2
36652 { \__text_expand_protect:Nw #2 #1 \q__text_nil #1 ~ \q__text_nil \q__text_nil \s__text_stop }
36653 \cs_new:Npn \__text_expand_protect:Nw #1 #2 ~ \q__text_nil #3 \q__text_nil #4 \s__text_stop
36654 {
36655 \__text_quark_if_nil:nTF {#4}
36656 {
36657 \cs_if_exist:cTF {#2}
36658 { \exp_args:Ne \__text_expand_store:n { \exp_not:c {#2} } }
36659 { \__text_expand_store:n { \protect #1 } }
36660 }
36661 { \__text_expand_store:n { \protect #1 } }
36662 \__text_expand_loop:w
36663 }
36664 \cs_new:Npn \__text_expand_testopt:N #1
36665 {
36666 \token_if_eq_meaning:NNTF #1 \@protected@testopt
36667 { \__text_expand_testopt:NNn }
36668 { \__text_expand_encoding:N #1 }
36669 }
36670 \cs_new:Npn \__text_expand_testopt:NNn #1#2#3
36671 {
36672 \__text_expand_store:n {#1}
36673 \__text_expand_loop:w
36674 }
36675 \cs_new:Npn \__text_expand_encoding:N #1
36676 {
36677 \bool_lazy_or:nnTF
36678 { \cs_if_eq_p:NN #1 \@current@cmd }
36679 { \cs_if_eq_p:NN #1 \@changed@cmd }
36680 { \exp_after:wN \__text_expand_loop:w \__text_expand_encoding_escape:NN }
36681 { \__text_expand_replace:N #1 }
36682 }
36683 \cs_new:Npn \__text_expand_encoding_escape:NN #1#2 { \exp_not:n {#1} }
36684 \cs_new:Npn \__text_expand_replace:N #1
36685 {
36686 \bool_lazy_and:nnTF
36687 { \cs_if_exist_p:c { l__text_expand_ \token_to_str:N #1 _tl } }
36688 {
36689 \bool_lazy_or_p:nn
36690 { \token_if_cs_p:N #1 }
36691 { \token_if_active_p:N #1 }
36692 }
36693 {
36694 \exp_args:Nv \__text_expand_replace:n
36695 { l__text_expand_ \token_to_str:N #1 _tl }
36696 }
36697 { \__text_expand_cs_expand:N #1 }
36698 }
36699 \cs_new:Npn \__text_expand_replace:n #1 { \__text_expand_loop:w #1 }
36700 \cs_new:Npn \__text_expand_cs_expand:N #1
36701 {
36702 \__text_if_expandable:NTF #1
36703 {
36704 \token_if_eq_meaning:NNTF #1 \exp_not:n
36705 { \__text_expand_unexpanded:w }
36706 { \exp_after:wN \__text_expand_loop:w #1 }
36707 }
36708 {
36709 \__text_expand_store:n {#1}
36710 \__text_expand_loop:w
36711 }
36712 }
36713 \cs_new:Npn \__text_expand_unexpanded:w
36714 {
36715 \exp_after:wN \__text_expand_unexpanded_test:w
36716 \exp:w \exp_end_continue_f:w
36717 }
36718 \cs_new:Npn \__text_expand_unexpanded_test:w #1 \s__text_recursion_stop
36719 {
36720 \tl_if_head_is_group:nTF {#1}
36721 { \__text_expand_unexpanded:n }
36722 {
36723 \__text_expand_unexpanded:w
36724 \tl_if_head_is_N_type:nT {#1} { \__text_expand_unexpanded:N }
36725 }
36726 #1 \s__text_recursion_stop
36727 }
36728 \cs_new:Npn \__text_expand_unexpanded:N #1
36729 {
36730 \exp_after:wN \if_meaning:w \exp_not:N #1 #1
36731 \else:
36732 \exp_after:wN #1
36733 \fi:
36734 }
36735 \cs_new:Npn \__text_expand_unexpanded:n #1
36736 {
36737 \__text_expand_store:n {#1}
36738 \__text_expand_loop:w
36739 }
36740 \cs_new_protected:Npn \text_declare_expand_equivalent:Nn #1#2
36741 {
36742 \tl_clear_new:c { l__text_expand_ \token_to_str:N #1 _tl }
36743 \tl_set:cn { l__text_expand_ \token_to_str:N #1 _tl } {#2}
36744 }
36745 \cs_generate_variant:Nn \text_declare_expand_equivalent:Nn { c }
36746 \tl_map_inline:nn
36747 { \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t }
36748 { \text_declare_expand_equivalent:Nn #1 { \exp_not:n {#1} } }
36749 \tl_map_inline:nn
36750 {
36751 \AA \aa
36752 \AE \ae
36753 \DH \dh
36754 \DJ \dj
36755 \IJ \ij
36756 \L \l
36757 \NG \ng
36758 \O \o
36759 \OE \oe
36760 \SS \ss
36761 \TH \th
36762 }
36763 { \text_declare_expand_equivalent:Nn #1 { \exp_not:n {#1} } }
36764 \text_declare_expand_equivalent:Nn \@setfontsize \use_none:nnn
36765 %% File: l3text-case.dtx
36766 \bool_new:N \l_text_titlecase_check_letter_bool
36767 \bool_set_true:N \l_text_titlecase_check_letter_bool
36768 \cs_new:Npn \text_lowercase:n #1
36769 { \__text_change_case:nnn { lower } { } {#1} }
36770 \cs_new:Npn \text_uppercase:n #1
36771 { \__text_change_case:nnn { upper } { } {#1} }
36772 \cs_new:Npn \text_titlecase_all:n #1
36773 { \__text_change_case:nnn { title } { } {#1} }
36774 \cs_new:Npn \text_titlecase_first:n #1
36775 { \__text_change_case:nnnn { title } { break } { } {#1} }
36776 \cs_new:Npn \text_lowercase:nn #1#2
36777 { \__text_change_case:nnn { lower } {#1} {#2} }
36778 \cs_generate_variant:Nn \text_lowercase:nn { V , e }
36779 \cs_new:Npn \text_uppercase:nn #1#2
36780 { \__text_change_case:nnn { upper } {#1} {#2} }
36781 \cs_generate_variant:Nn \text_uppercase:nn { V , e }
36782 \cs_new:Npn \text_titlecase_all:nn #1#2
36783 { \__text_change_case:nnn { title } {#1} {#2} }
36784 \cs_generate_variant:Nn \text_titlecase_all:nn { V , e }
36785 \cs_new:Npn \text_titlecase_first:nn #1#2
36786 { \__text_change_case:nnnn { title } { break } {#1} {#2} }
36787 \cs_generate_variant:Nn \text_titlecase_first:nn { V , e }
36788 \cs_new:Npn \__text_change_case:nnn #1#2#3
36789 { \__text_change_case:nnnn {#1} {#1} {#2} {#3} }
36790 \cs_new:Npn \__text_change_case:nnnn #1#2#3#4
36791 {
36792 \exp_not:e
36793 {
36794 \exp_args:Nee \__text_change_case_auxi:nnnn
36795 { \text_expand:n {#4} } {#3}
36796 {#1} {#2}
36797 }
36798 }
36799 \cs_new:Npn \__text_change_case_auxi:nnnn #1#2#3#4
36800 {
36801 \tl_if_blank:nTF {#2}
36802 { \__text_change_case_auxii:nnnn {#1} {#3} {#4} { } }
36803 {
36804 \exp_args:Ne \__text_change_case_bcp:nn
36805 { \text_bcp_parse:n {#2} } { {#1} {#3} {#4} }
36806 }
36807 }
36808 \cs_new:Npn \__text_change_case_bcp:nn #1#2
36809 { \__text_change_case_bcp:nnnnnnnn #1 {#2} }
36810 \cs_new:Npn \__text_change_case_bcp:nnnnnnnn #1#2#3#4#5#6#7#8
36811 {
36812 \tl_if_blank:nTF {#7}
36813 { \__text_change_case_auxii:nnnn #8 {#1} }
36814 {
36815 \__text_change_case_auxii:nnnnn #8 {#1} #7
36816 \q_recursion_tail \q_recursion_stop
36817 }
36818 }
36819 \cs_new:Npn \__text_change_case_auxii:nnnnn #1#2#3#4#5
36820 {
36821 \quark_if_recursion_tail_stop_do:nn {#5}
36822 { \__text_change_case_auxii:nnnn {#1} {#2} {#3} {#4} }
36823 \bool_lazy_or:nnT
36824 { \cs_if_exist_p:c { __text_change_case_ #2 _ #4 -x- #5 :nnnnn } }
36825 { \tl_if_exist_p:c { l__text_ #2 case_special_ #4 -x- #5 _tl } }
36826 {
36827 \use_i_delimit_by_q_recursion_stop:nw
36828 { \__text_change_case_auxii:nnnn {#1} {#2} {#3} { #4 -x- #5 } }
36829 }
36830 \__text_change_case_auxii:nnnnn {#1} {#2} {#3} {#4}
36831 }
36832 \cs_new:Npn \__text_change_case_auxii:nnnn #1#2#3#4
36833 {
36834 \group_align_safe_begin:
36835 \exp_args:Ne \__text_change_case_inner:nnnn
36836 {
36837 \__text_map_tokens:nnn {#1}
36838 { wordbreak } { \__text_change_case_exclude_words:nn {#2} }
36839 }
36840 {#2} {#3} {#4}
36841 \group_align_safe_end:
36842 }
36843 \cs_new:Npn \__text_change_case_exclude_words:nn #1#2
36844 {
36845 \tl_if_exist:cTF { l__text_ #1 case_exclude_ \tl_to_str:n {#2} _tl }
36846 { \exp_not:n { \__text_change_case_exclude_word:n {#2} } }
36847 { \exp_not:n {#2} }
36848 }
36849 \cs_new:Npn \__text_change_case_exclude_word:n #1 {#1}
36850 \cs_new:Npn \__text_change_case_inner:nnnn #1#2#3#4
36851 {
36852 \cs_if_exist_use:c { __text_change_case_boundary_ #2 _ #4 :Nnnnw }
36853 \__text_change_case_loop:nnnw {#2} {#3} {#4} #1
36854 \q__text_recursion_tail \q__text_recursion_stop
36855 \prg_break_point:Nn \__text_change_case_break: { }
36856 }
36857 \cs_new:Npn \__text_change_case_loop:nnnw #1#2#3#4 \q__text_recursion_stop
36858 {
36859 \tl_if_head_is_N_type:nTF {#4}
36860 { \__text_change_case_N_type:nnnN }
36861 {
36862 \tl_if_head_is_group:nTF {#4}
36863 { \use:c { __text_change_case_group_ #1 :nnnn } }
36864 { \__text_change_case_space:nnnw }
36865 }
36866 {#1} {#2} {#3} #4 \q__text_recursion_stop
36867 }
36868 \cs_new:Npn \__text_change_case_break:
36869 { \prg_map_break:Nn \__text_change_case_break: { } }
36870 \cs_new:Npn \__text_change_case_group_lower:nnnn #1#2#3#4
36871 {
36872 \exp_not:e
36873 { { \__text_change_case_inner:nnnn {#4} {#1} {#2} {#3} } }
36874 \__text_change_case_loop:nnnw {#1} {#2} {#3}
36875 }
36876 \cs_new_eq:NN \__text_change_case_group_upper:nnnn
36877 \__text_change_case_group_lower:nnnn
36878 \cs_new:Npn \__text_change_case_group_title:nnnn #1#2#3#4
36879 {
36880 \exp_not:e
36881 { { \__text_change_case_inner:nnnn {#4} {#1} {#2} {#3} } }
36882 \__text_change_case_skip:nnw {#2} {#3}
36883 }
36884 \use:e
36885 {
36886 \cs_new:Npn \exp_not:N \__text_change_case_space:nnnw #1#2#3 \c_space_tl
36887 }
36888 {
36889 \c_space_tl
36890 \cs_if_exist_use:cF { __text_change_case_space_ #2 :nnn }
36891 {
36892 \cs_if_exist_use:c { __text_change_case_boundary_ #1 _ #3 :Nnnnw }
36893 \__text_change_case_loop:nnnw
36894 }
36895 {#2} {#2} {#3}
36896 }
36897 \cs_new:Npn \__text_change_case_space_break:nnn #1#2#3
36898 { \__text_change_case_space_break:w \prg_do_nothing: }
36899 \cs_new:Npn \__text_change_case_space_break:w
36900 #1 \q__text_recursion_tail \q__text_recursion_stop
36901 {
36902 \__text_change_case_space_break_aux:w #1
36903 \__text_change_case_exclude_word:n \q__text_recursion_tail \q__text_recursion_stop
36904 }
36905 \cs_new:Npn \__text_change_case_space_break_aux:w #1 \__text_change_case_exclude_word:n #2
36906 {
36907 \exp_not:o {#1}
36908 \__text_if_q_recursion_tail_stop_do:nn {#2} { \__text_change_case_break: }
36909 \__text_change_case_space_break_aux:w \prg_do_nothing: #2
36910 }
36911 \cs_new:Npn \__text_change_case_N_type:nnnN #1#2#3#4
36912 {
36913 \__text_if_q_recursion_tail_stop_do:Nn #4
36914 { \__text_change_case_break: }
36915 \__text_change_case_N_type_aux:nnnN {#1} {#2} {#3} #4
36916 }
36917 \cs_new:Npn \__text_change_case_N_type_aux:nnnN #1#2#3#4
36918 {
36919 \exp_args:NV \__text_change_case_N_type:nnnnN
36920 \l_text_math_delims_tl {#1} {#2} {#3} #4
36921 }
36922 \cs_new:Npn \__text_change_case_N_type:nnnnN #1#2#3#4#5
36923 {
36924 \__text_change_case_math_search:nnnNNN {#2} {#3} {#4} #5 #1
36925 \q__text_recursion_tail \q__text_recursion_tail
36926 \q__text_recursion_stop
36927 }
36928 \cs_new:Npn \__text_change_case_math_search:nnnNNN #1#2#3#4#5#6
36929 {
36930 \__text_if_q_recursion_tail_stop_do:Nn #5
36931 { \__text_change_case_cs_check:nnnN {#1} {#2} {#3} #4 }
36932 \token_if_eq_meaning:NNTF #4 #5
36933 {
36934 \__text_use_i_delimit_by_q_recursion_stop:nw
36935 {
36936 \exp_not:n {#4}
36937 \__text_change_case_math_loop:nnnNw {#1} {#2} {#3} #6
36938 }
36939 }
36940 { \__text_change_case_math_search:nnnNNN {#1} {#2} {#3} #4 }
36941 }
36942 \cs_new:Npn \__text_change_case_math_loop:nnnNw #1#2#3#4#5 \q__text_recursion_stop
36943 {
36944 \tl_if_head_is_N_type:nTF {#5}
36945 { \__text_change_case_math_N_type:nnnNN }
36946 {
36947 \tl_if_head_is_group:nTF {#5}
36948 { \__text_change_case_math_group:nnnNn }
36949 { \__text_change_case_math_space:nnnNw }
36950 }
36951 {#1} {#2} {#3} #4 #5 \q__text_recursion_stop
36952 }
36953 \cs_new:Npn \__text_change_case_math_N_type:nnnNN #1#2#3#4#5
36954 {
36955 \__text_if_q_recursion_tail_stop_do:Nn #5
36956 { \__text_change_case_break: }
36957 \exp_not:n {#5}
36958 \token_if_eq_meaning:NNTF #5 #4
36959 { \__text_change_case_loop:nnnw {#1} {#2} {#3} }
36960 { \__text_change_case_math_loop:nnnNw {#1} {#2} {#3} #4 }
36961 }
36962 \cs_new:Npn \__text_change_case_math_group:nnnNn #1#2#3#4#5
36963 {
36964 \exp_not:n { {#5} }
36965 \__text_change_case_math_loop:nnnNw {#1} {#2} {#3} #4
36966 }
36967 \use:e
36968 {
36969 \cs_new:Npn \exp_not:N \__text_change_case_math_space:nnnNw #1#2#3#4
36970 \c_space_tl
36971 }
36972 {
36973 \c_space_tl
36974 \__text_change_case_math_loop:nnnNw {#1} {#2} {#3} #4
36975 }
36976 \cs_new:Npn \__text_change_case_cs_check:nnnN #1#2#3#4
36977 {
36978 \token_if_cs:NTF #4
36979 { \__text_change_case_exclude:nnnN {#1} {#2} {#3} }
36980 {
36981 \__text_codepoint_process:nN
36982 { \use:c { __text_change_case_custom_ #1 :nnnn } {#1} {#2} {#3} }
36983 }
36984 #4
36985 }
36986 \cs_new:Npn \__text_change_case_exclude:nnnN #1#2#3#4
36987 {
36988 \str_if_eq:nnTF {#4} { \__text_change_case_exclude_word:n }
36989 { \__text_change_case_exclude:nnnn {#1} {#2} {#3} }
36990 { \__text_change_case_exclude_aux:nnnN {#1} {#2} {#3} #4 }
36991 }
36992 \cs_new:Npn \__text_change_case_exclude_aux:nnnN #1#2#3#4
36993 {
36994 \exp_args:Ne \__text_change_case_exclude:nnnnN
36995 {
36996 \exp_not:V \l_text_math_arg_tl
36997 \exp_not:V \l_text_case_exclude_arg_tl
36998 }
36999 {#1} {#2} {#3} #4
37000 }
37001 \cs_new:Npn \__text_change_case_exclude:nnnn #1#2#3#4
37002 {
37003 \exp_not:n {#4}
37004 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37005 }
37006 \cs_new:Npn \__text_change_case_exclude:nnnnN #1#2#3#4#5
37007 {
37008 \__text_change_case_exclude:nnnNN {#2} {#3} {#4} #5 #1
37009 \q__text_recursion_tail \q__text_recursion_stop
37010 }
37011 \cs_new:Npn \__text_change_case_exclude:nnnNN #1#2#3#4#5
37012 {
37013 \__text_if_q_recursion_tail_stop_do:Nn #5
37014 { \__text_change_case_replace:nnnN {#1} {#2} {#3} #4 }
37015 \str_if_eq:nnTF {#4} {#5}
37016 {
37017 \__text_use_i_delimit_by_q_recursion_stop:nw
37018 { \__text_change_case_exclude:nnnNw {#1} {#2} {#3} #4 }
37019 }
37020 { \__text_change_case_exclude:nnnNN {#1} {#2} {#3} #4 }
37021 }
37022 \cs_new:Npn \__text_change_case_exclude:nnnNw #1#2#3#4#5#
37023 { \__text_change_case_exclude:nnnNnn {#1} {#2} {#3} {#4} {#5} }
37024 \cs_new:Npn \__text_change_case_exclude:nnnNnn #1#2#3#4#5#6
37025 {
37026 \tl_if_blank:nTF {#5}
37027 { \exp_not:n { #4 {#6} } }
37028 {
37029 \exp_not:e
37030 {
37031 \exp_not:N #4
37032 \__text_change_case_inner:nnnn {#5} {#1} {#2} {#3}
37033 {#6}
37034 }
37035 }
37036 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37037 }
37038 \cs_new:Npn \__text_change_case_replace:nnnN #1#2#3#4
37039 {
37040 \cs_if_exist:cTF { l__text_case_ \token_to_str:N #4 _tl }
37041 {
37042 \__text_change_case_replace:vnnn
37043 { l__text_case_ \token_to_str:N #4 _tl } {#1} {#2} {#3}
37044 }
37045 { \__text_change_case_switch:nnnN {#1} {#2} {#3} #4 }
37046 }
37047 \cs_new:Npn \__text_change_case_replace:nnnn #1#2#3#4
37048 { \__text_change_case_loop:nnnw {#2} {#3} {#4} #1 }
37049 \cs_generate_variant:Nn \__text_change_case_replace:nnnn { v }
37050 \cs_new:Npn \__text_change_case_switch:nnnN #1#2#3#4
37051 {
37052 \cs_if_eq:NNTF #4 \text_case_switch:nnnn
37053 { \use:c { __text_change_case_switch_ #1 :nnnNnnnn } }
37054 { \use:c { __text_change_case_letterlike_ #1 :nnnN } }
37055 {#1} {#2} {#3} #4
37056 }
37057 \cs_new:Npn \__text_change_case_switch_lower:nnnNnnnn #1#2#3#4#5#6#7#8
37058 {
37059 \exp_not:n {#7}
37060 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37061 }
37062 \cs_new:Npn \__text_change_case_switch_upper:nnnNnnnn #1#2#3#4#5#6#7#8
37063 {
37064 \exp_not:n {#6}
37065 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37066 }
37067 \cs_new:Npn \__text_change_case_switch_title:nnnNnnnn #1#2#3#4#5#6#7#8
37068 {
37069 \exp_not:n {#8}
37070 \__text_change_case_skip:nnw {#2} {#3}
37071 }
37072 \cs_new:Npn \__text_change_case_skip:nnw #1#2#3 \q__text_recursion_stop
37073 {
37074 \tl_if_head_is_N_type:nTF {#3}
37075 { \__text_change_case_skip_N_type:nnN }
37076 {
37077 \tl_if_head_is_group:nTF {#3}
37078 { \__text_change_case_skip_group:nnn }
37079 { \__text_change_case_skip_space:nnw }
37080 }
37081 {#1} {#2} #3 \q__text_recursion_stop
37082 }
37083 \cs_new:Npn \__text_change_case_skip_N_type:nnN #1#2#3
37084 {
37085 \__text_if_q_recursion_tail_stop_do:Nn #3
37086 { \__text_change_case_break: }
37087 \exp_not:n {#3}
37088 \__text_change_case_skip:nnw {#1} {#2}
37089 }
37090 \cs_new:Npn \__text_change_case_skip_group:nnn #1#2#3
37091 {
37092 \exp_not:n { {#3} }
37093 \__text_change_case_skip:nnw {#1} {#2}
37094 }
37095 \cs_new:Npn \__text_change_case_skip_space:nnw #1#2
37096 { \__text_change_case_space:nnnw {#1} {#1} {#2} }
37097 \cs_new:Npn \__text_change_case_letterlike_lower:nnnN #1#2#3#4
37098 { \__text_change_case_letterlike:nnnnnN {#1} {#1} {#1} {#2} {#3} #4 }
37099 \cs_new_eq:NN \__text_change_case_letterlike_upper:nnnN
37100 \__text_change_case_letterlike_lower:nnnN
37101 \cs_new:Npn \__text_change_case_letterlike_title:nnnN #1#2#3#4
37102 { \__text_change_case_letterlike:nnnnnN { upper } { end } {#1} {#2} {#3} #4 }
37103 \cs_new:Npn \__text_change_case_letterlike:nnnnnN #1#2#3#4#5#6
37104 {
37105 \cs_if_exist:cTF { c__text_ #1 case_ \token_to_str:N #6 _tl }
37106 {
37107 \exp_not:v
37108 { c__text_ #1 case_ \token_to_str:N #6 _tl }
37109 \use:c { __text_change_case_next_ #2 :nnn } {#2} {#4} {#5}
37110 }
37111 {
37112 \exp_not:n {#6}
37113 \cs_if_exist:cTF
37114 {
37115 c__text_
37116 \str_if_eq:nnTF {#1} { lower } { upper } { lower }
37117 case_ \token_to_str:N #6 _tl
37118 }
37119 { \use:c { __text_change_case_next_ #2 :nnn } {#2} {#4} {#5} }
37120 { \__text_change_case_loop:nnnw {#3} {#4} {#5} }
37121 }
37122 }
37123 \cs_new:Npn \__text_change_case_custom_lower:nnnn #1#2#3#4
37124 {
37125 \__text_change_case_custom:nnnnnn {#1} {#1} {#2} {#3} {#4}
37126 { \use:c { __text_change_case_codepoint_ #1 :nnnn } {#1} {#2} {#3} {#4} }
37127 }
37128 \cs_new_eq:NN \__text_change_case_custom_upper:nnnn
37129 \__text_change_case_custom_lower:nnnn
37130 \cs_new:Npn \__text_change_case_custom_title:nnnn #1#2#3#4
37131 {
37132 \__text_change_case_custom:nnnnnn { title } {#1} {#2} {#3} {#4}
37133 {
37134 \__text_change_case_custom:nnnnnn { upper } {#1} {#2} {#3} {#4}
37135 { \use:c { __text_change_case_codepoint_ #1 :nnnn } {#1} {#2} {#3} {#4} }
37136 }
37137 }
37138 \cs_new:Npn \__text_change_case_custom:nnnnnn #1#2#3#4#5#6
37139 {
37140 \tl_if_exist:cTF { l__text_ #1 case _ \tl_to_str:n {#5} _ #4 _tl }
37141 {
37142 \__text_change_case_replace:vnnn
37143 { l__text_ #1 case _ \tl_to_str:n {#5} _ #4 _tl } {#2} {#3} {#4}
37144 }
37145 {
37146 \tl_if_exist:cTF { l__text_ #1 case _ \tl_to_str:n {#5} _tl }
37147 {
37148 \__text_change_case_replace:vnnn
37149 { l__text_ #1 case _ \tl_to_str:n {#5} _tl } {#2} {#3} {#4}
37150 }
37151 {#6}
37152 }
37153 }
37154 \cs_new:Npn \__text_change_case_codepoint_lower:nnnn #1#2#3#4
37155 {
37156 \cs_if_exist_use:cF { __text_change_case_lower_ #3 :nnnnn }
37157 { \__text_change_case_lower_sigma:nnnnn }
37158 {#1} {#1} {#2} {#3} {#4}
37159 }
37160 \cs_new:Npn \__text_change_case_codepoint_upper:nnnn #1#2#3#4
37161 {
37162 \cs_if_exist_use:cF { __text_change_case_upper_ #3 :nnnnn }
37163 { \__text_change_case_codepoint:nnnnn }
37164 {#1} {#1} {#2} {#3} {#4}
37165 }
37166 \cs_new:Npn \__text_change_case_lower_sigma:nnnnn #1#2#3#4#5
37167 {
37168 \__text_codepoint_compare:nNnTF {#5} = { "03A3 }
37169 { \__text_change_case_lower_sigma:nnnnw {#2} }
37170 { \__text_change_case_codepoint:nnnnn {#1} {#2} }
37171 {#3} {#4} {#5}
37172 }
37173 \cs_new:Npn \__text_change_case_lower_sigma:nnnnw #1#2#3#4#5 \q__text_recursion_stop
37174 {
37175 \tl_if_head_is_N_type:nTF {#5}
37176 { \__text_change_case_lower_sigma:nnnnN {#4} }
37177 {
37178 \codepoint_generate:nn { "03C2 } { \__text_char_catcode:N #4 }
37179 \__text_change_case_loop:nnnw
37180 }
37181 {#1} {#2} {#3} #5 \q__text_recursion_stop
37182 }
37183 \cs_new:Npn \__text_change_case_lower_sigma:nnnnN #1#2#3#4#5
37184 {
37185 \bool_lazy_or:nnTF
37186 { \token_if_letter_p:N #5 }
37187 {
37188 \bool_lazy_and_p:nn
37189 { \token_if_active_p:N #5 }
37190 { \int_compare_p:nNn {`#5} > { "80 } }
37191 }
37192 { \codepoint_generate:nn { "03C3 } { \__text_char_catcode:N #1 } }
37193 { \codepoint_generate:nn { "03C2 } { \__text_char_catcode:N #1 } }
37194 \__text_change_case_loop:nnnw {#2} {#3} {#4} #5
37195 }
37196 \cs_new:Npn \__text_change_case_codepoint_title:nnnn #1#2#3#4
37197 {
37198 \bool_if:NTF \l_text_titlecase_check_letter_bool
37199 {
37200 \exp_args:Ne \__text_change_case_codepoint_title_auxi:nnnn
37201 {
37202 \codepoint_to_category:n
37203 { \__text_codepoint_from_chars:Nw #4 }
37204 }
37205 }
37206 { \__text_change_case_codepoint_title:nnn }
37207 {#2} {#3} {#4}
37208 }
37209 \cs_new:Npn \__text_change_case_codepoint_title_auxi:nnnn #1#2#3#4
37210 {
37211 \tl_if_head_eq_charcode:nNTF {#1} { L }
37212 { \__text_change_case_codepoint_title:nnn }
37213 { \__text_change_case_codepoint_title_auxii:nnnn { title } }
37214 {#2} {#3} {#4}
37215 }
37216 \cs_new:Npn \__text_change_case_codepoint_title:nnn #1#2#3
37217 { \__text_change_case_codepoint_title_auxii:nnnn { end } {#1} {#2} {#3} }
37218 \cs_new:Npn \__text_change_case_codepoint_title_auxii:nnnn #1#2#3#4
37219 {
37220 \cs_if_exist_use:cF { __text_change_case_title_ #3 :nnnnn }
37221 {
37222 \cs_if_exist_use:cF { __text_change_case_upper_ #3 :nnnnn }
37223 { \__text_change_case_codepoint:nnnnn }
37224 }
37225 { title } {#1} {#2} {#3} {#4}
37226 }
37227 \cs_new:Npn \__text_change_case_codepoint:nnnnn #1#2#3#4#5
37228 {
37229 \bool_lazy_and:nnTF
37230 { \tl_if_single_p:n {#5} }
37231 { \token_if_active_p:N #5 }
37232 { \exp_not:n {#5} }
37233 { \__text_change_case_codepoint:nn {#1} {#5} }
37234 \use:c { __text_change_case_next_ #2 :nnn } {#2} {#3} {#4}
37235 }
37236 \cs_new:Npn \__text_change_case_codepoint:nn #1#2
37237 {
37238 \__text_change_case_codepoint:fnn
37239 { \int_eval:n { \__text_codepoint_from_chars:Nw #2 } } {#1} {#2}
37240 }
37241 \cs_new:Npn \__text_change_case_codepoint:nnn #1#2#3
37242 {
37243 \exp_args:Ne \__text_change_case_codepoint_aux:nn
37244 { \__kernel_codepoint_case:nn { #2 case } {#1} } {#3}
37245 }
37246 \cs_generate_variant:Nn \__text_change_case_codepoint:nnn { f }
37247 \sys_if_engine_ptex:T
37248 {
37249 \cs_new_eq:NN \__text_change_case_codepoint_aux:nnn
37250 \__text_change_case_codepoint:nnn
37251 \cs_gset:Npn \__text_change_case_codepoint:nnn #1#2#3
37252 {
37253 \int_compare:nNnTF {#1} = { -1 }
37254 { \exp_not:n {#3} }
37255 { \__text_change_case_codepoint_aux:nnn {#1} {#2} {#3} }
37256 }
37257 }
37258 \cs_new:Npn \__text_change_case_codepoint_aux:nn #1#2
37259 {
37260 \use:e { \__text_change_case_codepoint_aux:nnnn #1 {#2} }
37261 }
37262 \cs_new:Npn \__text_change_case_codepoint_aux:nnnn #1#2#3#4
37263 {
37264 \__text_codepoint_compare:nNnTF {#4} = {#1}
37265 { \exp_not:n {#4} }
37266 {
37267 \codepoint_generate:nn {#1}
37268 { \__text_change_case_catcode:nn {#4} {#1} }
37269 \tl_if_blank:nF {#2}
37270 {
37271 \codepoint_generate:nn {#2}
37272 { \char_value_catcode:n {#2} }
37273 \tl_if_blank:nF {#3}
37274 {
37275 \codepoint_generate:nn {#3}
37276 { \char_value_catcode:n {#3} }
37277 }
37278 }
37279 }
37280 }
37281 \sys_if_engine_opentype:TF
37282 {
37283 \cs_new:Npn \__text_change_case_catcode:nn #1#2
37284 { \__text_char_catcode:N #1 }
37285 }
37286 {
37287 \cs_new:Npn \__text_change_case_catcode:nn #1#2
37288 {
37289 \__text_codepoint_compare:nNnTF {#1} < { "80 }
37290 { \__text_char_catcode:N #1 }
37291 {
37292 \int_compare:nNnTF {#2} < { "80 }
37293 { \char_value_catcode:n {#2} }
37294 { 13 }
37295 }
37296 }
37297 }
37298 \cs_new:Npn \__text_change_case_next_lower:nnn #1#2#3
37299 { \__text_change_case_loop:nnnw {#1} {#2} {#3} }
37300 \cs_new_eq:NN \__text_change_case_next_upper:nnn
37301 \__text_change_case_next_lower:nnn
37302 \cs_new_eq:NN \__text_change_case_next_title:nnn
37303 \__text_change_case_next_lower:nnn
37304 \cs_new:Npn \__text_change_case_next_end:nnn #1#2#3
37305 { \__text_change_case_skip:nnw {#2} {#3} }
37306 \cs_new_protected:Npn \text_declare_case_equivalent:Nn #1#2
37307 {
37308 \tl_clear_new:c { l__text_case_ \token_to_str:N #1 _tl }
37309 \tl_set:cn { l__text_case_ \token_to_str:N #1 _tl } {#2}
37310 }
37311 \cs_new_protected:Npn \text_declare_lowercase_mapping:nn #1#2
37312 { \__text_declare_case_mapping:nnn { lower } {#1} {#2} }
37313 \cs_new_protected:Npn \text_declare_titlecase_mapping:nn #1#2
37314 { \__text_declare_case_mapping:nnn { title } {#1} {#2} }
37315 \cs_new_protected:Npn \text_declare_uppercase_mapping:nn #1#2
37316 { \__text_declare_case_mapping:nnn { upper } {#1} {#2} }
37317 \cs_new_protected:Npn \__text_declare_case_mapping:nnn #1#2#3
37318 {
37319 \exp_args:Ne \__text_declare_case_mapping_aux:nnn
37320 { \codepoint_str_generate:n {#2} } {#1} {#3}
37321 }
37322 \cs_new_protected:Npn \__text_declare_case_mapping_aux:nnn #1#2#3
37323 {
37324 \tl_clear_new:c { l__text_ #2 case _ #1 _tl }
37325 \tl_set:cn { l__text_ #2 case _ #1 _ tl } {#3}
37326 }
37327 \cs_new_protected:Npn \text_declare_lowercase_mapping:nnn #1#2#3
37328 { \__text_declare_case_mapping:nnnn { lower } {#1} {#2} {#3} }
37329 \cs_new_protected:Npn \text_declare_titlecase_mapping:nnn #1#2#3
37330 { \__text_declare_case_mapping:nnnn { title } {#1} {#2} {#3} }
37331 \cs_new_protected:Npn \text_declare_uppercase_mapping:nnn #1#2#3
37332 { \__text_declare_case_mapping:nnnn { upper } {#1} {#2} {#3} }
37333 \cs_new_protected:Npn \__text_declare_case_mapping:nnnn #1#2#3#4
37334 {
37335 \exp_args:Ne \__text_declare_case_mapping_aux:nnnn
37336 { \codepoint_str_generate:n {#3} } {#1} {#2} {#4}
37337 }
37338 \cs_new_protected:Npn \__text_declare_case_mapping_aux:nnnn #1#2#3#4
37339 {
37340 \tl_clear_new:c { l__text_ #2 case _ #1 _ #3 _tl }
37341 \tl_set:cn { l__text_ #2 case _ #1 _ #3 _ tl } {#4}
37342 \tl_clear_new:c { l__text_ #2 case_special_ #3 _tl }
37343 }
37344 \cs_new_protected:Npn \text_declare_lowercase_exclusion:n #1
37345 { \__text_declare_case_exclusion:nn { lower } {#1} }
37346 \cs_new_protected:Npn \text_declare_titlecase_exclusion:n #1
37347 { \__text_declare_case_exclusion:nn { title } {#1} }
37348 \cs_new_protected:Npn \text_declare_uppercase_exclusion:n #1
37349 { \__text_declare_case_exclusion:nn { upper } {#1} }
37350 \cs_new_protected:Npn \__text_declare_case_exclusion:nn #1#2
37351 { \tl_clear_new:c { l__text_ #1 case_exclude_ \tl_to_str:n {#2} _tl } }
37352 \cs_new:Npn \text_case_switch:nnnn #1#2#3#4
37353 {
37354 \__text_case_switch_marker:
37355 #1
37356 }
37357 \cs_new:Npn \__text_case_switch_marker: { }
37358 \cs_new:Npn \__text_change_case_generate:n #1
37359 { \codepoint_generate:nn {#1} { \char_value_catcode:n {#1} } }
37360 \cs_new:cpn { __text_change_case_upper_de-x-eszett:nnnnn } #1#2#3#4#5
37361 {
37362 \__text_codepoint_compare:nNnTF {#5} = { "00DF }
37363 {
37364 \codepoint_generate:nn { "1E9E }
37365 { \__text_change_case_catcode:nn {#5} { "1E9E } }
37366 \use:c { __text_change_case_next_ #2 :nnn }
37367 {#2} {#3} {#4}
37368 }
37369 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
37370 }
37371 \cs_new_eq:cc { __text_change_case_upper_de-alt:nnnnn }
37372 { __text_change_case_upper_de-x-eszett:nnnnn }
37373 \cs_new:Npn \__text_change_case_upper_el:nnnnn #1#2#3#4#5
37374 {
37375 \bool_lazy_and:nnTF
37376 { \__text_change_case_if_greek_p:n {#5} }
37377 {
37378 ! \bool_lazy_or_p:nn
37379 { \__text_codepoint_compare_p:nNn {#5} = { "0374 } }
37380 { \__text_codepoint_compare_p:nNn {#5} = { "037E } }
37381 }
37382 {
37383 \__text_change_case_if_greek_spacing_diacritic:nTF {#5}
37384 {
37385 \exp_not:n {#5}
37386 \__text_change_case_loop:nnnw
37387 }
37388 {
37389 \exp_args:Ne \__text_change_case_upper_el:nnnn
37390 {
37391 \codepoint_to_nfd:n
37392 { \__text_codepoint_from_chars:Nw #5 }
37393 }
37394 }
37395 {#2} {#3} {#4}
37396 }
37397 {
37398 \__text_codepoint_compare:nNnTF {#5} = { "0345 }
37399 {
37400 \codepoint_generate:nn { "0399 }
37401 { \char_value_catcode:n { "0399 } }
37402 \__text_change_case_loop:nnnw {#2} {#3} {#4}
37403 }
37404 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
37405 }
37406 }
37407 \cs_new_eq:cN { __text_change_case_upper_el-x-iota:nnnnn }
37408 \__text_change_case_upper_el:nnnnn
37409 \cs_new:Npn \__text_change_case_upper_el:nnnn #1#2#3#4
37410 {
37411 \__text_codepoint_process:nN
37412 { \__text_change_case_upper_el:nnnnw {#2} {#3} {#4} } #1
37413 }
37414 \cs_new:Npn \__text_change_case_upper_el:nnnnw #1#2#3#4#5 \q__text_recursion_stop
37415 {
37416 \tl_if_head_is_N_type:nTF {#5}
37417 { \__text_change_case_upper_el:nnnnN {#4} }
37418 {
37419 \__text_change_case_codepoint:nn { upper } {#4}
37420 \__text_change_case_loop:nnnw
37421 }
37422 {#1} {#2} {#3} #5 \q__text_recursion_stop
37423 }
37424 \cs_new:Npn \__text_change_case_upper_el:nnnnN #1#2#3#4#5
37425 {
37426 \token_if_cs:NTF #5
37427 {
37428 \__text_change_case_codepoint:nn { upper } {#1}
37429 \__text_change_case_loop:nnnw {#2} {#3} {#4} #5
37430 }
37431 {
37432 \__text_change_case_if_takes_ypogegrammeni:nTF {#1}
37433 {
37434 \__text_change_case_upper_el_ypogegrammeni:nnnnnnw
37435 {#1} {#2} {#3} {#4} { } { } #5
37436 }
37437 { \__text_change_case_upper_el_aux:nnnnN {#1} {#2} {#3} {#4} #5 }
37438 }
37439 }
37440 \cs_new:Npn \__text_change_case_upper_el_ypogegrammeni:nnnnnnw
37441 #1#2#3#4#5#6#7 \q__text_recursion_stop
37442 {
37443 \tl_if_head_is_N_type:nTF {#7}
37444 {
37445 \__text_change_case_upper_el_ypogegrammeni:nnnnnnN
37446 {#1} {#2} {#3} {#4} {#5} {#6}
37447 }
37448 { \__text_change_case_upper_el_aux:nnnnN {#1} {#2} {#3} {#4} #5#6 }
37449 #7 \q__text_recursion_stop
37450 }
37451 \cs_new:Npn \__text_change_case_upper_el_ypogegrammeni:nnnnnnN #1#2#3#4#5#6#7
37452 {
37453 \token_if_cs:NTF #7
37454 { \__text_change_case_upper_el_aux:nnnnN {#1} {#2} {#3} {#4} #5#6 }
37455 {
37456 \__text_codepoint_process:nN
37457 {
37458 \__text_change_case_upper_el_ypogegrammeni:nnnnnnn
37459 {#1} {#2} {#3} {#4} {#5} {#6}
37460 }
37461 }
37462 #7
37463 }
37464 \cs_new:Npn \__text_change_case_upper_el_ypogegrammeni:nnnnnnn #1#2#3#4#5#6#7
37465 {
37466 \__text_codepoint_compare:nNnTF {#7} = { "0345 }
37467 {
37468 \__text_change_case_upper_el_ypogegrammeni:nnnnnnw
37469 {#1} {#2} {#3} {#4} {#5} {#7}
37470 }
37471 {
37472 \bool_lazy_or:nnTF
37473 { \__text_change_case_if_greek_accent_p:n {#7} }
37474 { \__text_change_case_if_greek_breathing_p:n {#7} }
37475 {
37476 \__text_change_case_upper_el_ypogegrammeni:nnnnnnw
37477 {#1} {#2} {#3} {#4} {#5#7} {#6}
37478 }
37479 { \__text_change_case_upper_el_aux:nnnnN {#1} {#2} {#3} {#4} #5#6 #7 }
37480 }
37481 }
37482 \cs_new:Npn \__text_change_case_upper_el_aux:nnnnN #1#2#3#4#5
37483 {
37484 \__text_codepoint_process:nN
37485 { \__text_change_case_upper_el_aux:nnnnn {#1} {#2} {#3} {#4} } #5
37486 }
37487 \cs_new:Npn \__text_change_case_upper_el_aux:nnnnn #1#2#3#4#5
37488 {
37489 \__text_codepoint_compare:nNnTF {#5} = { "0308 }
37490 { \__text_change_case_upper_el_dialytika:nnnn {#2} {#3} {#4} {#1} }
37491 {
37492 \__text_change_case_if_greek_accent:nTF {#5}
37493 { \__text_change_case_upper_el_hiatus:nnnnw {#2} {#3} {#4} {#1} }
37494 {
37495 \__text_change_case_if_greek_breathing:nTF {#5}
37496 { \__text_change_case_upper_el:nnnn {#1} {#2} {#3} {#4} }
37497 {
37498 \__text_codepoint_compare:nNnTF {#5} = { "0345 }
37499 {
37500 \use:c { __text_change_case_upper_ #4 _ypogegrammeni:n } {#1}
37501 \__text_change_case_loop:nnnw {#2} {#3} {#4}
37502 }
37503 {
37504 \__text_change_case_if_greek_stress:nTF {#5}
37505 {
37506 \__text_change_case_upper_el_stress:nn {#1} {#5}
37507 \__text_change_case_loop:nnnw {#2} {#3} {#4}
37508 }
37509 {
37510 \__text_change_case_codepoint:nn { upper } {#1}
37511 \__text_change_case_loop:nnnw {#2} {#3} {#4} #5
37512 }
37513 }
37514 }
37515 }
37516 }
37517 }
37518 \cs_new:Npn \__text_change_case_upper_el_dialytika:nnnn #1#2#3#4
37519 {
37520 \__text_change_case_if_takes_dialytika:nTF {#4}
37521 { \__text_change_case_upper_el_dialytika:n {#4} }
37522 { \__text_change_case_codepoint:nn { upper } {#4} }
37523 \__text_change_case_upper_el_gobble:nnnw {#1} {#2} {#3}
37524 }
37525 \cs_new:Npn \__text_change_case_upper_el_dialytika:n #1
37526 {
37527 \bool_lazy_or:nnTF
37528 { \__text_codepoint_compare_p:nNn {#1} = { "0399 } }
37529 { \__text_codepoint_compare_p:nNn {#1} = { "03B9 } }
37530 {
37531 \codepoint_generate:nn { "03AA }
37532 { \__text_change_case_catcode:nn {#1} { "03AA } }
37533 }
37534 {
37535 \codepoint_generate:nn { "03AB }
37536 { \__text_change_case_catcode:nn {#1} { "03AB } }
37537 }
37538 }
37539 \cs_new:Npn \__text_change_case_upper_el_hiatus:nnnnw
37540 #1#2#3#4#5 \q__text_recursion_stop
37541 {
37542 \tl_if_head_is_N_type:nTF {#5}
37543 { \__text_change_case_upper_el_hiatus:nnnnN {#4} }
37544 {
37545 \__text_change_case_codepoint:nn { upper } {#4}
37546 \__text_change_case_loop:nnnw
37547 }
37548 {#1} {#2} {#3} #5 \q__text_recursion_stop
37549 }
37550 \cs_new:Npn \__text_change_case_upper_el_hiatus:nnnnN #1#2#3#4#5
37551 {
37552 \token_if_cs:NTF #5
37553 {
37554 \__text_change_case_codepoint:nn { upper } {#1}
37555 \__text_change_case_loop:nnnw {#2} {#3} {#4} #5
37556 }
37557 {
37558 \__text_codepoint_process:nN
37559 { \__text_change_case_upper_el_hiatus:nnnnn {#1} {#2} {#3} {#4} } #5
37560 }
37561 }
37562 \cs_new:Npn \__text_change_case_upper_el_hiatus:nnnnn #1#2#3#4#5
37563 {
37564 \__text_change_case_if_takes_dialytika:nTF {#5}
37565 {
37566 \__text_change_case_codepoint:nn { upper } {#1}
37567 \__text_change_case_upper_el_dialytika:n {#5}
37568 \__text_change_case_upper_el_gobble:nnnw {#2} {#3} {#4}
37569 }
37570 { \__text_change_case_upper_el:nnnn {#1} {#2} {#3} {#4} #5 }
37571 }
37572 \cs_new:Npn \__text_change_case_upper_el_ypogegrammeni:n #1
37573 {
37574 \exp_args:Ne \__text_change_case_generate:n
37575 {
37576 \int_case:nn
37577 { \__text_codepoint_from_chars:Nw #1 }
37578 {
37579 { "0391 } { "1FBC }
37580 { "03B1 } { "1FBC }
37581 { "0397 } { "1FCC }
37582 { "03B7 } { "1FCC }
37583 { "03A9 } { "1FFC }
37584 { "03C9 } { "1FFC }
37585 }
37586 }
37587 }
37588 \cs_new:cpn { __text_change_case_upper_el-x-iota_ypogegrammeni:n } #1
37589 {
37590 \__text_change_case_codepoint:nn { upper } {#1}
37591 \codepoint_generate:nn { "0399 }
37592 { \char_value_catcode:n { "0399 } }
37593 }
37594 \cs_new:Npn \__text_change_case_upper_el_stress:nn #1#2
37595 {
37596 \exp_args:Ne \__text_change_case_generate:n
37597 {
37598 \int_case:nn
37599 { \__text_codepoint_from_chars:Nw #2 }
37600 {
37601 { "0304 }
37602 {
37603 \int_case:nn { \__text_codepoint_from_chars:Nw #1 }
37604 {
37605 { "0391 } { "1FB9 }
37606 { "03B1 } { "1FB9 }
37607 { "0399 } { "1FD9 }
37608 { "03B9 } { "1FD9 }
37609 { "03A5 } { "1FE9 }
37610 { "03C5 } { "1FE9 }
37611 }
37612 }
37613 { "0306 }
37614 {
37615 \int_case:nn { \__text_codepoint_from_chars:Nw #1 }
37616 {
37617 { "0391 } { "1FB8 }
37618 { "03B1 } { "1FB8 }
37619 { "0399 } { "1FD8 }
37620 { "03B9 } { "1FD8 }
37621 { "03A5 } { "1FE8 }
37622 { "03C5 } { "1FE8 }
37623 }
37624 }
37625 }
37626 }
37627 }
37628 \cs_new:Npn \__text_change_case_upper_el_gobble:nnnw
37629 #1#2#3#4 \q__text_recursion_stop
37630 {
37631 \tl_if_head_is_N_type:nTF {#4}
37632 { \__text_change_case_upper_el_gobble:nnnN }
37633 { \__text_change_case_loop:nnnw }
37634 {#1} {#2} {#3} #4 \q__text_recursion_stop
37635 }
37636 \cs_new:Npn \__text_change_case_upper_el_gobble:nnnN #1#2#3#4
37637 {
37638 \token_if_cs:NTF #4
37639 { \__text_change_case_loop:nnnw {#1} {#2} {#3} }
37640 {
37641 \__text_codepoint_process:nN
37642 { \__text_change_case_upper_el_gobble:nnnn {#1} {#2} {#3} }
37643 }
37644 #4
37645 }
37646 \cs_new:Npn \__text_change_case_upper_el_gobble:nnnn #1#2#3#4
37647 {
37648 \bool_lazy_or:nnTF
37649 { \__text_change_case_if_greek_accent_p:n {#4} }
37650 { \__text_change_case_if_greek_breathing_p:n {#4} }
37651 { \__text_change_case_upper_el_gobble:nnnw {#1} {#2} {#3} }
37652 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37653 }
37654 \prg_new_conditional:Npnn \__text_change_case_if_greek:n #1 { p , TF }
37655 {
37656 \exp_args:Nf \__text_change_case_if_greek:n
37657 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37658 }
37659 \cs_new:Npn \__text_change_case_if_greek:n #1
37660 {
37661 \if_int_compare:w #1 < "0370 \exp_stop_f:
37662 \prg_return_false:
37663 \else:
37664 \if_int_compare:w #1 > "03FF \exp_stop_f:
37665 \if_int_compare:w #1 < "1F00 \exp_stop_f:
37666 \prg_return_false:
37667 \else:
37668 \if_int_compare:w #1 > "1FFF \exp_stop_f:
37669 \if_int_compare:w #1 = "2126 \exp_stop_f:
37670 \prg_return_true:
37671 \else:
37672 \prg_return_false:
37673 \fi:
37674 \else:
37675 \prg_return_true:
37676 \fi:
37677 \fi:
37678 \else:
37679 \prg_return_true:
37680 \fi:
37681 \fi:
37682 }
37683 \prg_new_conditional:Npnn \__text_change_case_if_greek_accent:n #1 { TF , p }
37684 {
37685 \exp_args:Nf \__text_change_case_if_greek_accent:n
37686 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37687 }
37688 \cs_new:Npn \__text_change_case_if_greek_accent:n #1
37689 {
37690 \if_int_compare:w #1 = "0300 \exp_stop_f:
37691 \prg_return_true:
37692 \else:
37693 \if_int_compare:w #1 = "0301 \exp_stop_f:
37694 \prg_return_true:
37695 \else:
37696 \if_int_compare:w #1 = "0342 \exp_stop_f:
37697 \prg_return_true:
37698 \else:
37699 \if_int_compare:w #1 = "0302 \exp_stop_f:
37700 \prg_return_true:
37701 \else:
37702 \if_int_compare:w #1 = "0303 \exp_stop_f:
37703 \prg_return_true:
37704 \else:
37705 \if_int_compare:w #1 = "0311 \exp_stop_f:
37706 \prg_return_true:
37707 \else:
37708 \prg_return_false:
37709 \fi:
37710 \fi:
37711 \fi:
37712 \fi:
37713 \fi:
37714 \fi:
37715 }
37716 \prg_new_conditional:Npnn \__text_change_case_if_greek_spacing_diacritic:n
37717 #1 { TF }
37718 {
37719 \exp_args:Nf \__text_change_case_if_greek_spacing_diacritic:n
37720 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37721 }
37722 \cs_new:Npn \__text_change_case_if_greek_spacing_diacritic:n #1
37723 {
37724 \if_int_compare:w #1 < "1FBD \exp_stop_f:
37725 \if_int_compare:w #1 = "037A \exp_stop_f:
37726 \prg_return_true:
37727 \else:
37728 \prg_return_false:
37729 \fi:
37730 \else:
37731 \if_int_compare:w #1 = "1FBD \exp_stop_f:
37732 \prg_return_true:
37733 \else:
37734 \if_int_compare:w #1 = "1FBF \exp_stop_f:
37735 \prg_return_true:
37736 \else:
37737 \if_int_compare:w #1 = "1FC0 \exp_stop_f:
37738 \prg_return_true:
37739 \else:
37740 \if_int_compare:w #1 = "1FC1 \exp_stop_f:
37741 \prg_return_true:
37742 \else:
37743 \if_int_compare:w #1 = "1FCD \exp_stop_f:
37744 \prg_return_true:
37745 \else:
37746 \if_int_compare:w #1 = "1FCE \exp_stop_f:
37747 \prg_return_true:
37748 \else:
37749 \if_int_compare:w #1 = "1FCF \exp_stop_f:
37750 \prg_return_true:
37751 \else:
37752 \if_int_compare:w #1 = "1FDD \exp_stop_f:
37753 \prg_return_true:
37754 \else:
37755 \if_int_compare:w #1 = "1FDE \exp_stop_f:
37756 \prg_return_true:
37757 \else:
37758 \if_int_compare:w #1 = "1FDF \exp_stop_f:
37759 \prg_return_true:
37760 \else:
37761 \if_int_compare:w #1 = "1FED \exp_stop_f:
37762 \prg_return_true:
37763 \else:
37764 \if_int_compare:w #1 = "1FEE \exp_stop_f:
37765 \prg_return_true:
37766 \else:
37767 \if_int_compare:w #1 = "1FEF \exp_stop_f:
37768 \prg_return_true:
37769 \else:
37770 \if_int_compare:w #1 = "1FFD \exp_stop_f:
37771 \prg_return_true:
37772 \else:
37773 \if_int_compare:w #1 = "1FFE \exp_stop_f:
37774 \prg_return_true:
37775 \else:
37776 \prg_return_false:
37777 \fi:
37778 \fi:
37779 \fi:
37780 \fi:
37781 \fi:
37782 \fi:
37783 \fi:
37784 \fi:
37785 \fi:
37786 \fi:
37787 \fi:
37788 \fi:
37789 \fi:
37790 \fi:
37791 \fi:
37792 \fi:
37793 }
37794 \prg_new_conditional:Npnn \__text_change_case_if_greek_breathing:n
37795 #1 { TF , p }
37796 {
37797 \exp_args:Nf \__text_change_case_if_greek_breathing:n
37798 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37799 }
37800 \cs_new:Npn \__text_change_case_if_greek_breathing:n #1
37801 {
37802 \if_int_compare:w #1 = "0313 \exp_stop_f:
37803 \prg_return_true:
37804 \else:
37805 \if_int_compare:w #1 = "0314 \exp_stop_f:
37806 \prg_return_true:
37807 \else:
37808 \prg_return_false:
37809 \fi:
37810 \fi:
37811 }
37812 \prg_new_conditional:Npnn \__text_change_case_if_greek_stress:n
37813 #1 { TF , p }
37814 {
37815 \exp_args:Nf \__text_change_case_if_greek_stress:n
37816 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37817 }
37818 \cs_new:Npn \__text_change_case_if_greek_stress:n #1
37819 {
37820 \if_int_compare:w #1 = "0304 \exp_stop_f:
37821 \prg_return_true:
37822 \else:
37823 \if_int_compare:w #1 = "0306 \exp_stop_f:
37824 \prg_return_true:
37825 \else:
37826 \prg_return_false:
37827 \fi:
37828 \fi:
37829 }
37830 \prg_new_conditional:Npnn \__text_change_case_if_takes_dialytika:n #1 { TF }
37831 {
37832 \exp_args:Nf \__text_change_case_if_takes_dialytika:n
37833 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37834 }
37835 \cs_new:Npn \__text_change_case_if_takes_dialytika:n #1
37836 {
37837 \if_int_compare:w #1 = "0399 \exp_stop_f:
37838 \prg_return_true:
37839 \else:
37840 \if_int_compare:w #1 = "03B9 \exp_stop_f:
37841 \prg_return_true:
37842 \else:
37843 \if_int_compare:w #1 = "03A5 \exp_stop_f:
37844 \prg_return_true:
37845 \else:
37846 \if_int_compare:w #1 = "03C5 \exp_stop_f:
37847 \prg_return_true:
37848 \else:
37849 \prg_return_false:
37850 \fi:
37851 \fi:
37852 \fi:
37853 \fi:
37854 }
37855 \prg_new_conditional:Npnn \__text_change_case_if_takes_ypogegrammeni:n #1 { TF }
37856 {
37857 \exp_args:Nf \__text_change_case_if_takes_ypogegrammeni:n
37858 { \int_eval:n { \__text_codepoint_from_chars:Nw #1 } }
37859 }
37860 \cs_new:Npn \__text_change_case_if_takes_ypogegrammeni:n #1
37861 {
37862 \if_int_compare:w #1 = "03B1 \exp_stop_f:
37863 \prg_return_true:
37864 \else:
37865 \if_int_compare:w #1 = "03B7 \exp_stop_f:
37866 \prg_return_true:
37867 \else:
37868 \if_int_compare:w #1 = "03C9 \exp_stop_f:
37869 \prg_return_true:
37870 \else:
37871 \prg_return_false:
37872 \fi:
37873 \fi:
37874 \fi:
37875 }
37876 \cs_new:Npn \__text_change_case_boundary_upper_el:Nnnnw
37877 #1#2#3#4#5 \q__text_recursion_stop
37878 {
37879 \tl_if_head_is_N_type:nTF {#5}
37880 { \__text_change_case_boundary_upper_el:nnnN }
37881 { \__text_change_case_loop:nnnw }
37882 {#2} {#3} {#4} #5 \q__text_recursion_stop
37883 }
37884 \cs_new_eq:cN { __text_change_case_boundary_upper_el-x-iota:Nnnnw }
37885 \__text_change_case_boundary_upper_el:Nnnnw
37886 \cs_new:Npn \__text_change_case_boundary_upper_el:nnnN #1#2#3#4
37887 {
37888 \token_if_cs:NTF #4
37889 { \__text_change_case_loop:nnnw {#1} {#2} {#3} }
37890 {
37891 \__text_codepoint_process:nN
37892 { \__text_change_case_boundary_upper_el:nnnn {#1} {#2} {#3} }
37893 }
37894 #4
37895 }
37896 \cs_new:Npn \__text_change_case_boundary_upper_el:nnnn #1#2#3#4
37897 {
37898 \bool_lazy_any:nTF
37899 {
37900 { \__text_codepoint_compare_p:nNn {#4} = { "0389 } }
37901 { \__text_codepoint_compare_p:nNn {#4} = { "03AE } }
37902 { \__text_codepoint_compare_p:nNn {#4} = { "1F22 } }
37903 { \__text_codepoint_compare_p:nNn {#4} = { "1F2A } }
37904 }
37905 { \__text_change_case_boundary_upper_el:nnnnw {#1} {#2} {#3} {#4} }
37906 { \__text_change_case_breathing:nnnn {#1} {#2} {#3} {#4} }
37907 }
37908 \cs_new:Npn \__text_change_case_boundary_upper_el:nnnnw
37909 #1#2#3#4#5 \q__text_recursion_stop
37910 {
37911 \tl_if_head_is_N_type:nTF {#5}
37912 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37913 {
37914 \codepoint_generate:nn { "0389 }
37915 { \__text_change_case_catcode:nn {#4} { "0389 } }
37916 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37917 }
37918 #5 \q__text_recursion_stop
37919 }
37920 \cs_new:Npn \__text_change_case_breathing:nnnn #1#2#3#4
37921 {
37922 \__text_change_case_if_greek:nTF {#4}
37923 {
37924 \exp_args:Ne \__text_change_case_breathing:nnnnn
37925 {
37926 \codepoint_to_nfd:n
37927 { \__text_codepoint_from_chars:Nw #4 }
37928 }
37929 {#1} {#2} {#3} {#4}
37930 }
37931 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37932 }
37933 \cs_new:Npn \__text_change_case_breathing:nnnnn #1#2#3#4#5
37934 {
37935 \__text_codepoint_process:nN
37936 { \__text_change_case_breathing:nnnnnw {#2} {#3} {#4} {#5} }
37937 #1 \q_mark
37938 }
37939 \cs_new:Npn \__text_change_case_breathing:nnnnnw #1#2#3#4#5#6 \q_mark
37940 {
37941 \tl_if_blank:nTF {#6}
37942 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37943 {
37944 \__text_codepoint_process:nN
37945 { \__text_change_case_breathing:nnnnnnw {#1} {#2} {#3} {#4} {#5} }
37946 #6 \q_mark
37947 }
37948 }
37949 \cs_new:Npn \__text_change_case_breathing:nnnnnnw #1#2#3#4#5#6#7 \q_mark
37950 {
37951 \tl_if_blank:nTF {#7}
37952 {
37953 \__text_change_case_breathing_aux:nnnnnn
37954 {#1} {#2} {#3} {#4} {#5} {#6}
37955 }
37956 {
37957 \__text_codepoint_process:nN
37958 { \__text_change_case_breathing:nnnnnnw {#1} {#2} {#3} {#4} {#5} }
37959 #7 \q_mark
37960 }
37961 }
37962 \cs_new:Npn \__text_change_case_breathing_aux:nnnnnn #1#2#3#4#5#6
37963 {
37964 \bool_lazy_or:nnTF
37965 { \__text_codepoint_compare_p:nNn {#6} = { "0313 } }
37966 { \__text_codepoint_compare_p:nNn {#6} = { "0314 } }
37967 { \__text_change_case_breathing_aux:nnnnw {#1} {#2} {#3} {#5} }
37968 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37969 }
37970 \cs_new:Npn \__text_change_case_breathing_aux:nnnnw #1#2#3#4#5
37971 \q__text_recursion_stop
37972 {
37973 \__text_change_case_codepoint:nn { upper } {#4}
37974 \tl_if_head_is_N_type:nTF {#5}
37975 { \__text_change_case_breathing_aux:nnnN }
37976 { \__text_change_case_loop:nnnw }
37977 {#1} {#2} {#3} #5 \q__text_recursion_stop
37978 }
37979 \cs_new:Npn \__text_change_case_breathing_aux:nnnN #1#2#3#4
37980 {
37981 \__text_if_q_recursion_tail_stop_do:Nn #4
37982 { \__text_change_case_break: }
37983 \__text_codepoint_process:nN
37984 { \__text_change_case_breathing_dialytika:nnnn {#1} {#2} {#3} } #4
37985 }
37986 \cs_new:Npn \__text_change_case_breathing_dialytika:nnnn #1#2#3#4
37987 {
37988 \__text_change_case_if_takes_dialytika:nTF {#4}
37989 {
37990 \__text_change_case_upper_el_dialytika:n {#4}
37991 \__text_change_case_loop:nnnw {#1} {#2} {#3}
37992 }
37993 { \__text_change_case_loop:nnnw {#1} {#2} {#3} #4 }
37994 }
37995 \cs_new:Npn \__text_change_case_title_el:nnnnn #1#2#3#4#5
37996 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
37997 \cs_new:Npn \__text_change_case_upper_hy:nnnnn #1#2#3#4#5
37998 {
37999 \__text_codepoint_compare:nNnTF {#5} = { "0587 }
38000 {
38001 \codepoint_generate:nn { "0535 }
38002 { \__text_change_case_catcode:nn {#5} { "0535 } }
38003 \codepoint_generate:nn { "054E }
38004 { \__text_change_case_catcode:nn {#5} { "054E } }
38005 \use:c { __text_change_case_next_ #2 :nnn }
38006 {#2} {#3} {#4}
38007 }
38008 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38009 }
38010 \cs_new:Npn \__text_change_case_title_hy:nnnnn #1#2#3#4#5
38011 {
38012 \__text_codepoint_compare:nNnTF {#5} = { "0587 }
38013 {
38014 \codepoint_generate:nn { "0535 }
38015 { \__text_change_case_catcode:nn {#5} { "0535 } }
38016 \codepoint_generate:nn { "057E }
38017 { \__text_change_case_catcode:nn {#5} { "057E } }
38018 \use:c { __text_change_case_next_ #2 :nnn }
38019 {#2} {#3} {#4}
38020 }
38021 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38022 }
38023 \cs_new:cpn { __text_change_case_upper_hy-x-yiwn:nnnnn } #1#2#3#4#5
38024 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38025 \cs_new_eq:cc { __text_change_case_title_hy-x-yiwn:nnnnn }
38026 { __text_change_case_upper_hy-x-yiwn:nnnnn }
38027 \cs_new:cpn { __text_change_case_lower_la-x-medieval:nnnnn } #1#2#3#4#5
38028 {
38029 \__text_codepoint_compare:nNnTF {#5} = { "0056 }
38030 {
38031 \char_generate:nn { "0075 } { \__text_char_catcode:N #5 }
38032 \use:c { __text_change_case_next_ #2 :nnn }
38033 {#2} {#3} {#4}
38034 }
38035 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38036 }
38037 \cs_new:cpn { __text_change_case_upper_la-x-medieval:nnnnn } #1#2#3#4#5
38038 {
38039 \__text_codepoint_compare:nNnTF {#5} = { "0075 }
38040 {
38041 \char_generate:nn { "0056 } { \__text_char_catcode:N #5 }
38042 \use:c { __text_change_case_next_ #2 :nnn }
38043 {#2} {#3} {#4}
38044 }
38045 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38046 }
38047 \cs_new:Npn \__text_change_case_lower_lt:nnnnn #1#2#3#4#5
38048 {
38049 \exp_args:Ne \__text_change_case_lower_lt_auxi:nnnnn
38050 {
38051 \int_case:nn { \__text_codepoint_from_chars:Nw #5 }
38052 {
38053 { "00CC } { "0300 }
38054 { "00CD } { "0301 }
38055 { "0128 } { "0303 }
38056 }
38057 }
38058 {#2} {#3} {#4} {#5}
38059 }
38060 \cs_new:Npn \__text_change_case_lower_lt_auxi:nnnnn #1#2#3#4#5
38061 {
38062 \tl_if_blank:nTF {#1}
38063 {
38064 \exp_args:Ne \__text_change_case_lower_lt_auxii:nnnnn
38065 {
38066 \int_case:nn { \__text_codepoint_from_chars:Nw #5 }
38067 {
38068 { "0049 } { "0069 }
38069 { "004A } { "006A }
38070 { "012E } { "012F }
38071 }
38072 }
38073 {#2} {#3} {#4} {#5}
38074 }
38075 {
38076 \codepoint_generate:nn { "0069 }
38077 { \__text_change_case_catcode:nn {#5} { "0069 } }
38078 \codepoint_generate:nn { "0307 }
38079 { \__text_change_case_catcode:nn {#5} { "0307 } }
38080 \codepoint_generate:nn {#1}
38081 { \__text_change_case_catcode:nn {#5} {#1} }
38082 \__text_change_case_loop:nnnw {#2} {#3} {#4}
38083 }
38084 }
38085 \cs_new:Npn \__text_change_case_lower_lt_auxii:nnnnn #1#2#3#4#5
38086 {
38087 \tl_if_blank:nTF {#1}
38088 { \__text_change_case_codepoint:nnnnn {#2} {#2} {#3} {#4} {#5} }
38089 {
38090 \codepoint_generate:nn {#1}
38091 { \__text_change_case_catcode:nn {#5} {#1} }
38092 \__text_change_case_lower_lt:nnnw {#2} {#3} {#4}
38093 }
38094 }
38095 \cs_new:Npn \__text_change_case_lower_lt:nnnw #1#2#3#4 \q__text_recursion_stop
38096 {
38097 \tl_if_head_is_N_type:nTF {#4}
38098 { \__text_change_case_lower_lt:nnnN }
38099 { \__text_change_case_loop:nnnw }
38100 {#1} {#2} {#3} #4 \q__text_recursion_stop
38101 }
38102 \cs_new:Npn \__text_change_case_lower_lt:nnnN #1#2#3#4
38103 {
38104 \__text_codepoint_process:nN
38105 { \__text_change_case_lower_lt:nnnn {#1} {#2} {#3} } #4
38106 }
38107 \cs_new:Npn \__text_change_case_lower_lt:nnnn #1#2#3#4
38108 {
38109 \bool_lazy_and:nnT
38110 {
38111 \bool_lazy_or_p:nn
38112 { ! \tl_if_single_p:n {#4} }
38113 { ! \token_if_cs_p:N #4 }
38114 }
38115 {
38116 \bool_lazy_any_p:n
38117 {
38118 { \__text_codepoint_compare_p:nNn {#4} = { "0300 } }
38119 { \__text_codepoint_compare_p:nNn {#4} = { "0301 } }
38120 { \__text_codepoint_compare_p:nNn {#4} = { "0303 } }
38121 }
38122 }
38123 {
38124 \codepoint_generate:nn { "0307 }
38125 { \__text_change_case_catcode:nn {#4} { "0307 } }
38126 }
38127 \__text_change_case_loop:nnnw {#1} {#2} {#3} #4
38128 }
38129 \cs_new:Npn \__text_change_case_upper_lt:nnnnn #1#2#3#4#5
38130 {
38131 \exp_args:Ne \__text_change_case_upper_lt_aux:nnnnn
38132 {
38133 \int_case:nn { \__text_codepoint_from_chars:Nw #5 }
38134 {
38135 { "0069 } { "0049 }
38136 { "006A } { "004A }
38137 { "012F } { "012E }
38138 }
38139 }
38140 {#2} {#3} {#4} {#5}
38141 }
38142 \cs_new:Npn \__text_change_case_upper_lt_aux:nnnnn #1#2#3#4#5
38143 {
38144 \tl_if_blank:nTF {#1}
38145 { \__text_change_case_codepoint:nnnnn { upper } {#2} {#3} {#4} {#5} }
38146 {
38147 \codepoint_generate:nn {#1}
38148 { \__text_change_case_catcode:nn {#5} {#1} }
38149 \__text_change_case_upper_lt:nnnw {#2} {#3} {#4}
38150 }
38151 }
38152 \cs_new:Npn \__text_change_case_upper_lt:nnnw #1#2#3#4 \q__text_recursion_stop
38153 {
38154 \tl_if_head_is_N_type:nTF {#4}
38155 { \__text_change_case_upper_lt:nnnN }
38156 { \use:c { __text_change_case_next_ #1 :nnn } }
38157 {#1} {#2} {#3} #4 \q__text_recursion_stop
38158 }
38159 \cs_new:Npn \__text_change_case_upper_lt:nnnN #1#2#3#4
38160 {
38161 \__text_codepoint_process:nN
38162 { \__text_change_case_upper_lt:nnnn {#1} {#2} {#3} } #4
38163 }
38164 \cs_new:Npn \__text_change_case_upper_lt:nnnn #1#2#3#4
38165 {
38166 \bool_lazy_and:nnTF
38167 {
38168 \bool_lazy_or_p:nn
38169 { ! \tl_if_single_p:n {#4} }
38170 { ! \token_if_cs_p:N #4 }
38171 }
38172 { \__text_codepoint_compare_p:nNn {#4} = { "0307 } }
38173 { \use:c { __text_change_case_next_ #1 :nnn } {#1} {#2} {#3} }
38174 { \use:c { __text_change_case_next_ #1 :nnn } {#1} {#2} {#3} #4 }
38175 }
38176 \cs_new:Npn \__text_change_case_title_nl:nnnnn #1#2#3#4#5
38177 {
38178 \tl_if_single:nTF {#5}
38179 { \__text_change_case_title_nl_aux:nnnnn }
38180 { \__text_change_case_codepoint:nnnnn }
38181 {#1} {#2} {#3} {#4} {#5}
38182 }
38183 \cs_new:Npn \__text_change_case_title_nl_aux:nnnnn #1#2#3#4#5
38184 {
38185 \bool_lazy_or:nnTF
38186 { \int_compare_p:nNn {`#5} = { "0049 } }
38187 { \int_compare_p:nNn {`#5} = { "0069 } }
38188 {
38189 \char_generate:nn { "0049 } { \__text_char_catcode:N #5 }
38190 \__text_change_case_title_nl:nnnw {#2} {#3} {#4}
38191 }
38192 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38193 }
38194 \cs_new:Npn \__text_change_case_title_nl:nnnw #1#2#3#4 \q__text_recursion_stop
38195 {
38196 \tl_if_head_is_N_type:nTF {#4}
38197 { \__text_change_case_title_nl:nnnN }
38198 { \use:c { __text_change_case_next_ #1 :nnn } }
38199 {#1} {#2} {#3} #4 \q__text_recursion_stop
38200 }
38201 \cs_new:Npn \__text_change_case_title_nl:nnnN #1#2#3#4
38202 {
38203 \bool_lazy_and:nnTF
38204 { ! \token_if_cs_p:N #4 }
38205 {
38206 \bool_lazy_or_p:nn
38207 { \int_compare_p:nNn {`#4} = { "004A } }
38208 { \int_compare_p:nNn {`#4} = { "006A } }
38209 }
38210 {
38211 \char_generate:nn { "004A } { \__text_char_catcode:N #4 }
38212 \use:c { __text_change_case_next_ #1 :nnn } {#1} {#2} {#3}
38213 }
38214 { \use:c { __text_change_case_next_ #1 :nnn } {#1} {#2} {#3} #4 }
38215 }
38216 \cs_new:Npn \__text_change_case_lower_tr:nnnnn #1#2#3#4#5
38217 {
38218 \__text_codepoint_compare:nNnTF {#5} = { "0049 }
38219 { \__text_change_case_lower_tr:nnnNw {#1} {#3} {#4} #5 }
38220 {
38221 \__text_codepoint_compare:nNnTF {#5} = { "0130 }
38222 {
38223 \codepoint_generate:nn { "0069 }
38224 { \__text_change_case_catcode:nn {#5} { "0069 } }
38225 \__text_change_case_loop:nnnw {#1} {#3} {#4}
38226 }
38227 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38228 }
38229 }
38230 \cs_new:Npn \__text_change_case_lower_tr:nnnNw #1#2#3#4#5 \q__text_recursion_stop
38231 {
38232 \tl_if_head_is_N_type:nTF {#5}
38233 { \__text_change_case_lower_tr:NnnnN #4 {#1} {#2} {#3} }
38234 {
38235 \codepoint_generate:nn { "0131 }
38236 { \__text_change_case_catcode:nn {#4} { "0131 } }
38237 \__text_change_case_loop:nnnw {#1} {#2} {#3}
38238 }
38239 #5 \q__text_recursion_stop
38240 }
38241 \cs_new:Npn \__text_change_case_lower_tr:NnnnN #1#2#3#4#5
38242 {
38243 \__text_codepoint_process:nN
38244 { \__text_change_case_lower_tr:Nnnnn #1 {#2} {#3} {#4} } #5
38245 }
38246 \cs_new:Npn \__text_change_case_lower_tr:Nnnnn #1#2#3#4#5
38247 {
38248 \bool_lazy_or:nnTF
38249 {
38250 \bool_lazy_and_p:nn
38251 { \tl_if_single_p:n {#5} }
38252 { \token_if_cs_p:N #5 }
38253 }
38254 { ! \__text_codepoint_compare_p:nNn {#5} = { "0307 } }
38255 {
38256 \codepoint_generate:nn { "0131 }
38257 { \__text_change_case_catcode:nn {#1} { "0131 } }
38258 \__text_change_case_loop:nnnw {#2} {#3} {#4} #5
38259 }
38260 {
38261 \codepoint_generate:nn { "0069 }
38262 { \__text_change_case_catcode:nn {#1} { "0069 } }
38263 \__text_change_case_loop:nnnw {#2} {#3} {#4}
38264 }
38265 }
38266 \cs_new:Npn \__text_change_case_upper_tr:nnnnn #1#2#3#4#5
38267 {
38268 \__text_codepoint_compare:nNnTF {#5} = { "0069 }
38269 {
38270 \codepoint_generate:nn { "0130 }
38271 { \__text_change_case_catcode:nn {#5} { "0130 } }
38272 \use:c { __text_change_case_next_ #2 :nnn } {#2} {#3} {#4}
38273 }
38274 { \__text_change_case_codepoint:nnnnn {#1} {#2} {#3} {#4} {#5} }
38275 }
38276 \cs_new_eq:NN \__text_change_case_lower_az:nnnnn
38277 \__text_change_case_lower_tr:nnnnn
38278 \cs_new_eq:NN \__text_change_case_upper_az:nnnnn
38279 \__text_change_case_upper_tr:nnnnn
38280 \group_begin:
38281 \cs_set_protected:Npn \__text_change_case_setup:NN #1#2
38282 {
38283 \quark_if_recursion_tail_stop:N #1
38284 \tl_const:cn { c__text_lowercase_ \token_to_str:N #1 _tl }
38285 { #2 }
38286 \tl_const:cn { c__text_uppercase_ \token_to_str:N #2 _tl }
38287 { #1 }
38288 \__text_change_case_setup:NN
38289 }
38290 \__text_change_case_setup:NN
38291 \AA \aa
38292 \AE \ae
38293 \DH \dh
38294 \DJ \dj
38295 \IJ \ij
38296 \L \l
38297 \NG \ng
38298 \O \o
38299 \OE \oe
38300 \SS \ss
38301 \TH \th
38302 \q_recursion_tail ?
38303 \q_recursion_stop
38304 \tl_const:cn { c__text_uppercase_ \token_to_str:N \i _tl } { I }
38305 \tl_const:cn { c__text_uppercase_ \token_to_str:N \j _tl } { J }
38306 \group_end:
38307 \tl_if_exist:NT \@expl@finalise@setup@@
38308 {
38309 \tl_gput_right:Nn \@expl@finalise@setup@@
38310 {
38311 \tl_gput_right:Nn \@kernel@after@begindocument
38312 {
38313 \group_begin:
38314 \cs_set_protected:Npn \__text_change_case_setup:Nn #1#2
38315 {
38316 \quark_if_recursion_tail_stop:N #1
38317 \tl_if_single_token:nT {#2}
38318 {
38319 \cs_if_exist:cF
38320 { c__text_uppercase_ \token_to_str:N #1 _tl }
38321 {
38322 \tl_const:cn
38323 { c__text_uppercase_ \token_to_str:N #1 _tl }
38324 { #2 }
38325 }
38326 \cs_if_exist:cF
38327 { c__text_lowercase_ \token_to_str:N #2 _tl }
38328 {
38329 \tl_const:cn
38330 { c__text_lowercase_ \token_to_str:N #2 _tl }
38331 { #1 }
38332 }
38333 }
38334 \__text_change_case_setup:Nn
38335 }
38336 \exp_after:wN \__text_change_case_setup:Nn \@uclclist
38337 \q_recursion_tail ?
38338 \q_recursion_stop
38339 \group_end:
38340 }
38341 }
38342 }
38343 \sys_if_engine_opentype:F
38344 {
38345 \text_declare_uppercase_mapping:nn { "01F0 } { \v { J } }
38346 }
38347 %% File: l3text-map.dtx
38348 \cs_new:Npn \__text_map_tokens:nnn #1#2#3
38349 {
38350 \__text_map_loop:nnnw {#3} {#2} { } #1
38351 \q__text_recursion_tail \q__text_recursion_stop
38352 \prg_break_point:Nn \text_map_break: { }
38353 }
38354 \cs_generate_variant:Nn \__text_map_tokens:nnn { e }
38355 \cs_new:Npn \__text_map_loop:nnnw #1#2#3#4 \q__text_recursion_stop
38356 {
38357 \tl_if_head_is_N_type:nTF {#4}
38358 { \__text_map_N_type:nnnN }
38359 {
38360 \tl_if_head_is_group:nTF {#4}
38361 { \__text_map_group:nnnn }
38362 { \__text_map_space:nnnw }
38363 }
38364 {#1} {#2} {#3} #4 \q__text_recursion_stop
38365 }
38366 \cs_new:Npn \__text_map_group:nnnn #1#2#3#4
38367 {
38368 \__text_map_output:nn {#1} {#3}
38369 \__text_map_output:nn {#1} { {#4} }
38370 \__text_map_loop:nnnw {#1} {#2} { }
38371 }
38372 \use:e
38373 { \cs_new:Npn \exp_not:N \__text_map_space:nnnw #1#2#3 \c_space_tl }
38374 {
38375 \__text_map_output:nn {#1} {#3}
38376 #1 { ~ }
38377 \__text_map_loop:nnnw {#1} {#2} { }
38378 }
38379 \cs_new:Npn \__text_map_N_type:nnnN #1#2#3#4
38380 {
38381 \__text_if_q_recursion_tail_stop_do:Nn #4
38382 {
38383 \__text_map_output:nn {#1} {#3}
38384 \text_map_break:
38385 }
38386 \exp_args:NV \__text_map_math_search:nnnnN
38387 \l_text_math_delims_tl {#1} {#2} {#3} #4
38388 }
38389 \cs_new:Npn \__text_map_math_search:nnnnN #1#2#3#4#5
38390 {
38391 \__text_map_math_search:nnnNNN {#2} {#3} {#4} #5 #1
38392 \q__text_recursion_tail \q__text_recursion_tail
38393 \q__text_recursion_stop
38394 }
38395 \cs_new:Npn \__text_map_math_search:nnnNNN #1#2#3#4#5#6
38396 {
38397 \__text_if_q_recursion_tail_stop_do:Nn #5
38398 { \__text_map_cs_check:nnnN {#1} {#2} {#3} #4 }
38399 \token_if_eq_meaning:NNTF #4 #5
38400 {
38401 \__text_use_i_delimit_by_q_recursion_stop:nw
38402 {
38403 \__text_map_output:nn {#1} {#3}
38404 \__text_map_math_loop:nnnNw {#1} {#2} {#4} #6
38405 }
38406 }
38407 { \__text_map_math_search:nnnNNN {#1} {#2} {#3} #4 }
38408 }
38409 \cs_new:Npn \__text_map_math_loop:nnnNw #1#2#3#4#5 \q__text_recursion_stop
38410 {
38411 \tl_if_head_is_N_type:nTF {#5}
38412 { \__text_map_math_N_type:nnnNN }
38413 {
38414 \tl_if_head_is_group:nTF {#5}
38415 { \__text_map_math_group:nnnNn }
38416 { \__text_map_math_space:nnnNw }
38417 }
38418 {#1} {#2} {#3} #4 #5 \q__text_recursion_stop
38419 }
38420 \cs_new:Npn \__text_map_math_N_type:nnnNN #1#2#3#4#5
38421 {
38422 \__text_if_q_recursion_tail_stop_do:Nn #5
38423 {
38424 \__text_map_output:nn {#1} {#3}
38425 \text_map_break:
38426 }
38427 \token_if_eq_meaning:NNTF #5 #4
38428 {
38429 \__text_map_output:nn {#1} { #3 #4 }
38430 \__text_map_loop:nnnw {#1} {#2} { }
38431 }
38432 { \__text_map_math_loop:nnnNw {#1} {#2} { #3 #5 } #4 }
38433 }
38434 \cs_new:Npn \__text_map_math_group:nnnNn #1#2#3#4#5
38435 { \__text_map_math_loop:nnnNw {#1} {#2} { #3 {#5} } #4 }
38436 \use:e
38437 {
38438 \cs_new:Npn \exp_not:N \__text_map_math_space:nnnNw #1#2#3#4
38439 \c_space_tl
38440 }
38441 { \__text_map_math_loop:nnnNw {#1} {#2} { #3 ~ } #4 }
38442 \cs_new:Npn \__text_map_cs_check:nnnN #1#2#3#4
38443 {
38444 \token_if_cs:NTF #4
38445 {
38446 \__text_map_output:nn {#1} {#3}
38447 #1 {#4}
38448 \__text_map_loop:nnnw {#1} {#2} { }
38449 }
38450 {
38451 \__text_codepoint_process:nN
38452 { \__text_map_active_check:nnnn {#1} {#2} {#3} } #4
38453 }
38454 }
38455 \cs_new:Npn \__text_map_active_check:nnnn #1#2#3#4
38456 {
38457 \bool_lazy_and:nnTF
38458 { \tl_if_single_token_p:n {#4} }
38459 { \token_if_active_p:N #4 }
38460 {
38461 \__text_map_output:nn {#1} {#3}
38462 #1 {#4}
38463 \__text_map_loop:nnnw {#1} {#2} { }
38464 }
38465 { \__text_map_codepoint:nnnn {#1} {#2} {#3} {#4} }
38466 }
38467 \cs_new:Npn \__text_map_codepoint:nnnn #1#2#3#4
38468 {
38469 \__text_codepoint_compare:nNnTF {#4} = { "000D }
38470 {
38471 \__text_map_output:nn {#1} {#3}
38472 \__text_map_CR:nnnw {#1} {#2} {#4}
38473 }
38474 {
38475 \__text_codepoint_compare:nNnTF {#4} = { "200D }
38476 { \__text_map_loop:nnnw {#1} {#2} {#3#4} }
38477 { \__text_map_class:nnnn {#1} {#2} {#3} {#4} }
38478 }
38479 }
38480 \cs_new:Npn \__text_map_CR:nnnw #1#2#3#4 \q__text_recursion_stop
38481 {
38482 \tl_if_head_is_N_type:nTF {#4}
38483 { \__text_map_CR:nnnN {#1} {#2} {#3} }
38484 {
38485 #1 {#3}
38486 \__text_map_loop:nnnw {#1} {#2} { }
38487 }
38488 #4 \q__text_recursion_stop
38489 }
38490 \cs_new:Npn \__text_map_CR:nnnN #1#2#3#4
38491 {
38492 \__text_if_q_recursion_tail_stop_do:Nn #4
38493 {
38494 #1 {#3}
38495 \text_map_break:
38496 }
38497 \bool_lazy_and:nnTF
38498 { ! \token_if_cs_p:N #4 }
38499 { \int_compare_p:nNn { `#4 } = { "000A } }
38500 {
38501 \__text_map_output:nn {#1} {#3#4}
38502 \__text_map_loop:nnnw {#1} {#2} { }
38503 }
38504 { \__text_map_loop:nnnw {#1} {#2} { } #3 }
38505 }
38506 \cs_new:Npn \__text_map_class:nnnn #1#2#3#4
38507 {
38508 \exp_args:Nnnne \__text_map_class:nnnnn {#1} {#2} {#3} {#4}
38509 {
38510 \use:c { __kernel_codepoint_to_ #2 _class:n }
38511 { \__text_codepoint_from_chars:Nw #4 }
38512 }
38513 }
38514 \cs_new:Npn \__text_map_class:nnnnn #1#2#3#4#5
38515 {
38516 \cs_if_exist_use:cF { __text_map_ #5 :nnnn }
38517 { \__text_map_Other:nnnn }
38518 {#1} {#2} {#3} {#4}
38519 }
38520 \cs_new:Npn \__text_map_lookahead:nnnnnw #1#2#3#4#5#6 \q__text_recursion_stop
38521 {
38522 \tl_if_head_is_N_type:nTF {#6}
38523 { \__text_map_lookahead:nnnnnN {#1} {#2} {#3} {#4} {#5} }
38524 { \__text_map_loop:nnnw {#1} {#2} {#3} #4 }
38525 #6 \q__text_recursion_stop
38526 }
38527 \cs_new:Npn \__text_map_lookahead:nnnnnN #1#2#3#4#5#6
38528 {
38529 \__text_if_q_recursion_tail_stop_do:Nn #6
38530 {
38531 #1 {#3}
38532 \tl_if_blank:nF {#4} { #1 {#4} }
38533 }
38534 \token_if_cs:NTF #6
38535 {
38536 #1 {#3}
38537 \__text_map_loop:nnnw {#1} {#2} { } #4
38538 }
38539 { \__text_codepoint_process:nN { #5 {#1} {#2} {#3} {#4} } }
38540 #6
38541 }
38542 \prg_new_conditional:Npnn \__text_map_if_ignorable:n #1 { TF }
38543 {
38544 \str_case:nnTF {#1}
38545 {
38546 { Extend } { }
38547 { Format } { }
38548 { ZWJ } { }
38549 }
38550 \prg_return_true:
38551 \prg_return_false:
38552 }
38553 \cs_new:Npn \__text_map_output:nn #1#2
38554 { \tl_if_blank:nF {#2} { #1 {#2} } }
38555 \cs_new:Npn \text_map_break:
38556 { \prg_map_break:Nn \text_map_break: { } }
38557 \cs_new:Npn \text_map_break:n
38558 { \prg_map_break:Nn \text_map_break: }
38559 \cs_new:Npn \__text_map_Control:nnnn #1#2#3#4
38560 {
38561 \__text_map_output:nn {#1} {#3}
38562 \__text_map_output:nn {#1} {#4}
38563 \__text_map_loop:nnnw {#1} {#2} { }
38564 }
38565 \cs_new_eq:NN \__text_map_Newline:nnnn \__text_map_Control:nnnn
38566 \cs_new:Npn \__text_map_Extend:nnnn #1#2#3#4
38567 { \__text_map_loop:nnnw {#1} {#2} {#3#4} }
38568 \cs_new_eq:NN \__text_map_Format:nnnn \__text_map_Extend:nnnn
38569 \cs_new_eq:NN \__text_map_SpacingMark:nnnn \__text_map_Extend:nnnn
38570 \cs_new:Npn \__text_map_Other:nnnn #1#2#3#4
38571 {
38572 \__text_map_output:nn {#1} {#3}
38573 \__text_map_loop:nnnw {#1} {#2} {#4}
38574 }
38575 \cs_new:Npn \__text_map_Regional_Indicator:nnnn #1#2#3#4
38576 {
38577 \__text_map_output:nn {#1} {#3}
38578 \__text_map_lookahead:nnnnnw {#1} {#2} {#4} { }
38579 \__text_map_Regional_Indicator_aux:nnnnn
38580 }
38581 \cs_new:Npn \__text_map_Regional_Indicator_aux:nnnnn #1#2#3#4#5
38582 {
38583 \bool_lazy_or:nnTF
38584 { \__text_codepoint_compare_p:nNn {#5} < { "1F1E6 } }
38585 { \__text_codepoint_compare_p:nNn {#5} > { "1F1FF } }
38586 {
38587 \str_if_eq:nnTF {#2} { wordbreak }
38588 {
38589 \exp_args:Ne \__text_map_if_ignorable:nTF
38590 {
38591 \__kernel_codepoint_to_grapheme_class:n
38592 { \__text_codepoint_from_chars:Nw #5 }
38593 }
38594 {
38595 \__text_map_lookahead:nnnnnw {#1} {#2} {#3#5} { }
38596 \__text_map_Regional_Indicator_aux:nnnnn
38597 }
38598 { \__text_map_loop:nnnw {#1} {#2} {#3} #5 }
38599 }
38600 { \__text_map_loop:nnnw {#1} {#2} {#3} #5 }
38601 }
38602 { \__text_map_loop:nnnw {#1} {#2} {#3#5} }
38603 }
38604 \cs_new:Npn \text_map_function:nN #1#2
38605 {
38606 \__text_map_tokens:enn { \text_expand:n {#1} }
38607 { grapheme } {#2}
38608 }
38609 \cs_new:Npn \text_map_tokens:nn #1#2
38610 {
38611 \__text_map_tokens:enn { \text_expand:n {#1} }
38612 { grapheme } {#2}
38613 }
38614 \cs_new:Npn \__text_map_Prepend:nnnn #1#2#3#4
38615 {
38616 \__text_map_output:nn {#1} {#3}
38617 \__text_map_lookahead:nnnnnw {#1} { grapheme } {#4} { }
38618 \__text_map_Prepend_aux:nnnnn
38619 }
38620 \cs_new:Npn \__text_map_Prepend_aux:nnnnn #1#2#3#4#5
38621 {
38622 \bool_lazy_or:nnTF
38623 { \__text_codepoint_compare_p:nNn {#5} = { "000A } }
38624 { \__text_codepoint_compare_p:nNn {#5} = { "000D } }
38625 {
38626 #1 {#3}
38627 \__text_map_loop:nnnw {#1} { grapheme } {#5}
38628 }
38629 { \__text_map_Prepend:nnn {#1} {#3} {#5} }
38630 }
38631 \cs_new:Npn \__text_map_Prepend:nnn #1#2#3
38632 {
38633 \str_if_eq:eeTF
38634 { Control }
38635 {
38636 \__kernel_codepoint_to_grapheme_class:n
38637 { \__text_codepoint_from_chars:Nw #3 }
38638 }
38639 { \__text_map_loop:nnnw {#1} { grapheme } {#2} #3 }
38640 { \__text_map_loop:nnnw {#1} { grapheme } {#2#3} }
38641 }
38642 \cs_new:Npn \__text_map_L:nnnn #1#2#3#4
38643 {
38644 \__text_map_output:nn {#1} {#3}
38645 \__text_map_hangul:nnnw
38646 {#1} {#4} { L ; V ; LV ; LVT }
38647 }
38648 \cs_new:Npn \__text_map_LV:nnnn #1#2#3#4
38649 {
38650 \__text_map_output:nn {#1} {#3}
38651 \__text_map_hangul:nnnw
38652 {#1} {#4} { V ; T }
38653 }
38654 \cs_new_eq:NN \__text_map_V:nnnn \__text_map_LV:nnnn
38655 \cs_new:Npn \__text_map_LVT:nnnn #1#2#3#4
38656 {
38657 \__text_map_output:nn {#1} {#3}
38658 \__text_map_hangul:nnnw
38659 {#1} {#4} { T }
38660 }
38661 \cs_new_eq:NN \__text_map_T:nnnn \__text_map_LVT:nnnn
38662 \cs_new:Npn \__text_map_hangul:nnnw #1#2#3#4 \q__text_recursion_stop
38663 {
38664 \tl_if_head_is_N_type:nTF {#4}
38665 { \__text_map_hangul:nnnN {#1} {#2} {#3} }
38666 {
38667 #1 {#2}
38668 \__text_map_loop:nnnw {#1} { grapheme } { }
38669 }
38670 #4 \q__text_recursion_stop
38671 }
38672 \cs_new:Npn \__text_map_hangul:nnnN #1#2#3#4
38673 {
38674 \__text_if_q_recursion_tail_stop_do:Nn #4
38675 {
38676 #1 {#2}
38677 \text_map_break:
38678 }
38679 \token_if_cs:NTF #4
38680 {
38681 #1 {#2}
38682 \__text_map_loop:nnnw {#1} { grapheme } { }
38683 }
38684 {
38685 \__text_codepoint_process:nN
38686 { \__text_map_hangul:nnnn {#1} {#2} {#3} } #4
38687 }
38688 }
38689 \exp_args_generate:n { Nnne }
38690 \cs_new:Npn \__text_map_hangul:nnnn #1#2#3#4
38691 {
38692 \exp_args:NNnne \__text_map_hangul_aux:nnnnw {#1} {#2} {#4}
38693 {
38694 \__kernel_codepoint_to_grapheme_class:n
38695 { \__text_codepoint_from_chars:Nw #4 }
38696 }
38697 #3 ; \q_recursion_tail ; \q_recursion_stop
38698 }
38699 \cs_new:Npn \__text_map_hangul_aux:nnnnw #1#2#3#4#5 ;
38700 {
38701 \quark_if_recursion_tail_stop_do:nn {#5}
38702 { \__text_map_loop:nnnw {#1} { grapheme } {#2} #3 }
38703 \__text_map_hangul:nnnnnw {#1} {#2} {#3} {#4} {#5}
38704 }
38705 \cs_generate_variant:Nn \__text_map_hangul_aux:nnnnw { nnne }
38706 \cs_new:Npn \__text_map_hangul:nnnnnw #1#2#3#4#5#6 \q_recursion_stop
38707 {
38708 \str_if_eq:nnTF {#4} {#5}
38709 { \use:c { __text_map_hangul_ #5 :nnn } {#1} {#2} {#3} }
38710 { \__text_map_hangul_next:nnnnn {#1} {#2} {#3} {#4} {#6} }
38711 }
38712 \cs_new:Npn \__text_map_hangul_next:nnnnn #1#2#3#4#5
38713 { \__text_map_hangul_aux:nnnnw {#1} {#2} {#3} {#4} #5 \q_recursion_stop }
38714 \cs_new:Npn \__text_map_hangul_end:nw #1#2 \q__text_recursion_stop {#1}
38715 \cs_new:Npn \__text_map_hangul_L:nnn #1#2#3
38716 {
38717 \__text_map_hangul:nnnw
38718 {#1} {#2#3} { L V { LV } { LVT } }
38719 }
38720 \cs_new:Npn \__text_map_hangul_LV:nnn #1#2#3
38721 {
38722 \__text_map_hangul:nnnw
38723 {#1} {#2#3} { VT }
38724 }
38725 \cs_new_eq:NN \__text_map_hangul_V:nnn \__text_map_hangul_LV:nnn
38726 \cs_new:Npn \__text_map_hangul_LVT:nnn #1#2#3
38727 {
38728 \__text_map_hangul:nnnw
38729 {#1} {#2#3} { T }
38730 }
38731 \cs_new_eq:NN \__text_map_hangul_T:nnn \__text_map_hangul_LVT:nnn
38732 \cs_new:Npn \text_words_map_function:nN #1#2
38733 {
38734 \__text_map_tokens:enn { \text_expand:n {#1} }
38735 { wordbreak } {#2}
38736 }
38737 \cs_new:Npn \text_words_map_tokens:nn #1#2
38738 {
38739 \__text_map_tokens:enn { \text_expand:n {#1} }
38740 { wordbreak } {#2}
38741 }
38742 \cs_new:Npn \__text_map_collect:nnnnn #1#2#3#4#5
38743 {
38744 \__text_map_lookahead:nnnnnw {#1} { wordbreak } {#2} { }
38745 { \__text_map_collect_auxi:nnnnnnnn {#3} {#4} {#5} }
38746 }
38747 \cs_new:Npn \__text_map_collect_auxi:nnnnnnnn #1#2#3#4#5#6#7#8
38748 {
38749 \exp_args:Ne \__text_map_collect_auxii:nnnnnnn
38750 {
38751 \__kernel_codepoint_to_wordbreak_class:n
38752 { \__text_codepoint_from_chars:Nw #8 }
38753 }
38754 {#4} {#6} {#1} {#2} {#3} {#8}
38755 }
38756 \cs_new:Npn \__text_map_collect_auxii:nnnnnnn #1#2#3#4#5#6#7
38757 {
38758 \str_case:neTF {#1}
38759 {
38760 \tl_map_function:eN
38761 {
38762 #4
38763 \str_if_eq:nnF {#4} { { WSegSpace } } { { ExtendNumLet } }
38764 }
38765 \__text_map_collect_auxiii:n
38766 }
38767 {
38768 \cs_if_exist_use:cF { __text_map_ #1 :nnnn }
38769 { \__text_map_Other:nnnn }
38770 {#2} { wordbreak } { } {#3#7}
38771 }
38772 {
38773 \__text_map_if_ignorable:nTF {#1}
38774 { \__text_map_collect:nnnnn {#2} {#3#7} {#4} {#5} {#6} }
38775 {
38776 \str_case:neTF {#1}
38777 { \tl_map_function:nN {#5} \__text_map_collect_auxiii:n }
38778 {
38779 \__text_map_lookahead:nnnnnw {#2} { wordbreak } {#3} {#7}
38780 { \__text_map_collect_auxiv:nnnnnnn {#5} {#6} }
38781 }
38782 {
38783 \__text_map_output:nn {#2} {#3}
38784 \__text_map_loop:nnnw {#2} { wordbreak } { } #7
38785 }
38786 }
38787 }
38788 }
38789 \cs_new:Npn \__text_map_collect_auxiii:n #1
38790 { \exp_not:n { {#1} { } } }
38791 \cs_new:Npn \__text_map_collect_auxiv:nnnnnnn #1#2#3#4#5#6#7
38792 {
38793 \exp_args:Ne \__text_map_collect_auxv:nnnnnnn
38794 {
38795 \__kernel_codepoint_to_wordbreak_class:n
38796 { \__text_codepoint_from_chars:Nw #7 }
38797 }
38798 {#3} {#5} {#6} {#1} {#2} {#7}
38799 }
38800 \cs_new:Npn \__text_map_collect_auxv:nnnnnnn #1#2#3#4#5#6#7
38801 {
38802 \str_case:neTF {#1}
38803 { \tl_map_function:nN {#6} \__text_map_collect_auxiii:n }
38804 { \use:c { __text_map_ #1 :nnnn } {#2} { wordbreak } { } {#3#4#7} }
38805 {
38806 \__text_map_if_ignorable:nTF {#1}
38807 {
38808 \__text_map_lookahead:nnnnnw {#2} { wordbreak } {#3} {#4#7}
38809 { \__text_map_collect_auxiv:nnnnnnn {#5} {#6} }
38810 }
38811 {
38812 \__text_map_output:nn {#2} {#3}
38813 \__text_map_loop:nnnw {#2} { wordbreak } { } #4#7
38814 }
38815 }
38816 }
38817 \cs_new:Npn \__text_map_ALetter:nnnn #1#2#3#4
38818 {
38819 \__text_map_output:nn {#1} {#3}
38820 \__text_map_collect:nnnnn {#1} {#4}
38821 { { ALetter } { Hebrew_Letter } { Numeric } }
38822 { { MidLetter } { MidNumLet } { Single_Quote } }
38823 { { ALetter } { Hebrew_Letter } }
38824 }
38825 \cs_new:Npn \__text_map_Hebrew_Letter:nnnn #1#2#3#4
38826 {
38827 \__text_map_output:nn {#1} {#3}
38828 \__text_map_collect:nnnnn {#1} {#4}
38829 { { ALetter } { Hebrew_Letter } { Numeric } { Single_Quote } }
38830 { { MidLetter } { MidNumLet } { Double_Quote } }
38831 { { Hebrew_Letter } }
38832 }
38833 \cs_new:Npn \__text_map_Katakana:nnnn #1#2#3#4
38834 {
38835 \__text_map_output:nn {#1} {#3}
38836 \__text_map_collect:nnnnn {#1} {#4} { { Katakana } } { } { }
38837 }
38838 \cs_new:Npn \__text_map_Numeric:nnnn #1#2#3#4
38839 {
38840 \__text_map_output:nn {#1} {#3}
38841 \__text_map_collect:nnnnn {#1} {#4}
38842 { { ALetter } { Hebrew_Letter } { Numeric } }
38843 { { MidNum } { MidNumLet } { Single_Quote } }
38844 { { Numeric } }
38845 }
38846 \cs_new:Npn \__text_map_WSegSpace:nnnn #1#2#3#4
38847 {
38848 \__text_map_output:nn {#1} {#3}
38849 \__text_map_collect:nnnnn {#1} {#4} { { WSegSpace } } { } { }
38850 }
38851 \cs_new:Npn \__text_map_ExtendNumLet:nnnn #1#2#3#4
38852 {
38853 \__text_map_output:nn {#1} {#3}
38854 \__text_map_lookahead:nnnnnw {#1} { wordbreak } {#4} { }
38855 \__text_map_ExtendNumLet_auxi:nnnnn
38856 }
38857 \cs_new:Npn \__text_map_ExtendNumLet_auxi:nnnnn #1#2#3#4#5
38858 {
38859 \exp_args:Ne \__text_map_ExtendNumLet_auxii:nnnn
38860 {
38861 \__kernel_codepoint_to_wordbreak_class:n
38862 { \__text_codepoint_from_chars:Nw #5 }
38863 }
38864 {#1} {#3} {#5}
38865 }
38866 \cs_new:Npn \__text_map_ExtendNumLet_auxii:nnnn #1#2#3#4
38867 {
38868 \str_case:nnTF {#1}
38869 {
38870 { ALetter } { }
38871 { Hebrew_Letter } { }
38872 { Numeric } { }
38873 { Katakana } { }
38874 { ExtendNumLet } { }
38875 }
38876 {
38877 \cs_if_exist_use:cF { __text_map_ #1 :nnnn }
38878 { \__text_map_Other:nnnn }
38879 {#2} { wordbreak } { } {#3#4}
38880 }
38881 {
38882 \__text_map_if_ignorable:nTF {#1}
38883 {
38884 \__text_map_lookahead:nnnnnw {#2} { wordbreak } {#3#4} { }
38885 \__text_map_ExtendNumLet_auxi:nnnnn
38886 }
38887 {
38888 \__text_map_output:nn {#2} {#3}
38889 \__text_map_loop:nnnw {#2} { wordbreak } { } #4
38890 }
38891 }
38892 }
38893 \cs_new_protected:Npn \text_map_inline:nn #1#2
38894 {
38895 \int_gincr:N \g__kernel_prg_map_int
38896 \cs_gset_protected:cpn
38897 { __text_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
38898 \exp_args:Nnc \text_map_function:nN {#1}
38899 { __text_map_ \int_use:N \g__kernel_prg_map_int :w }
38900 \prg_break_point:Nn \text_map_break:
38901 { \int_gdecr:N \g__kernel_prg_map_int }
38902 }
38903 \cs_new_protected:Npn \text_words_map_inline:nn #1#2
38904 {
38905 \int_gincr:N \g__kernel_prg_map_int
38906 \cs_gset_protected:cpn
38907 { __text_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
38908 \exp_args:Nnc \text_words_map_function:nN {#1}
38909 { __text_map_ \int_use:N \g__kernel_prg_map_int :w }
38910 \prg_break_point:Nn \text_map_break:
38911 { \int_gdecr:N \g__kernel_prg_map_int }
38912 }
38913 %% File: l3text-purify.dtx
38914 \__kernel_quark_new_test:N \__text_if_recursion_tail_stop:N
38915 \cs_new:Npn \text_purify:n #1
38916 {
38917 \__kernel_exp_not:w \exp_after:wN
38918 {
38919 \exp:w
38920 \exp_args:Ne \__text_purify:n
38921 { \text_expand:n {#1} }
38922 }
38923 }
38924 \cs_generate_variant:Nn \text_purify:n { V , v }
38925 \cs_new:Npn \__text_purify:n #1
38926 {
38927 \group_align_safe_begin:
38928 \__text_purify_loop:w #1
38929 \q__text_recursion_tail \q__text_recursion_stop
38930 \__text_purify_result:n { }
38931 }
38932 \cs_new:Npn \__text_purify_store:n #1
38933 { \__text_purify_store:nw {#1} }
38934 \cs_new:Npn \__text_purify_store:nw #1#2 \__text_purify_result:n #3
38935 { #2 \__text_purify_result:n { #3 #1 } }
38936 \cs_new:Npn \__text_purify_end:w #1 \__text_purify_result:n #2
38937 {
38938 \group_align_safe_end:
38939 \exp_end:
38940 #2
38941 }
38942 \cs_new:Npn \__text_purify_loop:w #1 \q__text_recursion_stop
38943 {
38944 \tl_if_head_is_N_type:nTF {#1}
38945 { \__text_purify_N_type:N }
38946 {
38947 \tl_if_head_is_group:nTF {#1}
38948 { \__text_purify_group:n }
38949 { \__text_purify_space:w }
38950 }
38951 #1 \q__text_recursion_stop
38952 }
38953 \cs_new:Npn \__text_purify_group:n #1 { \__text_purify_loop:w #1 }
38954 \exp_last_unbraced:NNo \cs_new:Npn \__text_purify_space:w \c_space_tl
38955 {
38956 \__text_purify_store:n { ~ }
38957 \__text_purify_loop:w
38958 }
38959 \cs_new:Npn \__text_purify_N_type:N #1
38960 {
38961 \__text_if_q_recursion_tail_stop_do:Nn #1 { \__text_purify_end:w }
38962 \__text_purify_N_type_aux:N #1
38963 }
38964 \cs_new:Npn \__text_purify_N_type_aux:N #1
38965 {
38966 \exp_after:wN \__text_purify_math_search:NNN
38967 \exp_after:wN #1 \l_text_math_delims_tl
38968 \q__text_recursion_tail ?
38969 \q__text_recursion_stop
38970 }
38971 \cs_new:Npn \__text_purify_math_search:NNN #1#2#3
38972 {
38973 \__text_if_q_recursion_tail_stop_do:Nn #2
38974 { \__text_purify_math_cmd:N #1 }
38975 \token_if_eq_meaning:NNTF #1 #2
38976 {
38977 \__text_use_i_delimit_by_q_recursion_stop:nw
38978 { \__text_purify_math_start:NNw #2 #3 }
38979 }
38980 { \__text_purify_math_search:NNN #1 }
38981 }
38982 \cs_new:Npn \__text_purify_math_start:NNw #1#2#3 \q__text_recursion_stop
38983 {
38984 \__text_purify_math_loop:NNw #1#2#3 \q__text_recursion_stop
38985 \__text_purify_math_result:n { }
38986 }
38987 \cs_new:Npn \__text_purify_math_store:n #1
38988 { \__text_purify_math_store:nw {#1} }
38989 \cs_new:Npn \__text_purify_math_store:nw #1#2 \__text_purify_math_result:n #3
38990 { #2 \__text_purify_math_result:n { #3 #1 } }
38991 \cs_new:Npn \__text_purify_math_end:w #1 \__text_purify_math_result:n #2
38992 {
38993 \__text_purify_store:n { $ #2 $ }
38994 \__text_purify_loop:w #1
38995 }
38996 \cs_new:Npn \__text_purify_math_stop:Nw #1 \__text_purify_math_result:n #2
38997 {
38998 \__text_purify_store:n {#1#2}
38999 \__text_purify_end:w
39000 }
39001 \cs_new:Npn \__text_purify_math_loop:NNw #1#2#3 \q__text_recursion_stop
39002 {
39003 \tl_if_head_is_N_type:nTF {#3}
39004 { \__text_purify_math_N_type:NNN }
39005 {
39006 \tl_if_head_is_group:nTF {#3}
39007 { \__text_purify_math_group:NNn }
39008 { \__text_purify_math_space:NNw }
39009 }
39010 #1#2#3 \q__text_recursion_stop
39011 }
39012 \cs_new:Npn \__text_purify_math_N_type:NNN #1#2#3
39013 {
39014 \__text_if_q_recursion_tail_stop_do:Nn #3
39015 { \__text_purify_math_stop:Nw #1 }
39016 \token_if_eq_meaning:NNTF #3 #2
39017 { \__text_purify_math_end:w }
39018 {
39019 \__text_purify_math_store:n {#3}
39020 \__text_purify_math_loop:NNw #1#2
39021 }
39022 }
39023 \cs_new:Npn \__text_purify_math_group:NNn #1#2#3
39024 {
39025 \__text_purify_math_store:n { {#3} }
39026 \__text_purify_math_loop:NNw #1#2
39027 }
39028 \exp_after:wN \cs_new:Npn \exp_after:wN \__text_purify_math_space:NNw
39029 \exp_after:wN # \exp_after:wN 1
39030 \exp_after:wN # \exp_after:wN 2 \c_space_tl
39031 {
39032 \__text_purify_math_store:n { ~ }
39033 \__text_purify_math_loop:NNw #1#2
39034 }
39035 \cs_new:Npn \__text_purify_math_cmd:N #1
39036 {
39037 \exp_after:wN \__text_purify_math_cmd:NN \exp_after:wN #1
39038 \l_text_math_arg_tl \q__text_recursion_tail \q__text_recursion_stop
39039 }
39040 \cs_new:Npn \__text_purify_math_cmd:NN #1#2
39041 {
39042 \__text_if_q_recursion_tail_stop_do:Nn #2
39043 { \__text_purify_replace:N #1 }
39044 \cs_if_eq:NNTF #2 #1
39045 {
39046 \__text_use_i_delimit_by_q_recursion_stop:nw
39047 { \__text_purify_math_cmd:n }
39048 }
39049 { \__text_purify_math_cmd:NN #1 }
39050 }
39051 \cs_new:Npn \__text_purify_math_cmd:n #1
39052 { \__text_purify_math_end:w \__text_purify_math_result:n {#1} }
39053 \cs_new:Npn \__text_purify_replace:N #1
39054 {
39055 \bool_lazy_and:nnTF
39056 { \cs_if_exist_p:c { l__text_purify_ \token_to_str:N #1 _tl } }
39057 {
39058 \bool_lazy_or_p:nn
39059 { \token_if_cs_p:N #1 }
39060 { \token_if_active_p:N #1 }
39061 }
39062 {
39063 \__text_purify_replace_auxi:v
39064 { l__text_purify_ \token_to_str:N #1 _tl }
39065 }
39066 {
39067 \bool_lazy_or:nnTF
39068 { \token_if_group_begin_p:N #1 }
39069 { \token_if_group_end_p:N #1 }
39070 { \__text_purify_loop:w }
39071 {
39072 \exp_args:Ne \__text_purify_replace_auxii:n
39073 { \__text_token_to_explicit:N #1 }
39074 }
39075 }
39076 }
39077 \cs_new:Npn \__text_purify_replace_auxi:n #1 { \__text_purify_loop:w #1 }
39078 \cs_generate_variant:Nn \__text_purify_replace_auxi:n { v }
39079 \cs_new:Npn \__text_purify_replace_auxii:n #1
39080 {
39081 \token_if_cs:NTF #1
39082 { \__text_purify_expand:N #1 }
39083 {
39084 \__text_purify_store:n {#1}
39085 \__text_purify_loop:w
39086 }
39087 }
39088 \cs_new:Npn \__text_purify_expand:N #1
39089 {
39090 \str_if_eq:nnTF {#1} { \protect }
39091 { \__text_purify_protect:N }
39092 { \__text_purify_encoding:N #1 }
39093 }
39094 \cs_new:Npn \__text_purify_protect:N #1
39095 {
39096 \__text_if_q_recursion_tail_stop_do:Nn #1 { \__text_purify_end:w }
39097 \cs_if_exist:cTF { l__text_purify_ \token_to_str:N #1 _tl }
39098 {
39099 \__text_purify_replace_auxi:v
39100 { l__text_purify_ \token_to_str:N #1 _tl }
39101 }
39102 { \__text_purify_loop:w }
39103 }
39104 \cs_new:Npn \__text_purify_encoding:N #1
39105 {
39106 \bool_lazy_or:nnTF
39107 { \cs_if_eq_p:NN #1 \@current@cmd }
39108 { \cs_if_eq_p:NN #1 \@changed@cmd }
39109 { \__text_purify_encoding_escape:NN }
39110 {
39111 \__text_if_expandable:NTF #1
39112 { \exp_after:wN \__text_purify_loop:w #1 }
39113 { \__text_purify_loop:w }
39114 }
39115 }
39116 \cs_new:Npn \__text_purify_encoding_escape:NN #1#2
39117 {
39118 \__text_purify_store:n {#1}
39119 \__text_purify_loop:w
39120 }
39121 \cs_new_protected:Npn \text_declare_purify_equivalent:Nn #1#2
39122 {
39123 \tl_clear_new:c { l__text_purify_ \token_to_str:N #1 _tl }
39124 \tl_set:cn { l__text_purify_ \token_to_str:N #1 _tl } {#2}
39125 }
39126 \cs_generate_variant:Nn \text_declare_purify_equivalent:Nn { Ne }
39127 \tl_map_inline:nn
39128 {
39129 \fontencoding
39130 \fontfamily
39131 \fontseries
39132 \fontshape
39133 }
39134 { \text_declare_purify_equivalent:Nn #1 { \use_none:n } }
39135 \text_declare_purify_equivalent:Nn \fontsize { \use_none:nn }
39136 \text_declare_purify_equivalent:Nn \selectfont { }
39137 \text_declare_purify_equivalent:Nn \usefont { \use_none:nnnn }
39138 \exp_args:Nc \text_declare_purify_equivalent:Nn
39139 { @protected@testopt } { \use_none:nnn }
39140 \text_declare_purify_equivalent:Nn \begin { \use:c }
39141 \text_declare_purify_equivalent:Nn \end { \__text_end_env:n }
39142 \cs_new:Npn \__text_end_env:n #1 { \cs:w end #1 \cs_end: }
39143 \text_declare_purify_equivalent:Nn \\ { }
39144 \tl_map_inline:nn
39145 { \{ \} \# \$ \% \_ }
39146 { \text_declare_purify_equivalent:Ne #1 { \cs_to_str:N #1 } }
39147 \text_declare_purify_equivalent:Nn \label { \use_none:n }
39148 \group_begin:
39149 \char_set_catcode_active:N \~
39150 \use:n
39151 {
39152 \group_end:
39153 \text_declare_purify_equivalent:Ne ~ { \c_space_tl }
39154 }
39155 \text_declare_purify_equivalent:Nn \nobreakspace { ~ }
39156 \text_declare_purify_equivalent:Nn \ { ~ }
39157 \text_declare_purify_equivalent:Nn \, { ~ }
39158 \cs_set_protected:Npn \__text_loop:Nn #1#2
39159 {
39160 \quark_if_recursion_tail_stop:N #1
39161 \text_declare_purify_equivalent:Ne #1
39162 {
39163 \codepoint_generate:nn {"#2}
39164 { \char_value_catcode:n {"#2} }
39165 }
39166 \__text_loop:Nn
39167 }
39168 \__text_loop:Nn
39169 \AA { 00C5 }
39170 \AE { 00C6 }
39171 \DH { 00D0 }
39172 \DJ { 0110 }
39173 \IJ { 0132 }
39174 \L { 0141 }
39175 \NG { 014A }
39176 \O { 00D8 }
39177 \OE { 0152 }
39178 \TH { 00DE }
39179 \aa { 00E5 }
39180 \ae { 00E6 }
39181 \dh { 00F0 }
39182 \dj { 0111 }
39183 \i { 0131 }
39184 \j { 0237 }
39185 \ij { 0132 }
39186 \l { 0142 }
39187 \ng { 014B }
39188 \o { 00F8 }
39189 \oe { 0153 }
39190 \ss { 00DF }
39191 \th { 00FE }
39192 \q_recursion_tail ?
39193 \q_recursion_stop
39194 \text_declare_purify_equivalent:Nn \SS { SS }
39195 \cs_new:Npn \__text_purify_accent:NN #1#2
39196 {
39197 \cs_if_exist:cTF
39198 { c__text_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl }
39199 {
39200 \exp_not:v
39201 { c__text_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl }
39202 }
39203 {
39204 \exp_not:n {#2}
39205 \exp_not:v { c__text_purify_ \token_to_str:N #1 _tl }
39206 }
39207 }
39208 \tl_map_inline:nn { \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t }
39209 { \text_declare_purify_equivalent:Nn #1 { \__text_purify_accent:NN #1 } }
39210 \group_begin:
39211 \cs_set_protected:Npn \__text_loop:Nn #1#2
39212 {
39213 \quark_if_recursion_tail_stop:N #1
39214 \tl_const:ce { c__text_purify_ \token_to_str:N #1 _tl }
39215 { \codepoint_generate:nn {"#2} { \char_value_catcode:n { "#2 } } }
39216 \__text_loop:Nn
39217 }
39218 \__text_loop:Nn
39219 \` { 0300 }
39220 \' { 0301 }
39221 \^ { 0302 }
39222 \~ { 0303 }
39223 \= { 0304 }
39224 \u { 0306 }
39225 \. { 0307 }
39226 \" { 0308 }
39227 \r { 030A }
39228 \H { 030B }
39229 \v { 030C }
39230 \d { 0323 }
39231 \c { 0327 }
39232 \k { 0328 }
39233 \b { 0331 }
39234 \t { 0361 }
39235 \q_recursion_tail { }
39236 \q_recursion_stop
39237 \cs_set_protected:Npn \__text_loop:NNn #1#2#3
39238 {
39239 \quark_if_recursion_tail_stop:N #1
39240 \tl_const:ce
39241 { c__text_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl }
39242 { \codepoint_generate:nn {"#3} { \char_value_catcode:n { "#3 } } }
39243 \__text_loop:NNn
39244 }
39245 \__text_loop:NNn
39246 \` A { 00C0 }
39247 \' A { 00C1 }
39248 \^ A { 00C2 }
39249 \~ A { 00C3 }
39250 \" A { 00C4 }
39251 \r A { 00C5 }
39252 \c C { 00C7 }
39253 \` E { 00C8 }
39254 \' E { 00C9 }
39255 \^ E { 00CA }
39256 \" E { 00CB }
39257 \` I { 00CC }
39258 \' I { 00CD }
39259 \^ I { 00CE }
39260 \" I { 00CF }
39261 \~ N { 00D1 }
39262 \` O { 00D2 }
39263 \' O { 00D3 }
39264 \^ O { 00D4 }
39265 \~ O { 00D5 }
39266 \" O { 00D6 }
39267 \` U { 00D9 }
39268 \' U { 00DA }
39269 \^ U { 00DB }
39270 \" U { 00DC }
39271 \' Y { 00DD }
39272 \` a { 00E0 }
39273 \' a { 00E1 }
39274 \^ a { 00E2 }
39275 \~ a { 00E3 }
39276 \" a { 00E4 }
39277 \r a { 00E5 }
39278 \c c { 00E7 }
39279 \` e { 00E8 }
39280 \' e { 00E9 }
39281 \^ e { 00EA }
39282 \" e { 00EB }
39283 \` i { 00EC }
39284 \` \i { 00EC }
39285 \' i { 00ED }
39286 \' \i { 00ED }
39287 \^ i { 00EE }
39288 \^ \i { 00EE }
39289 \" i { 00EF }
39290 \" \i { 00EF }
39291 \~ n { 00F1 }
39292 \` o { 00F2 }
39293 \' o { 00F3 }
39294 \^ o { 00F4 }
39295 \~ o { 00F5 }
39296 \" o { 00F6 }
39297 \` u { 00F9 }
39298 \' u { 00FA }
39299 \^ u { 00FB }
39300 \" u { 00FC }
39301 \' y { 00FD }
39302 \" y { 00FF }
39303 \= A { 0100 }
39304 \= a { 0101 }
39305 \u A { 0102 }
39306 \u a { 0103 }
39307 \k A { 0104 }
39308 \k a { 0105 }
39309 \' C { 0106 }
39310 \' c { 0107 }
39311 \^ C { 0108 }
39312 \^ c { 0109 }
39313 \. C { 010A }
39314 \. c { 010B }
39315 \v C { 010C }
39316 \v c { 010D }
39317 \v D { 010E }
39318 \v d { 010F }
39319 \= E { 0112 }
39320 \= e { 0113 }
39321 \u E { 0114 }
39322 \u e { 0115 }
39323 \. E { 0116 }
39324 \. e { 0117 }
39325 \k E { 0118 }
39326 \k e { 0119 }
39327 \v E { 011A }
39328 \v e { 011B }
39329 \^ G { 011C }
39330 \^ g { 011D }
39331 \u G { 011E }
39332 \u g { 011F }
39333 \. G { 0120 }
39334 \. g { 0121 }
39335 \c G { 0122 }
39336 \c g { 0123 }
39337 \^ H { 0124 }
39338 \^ h { 0125 }
39339 \~ I { 0128 }
39340 \~ i { 0129 }
39341 \~ \i { 0129 }
39342 \= I { 012A }
39343 \= i { 012B }
39344 \= \i { 012B }
39345 \u I { 012C }
39346 \u i { 012D }
39347 \u \i { 012D }
39348 \k I { 012E }
39349 \k i { 012F }
39350 \k \i { 012F }
39351 \. I { 0130 }
39352 \^ J { 0134 }
39353 \^ j { 0135 }
39354 \^ \j { 0135 }
39355 \c K { 0136 }
39356 \c k { 0137 }
39357 \' L { 0139 }
39358 \' l { 013A }
39359 \c L { 013B }
39360 \c l { 013C }
39361 \v L { 013D }
39362 \v l { 013E }
39363 \. L { 013F }
39364 \. l { 0140 }
39365 \' N { 0143 }
39366 \' n { 0144 }
39367 \c N { 0145 }
39368 \c n { 0146 }
39369 \v N { 0147 }
39370 \v n { 0148 }
39371 \= O { 014C }
39372 \= o { 014D }
39373 \u O { 014E }
39374 \u o { 014F }
39375 \H O { 0150 }
39376 \H o { 0151 }
39377 \' R { 0154 }
39378 \' r { 0155 }
39379 \c R { 0156 }
39380 \c r { 0157 }
39381 \v R { 0158 }
39382 \v r { 0159 }
39383 \' S { 015A }
39384 \' s { 015B }
39385 \^ S { 015C }
39386 \^ s { 015D }
39387 \c S { 015E }
39388 \c s { 015F }
39389 \v S { 0160 }
39390 \v s { 0161 }
39391 \c T { 0162 }
39392 \c t { 0163 }
39393 \v T { 0164 }
39394 \v t { 0165 }
39395 \~ U { 0168 }
39396 \~ u { 0169 }
39397 \= U { 016A }
39398 \= u { 016B }
39399 \u U { 016C }
39400 \u u { 016D }
39401 \r U { 016E }
39402 \r u { 016F }
39403 \H U { 0170 }
39404 \H u { 0171 }
39405 \k U { 0172 }
39406 \k u { 0173 }
39407 \^ W { 0174 }
39408 \^ w { 0175 }
39409 \^ Y { 0176 }
39410 \^ y { 0177 }
39411 \" Y { 0178 }
39412 \' Z { 0179 }
39413 \' z { 017A }
39414 \. Z { 017B }
39415 \. z { 017C }
39416 \v Z { 017D }
39417 \v z { 017E }
39418 \v A { 01CD }
39419 \v a { 01CE }
39420 \v I { 01CF }
39421 \v \i { 01D0 }
39422 \v i { 01D0 }
39423 \v O { 01D1 }
39424 \v o { 01D2 }
39425 \v U { 01D3 }
39426 \v u { 01D4 }
39427 \v G { 01E6 }
39428 \v g { 01E7 }
39429 \v K { 01E8 }
39430 \v k { 01E9 }
39431 \k O { 01EA }
39432 \k o { 01EB }
39433 \v \j { 01F0 }
39434 \v j { 01F0 }
39435 \' G { 01F4 }
39436 \' g { 01F5 }
39437 \` N { 01F8 }
39438 \` n { 01F9 }
39439 \' \AE { 01FC }
39440 \' \ae { 01FD }
39441 \' \O { 01FE }
39442 \' \o { 01FF }
39443 \v H { 021E }
39444 \v h { 021F }
39445 \. A { 0226 }
39446 \. a { 0227 }
39447 \c E { 0228 }
39448 \c e { 0229 }
39449 \. O { 022E }
39450 \. o { 022F }
39451 \= Y { 0232 }
39452 \= y { 0233 }
39453 \q_recursion_tail ? { }
39454 \q_recursion_stop
39455 \group_end:
39456 %% File: l3text-utils.dtx
39457 \prop_const_from_keyval:Nn \c__text_bcp_normal_prop
39458 {
39459 en-gb-oed = en-gb-oxendict ,
39460 i-ami = ami ,
39461 i-bnn = bnn ,
39462 i-hak = hak ,
39463 i-klingon = tlh ,
39464 i-lux = lb ,
39465 i-navajo = nv ,
39466 i-pwn = pwn ,
39467 i-tao = tao ,
39468 i-tay = tay ,
39469 i-tsu = tsu ,
39470 sgn-be-fr = sfb ,
39471 sgn-be-nl = vgt ,
39472 sgn-ch-de = sgg ,
39473 art-lojban = jbo ,
39474 no-bok = nb ,
39475 no-nyn = nn ,
39476 zh-guoyu = cmn ,
39477 zh-hakka = hak ,
39478 zh-min-nan = nan ,
39479 zh-xiang = hsn
39480 }
39481 \prop_make_linked:N \c__text_bcp_normal_prop
39482 \cs_new:Npn \text_bcp_parse:n #1
39483 {
39484 \tl_if_blank:nTF {#1}
39485 { \msg_expandable_error:nn { text } { bcp-blank } }
39486 { \exp_args:Ne \__text_bcp_parse_auxi:n { \str_casefold:n {#1} } }
39487 }
39488 \cs_new:Npn \__text_bcp_parse_auxi:n #1
39489 {
39490 \exp_args:Ne \__text_bcp_parse_auxii:nn
39491 { \prop_item:Nn \c__text_bcp_normal_prop {#1} }
39492 {#1}
39493 }
39494 \cs_new:Npn \__text_bcp_parse_auxii:nn #1#2
39495 {
39496 \tl_if_blank:nTF {#1}
39497 { \__text_bcp_parse_auxiii:n {#2} }
39498 { \__text_bcp_parse_auxiii:n {#1} }
39499 }
39500 \cs_new:Npn \__text_bcp_parse_auxiii:n #1
39501 {
39502 \__text_bcp_parse_auxiv:w #1 - \q_recursion_tail - \q_recursion_stop
39503 }
39504 \cs_new:Npn \__text_bcp_parse_auxiv:w #1 -
39505 {
39506 \int_compare:nTF { 1 < \__text_bcp_parse_count:n {#1} < 4 }
39507 {
39508 {#1}
39509 \__text_bcp_parse_auxv:w
39510 }
39511 { \msg_expandable_error:nn { text } { bcp-invalid-lang } }
39512 }
39513 \cs_new:Npn \__text_bcp_parse_auxv:w #1 -
39514 {
39515 \quark_if_recursion_tail_stop_do:nn {#1}
39516 { { } { } { } { } { } { } }
39517 \int_case:nnF { \__text_bcp_parse_count:n {#1} }
39518 {
39519 { 1 } { { } { } { } { } \__text_bcp_parse_ext:n }
39520 { 2 } { { } { } \__text_bcp_parse_region:n }
39521 { 3 } { \__text_bcp_parse_extlang:n }
39522 { 4 } { { } \__text_bcp_parse_auxvi:n }
39523 { 5 } { { } { } { } \__text_bcp_parse_variant:n }
39524 { 6 } { { } { } { } \__text_bcp_parse_variant:n }
39525 { 7 } { { } { } { } \__text_bcp_parse_variant:n }
39526 { 8 } { { } { } { } \__text_bcp_parse_variant:n }
39527 }
39528 {
39529 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39530 \use_none_delimit_by_q_recursion_stop:w
39531 }
39532 {#1}
39533 }
39534 \cs_new:Npn \__text_bcp_parse_auxvi:n #1
39535 { \__text_bcp_parse_auxvii:NNNN #1 }
39536 \cs_new:Npn \__text_bcp_parse_auxvii:NNNN #1#2#3#4
39537 {
39538 \bool_lazy_or:nnTF
39539 { \int_compare_p:nNn {`#1} < { `0 } }
39540 { \int_compare_p:nNn {`#1} > { `9 } }
39541 { \__text_bcp_parse_script:n }
39542 { { } { } \__text_bcp_parse_variant:n }
39543 {#1#2#3#4}
39544 }
39545 \cs_new:Npn \__text_bcp_parse_extlang:n #1
39546 { \__text_bcp_parse_extlang:nw { {#1} } }
39547 \cs_new:Npn \__text_bcp_parse_extlang:nw #1#2 -
39548 {
39549 \quark_if_recursion_tail_stop_do:nn {#2}
39550 { {#1} { } { } { } { } { } }
39551 \int_case:nnF { \__text_bcp_parse_count:n {#2} }
39552 {
39553 { 1 } { { {#1} } { } { } { } \__text_bcp_parse_ext:n }
39554 { 2 } { { {#1} } { } \__text_bcp_parse_region:n }
39555 { 3 } { \__text_bcp_parse_extlang:nn {#1} }
39556 { 4 } { { {#1} } \__text_bcp_parse_auxvi:n }
39557 { 5 } { { {#1} } { } { } \__text_bcp_parse_variant:n }
39558 { 6 } { { {#1} } { } { } \__text_bcp_parse_variant:n }
39559 { 7 } { { {#1} } { } { } \__text_bcp_parse_variant:n }
39560 { 8 } { { {#1} } { } { } \__text_bcp_parse_variant:n }
39561 }
39562 {
39563 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39564 \use_none_delimit_by_q_recursion_stop:w
39565 }
39566 {#2}
39567 }
39568 \cs_new:Npn \__text_bcp_parse_extlang:nn #1#2
39569 {
39570 \int_compare:nNnTF { \tl_count:n {#1} } = 3
39571 {
39572 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39573 \use_none_delimit_by_q_recursion_stop:w
39574 }
39575 { \__text_bcp_parse_extlang:nw { #1 {#2} } }
39576 }
39577 \cs_new:Npn \__text_bcp_parse_script:n #1
39578 {
39579 {#1}
39580 \__text_bcp_parse_script:w
39581 }
39582 \cs_new:Npn \__text_bcp_parse_script:w #1 -
39583 {
39584 \quark_if_recursion_tail_stop_do:nn {#1}
39585 { { } { } { } { } }
39586 \int_case:nnF { \__text_bcp_parse_count:n {#1} }
39587 {
39588 { 1 } { { } { } \__text_bcp_parse_ext:n }
39589 { 2 } { \__text_bcp_parse_region:n }
39590 { 4 } { { } \__text_bcp_parse_variant_chk:n }
39591 { 5 } { { } \__text_bcp_parse_variant:n }
39592 { 6 } { { } \__text_bcp_parse_variant:n }
39593 { 7 } { { } \__text_bcp_parse_variant:n }
39594 { 8 } { { } \__text_bcp_parse_variant:n }
39595 }
39596 {
39597 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39598 \use_none_delimit_by_q_recursion_stop:w
39599 }
39600 {#1}
39601 }
39602 \cs_new:Npn \__text_bcp_parse_region:n #1
39603 {
39604 {#1}
39605 \__text_bcp_parse_region:w
39606 }
39607 \cs_new:Npn \__text_bcp_parse_region:w #1 -
39608 {
39609 \quark_if_recursion_tail_stop_do:nn {#1}
39610 { { } { } { } }
39611 \int_case:nnF { \__text_bcp_parse_count:n {#1} }
39612 {
39613 { 1 } { { } \__text_bcp_parse_ext:n }
39614 { 4 } { \__text_bcp_parse_variant_chk:n }
39615 { 5 } { \__text_bcp_parse_variant:n }
39616 { 6 } { \__text_bcp_parse_variant:n }
39617 { 7 } { \__text_bcp_parse_variant:n }
39618 { 8 } { \__text_bcp_parse_variant:n }
39619 }
39620 {
39621 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39622 \use_none_delimit_by_q_recursion_stop:w
39623 }
39624 {#1}
39625 }
39626 \cs_new:Npn \__text_bcp_parse_variant_chk:n #1
39627 { \__text_bcp_parse_variant_chk:NNNN #1 }
39628 \cs_new:Npn \__text_bcp_parse_variant_chk:NNNN #1#2#3#4
39629 {
39630 \bool_lazy_or:nnTF
39631 { \int_compare_p:nNn {`#1} < { `0 } }
39632 { \int_compare_p:nNn {`#1} > { `9 } }
39633 {
39634 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39635 \use_none_delimit_by_q_recursion_stop:w
39636 }
39637 { \__text_bcp_parse_variant:n }
39638 {#1#2#3#4}
39639 }
39640 \cs_new:Npn \__text_bcp_parse_variant:n #1
39641 { \__text_bcp_parse_variant:nw { {#1} } }
39642 \cs_new:Npn \__text_bcp_parse_variant:nw #1#2 -
39643 {
39644 \quark_if_recursion_tail_stop_do:nn {#2}
39645 { {#1} { } { } }
39646 \int_case:nnF { \__text_bcp_parse_count:n {#2} }
39647 {
39648 { 1 } { \__text_bcp_parse_variant_end:nn }
39649 { 4 } { \__text_bcp_parse_variant_chk:nn }
39650 { 5 } { \__text_bcp_parse_variant:nn }
39651 { 6 } { \__text_bcp_parse_variant:nn }
39652 { 7 } { \__text_bcp_parse_variant:nn }
39653 { 8 } { \__text_bcp_parse_variant:nn }
39654 }
39655 {
39656 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39657 \use_none_delimit_by_q_recursion_stop:w
39658 }
39659 {#1} {#2}
39660 }
39661 \cs_new:Npn \__text_bcp_parse_variant:nn #1#2
39662 { \__text_bcp_parse_variant:nw { #2 {#1} } }
39663 \cs_new:Npn \__text_bcp_parse_variant_chk:nn #1#2
39664 { \__text_bcp_parse_variant_chk:NNNNn #1 {#2} }
39665 \cs_new:Npn \__text_bcp_parse_variant_chk:NNNNn #1#2#3#4
39666 {
39667 \bool_lazy_or:nnTF
39668 { \int_compare_p:nNn {`#1} < { `0 } }
39669 { \int_compare_p:nNn {`#1} > { `9 } }
39670 {
39671 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39672 \use_none_delimit_by_q_recursion_stop:w
39673 }
39674 { \__text_bcp_parse_variant:nn }
39675 {#1#2#3#4} {#2}
39676 }
39677 \cs_new:Npn \__text_bcp_parse_variant_end:nn #1#2
39678 {
39679 {#2}
39680 \__text_bcp_parse_ext:n {#1}
39681 }
39682 \cs_new:Npn \__text_bcp_parse_ext:n #1
39683 {
39684 \str_if_eq:nnTF {#1} { x }
39685 {
39686 { }
39687 \__text_bcp_parse_private:nw { }
39688 }
39689 { \__text_bcp_parse_ext:nN { } #1 }
39690 }
39691 \cs_new:Npn \__text_bcp_parse_ext:nN #1#2
39692 {
39693 \bool_lazy_or:nnTF
39694 { \str_if_eq_p:nn {#2} { t } }
39695 { \str_if_eq_p:nn {#2} { u } }
39696 {
39697 \bool_lazy_or:nnTF
39698 { \tl_if_head_eq_charcode_p:nN {#1} #2 }
39699 { \int_compare_p:nNn { \tl_count:n {#1} } > 2 }
39700 {
39701 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39702 \use_none_delimit_by_q_recursion_stop:w
39703 }
39704 { \__text_bcp_parse_ext:nNnw {#1} #2 { } }
39705 }
39706 {
39707 \str_if_eq:nnTF {#2} { x }
39708 {
39709 {#1}
39710 \__text_bcp_parse_private:nw { }
39711 }
39712 {
39713 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39714 \use_none_delimit_by_q_recursion_stop:w
39715 }
39716 }
39717 }
39718 \cs_new:Npn \__text_bcp_parse_ext:nNnw #1#2#3#4 -
39719 {
39720 \quark_if_recursion_tail_stop_do:nn {#4}
39721 {
39722 \str_if_empty:nTF {#3}
39723 { \msg_expandable_error:nn { text } { bcp-invalid-subtag } }
39724 { { #1 #2 {#3} } { } }
39725 }
39726 \int_compare:nTF { 1 < \__text_bcp_parse_count:n {#4} < 9 }
39727 { \__text_bcp_parse_ext:nNnw {#1} #2 { #3 {#4} } }
39728 {
39729 \int_compare:nNnTF { \__text_bcp_parse_count:n {#4} } = 1
39730 {
39731 \str_if_empty:nTF {#3}
39732 {
39733 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39734 \use_none_delimit_by_q_recursion_stop:w
39735 }
39736 {
39737 \use:e
39738 {
39739 \exp_not:n { \__text_bcp_parse_ext:nN { #1 #2 {#3} } }
39740 \str_casefold:n {#4}
39741 }
39742 }
39743 }
39744 {
39745 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39746 \use_none_delimit_by_q_recursion_stop:w
39747 }
39748 }
39749 }
39750 \cs_new:Npn \__text_bcp_parse_private:nw #1#2 -
39751 {
39752 \quark_if_recursion_tail_stop_do:nn {#2}
39753 {
39754 \str_if_empty:nTF {#1}
39755 { \msg_expandable_error:nn { text } { bcp-invalid-subtag } }
39756 { {#1} }
39757 }
39758 \int_compare:nTF { 0 < \__text_bcp_parse_count:n {#2} < 9 }
39759 { \__text_bcp_parse_private:nw { #1 {#2} } }
39760 {
39761 \msg_expandable_error:nn { text } { bcp-invalid-subtag }
39762 \use_none_delimit_by_q_recursion_stop:w
39763 }
39764 }
39765 \cs_new:Npn \__text_bcp_parse_count:n #1
39766 {
39767 \__text_bcp_parse_count_auxi:w #1
39768 \q_nil \q_nil \q_nil \q_nil \q_nil \q_nil \q_nil \q_nil \q_nil
39769 \q_stop {#1}
39770 }
39771 \cs_new:Npn \__text_bcp_parse_count_auxi:w #1#2#3#4#5#6#7#8#9
39772 {
39773 \quark_if_nil:NTF #9
39774 { \__text_bcp_parse_count_auxii:w }
39775 { \msg_expandable_error:nn { text } { bcp-invalid-lang } }
39776 }
39777 \cs_new:Npn \__text_bcp_parse_count_auxii:w #1 \q_stop #2
39778 { \__text_bcp_parse_count_auxiii:w #2 876543210 \q_stop }
39779 \cs_new:Npn \__text_bcp_parse_count_auxiii:w #1#2#3#4#5#6#7#8#9
39780 { \__text_bcp_parse_count_auxiv:N #9 }
39781 \cs_new:Npn \__text_bcp_parse_count_auxiv:N #1#2 \q_stop {#1}
39782 \msg_new:nnn { text } { bcp-blank }
39783 { Empty~input~for~BCP~47~decoding. }
39784 \msg_new:nnn { text } { bcp-invalid-lang }
39785 { Invalid~language~in~BCP~input. }
39786 \msg_new:nnn { text } { bcp-invalid-subtag }
39787 { Invalid~subtag~in~BCP~input. }
39788 %% File: l3legacy.dtx
39789 \prg_new_conditional:Npnn \legacy_if:n #1 { p , T , F , TF }
39790 {
39791 \exp_after:wN \reverse_if:N
39792 \cs:w if#1 \cs_end:
39793 \prg_return_false:
39794 \else:
39795 \prg_return_true:
39796 \fi:
39797 }
39798 \cs_new_protected:Npn \legacy_if_set_true:n #1
39799 { \cs_set_eq:cN { if#1 } \if_true: }
39800 \cs_new_protected:Npn \legacy_if_set_false:n #1
39801 { \cs_set_eq:cN { if#1 } \if_false: }
39802 \cs_new_protected:Npn \legacy_if_gset_true:n #1
39803 { \cs_gset_eq:cN { if#1 } \if_true: }
39804 \cs_new_protected:Npn \legacy_if_gset_false:n #1
39805 { \cs_gset_eq:cN { if#1 } \if_false: }
39806 \cs_new_protected:Npn \legacy_if_set:nn #1#2
39807 {
39808 \bool_if:nTF {#2} \legacy_if_set_true:n \legacy_if_set_false:n
39809 {#1}
39810 }
39811 \cs_new_protected:Npn \legacy_if_gset:nn #1#2
39812 {
39813 \bool_if:nTF {#2} \legacy_if_gset_true:n \legacy_if_gset_false:n
39814 {#1}
39815 }
39816 %% File: l3deprecation.dtx
39817 \cs_new_protected:Npn \__kernel_patch_deprecation:nnNNpn #1#2#3#4#5#
39818 { \__deprecation_patch_aux:nnNNnn {#1} {#2} #3 #4 {#5} }
39819 \cs_new_protected:Npn \__deprecation_patch_aux:nnNNnn #1#2#3#4#5#6
39820 {
39821 \__kernel_deprecation_code:nn
39822 {
39823 \tex_let:D #4 \scan_stop:
39824 \__kernel_deprecation_error:Nnn #4 {#2} {#1}
39825 }
39826 { \tex_let:D #4 \scan_stop: }
39827 \cs_if_eq:NNTF #3 \cs_gset_protected:Npn
39828 { \__deprecation_warn_once:nnNnn {#1} {#2} #4 {#5} {#6} }
39829 { \__deprecation_patch_aux:Nn #3 { #4 #5 {#6} } }
39830 }
39831 \cs_new_protected:Npn \__deprecation_warn_once:nnNnn #1#2#3#4#5
39832 {
39833 \cs_gset_protected:Npe #3
39834 {
39835 \__kernel_if_debug:TF
39836 {
39837 \exp_not:N \msg_warning:nneee
39838 { deprecation } { deprecated-command }
39839 {#1}
39840 { \token_to_str:N #3 }
39841 { \tl_to_str:n {#2} }
39842 }
39843 { }
39844 \exp_not:n { \cs_gset_protected:Npn #3 #4 {#5} }
39845 \exp_not:N #3
39846 }
39847 \__kernel_deprecation_code:nn { }
39848 { \cs_set_protected:Npn #3 #4 {#5} }
39849 }
39850 \cs_new_protected:Npn \__deprecation_patch_aux:Nn #1#2
39851 {
39852 #1 #2
39853 \cs_if_eq:NNTF #1 \cs_gset_protected:Npn
39854 { \__kernel_deprecation_code:nn { } { \cs_set_protected:Npn #2 } }
39855 { \__kernel_deprecation_code:nn { } { \cs_set:Npn #2 } }
39856 }
39857 \cs_new_protected:Npn \__kernel_deprecation_error:Nnn #1#2#3
39858 {
39859 \tex_protected:D \tex_outer:D \tex_edef:D #1
39860 {
39861 \exp_not:N \msg_expandable_error:nnnnn
39862 { deprecation } { deprecated-command }
39863 { \tl_to_str:n {#3} } { \token_to_str:N #1 } { \tl_to_str:n {#2} }
39864 \exp_not:N \msg_error:nneee
39865 { deprecation } { deprecated-command }
39866 { \tl_to_str:n {#3} } { \token_to_str:N #1 } { \tl_to_str:n {#2} }
39867 }
39868 }
39869 \msg_new:nnn { deprecation } { deprecated-command }
39870 {
39871 \tl_if_blank:nF {#3} { Use~ \tl_trim_spaces:n {#3} ~not~ }
39872 #2~deprecated~on~#1.
39873 }
39874 \cs_new:Npn \cs_argument_spec:N { \cs_parameter_spec:N }
39875 \cs_new_protected:Npn \iow_shipout_x:Nn { \iow_shipout_e:Nn }
39876 \cs_generate_variant:Nn \iow_shipout_x:Nn { Nx , c, cx }
39877 \cs_new_protected:cpn { \c__keys_props_root_str .str_set_x:N } #1
39878 { \__keys_variable_set:NnnN #1 { str } { } x }
39879 \cs_new_protected:cpn { \c__keys_props_root_str .str_set_x:c } #1
39880 { \__keys_variable_set:cnnN {#1} { str } { } x }
39881 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset_x:N } #1
39882 { \__keys_variable_set:NnnN #1 { str } { g } x }
39883 \cs_new_protected:cpn { \c__keys_props_root_str .str_gset_x:c } #1
39884 { \__keys_variable_set:cnnN {#1} { str } { g } x }
39885 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set_x:N } #1
39886 { \__keys_variable_set:NnnN #1 { tl } { } x }
39887 \cs_new_protected:cpn { \c__keys_props_root_str .tl_set_x:c } #1
39888 { \__keys_variable_set:cnnN {#1} { tl } { } x }
39889 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset_x:N } #1
39890 { \__keys_variable_set:NnnN #1 { tl } { g } x }
39891 \cs_new_protected:cpn { \c__keys_props_root_str .tl_gset_x:c } #1
39892 { \__keys_variable_set:cnnN {#1} { tl } { g } x }
39893 \cs_new_protected:Npn \keys_set_filter:nnn { \keys_set_exclude_groups:nnn }
39894 \cs_generate_variant:Nn \keys_set_filter:nnn { nnV , nnv , nno }
39895 \cs_new_protected:Npn \keys_set_filter:nnnN { \keys_set_exclude_groups:nnnN }
39896 \cs_generate_variant:Nn \keys_set_filter:nnnN { nnV , nnv , nno }
39897 \cs_new_protected:Npn \keys_set_filter:nnnnN { \keys_set_exclude_groups:nnnnN }
39898 \cs_generate_variant:Nn \keys_set_filter:nnnnN { nnV , nnv , nno }
39899 \__kernel_patch_deprecation:nnNNpn { 2024-02-13 } { \msg_set:nnnn }
39900 \cs_new_protected:Npn \msg_gset:nnnn { \msg_set:nnnn }
39901 \__kernel_patch_deprecation:nnNNpn { 2024-02-13 } { \msg_set:nnn }
39902 \cs_new_protected:Npn \msg_gset:nnn { \msg_set:nnn }
39903 \prop_new:N \g__pdf_object_prop
39904 \__kernel_patch_deprecation:nnNNpn { 2022-08-30 } { [\pdf_object_new:n] }
39905 \cs_new_protected:Npn \pdf_object_new:nn #1#2
39906 {
39907 \prop_gput:Nnn \g__pdf_object_prop {#1} {#2}
39908 \pdf_object_new:n {#1}
39909 }
39910 \__kernel_patch_deprecation:nnNNpn { 2022-08-30 } { [\pdf_object_write:n] }
39911 \cs_new_protected:Npn \pdf_object_write:nn #1#2
39912 {
39913 \exp_args:Nee \__pdf_backend_object_write:nnn
39914 { \__pdf_object_retrieve:n {#1} }
39915 { \prop_item:Nn \g__pdf_object_prop {#1} } {#2}
39916 \bool_gset_true:N \g__pdf_init_bool
39917 }
39918 \cs_generate_variant:Nn \pdf_object_write:nn { nx }
39919 \__kernel_patch_deprecation:nnNNpn { 2023-05-03 } { \bool_case:n }
39920 \cs_new:Npn \bool_case_true:n { \bool_case:n }
39921 \__kernel_patch_deprecation:nnNNpn { 2023-05-03 } { \bool_case:nT }
39922 \cs_new:Npn \bool_case_true:nT { \bool_case:nT }
39923 \__kernel_patch_deprecation:nnNNpn { 2023-05-03 } { \bool_case:nF }
39924 \cs_new:Npn \bool_case_true:nF { \bool_case:nF }
39925 \__kernel_patch_deprecation:nnNNpn { 2023-05-03 } { \bool_case:nTF }
39926 \cs_new:Npn \bool_case_true:nTF { \bool_case:nTF }
39927 \cs_new_protected:Npn \regex_match:nnT { \regex_if_match:nnT }
39928 \cs_new_protected:Npn \regex_match:nnF { \regex_if_match:nnF }
39929 \cs_new_protected:Npn \regex_match:nnTF { \regex_if_match:nnTF }
39930 \cs_new_protected:Npn \regex_match:NnT { \regex_if_match:NnT }
39931 \cs_new_protected:Npn \regex_match:NnF { \regex_if_match:NnF }
39932 \cs_new_protected:Npn \regex_match:NnTF { \regex_if_match:NnTF }
39933 \prg_generate_conditional_variant:Nnn \regex_match:nn
39934 { nV } { T , F , TF }
39935 \prg_generate_conditional_variant:Nnn \regex_match:Nn
39936 { NV } { T , F , TF }
39937 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_lowercase:n }
39938 \cs_new:Npn \str_lower_case:n { \str_lowercase:n }
39939 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_lowercase:f }
39940 \cs_new:Npn \str_lower_case:f { \str_lowercase:f }
39941 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_uppercase:n }
39942 \cs_new:Npn \str_upper_case:n { \str_uppercase:n }
39943 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_uppercase:f }
39944 \cs_new:Npn \str_upper_case:f { \str_uppercase:f }
39945 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:n }
39946 \cs_new:Npn \str_fold_case:n { \str_casefold:n }
39947 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:V }
39948 \cs_new:Npn \str_fold_case:V { \str_casefold:V }
39949 \__kernel_patch_deprecation:nnNNpn { 2020-10-17 } { \str_casefold:n }
39950 \cs_new:Npn \str_foldcase:n { \str_casefold:n }
39951 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_casefold:V }
39952 \cs_new:Npn \str_foldcase:V { \str_casefold:V }
39953 \__kernel_patch_deprecation:nnNNpn { 2020-08-20 } { }
39954 \cs_new_protected:Npn \str_declare_eight_bit_encoding:nnn #1
39955 { \__str_declare_eight_bit_encoding:nnnn {#1} { 1114112 } }
39956 \__kernel_patch_deprecation:nnNNpn { 2020-06-18 } { \seq_map_indexed_inline:Nn }
39957 \cs_new_protected:Npn \seq_indexed_map_inline:Nn { \seq_map_indexed_inline:Nn }
39958 \__kernel_patch_deprecation:nnNNpn { 2020-06-18 } { \seq_map_indexed_function:NN }
39959 \cs_new:Npn \seq_indexed_map_function:NN { \seq_map_indexed_function:NN }
39960 \__kernel_patch_deprecation:nnNNpn { 2023-05-10 } { \seq_map_pairwise_function:NNN }
39961 \cs_new:Npn \seq_mapthread_function:NNN { \seq_map_pairwise_function:NNN }
39962 \__kernel_patch_deprecation:nnNNpn { 2023-10-26 } { \seq_set_map_e:NNn }
39963 \cs_new_protected:Npn \seq_set_map_x:NNn { \seq_set_map_e:NNn }
39964 \__kernel_patch_deprecation:nnNNpn { 2023-10-26 } { \seq_gset_map_e:NNn }
39965 \cs_new_protected:Npn \seq_gset_map_x:NNn { \seq_gset_map_e:NNn }
39966 \__kernel_patch_deprecation:nnNNpn { 2025-05-25 } { \sys_finalize: }
39967 \cs_new_protected:Npn \sys_finalise: { \sys_finalize: }
39968 \__kernel_patch_deprecation:nnNNpn { 2021-01-11 } { (no~longer~required) }
39969 \cs_new_protected:Npn \sys_load_deprecation: { }
39970 \__kernel_patch_deprecation:nnNNpn { 2025-03-26 } { (no~longer~required) }
39971 \cs_new:Npn \sys_if_timer_exist:T #1 {#1}
39972 \__kernel_patch_deprecation:nnNNpn { 2025-03-26 } { (no~longer~required) }
39973 \cs_new:Npn \sys_if_timer_exist:F #1 { }
39974 \__kernel_patch_deprecation:nnNNpn { 2025-03-26 } { (no~longer~required) }
39975 \cs_new:Npn \sys_if_timer_exist:TF #1#2 {#1}
39976 \__kernel_patch_deprecation:nnNNpn { 2025-03-26 } { (no~longer~required) }
39977 \cs_new:Npn \sys_if_timer_exist_p: { \c_true_bool }
39978 \__kernel_patch_deprecation:nnNNpn { 2023-07-08 } { \text_titlecase_first:n }
39979 \cs_new:Npn \text_titlecase:n #1
39980 { \text_titlecase_first:n { \text_lowercase:n {#1} } }
39981 \__kernel_patch_deprecation:nnNNpn { 2023-07-08 } { \text_titlecase_first:nn }
39982 \cs_new:Npn \text_titlecase:nn #1#2
39983 { \text_titlecase_first:nn {#1} { \text_lowercase:n {#2} } }
39984 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_lowercase:n }
39985 \cs_new:Npn \tl_lower_case:n #1
39986 { \text_lowercase:n {#1} }
39987 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_lowercase:nn }
39988 \cs_new:Npn \tl_lower_case:nn #1#2
39989 { \text_lowercase:nn {#1} {#2} }
39990 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_uppercase:n }
39991 \cs_new:Npn \tl_upper_case:n #1
39992 { \text_uppercase:n {#1} }
39993 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_uppercase:nn }
39994 \cs_new:Npn \tl_upper_case:nn #1#2
39995 { \text_uppercase:nn {#1} {#2} }
39996 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_titlecase_first:n }
39997 \cs_new:Npn \tl_mixed_case:n #1
39998 { \text_titlecase_first:n { \text_lowercase:n {#1} } }
39999 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_titlecase_first:nn }
40000 \cs_new:Npn \tl_mixed_case:nn #1#2
40001 { \text_titlecase_first:nn {#1} { \text_lowercase:n {#2} } }
40002 \__kernel_patch_deprecation:nnNNpn { 2022-05-23 } { \token_case_meaning:Nn }
40003 \cs_new:Npn \tl_case:Nn { \token_case_meaning:Nn }
40004 \__kernel_patch_deprecation:nnNNpn { 2022-05-23 } { \token_case_meaning:NnT }
40005 \cs_new:Npn \tl_case:NnT { \token_case_meaning:NnT }
40006 \__kernel_patch_deprecation:nnNNpn { 2022-05-23 } { \token_case_meaning:NnF }
40007 \cs_new:Npn \tl_case:NnF { \token_case_meaning:NnF }
40008 \__kernel_patch_deprecation:nnNNpn { 2022-05-23 } { \token_case_meaning:NnTF }
40009 \cs_new:Npn \tl_case:NnTF { \token_case_meaning:NnTF }
40010 \cs_generate_variant:Nn \tl_case:Nn { c }
40011 \prg_generate_conditional_variant:Nnn \tl_case:Nn
40012 { c } { T , F , TF }
40013 \__kernel_patch_deprecation:nnNNpn { 2023-10-18 } { \tl_build_begin:N }
40014 \cs_new_protected:Npn \tl_build_clear:N { \tl_build_begin:N }
40015 \__kernel_patch_deprecation:nnNNpn { 2023-10-18 } { \tl_build_gbegin:N }
40016 \cs_new_protected:Npn \tl_build_gclear:N { \tl_build_gbegin:N }
40017 \__kernel_patch_deprecation:nnNNpn { 2023-10-25 } { \tl_build_get_intermediate:NN }
40018 \cs_new_protected:Npn \tl_build_get:NN { \tl_build_get_intermediate:NN }
40019 \__kernel_patch_deprecation:nnNNpn { 2022-10-09 } { [ \codepoint_generate:nn ] }
40020 \cs_new:Npn \char_to_utfviii_bytes:n { \__kernel_codepoint_to_bytes:n }
40021 \__kernel_patch_deprecation:nnNNpn { 2022-10-09 } { \codepoint_to_nfd:n }
40022 \cs_new:Npn \char_to_nfd:N #1 { \codepoint_to_nfd:n {`#1} }
40023 \__kernel_patch_deprecation:nnNNpn { 2022-10-09 } { \codepoint_to_nfd:n }
40024 \cs_new:Npn \char_to_nfd:n { \codepoint_to_nfd:n }
40025 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_lowercase:n }
40026 \cs_new:Npn \char_lower_case:N { \text_lowercase:n }
40027 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_uppercase:n }
40028 \cs_new:Npn \char_upper_case:N { \text_uppercase:n }
40029 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \text_titlecase_first:n }
40030 \cs_new:Npn \char_mixed_case:N { \text_titlecase_first:n }
40031 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:n }
40032 \cs_new:Npn \char_fold_case:N { \str_casefold:n }
40033 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_lowercase:n }
40034 \cs_new:Npn \char_str_lower_case:N { \str_lowercase:n }
40035 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_uppercase:n }
40036 \cs_new:Npn \char_str_upper_case:N { \str_uppercase:n }
40037 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_titlecase:n }
40038 \cs_new:Npn \char_str_mixed_case:N { \str_titlecase:n }
40039 \__kernel_patch_deprecation:nnNNpn { 2020-01-03 } { \str_casefold:n }
40040 \cs_new:Npn \char_str_fold_case:N { \str_casefold:n }
40041 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \text_lowercase:n }
40042 \cs_new:Npn \char_lowercase:N { \text_lowercase:n }
40043 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \text_uppercase:n }
40044 \cs_new:Npn \char_uppercase:N { \text_uppercase:n }
40045 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \text_titlecase_first:n }
40046 \cs_new:Npn \char_titlecase:N { \text_titlecase_first:n }
40047 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_casefold:n }
40048 \cs_new:Npn \char_foldcase:N { \str_casefold:n }
40049 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_lowercase:n }
40050 \cs_new:Npn \char_str_lowercase:N { \str_lowercase:n }
40051 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 }
40052 { \tl_to_str:e { \text_titlecase_first:n } }
40053 \cs_new:Npn \char_str_titlecase:N #1
40054 { \tl_to_str:e { \text_titlecase_first:n {#1} } }
40055 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_uppercase:n }
40056 \cs_new:Npn \char_str_uppercase:N { \str_uppercase:n }
40057 \__kernel_patch_deprecation:nnNNpn { 2022-10-17 } { \str_casefold:n }
40058 \cs_new:Npn \char_str_foldcase:N { \str_casefold:n }
40059 \tl_map_inline:nn
40060 {
40061 { catcode } { catcode_remove }
40062 { charcode } { charcode_remove }
40063 { meaning } { meaning_remove }
40064 }
40065 {
40066 \use:e
40067 {
40068 \__kernel_patch_deprecation:nnNNpn { 2022-01-11 } { \peek_remove_spaces:n }
40069 \cs_gset_protected:Npn \exp_not:c { peek_ #1 _ignore_spaces:NTF } ##1##2##3
40070 {
40071 \peek_remove_spaces:n
40072 { \exp_not:c { peek_ #1 :NTF } ##1 {##2} {##3} }
40073 }
40074 \__kernel_patch_deprecation:nnNNpn { 2022-01-11 } { \peek_remove_spaces:n }
40075 \cs_gset_protected:Npn \exp_not:c { peek_ #1 _ignore_spaces:NT } ##1##2
40076 {
40077 \peek_remove_spaces:n
40078 { \exp_not:c { peek_ #1 :NT } ##1 {##2} }
40079 }
40080 \__kernel_patch_deprecation:nnNNpn { 2022-01-11 } { \peek_remove_spaces:n }
40081 \cs_gset_protected:Npn \exp_not:c { peek_ #1 _ignore_spaces:NF } ##1##2
40082 {
40083 \peek_remove_spaces:n
40084 { \exp_not:c { peek_ #1 :NF } ##1 {##2} }
40085 }
40086 }
40087 }
40088 \cs_new_protected:Npn \prop_put_if_new:Nnn { \prop_put_if_not_in:Nnn }
40089 \cs_new_protected:Npn \prop_gput_if_new:Nnn { \prop_gput_if_not_in:Nnn }
40090 \cs_generate_variant:Nn \prop_put_if_new:Nnn
40091 { NnV , NV , c , cnV , cV }
40092 \cs_generate_variant:Nn \prop_gput_if_new:Nnn
40093 { NnV , NV , c , cnV , cV }
40094 %%
40095 %%
40096 %% End of file `expl3-code.tex'.