summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3skip.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3skip.dtx186
1 files changed, 100 insertions, 86 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx
index 3eb3eb8c901..1a9d70f8756 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
%% File: l3skip.dtx Copyright (C) 2004-2011 Frank Mittelbach, The LaTeX3 Project
-%% (C) 2012 The LaTeX3 Project
+%% (C) 2012,2013 The 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
@@ -36,7 +36,7 @@
%
%<*driver|package>
\RequirePackage{l3bootstrap}
-\GetIdInfo$Id: l3skip.dtx 4260 2012-11-04 17:20:25Z joseph $
+\GetIdInfo$Id: l3skip.dtx 4444 2013-01-13 20:27:20Z bruno $
{L3 Dimensions and skips}
%</driver|package>
%<*driver>
@@ -228,16 +228,37 @@
% \end{center}
% \end{function}
%
-% \begin{function}[EXP,pTF]{\dim_compare:n}
+% \begin{function}[updated = 2013-01-13, EXP, pTF]{\dim_compare:n}
% \begin{syntax}
-% \cs{dim_compare_p:n} \{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \} \\
+% \cs{dim_compare_p:n} \\
+% ~~\{ \\
+% ~~~~\meta{dimexpr_1} \meta{relation_1} \\
+% ~~~~\ldots{} \\
+% ~~~~\meta{dimexpr_N} \meta{relation_N} \\
+% ~~~~\meta{dimexpr_{N+1}} \\
+% ~~\} \\
% \cs{dim_compare:nTF}
-% ~~\{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \}
+% ~~\{ \\
+% ~~~~\meta{dimexpr_1} \meta{relation_1} \\
+% ~~~~\ldots{} \\
+% ~~~~\meta{dimexpr_N} \meta{relation_N} \\
+% ~~~~\meta{dimexpr_{N+1}} \\
+% ~~\} \\
% ~~\Arg{true code} \Arg{false code}
% \end{syntax}
-% This function first evaluates each of the \meta{dimension expressions}
-% as described for \cs{dim_eval:n}. The two results are then
-% compared using the \meta{relation}:
+% This function evaluates the \meta{dimension expressions} as
+% described for \cs{dim_eval:n} and compares consecutive result using
+% the corresponding \meta{relation}, namely it compares
+% \meta{dimexpr_1} and \meta{dimexpr_2} using the \meta{relation_1},
+% then \meta{dimexpr_2} and \meta{dimexpr_3} using the
+% \meta{relation_2}, until finally comparing \meta{dimexpr_N} and
+% \meta{dimexpr_{N+1}} using the \meta{relation_N}. The test yields
+% \texttt{true} if all comparisons are \texttt{true}. Each
+% \meta{dimension expression} is evaluated only once, and the
+% evaluation is lazy, in the sense that if one comparison is
+% \texttt{false}, then no other \meta{dimension expression} is
+% evaluated and no other comparison is performed. The
+% \meta{relations} can be any of the following:
% \begin{center}
% \begin{tabular}{ll}
% Equal & |=| or |==| \\
@@ -331,35 +352,35 @@
% \texttt{false}.
% \end{function}
%
-% \begin{function}[rEXP]{\dim_do_until:nn}
+% \begin{function}[updated = 2013-01-13, rEXP]{\dim_do_until:nn}
% \begin{syntax}
-% \cs{dim_do_until:nn} \{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \} \Arg{code}
+% \cs{dim_do_until:nn} \Arg{dimension relation} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process, and
-% then evaluates the relationship between the two
-% \meta{dimension expressions} as described for \cs{dim_compare:nTF}.
+% then evaluates the \meta{dimension relation}
+% as described for \cs{dim_compare:nTF}.
% If the test is \texttt{false} then the \meta{code} will be inserted
% into the input stream again and a loop will occur until the
% \meta{relation} is \texttt{true}.
% \end{function}
%
-% \begin{function}[rEXP]{\dim_do_while:nn}
+% \begin{function}[updated = 2013-01-13, rEXP]{\dim_do_while:nn}
% \begin{syntax}
-% \cs{dim_do_while:nn} \{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \} \Arg{code}
+% \cs{dim_do_while:nn} \Arg{dimension relation} \Arg{code}
% \end{syntax}
% Places the \meta{code} in the input stream for \TeX{} to process, and
-% then evaluates the relationship between the two
-% \meta{dimension expressions} as described for \cs{dim_compare:nTF}.
+% then evaluates the \meta{dimension relation}
+% as described for \cs{dim_compare:nTF}.
% If the test is \texttt{true} then the \meta{code} will be inserted
% into the input stream again and a loop will occur until the
% \meta{relation} is \texttt{false}.
% \end{function}
%
-% \begin{function}[rEXP]{\dim_until_do:nn}
+% \begin{function}[updated = 2013-01-13, rEXP]{\dim_until_do:nn}
% \begin{syntax}
-% \cs{dim_until_do:nn} \{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \} \Arg{code}
+% \cs{dim_until_do:nn} \Arg{dimension relation} \Arg{code}
% \end{syntax}
-% Evaluates the relationship between the two \meta{dimension expressions}
+% Evaluates the \meta{dimension relation}
% as described for \cs{dim_compare:nTF}, and then places the
% \meta{code} in the input stream if the \meta{relation} is
% \texttt{false}. After the \meta{code} has been processed by \TeX{} the
@@ -367,11 +388,11 @@
% \texttt{true}.
% \end{function}
%
-% \begin{function}[rEXP]{\dim_while_do:nn}
+% \begin{function}[updated = 2013-01-13, rEXP]{\dim_while_do:nn}
% \begin{syntax}
-% \cs{dim_while_do:nn} \{ \meta{dimexpr_1} \meta{relation} \meta{dimexpr_2} \} \Arg{code}
+% \cs{dim_while_do:nn} \Arg{dimension relation} \Arg{code}
% \end{syntax}
-% Evaluates the relationship between the two \meta{dimension expressions}
+% Evaluates the \meta{dimension relation}
% as described for \cs{dim_compare:nTF}, and then places the
% \meta{code} in the input stream if the \meta{relation} is
% \texttt{true}. After the \meta{code} has been processed by \TeX{} the
@@ -991,14 +1012,8 @@
% \begin{macro}[pTF]{\dim_if_exist:N, \dim_if_exist:c}
% Copies of the \texttt{cs} functions defined in \pkg{l3basics}.
% \begin{macrocode}
-\cs_new_eq:NN \dim_if_exist:NTF \cs_if_exist:NTF
-\cs_new_eq:NN \dim_if_exist:NT \cs_if_exist:NT
-\cs_new_eq:NN \dim_if_exist:NF \cs_if_exist:NF
-\cs_new_eq:NN \dim_if_exist_p:N \cs_if_exist_p:N
-\cs_new_eq:NN \dim_if_exist:cTF \cs_if_exist:cTF
-\cs_new_eq:NN \dim_if_exist:cT \cs_if_exist:cT
-\cs_new_eq:NN \dim_if_exist:cF \cs_if_exist:cF
-\cs_new_eq:NN \dim_if_exist_p:c \cs_if_exist_p:c
+\prg_new_eq_conditional:NNn \dim_if_exist:N \cs_if_exist:N { TF , T , F , p }
+\prg_new_eq_conditional:NNn \dim_if_exist:c \cs_if_exist:c { TF , T , F , p }
% \end{macrocode}
% \end{macro}
%
@@ -1134,58 +1149,61 @@
% \end{macro}
%
% \begin{macro}[pTF, EXP]{\dim_compare:n}
-% \begin{macro}[aux, EXP]{\@@_compare_aux:w, \@@_compare_aux:NNw}
+% \begin{macro}[aux, EXP]{\@@_compare:w, \@@_compare:wNN}
% \begin{macro}[aux, EXP]
% {
-% \@@_compare_=:NNw,
-% \@@_compare_<:NNw,
-% \@@_compare_>:NNw,
-% \@@_compare_==:NNw,
-% \@@_compare_!=:NNw,
-% \@@_compare_<=:NNw,
-% \@@_compare_>=:NNw
+% \@@_compare_=:w,
+% \@@_compare_!:w,
+% \@@_compare_<:w,
+% \@@_compare_>:w
% }
% This code is adapted from the \cs{int_compare:nTF} function. First
-% evaluate the left-hand side. Then access the relation symbol by
-% grabbing until \texttt{pt} (with category other), and pursue
-% otherwise just as for \cs{int_compare:nTF}.
+% make sure that there is at least one relation operator, by
+% evaluating a dimension expression with a trailing
+% \cs{__prg_compare_error:}. Just like for integers, the looping
+% auxiliary \cs{@@_compare:wNN} closes a primitive conditional and
+% opens a new one. It is actually easier to grab a dimension operand
+% than an integer one, because once evaluated, dimensions all end with
+% \texttt{pt} (with category other). Thus we do not need specific
+% auxiliaries for the three \enquote{simple} relations |<|, |=|,
+% and~|>|.
% \begin{macrocode}
\prg_new_conditional:Npnn \dim_compare:n #1 { p , T , F , TF }
{
- \exp_after:wN \@@_compare_aux:w \dim_use:N \@@_eval:w #1
- \__prg_compare_error: \@@_eval_end:
- \prg_return_true:
- \else:
- \prg_return_false:
- \fi:
+ \exp_after:wN \@@_compare:w
+ \dim_use:N \@@_eval:w #1 \__prg_compare_error:
}
-\exp_args:Nno \use:nn
- { \cs_new:Npn \@@_compare_aux:w #1 }
- { \tl_to_str:n { pt } }
- #2 \__prg_compare_error:
+\cs_new:Npn \@@_compare:w #1 \__prg_compare_error:
{
- \exp_after:wN \@@_compare_aux:NNw #2 ?? \q_mark
- #1 pt #2
+ \exp_after:wN \if_false: \tex_romannumeral:D -`0
+ \@@_compare:wNN #1 ? { = \@@_compare_end:w \else: } \q_stop
}
-\cs_new:Npn \@@_compare_aux:NNw #1#2#3 \q_mark
+\exp_args:Nno \use:nn
+ { \cs_new:Npn \@@_compare:wNN #1 }
+ { \tl_to_str:n {pt} }
+ #2#3
{
- \use:c { @@_compare_ #1 \if_meaning:w = #2 = \fi: :NNw }
- \__prg_compare_error:Nw #1
+ \if_meaning:w = #3
+ \use:c { @@_compare_#2:w }
+ \fi:
+ #1 pt \exp_stop_f:
+ \prg_return_false:
+ \exp_after:wN \use_none_delimit_by_q_stop:w
+ \fi:
+ \reverse_if:N \if_dim:w #1 pt #2
+ \exp_after:wN \@@_compare:wNN
+ \dim_use:N \@@_eval:w #3
}
-\cs_new:cpn { @@_compare_=:NNw } #1#2#3 =
- { \if_dim:w #3 = \@@_eval:w }
-\cs_new:cpn { @@_compare_<:NNw } #1#2#3 <
- { \if_dim:w #3 < \@@_eval:w }
-\cs_new:cpn { @@_compare_>:NNw } #1#2#3 >
- { \if_dim:w #3 > \@@_eval:w }
-\cs_new:cpn { @@_compare_==:NNw } #1#2#3 ==
- { \if_dim:w #3 = \@@_eval:w }
-\cs_new:cpn { @@_compare_!=:NNw } #1#2#3 !=
- { \reverse_if:N \if_dim:w #3 = \@@_eval:w }
-\cs_new:cpn { @@_compare_<=:NNw } #1#2#3 <=
- { \reverse_if:N \if_dim:w #3 > \@@_eval:w }
-\cs_new:cpn { @@_compare_>=:NNw } #1#2#3 >=
- { \reverse_if:N \if_dim:w #3 < \@@_eval:w }
+\cs_new:cpn { @@_compare_ ! :w }
+ #1 \reverse_if:N #2 ! #3 = { #1 #2 = #3 }
+\cs_new:cpn { @@_compare_ = :w }
+ #1 \@@_eval:w = { #1 \@@_eval:w }
+\cs_new:cpn { @@_compare_ < :w }
+ #1 \reverse_if:N #2 < #3 = { #1 #2 > #3 }
+\cs_new:cpn { @@_compare_ > :w }
+ #1 \reverse_if:N #2 > #3 = { #1 #2 < #3 }
+\cs_new:Npn \@@_compare_end:w #1 \prg_return_false: #2 \q_stop
+ { #1 \prg_return_false: \else: \prg_return_true: \fi: }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1454,14 +1472,8 @@
% \begin{macro}[pTF]{\skip_if_exist:N, \skip_if_exist:c}
% Copies of the \texttt{cs} functions defined in \pkg{l3basics}.
% \begin{macrocode}
-\cs_new_eq:NN \skip_if_exist:NTF \cs_if_exist:NTF
-\cs_new_eq:NN \skip_if_exist:NT \cs_if_exist:NT
-\cs_new_eq:NN \skip_if_exist:NF \cs_if_exist:NF
-\cs_new_eq:NN \skip_if_exist_p:N \cs_if_exist_p:N
-\cs_new_eq:NN \skip_if_exist:cTF \cs_if_exist:cTF
-\cs_new_eq:NN \skip_if_exist:cT \cs_if_exist:cT
-\cs_new_eq:NN \skip_if_exist:cF \cs_if_exist:cF
-\cs_new_eq:NN \skip_if_exist_p:c \cs_if_exist_p:c
+\prg_new_eq_conditional:NNn \skip_if_exist:N \cs_if_exist:N { TF , T , F , p }
+\prg_new_eq_conditional:NNn \skip_if_exist:c \cs_if_exist:c { TF , T , F , p }
% \end{macrocode}
% \end{macro}
%
@@ -1705,14 +1717,8 @@
% \begin{macro}[pTF]{\muskip_if_exist:N, \muskip_if_exist:c}
% Copies of the \texttt{cs} functions defined in \pkg{l3basics}.
% \begin{macrocode}
-\cs_new_eq:NN \muskip_if_exist:NTF \cs_if_exist:NTF
-\cs_new_eq:NN \muskip_if_exist:NT \cs_if_exist:NT
-\cs_new_eq:NN \muskip_if_exist:NF \cs_if_exist:NF
-\cs_new_eq:NN \muskip_if_exist_p:N \cs_if_exist_p:N
-\cs_new_eq:NN \muskip_if_exist:cTF \cs_if_exist:cTF
-\cs_new_eq:NN \muskip_if_exist:cT \cs_if_exist:cT
-\cs_new_eq:NN \muskip_if_exist:cF \cs_if_exist:cF
-\cs_new_eq:NN \muskip_if_exist_p:c \cs_if_exist_p:c
+\prg_new_eq_conditional:NNn \muskip_if_exist:N \cs_if_exist:N { TF , T , F , p }
+\prg_new_eq_conditional:NNn \muskip_if_exist:c \cs_if_exist:c { TF , T , F , p }
% \end{macrocode}
% \end{macro}
%
@@ -1847,8 +1853,10 @@
% \begin{macro}[EXP, pTF]{\skip_if_infinite_glue:n}
% Reverse of \cs{skip_if_finite:nTF}.
% \begin{macrocode}
+%<*deprecated>
\prg_new_conditional:Npnn \skip_if_infinite_glue:n #1 { p , T , F , TF }
{ \skip_if_finite:nTF {#1} \prg_return_false: \prg_return_true: }
+%</deprecated>
% \end{macrocode}
% \end{macro}
%
@@ -1858,14 +1866,18 @@
% Moved here, was in \pkg{l3prg} but load order means we define it here
% now.
% \begin{macrocode}
+%<*deprecated>
\cs_new_eq:NN \prg_case_dim:nnn \dim_case:nnn
+%</deprecated>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dim_eval:w, \dim_eval_end:}
% \begin{macrocode}
+%<*deprecated>
\cs_new_eq:NN \dim_eval:w \__dim_eval:w
\cs_new_eq:NN \dim_eval_end: \__dim_eval_end:
+%</deprecated>
% \end{macrocode}
% \end{macro}
%
@@ -1876,6 +1888,7 @@
% \begin{macro}[aux]{\@@_set_max:NNNn}
% Deprecated on 2012-09-09 for removal after 2012-12-31.
% \begin{macrocode}
+%<*deprecated>
\cs_new_protected_nopar:Npn \dim_set_max:Nn
{ \@@_set_max:NNNn < \dim_set:Nn }
\cs_new_protected_nopar:Npn \dim_gset_max:Nn
@@ -1890,6 +1903,7 @@
\cs_generate_variant:Nn \dim_gset_max:Nn { c }
\cs_generate_variant:Nn \dim_set_min:Nn { c }
\cs_generate_variant:Nn \dim_gset_min:Nn { c }
+%</deprecated>
% \end{macrocode}
% \end{macro}
% \end{macro}