summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3basics.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3basics.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3basics.dtx174
1 files changed, 69 insertions, 105 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3basics.dtx b/Master/texmf-dist/source/latex/expl3/l3basics.dtx
index 4bfc83ec33b..61d3170170e 100644
--- a/Master/texmf-dist/source/latex/expl3/l3basics.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3basics.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3basics.dtx Copyright (C) 1990-2008 LaTeX3 project
+%% File: l3basics.dtx Copyright (C) 1990-2008,2010 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3basics.dtx 1992 2010-08-04 20:41:40Z joseph $
+\GetIdInfo$Id: l3basics.dtx 2037 2010-09-20 21:22:45Z joseph $
{L3 Experimental basic definitions}
%\iffalse
%<*driver>
@@ -344,6 +344,41 @@
% This function checks that <cs> is defined. If it is not an error
% is generated.
% \end{function}
+%
+%\begin{function}{
+% \str_if_eq_p:nn / (EXP) |
+% \str_if_eq_p:Vn / (EXP) |
+% \str_if_eq_p:on / (EXP) |
+% \str_if_eq_p:no / (EXP) |
+% \str_if_eq_p:nV / (EXP) |
+% \str_if_eq_p:VV / (EXP) |
+% \str_if_eq_p:xx / (EXP) |
+% \str_if_eq:nn / (EXP) (TF) |
+% \str_if_eq:Vn / (EXP) (TF) |
+% \str_if_eq:on / (EXP) (TF) |
+% \str_if_eq:no / (EXP) (TF) |
+% \str_if_eq:nV / (EXP) (TF) |
+% \str_if_eq:VV / (EXP) (TF) |
+% \str_if_eq:xx / (EXP) (TF) |
+%}
+% \begin{syntax}
+% \cs{str_if_eq_p:nn} \Arg{tl1} \Arg{tl2}
+% \cs{str_if_eq:nnTF} \Arg{tl1} \Arg{tl2} \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:xx { abc } { \tl_to_str:n { abc } }
+% \end{verbatim}
+% is logically \texttt{true}. The branching versions then leave either
+% \meta{true code} or \meta{false code} in the input stream, as
+% appropriate to the truth of the test and the variant of the function
+% chosen. The logical truth of the test is left in the input stream by
+% the predicate version. All versions of these functions are fully
+% expandable (including those involving an \texttt{x}-type
+% expansion).
+%\end{function}
%
% \begin{variable}{ \c_true_bool | \c_false_bool }
% \begin{syntax}
@@ -352,25 +387,6 @@
% implement predicates.
% \end{variable}
%
-% \subsection{Applications}
-%
-% \begin{function}{ \str_if_eq_p:nn / (EXP) }
-% \begin{syntax}
-% "\str_if_eq_p:nn" \Arg{string1} \Arg{string2}
-% \end{syntax}
-% Expands to `true' if <string1> is the same as <string2>,
-% otherwise `false'. Ignores spaces within the strings.
-% \end{function}
-%
-% \begin{function}{ \str_if_eq_var_p:nf / (EXP) }
-% \begin{syntax}
-% "\str_if_eq_var_p:nf" \Arg{string1} \Arg{string2}
-% \end{syntax}
-% A variant of "\str_if_eq_p:nn" which has the advantage of
-% obeying spaces in at least the second argument.
-% \end{function}
-%
-%
% \section{Control sequences}
%
% \begin{function}{ \cs:w / (EXP) | \cs_end: / (EXP) }
@@ -2036,13 +2052,13 @@
% like this (again getting TeX to remove the leading space for us):
% \begin{macrocode}
\cs_set_nopar:Npn \cs_to_str:N {
- \if:w \exp_after:wN \cs_str_aux:w\token_to_str:N \a ax\q_nil
+ \if:w \exp_after:wN \cs_str_aux:w\token_to_str:N \a ax\q_stop
\else:
\exp_after:wN \exp_after:wN\exp_after:wN \use_ii:nn
\fi:
\exp_after:wN \use_none:n \token_to_str:N
}
-\cs_set:Npn \cs_str_aux:w #1#2#3#4\q_nil{#2#3}
+\cs_set:Npn \cs_str_aux:w #1#2#3#4\q_stop{#2#3}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2077,7 +2093,7 @@
% \begin{macrocode}
\cs_set:Npn \cs_split_function:NN #1#2{
\exp_after:wN \cs_split_function_aux:w
- \tex_romannumeral:D -`\q \cs_to_str:N #1 @a \q_nil #2
+ \tex_romannumeral:D -`\q \cs_to_str:N #1 @a \q_stop #2
}
% \end{macrocode}
% If no colon in the name, |#2| is |a| with catcode 11 and |#3| is
@@ -2088,16 +2104,16 @@
% We can't use |\quark_if_no_value:NTF| yet but this is very safe
% anyway as all tokens have catcode~12.
% \begin{macrocode}
-\cs_set:Npn \cs_split_function_aux:w #1@#2#3\q_nil#4{
+\cs_set:Npn \cs_split_function_aux:w #1@#2#3\q_stop#4{
\if_meaning:w a#2
\exp_after:wN \use_i:nn
\else:
\exp_after:wN\use_ii:nn
\fi:
{#4{#1}{}\c_false_bool}
- {\cs_split_function_auxii:w#2#3\q_nil #4{#1}}
+ {\cs_split_function_auxii:w#2#3\q_stop #4{#1}}
}
-\cs_set:Npn \cs_split_function_auxii:w #1@a\q_nil#2#3{
+\cs_set:Npn \cs_split_function_auxii:w #1@a\q_stop#2#3{
#2{#3}{#1}\c_true_bool
}
% \end{macrocode}
@@ -2187,7 +2203,7 @@
\cs_split_function:NN #1 \cs_if_do_not_use_aux:nnN
}
\cs_set:Npn \cs_if_do_not_use_aux:nnN #1#2#3{
- \exp_after:wN\str_if_eq_p:nn \token_to_str:N D {#2}
+ \str_if_eq_p:nn { D } {#2}
}
% \end{macrocode}
% \end{macro}
@@ -2377,95 +2393,43 @@
% \end{macro}
% \end{macro}
%
-%
-% \begin{macro}{\str_if_eq_p:nn}
-% \begin{macro}[aux]{\str_if_eq_p_aux:w}
-% Takes 2 lists of characters as arguments and expands into
-% |\c_true_bool| if they are equal, and |\c_false_bool| otherwise. Note that
-% in the current implementation spaces in these strings are
-% ignored.\footnote{This is a function which could use
-% \cs{tlist_compare:xx}.}
+%\begin{macro}{\str_if_eq_p:nn}
+%\begin{macro}[TF]{\str_if_eq:nn}
+%\begin{macro}{\str_if_eq_p:xx}
+%\begin{macro}[TF]{\str_if_eq:xx}
+% 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.
% \begin{macrocode}
-\prg_set_conditional:Npnn \str_if_eq:nn #1#2{p}{
- \str_if_eq_p_aux:w #1\scan_stop:\\#2\scan_stop:\\
+\prg_set_conditional:Npnn \str_if_eq:nn #1#2 { p , T , F , TF } {
+ \tex_ifnum:D \pdf_strcmp:D
+ { \etex_unexpanded:D {#1} } { \etex_unexpanded:D {#2} }
+ = \c_zero
+ \prg_return_true: \else: \prg_return_false: \fi:
+}
+\prg_set_conditional:Npnn \str_if_eq:xx #1#2 { p , T , F , TF } {
+ \tex_ifnum:D \pdf_strcmp:D {#1} {#2} = \c_zero
+ \prg_return_true: \else: \prg_return_false: \fi:
}
-\cs_set_nopar:Npn \str_if_eq_p_aux:w #1#2\\#3#4\\{
- \if_meaning:w#1#3
- \if_meaning:w#1\scan_stop:\prg_return_true: \else:
- \if_meaning:w#3\scan_stop:\prg_return_false: \else:
- \str_if_eq_p_aux:w #2\\#4\\\fi:\fi:
- \else:\prg_return_false: \fi:}
% \end{macrocode}
-% \end{macro}
-% \end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
% \begin{macro}{\cs_if_eq_name_p:NN}
% An application of the above function, already streamlined for
-% speed, so I put it in here. It takes two control sequences as
-% arguments and expands into true iff they have the same name.
-% We make it long in case one of them is |\par|!
+% speed, so I put it in here.
% \begin{macrocode}
\prg_set_conditional:Npnn \cs_if_eq_name:NN #1#2{p}{
- \exp_after:wN\exp_after:wN
- \exp_after:wN\str_if_eq_p_aux:w
- \exp_after:wN\token_to_str:N
- \exp_after:wN#1
- \exp_after:wN\scan_stop:
- \exp_after:wN\\
- \token_to_str:N#2\scan_stop:\\}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\str_if_eq_var_p:nf}
-% \begin{macro}[aux]{\str_if_eq_var_start:nnN}
-% \begin{macro}[aux]{\str_if_eq_var_stop:w}
-% A variant of |\str_if_eq_p:nn| which has the advantage of obeying
-% spaces in at least the second argument. See \textsf{l3quark} for
-% an application. From the hand of David Kastrup with slight
-% modifications to make it fit with the remainder of the expl3
-% language.
-%
-% The macro builds a string of |\if:w \fi:| pairs from the first
-% argument. The idea is to turn the comparison of |ab| and |cde|
-% into
-% \begin{verbatim}
-% \tex_number:D
-% \if:w \scan_stop: \if:w b\if:w a cde\scan_stop: '\fi: \fi: \fi:
-% 13
-% \end{verbatim}
-% The |'| is important here. If all tests are true, the |'| is read
-% as part of the number in which case the returned number is |13| in
-% octal notation so |\tex_number:D| returns |11|. If one test
-% returns false the |'| is never seen and then we get just |13|. We
-% wrap the whole process in an external |\if:w| in order to make it
-% return either |\c_true_bool| or |\c_false_bool| since some parts of
-% \textsf{l3prg} expect a predicate to return one of these two
-% tokens.
-% \begin{macrocode}
-\prg_set_conditional:Npnn \str_if_eq_var:nf #1#2 {p} {
- \if:w \tex_number:D\str_if_eq_var_start:nnN{}{}#1\scan_stop:{#2}
-}
-\cs_set_nopar:Npn\str_if_eq_var_start:nnN#1#2#3{
- \if:w#3\scan_stop:\exp_after:wN\str_if_eq_var_stop:w\fi:
- \str_if_eq_var_start:nnN{\if:w#3#1}{#2\fi:}
-}
-\cs_set:Npn\str_if_eq_var_stop:w\str_if_eq_var_start:nnN#1#2#3{
- #1#3\scan_stop:'#213~\prg_return_true:\else:\prg_return_false:\fi:
+ \str_if_eq_p:nn {#1} {#2}
}
% \end{macrocode}
% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
-%
%
% \subsection{More new definitions}
%
-%
-%
-%
% \begin{macro}{\cs_new_nopar:Npn}
% \begin{macro}{\cs_new_nopar:Npx}
% \begin{macro}{\cs_new:Npn}
@@ -2857,11 +2821,11 @@
\fi:
{
\exp_after:wN \cs_get_arg_count_from_signature_auxii:w
- \use_none:nnnnnnnnn #2 9876543210\q_nil
+ \use_none:nnnnnnnnn #2 9876543210\q_stop
}
{-1}
}
-\cs_set:Npn \cs_get_arg_count_from_signature_auxii:w #1#2\q_nil{#1}
+\cs_set:Npn \cs_get_arg_count_from_signature_auxii:w #1#2\q_stop{#1}
% \end{macrocode}
% A variant form we need right away.
% \begin{macrocode}