diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3skip.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3skip.dtx | 192 |
1 files changed, 37 insertions, 155 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx index 108a54eb12f..da8a06f38bd 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2019-09-19} +% \date{Released 2019-09-28} % % \maketitle % @@ -457,6 +457,14 @@ % an \meta{internal dimension}. % \end{function} % +% \begin{function}[EXP, added = 2018-11-03]{\dim_sign:n} +% \begin{syntax} +% \cs{dim_sign:n} \Arg{dimexpr} +% \end{syntax} +% Evaluates the \meta{dimexpr} then leaves $1$ or $0$ or $-1$ in the +% input stream according to the sign of the result. +% \end{function} +% % \begin{function}[EXP]{\dim_use:N, \dim_use:c} % \begin{syntax} % \cs{dim_use:N} \meta{dimension} @@ -1103,7 +1111,6 @@ % \cs{dim_eval:n} to avoid needing a debugging patch that wraps the % expression in checking code. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_scope:NN c #1 } { } \cs_new_protected:Npn \dim_const:Nn #1#2 { \dim_new:N #1 @@ -1119,9 +1126,7 @@ % case where the variable passed is incorrectly a skip (for example a % \LaTeXe{} length). % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_local:N #1 } { } \cs_new_protected:Npn \dim_zero:N #1 { #1 \c_zero_skip } -\__kernel_patch:nnNNpn { \__kernel_chk_var_global:N #1 } { } \cs_new_protected:Npn \dim_gzero:N #1 { \tex_global:D #1 \c_zero_skip } \cs_generate_variant:Nn \dim_zero:N { c } @@ -1155,22 +1160,6 @@ % % \subsection{Setting \texttt{dim} variables} % -% Several functions here have a signature |:Nn| and are such that when -% debugging, the first argument should be checked to be a local/global -% variable and the second should be wrapped in code for an expression. -% The temporary function \cs{@@_tmp:w} finds the name |#3| of the -% function being redefined and writes the appropriate patch. -% \begin{macrocode} -\cs_set_protected:Npn \@@_tmp:w #1#2#3 - { - \__kernel_patch_args:nnnNNpn - { #1 ##1 } - { } - { {##1} { \__kernel_chk_expr:nNnN {##2} \@@_eval:w { } #3 } } - #2 #3 - } -% \end{macrocode} -% % \begin{macro}{\dim_set:Nn, \dim_set:cn} % \begin{macro}{\dim_gset:Nn, \dim_gset:cn} % Setting dimensions is easy enough but when debugging we want both to @@ -1179,10 +1168,8 @@ % where the variable passed is a skip (for example a \LaTeXe{} % length). % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \dim_set:Nn #1#2 { #1 ~ \@@_eval:w #2 \@@_eval_end: \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \dim_gset:Nn #1#2 { \tex_global:D #1 ~ \@@_eval:w #2 \@@_eval_end: \scan_stop: } \cs_generate_variant:Nn \dim_set:Nn { c } @@ -1197,11 +1184,9 @@ % All straightforward, with a \cs{scan_stop:} to deal with the case % where |#1| is (incorrectly) a skip. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_local:N #1 } { } \cs_new_protected:Npn \dim_set_eq:NN #1#2 { #1 = #2 \scan_stop: } \cs_generate_variant:Nn \dim_set_eq:NN { c , Nc , cc } -\__kernel_patch:nnNNpn { \__kernel_chk_var_global:N #1 } { } \cs_new_protected:Npn \dim_gset_eq:NN #1#2 { \tex_global:D #1 = #2 \scan_stop: } \cs_generate_variant:Nn \dim_gset_eq:NN { c , Nc , cc } @@ -1220,10 +1205,8 @@ % the local versions. The debugging code is inserted by % \cs{@@_tmp:w}. % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \dim_add:Nn #1#2 { \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \dim_gadd:Nn #1#2 { \tex_global:D \tex_advance:D #1 by @@ -1231,10 +1214,8 @@ } \cs_generate_variant:Nn \dim_add:Nn { c } \cs_generate_variant:Nn \dim_gadd:Nn { c } -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \dim_sub:Nn #1#2 { \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \dim_gsub:Nn #1#2 { \tex_global:D \tex_advance:D #1 by @@ -1261,8 +1242,6 @@ % Functions for $\min$, $\max$, and absolute value with only one evaluation. % The absolute value is evaluated by removing a leading~|-| if present. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_abs:n } } \cs_new:Npn \dim_abs:n #1 { \exp_after:wN \@@_abs:N @@ -1270,11 +1249,6 @@ } \cs_new:Npn \@@_abs:N #1 { \if_meaning:w - #1 \else: \exp_after:wN #1 \fi: } -\__kernel_patch_args:nNNpn - { - { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_max:nn } - { \__kernel_chk_expr:nNnN {#2} \@@_eval:w { } \dim_max:nn } - } \cs_new:Npn \dim_max:nn #1#2 { \dim_use:N \@@_eval:w \exp_after:wN \@@_maxmin:wwN @@ -1283,11 +1257,6 @@ > \@@_eval_end: } -\__kernel_patch_args:nNNpn - { - { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_min:nn } - { \__kernel_chk_expr:nNnN {#2} \@@_eval:w { } \dim_min:nn } - } \cs_new:Npn \dim_min:nn #1#2 { \dim_use:N \@@_eval:w \exp_after:wN \@@_maxmin:wwN @@ -1331,12 +1300,6 @@ % \begin{macro}[pTF, EXP]{\dim_compare:nNn} % Simple comparison. % \begin{macrocode} -\__kernel_patch_conditional_args:nNNpnn - { - { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_compare:nNn } - { \@@_eval_end: #2 } - { \__kernel_chk_expr:nNnN {#3} \@@_eval:w { } \dim_compare:nNn } - } \prg_new_conditional:Npnn \dim_compare:nNn #1#2#3 { p , T , F , TF } { \if_dim:w \@@_eval:w #1 #2 \@@_eval:w #3 \@@_eval_end: @@ -1549,21 +1512,6 @@ % step size of zero before checking the sign, but we optimize for the % most frequent case (positive step). % \begin{macrocode} -\__kernel_patch_args:nNNpn - { - { - \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } - \dim_step_function:nnnN - } - { - \__kernel_chk_expr:nNnN {#2} \@@_eval:w { } - \dim_step_function:nnnN - } - { - \__kernel_chk_expr:nNnN {#3} \@@_eval:w { } - \dim_step_function:nnnN - } - } \cs_new:Npn \dim_step_function:nnnN #1#2#3 { \exp_after:wN \@@_step:wwwN @@ -1645,13 +1593,39 @@ % \begin{macro}{\dim_eval:n} % Evaluating a dimension expression expandably. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_eval:n } } \cs_new:Npn \dim_eval:n #1 { \dim_use:N \@@_eval:w #1 \@@_eval_end: } % \end{macrocode} % \end{macro} % +% \begin{macro}[EXP]{\dim_sign:n, \@@_sign:Nw} +% See \cs{dim_abs:n}. Contrarily to \cs{int_sign:n} the case of a +% zero dimension cannot be distinguished from a positive dimension by +% looking only at the first character, since |0.2pt| and |0pt| start +% the same way. We need explicit comparisons. We start by +% distinguishing the most common case of a positive dimension. +% \begin{macrocode} +\cs_new:Npn \dim_sign:n #1 + { + \int_value:w \exp_after:wN \@@_sign:Nw + \dim_use:N \@@_eval:w #1 \@@_eval_end: ; + \exp_stop_f: + } +\cs_new:Npn \@@_sign:Nw #1#2 ; + { + \if_dim:w #1#2 > \c_zero_dim + 1 + \else: + \if_meaning:w - #1 + -1 + \else: + 0 + \fi: + \fi: + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\dim_use:N, \dim_use:c} % Accessing a \meta{dim}. % \begin{macrocode} @@ -1673,8 +1647,6 @@ % terminating early and leaving extra tokens lying around. This is % used a lot by low-level manipulations. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \dim_to_decimal:n } } \cs_new:Npn \dim_to_decimal:n #1 { \exp_after:wN @@ -1709,13 +1681,6 @@ % Another hard-coded conversion: this one is necessary to avoid things going % off-scale. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { - { - \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } - \dim_to_decimal_in_sp:n - } - } \cs_new:Npn \dim_to_decimal_in_sp:n #1 { \int_value:w \@@_eval:w #1 \@@_eval_end: } % \end{macrocode} @@ -1820,7 +1785,6 @@ % even for constants. See \cs{dim_const:Nn} for why we cannot use % \cs{skip_gset:Nn}. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_scope:NN c #1 } { } \cs_new_protected:Npn \skip_const:Nn #1#2 { \skip_new:N #1 @@ -1834,9 +1798,7 @@ % \begin{macro}{\skip_gzero:N, \skip_gzero:c} % Reset the register to zero. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_local:N #1 } { } \cs_new_protected:Npn \skip_zero:N #1 { #1 \c_zero_skip } -\__kernel_patch:nnNNpn { \__kernel_chk_var_global:N #1 } { } \cs_new_protected:Npn \skip_gzero:N #1 { \tex_global:D #1 \c_zero_skip } \cs_generate_variant:Nn \skip_zero:N { c } \cs_generate_variant:Nn \skip_gzero:N { c } @@ -1869,29 +1831,12 @@ % % \subsection{Setting \texttt{skip} variables} % -% Much as for \texttt{dim} variables, \cs{@@_tmp:w} prepares a patch -% for |:Nn| function definitions in which the first argument should be -% checked to be a local/global variable and the second should be wrapped -% in code for an expression. -% \begin{macrocode} -\cs_set_protected:Npn \@@_tmp:w #1#2#3 - { - \__kernel_patch_args:nnnNNpn - { #1 ##1 } - { } - { {##1} { \__kernel_chk_expr:nNnN {##2} \tex_glueexpr:D { } #3 } } - #2 #3 - } -% \end{macrocode} -% % \begin{macro}{\skip_set:Nn, \skip_set:cn} % \begin{macro}{\skip_gset:Nn, \skip_gset:cn} % Much the same as for dimensions. % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \skip_set:Nn #1#2 { #1 ~ \tex_glueexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \skip_gset:Nn #1#2 { \tex_global:D #1 ~ \tex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_set:Nn { c } @@ -1920,18 +1865,14 @@ % \begin{macro}{\skip_gsub:Nn, \skip_gsub:cn} % Using |by| here deals with the (incorrect) case |\skip123|. % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \skip_add:Nn #1#2 { \tex_advance:D #1 by \tex_glueexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \skip_gadd:Nn #1#2 { \tex_global:D \tex_advance:D #1 by \tex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_add:Nn { c } \cs_generate_variant:Nn \skip_gadd:Nn { c } -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \skip_sub:Nn #1#2 { \tex_advance:D #1 by - \tex_glueexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \skip_gsub:Nn #1#2 { \tex_global:D \tex_advance:D #1 by - \tex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_sub:Nn { c } @@ -1969,13 +1910,6 @@ % \begin{macrocode} \cs_set_protected:Npn \@@_tmp:w #1 { - \__kernel_patch_conditional_args:nNNpnn - { - { - \__kernel_chk_expr:nNnN - {##1} \tex_glueexpr:D { } \skip_if_finite:n - } - } \prg_new_conditional:Npnn \skip_if_finite:n ##1 { p , T , F , TF } { \exp_after:wN \@@_if_finite:wwNw @@ -1994,8 +1928,6 @@ % \begin{macro}{\skip_eval:n} % Evaluating a skip expression expandably. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { { \__kernel_chk_expr:nNnN {#1} \tex_glueexpr:D { } \skip_eval:n } } \cs_new:Npn \skip_eval:n #1 { \skip_use:N \tex_glueexpr:D #1 \scan_stop: } % \end{macrocode} @@ -2017,23 +1949,9 @@ % Inserting skips. % \begin{macrocode} \cs_new_eq:NN \skip_horizontal:N \tex_hskip:D -\__kernel_patch_args:nNNpn - { - { - \__kernel_chk_expr:nNnN {#1} \tex_glueexpr:D { } - \skip_horizontal:n - } - } \cs_new:Npn \skip_horizontal:n #1 { \skip_horizontal:N \tex_glueexpr:D #1 \scan_stop: } \cs_new_eq:NN \skip_vertical:N \tex_vskip:D -\__kernel_patch_args:nNNpn - { - { - \__kernel_chk_expr:nNnN {#1} \tex_glueexpr:D { } - \skip_vertical:n - } - } \cs_new:Npn \skip_vertical:n #1 { \skip_vertical:N \tex_glueexpr:D #1 \scan_stop: } \cs_generate_variant:Nn \skip_horizontal:N { c } @@ -2116,7 +2034,6 @@ % \begin{macro}{\muskip_const:Nn, \muskip_const:cn} % See \cs{skip_const:Nn}. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_scope:NN c #1 } { } \cs_new_protected:Npn \muskip_const:Nn #1#2 { \muskip_new:N #1 @@ -2130,10 +2047,8 @@ % \begin{macro}{\muskip_gzero:N, \muskip_gzero:c} % Reset the register to zero. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_local:N #1 } { } \cs_new_protected:Npn \muskip_zero:N #1 { #1 \c_zero_muskip } -\__kernel_patch:nnNNpn { \__kernel_chk_var_global:N #1 } { } \cs_new_protected:Npn \muskip_gzero:N #1 { \tex_global:D #1 \c_zero_muskip } \cs_generate_variant:Nn \muskip_zero:N { c } @@ -2170,32 +2085,12 @@ % % \subsection{Setting \texttt{muskip} variables} % -% See \texttt{skip} case. -% \begin{macrocode} -\cs_set_protected:Npn \@@_tmp:w #1#2#3 - { - \__kernel_patch_args:nnnNNpn - { #1 ##1 } - { } - { - {##1} - { - \__kernel_chk_expr:nNnN {##2} - \tex_muexpr:D { \tex_mutoglue:D } #3 - } - } - #2 #3 - } -% \end{macrocode} -% % \begin{macro}{\muskip_set:Nn, \muskip_set:cn} % \begin{macro}{\muskip_gset:Nn, \muskip_gset:cn} % This should be pretty familiar. % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \muskip_set:Nn #1#2 { #1 ~ \tex_muexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \muskip_gset:Nn #1#2 { \tex_global:D #1 ~ \tex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_set:Nn { c } @@ -2216,10 +2111,8 @@ % } % All straightforward. % \begin{macrocode} -\__kernel_patch:nnNNpn { \__kernel_chk_var_local:N #1 } { } \cs_new_protected:Npn \muskip_set_eq:NN #1#2 { #1 = #2 } \cs_generate_variant:Nn \muskip_set_eq:NN { c , Nc , cc } -\__kernel_patch:nnNNpn { \__kernel_chk_var_global:N #1 } { } \cs_new_protected:Npn \muskip_gset_eq:NN #1#2 { \tex_global:D #1 = #2 } \cs_generate_variant:Nn \muskip_gset_eq:NN { c , Nc , cc } % \end{macrocode} @@ -2232,18 +2125,14 @@ % \begin{macro}{\muskip_gsub:Nn, \muskip_gsub:cn} % Using |by| here deals with the (incorrect) case |\muskip123|. % \begin{macrocode} -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \muskip_add:Nn #1#2 { \tex_advance:D #1 by \tex_muexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \muskip_gadd:Nn #1#2 { \tex_global:D \tex_advance:D #1 by \tex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_add:Nn { c } \cs_generate_variant:Nn \muskip_gadd:Nn { c } -\@@_tmp:w \__kernel_chk_var_local:N \cs_new_protected:Npn \muskip_sub:Nn #1#2 { \tex_advance:D #1 by - \tex_muexpr:D #2 \scan_stop: } -\@@_tmp:w \__kernel_chk_var_global:N \cs_new_protected:Npn \muskip_gsub:Nn #1#2 { \tex_global:D \tex_advance:D #1 by - \tex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_sub:Nn { c } @@ -2259,13 +2148,6 @@ % \begin{macro}{\muskip_eval:n} % Evaluating a muskip expression expandably. % \begin{macrocode} -\__kernel_patch_args:nNNpn - { - { - \__kernel_chk_expr:nNnN {#1} \tex_muexpr:D - { \tex_mutoglue:D } \muskip_eval:n - } - } \cs_new:Npn \muskip_eval:n #1 { \muskip_use:N \tex_muexpr:D #1 \scan_stop: } % \end{macrocode} |