1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
% \iffalse meta-comment
%
%% File: l3kernel-functions.dtx
%
% Copyright (C) 2018-2019 The LaTeX3 project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% https://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
% https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full,kernel]{l3doc}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
% The \pkg{l3kernel-functions} package\\ Kernel-reserved functions^^A
% }
%
% \author{^^A
% The \LaTeX3 Project\thanks
% {^^A
% E-mail:
% \href{mailto:latex-team@latex-project.org}
% {latex-team@latex-project.org}^^A
% }^^A
% }
%
% \date{Released 2019-10-21}
%
% \maketitle
%
% \begin{documentation}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{Internal kernel functions}
%
% \begin{function}{\__kernel_chk_cs_exist:N, \__kernel_chk_cs_exist:c}
% \begin{syntax}
% \cs{__kernel_chk_cs_exist:N} \meta{cs}
% \end{syntax}
% This function is only created if debugging is enabled. It checks
% that \meta{cs} exists according to the criteria for
% \cs{cs_if_exist_p:N}, and if not raises a kernel-level error.
% \end{function}
%
% \begin{function}{\__kernel_chk_defined:NT}
% \begin{syntax}
% \cs{__kernel_chk_defined:NT} \meta{variable} \Arg{true code}
% \end{syntax}
% If \meta{variable} is not defined (according to
% \cs{cs_if_exist:NTF}), this triggers an error, otherwise the
% \meta{true code} is run.
% \end{function}
%
% \begin{function}{\__kernel_chk_expr:nNnN}
% \begin{syntax}
% \cs{__kernel_chk_expr:nNnN} \Arg{expr} \meta{eval} \Arg{convert} \meta{caller}
% \end{syntax}
% This function is only created if debugging is enabled. By default
% it is equivalent to \cs{use_i:nnnn}. When expression checking is
% enabled, it leaves in the input stream the result of \cs{tex_the:D}
% \meta{eval} \meta{expr} \cs{tex_relax:D} after checking that no
% token was left over. If any token was not taken as part of the
% expression, there is an error message displaying the result of the
% evaluation as well as the \meta{caller}. For instance \meta{eval}
% can be \cs{__int_eval:w} and \meta{caller} can be \cs{int_eval:n} or
% \cs{int_set:Nn}. The argument \meta{convert} is empty except for mu
% expressions where it is \cs{tex_mutoglue:D}, used for internal
% purposes.
% \end{function}
%
% \begin{function}{\__kernel_cs_parm_from_arg_count:nnF}
% \begin{syntax}
% \cs{__kernel_cs_parm_from_arg_count:nnF} \Arg{follow-on} \Arg{args} \Arg{false code}
% \end{syntax}
% Evaluates the number of \meta{args} and leaves the \meta{follow-on} code
% followed by a brace group containing the required number of primitive
% parameter markers (|#1|, \emph{etc}.). If the number of \meta{args} is outside
% the range $[0,9]$, the \meta{false code} is inserted \emph{instead} of
% the \meta{follow-on}.
% \end{function}
%
% \begin{function}{\__kernel_deprecation_code:nn}
% \begin{syntax}
% \cs{__kernel_deprecation_code:nn} \Arg{error code} \Arg{working code}
% \end{syntax}
% Stores both an \meta{error} and \meta{working} definition for given material
% such that they can be exchanged by \cs{debug_on:} and \cs{debug_off:}.
% \end{function}
%
% \begin{function}[EXP]{\__kernel_exp_not:w}
% \begin{syntax}
% \cs{__kernel_exp_not:w} \meta{expandable tokens} \Arg{content}
% \end{syntax}
% Carries out expansion on the \meta{expandable tokens} before preventing
% further expansion of the \meta{content} as for \cs{exp_not:n}. Typically,
% the \meta{expandable tokens} will alter the nature of the \meta{content},
% \emph{i.e.}~allow it to be generated in some way.
% \end{function}
%
% \begin{variable}{\l__kernel_expl_bool}
% A boolean which records the current code syntax status: \texttt{true} if
% currently inside a code environment. This variable should only be
% set by \cs{ExplSyntaxOn}/\cs{ExplSyntaxOff}.
% \end{variable}
%
% \begin{function}{\__kernel_file_missing:n}
% \begin{syntax}
% \cs{__kernel_file_missing:n} \Arg{name}
% \end{syntax}
% Expands the \meta{name} as per \cs{__kernel_file_name_sanitize:nN} then
% produces an error message indicating that that file was not found.
% \end{function}
%
% \begin{function}{\__kernel_file_name_sanitize:nN}
% \begin{syntax}
% \cs{__kernel_file_name_sanitize:nN} \Arg{name} \meta{str var}
% \end{syntax}
% For converting a \meta{name} to a string where active characters are treated
% as strings.
% \end{function}
%
% \begin{function}{\__kernel_file_input_push:n, \__kernel_file_input_pop:}
% \begin{syntax}
% \cs{__kernel_file_input_push:n} \Arg{name}
% \cs{__kernel_file_input_pop:}
% \end{syntax}
% Used to push and pop data from the internal file stack: needed only
% in package mode, where interfacing with the \LaTeXe{} kernel is necessary.
% \end{function}
%
% \begin{function}[EXP]{\__kernel_int_add:nnn}
% \begin{syntax}
% \cs{__kernel_int_add:nnn} \Arg{integer_1} \Arg{integer_2} \Arg{integer_3}
% \end{syntax}
% Expands to the result of adding the three \meta{integers} (which
% must be suitable input for \cs{int_eval:w}), avoiding intermediate
% overflow. Overflow occurs only if the overall result is outside
% $[-2^{31}+1,2^{31}-1]$. The \meta{integers} may be of the form
% \cs{int_eval:w} \dots{} \cs{scan_stop:} but may be evaluated more
% than once.
% \end{function}
%
% \begin{function}{\__kernel_ior_open:Nn, \__kernel_ior_open:No}
% \begin{syntax}
% \cs{__kernel_ior_open:Nn} \meta{stream} \Arg{file name}
% \end{syntax}
% This function has identical syntax to the public version. However,
% is does not take precautions against active characters in the
% \meta{file name}, and it does not attempt to add a \meta{path} to
% the \meta{file name}: it is therefore intended to be used by
% higher-level
% functions which have already fully expanded the \meta{file name} and which
% need to perform multiple open or close operations. See for example the
% implementation of \cs{file_get_full_name:nN},
% \end{function}
%
% \begin{function}{\__kernel_iow_with:Nnn}
% \begin{syntax}
% \cs{__kernel_iow_with:Nnn} \meta{integer} \Arg{value} \Arg{code}
% \end{syntax}
% If the \meta{integer} is equal to the \meta{value} then this
% function simply runs the \meta{code}. Otherwise it saves the
% current value of the \meta{integer}, sets it to the \meta{value},
% runs the \meta{code}, and restores the \meta{integer} to its former
% value. This is used to ensure that the \tn{newlinechar} is~$10$
% when writing to a stream, which lets \cs{iow_newline:} work, and
% that \tn{errorcontextlines} is $-1$ when displaying a message.
% \end{function}
%
% \begin{function}
% {\__kernel_msg_new:nnnn, \__kernel_msg_new:nnn}
% \begin{syntax}
% \cs{__kernel_msg_new:nnnn} \Arg{module} \Arg{message} \Arg{text} \Arg{more text}
% \end{syntax}
% Creates a kernel \meta{message} for a given \meta{module}.
% The message is defined to first give \meta{text} and then
% \meta{more text} if the user requests it. If no \meta{more text} is
% available then a standard text is given instead. Within \meta{text}
% and \meta{more text} four parameters (|#1| to |#4|) can be used:
% these will be supplied and expanded at the time the message is used.
% An error is raised if the \meta{message} already exists.
% \end{function}
%
% \begin{function}
% {\__kernel_msg_set:nnnn, \__kernel_msg_set:nnn}
% \begin{syntax}
% \cs{__kernel_msg_set:nnnn} \Arg{module} \Arg{message} \Arg{text} \Arg{more text}
% \end{syntax}
% Sets up the text for a kernel \meta{message} for a given \meta{module}.
% The message is defined to first give \meta{text} and then
% \meta{more text} if the user requests it. If no \meta{more text} is
% available then a standard text is given instead. Within \meta{text}
% and \meta{more text} four parameters (|#1| to |#4|) can be used:
% these will be supplied and expanded at the time the message is used.
% \end{function}
%
% \begin{function}
% {
% \__kernel_msg_fatal:nnnnnn ,
% \__kernel_msg_fatal:nnnnn ,
% \__kernel_msg_fatal:nnnn ,
% \__kernel_msg_fatal:nnn ,
% \__kernel_msg_fatal:nn ,
% \__kernel_msg_fatal:nnxxxx ,
% \__kernel_msg_fatal:nnxxx ,
% \__kernel_msg_fatal:nnxx ,
% \__kernel_msg_fatal:nnx
% }
% \begin{syntax}
% \cs{__kernel_msg_fatal:nnnnnn} \Arg{module} \Arg{message} \Arg{arg one} \Arg{arg two} \Arg{arg three} \Arg{arg four}
% \end{syntax}
% Issues kernel \meta{module} error \meta{message}, passing \meta{arg one}
% to \meta{arg four} to the text-creating functions. After issuing a
% fatal error the \TeX{} run halts. Cannot be redirected.
% \end{function}
%
% \begin{function}
% {
% \__kernel_msg_error:nnnnnn ,
% \__kernel_msg_error:nnnnn ,
% \__kernel_msg_error:nnnn ,
% \__kernel_msg_error:nnn ,
% \__kernel_msg_error:nn ,
% \__kernel_msg_error:nnxxxx ,
% \__kernel_msg_error:nnxxx ,
% \__kernel_msg_error:nnxx ,
% \__kernel_msg_error:nnx
% }
% \begin{syntax}
% \cs{__kernel_msg_error:nnnnnn} \Arg{module} \Arg{message} \Arg{arg one} \Arg{arg two} \Arg{arg three} \Arg{arg four}
% \end{syntax}
% Issues kernel \meta{module} error \meta{message}, passing \meta{arg one}
% to
% \meta{arg four} to the text-creating functions. The error
% stops processing and issues the text at the terminal. After user input,
% the run continues. Cannot be redirected.
% \end{function}
%
% \begin{function}
% {
% \__kernel_msg_warning:nnnnnn ,
% \__kernel_msg_warning:nnnnn ,
% \__kernel_msg_warning:nnnn ,
% \__kernel_msg_warning:nnn ,
% \__kernel_msg_warning:nn ,
% \__kernel_msg_warning:nnxxxx ,
% \__kernel_msg_warning:nnxxx ,
% \__kernel_msg_warning:nnxx ,
% \__kernel_msg_warning:nnx
% }
% \begin{syntax}
% \cs{__kernel_msg_warning:nnnnnn} \Arg{module} \Arg{message} \Arg{arg one} \Arg{arg two} \Arg{arg three} \Arg{arg four}
% \end{syntax}
% Issues kernel \meta{module} warning \meta{message}, passing
% \meta{arg one} to
% \meta{arg four} to the text-creating functions. The warning text
% is added to the log file, but the \TeX{} run is not interrupted.
% \end{function}
%
% \begin{function}
% {
% \__kernel_msg_info:nnnnnn ,
% \__kernel_msg_info:nnnnn ,
% \__kernel_msg_info:nnnn ,
% \__kernel_msg_info:nnn ,
% \__kernel_msg_info:nn ,
% \__kernel_msg_info:nnxxxx ,
% \__kernel_msg_info:nnxxx ,
% \__kernel_msg_info:nnxx ,
% \__kernel_msg_info:nnx
% }
% \begin{syntax}
% \cs{__kernel_msg_info:nnnnnn} \Arg{module} \Arg{message} \Arg{arg one} \Arg{arg two} \Arg{arg three} \Arg{arg four}
% \end{syntax}
% Issues kernel \meta{module} information \meta{message}, passing
% \meta{arg one} to \meta{arg four} to the text-creating functions.
% The information text is added to the log file.
% \end{function}
%
% \begin{function}[EXP]
% {
% \__kernel_msg_expandable_error:nnnnnn,
% \__kernel_msg_expandable_error:nnnnn,
% \__kernel_msg_expandable_error:nnnn,
% \__kernel_msg_expandable_error:nnn,
% \__kernel_msg_expandable_error:nn,
% \__kernel_msg_expandable_error:nnffff,
% \__kernel_msg_expandable_error:nnfff,
% \__kernel_msg_expandable_error:nnff,
% \__kernel_msg_expandable_error:nnf,
% }
% \begin{syntax}
% \cs{__kernel_msg_expandable_error:nnnnnn} \Arg{module} \Arg{message} \Arg{arg one} \Arg{arg two} \Arg{arg three} \Arg{arg four}
% \end{syntax}
% Issues an error, passing \meta{arg one} to \meta{arg four}
% to the text-creating functions. The resulting string must
% be much shorter than a line, otherwise it is cropped.
% \end{function}
%
% \begin{variable}{\g__kernel_prg_map_int}
% This integer is used by non-expandable mapping functions to track
% the level of nesting in force. The functions
% \cs[no-index]{\meta{type}_map_1:w},
% \cs[no-index]{\meta{type}_map_2:w}, \emph{etc.}, labelled by
% \cs{g__kernel_prg_map_int}
% hold functions to be mapped over various list datatypes in inline
% and variable mappings.
% \end{variable}
%
% \begin{variable}{\c__kernel_randint_max_int}
% Maximal allowed argument to \cs{__kernel_randint:n}. Equal to
% $2^{17}-1$.
% \end{variable}
%
% \begin{function}{\__kernel_randint:n}
% \begin{syntax}
% \cs{__kernel_randint:n} \Arg{max}
% \end{syntax}
% Used in an integer expression this gives a pseudo-random number
% between $1$ and $\meta{max}$ included. One must have
% $\meta{max}\leq 2^{17}-1$. The \meta{max} must be suitable for
% \cs{int_value:w} (and any \cs{int_eval:w} must be terminated by
% \cs{scan_stop:} or equivalent).
% \end{function}
%
% \begin{function}{\__kernel_randint:nn}
% \begin{syntax}
% \cs{__kernel_randint:nn} \Arg{min} \Arg{max}
% \end{syntax}
% Used in an integer expression this gives a pseudo-random number
% between $\meta{min}$ and $\meta{max}$ included. The \meta{min} and
% \meta{max} must be suitable for \cs{int_value:w} (and any
% \cs{int_eval:w} must be terminated by \cs{scan_stop:} or
% equivalent). For small ranges
% $R=\meta{max}-\meta{min}+1\leq 2^{17}-1$,
% $\meta{min} - 1 + \cs{__kernel_randint:n} |{|R|}|$ is faster.
% \end{function}
%
% \begin{function}{\__kernel_register_show:N, \__kernel_register_show:c}
% \begin{syntax}
% \cs{__kernel_register_show:N} \meta{register}
% \end{syntax}
% Used to show the contents of a \TeX{} register at the terminal, formatted
% such that internal parts of the mechanism are not visible.
% \end{function}
%
% \begin{function}
% {\__kernel_register_log:N, \__kernel_register_log:c}
% \begin{syntax}
% \cs{__kernel_register_log:N} \meta{register}
% \end{syntax}
% Used to write the contents of a \TeX{} register to the log file in a
% form similar to \cs{__kernel_register_show:N}.
% \end{function}
%
% \begin{function}[EXP]{\__kernel_str_to_other:n}
% \begin{syntax}
% \cs{__kernel_str_to_other:n} \Arg{token list}
% \end{syntax}
% Converts the \meta{token list} to a \meta{other string}, where
% spaces have category code \enquote{other}. This function can be
% \texttt{f}-expanded without fear of losing a leading space, since
% spaces do not have category code $10$ in its result. It takes a
% time quadratic in the character count of the string.
% \end{function}
%
% \begin{function}[rEXP]{\__kernel_str_to_other_fast:n}
% \begin{syntax}
% \cs{__kernel_str_to_other_fast:n} \Arg{token list}
% \end{syntax}
% Same behaviour \cs{__kernel_str_to_other:n} but only restricted-expandable.
% It takes a time linear in the character count of the string.
% \end{function}
%
% \begin{function}[EXP]{\__kernel_tl_to_str:w}
% \begin{syntax}
% \cs{__kernel_tl_to_str:w} \meta{expandable tokens} \Arg{tokens}
% \end{syntax}
% Carries out expansion on the \meta{expandable tokens} before conversion of
% the \meta{tokens} to a string as describe for \cs{tl_to_str:n}. Typically,
% the \meta{expandable tokens} will alter the nature of the \meta{tokens},
% \emph{i.e.}~allow it to be generated in some way. This function requires
% only a single expansion.
% \end{function}
%
% \section{Kernel backend functions}
%
% These functions are required to pass information to the backend. The nature
% of these means that they are defined only when the relevant backend is in
% use.
%
% \begin{function}
% {
% \__kernel_backend_literal:n,
% \__kernel_backend_literal:e,
% \__kernel_backend_literal:x
% }
% \begin{syntax}
% \cs{__kernel_backend_literal:n} \Arg{content}
% \end{syntax}
% Adds the \meta{content} literally to the current vertical list as a
% whatsit. The nature of the \meta{content} will depend on the backend in
% use.
% \end{function}
%
% \begin{function}
% {
% \__kernel_backend_literal_postscript:n,
% \__kernel_backend_literal_postscript:x
% }
% \begin{syntax}
% \cs{__kernel_backend_literal_postscript:n} \Arg{PostScript}
% \end{syntax}
% Adds the \meta{PostScript} literally to the current vertical list as a
% whatsit. No positioning is applied.
% \end{function}
%
% \begin{function}
% {
% \__kernel_backend_literal_pdf:n,
% \__kernel_backend_literal_pdf:x
% }
% \begin{syntax}
% \cs{__kernel_backend_literal_pdf:n} \Arg{PDF instructions}
% \end{syntax}
% Adds the \meta{PDF instructions} literally to the current vertical list as
% a whatsit. No positioning is applied.
% \end{function}
%
% \begin{function}
% {
% \__kernel_backend_literal_svg:n,
% \__kernel_backend_literal_svg:x
% }
% \begin{syntax}
% \cs{__kernel_backend_literal_svg:n} \Arg{SVG instructions}
% \end{syntax}
% Adds the \meta{SVG instructions} literally to the current vertical list as
% a whatsit. No positioning is applied.
% \end{function}
%
% \begin{function}
% {
% \__kernel_backend_postscript:n,
% \__kernel_backend_postscript:x
% }
% \begin{syntax}
% \cs{__kernel_backend_postscript:n} \Arg{PostScript}
% \end{syntax}
% Adds the \meta{PostScript} to the current vertical list as a
% whatsit. The PostScript reference point is adjusted to match the
% current position. The PostScript is inserted inside a |SDict begin|/|end|
% pair.
% \end{function}
%
% \begin{function}{\__kernel_backend_postscript_header:n}
% \begin{syntax}
% \cs{__kernel_backend_postscript_header:n} \Arg{PostScript}
% \end{syntax}
% Adds the \meta{PostScript} to the PostScript header.
% \end{function}
%
% \begin{function}{\__kernel_backend_align_begin:, \__kernel_backend_align_end:}
% \begin{syntax}
% \cs{__kernel_backend_align_begin:}
% \meta{PostScript literals}
% \cs{__kernel_backend_align_end:}
% \end{syntax}
% Arranges to align the PostScript and DVI current positions and scales.
% \end{function}
%
% \begin{function}{\__kernel_backend_scope_begin:, \__kernel_backend_scope_end:}
% \begin{syntax}
% \cs{__kernel_backend_scope_begin:}
% \meta{content}
% \cs{__kernel_backend_scope_end:}
% \end{syntax}
% Creates a scope for instructions at the backend level.
% \end{function}
%
% \begin{function}
% {
% \__kernel_backend_matrix:n,
% \__kernel_backend_matrix:x
% }
% \begin{syntax}
% \cs{__kernel_backend_matrix:n} \Arg{matrix}
% \end{syntax}
% Applies the \meta{matrix} to the current transformation matrix.
% \end{function}
%
% \begin{function}{\l__kernel_color_stack_int}
% The color stack used in \pdfTeX{} and \LuaTeX{} for the main color.
% \end{function}
%
% \end{implementation}
%
% \PrintIndex
|