summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3tl.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3tl.dtx200
1 files changed, 102 insertions, 98 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
index a655fe18ea3..61505a3337c 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx
@@ -41,7 +41,7 @@
% }^^A
% }
%
-% \date{Released 2018/03/05}
+% \date{Released 2018-04-30}
%
% \maketitle
%
@@ -316,8 +316,7 @@
% (character code $32$ or $9$) at the end of every line.
% Otherwise, spaces (and tabs) are retained at both ends of the
% single-line string, as if it appeared in the middle of a line
-% read from a file. Only the case of a single line is supported in
-% \LuaTeX{} because of a bug in this engine.
+% read from a file.
% \end{texnote}
% \end{function}
%
@@ -346,8 +345,7 @@
% (character code $32$ or $9$) at the end of every line.
% Otherwise, spaces (and tabs) are retained at both ends of the
% single-line string, as if it appeared in the middle of a line
-% read from a file. Only the case of a single line is supported in
-% \LuaTeX{} because of a bug in this engine.
+% read from a file.
% \end{texnote}
% \end{function}
%
@@ -621,7 +619,10 @@
% resulting character tokens in the input stream. A \meta{string}
% is a series of tokens with category code $12$ (other) with the exception
% of spaces, which retain category code $10$ (space).
+% This function requires only a single expansion.
+% Its argument \emph{must} be braced.
% \begin{texnote}
+% This is the \eTeX{} primitive \tn{detokenize}.
% Converting a \meta{token list} to a \meta{string} yields a
% concatenation of the string representations of every token in the
% \meta{token list}.
@@ -754,7 +755,7 @@
% \end{function}
%
% \begin{function}[added = 2011-07-09, updated = 2012-06-25, EXP]
-% {\tl_trim_spaces:n}
+% {\tl_trim_spaces:n, \tl_trim_spaces:o}
% \begin{syntax}
% \cs{tl_trim_spaces:n} \Arg{token list}
% \end{syntax}
@@ -769,6 +770,17 @@
% \end{texnote}
% \end{function}
%
+% \begin{function}[added = 2018-04-12, EXP]
+% {\tl_trim_spaces_apply:nN, \tl_trim_spaces_apply:oN}
+% \begin{syntax}
+% \cs{tl_trim_spaces_apply:nN} \Arg{token list} \meta{function}
+% \end{syntax}
+% Removes any leading and trailing explicit space characters (explicit
+% tokens with character code~$32$ and category code~$10$) from the
+% \meta{token list} and passes the result to the \meta{function} as an
+% \texttt{n}-type argument.
+% \end{function}
+%
% \begin{function}[added = 2011-07-09]
% {
% \tl_trim_spaces:N, \tl_trim_spaces:c,
@@ -1079,22 +1091,6 @@
% code and so should only be used for short-term storage.
% \end{variable}
%
-% \section{Internal functions}
-%
-% \begin{function}{\__tl_trim_spaces:nn}
-% \begin{syntax}
-% \cs{__tl_trim_spaces:nn} |{ \q_mark| \meta{token list} |}| \Arg{continuation}
-% \end{syntax}
-% This function removes all leading and trailing explicit space
-% characters from the \meta{token list}, and expands to the
-% \meta{continuation}, followed by a brace group containing
-% \cs{use_none:n} \cs{q_mark} \meta{trimmed token list}. For
-% instance, \cs{tl_trim_spaces:n} is implemented by taking the
-% \meta{continuation} to be \cs{exp_not:o}, and the \texttt{o}-type
-% expansion removes the \cs{q_mark}. This function is also used in
-% \pkg{l3clist} and \pkg{l3candidates}.
-% \end{function}
-%
% \end{documentation}
%
% \begin{implementation}
@@ -1121,7 +1117,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \tl_new:N #1
{
- \__chk_if_free_cs:N #1
+ \__kernel_chk_if_free_cs:N #1
\cs_gset_eq:NN #1 \c_empty_tl
}
\cs_generate_variant:Nn \tl_new:N { c }
@@ -1134,13 +1130,13 @@
\__kernel_patch:nnNNpn { \__kernel_chk_var_scope:NN c #1 } { }
\cs_new_protected:Npn \tl_const:Nn #1#2
{
- \__chk_if_free_cs:N #1
+ \__kernel_chk_if_free_cs:N #1
\cs_gset_nopar:Npx #1 { \exp_not:n {#2} }
}
\__kernel_patch:nnNNpn { \__kernel_chk_var_scope:NN c #1 } { }
\cs_new_protected:Npn \tl_const:Nx #1#2
{
- \__chk_if_free_cs:N #1
+ \__kernel_chk_if_free_cs:N #1
\cs_gset_nopar:Npx #1 {#2}
}
\cs_generate_variant:Nn \tl_const:Nn { c }
@@ -1183,23 +1179,25 @@
% For setting token list variables equal to each other. When checking
% is turned on, make sure both variables exist.
% \begin{macrocode}
-\tex_ifodd:D \l@expl@enable@debug@bool
- \cs_new_protected:Npn \tl_set_eq:NN #1#2
- {
- \__kernel_chk_var_local:N #1
- \__kernel_chk_var_exist:N #2
- \cs_set_eq:NN #1 #2
- }
- \cs_new_protected:Npn \tl_gset_eq:NN #1#2
- {
- \__kernel_chk_var_global:N #1
- \__kernel_chk_var_exist:N #2
- \cs_gset_eq:NN #1 #2
- }
-\else:
- \cs_new_eq:NN \tl_set_eq:NN \cs_set_eq:NN
- \cs_new_eq:NN \tl_gset_eq:NN \cs_gset_eq:NN
-\fi:
+\__kernel_if_debug:TF
+ {
+ \cs_new_protected:Npn \tl_set_eq:NN #1#2
+ {
+ \__kernel_chk_var_local:N #1
+ \__kernel_chk_var_exist:N #2
+ \cs_set_eq:NN #1 #2
+ }
+ \cs_new_protected:Npn \tl_gset_eq:NN #1#2
+ {
+ \__kernel_chk_var_global:N #1
+ \__kernel_chk_var_exist:N #2
+ \cs_gset_eq:NN #1 #2
+ }
+ }
+ {
+ \cs_new_eq:NN \tl_set_eq:NN \cs_set_eq:NN
+ \cs_new_eq:NN \tl_gset_eq:NN \cs_gset_eq:NN
+ }
\cs_generate_variant:Nn \tl_set_eq:NN { cN, Nc, cc }
\cs_generate_variant:Nn \tl_gset_eq:NN { cN, Nc, cc }
% \end{macrocode}
@@ -1491,7 +1489,8 @@
}
{
\group_begin:
- \exp_args:No \etex_everyeof:D { \c_@@_rescan_marker_tl \exp_not:N }
+ \exp_args:No \etex_everyeof:D
+ { \c_@@_rescan_marker_tl \exp_not:N }
\int_compare:nNnT \tex_endlinechar:D = { 32 }
{ \int_set:Nn \tex_endlinechar:D { -1 } }
\tex_newlinechar:D \tex_endlinechar:D
@@ -1636,7 +1635,7 @@
\int_compare:nNnT
{
\char_value_catcode:n
- { \exp_last_unbraced:Nf ` \str_head:n {#2} ~ }
+ { \exp_last_unbraced:Nf ` { \str_head:n {#2} } ~ }
}
= { 10 } { ~ }
\exp_after:wN \@@_rescan:w
@@ -1783,9 +1782,12 @@
}
% \end{macrocode}
% The auxiliary \cs{@@_replace_auxii:nNNNnn} receives the following
-% arguments: \Arg{delimiter}
-% \meta{function} \meta{assignment} \meta{tl~var} \Arg{pattern}
-% \Arg{replacement}. All of its work is done between
+% arguments:
+% \begin{quote}
+% \Arg{delimiter} \meta{function} \meta{assignment} \\
+% \meta{tl~var} \Arg{pattern} \Arg{replacement}
+% \end{quote}
+% All of its work is done between
% \cs{group_align_safe_begin:} and \cs{group_align_safe_end:} to avoid
% issues in alignments. It does the actual replacement within
% |#3|~|#4|~|{...}|, an \texttt{x}-expanding \meta{assignment}~|#3| to
@@ -1960,13 +1962,11 @@
% The test for emptiness is based on \cs{tl_if_empty:nTF}, but
% the expansion is hard-coded for efficiency, as this auxiliary
% function is used in many places.
-% Note that this works because \cs{etex_detokenize:D} expands tokens
-% that follow until reading a catcode $1$ (begin-group) token.
% \begin{macrocode}
\cs_new:Npn \@@_if_empty_return:o #1
{
\exp_after:wN \if_meaning:w \exp_after:wN \q_nil
- \etex_detokenize:D \exp_after:wN {#1} \q_nil
+ \__kernel_tl_to_str:w \exp_after:wN {#1} \q_nil
\prg_return_true:
\else:
\prg_return_false:
@@ -2067,23 +2067,20 @@
% up to be expandable and to check the value exactly. The question
% mark prevents the auxiliary from losing braces.
% \begin{macrocode}
-\use:x
+\cs_set_protected:Npn \@@_tmp:w #1
{
- \prg_new_conditional:Npnn \exp_not:N \tl_if_novalue:n ##1
+ \prg_new_conditional:Npnn \tl_if_novalue:n ##1
{ p , T , F , TF }
{
- \exp_not:N \str_if_eq:onTF
- {
- \exp_not:N \@@_if_novalue:w ? ##1 { }
- \c_novalue_tl
- }
- { ? { } \c_novalue_tl }
- { \exp_not:N \prg_return_true: }
- { \exp_not:N \prg_return_false: }
+ \str_if_eq:onTF
+ { \@@_if_novalue:w ? ##1 { } #1 }
+ { ? { } #1 }
+ { \prg_return_true: }
+ { \prg_return_false: }
}
- \cs_new:Npn \exp_not:N \@@_if_novalue:w ##1 \c_novalue_tl
- {##1}
+ \cs_new:Npn \@@_if_novalue:w ##1 #1 {##1}
}
+\exp_args:No \@@_tmp:w { \c_novalue_tl }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2112,15 +2109,15 @@
% |#1| has a single item, the token is~|^| and the catcode test
% yields \texttt{true}. Otherwise, it is one of the characters
% resulting from \cs{tl_to_str:n}, and the catcode test yields
-% \texttt{false}. Note that \cs{if_catcode:w} takes care of the
-% expansions, and that \cs{tl_to_str:n} (the \tn{detokenize}
-% primitive) actually expands tokens until finding a begin-group
-% token.
+% \texttt{false}. Note that \cs{if_catcode:w} and
+% \cs{__kernel_tl_to_str:w} are primitives that take care of
+% expansion.
% \begin{macrocode}
\prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF }
{
\if_catcode:w ^ \exp_after:wN \@@_if_single:nnw
- \tl_to_str:n \exp_after:wN { \use_none:nn #1 ?? } ^ ? \q_stop
+ \__kernel_tl_to_str:w
+ \exp_after:wN { \use_none:nn #1 ?? } ^ ? \q_stop
\prg_return_true:
\else:
\prg_return_false:
@@ -2134,7 +2131,6 @@
% \begin{macro}[EXP, noTF]{\tl_case:Nn, \tl_case:cn}
% \begin{macro}[EXP]{\@@_case:nnTF}
% \begin{macro}[EXP]{\@@_case:Nw}
-% \begin{macro}[EXP]{\__prg_case_end:nw}
% \begin{macro}[EXP]{\@@_case_end:nw}
% The aim here is to allow the case statement to be evaluated
% using a known number of expansion steps (two), and without
@@ -2187,15 +2183,13 @@
% the first \cs{q_mark} and so |#4| is the \texttt{false} code (the
% \texttt{true} code is mopped up by |#3|).
% \begin{macrocode}
-\cs_new:Npn \__prg_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
+\cs_new:Npn \@@_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
{ \exp_end: #1 #4 }
-\cs_new_eq:NN \@@_case_end:nw \__prg_case_end:nw
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \subsection{Mapping to token lists}
%
@@ -2210,13 +2204,13 @@
{
\@@_map_function:Nn #2 #1
\q_recursion_tail
- \__prg_break_point:Nn \tl_map_break: { }
+ \prg_break_point:Nn \tl_map_break: { }
}
\cs_new:Npn \tl_map_function:NN
{ \exp_args:No \tl_map_function:nN }
\cs_new:Npn \@@_map_function:Nn #1#2
{
- \__quark_if_recursion_tail_break:nN {#2} \tl_map_break:
+ \quark_if_recursion_tail_break:nN {#2} \tl_map_break:
#1 {#2} \@@_map_function:Nn #1
}
\cs_generate_variant:Nn \tl_map_function:NN { c }
@@ -2228,19 +2222,20 @@
% \begin{macro}{\tl_map_inline:nn}
% \begin{macro}{\tl_map_inline:Nn, \tl_map_inline:cn}
% The inline functions are straight forward by now. We use a little
-% trick with the counter \cs{g__prg_map_int} to make
+% trick with the counter \cs{g__kernel_prg_map_int} to make
% them nestable. We can also make use of \cs{@@_map_function:Nn}
% from before.
% \begin{macrocode}
\cs_new_protected:Npn \tl_map_inline:nn #1#2
{
- \int_gincr:N \g__prg_map_int
+ \int_gincr:N \g__kernel_prg_map_int
\cs_gset_protected:cpn
- { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2}
+ { @@_map_ \int_use:N \g__kernel_prg_map_int :w } ##1 {#2}
\exp_args:Nc \@@_map_function:Nn
- { __prg_map_ \int_use:N \g__prg_map_int :w }
+ { @@_map_ \int_use:N \g__kernel_prg_map_int :w }
#1 \q_recursion_tail
- \__prg_break_point:Nn \tl_map_break: { \int_gdecr:N \g__prg_map_int }
+ \prg_break_point:Nn \tl_map_break:
+ { \int_gdecr:N \g__kernel_prg_map_int }
}
\cs_new_protected:Npn \tl_map_inline:Nn
{ \exp_args:No \tl_map_inline:nn }
@@ -2260,14 +2255,14 @@
{
\@@_map_variable:Nnn #2 {#3} #1
\q_recursion_tail
- \__prg_break_point:Nn \tl_map_break: { }
+ \prg_break_point:Nn \tl_map_break: { }
}
\cs_new_protected:Npn \tl_map_variable:NNn
{ \exp_args:No \tl_map_variable:nNn }
\cs_new_protected:Npn \@@_map_variable:Nnn #1#2#3
{
\tl_set:Nn #1 {#3}
- \__quark_if_recursion_tail_break:NN #1 \tl_map_break:
+ \quark_if_recursion_tail_break:NN #1 \tl_map_break:
\use:n {#2}
\@@_map_variable:Nnn #1 {#2}
}
@@ -2279,12 +2274,12 @@
%
% \begin{macro}{\tl_map_break:}
% \begin{macro}{\tl_map_break:n}
-% The break statements use the general \cs{__prg_map_break:Nn}.
+% The break statements use the general \cs{prg_map_break:Nn}.
% \begin{macrocode}
\cs_new:Npn \tl_map_break:
- { \__prg_map_break:Nn \tl_map_break: { } }
+ { \prg_map_break:Nn \tl_map_break: { } }
\cs_new:Npn \tl_map_break:n
- { \__prg_map_break:Nn \tl_map_break: }
+ { \prg_map_break:Nn \tl_map_break: }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2302,7 +2297,7 @@
% These functions return the replacement text of a token list as a
% string.
% \begin{macrocode}
-\cs_new:Npn \tl_to_str:N #1 { \etex_detokenize:D \exp_after:wN {#1} }
+\cs_new:Npn \tl_to_str:N #1 { \__kernel_tl_to_str:w \exp_after:wN {#1} }
\cs_generate_variant:Nn \tl_to_str:N { c }
% \end{macrocode}
% \end{macro}
@@ -2381,6 +2376,7 @@
% \end{macro}
%
% \begin{macro}{\tl_trim_spaces:n, \tl_trim_spaces:o}
+% \begin{macro}{\tl_trim_spaces_apply:nN, \tl_trim_spaces_apply:oN}
% \begin{macro}
% {
% \tl_trim_spaces:N, \tl_trim_spaces:c,
@@ -2397,6 +2393,9 @@
\cs_new:Npn \tl_trim_spaces:n #1
{ \@@_trim_spaces:nn { \q_mark #1 } \exp_not:o }
\cs_generate_variant:Nn \tl_trim_spaces:n { o }
+\cs_new:Npn \tl_trim_spaces_apply:nN #1#2
+ { \@@_trim_spaces:nn { \q_mark #1 } { \exp_args:No #2 } }
+\cs_generate_variant:Nn \tl_trim_spaces_apply:nN { o }
\cs_new_protected:Npn \tl_trim_spaces:N #1
{ \tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
\cs_new_protected:Npn \tl_gtrim_spaces:N #1
@@ -2469,6 +2468,7 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}
% {\tl_sort:Nn, \tl_sort:cn, \tl_gsort:Nn, \tl_gsort:cn, \tl_sort:nN}
@@ -2478,12 +2478,16 @@
% \subsection{Token by token changes}
%
% \begin{variable}{\q_@@_act_mark, \q_@@_act_stop}
-% The \cs{tl_act} functions may be applied to any token list.
+% The \cs[no-index]{@@_act_\ldots{}} functions may be applied to any token list.
% Hence, we use two private quarks, to allow any token, even quarks,
% in the token list.
% Only \cs{q_@@_act_mark} and \cs{q_@@_act_stop} may not appear
-% in the token lists manipulated by \cs{@@_act:NNNnn} functions. The quarks
-% are effectively defined in \pkg{l3quark}.
+% in the token lists manipulated by \cs{@@_act:NNNnn} functions.
+% No quark module yet, so do things by hand.
+% \begin{macrocode}
+\cs_new_nopar:Npn \q_@@_act_mark { \q_@@_act_mark }
+\cs_new_nopar:Npn \q_@@_act_stop { \q_@@_act_stop }
+% \end{macrocode}
% \end{variable}
%
% \begin{macro}[EXP]{\@@_act:NNNnn}
@@ -2588,7 +2592,7 @@
% \begin{macrocode}
\cs_new:Npn \tl_reverse:n #1
{
- \etex_unexpanded:D \exp_after:wN
+ \__kernel_exp_not:w \exp_after:wN
{
\exp:w
\@@_act:NNNnn
@@ -2645,7 +2649,7 @@
% \begin{macrocode}
\cs_new:Npn \tl_head:n #1
{
- \etex_unexpanded:D
+ \__kernel_exp_not:w
\if_false: { \fi: \@@_head_auxi:nw #1 { } \q_stop }
}
\cs_new:Npn \@@_head_auxi:nw #1#2 \q_stop
@@ -2656,7 +2660,7 @@
\cs_new:Npn \@@_head_auxii:n #1
{
\exp_after:wN \if_meaning:w \exp_after:wN \q_nil
- \tl_to_str:n \exp_after:wN { \use_none:n #1 } \q_nil
+ \__kernel_tl_to_str:w \exp_after:wN { \use_none:n #1 } \q_nil
\exp_after:wN \use_i:nn
\else:
\exp_after:wN \use_ii:nn
@@ -2685,7 +2689,7 @@
% \begin{macrocode}
\cs_new:Npn \tl_tail:n #1
{
- \etex_unexpanded:D
+ \__kernel_exp_not:w
\tl_if_blank:nTF {#1}
{ { } }
{ \exp_after:wN { \use_none:n #1 } }
@@ -2928,7 +2932,7 @@
{ \exp_args:Nf \@@_item_aux:nn { \int_eval:n {#2} } {#1} }
#1
\q_recursion_tail
- \__prg_break_point:
+ \prg_break_point:
}
\cs_new:Npn \@@_item_aux:nn #1#2
{
@@ -2938,9 +2942,9 @@
}
\cs_new:Npn \@@_item:nn #1#2
{
- \__quark_if_recursion_tail_break:nN {#2} \__prg_break:
+ \quark_if_recursion_tail_break:nN {#2} \prg_break:
\int_compare:nNnTF {#1} = 1
- { \__prg_break:n { \exp_not:n {#2} } }
+ { \prg_break:n { \exp_not:n {#2} } }
{ \exp_args:Nf \@@_item:nn { \int_eval:n { #1 - 1 } } }
}
\cs_new:Npn \tl_item:Nn { \exp_args:No \tl_item:nn }
@@ -2961,7 +2965,7 @@
\cs_generate_variant:Nn \tl_log:N { c }
\cs_new_protected:Npn \@@_show:NN #1#2
{
- \__kernel_check_defined:NT #2
+ \__kernel_chk_defined:NT #2
{ \exp_args:Nx #1 { \token_to_str:N #2 = \exp_not:o {#2} } }
}
% \end{macrocode}
@@ -2980,7 +2984,7 @@
% of all these manipulations is displayed to the terminal using
% \cs{etex_showtokens:D} and an odd \cs{exp_after:wN} which expand the
% closing brace to improve the output slightly. The calls to
-% \cs{__iow_with:Nnn} ensure that the \tn{newlinechar} is set to~$10$
+% \cs{__kernel_iow_with:Nnn} ensure that the \tn{newlinechar} is set to~$10$
% so that the \cs{iow_newline:} inserted by the line-wrapping code
% are correctly recognized by \TeX{}, and that \tn{errorcontextlines}
% is $-1$ to avoid printing irrelevant context.
@@ -2990,9 +2994,9 @@
\cs_new_protected:Npn \@@_show:n #1
{
\tl_set:Nf \l_@@_internal_a_tl { \@@_show:w #1 \q_stop }
- \__iow_with:Nnn \tex_newlinechar:D { 10 }
+ \__kernel_iow_with:Nnn \tex_newlinechar:D { 10 }
{
- \__iow_with:Nnn \tex_errorcontextlines:D { -1 }
+ \__kernel_iow_with:Nnn \tex_errorcontextlines:D { -1 }
{
\etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN
{ \exp_after:wN \l_@@_internal_a_tl }