Debian Codegraph @

texmf-dist/source/latex/l3kernel/l3sys.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3sys.dtx
4 %
5 % Copyright (C) 2015-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "l3kernel bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/latex3
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \documentclass[full,kernel]{l3doc}
27 \begin{document}
28 \DocInput{\jobname.dtx}
29 \end{document}
30 %</driver>
31 % \fi
32 %
33 % \title{^^A
34 % The \pkg{l3sys} module\\ System/runtime functions^^A
35 % }
36 %
37 % \author{^^A
38 % The \LaTeX{} Project\thanks
39 % {^^A
40 % E-mail:
41 % \href{mailto:[email protected]}
42 % {[email protected]}^^A
43 % }^^A
44 % }
45 %
46 % \date{Released 2026-05-15}
47 %
48 % \maketitle
49 %
50 % \begin{documentation}
51 %
52 % \section{The name of the job}
53 %
54 % \begin{variable}[added = 2015-09-19, updated = 2019-10-27]{\c_sys_jobname_str}
55 % Constant that gets the \enquote{job name} assigned when \TeX{} starts.
56 % \begin{texnote}
57 % This is the \TeX{} primitive \tn{jobname}. For technical
58 % reasons, the string here is not of the same internal form as other,
59 % but may be manipulated using normal string functions.
60 % \end{texnote}
61 % \end{variable}
62 %
63 % \section{Date and time}
64 %
65 % \begin{variable}[added = 2015-09-22]
66 % {
67 % \c_sys_minute_int,
68 % \c_sys_hour_int,
69 % \c_sys_day_int,
70 % \c_sys_month_int,
71 % \c_sys_year_int,
72 % }
73 % The date and time at which the current job was started: these are
74 % all reported as integers.
75 % \begin{texnote}
76 % Whilst the underlying \TeX{} primitives \tn{time}, \tn{day}, \tn{month},
77 % and~\tn{year} can be altered by the user, this
78 % interface to the time and date is intended to be the \enquote{real}
79 % values.
80 % \end{texnote}
81 % \end{variable}
82 %
83 % \begin{variable}[added = 2023-08-27]{\c_sys_timestamp_str}
84 % The timestamp for the current job: the format is as described for
85 % \cs{file_timestamp:n}.
86 % \end{variable}
87 %
88 % \section{Engine}
89 %
90 % \begin{function}[added = 2015-09-07, EXP, pTF]
91 % {
92 % \sys_if_engine_luatex:,
93 % \sys_if_engine_pdftex:,
94 % \sys_if_engine_ptex: ,
95 % \sys_if_engine_uptex: ,
96 % \sys_if_engine_xetex:
97 % }
98 % \begin{syntax}
99 % \cs{sys_if_engine_pdftex_p:}
100 % \cs{sys_if_engine_pdftex:TF} \Arg{true code} \Arg{false code}
101 % \end{syntax}
102 % Conditionals which allow engine-specific code to be used. The names
103 % follow naturally from those of the engine binaries: note that the
104 % |(u)ptex| tests are for \epTeX{} and \eupTeX{} as \pkg{expl3} requires
105 % the \eTeX{} extensions. Each conditional is true for
106 % \emph{exactly one} supported engine. In particular,
107 % |\sys_if_engine_ptex_p:| is true for \epTeX{} but false for \eupTeX{}.
108 % \end{function}
109 %
110 % \begin{function}[added = 2024-11-05, pTF]{\sys_if_engine_opentype:}
111 % \begin{syntax}
112 % \cs{sys_if_engine_opentype_p:}
113 % \cs{sys_if_engine_opentype:TF} \Arg{true code} \Arg{false code}
114 % \end{syntax}
115 % Conditional which allows functionality-specific code to be used.
116 % The test is true for engines which can use OpenType fonts and
117 % thus full Unicode typesetting. This tests for features not engine
118 % name, but currently is equivalent to requiring either
119 % \XeTeX{} or \LuaTeX{}.
120 % \begin{texnote}
121 % The underlying test here checks for \tn{Umathcode}, which
122 % is used to implement OpenType math font typesetting. Any
123 % engine which should give a \texttt{true} result here needs
124 % to provide general Unicode support (accepting the full UTF-8
125 % range for character codes), a mechanism to load system fonts
126 % and a suitable interface for math mode typesetting.
127 % \end{texnote}
128 % \end{function}
129 %
130 % \begin{variable}[added = 2015-09-19]{\c_sys_engine_str}
131 % The current engine given as a lower case string: one of
132 % |luatex|, |pdftex|, |ptex|, |uptex| or |xetex|.
133 % \end{variable}
134 %
135 % \begin{variable}[added = 2020-08-20]{\c_sys_engine_exec_str}
136 % The name of the standard executable for the current \TeX{} engine given
137 % as a lower case string: one of |luatex|,
138 % |luahbtex|, |pdftex|, |eptex|, |euptex| or |xetex|.
139 % \end{variable}
140 %
141 % \begin{variable}[added = 2020-08-20]{\c_sys_engine_format_str}
142 % The name of the preloaded format for the current \TeX{} run given
143 % as a lower case string: one of
144 % |lualatex| (or |dvilualatex|),
145 % |pdflatex| (or |latex|), |platex|, |uplatex| or |xelatex| for \LaTeX{},
146 % similar names for plain \TeX{} (except \pdfTeX{} in DVI mode yields
147 % |etex|), and |cont-en| for Con\TeX{}t (i.e., the
148 % \tn{fmtname}).
149 % \end{variable}
150 %
151 % \begin{variable}[added = 2018-05-02]{\c_sys_engine_version_str}
152 % The version string of the current engine, in the same form as
153 % given in the banner issued when running a job. For \pdfTeX{}
154 % and \LuaTeX{} this is of the form
155 % \begin{quote}
156 % \meta{major}.\meta{minor}.\meta{revision}
157 % \end{quote}
158 % For \XeTeX{}, the form is
159 % \begin{quote}
160 % \meta{major}.\meta{minor}
161 % \end{quote}
162 % For \pTeX{} and \upTeX{}, only releases since \TeX{} Live 2018
163 % make the data available, and the form is more complex, as it comprises
164 % the \pTeX{} version, the \upTeX{} version and the e-\pTeX{} version.
165 % \begin{quote}
166 % p\meta{major}.\meta{minor}.\meta{revision}-u\meta{major}.\meta{minor}^^A
167 % -\meta{epTeX}
168 % \end{quote}
169 % where the |u| part is only present for \upTeX{}.
170 % \end{variable}
171 %
172 % \begin{function}[added = 2021-05-12, EXP]{\sys_timer:}
173 % \begin{syntax}
174 % \cs{sys_timer:}
175 % \end{syntax}
176 % Expands to the current value of the engine's timer clock, a
177 % non-negative integer. This function is only defined for engines with
178 % timer support. This command measures not just CPU time but
179 % real time (including time waiting for user input). The unit are
180 % scaled seconds ($2^{-16}$ seconds).
181 % \end{function}
182 %
183 % \section{Output format}
184 %
185 % In \LaTeX{}, the output format may be set in the preamble: as such,
186 % \pkg{expl3} delays setting the information here until either
187 % \begin{itemize}
188 % \item \cs{sys_ensure_backend:} or \cs{sys_load_backend:n} are used
189 % \item |\begin{document}| is reached
190 % \end{itemize}
191 %
192 % \begin{function}[added = 2015-09-19, EXP, pTF]
193 % {
194 % \sys_if_output_dvi:,
195 % \sys_if_output_pdf:
196 % }
197 % \begin{syntax}
198 % \cs{sys_if_output_dvi_p:}
199 % \cs{sys_if_output_dvi:TF} \Arg{true code} \Arg{false code}
200 % \end{syntax}
201 % Conditionals which give the current output mode the \TeX{} run is
202 % operating in. This is always one of two outcomes, DVI mode or
203 % PDF mode. The two sets of conditionals are thus complementary and
204 % are both provided to allow the programmer to emphasize the most
205 % appropriate case.
206 % \end{function}
207 %
208 % \begin{variable}[added = 2015-09-19]{\c_sys_output_str}
209 % The current output mode given as a lower case string: one of
210 % |dvi| or |pdf|.
211 % \end{variable}
212 %
213 % \section{Platform}
214 %
215 % \begin{function}[added = 2018-07-27, EXP, pTF]
216 % {
217 % \sys_if_platform_unix:,
218 % \sys_if_platform_windows:
219 % }
220 % \begin{syntax}
221 % \cs{sys_if_platform_unix_p:}
222 % \cs{sys_if_platform_unix:TF} \Arg{true code} \Arg{false code}
223 % \end{syntax}
224 % Conditionals which allow platform-specific code to be used. The names
225 % follow the \Lua{} |os.type()| function, i.e., all Unix-like systems
226 % are |unix| (including Linux and MacOS).
227 % \end{function}
228 %
229 % \begin{variable}[added = 2018-07-27]{\c_sys_platform_str}
230 % The current platform given as a lower case string: one of
231 % |unix|, |windows| or |unknown|.
232 % \end{variable}
233 %
234 % \section{Random numbers}
235 %
236 % \begin{function}[added = 2017-05-27, EXP]{\sys_rand_seed:}
237 % \begin{syntax}
238 % \cs{sys_rand_seed:}
239 % \end{syntax}
240 % Expands to the current value of the engine's random seed, a
241 % non-negative integer. In engines without random number support this
242 % expands to $0$.
243 % \end{function}
244 %
245 % \begin{function}[added = 2017-05-27]{\sys_gset_rand_seed:n}
246 % \begin{syntax}
247 % \cs{sys_gset_rand_seed:n} \Arg{int expr}
248 % \end{syntax}
249 % Globally sets the seed for the engine's pseudo-random number
250 % generator to the \meta{integer expression}. This random seed
251 % affects all \cs[no-index]{\ldots{}_rand} functions (such as
252 % \cs{int_rand:nn} or \cs{clist_rand_item:n}) as well as other
253 % packages relying on the engine's random number generator. In
254 % engines without random number support this produces an error.
255 % \begin{texnote}
256 % While a $32$-bit (signed) integer can be given as a seed, only the
257 % absolute value is used and any number beyond $2^{28}$ is divided
258 % by an appropriate power of~$2$. We recommend using an integer in
259 % $[0,2^{28}-1]$.
260 % \end{texnote}
261 % \end{function}
262 %
263 % \section{Access to the shell}
264 %
265 % \begin{function}[noTF, added = 2019-09-20]
266 % {\sys_get_shell:nnN}
267 % \begin{syntax}
268 % \cs{sys_get_shell:nnN} \Arg{shell~command} \Arg{setup} \meta{tl~var}
269 % \cs{sys_get_shell:nnNTF} \Arg{shell~command} \Arg{setup} \meta{tl~var} \Arg{true code} \Arg{false code}
270 % \end{syntax}
271 % Defines \meta{tl~var} to the text returned by the \meta{shell command}.
272 % The \meta{shell command} is converted to a string using
273 % \cs{tl_to_str:n}. Category codes may need to be set appropriately
274 % via the \meta{setup} argument, which is run just before running the
275 % \meta{shell command} (in a group).
276 % If shell escape is disabled, the \meta{tl~var} will be set to
277 % \cs{q_no_value} in the non-branching version.
278 % Note that quote characters (|"|) \emph{cannot} be used inside the
279 % \meta{shell command}. The \cs{sys_get_shell:nnNTF} conditional
280 % inserts the \meta{true code} if the shell is available and no quote is
281 % detected, and the \meta{false code} otherwise.
282 %
283 % \emph{Note}: It is not possible to tell from \TeX{} if a command is allowed
284 % in restricted shell escape. If restricted escape is enabled, the
285 % \texttt{true} branch is taken: if the command is forbidden at this stage, a
286 % low-level \TeX{} error will arise.
287 % \end{function}
288 %
289 % \begin{variable}[added = 2017-05-27]{\c_sys_shell_escape_int}
290 % This variable exposes the internal triple of the shell escape
291 % status. The possible values are
292 % \begin{description}
293 % \item[0] Shell escape is disabled
294 % \item[1] Unrestricted shell escape is enabled
295 % \item[2] Restricted shell escape is enabled
296 % \end{description}
297 % \end{variable}
298 %
299 % \begin{function}[added = 2017-05-27, EXP, pTF]{\sys_if_shell:}
300 % \begin{syntax}
301 % \cs{sys_if_shell_p:}
302 % \cs{sys_if_shell:TF} \Arg{true code} \Arg{false code}
303 % \end{syntax}
304 % Performs a check for whether shell escape is enabled. This
305 % returns true if either of restricted or unrestricted shell escape
306 % is enabled.
307 % \end{function}
308 %
309 % \begin{function}[added = 2017-05-27, EXP, pTF]{\sys_if_shell_unrestricted:}
310 % \begin{syntax}
311 % \cs{sys_if_shell_unrestricted_p:}
312 % \cs{sys_if_shell_unrestricted:TF} \Arg{true code} \Arg{false code}
313 % \end{syntax}
314 % Performs a check for whether \emph{unrestricted} shell escape is
315 % enabled.
316 % \end{function}
317 %
318 % \begin{function}[added = 2017-05-27, EXP, pTF]{\sys_if_shell_restricted:}
319 % \begin{syntax}
320 % \cs{sys_if_shell_restricted_p:}
321 % \cs{sys_if_shell_restricted:TF} \Arg{true code} \Arg{false code}
322 % \end{syntax}
323 % Performs a check for whether \emph{restricted} shell escape is
324 % enabled. This returns false if unrestricted shell escape is
325 % enabled. Unrestricted shell escape is not considered a superset
326 % of restricted shell escape in this case. To find whether any
327 % shell escape is enabled use \cs{sys_if_shell:TF}.
328 % \end{function}
329 %
330 % \begin{function}[added = 2017-05-27]
331 % {\sys_shell_now:n, \sys_shell_now:e}
332 % \begin{syntax}
333 % \cs{sys_shell_now:n} \Arg{tokens}
334 % \end{syntax}
335 % Execute \meta{tokens} through shell escape immediately.
336 % \end{function}
337 %
338 % \begin{function}[added = 2017-05-27]
339 % {\sys_shell_shipout:n, \sys_shell_shipout:e}
340 % \begin{syntax}
341 % \cs{sys_shell_shipout:n} \Arg{tokens}
342 % \end{syntax}
343 % Execute \meta{tokens} through shell escape at shipout.
344 % \end{function}
345 %
346 % \section{System queries}
347 %
348 % Some queries can be made about the file system, etc., without needing to
349 % use unrestricted shell escape. This is carried out using the script
350 % \texttt{l3sys-query}, which is documented separately. The wrappers here
351 % use this script, if available, to obtain system information that is
352 % not directly available within the \TeX{} run. Note that if restricted
353 % shell escape is disabled, no results can be obtained.
354 %
355 % \begin{function}[added = 2024-03-08, updated = 2024-04-08]
356 % {\sys_get_query:nN, \sys_get_query:nnN, \sys_get_query:nnnN}
357 % \begin{syntax}
358 % \cs{sys_get_query:nN} \Arg{cmd} \meta{tl var}
359 % \cs{sys_get_query:nnN} \Arg{cmd} \Arg{spec} \meta{tl var}
360 % \cs{sys_get_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \meta{tl var}
361 % \end{syntax}
362 % Sets the \meta{tl var} to the information returned by the
363 % \texttt{l3sys-query} \meta{cmd}, potentially supplying the \meta{options}
364 % and \meta{spec} to the query call. The valid \meta{cmd} names are at present
365 % \begin{itemize}
366 % \item \texttt{pwd} Returns the present working directory
367 % \item \texttt{ls} Returns a directory listing, using the \meta{spec} to
368 % select files and applying the \meta{options} if given
369 % \end{itemize}
370 % The \meta{spec} is likely to contain the wildcards |*| or |?|,
371 % and will automatically be passed to
372 % the script without shell expansion. In a glob is needed within the
373 % \meta{options}, this will need to be protected from shell expansion
374 % using |'| tokens.
375 %
376 % The \meta{spec} and \meta{options}, if given, are expanded fully
377 % before passing to the underlying script.
378 %
379 % Spaces in the output are stored as active tokens, allowing them to be
380 % replaced by for example a visible space easily. Other non-letter
381 % characters in the ASCII range are set to category code~12. The category
382 % codes for characters out of the ASCII range are left unchanged: typically
383 % this will mean that with an 8-bit engine, accented values can be typeset
384 % directly whilst in Unicode engines, standard category code setup will
385 % apply.
386 %
387 % If more than one line of text is returned by the \meta{cmd}, these will be
388 % separated by character~13 (|^^M|) tokens of category code~12. In most
389 % cases, \cs{sys_split_query:nnnN} should be preferred when multi-line
390 % output is expected.
391 % \end{function}
392 %
393 % \begin{function}[added = 2024-03-08]
394 % {\sys_split_query:nN, \sys_split_query:nnN, \sys_split_query:nnnN}
395 % \begin{syntax}
396 % \cs{sys_split_query:nN} \Arg{cmd} \meta{seq var}
397 % \cs{sys_split_query:nnN} \Arg{cmd} \Arg{spec} \meta{seq var}
398 % \cs{sys_split_query:nnnN} \Arg{cmd} \Arg{options} \Arg{spec} \meta{seq var}
399 % \end{syntax}
400 % Works as described for \cs{sys_split_query:nnnN}, but sets the \meta{seq var}
401 % to contain one entry for each line returned by \texttt{l3sys-query}.
402 % This function should therefore be preferred where multi-line return is
403 % expected, e.g.~for the \texttt{ls} command.
404 % \end{function}
405 %
406 % \section{Loading configuration data}
407 %
408 % \begin{function}[added = 2019-09-12]{\sys_load_backend:n}
409 % \begin{syntax}
410 % \cs{sys_load_backend:n} \Arg{backend}
411 % \end{syntax}
412 % Loads the additional configuration file needed for backend support.
413 % If the \meta{backend} is empty, the standard backend for the engine in
414 % use will be loaded. This command may only be used once.
415 % \end{function}
416 %
417 % \begin{function}[added = 2022-07-29]{\sys_ensure_backend:}
418 % \begin{syntax}
419 % \cs{sys_ensure_backend:}
420 % \end{syntax}
421 % Ensures that a backend has been loaded by calling \cs{sys_load_backend:n}
422 % if required.
423 % \end{function}
424 %
425 % \begin{variable}{\c_sys_backend_str}
426 % Set to the name of the backend in use by \cs{sys_load_backend:n} when
427 % issued. Possible values are
428 % \begin{itemize}
429 % \item \texttt{pdftex}
430 % \item \texttt{luatex}
431 % \item \texttt{xetex}
432 % \item \texttt{dvips}
433 % \item \texttt{dvipdfmx}
434 % \item \texttt{dvisvgm}
435 % \end{itemize}
436 % \end{variable}
437 %
438 % \begin{function}[added = 2019-09-12]{\sys_load_debug:}
439 % \begin{syntax}
440 % \cs{sys_load_debug:}
441 % \end{syntax}
442 % Load the additional configuration file for debugging support.
443 % \end{function}
444 %
445 % \subsection{Final settings}
446 %
447 % \begin{function}[added = 2025-05-25]{\sys_finalize:}
448 % \begin{syntax}
449 % \cs{sys_finalize:}
450 % \end{syntax}
451 % Finalizes all system-dependent functionality: required before loading
452 % a backend.
453 % \end{function}
454 %
455 % \end{documentation}
456 %
457 % \begin{implementation}
458 %
459 % \section{\pkg{l3sys} implementation}
460 %
461 % \begin{macrocode}
462 %<@@=sys>
463 % \end{macrocode}
464 %
465 % \subsection{Kernel code}
466 %
467 % \begin{macrocode}
468 %<*code>
469 % \end{macrocode}
470 %
471 % \begin{macro}{\l_@@_tmp_tl}
472 % \begin{macrocode}
473 \tl_new:N \l_@@_tmp_tl
474 % \end{macrocode}
475 % \end{macro}
476 %
477 % \subsubsection{Detecting the engine}
478 %
479 % \begin{macro}{\@@_const:nn}
480 % Set the |T|, |F|, |TF|, |p| forms of |#1| to be constants equal to
481 % the result of evaluating the boolean expression~|#2|.
482 % \begin{macrocode}
483 \cs_new_protected:Npn \@@_const:nn #1#2
484 {
485 \bool_if:nTF {#2}
486 {
487 \cs_new_eq:cN { #1 :T } \use:n
488 \cs_new_eq:cN { #1 :F } \use_none:n
489 \cs_new_eq:cN { #1 :TF } \use_i:nn
490 \cs_new_eq:cN { #1 _p: } \c_true_bool
491 }
492 {
493 \cs_new_eq:cN { #1 :T } \use_none:n
494 \cs_new_eq:cN { #1 :F } \use:n
495 \cs_new_eq:cN { #1 :TF } \use_ii:nn
496 \cs_new_eq:cN { #1 _p: } \c_false_bool
497 }
498 }
499 % \end{macrocode}
500 % \end{macro}
501 %
502 % \begin{macro}[pTF, EXP]
503 % {
504 % \sys_if_engine_luatex:,
505 % \sys_if_engine_pdftex:,
506 % \sys_if_engine_ptex:,
507 % \sys_if_engine_uptex:,
508 % \sys_if_engine_xetex:
509 % }
510 % \begin{variable}{\c_sys_engine_str}
511 % Set up the engine tests on the basis exactly one test should be true.
512 % Mainly a case of looking for the appropriate marker primitive.
513 % \begin{macrocode}
514 \str_const:Ne \c_sys_engine_str
515 {
516 \cs_if_exist:NT \tex_luatexversion:D { luatex }
517 \cs_if_exist:NT \tex_pdftexversion:D { pdftex }
518 \cs_if_exist:NT \tex_kanjiskip:D
519 {
520 \cs_if_exist:NTF \tex_enablecjktoken:D
521 { uptex }
522 { ptex }
523 }
524 \cs_if_exist:NT \tex_XeTeXversion:D { xetex }
525 }
526 \tl_map_inline:nn { { luatex } { pdftex } { ptex } { uptex } { xetex } }
527 {
528 \@@_const:nn { sys_if_engine_ #1 }
529 { \str_if_eq_p:Vn \c_sys_engine_str {#1} }
530 }
531 % \end{macrocode}
532 % \end{variable}
533 % \end{macro}
534 %
535 % \begin{function}[pTF]{\sys_if_engine_opentype:}
536 % \begin{macrocode}
537 \@@_const:nn
538 { sys_if_engine_opentype }
539 { \cs_if_exist_p:N \tex_Umathcode:D }
540 % \end{macrocode}
541 % \end{function}
542 %
543 % \begin{variable}{\c_sys_engine_exec_str,\c_sys_engine_format_str}
544 % Take the functions defined above, and set up the engine and format
545 % names. \cs{c_sys_engine_exec_str} differs from \cs{c_sys_engine_str}
546 % as it is the \emph{actual} engine name, not a \enquote{filtered}
547 % version. It differs for |ptex| and |uptex|, which have a leading
548 % |e|, and for |luatex|, because \LaTeX{} uses the \Lua HB\TeX{}
549 % engine.
550 %
551 % \cs{c_sys_engine_format_str} is quite similar to
552 % \cs{c_sys_engine_str}, except that it differentiates |pdflatex| from
553 % |latex| (which is \pdfTeX{} in DVI mode). This differentiation,
554 % however, is reliable only if the user doesn't change
555 % \cs{tex_pdfoutput:D} before loading this code.
556 % \begin{macrocode}
557 \group_begin:
558 \cs_set_eq:NN \lua_now:e \tex_directlua:D
559 \str_const:Ne \c_sys_engine_exec_str
560 {
561 \sys_if_engine_pdftex:T { pdf }
562 \sys_if_engine_xetex:T { xe }
563 \sys_if_engine_ptex:T { ep }
564 \sys_if_engine_uptex:T { eup }
565 \sys_if_engine_luatex:T
566 {
567 lua \lua_now:e
568 {
569 if (pcall(require, 'luaharfbuzz')) then ~
570 tex.print("hb") ~
571 end
572 }
573 }
574 tex
575 }
576 \group_end:
577 \str_const:Ne \c_sys_engine_format_str
578 {
579 \cs_if_exist:NTF \fmtname
580 {
581 \bool_lazy_or:nnTF
582 { \str_if_eq_p:Vn \fmtname { plain } }
583 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
584 {
585 \sys_if_engine_pdftex:T
586 { \int_compare:nNnT { \tex_pdfoutput:D } = { 1 } { pdf } }
587 \sys_if_engine_xetex:T { xe }
588 \sys_if_engine_ptex:T { p }
589 \sys_if_engine_uptex:T { up }
590 \sys_if_engine_luatex:T
591 {
592 \int_compare:nNnT { \tex_pdfoutput:D } = { 0 } { dvi }
593 lua
594 }
595 \str_if_eq:VnTF \fmtname { LaTeX2e }
596 { latex }
597 {
598 \bool_lazy_and:nnT
599 { \sys_if_engine_pdftex_p: }
600 { \int_compare_p:nNn { \tex_pdfoutput:D } = { 0 } }
601 { e }
602 tex
603 }
604 }
605 { \fmtname }
606 }
607 { unknown }
608 }
609 % \end{macrocode}
610 % \end{variable}
611 %
612 % \begin{variable}{\c_sys_engine_version_str}
613 % Various different engines, various different ways to extract the
614 % data!
615 % \begin{macrocode}
616 \str_const:Ne \c_sys_engine_version_str
617 {
618 \str_case:on \c_sys_engine_str
619 {
620 { pdftex }
621 {
622 \int_div_truncate:nn { \tex_pdftexversion:D } { 100 }
623 .
624 \int_mod:nn { \tex_pdftexversion:D } { 100 }
625 .
626 \tex_pdftexrevision:D
627 }
628 { ptex }
629 {
630 \cs_if_exist:NT \tex_ptexversion:D
631 {
632 p
633 \int_use:N \tex_ptexversion:D
634 .
635 \int_use:N \tex_ptexminorversion:D
636 \tex_ptexrevision:D
637 -
638 \int_use:N \tex_epTeXversion:D
639 }
640 }
641 { luatex }
642 {
643 \int_div_truncate:nn { \tex_luatexversion:D } { 100 }
644 .
645 \int_mod:nn { \tex_luatexversion:D } { 100 }
646 .
647 \tex_luatexrevision:D
648 }
649 { uptex }
650 {
651 \cs_if_exist:NT \tex_ptexversion:D
652 {
653 p
654 \int_use:N \tex_ptexversion:D
655 .
656 \int_use:N \tex_ptexminorversion:D
657 \tex_ptexrevision:D
658 -
659 u
660 \int_use:N \tex_uptexversion:D
661 \tex_uptexrevision:D
662 -
663 \int_use:N \tex_epTeXversion:D
664 }
665 }
666 { xetex }
667 {
668 \int_use:N \tex_XeTeXversion:D
669 \tex_XeTeXrevision:D
670 }
671 }
672 }
673 % \end{macrocode}
674 % \end{variable}
675 %
676 % \subsubsection{Platform}
677 %
678 % \begin{macro}[pTF]{\sys_if_platform_unix:, \sys_if_platform_windows:}
679 % \begin{variable}{\c_sys_platform_str}
680 % Setting these up requires the file module (file lookup), so is actually
681 % implemented there.
682 % \end{variable}
683 % \end{macro}
684 %
685 % \subsubsection{Configurations}
686 %
687 % \begin{macro}{\sys_load_backend:n}
688 % \begin{macro}{\@@_load_backend_check:N}
689 % \begin{variable}{\c_sys_backend_str}
690 % Loading the backend code is pretty simply: check that the backend is valid,
691 % then load it up.
692 % \begin{macrocode}
693 \cs_new_protected:Npn \sys_load_backend:n #1
694 {
695 \sys_finalize:
696 \str_if_exist:NTF \c_sys_backend_str
697 {
698 \str_if_eq:VnF \c_sys_backend_str {#1}
699 { \msg_error:nn { sys } { backend-set } }
700 }
701 {
702 \tl_if_blank:nF {#1}
703 { \tl_gset:Nn \g_@@_backend_tl {#1} }
704 \@@_load_backend_check:N \g_@@_backend_tl
705 \str_const:Ne \c_sys_backend_str { \g_@@_backend_tl }
706 \__kernel_sys_configuration_load:n
707 { l3backend- \c_sys_backend_str }
708 }
709 }
710 \cs_new_protected:Npn \@@_load_backend_check:N #1
711 {
712 \sys_if_engine_xetex:TF
713 {
714 \str_case:VnF #1
715 {
716 { dvisvgm } { }
717 { xdvipdfmx } { \tl_gset:Nn #1 { xetex } }
718 { xetex } { }
719 }
720 {
721 \msg_error:nnee { sys } { wrong-backend }
722 #1 { xetex }
723 \tl_gset:Nn #1 { xetex }
724 }
725 }
726 {
727 \sys_if_output_pdf:TF
728 {
729 \str_if_eq:VnTF #1 { pdfmode }
730 {
731 \sys_if_engine_luatex:TF
732 { \tl_gset:Nn #1 { luatex } }
733 { \tl_gset:Nn #1 { pdftex } }
734 }
735 {
736 \bool_lazy_or:nnF
737 { \str_if_eq_p:Vn #1 { luatex } }
738 { \str_if_eq_p:Vn #1 { pdftex } }
739 {
740 \msg_error:nnee { sys } { wrong-backend }
741 #1 { \sys_if_engine_luatex:TF { luatex } { pdftex } }
742 \sys_if_engine_luatex:TF
743 { \tl_gset:Nn #1 { luatex } }
744 { \tl_gset:Nn #1 { pdftex } }
745 }
746 }
747 }
748 {
749 \str_case:VnF #1
750 {
751 { dvipdfmx } { }
752 { dvips } { }
753 { dvisvgm } { }
754 }
755 {
756 \msg_error:nnee { sys } { wrong-backend }
757 #1 { dvips }
758 \tl_gset:Nn #1 { dvips }
759 }
760 }
761 }
762 }
763 % \end{macrocode}
764 % \end{variable}
765 % \end{macro}
766 % \end{macro}
767 %
768 % \begin{macro}{\sys_ensure_backend:}
769 % A simple wrapper.
770 % \begin{macrocode}
771 \cs_new_protected:Npn \sys_ensure_backend:
772 {
773 \str_if_exist:NF \c_sys_backend_str
774 { \sys_load_backend:n { } }
775 }
776 % \end{macrocode}
777 % \end{macro}
778 %
779 % \begin{variable}{\g_@@_debug_bool}
780 % \begin{macrocode}
781 \bool_new:N \g_@@_debug_bool
782 % \end{macrocode}
783 % \end{variable}
784 %
785 % \begin{macro}{\sys_load_debug:}
786 % The most complicated thing here is that we can only use
787 % \cs{__kernel_sys_configuration_load:n} in the preamble in \LaTeX{}.
788 % \begin{macrocode}
789 \cs_new_protected:Npn \sys_load_debug:
790 {
791 \bool_if:NF \g_@@_debug_bool
792 { \__kernel_sys_configuration_load:n { l3debug } }
793 \bool_gset_true:N \g_@@_debug_bool
794 }
795 \cs_if_exist:NT \@expl@finalise@setup@@@@
796 {
797 \tl_gput_right:Nn \@expl@finalise@setup@@@@
798 {
799 \tl_gput_right:Nn \@kernel@after@begindocument
800 {
801 \cs_gset_protected:Npn \sys_load_debug:
802 { \msg_error:nn { sys } { load-debug-in-preamble } }
803 }
804 }
805 }
806 % \end{macrocode}
807 % \end{macro}
808 %
809 % \subsubsection{Access to the shell}
810 %
811 % \begin{variable}{\c_@@_marker_tl}
812 % The same idea as the marker for rescanning token lists.
813 % \begin{macrocode}
814 \tl_const:Ne \c_@@_marker_tl { : \token_to_str:N : }
815 % \end{macrocode}
816 % \end{variable}
817 %
818 % \begin{macro}[TF]{\sys_get_shell:nnN}
819 % \begin{macro}{\sys_get_shell:nnN,\@@_get:nnN,\@@_get_do:Nw}
820 % Setting using a shell is at this level just a slightly specialized file
821 % operation, with an additional check for quotes, as these are not supported.
822 % \begin{macrocode}
823 \cs_new_protected:Npn \sys_get_shell:nnN #1#2#3
824 {
825 \sys_get_shell:nnNF {#1} {#2} #3
826 { \tl_set:Nn #3 { \q_no_value } }
827 }
828 \prg_new_protected_conditional:Npnn \sys_get_shell:nnN #1#2#3 { T , F , TF }
829 {
830 \sys_if_shell:TF
831 { \exp_args:No \@@_get:nnN { \tl_to_str:n {#1} } {#2} #3 }
832 { \prg_return_false: }
833 }
834 \cs_new_protected:Npn \@@_get:nnN #1#2#3
835 {
836 \tl_if_in:nnTF {#1} { " }
837 {
838 \msg_error:nne
839 { kernel } { quote-in-shell } {#1}
840 \prg_return_false:
841 }
842 {
843 \group_begin:
844 \if_false: { \fi:
845 \int_set_eq:NN \tex_tracingnesting:D \c_zero_int
846 \exp_args:No \tex_everyeof:D { \c_@@_marker_tl }
847 #2 \scan_stop:
848 \exp_after:wN \@@_get_do:Nw
849 \exp_after:wN #3
850 \exp_after:wN \prg_do_nothing:
851 \tex_input:D | "#1" \scan_stop:
852 \if_false: } \fi:
853 \prg_return_true:
854 }
855 }
856 \exp_args:Nno \use:nn
857 { \cs_new_protected:Npn \@@_get_do:Nw #1#2 }
858 { \c_@@_marker_tl }
859 {
860 \group_end:
861 \tl_set:No #1 {#2}
862 }
863 % \end{macrocode}
864 % \end{macro}
865 % \end{macro}
866 %
867 % \begin{variable}{\c_@@_shell_stream_int}
868 % This is not needed for \LuaTeX{}: shell escape there isn't done using
869 % a \TeX{} interface.
870 % \begin{macrocode}
871 \sys_if_engine_luatex:F
872 { \int_const:Nn \c_@@_shell_stream_int { 18 } }
873 %</code>
874 % \end{macrocode}
875 % \end{variable}
876 %
877 % \begin{macro}{\sys_shell_now:n, \sys_shell_now:e, \sys_shell_now:x}
878 % \begin{macro}{\@@_shell_now:e}
879 % Execute commands through shell escape immediately.
880 %
881 % For \LuaTeX{}, we use a pseudo-primitive to do the actual work.
882 % \begin{macrocode}
883 %<*lua>
884 do
885 local os_exec = os.execute
886
887 local function shellescape(cmd)
888 local status,msg = os_exec(cmd)
889 if status == nil then
890 write_nl("log","runsystem(" .. cmd .. ")...(" .. msg .. ").\n")
891 elseif status == 0 then
892 write_nl("log","runsystem(" .. cmd .. ")...executed.\n")
893 else
894 write_nl("log","runsystem(" .. cmd .. ")...failed. " .. (msg or "") .. "\n")
895 end
896 end
897 luacmd("@@_shell_now:e", function()
898 shellescape(scan_string())
899 end, "global", "protected")
900 %</lua>
901 % \end{macrocode}
902 %
903 % \begin{macrocode}
904 %<*code>
905 \sys_if_engine_luatex:TF
906 {
907 \cs_new_protected:Npn \sys_shell_now:n #1
908 { \@@_shell_now:e { \exp_not:n {#1} } }
909 }
910 {
911 \cs_new_protected:Npn \sys_shell_now:n #1
912 { \iow_now:Nn \c_@@_shell_stream_int {#1} }
913 }
914 \cs_generate_variant:Nn \sys_shell_now:n { e, x }
915 %</code>
916 % \end{macrocode}
917 % \end{macro}
918 % \end{macro}
919 %
920 % \begin{macro}{\sys_shell_shipout:n, \sys_shell_shipout:e, \sys_shell_shipout:x}
921 % \begin{macro}{\@@_shell_shipout:e}
922 % Execute commands through shell escape at shipout.
923 %
924 % For \LuaTeX, we use the same helper as above but delayed using a |late_lua| whatsit.
925 % Creating a |late_lua| whatsit works a bit different if we are running under Con\TeX{}t.
926 % \begin{macrocode}
927 %<*lua>
928 local new_latelua = nodes and nodes.nuts and nodes.nuts.pool and nodes.nuts.pool.latelua or (function()
929 local whatsit_id = node.id'whatsit'
930 local latelua_sub = node.subtype'late_lua'
931 local node_new = node.direct.new
932 local setfield = node.direct.setwhatsitfield or node.direct.setfield
933 return function(f)
934 local n = node_new(whatsit_id, latelua_sub)
935 setfield(n, 'data', f)
936 return n
937 end
938 end)()
939 local node_write = node.direct.write
940
941 luacmd("@@_shell_shipout:e", function()
942 local cmd = scan_string()
943 node_write(new_latelua(function() shellescape(cmd) end))
944 end, "global", "protected")
945 end
946 %</lua>
947 % \end{macrocode}
948 %
949 % \begin{macrocode}
950 %<*code>
951 \sys_if_engine_luatex:TF
952 {
953 \cs_new_protected:Npn \sys_shell_shipout:n #1
954 { \@@_shell_shipout:e { \exp_not:n {#1} } }
955 }
956 {
957 \cs_new_protected:Npn \sys_shell_shipout:n #1
958 { \iow_shipout:Nn \c_@@_shell_stream_int {#1} }
959 }
960 \cs_generate_variant:Nn \sys_shell_shipout:n { e , x }
961 % \end{macrocode}
962 % \end{macro}
963 % \end{macro}
964 %
965 % \subsection{Dynamic (every job) code}
966 %
967 % \begin{macro}{\__kernel_sys_everyjob:}
968 % \begin{macro}{\@@_everyjob:n}
969 % \begin{variable}{\g_@@_everyjob_tl}
970 % \begin{macrocode}
971 \cs_new_protected:Npn \__kernel_sys_everyjob:
972 {
973 \tl_use:N \g_@@_everyjob_tl
974 \tl_gclear:N \g_@@_everyjob_tl
975 }
976 \cs_new_protected:Npn \@@_everyjob:n #1
977 { \tl_gput_right:Nn \g_@@_everyjob_tl {#1} }
978 \tl_new:N \g_@@_everyjob_tl
979 % \end{macrocode}
980 % \end{variable}
981 % \end{macro}
982 % \end{macro}
983 %
984 % \subsubsection{The name of the job}
985 %
986 % \begin{variable}{\c_sys_jobname_str}
987 % Inherited from the \LaTeX3 name for the primitive. This \emph{has} to be
988 % the primitive as it's set in \tn{everyjob}. If the user does
989 % \begin{verbatim}
990 % pdflatex \input some-file-name
991 % \end{verbatim}
992 % then \tn{everyjob} is inserted \emph{before} \tn{jobname} is changed form
993 % |texput|, and thus we would have the wrong result.
994 % \begin{macrocode}
995 \@@_everyjob:n
996 { \cs_new_eq:NN \c_sys_jobname_str \tex_jobname:D }
997 % \end{macrocode}
998 % \end{variable}
999 %
1000 % \subsubsection{Time and date}
1001 %
1002 % \begin{variable}
1003 % {
1004 % \c_sys_minute_int,
1005 % \c_sys_hour_int,
1006 % \c_sys_day_int,
1007 % \c_sys_month_int,
1008 % \c_sys_year_int,
1009 % }
1010 % Copies of the information provided by \TeX{}. There is a lot of defensive
1011 % code in package mode: someone may have moved the primitives, and they can
1012 % only be recovered if we have \tn{primitive} and it is working correctly.
1013 % For Ini\TeX{} of course that is all redundant but does no harm.
1014 % \begin{macrocode}
1015 \@@_everyjob:n
1016 {
1017 \group_begin:
1018 \cs_set:Npn \@@_tmp:w #1
1019 {
1020 \str_if_eq:eeTF { \cs_meaning:N #1 } { \token_to_str:N #1 }
1021 { #1 }
1022 {
1023 \cs_if_exist:NTF \tex_primitive:D
1024 {
1025 \bool_lazy_and:nnTF
1026 { \sys_if_engine_xetex_p: }
1027 {
1028 \int_compare_p:nNn
1029 { \exp_after:wN \use_none:n \tex_XeTeXrevision:D }
1030 < { 99999 }
1031 }
1032 { 0 }
1033 { \tex_primitive:D #1 }
1034 }
1035 { 0 }
1036 }
1037 }
1038 \int_const:Nn \c_sys_minute_int
1039 { \int_mod:nn { \@@_tmp:w \time } { 60 } }
1040 \int_const:Nn \c_sys_hour_int
1041 { \int_div_truncate:nn { \@@_tmp:w \time } { 60 } }
1042 \int_const:Nn \c_sys_day_int { \@@_tmp:w \day }
1043 \int_const:Nn \c_sys_month_int { \@@_tmp:w \month }
1044 \int_const:Nn \c_sys_year_int { \@@_tmp:w \year }
1045 \group_end:
1046 }
1047 % \end{macrocode}
1048 % \end{variable}
1049 %
1050 % \begin{variable}{\c_sys_timestamp_str}
1051 % A simple expansion: Lua\TeX{} chokes if we use \tn{pdffeedback} here,
1052 % hence the direct use of Lua. Notice that the function there is in the
1053 % \texttt{pdf} library but isn't actually tied to PDF.
1054 % \begin{macrocode}
1055 \@@_everyjob:n
1056 {
1057 \str_const:Ne \c_sys_timestamp_str
1058 {
1059 \cs_if_exist:NTF \tex_directlua:D
1060 { \tex_directlua:D { tex.print(pdf.getcreationdate()) } }
1061 { \tex_creationdate:D }
1062 }
1063 }
1064 % \end{macrocode}
1065 % \end{variable}
1066 %
1067 % \subsubsection{Random numbers}
1068 %
1069 % \begin{macro}[EXP]{\sys_rand_seed:}
1070 % Unpack the primitive.
1071 % \begin{macrocode}
1072 \@@_everyjob:n
1073 {
1074 \cs_new:Npn \sys_rand_seed: { \tex_the:D \tex_randomseed:D }
1075 }
1076 % \end{macrocode}
1077 % \end{macro}
1078 %
1079 % \begin{macro}{\sys_gset_rand_seed:n}
1080 % The primitive always assigns the seed globally.
1081 % \begin{macrocode}
1082 \@@_everyjob:n
1083 {
1084 \cs_new_protected:Npn \sys_gset_rand_seed:n #1
1085 { \tex_setrandomseed:D \int_eval:n {#1} \exp_stop_f: }
1086 }
1087 % \end{macrocode}
1088 % \end{macro}
1089 %
1090 % \begin{macro}[EXP]{\sys_timer:, \@@_elapsedtime:}
1091 % \begin{macro}[EXP, pTF]{\sys_if_timer_exist:}
1092 % In \LuaTeX{}, create a pseudo-primitive, otherwise try to
1093 % locate the real primitive. The elapsed time will be
1094 % available if this succeeds.
1095 % \begin{macrocode}
1096 %</code>
1097 %<*lua>
1098 local gettimeofday = os.gettimeofday
1099 local epoch = gettimeofday() - os.clock()
1100 local write = tex.write
1101 local tointeger = math.tointeger
1102 luacmd('@@_elapsedtime:', function()
1103 write(tointeger((gettimeofday() - epoch)*65536 // 1))
1104 end, 'global')
1105 %</lua>
1106 %<*code>
1107 \cs_new:Npe \sys_timer:
1108 {
1109 \sys_if_engine_luatex:TF
1110 { \exp_not:N \@@_elapsedtime: }
1111 { \exp_not:N \int_value:w \exp_not:N \tex_elapsedtime:D }
1112 }
1113 % \end{macrocode}
1114 % \end{macro}
1115 % \end{macro}
1116 %
1117 % \subsubsection{Access to the shell}
1118 %
1119 % \begin{variable}{\c_sys_shell_escape_int}
1120 % Expose the engine's shell escape status to the user.
1121 % \begin{macrocode}
1122 \@@_everyjob:n
1123 {
1124 \int_const:Nn \c_sys_shell_escape_int
1125 {
1126 \sys_if_engine_luatex:TF
1127 {
1128 \tex_directlua:D
1129 { tex.sprint(status.shell_escape~or~os.execute()) }
1130 }
1131 { \tex_shellescape:D }
1132 }
1133 }
1134 % \end{macrocode}
1135 % \end{variable}
1136 %
1137 % \begin{macro}[EXP, pTF]{\sys_if_shell:, \sys_if_shell_unrestricted:, \sys_if_shell_restricted:}
1138 % Performs a check for whether shell escape is enabled. The first set
1139 % of functions returns true if either of restricted or unrestricted
1140 % shell escape is enabled, while the other two sets of functions
1141 % return true in only one of these two cases.
1142 % \begin{macrocode}
1143 \@@_everyjob:n
1144 {
1145 \@@_const:nn { sys_if_shell }
1146 { \int_compare_p:nNn \c_sys_shell_escape_int > 0 }
1147 \@@_const:nn { sys_if_shell_unrestricted }
1148 { \int_compare_p:nNn \c_sys_shell_escape_int = 1 }
1149 \@@_const:nn { sys_if_shell_restricted }
1150 { \int_compare_p:nNn \c_sys_shell_escape_int = 2 }
1151 }
1152 % \end{macrocode}
1153 % \end{macro}
1154 %
1155 % \subsection{System queries}
1156 %
1157 % \begin{macro}{\sys_get_query:nN}
1158 % \begin{macro}{\sys_get_query:nnN}
1159 % \begin{macro}
1160 % {
1161 % \sys_get_query:nnnN,
1162 % \@@_get_query_auxi:nnnN, \@@_get_query_auxi:neeN,
1163 % \@@_get_query_auxii:nnnN, \@@_get_query_auxii:neeN
1164 % }
1165 % Calling the query system is quite straight-forward: most of the effort is
1166 % in making the read-back catcode-safe. We also want to trim off the trailing
1167 % |^^M| from the last line.
1168 % \begin{macrocode}
1169 \cs_new_protected:Npn \sys_get_query:nN #1#2
1170 { \sys_get_query:nnnN {#1} { } { } #2 }
1171 \cs_new_protected:Npn \sys_get_query:nnN #1#2#3
1172 { \sys_get_query:nnnN {#1} { } {#2} #3 }
1173 \cs_new_protected:Npn \sys_get_query:nnnN #1#2#3#4
1174 {
1175 \tl_clear:N #4
1176 \@@_get_query_auxi:neeN {#1} {#2} {#3} #4
1177 }
1178 \cs_new:Npn \@@_get_query_auxi:nnnN #1#2#3#4
1179 {
1180 \@@_get_query_auxii:neeN {#1}
1181 { \tl_if_blank:nF {#2} { \tl_to_str:n { ~ #2 } } }
1182 {
1183 \tl_if_blank:nF {#3}
1184 {
1185 \c_space_tl
1186 \sys_if_shell_restricted:F '
1187 \tl_to_str:n {#3}
1188 \sys_if_shell_restricted:F '
1189 }
1190 }
1191 #4
1192 }
1193 \cs_generate_variant:Nn \@@_get_query_auxi:nnnN { nee }
1194 \cs_new_protected:Npn \@@_get_query_auxii:nnnN #1#2#3#4
1195 {
1196 \sys_if_shell:T
1197 {
1198 \sys_get_shell:nnN
1199 { l3sys-query~#1 #2 #3 }
1200 {
1201 \int_step_inline:nnn { 0 } { `A - 1 }
1202 { \char_set_catcode_other:n {##1} }
1203 \int_step_inline:nnn { `Z + 1 } { `a - 1 }
1204 { \char_set_catcode_other:n {##1} }
1205 \int_step_inline:nnn { `z + 1 } { 127 }
1206 { \char_set_catcode_other:n {##1} }
1207 \char_set_catcode_active:n { `\ }
1208 \tex_endlinechar:D 13 \scan_stop:
1209 }
1210 \l_@@_tmp_tl
1211 \tl_if_empty:NF \l_@@_tmp_tl
1212 {
1213 \exp_after:wN \@@_get_query:Nw \exp_after:wN #4
1214 \l_@@_tmp_tl \q_stop
1215 }
1216 }
1217 }
1218 \cs_generate_variant:Nn \@@_get_query_auxii:nnnN { nee }
1219 \group_begin:
1220 \tex_lccode:D `\* = 13 \scan_stop:
1221 \tex_lowercase:D
1222 {
1223 \group_end:
1224 \cs_new_protected:Npn \@@_get_query:Nw #1#2 * \q_stop
1225 }
1226 { \tl_set:Nn #1 {#2} }
1227 % \end{macrocode}
1228 % \end{macro}
1229 % \end{macro}
1230 % \end{macro}
1231 %
1232 % \begin{macro}{\sys_split_query:nN}
1233 % \begin{macro}{\sys_split_query:nnN}
1234 % \begin{macro}{\sys_split_query:nnnN}
1235 % A wrapper for convenience.
1236 % \begin{macrocode}
1237 \cs_new_protected:Npn \sys_split_query:nN #1#2
1238 { \sys_split_query:nnnN {#1} { } { } #2 }
1239 \cs_new_protected:Npn \sys_split_query:nnN #1#2#3
1240 { \sys_split_query:nnnN {#1} { } {#2} #3 }
1241 \group_begin:
1242 \tex_lccode:D `\* = 13 \scan_stop:
1243 \tex_lowercase:D
1244 {
1245 \group_end:
1246 \cs_new_protected:Npn \sys_split_query:nnnN #1#2#3#4
1247 {
1248 \seq_clear:N #4
1249 \sys_get_query:nnnN {#1} {#2} {#3} \l_@@_tmp_tl
1250 \tl_if_empty:NF \l_@@_tmp_tl
1251 { \seq_set_split:NnV #4 * \l_@@_tmp_tl }
1252 }
1253 }
1254 % \end{macrocode}
1255 % \end{macro}
1256 % \end{macro}
1257 % \end{macro}
1258 %
1259 % \subsubsection{Held over from \pkg{l3file}}
1260 %
1261 % \begin{variable}{\g_file_curr_name_str}
1262 % See comments about \cs{c_sys_jobname_str}: here, as soon as there is
1263 % file input/output, things get \enquote{tided up}.
1264 % \begin{macrocode}
1265 \@@_everyjob:n
1266 { \cs_gset_eq:NN \g_file_curr_name_str \tex_jobname:D }
1267 % \end{macrocode}
1268 % \end{variable}
1269 %
1270 % \subsection{Last-minute code}
1271 %
1272 % \begin{macro}{\sys_finalize:}
1273 % \begin{macro}{\@@_finalize:n}
1274 % \begin{variable}{\g_@@_finalize_tl}
1275 % A simple hook to finalize the system-dependent layer. This is forced by
1276 % the backend loader, which is forced by the main loader, so we do not need
1277 % to include that here.
1278 % \begin{macrocode}
1279 \cs_new_protected:Npn \sys_finalize:
1280 {
1281 \__kernel_sys_everyjob:
1282 \tl_use:N \g_@@_finalize_tl
1283 \tl_gclear:N \g_@@_finalize_tl
1284 }
1285 \cs_new_protected:Npn \@@_finalize:n #1
1286 { \tl_gput_right:Nn \g_@@_finalize_tl {#1} }
1287 \tl_new:N \g_@@_finalize_tl
1288 % \end{macrocode}
1289 % \end{variable}
1290 % \end{macro}
1291 % \end{macro}
1292 %
1293 % \subsubsection{Detecting the output}
1294 %
1295 % \begin{macro}[pTF, EXP]
1296 % {
1297 % \sys_if_output_dvi:,
1298 % \sys_if_output_pdf:
1299 % }
1300 % \begin{variable}{\c_sys_output_str}
1301 % This is a simple enough concept: the two views here are complementary.
1302 % \begin{macrocode}
1303 \@@_finalize:n
1304 {
1305 \str_const:Ne \c_sys_output_str
1306 {
1307 \int_compare:nNnTF
1308 { \cs_if_exist_use:NF \tex_pdfoutput:D { 0 } } > { 0 }
1309 { pdf }
1310 { dvi }
1311 }
1312 \@@_const:nn { sys_if_output_dvi }
1313 { \str_if_eq_p:Vn \c_sys_output_str { dvi } }
1314 \@@_const:nn { sys_if_output_pdf }
1315 { \str_if_eq_p:Vn \c_sys_output_str { pdf } }
1316 }
1317 % \end{macrocode}
1318 % \end{variable}
1319 % \end{macro}
1320 %
1321 % \subsubsection{Configurations}
1322 %
1323 % \begin{variable}{\g_@@_backend_tl}
1324 % As the backend has to be checked and possibly adjusted, the approach here
1325 % is to create a variable and use that in a one-shot to set a constant.
1326 % \begin{macrocode}
1327 \tl_new:N \g_@@_backend_tl
1328 \@@_finalize:n
1329 {
1330 \__kernel_tl_gset:Nx \g_@@_backend_tl
1331 {
1332 \sys_if_engine_xetex:TF
1333 { xetex }
1334 {
1335 \sys_if_output_pdf:TF
1336 {
1337 \sys_if_engine_pdftex:TF
1338 { pdftex }
1339 { luatex }
1340 }
1341 { dvips }
1342 }
1343 }
1344 }
1345 % \end{macrocode}
1346 % If there is a class option set, and recognized, we pick it up: these
1347 % will over-ride anything set automatically but will themselves be
1348 % over-written if there is a package option.
1349 % \begin{macrocode}
1350 \@@_finalize:n
1351 {
1352 \cs_if_exist:NT \@classoptionslist
1353 {
1354 \cs_if_eq:NNF \@classoptionslist \scan_stop:
1355 {
1356 \clist_map_inline:Nn \@classoptionslist
1357 {
1358 \str_case:nnT {#1}
1359 {
1360 { dvipdfmx }
1361 { \tl_gset:Nn \g_@@_backend_tl { dvipdfmx } }
1362 { dvips }
1363 { \tl_gset:Nn \g_@@_backend_tl { dvips } }
1364 { dvisvgm }
1365 { \tl_gset:Nn \g_@@_backend_tl { dvisvgm } }
1366 { pdftex }
1367 { \tl_gset:Nn \g_@@_backend_tl { pdfmode } }
1368 { xetex }
1369 { \tl_gset:Nn \g_@@_backend_tl { xdvipdfmx } }
1370 }
1371 { \clist_remove_all:Nn \@unusedoptionlist {#1} }
1372 }
1373 }
1374 }
1375 }
1376 % \end{macrocode}
1377 % \end{variable}
1378 %
1379 % \begin{macrocode}
1380 %</code>
1381 % \end{macrocode}
1382 %
1383 %\end{implementation}
1384 %
1385 %\PrintIndex