diff options
author | Karl Berry <karl@freefriends.org> | 2014-08-26 17:33:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-08-26 17:33:09 +0000 |
commit | 6c4cd2ab2f8d1ebe3a051d700c3005d73eefe04c (patch) | |
tree | 16833d474c6532347c42dee6b34fa77aed22eca6 /Master/texmf-dist/source/latex/l3kernel/l3quark.dtx | |
parent | 097e7dc0afa442be238a967b292237470680626e (diff) |
l3 (26aug14)
git-svn-id: svn://tug.org/texlive/trunk@35045 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3quark.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3quark.dtx | 80 |
1 files changed, 49 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx index 29352c0212b..755b37577dc 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx @@ -37,7 +37,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3quark.dtx 4889 2014-05-26 19:59:25Z joseph $ +\GetIdInfo$Id: l3quark.dtx 5354 2014-08-23 01:35:39Z bruno $ {L3 Quarks} %</driver|package> %<*driver> @@ -295,7 +295,8 @@ \cs_new:Npn \my_map_dbl:nn #1#2 { \cs_set:Npn \__my_map_dbl_fn:nn ##1 ##2 {#2} - \__my_map_dbl:nn #1 \q_recursion_tail \q_recursion_tail \q_recursion_stop + \__my_map_dbl:nn #1 \q_recursion_tail \q_recursion_tail + \q_recursion_stop } % \end{macrocode} % @@ -393,6 +394,10 @@ % % \subsection{Quarks} % +% \begin{macrocode} +%<@@=quark> +% \end{macrocode} +% % \begin{macro}{\quark_new:N} % \UnitTested % Allocate a new quark. @@ -461,30 +466,34 @@ % \begin{macro} % {\quark_if_recursion_tail_stop_do:nn,\quark_if_recursion_tail_stop_do:on} % \UnitTested -% The same idea applies when testing multiple tokens, but here we just -% compare the token list to \cs{q_recursion_tail} as a string. +% \begin{macro}[aux]{\@@_if_recursion_tail:w} +% See \cs{quark_if_nil:nTF} for the details. Expanding +% \cs{@@_if_recursion_tail:w} once in front of the tokens chosen here +% gives an empty result if and only if |#1|~is exactly +% \cs{q_recursion_tail}. % \begin{macrocode} \cs_new:Npn \quark_if_recursion_tail_stop:n #1 { - \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:N \q_recursion_tail } { \exp_not:n {#1} } = \c_zero - \exp_after:wN \use_none_delimit_by_q_recursion_stop:w - \fi: + \tl_if_empty:oTF + { \@@_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! } + { \use_none_delimit_by_q_recursion_stop:w } + { } } \cs_new:Npn \quark_if_recursion_tail_stop_do:nn #1 { - \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:N \q_recursion_tail } { \exp_not:n {#1} } = \c_zero - \exp_after:wN \use_i_delimit_by_q_recursion_stop:nw - \else: - \exp_after:wN \use_none:n - \fi: + \tl_if_empty:oTF + { \@@_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! } + { \use_i_delimit_by_q_recursion_stop:nw } + { \use_none:n } } +\cs_new:Npn \@@_if_recursion_tail:w + #1 \q_recursion_tail #2 ? #3 ?! { #1 #2 } \cs_generate_variant:Nn \quark_if_recursion_tail_stop:n { o } \cs_generate_variant:Nn \quark_if_recursion_tail_stop_do:nn { o } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\__quark_if_recursion_tail_break:NN} % \begin{macro}{\__quark_if_recursion_tail_break:nN} @@ -499,10 +508,10 @@ } \cs_new:Npn \__quark_if_recursion_tail_break:nN #1#2 { - \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:N \q_recursion_tail } { \exp_not:n {#1} } = \c_zero - \exp_after:wN #2 - \fi: + \tl_if_empty:oTF + { \@@_if_recursion_tail:w {} #1 {} ?! \q_recursion_tail ??! } + {#2} + { } } % \end{macrocode} % \end{macro} @@ -546,26 +555,34 @@ % \UnitTested % \begin{macro}[pTF]{\quark_if_no_value:n} % \UnitTested -% These are essentially \cs{str_if_eq:nn} tests but done directly. +% \begin{macro}[aux]{\@@_if_nil:w, \@@_if_no_value:w} +% Let us explain |\quark_if_nil:n(TF)|. Expanding \cs{@@_if_nil:w} +% once is safe thanks to the trailing \cs{q_nil} |??!|. The result of +% expanding once is empty if and only if both delimited arguments |#1| +% and~|#2| are empty and |#3|~is delimited by the last tokens~|?!|. +% Thanks to the leading~|{}|, the argument~|#1| is empty if and only +% if the argument of \cs{quark_if_nil:n} starts with \cs{q_nil}. The +% argument~|#2| is empty if and only if this \cs{q_nil} is followed +% immediately by~|?| or by~|{}?|, coming either from the trailing +% tokens in the definition of \cs{quark_if_nil:n}, or from its +% argument. In the first case, \cs{@@_if_nil:w} is followed by +% |{}\q_nil| |{}?| |!\q_nil|~|??!|, hence |#3|~is delimited by the +% final~|?!|, and the test returns \texttt{true} as wanted. In the +% second case, the result is not empty since the first~|?!| in the +% definition of \cs{quark_if_nil:n} stop~|#3|. % \begin{macrocode} \prg_new_conditional:Nnn \quark_if_nil:n { p, T , F , TF } { - \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:N \q_nil } { \exp_not:n {#1} } = \c_zero - \prg_return_true: - \else: - \prg_return_false: - \fi: + \__tl_if_empty_return:o + { \@@_if_nil:w {} #1 {} ? ! \q_nil ? ? ! } } +\cs_new:Npn \@@_if_nil:w #1 \q_nil #2 ? #3 ? ! { #1 #2 } \prg_new_conditional:Nnn \quark_if_no_value:n { p, T , F , TF } { - \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:N \q_no_value } { \exp_not:n {#1} } = \c_zero - \prg_return_true: - \else: - \prg_return_false: - \fi: + \__tl_if_empty_return:o + { \@@_if_no_value:w {} #1 {} ? ! \q_no_value ? ? ! } } +\cs_new:Npn \@@_if_no_value:w #1 \q_no_value #2 ? #3 ? ! { #1 #2 } \cs_generate_variant:Nn \quark_if_nil_p:n { V , o } \cs_generate_variant:Nn \quark_if_nil:nTF { V , o } \cs_generate_variant:Nn \quark_if_nil:nT { V , o } @@ -573,6 +590,7 @@ % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \begin{variable}{\q__tl_act_mark, \q__tl_act_stop} % These private quarks are needed by \pkg{l3tl}, but that is loaded |