diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3basics.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3basics.dtx | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx index 54fcf80009b..339eb9eacb1 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx @@ -37,7 +37,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3basics.dtx 4728 2014-05-04 13:25:37Z joseph $ +\GetIdInfo$Id: l3basics.dtx 5033 2014-06-04 05:32:44Z joseph $ {L3 Basic definitions} %</driver|package> %<*driver> @@ -1367,7 +1367,7 @@ % such that internal parts of the mechanism are not visible. % \end{function} % -% \begin{function}{\__prg_case_end:nw} +% \begin{function}[EXP]{\__prg_case_end:nw} % \begin{syntax} % \cs{__prg_case_end:nw} \Arg{code} \meta{tokens} \cs{q_mark} \Arg{true code} \cs{q_mark} \Arg{false code} \cs{q_stop} % \end{syntax} @@ -1377,8 +1377,18 @@ % case (if one is found) and either the \texttt{true code} or % \texttt{false code} for the over all outcome, as appropriate. % \end{function} +% +% \begin{function}[EXP]{\__str_if_eq_x:nn} +% \begin{syntax} +% \cs{__str_if_eq_x:nn} \Arg{tl_1} \Arg{tl_2} +% \end{syntax} +% Compares the full expansion of two \meta{token lists} on a character by +% character basis, and is \texttt{true} if the two lists contain the same +% characters in the same order. Leaves |0| in the input stream if the +% condition is true, and |+1| or |-1| otherwise. +% \end{function} % -% \begin{function}{\__str_if_eq_x_return:nn} +% \begin{function}[EXP]{\__str_if_eq_x_return:nn} % \begin{syntax} % \cs{__str_if_eq_x_return:nn} \Arg{tl_1} \Arg{tl_2} % \end{syntax} @@ -2506,6 +2516,7 @@ % \cs_new_protected_nopar:Npn , \cs_new_protected_nopar:Npx , % \cs_new_protected:Npn , \cs_new_protected:Npx % } +% \begin{macro}[int]{\__cs_tmp:w} % Function which check that the control sequence is free before % defining it. % \begin{macrocode} @@ -2527,6 +2538,7 @@ \__cs_tmp:w \cs_new_protected:Npx \cs_gset_protected:Npx % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro} % { @@ -3063,6 +3075,47 @@ % \end{macro} % % \subsection{String comparisons} +% +% \begin{macro}[int, EXP]{\__str_if_eq_x:nn} +% \begin{macro}[aux, EXP]{\__str_escape_x:n} +% String comparisons rely on the primitive \cs{(pdf)strcmp} if available: +% \LuaTeX{} does not have it, so emulation is required. As the net result +% is that we do not \emph{always} use the primitive, the correct approach +% is to wrap up in a function with defined behaviour. That's done by +% providing a wrapper and then redefining in the \LuaTeX{} case. Note that +% the necessary Lua code is covered in \pkg{l3boostrap}: long-term this may +% need to go into a separate Lua file, but at present it's somewhere that +% spaces are not skipped for ease-of-input. The need to detokenize and force +% expansion of input arises from the case where a |#| token is used in the +% input, \emph{e.g.}~|\__str_if_eq_x:nn {#} { \tl_to_str:n {#} }|, which +% otherwise will fail as \cs{luatex_luaescapestring:D} does not double +% such tokens. +% \begin{macrocode} +\cs_new:Npn \__str_if_eq_x:nn #1#2 { \pdftex_strcmp:D {#1} {#2} } +\luatex_if_engine:T + { + \cs_set:Npn \__str_if_eq_x:nn #1#2 + { + \luatex_directlua:D + { + l3kernel.strcmp + ( + " \__str_escape_x:n {#1} " , + " \__str_escape_x:n {#2} " + ) + } + } + \cs_new:Npn \__str_escape_x:n #1 + { + \luatex_luaescapestring:D + { + \etex_detokenize:D \exp_after:wN { \luatex_expanded:D {#1} } + } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} % % \begin{macro}[pTF, EXP]{\str_if_eq:nn, \str_if_eq_x:nn} % Modern engines provide a direct way of comparing two token lists, @@ -3073,13 +3126,13 @@ % \begin{macrocode} \prg_new_conditional:Npnn \str_if_eq:nn #1#2 { p , T , F , TF } { - \if_int_compare:w \pdftex_strcmp:D { \exp_not:n {#1} } { \exp_not:n {#2} } + \if_int_compare:w \__str_if_eq_x:nn { \exp_not:n {#1} } { \exp_not:n {#2} } = \c_zero \prg_return_true: \else: \prg_return_false: \fi: } \prg_new_conditional:Npnn \str_if_eq_x:nn #1#2 { p , T , F , TF } { - \if_int_compare:w \pdftex_strcmp:D {#1} {#2} = \c_zero + \if_int_compare:w \__str_if_eq_x:nn {#1} {#2} = \c_zero \prg_return_true: \else: \prg_return_false: \fi: } % \end{macrocode} @@ -3093,7 +3146,7 @@ % \begin{macrocode} \cs_new:Npn \__str_if_eq_x_return:nn #1 #2 { - \if_int_compare:w \pdftex_strcmp:D {#1} {#2} = \c_zero + \if_int_compare:w \__str_if_eq_x:nn {#1} {#2} = \c_zero \prg_return_true: \else: \prg_return_false: |