diff options
author | Karl Berry <karl@freefriends.org> | 2014-07-20 22:14:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-07-20 22:14:30 +0000 |
commit | 6c2678db440b5260ec13602bde6efebdd00f8549 (patch) | |
tree | ed93fc7244f4e5ef1baf86ccb157597dabf6ac1e /Master/texmf-dist/source/latex/l3kernel/l3basics.dtx | |
parent | 9790eead4cceaffc951c93887d06de70c02e196a (diff) |
l3
git-svn-id: svn://tug.org/texlive/trunk@34671 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3basics.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3basics.dtx | 291 |
1 files changed, 2 insertions, 289 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx index 339eb9eacb1..b36707ccc97 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 5033 2014-06-04 05:32:44Z joseph $ +\GetIdInfo$Id: l3basics.dtx 5187 2014-07-09 12:02:17Z will $ {L3 Basic definitions} %</driver|package> %<*driver> @@ -743,7 +743,7 @@ % \end{verbatim} % after two expansions of \cs{use:c}. % -% \begin{function}[TF, added = 2012-11-10] +% \begin{function}[EXP,added = 2012-11-10] % {\cs_if_exist_use:N,\cs_if_exist_use:c} % \begin{syntax} % \cs{cs_if_exist_use:N} \meta{control sequence} @@ -1088,89 +1088,6 @@ % \cs{cs_if_exist:N}). % \end{function} % -% \subsection{Testing string equality} -% -% \begin{function}[EXP,pTF] -% { -% \str_if_eq:nn, \str_if_eq:Vn, \str_if_eq:on, \str_if_eq:no, -% \str_if_eq:nV, \str_if_eq:VV -% } -% \begin{syntax} -% \cs{str_if_eq_p:nn} \Arg{tl_1} \Arg{tl_2} -% \cs{str_if_eq:nnTF} \Arg{tl_1} \Arg{tl_2} \Arg{true code} \Arg{false code} -% \end{syntax} -% Compares the 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. Thus for example -% \begin{verbatim} -% \str_if_eq_p:no { abc } { \tl_to_str:n { abc } } -% \end{verbatim} -% is logically \texttt{true}. -% \end{function} -% -% \begin{function}[EXP,pTF, added = 2012-06-05]{\str_if_eq_x:nn} -% \begin{syntax} -% \cs{str_if_eq_x_p:nn} \Arg{tl_1} \Arg{tl_2} -% \cs{str_if_eq_x:nnTF} \Arg{tl_1} \Arg{tl_2} \Arg{true code} \Arg{false code} -% \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. Thus for example -% \begin{verbatim} -% \str_if_eq_x_p:nn { abc } { \tl_to_str:n { abc } } -% \end{verbatim} -% is logically \texttt{true}. -% \end{function} -% -% \begin{function}[added = 2013-07-24, EXP, TF]{\str_case:nn, \str_case:on} -% \begin{syntax} -% \cs{str_case:nnTF} \Arg{test string} \\ -% ~~|{| \\ -% ~~~~\Arg{string case_1} \Arg{code case_1} \\ -% ~~~~\Arg{string case_2} \Arg{code case_2} \\ -% ~~~~\ldots \\ -% ~~~~\Arg{string case_n} \Arg{code case_n} \\ -% ~~|}| \\ -% ~~\Arg{true code} -% ~~\Arg{false code} -% \end{syntax} -% This function compares the \meta{test string} in turn with each -% of the \meta{string cases}. If the two are equal (as described for -% \cs{str_if_eq:nnTF} then the -% associated \meta{code} is left in the input stream. If any of the -% cases are matched, the \meta{true code} is also inserted into the -% input stream (after the code for the appropriate case), while if none -% match then the \meta{false code} is inserted. The function -% \cs{str_case:nn}, which does nothing if there is no match, is also -% available. -% \end{function} -% -% \begin{function}[added = 2013-07-24, EXP, TF]{\str_case_x:nn} -% \begin{syntax} -% \cs{str_case_x:nnn} \Arg{test string} \\ -% ~~|{| \\ -% ~~~~\Arg{string case_1} \Arg{code case_1} \\ -% ~~~~\Arg{string case_2} \Arg{code case_2} \\ -% ~~~~\ldots \\ -% ~~~~\Arg{string case_n} \Arg{code case_n} \\ -% ~~|}| \\ -% ~~\Arg{true code} -% ~~\Arg{false code} -% \end{syntax} -% This function compares the full expansion of the \meta{test string} -% in turn with the full expansion of the \meta{string cases}. If the two -% full expansions are equal (as described for \cs{str_if_eq:nnTF} then the -% associated \meta{code} is left in the input stream. If any of the -% cases are matched, the \meta{true code} is also inserted into the -% input stream (after the code for the appropriate case), while if none -% match then the \meta{false code} is inserted. The function -% \cs{str_case_x:nn}, which does nothing if there is no match, is also -% available. -% The \meta{test string} is expanded in each comparison, and must -% always yield the same result: for example, random numbers must -% not be used within this string. -% \end{function} -% % \subsection{Engine-specific conditionals} % % \begin{function}[updated = 2011-09-06,EXP,pTF]{\luatex_if_engine:} @@ -1377,27 +1294,6 @@ % 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}[EXP]{\__str_if_eq_x_return:nn} -% \begin{syntax} -% \cs{__str_if_eq_x_return: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. Either \cs{prg_return_true:} or -% \cs{prg_return_false:} is then left in the input stream. This is a version -% of \cs{str_if_eq_x:nn(TF)} coded for speed. -% \end{function} % % \end{documentation} % @@ -3074,179 +2970,6 @@ % \end{macrocode} % \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, -% but returning a number. This set of conditionals therefore make life -% a bit clearer. The \texttt{nn} and \texttt{xx} versions are created -% directly as this is most efficient. These should eventually -% move somewhere else. -% \begin{macrocode} -\prg_new_conditional:Npnn \str_if_eq:nn #1#2 { p , T , F , TF } - { - \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 \__str_if_eq_x:nn {#1} {#2} = \c_zero - \prg_return_true: \else: \prg_return_false: \fi: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int, EXP]{\__str_if_eq_x_return:nn} -% It turns out that we often need to compare a token list -% with the result of applying some function to it, and -% return with \cs{prg_return_true/false:}. This test is -% similar to \cs{str_if_eq:nnTF}, but hard-coded for speed. -% \begin{macrocode} -\cs_new:Npn \__str_if_eq_x_return:nn #1 #2 - { - \if_int_compare:w \__str_if_eq_x:nn {#1} {#2} = \c_zero - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[EXP]{\str_case:nn, \str_case_x:nn} -% \begin{macro}[EXP, TF]{\str_case:nn, \str_case_x:nn} -% \begin{macro}[EXP, aux]{\__str_case:nnTF, \__str_case_x:nnTF} -% \begin{macro}[int, EXP]{\__prg_case_end:nw} -% \begin{macro}[aux, EXP] -% {\__str_case:nw, \__str_case_x:nw, \__str_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 -% needing to use an explicit \enquote{end of recursion} marker. -% That is achieved by using the test input as the final case, -% as this will always be true. The trick is then to tidy up -% the output such that the appropriate case code plus either -% the \texttt{true} or \texttt{false} branch code is inserted. -% \begin{macrocode} -\cs_new:Npn \str_case:nn #1#2 - { - \tex_romannumeral:D - \__str_case:nnTF {#1} {#2} { } { } - } -\cs_new:Npn \str_case:nnT #1#2#3 - { - \tex_romannumeral:D - \__str_case:nnTF {#1} {#2} {#3} { } - } -\cs_new:Npn \str_case:nnF #1#2 - { - \tex_romannumeral:D - \__str_case:nnTF {#1} {#2} { } - } -\cs_new:Npn \str_case:nnTF #1#2 - { - \tex_romannumeral:D - \__str_case:nnTF {#1} {#2} - } -\cs_new:Npn \__str_case:nnTF #1#2#3#4 - { \__str_case:nw {#1} #2 {#1} { } \q_mark {#3} \q_mark {#4} \q_stop } -\cs_new:Npn \__str_case:nw #1#2#3 - { - \str_if_eq:nnTF {#1} {#2} - { \__str_case_end:nw {#3} } - { \__str_case:nw {#1} } - } -\cs_new:Npn \str_case_x:nn #1#2 - { - \tex_romannumeral:D - \__str_case_x:nnTF {#1} {#2} { } { } - } -\cs_new:Npn \str_case_x:nnT #1#2#3 - { - \tex_romannumeral:D - \__str_case_x:nnTF {#1} {#2} {#3} { } - } -\cs_new:Npn \str_case_x:nnF #1#2 - { - \tex_romannumeral:D - \__str_case_x:nnTF {#1} {#2} { } - } -\cs_new:Npn \str_case_x:nnTF #1#2 - { - \tex_romannumeral:D - \__str_case_x:nnTF {#1} {#2} - } -\cs_new:Npn \__str_case_x:nnTF #1#2#3#4 - { \__str_case_x:nw {#1} #2 {#1} { } \q_mark {#3} \q_mark {#4} \q_stop } -\cs_new:Npn \__str_case_x:nw #1#2#3 - { - \str_if_eq_x:nnTF {#1} {#2} - { \__str_case_end:nw {#3} } - { \__str_case_x:nw {#1} } - } -% \end{macrocode} -% To tidy up the recursion, there are two outcomes. If there was a hit to -% one of the cases searched for, then |#1| will be the code to insert, -% |#2| will be the \emph{next} case to check on and |#3| will be all of -% the rest of the cases code. That means that |#4| will be the \texttt{true} -% branch code, and |#5| will be tidy up the spare \cs{q_mark} and the -% \texttt{false} branch. On the other hand, if none of the cases matched -% then we arrive here using the \enquote{termination} case of comparing -% the search with itself. That means that |#1| will be empty, |#2| will be -% the first \cs{q_mark} and so |#4| will be 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 - { \c_zero #1 #4 } -\cs_new_eq:NN \__str_case_end:nw \__prg_case_end:nw -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% % \subsection{Breaking out of mapping functions} % % \begin{macro}[EXP]{\__prg_break_point:Nn, \__prg_map_break:Nn} @@ -3285,16 +3008,6 @@ % \end{macro} % \end{macro} % -% \subsection{Deprecated functions} -% -% \begin{macro}{\str_case:nnn, \str_case_x:nnn} -% Deprecated 2013-07-15. -% \begin{macrocode} -\cs_new_eq:NN \str_case:nnn \str_case:nnF -\cs_new_eq:NN \str_case_x:nnn \str_case_x:nnF -% \end{macrocode} -% \end{macro} -% % \begin{macrocode} %</initex|package> % \end{macrocode} |