[latex3-commits] [git/LaTeX3-latex3-latex3] scan-quark: Avoid using \tl_if_empty:nTF in l3quark since it is not available yet (44c1f68ac)
Bruno Le Floch
bruno at le-floch.fr
Wed May 6 23:40:08 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : scan-quark
Link : https://github.com/latex3/latex3/commit/44c1f68ac9874df8313c55e71dbbfa1be2bf4f5e
>---------------------------------------------------------------
commit 44c1f68ac9874df8313c55e71dbbfa1be2bf4f5e
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Wed May 6 23:40:08 2020 +0200
Avoid using \tl_if_empty:nTF in l3quark since it is not available yet
>---------------------------------------------------------------
44c1f68ac9874df8313c55e71dbbfa1be2bf4f5e
l3kernel/l3quark.dtx | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/l3kernel/l3quark.dtx b/l3kernel/l3quark.dtx
index 4cc9442c7..35d88c7d8 100644
--- a/l3kernel/l3quark.dtx
+++ b/l3kernel/l3quark.dtx
@@ -627,6 +627,10 @@
% \item[N] gives an analogue of \cs[no-index]{quark_if_nil:N(TF)}
% \end{description}
% Any other signature causes an error, as does a function without signature.
+% We use low-level emptiness tests as \pkg{l3tl} is not available yet when these
+% functions are used; thankfully we only care about whether strings
+% are empty so a simple \cs{if_meaning:w} \cs{q_nil} \meta{string}
+% \cs{q_nil} suffices.
%
% \begin{macro}{\@@_new_test:NNNn, \@@_new_test:Nccn,
% \@@_new_test_aux:nnNNnnnn, \@@_new_test_choose:nNnnnn}
@@ -635,12 +639,12 @@
{ \@@_new_test_aux:Nx #1 { \@@_module_name:N #1 } }
\cs_new_protected:Npn \@@_new_test_aux:Nn #1 #2
{
- \tl_if_empty:nTF {#2}
- { \__kernel_msg_expandable_error:nn { kernel } { invalid-quark-function } }
- {
- \@@_new_test:Nccn #1
- { q__#2_recursion_tail } { q__#2_recursion_stop } { __#2 }
- }
+ \if_meaning:w \q_nil #2 \q_nil
+ \__kernel_msg_expandable_error:nn { kernel } { invalid-quark-function }
+ \else:
+ \@@_new_test:Nccn #1
+ { q__#2_recursion_tail } { q__#2_recursion_stop } { __#2 }
+ \fi:
}
\cs_generate_variant:Nn \@@_new_test_aux:Nn { Nx }
\cs_new_protected:Npn \@@_new_test:NNNn #1
@@ -658,14 +662,18 @@
}
\cs_new_protected:Npn \@@_new_conditional:Nnnn #1#2#3#4
{
- \tl_if_empty:nTF {#3} { \use_i:nn } { \tl_if_empty:nTF {#2} }
- { \__kernel_msg_error:nn { kernel } { invalid-quark-function } }
- {
+ \if_meaning:w \q_nil #2 \q_nil
+ \__kernel_msg_error:nn { kernel } { invalid-quark-function }
+ \else:
+ \if_meaning:w \q_nil #3 \q_nil
+ \__kernel_msg_error:nn { kernel } { invalid-quark-function }
+ \else:
\exp_last_unbraced:Nf \@@_new_test_aux:nnNNnnnn
{ \cs_split_function:N #1 }
#1 { conditional }
{#2} {#3} {#4}
- }
+ \fi:
+ \fi:
}
\cs_generate_variant:Nn \@@_new_conditional:Nnnn { Nxx }
\cs_new_protected:Npn \@@_new_test_aux:nnNNnnnn #1 #2 #3 #4
@@ -875,7 +883,9 @@
% found the result is an empty string. The approach is to first cut
% off everything after the (first) |:| if any is present, then
% repeatedly grab |_|-delimited words until finding one of length at
-% least~$2$. If no \meta{module} is found (such as in \cs{::n}) we
+% least~$2$ (we use low-level tests as \pkg{l3tl} is not fully
+% available when \cs{__kernel_quark_new_test:N} is first used.
+% If no \meta{module} is found (such as in \cs{::n}) we
% get the trailing marker \cs{use_none:n} |{}|, which expands to
% nothing.
% \begin{macrocode}
@@ -890,13 +900,15 @@
{ \@@_module_name_loop:w ##1 #2 \use_none:n { } #2 \s_@@ }
\cs_new:Npn \@@_module_name_loop:w ##1 #2
{
- \tl_if_empty:nTF {##1} { \@@_module_name_loop:w }
- {
- \tl_if_single:nTF {##1} { \@@_module_name_loop:w }
- { ##1 \@@_module_name_end:w }
- }
+ \use_i_ii:nnn \if_meaning:w \prg_do_nothing:
+ ##1 \prg_do_nothing: \prg_do_nothing:
+ \exp_after:wN \@@_module_name_loop:w
+ \else:
+ \@@_module_name_end:w ##1
+ \fi:
}
- \cs_new:Npn \@@_module_name_end:w ##1 \s_@@ { }
+ \cs_new:Npn \@@_module_name_end:w
+ ##1 \fi: ##2 \s_@@ { \fi: ##1 }
}
\exp_after:wN \@@_tmp:w \tl_to_str:n { : _ }
% \end{macrocode}
More information about the latex3-commits
mailing list.