From 815ad4148b047c0d63020276367a646e9e2049a4 Mon Sep 17 00:00:00 2001 From: Bruno Le Floch Date: Wed, 29 Nov 2017 01:05:29 -0500 Subject: [PATCH] Check local/global assignments to int/dim/skip/muskip/box (see #410) --- l3kernel/l3basics.dtx | 69 +++++---- l3kernel/l3box.dtx | 135 ++++++++++++++---- l3kernel/l3coffins.dtx | 3 + l3kernel/l3int.dtx | 78 ++++++++--- l3kernel/l3skip.dtx | 187 ++++++++++++++++--------- l3kernel/testfiles/m3int001.luatex.tlg | 4 +- l3kernel/testfiles/m3int001.ptex.tlg | 4 +- l3kernel/testfiles/m3int001.tlg | 4 +- l3kernel/testfiles/m3int001.uptex.tlg | 4 +- l3kernel/testfiles/m3int001.xetex.tlg | 4 +- l3kernel/testfiles/m3skip001.lvt | 164 ++++++++++++---------- l3kernel/testfiles/m3skip002.lvt | 24 ++-- l3trial/l3tree/l3tree.dtx | 3 +- 13 files changed, 444 insertions(+), 239 deletions(-) diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx index f9450c3e00..0b568394d3 100644 --- a/l3kernel/l3basics.dtx +++ b/l3kernel/l3basics.dtx @@ -1339,6 +1339,16 @@ % counterpart. % \end{function} % +% \begin{function} +% {\__debug_patch_args:nnnNNpn, \__debug_patch_conditional_args:nnnNNpnn} +% \begin{syntax} +% \cs{__debug_patch_args:nnnNNpn} \Arg{before} \Arg{after} \Arg{arguments} +% \meta{definition} \meta{function} \meta{parameters} \Arg{code} +% \end{syntax} +% A combination of \cs{__debug_patch:nnNNpn} and +% \cs{__debug_patch_args:nNNpn}. +% \end{function} +% % \begin{function}{\__kernel_register_show:N, \__kernel_register_show:c} % \begin{syntax} % \cs{__kernel_register_show:N} \meta{register} @@ -2135,7 +2145,7 @@ % \begin{macro}[int] % {\@@_patch:nnNNpn, \@@_patch_conditional:nNNpnn} % \begin{macro}[aux] -% {\@@_patch_aux:nnNNnn, \@@_patch_aux:nNNnnn} +% {\@@_patch_aux:nnnn, \@@_patch_auxii:nnnn} % When debugging is not enabled, \cs{@@_patch:nnNNpn} and % \cs{@@_patch_conditional:nNNpnn} throw the patch away. % Otherwise they can be followed by \cs{cs_new:Npn} (or similar), and @@ -2146,13 +2156,13 @@ \@@:TF { \cs_set_protected:Npn \@@_patch:nnNNpn #1#2#3#4#5# - { \@@_patch_aux:nnNNnn {#1} {#2} #3 #4 {#5} } + { \@@_patch_aux:nnnn {#1} {#2} { #3 #4 #5 } } \cs_set_protected:Npn \@@_patch_conditional:nNNpnn #1#2#3#4# - { \@@_patch_aux:nNNnnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \@@_patch_aux:nnNNnn #1#2#3#4#5#6 - { #3 #4 #5 { #1 #6 #2 } } - \cs_set_protected:Npn \@@_patch_aux:nNNnnn #1#2#3#4#5#6 - { #2 #3 #4 {#5} { #1 #6 } } + { \@@_patch_auxii:nnnn {#1} { #2 #3 #4 } } + \cs_set_protected:Npn \@@_patch_aux:nnnn #1#2#3#4 + { #3 { #1 #4 #2 } } + \cs_set_protected:Npn \@@_patch_auxii:nnnn #1#2#3#4 + { #2 {#3} { #1 #4 } } } { \cs_set_protected:Npn \@@_patch:nnNNpn #1#2 { } @@ -2164,46 +2174,55 @@ % % \begin{macro}[int] % {\@@_patch_args:nNNpn, \@@_patch_conditional_args:nNNpnn} +% \begin{macro}[int] +% {\@@_patch_args:nnnNNpn, \@@_patch_conditional_args:nnnNNpnn} % \begin{macro}[aux] % { % \@@_tmp:w, -% \@@_patch_args_aux:nNNnn, -% \@@_patch_args_aux:nNNnnn +% \@@_patch_args_aux:nnnNNnn, +% \@@_patch_args_aux:nnnNNnnn, +% \@@_patch_args_aux:nnnn % } % See \cs{@@_patch:nnNNpn}. The first argument is something like % |{#1}{(#2)}|. Define a temporary macro using the \meta{parameters} % and \meta{code} of the definition that follows, then expand that % temporary macro in front of the first argument to obtain new % \meta{code}. Then perform the definition as if that new \meta{code} -% was directly typed in the file. To make it easy to expand in the -% definition, treat it as a \enquote{pre}-code to an empty definition. +% was directly typed in the file. % \begin{macrocode} +\cs_set_protected:Npn \@@_patch_args:nNNpn + { \@@_patch_args:nnnNNpn { } { } } +\cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn + { \@@_patch_conditional_args:nnnNNpnn { } { } } \@@:TF { - \cs_set_protected:Npn \@@_patch_args:nNNpn #1#2#3#4# - { \@@_patch_args_aux:nNNnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn #1#2#3#4# - { \@@_patch_args_aux:nNNnnn {#1} #2 #3 {#4} } - \cs_set_protected:Npn \@@_patch_args_aux:nNNnn #1#2#3#4#5 + \cs_set_protected:Npn \@@_patch_args:nnnNNpn #1#2#3#4#5#6# + { \@@_patch_args_aux:nnnNNnn {#1} {#2} {#3} #4 #5 {#6} } + \cs_set_protected:Npn \@@_patch_conditional_args:nnnNNpnn #1#2#3#4#5#6# + { \@@_patch_args_aux:nnnNNnnn {#1} {#2} {#3} #4 #5 {#6} } + \cs_set_protected:Npn \@@_patch_args_aux:nnnNNnn #1#2#3#4#5#6#7 { - \cs_set:Npn \@@_tmp:w #4 {#5} - \exp_after:wN \@@_patch_aux:nnNNnn \exp_after:wN - { \@@_tmp:w #1 } { } #2 #3 {#4} { } + \cs_set:Npn \@@_tmp:w #6 {#7} + \exp_after:wN \@@_patch_args_aux:nnnn \exp_after:wN + { \@@_tmp:w #3 } { #4 #5 #6 } {#1} {#2} } - \cs_set_protected:Npn \@@_patch_args_aux:nNNnnn #1#2#3#4#5#6 + \cs_set_protected:Npn \@@_patch_args_aux:nnnNNnnn #1#2#3#4#5#6#7#8 { - \cs_set:Npn \@@_tmp:w #4 {#6} - \exp_after:wN \@@_patch_aux:nNNnnn \exp_after:wN - { \@@_tmp:w #1 } #2 #3 {#4} {#5} { } + \cs_set:Npn \@@_tmp:w #6 {#8} + \exp_after:wN \@@_patch_args_aux:nnnn \exp_after:wN + { \@@_tmp:w #3 } { #4 #5 #6 {#7} } {#1} {#2} } + \cs_set_protected:Npn \@@_patch_args_aux:nnnn #1#2#3#4 + { #2 { #3 #1 #4 } } } { - \cs_set_protected:Npn \@@_patch_args:nNNpn #1 { } - \cs_set_protected:Npn \@@_patch_conditional_args:nNNpnn #1 { } + \cs_set_protected:Npn \@@_patch_args:nnnNNpn #1#2#3 { } + \cs_set_protected:Npn \@@_patch_conditional_args:nnnNNpnn #1#2#3 { } } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Conditional processing and definitions} % diff --git a/l3kernel/l3box.dtx b/l3kernel/l3box.dtx index 74ed05fa0d..e8e19f87b9 100644 --- a/l3kernel/l3box.dtx +++ b/l3kernel/l3box.dtx @@ -901,10 +901,12 @@ % \testfile* % Assigning the contents of a box to be another box. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \box_set_eq:NN #1#2 { \tex_setbox:D #1 \tex_copy:D #2 } -\cs_new_protected:Npn \box_gset_eq:NN - { \tex_global:D \box_set_eq:NN } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \box_gset_eq:NN #1#2 + { \tex_global:D \tex_setbox:D #1 \tex_copy:D #2 } \cs_generate_variant:Nn \box_set_eq:NN { c , Nc , cc } \cs_generate_variant:Nn \box_gset_eq:NN { c , Nc , cc } % \end{macrocode} @@ -926,10 +928,12 @@ % Assigning the contents of a box to be another box. % This clears the second box globally (that's how \TeX{} does it). % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \box_set_eq_clear:NN #1#2 { \tex_setbox:D #1 \tex_box:D #2 } -\cs_new_protected:Npn \box_gset_eq_clear:NN - { \tex_global:D \box_set_eq_clear:NN } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \box_gset_eq_clear:NN #1#2 + { \tex_global:D \tex_setbox:D #1 \tex_box:D #2 } \cs_generate_variant:Nn \box_set_eq_clear:NN { c , Nc , cc } \cs_generate_variant:Nn \box_gset_eq_clear:NN { c , Nc , cc } % \end{macrocode} @@ -1087,10 +1091,12 @@ % \testfile* % Set a box to the previous box. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \box_set_to_last:N #1 { \tex_setbox:D #1 \tex_lastbox:D } -\cs_new_protected:Npn \box_gset_to_last:N - { \tex_global:D \box_set_to_last:N } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \box_gset_to_last:N #1 + { \tex_global:D \tex_setbox:D #1 \tex_lastbox:D } \cs_generate_variant:Nn \box_set_to_last:N { c } \cs_generate_variant:Nn \box_gset_to_last:N { c } % \end{macrocode} @@ -1205,9 +1211,12 @@ % \begin{macro}{\hbox_gset:Nn, \hbox_gset:cn} % \testfile* % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \hbox_set:Nn #1#2 { \tex_setbox:D #1 \tex_hbox:D { \group_begin: #2 \group_end: } } -\cs_new_protected:Npn \hbox_gset:Nn { \tex_global:D \hbox_set:Nn } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \hbox_gset:Nn #1#2 + { \tex_global:D \tex_setbox:D #1 \tex_hbox:D { \group_begin: #2 \group_end: } } \cs_generate_variant:Nn \hbox_set:Nn { c } \cs_generate_variant:Nn \hbox_gset:Nn { c } % \end{macrocode} @@ -1220,14 +1229,25 @@ % Storing material in a horizontal box with a specified width. % Again, put the dimension expression in parentheses when debugging. % \begin{macrocode} -\__debug_patch_args:nNNpn { {#1} { (#2) } {#3} } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_local:N #1 } + { } + { {#1} { (#2) } {#3} } \cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3 { \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: { \group_begin: #3 \group_end: } } -\cs_new_protected:Npn \hbox_gset_to_wd:Nnn - { \tex_global:D \hbox_set_to_wd:Nnn } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_global:N #1 } + { } + { {#1} { (#2) } {#3} } +\cs_new_protected:Npn \hbox_gset_to_wd:Nnn #1#2#3 + { + \tex_global:D \tex_setbox:D #1 \tex_hbox:D + to \__dim_eval:w #2 \__dim_eval_end: + { \group_begin: #3 \group_end: } + } \cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c } \cs_generate_variant:Nn \hbox_gset_to_wd:Nnn { c } % \end{macrocode} @@ -1241,14 +1261,20 @@ % Storing material in a horizontal box. This type is useful in % environment definitions. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \hbox_set:Nw #1 { \tex_setbox:D #1 \tex_hbox:D \c_group_begin_token \group_begin: } -\cs_new_protected:Npn \hbox_gset:Nw - { \tex_global:D \hbox_set:Nw } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \hbox_gset:Nw #1 + { + \tex_global:D \tex_setbox:D #1 \tex_hbox:D + \c_group_begin_token + \group_begin: + } \cs_generate_variant:Nn \hbox_set:Nw { c } \cs_generate_variant:Nn \hbox_gset:Nw { c } \cs_new_protected:Npn \hbox_set_end: @@ -1266,15 +1292,27 @@ % \begin{macro}{\hbox_gset_to_wd:Nnw, \hbox_gset_to_wd:cnw} % Combining the above ideas. % \begin{macrocode} -\__debug_patch_args:nNNpn { {#1} { (#2) } } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_local:N #1 } + { } + { {#1} { (#2) } } \cs_new_protected:Npn \hbox_set_to_wd:Nnw #1#2 { \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: \c_group_begin_token \group_begin: } -\cs_new_protected:Npn \hbox_gset_to_wd:Nnw - { \tex_global:D \hbox_set_to_wd:Nnw } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_global:N #1 } + { } + { {#1} { (#2) } } +\cs_new_protected:Npn \hbox_gset_to_wd:Nnw #1#2 + { + \tex_global:D \tex_setbox:D #1 \tex_hbox:D + to \__dim_eval:w #2 \__dim_eval_end: + \c_group_begin_token + \group_begin: + } \cs_generate_variant:Nn \hbox_set_to_wd:Nnw { c } \cs_generate_variant:Nn \hbox_gset_to_wd:Nnw { c } % \end{macrocode} @@ -1367,12 +1405,18 @@ % \testfile* % Storing material in a vertical box with a natural height. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \vbox_set:Nn #1#2 { \tex_setbox:D #1 \tex_vbox:D { \group_begin: #2 \par \group_end: } } -\cs_new_protected:Npn \vbox_gset:Nn { \tex_global:D \vbox_set:Nn } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \vbox_gset:Nn #1#2 + { + \tex_global:D \tex_setbox:D #1 \tex_vbox:D + { \group_begin: #2 \par \group_end: } + } \cs_generate_variant:Nn \vbox_set:Nn { c } \cs_generate_variant:Nn \vbox_gset:Nn { c } % \end{macrocode} @@ -1385,13 +1429,18 @@ % Storing material in a vertical box with a natural height and reference % point at the baseline of the first object in the box. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \vbox_set_top:Nn #1#2 { \tex_setbox:D #1 \tex_vtop:D { \group_begin: #2 \par \group_end: } } -\cs_new_protected:Npn \vbox_gset_top:Nn - { \tex_global:D \vbox_set_top:Nn } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \vbox_gset_top:Nn #1#2 + { + \tex_global:D \tex_setbox:D #1 \tex_vtop:D + { \group_begin: #2 \par \group_end: } + } \cs_generate_variant:Nn \vbox_set_top:Nn { c } \cs_generate_variant:Nn \vbox_gset_top:Nn { c } % \end{macrocode} @@ -1403,14 +1452,25 @@ % \testfile* % Storing material in a vertical box with a specified height. % \begin{macrocode} -\__debug_patch_args:nNNpn { {#1} { (#2) } {#3} } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_local:N #1 } + { } + { {#1} { (#2) } {#3} } \cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3 { \tex_setbox:D #1 \tex_vbox:D to \__dim_eval:w #2 \__dim_eval_end: { \group_begin: #3 \par \group_end: } } -\cs_new_protected:Npn \vbox_gset_to_ht:Nnn - { \tex_global:D \vbox_set_to_ht:Nnn } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_global:N #1 } + { } + { {#1} { (#2) } {#3} } +\cs_new_protected:Npn \vbox_gset_to_ht:Nnn #1#2#3 + { + \tex_global:D \tex_setbox:D #1 \tex_vbox:D + to \__dim_eval:w #2 \__dim_eval_end: + { \group_begin: #3 \par \group_end: } + } \cs_generate_variant:Nn \vbox_set_to_ht:Nnn { c } \cs_generate_variant:Nn \vbox_gset_to_ht:Nnn { c } % \end{macrocode} @@ -1424,14 +1484,20 @@ % Storing material in a vertical box. This type is useful in % environment definitions. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \vbox_set:Nw #1 { \tex_setbox:D #1 \tex_vbox:D \c_group_begin_token \group_begin: } -\cs_new_protected:Npn \vbox_gset:Nw - { \tex_global:D \vbox_set:Nw } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \vbox_gset:Nw #1 + { + \tex_global:D \tex_setbox:D #1 \tex_vbox:D + \c_group_begin_token + \group_begin: + } \cs_generate_variant:Nn \vbox_set:Nw { c } \cs_generate_variant:Nn \vbox_gset:Nw { c } \cs_new_protected:Npn \vbox_set_end: @@ -1450,15 +1516,27 @@ % \begin{macro}{\vbox_gset_to_ht:Nnw, \vbox_gset_to_ht:cnw} % A combination of the above ideas. % \begin{macrocode} -\__debug_patch_args:nNNpn { {#1} { (#2) } } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_local:N #1 } + { } + { {#1} { (#2) } } \cs_new_protected:Npn \vbox_set_to_ht:Nnw #1#2 { \tex_setbox:D #1 \tex_vbox:D to \__dim_eval:w #2 \__dim_eval_end: \c_group_begin_token \group_begin: } -\cs_new_protected:Npn \vbox_gset_to_ht:Nnw - { \tex_global:D \vbox_set_to_ht:Nnw } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_global:N #1 } + { } + { {#1} { (#2) } } +\cs_new_protected:Npn \vbox_gset_to_ht:Nnw #1#2 + { + \tex_global:D \tex_setbox:D #1 \tex_vbox:D + to \__dim_eval:w #2 \__dim_eval_end: + \c_group_begin_token + \group_begin: + } \cs_generate_variant:Nn \vbox_set_to_ht:Nnw { c } \cs_generate_variant:Nn \vbox_gset_to_ht:Nnw { c } % \end{macrocode} @@ -1482,7 +1560,10 @@ % \testfile* % Splitting a vertical box in two. % \begin{macrocode} -\__debug_patch_args:nNNpn { {#1} {#2} { (#3) } } +\__debug_patch_args:nnnNNpn + { \__debug_chk_var_local:N #1 } + { } + { {#1} {#2} { (#3) } } \cs_new_protected:Npn \vbox_set_split_to_ht:NNn #1#2#3 { \tex_setbox:D #1 \tex_vsplit:D #2 to \__dim_eval:w #3 \__dim_eval_end: } % \end{macrocode} diff --git a/l3kernel/l3coffins.dtx b/l3kernel/l3coffins.dtx index 7d427145fa..d6fdf70031 100644 --- a/l3kernel/l3coffins.dtx +++ b/l3kernel/l3coffins.dtx @@ -686,9 +686,12 @@ % Special coffins: these cannot be set up earlier as they need % \cs{coffin_new:N}. The empty coffin is set as a box as the full % coffin-setting system needs some material which is not yet available. +% Debugging must be suspended as we are assigning to a constant coffin. % \begin{macrocode} \coffin_new:N \c_empty_coffin +\debug_suspend: \hbox_set:Nn \c_empty_coffin { } +\debug_resume: \coffin_new:N \l_@@_aligned_coffin \coffin_new:N \l_@@_aligned_internal_coffin % \end{macrocode} diff --git a/l3kernel/l3int.dtx b/l3kernel/l3int.dtx index fbe0b4ccc9..a793ebba9d 100644 --- a/l3kernel/l3int.dtx +++ b/l3kernel/l3int.dtx @@ -1200,6 +1200,8 @@ % \tn{mathchardef} but that's engine dependent. As a result, there is some % set up code to determine what can be done. No full engine testing just yet % so everything is a little awkward. +% We cannot use \cs{int_gset:Nn} because (when |check-declarations| is +% enabled) this runs some checks that constants would fail. % \begin{macrocode} \__debug_patch_args:nNNpn { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \int_const:Nn } } @@ -1208,20 +1210,20 @@ \int_compare:nNnTF {#2} < \c_zero { \int_new:N #1 - \int_gset:Nn #1 {#2} + \tex_global:D } { \int_compare:nNnTF {#2} > \c__max_constdef_int { \int_new:N #1 - \int_gset:Nn #1 {#2} + \tex_global:D } { \__chk_if_free_cs:N #1 - \tex_global:D \@@_constdef:Nw #1 = - \@@_eval:w #2 \@@_eval_end: + \tex_global:D \@@_constdef:Nw } } + #1 = \@@_eval:w #2 \@@_eval_end: } \cs_generate_variant:Nn \int_const:Nn { c } \if_int_odd:w 0 @@ -1248,7 +1250,9 @@ % \UnitTested % Functions that reset an \meta{integer} register to zero. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \int_zero:N #1 { #1 = \c_zero } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } \cs_new_protected:Npn \int_gzero:N #1 { \tex_global:D #1 = \c_zero } \cs_generate_variant:Nn \int_zero:N { c } \cs_generate_variant:Nn \int_gzero:N { c } @@ -1275,11 +1279,14 @@ % {\int_gset_eq:NN, \int_gset_eq:cN, \int_gset_eq:Nc, \int_gset_eq:cc} % \UnitTested % Setting equal means using one integer inside the set function of -% another. +% another. Check that assigned integer is local/global. No need to +% check that the other one is defined as \TeX{} does it for us. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \int_set_eq:NN #1#2 { #1 = #2 } \cs_generate_variant:Nn \int_set_eq:NN { c } \cs_generate_variant:Nn \int_set_eq:NN { Nc , cc } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } \cs_new_protected:Npn \int_gset_eq:NN #1#2 { \tex_global:D #1 = #2 } \cs_generate_variant:Nn \int_gset_eq:NN { c } \cs_generate_variant:Nn \int_gset_eq:NN { Nc , cc } @@ -1299,6 +1306,22 @@ % % \subsection{Setting and incrementing integers} % +% 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 + { + \__debug_patch_args:nnnNNpn + { #1 ##1 } + { } + { {##1} { \__debug_chk_expr:nNnN {##2} \@@_eval:w { } #3 } } + #2 #3 + } +% \end{macrocode} +% % \begin{macro}{\int_add:Nn, \int_add:cn} % \UnitTested % \begin{macro}{\int_gadd:Nn, \int_gadd:cn} @@ -1307,20 +1330,23 @@ % \UnitTested % \begin{macro}{\int_gsub:Nn, \int_gsub:cn} % \UnitTested -% Adding and subtracting to and from a counter \ldots +% Adding and subtracting to and from a counter. For each function, +% the debugging code produced by \cs{@@_tmp:w} checks that the +% assigned variable is correctly local/global and wraps the +% expression in some checking code. % \begin{macrocode} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \int_add:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \int_add:Nn #1#2 { \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: } -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \int_sub:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \int_sub:Nn #1#2 { \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: } -\cs_new_protected:Npn \int_gadd:Nn - { \tex_global:D \int_add:Nn } -\cs_new_protected:Npn \int_gsub:Nn - { \tex_global:D \int_sub:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \int_gadd:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \int_gsub:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: } \cs_generate_variant:Nn \int_add:Nn { c } \cs_generate_variant:Nn \int_gadd:Nn { c } \cs_generate_variant:Nn \int_sub:Nn { c } @@ -1342,14 +1368,18 @@ % Incrementing and decrementing of integer registers is done with % the following functions. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \int_incr:N #1 { \tex_advance:D #1 \c_one } +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \int_decr:N #1 { \tex_advance:D #1 - \c_one } -\cs_new_protected:Npn \int_gincr:N - { \tex_global:D \int_incr:N } -\cs_new_protected:Npn \int_gdecr:N - { \tex_global:D \int_decr:N } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \int_gincr:N #1 + { \tex_global:D \tex_advance:D #1 \c_one } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \int_gdecr:N #1 + { \tex_global:D \tex_advance:D #1 - \c_one } \cs_generate_variant:Nn \int_incr:N { c } \cs_generate_variant:Nn \int_decr:N { c } \cs_generate_variant:Nn \int_gincr:N { c } @@ -1365,14 +1395,16 @@ % \begin{macro}{\int_gset:Nn, \int_gset:cn} % \UnitTested % As integers are register-based \TeX{} issues an error -% if they are not defined. Thus there is no need for the checking -% code seen with token list variables. +% if they are not defined. Thus there is no need to check their +% existence as for token list variables. However, the code that +% checks whether the assignment is local or global is still needed. % \begin{macrocode} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \int_set:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \int_set:Nn #1#2 { #1 ~ \@@_eval:w #2 \@@_eval_end: } -\cs_new_protected:Npn \int_gset:Nn { \tex_global:D \int_set:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \int_gset:Nn #1#2 + { \tex_global:D #1 ~ \@@_eval:w #2 \@@_eval_end: } \cs_generate_variant:Nn \int_set:Nn { c } \cs_generate_variant:Nn \int_gset:Nn { c } % \end{macrocode} diff --git a/l3kernel/l3skip.dtx b/l3kernel/l3skip.dtx index ab6d53b6e8..991916eae2 100644 --- a/l3kernel/l3skip.dtx +++ b/l3kernel/l3skip.dtx @@ -1058,12 +1058,16 @@ % % \begin{macro}{\dim_const:Nn, \dim_const:cn} % Contrarily to integer constants, we cannot avoid using a register, -% even for constants. +% even for constants. We cannot use \cs{dim_gset:Nn} because +% debugging code would complain that the constant is not a global +% variable. Since \cs{dim_const:Nn} does not need to be fast, use +% \cs{dim_eval:n} to avoid needing a debugging patch that wraps the +% expression in checking code. % \begin{macrocode} -\cs_new_protected:Npn \dim_const:Nn #1 +\cs_new_protected:Npn \dim_const:Nn #1#2 { \dim_new:N #1 - \dim_gset:Nn #1 + \tex_global:D #1 ~ \dim_eval:n {#2} \scan_stop: } \cs_generate_variant:Nn \dim_const:Nn { c } % \end{macrocode} @@ -1073,8 +1077,10 @@ % \begin{macro}{\dim_gzero:N, \dim_gzero:c} % Reset the register to zero. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \dim_zero:N #1 { #1 \c_zero_dim } -\cs_new_protected:Npn \dim_gzero:N { \tex_global:D \dim_zero:N } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } +\cs_new_protected:Npn \dim_gzero:N #1 { \tex_global:D #1 \c_zero_dim } \cs_generate_variant:Nn \dim_zero:N { c } \cs_generate_variant:Nn \dim_gzero:N { c } % \end{macrocode} @@ -1106,17 +1112,36 @@ % % \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 + { + \__debug_patch_args:nnnNNpn + { #1 ##1 } + { } + { {##1} { \__debug_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. The |\scan_stop:| deals with the -% case where the variable passed is a skip (for example a \LaTeXe{} +% Setting dimensions is easy enough but when debugging we want both to +% check that the variable is correctly local/global and to wrap the +% expression in some code. The |\scan_stop:| deals with the case +% where the variable passed is a skip (for example a \LaTeXe{} % length). % \begin{macrocode} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \dim_set:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \dim_set:Nn #1#2 { #1 ~ \@@_eval:w #2 \@@_eval_end: \scan_stop: } -\cs_new_protected:Npn \dim_gset:Nn { \tex_global:D \dim_set:Nn } +\@@_tmp:w \__debug_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 } \cs_generate_variant:Nn \dim_gset:Nn { c } % \end{macrocode} @@ -1128,9 +1153,11 @@ % {\dim_gset_eq:NN, \dim_gset_eq:cN, \dim_gset_eq:Nc, \dim_gset_eq:cc} % All straightforward. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \dim_set_eq:NN #1#2 { #1 = #2 } \cs_generate_variant:Nn \dim_set_eq:NN { c } \cs_generate_variant:Nn \dim_set_eq:NN { Nc , cc } +\__debug_patch:nnNNpn { \__debug_chk_var_global:N #1 } { } \cs_new_protected:Npn \dim_gset_eq:NN #1#2 { \tex_global:D #1 = #2 } \cs_generate_variant:Nn \dim_gset_eq:NN { c } \cs_generate_variant:Nn \dim_gset_eq:NN { Nc , cc } @@ -1142,20 +1169,26 @@ % \begin{macro}{\dim_gadd:Nn, \dim_gadd:cn} % \begin{macro}{\dim_sub:Nn, \dim_sub:cn} % \begin{macro}{\dim_gsub:Nn, \dim_gsub:cn} -% Using |by| here deals with the (incorrect) case |\dimen123|. +% Using |by| here deals with the (incorrect) case |\dimen123|. Since +% debugging checks that the variable is correctly local/global, the +% global versions cannot be defined as \cs{tex_global:D} followed by +% the local versions. The debugging code is inserted by +% \cs{@@_tmp:w}. % \begin{macrocode} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \dim_add:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \dim_add:Nn #1#2 { \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: } -\cs_new_protected:Npn \dim_gadd:Nn { \tex_global:D \dim_add:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \dim_gadd:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: } \cs_generate_variant:Nn \dim_add:Nn { c } \cs_generate_variant:Nn \dim_gadd:Nn { c } -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \@@_eval:w { } \dim_sub:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \dim_sub:Nn #1#2 { \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: } -\cs_new_protected:Npn \dim_gsub:Nn { \tex_global:D \dim_sub:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \dim_gsub:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: } \cs_generate_variant:Nn \dim_sub:Nn { c } \cs_generate_variant:Nn \dim_gsub:Nn { c } % \end{macrocode} @@ -1615,12 +1648,13 @@ % % \begin{macro}{\skip_const:Nn, \skip_const:cn} % Contrarily to integer constants, we cannot avoid using a register, -% even for constants. +% even for constants. See \cs{dim_const:Nn} for why we cannot use +% \cs{skip_gset:Nn}. % \begin{macrocode} -\cs_new_protected:Npn \skip_const:Nn #1 +\cs_new_protected:Npn \skip_const:Nn #1#2 { \skip_new:N #1 - \skip_gset:Nn #1 + \tex_global:D #1 ~ \skip_eval:n {#2} \scan_stop: } \cs_generate_variant:Nn \skip_const:Nn { c } % \end{macrocode} @@ -1630,8 +1664,10 @@ % \begin{macro}{\skip_gzero:N, \skip_gzero:c} % Reset the register to zero. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \skip_zero:N #1 { #1 \c_zero_skip } -\cs_new_protected:Npn \skip_gzero:N { \tex_global:D \skip_zero:N } +\__debug_patch:nnNNpn { \__debug_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 } % \end{macrocode} @@ -1663,15 +1699,31 @@ % % \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 + { + \__debug_patch_args:nnnNNpn + { #1 ##1 } + { } + { {##1} { \__debug_chk_expr:nNnN {##2} \etex_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} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \etex_glueexpr:D { } \skip_set:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \skip_set:Nn #1#2 { #1 ~ \etex_glueexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \skip_gset:Nn { \tex_global:D \skip_set:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \skip_gset:Nn #1#2 + { \tex_global:D #1 ~ \etex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_set:Nn { c } \cs_generate_variant:Nn \skip_gset:Nn { c } % \end{macrocode} @@ -1700,18 +1752,20 @@ % \begin{macro}{\skip_gsub:Nn, \skip_gsub:cn} % Using |by| here deals with the (incorrect) case |\skip123|. % \begin{macrocode} -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \etex_glueexpr:D { } \skip_add:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \skip_add:Nn #1#2 { \tex_advance:D #1 by \etex_glueexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \skip_gadd:Nn { \tex_global:D \skip_add:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \skip_gadd:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by \etex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_add:Nn { c } \cs_generate_variant:Nn \skip_gadd:Nn { c } -\__debug_patch_args:nNNpn - { {#1} { \__debug_chk_expr:nNnN {#2} \etex_glueexpr:D { } \skip_sub:Nn } } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \skip_sub:Nn #1#2 { \tex_advance:D #1 by - \etex_glueexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \skip_gsub:Nn { \tex_global:D \skip_sub:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \skip_gsub:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by - \etex_glueexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \skip_sub:Nn { c } \cs_generate_variant:Nn \skip_gsub:Nn { c } % \end{macrocode} @@ -1749,7 +1803,7 @@ % it is quicker to make it search for the string \texttt{fil} which % characterizes infinite glue. % \begin{macrocode} -\cs_set_protected:Npn \__cs_tmp:w #1 +\cs_set_protected:Npn \@@_tmp:w #1 { \__debug_patch_conditional_args:nNNpnn { @@ -1766,7 +1820,7 @@ } \cs_new:Npn \__skip_if_finite:wwNw ##1 #1 ##2 ; ##3 ##4 \q_stop {##3} } -\exp_args:No \__cs_tmp:w { \tl_to_str:n { fil } } +\exp_args:No \@@_tmp:w { \tl_to_str:n { fil } } % \end{macrocode} % \end{macro} % \end{macro} @@ -1886,13 +1940,12 @@ % \end{macro} % % \begin{macro}{\muskip_const:Nn, \muskip_const:cn} -% Contrarily to integer constants, we cannot avoid using a register, -% even for constants. +% See \cs{skip_const:Nn}. % \begin{macrocode} -\cs_new_protected:Npn \muskip_const:Nn #1 +\cs_new_protected:Npn \muskip_const:Nn #1#2 { \muskip_new:N #1 - \muskip_gset:Nn #1 + \tex_global:D #1 ~ \muskip_eval:n {#2} \scan_stop: } \cs_generate_variant:Nn \muskip_const:Nn { c } % \end{macrocode} @@ -1902,9 +1955,12 @@ % \begin{macro}{\muskip_gzero:N, \muskip_gzero:c} % Reset the register to zero. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_chk_var_local:N #1 } { } \cs_new_protected:Npn \muskip_zero:N #1 { #1 \c_zero_muskip } -\cs_new_protected:Npn \muskip_gzero:N { \tex_global:D \muskip_zero:N } +\__debug_patch:nnNNpn { \__debug_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 } \cs_generate_variant:Nn \muskip_gzero:N { c } % \end{macrocode} @@ -1939,21 +1995,34 @@ % % \subsection{Setting \texttt{muskip} variables} % +% See \texttt{skip} case. +% \begin{macrocode} +\cs_set_protected:Npn \@@_tmp:w #1#2#3 + { + \__debug_patch_args:nnnNNpn + { #1 ##1 } + { } + { + {##1} + { + \__debug_chk_expr:nNnN {##2} + \etex_muexpr:D { \etex_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} -\__debug_patch_args:nNNpn - { - {#1} - { - \__debug_chk_expr:nNnN {#2} \etex_muexpr:D - { \etex_mutoglue:D } \muskip_set:Nn - } - } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \muskip_set:Nn #1#2 { #1 ~ \etex_muexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \muskip_gset:Nn { \tex_global:D \muskip_set:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \muskip_gset:Nn #1#2 + { \tex_global:D #1 ~ \etex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_set:Nn { c } \cs_generate_variant:Nn \muskip_gset:Nn { c } % \end{macrocode} @@ -1972,9 +2041,11 @@ % } % All straightforward. % \begin{macrocode} +\__debug_patch:nnNNpn { \__debug_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 } \cs_generate_variant:Nn \muskip_set_eq:NN { Nc , cc } +\__debug_patch:nnNNpn { \__debug_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 } \cs_generate_variant:Nn \muskip_gset_eq:NN { Nc , cc } @@ -1988,30 +2059,20 @@ % \begin{macro}{\muskip_gsub:Nn, \muskip_gsub:cn} % Using |by| here deals with the (incorrect) case |\muskip123|. % \begin{macrocode} -\__debug_patch_args:nNNpn - { - {#1} - { - \__debug_chk_expr:nNnN {#2} \etex_muexpr:D - { \etex_mutoglue:D } \muskip_add:Nn - } - } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \muskip_add:Nn #1#2 { \tex_advance:D #1 by \etex_muexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \muskip_gadd:Nn { \tex_global:D \muskip_add:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \muskip_gadd:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by \etex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_add:Nn { c } \cs_generate_variant:Nn \muskip_gadd:Nn { c } -\__debug_patch_args:nNNpn - { - {#1} - { - \__debug_chk_expr:nNnN {#2} \etex_muexpr:D - { \etex_mutoglue:D } \muskip_sub:Nn - } - } +\@@_tmp:w \__debug_chk_var_local:N \cs_new_protected:Npn \muskip_sub:Nn #1#2 { \tex_advance:D #1 by - \etex_muexpr:D #2 \scan_stop: } -\cs_new_protected:Npn \muskip_gsub:Nn { \tex_global:D \muskip_sub:Nn } +\@@_tmp:w \__debug_chk_var_global:N +\cs_new_protected:Npn \muskip_gsub:Nn #1#2 + { \tex_global:D \tex_advance:D #1 by - \etex_muexpr:D #2 \scan_stop: } \cs_generate_variant:Nn \muskip_sub:Nn { c } \cs_generate_variant:Nn \muskip_gsub:Nn { c } % \end{macrocode} diff --git a/l3kernel/testfiles/m3int001.luatex.tlg b/l3kernel/testfiles/m3int001.luatex.tlg index b4806c77f4..8d15316744 100644 --- a/l3kernel/testfiles/m3int001.luatex.tlg +++ b/l3kernel/testfiles/m3int001.luatex.tlg @@ -95,8 +95,8 @@ TEST 6: incrementing and decrementing: expect -2 TEST 7: trying invalid variables: expect errors ============================================================ ! You can't use `the character -' after \advance. -\int_decr:N #1->\tex_advance:D #1- - \c_one +\int_decr:N ...hk_var_local:N #1\tex_advance:D #1- + \c_one l. ... } I'm forgetting what you said and not changing anything. ============================================================ diff --git a/l3kernel/testfiles/m3int001.ptex.tlg b/l3kernel/testfiles/m3int001.ptex.tlg index 8c6087cbd1..7b50e1681b 100644 --- a/l3kernel/testfiles/m3int001.ptex.tlg +++ b/l3kernel/testfiles/m3int001.ptex.tlg @@ -95,8 +95,8 @@ TEST 6: incrementing and decrementing: expect -2 TEST 7: trying invalid variables: expect errors ============================================================ ! You can't use `the character -' after \advance. -\int_decr:N #1->\tex_advance:D #1- - \c_one +\int_decr:N ...hk_var_local:N #1\tex_advance:D #1- + \c_one l. ... } I'm forgetting what you said and not changing anything. ! Missing $ inserted. diff --git a/l3kernel/testfiles/m3int001.tlg b/l3kernel/testfiles/m3int001.tlg index 67e325bd64..05cd9bd917 100644 --- a/l3kernel/testfiles/m3int001.tlg +++ b/l3kernel/testfiles/m3int001.tlg @@ -95,8 +95,8 @@ TEST 6: incrementing and decrementing: expect -2 TEST 7: trying invalid variables: expect errors ============================================================ ! You can't use `the character -' after \advance. -\int_decr:N #1->\tex_advance:D #1- - \c_one +\int_decr:N ...hk_var_local:N #1\tex_advance:D #1- + \c_one l. ... } I'm forgetting what you said and not changing anything. ! Missing $ inserted. diff --git a/l3kernel/testfiles/m3int001.uptex.tlg b/l3kernel/testfiles/m3int001.uptex.tlg index 445ad347e9..e5897bf88b 100644 --- a/l3kernel/testfiles/m3int001.uptex.tlg +++ b/l3kernel/testfiles/m3int001.uptex.tlg @@ -95,8 +95,8 @@ TEST 6: incrementing and decrementing: expect -2 TEST 7: trying invalid variables: expect errors ============================================================ ! You can't use `the character -' after \advance. -\int_decr:N #1->\tex_advance:D #1- - \c_one +\int_decr:N ...hk_var_local:N #1\tex_advance:D #1- + \c_one l. ... } I'm forgetting what you said and not changing anything. ============================================================ diff --git a/l3kernel/testfiles/m3int001.xetex.tlg b/l3kernel/testfiles/m3int001.xetex.tlg index bc5c6bd044..7c07f589ce 100644 --- a/l3kernel/testfiles/m3int001.xetex.tlg +++ b/l3kernel/testfiles/m3int001.xetex.tlg @@ -95,8 +95,8 @@ TEST 6: incrementing and decrementing: expect -2 TEST 7: trying invalid variables: expect errors ============================================================ ! You can't use `the character -' after \advance. -\int_decr:N #1->\tex_advance:D #1- - \c_one +\int_decr:N ...hk_var_local:N #1\tex_advance:D #1- + \c_one l. ... } I'm forgetting what you said and not changing anything. ============================================================ diff --git a/l3kernel/testfiles/m3skip001.lvt b/l3kernel/testfiles/m3skip001.lvt index f956260e9e..3a0e01bc10 100644 --- a/l3kernel/testfiles/m3skip001.lvt +++ b/l3kernel/testfiles/m3skip001.lvt @@ -32,134 +32,144 @@ } \TEST{(SKIP)~setting~and~zeroing;~expect~zero/nonzero/nonzero/zero}{ - { \skip_set:Nn \g_testa_skip {3pt plus 2pt minus 1pt} } + { \skip_set:Nn \l_tmpa_skip {3pt plus 2pt minus 1pt} } \skip_gset:Nn \g_testb_skip {3pt plus 2pt minus 1pt} - \TYPE{ \skip_use:N \g_testa_skip } - \TYPE{ \skip_use:N \g_testb_skip } - { \skip_zero:N \g_testb_skip } + \TYPE{ \skip_use:N \l_tmpa_skip } \TYPE{ \skip_use:N \g_testb_skip } + \skip_set_eq:NN \l_tmpa_skip \g_testb_skip + { \skip_zero:N \l_tmpa_skip } + \TYPE{ \skip_use:N \l_tmpa_skip } { \skip_gzero:N \g_testb_skip } \TYPE{ \skip_use:N \g_testb_skip } } \TEST{(DIM)~setting~and~zeroing;~expect~zero/nonzero/nonzero/zero}{ - { \dim_set:Nn \g_testa_dim {3pt} } + { \dim_set:Nn \l_tmpa_dim {3pt} } \dim_gset:Nn \g_testb_dim {3pt} - \TYPE{ \dim_use:N \g_testa_dim } - \TYPE{ \dim_use:N \g_testb_dim } - { \dim_zero:N \g_testb_dim } + \TYPE{ \dim_use:N \l_tmpa_dim } \TYPE{ \dim_use:N \g_testb_dim } + \dim_set_eq:NN \l_tmpa_dim \g_testb_dim + { \dim_zero:N \l_tmpa_dim } + \TYPE{ \dim_use:N \l_tmpa_dim } { \dim_gzero:N \g_testb_dim } \TYPE{ \dim_use:N \g_testb_dim } } \TEST{(MUSKIP)~setting;~expect~zero/nonzero}{ - { \muskip_set:Nn \g_testa_muskip {3mu} } + { \muskip_set:Nn \l_tmpa_muskip {3mu} } \muskip_gset:Nn \g_testb_muskip {3mu} - \TYPE{ \muskip_use:N \g_testa_muskip } + \TYPE{ \muskip_use:N \l_tmpa_muskip } \TYPE{ \muskip_use:N \g_testb_muskip } } \TEST{(SKIP)~Add~and~sub}{ - \skip_set:Nn \g_testa_skip { 0pt } - \skip_add:Nn \g_testa_skip { 3pt } - \TYPE{ \skip_use:N \g_testa_skip } - \skip_add:Nn \g_testa_skip { -3pt } - \TYPE{ \skip_use:N \g_testa_skip } - \skip_sub:Nn \g_testa_skip { -3pt } - \TYPE{ \skip_use:N \g_testa_skip } - \skip_sub:Nn \g_testa_skip { 3pt } - \TYPE{ \skip_use:N \g_testa_skip } + \skip_set:Nn \l_tmpa_skip { 0pt } + \skip_add:Nn \l_tmpa_skip { 3pt } + \TYPE{ \skip_use:N \l_tmpa_skip } + \skip_add:Nn \l_tmpa_skip { -3pt } + \TYPE{ \skip_use:N \l_tmpa_skip } + \skip_sub:Nn \l_tmpa_skip { -3pt } + \TYPE{ \skip_use:N \l_tmpa_skip } + \skip_sub:Nn \l_tmpa_skip { 3pt } + \TYPE{ \skip_use:N \l_tmpa_skip } } \TEST{(DIM)~Add~and~sub}{ - \dim_set:Nn \g_testa_dim { 0pt } - \dim_add:Nn \g_testa_dim { 3pt } - \TYPE{ \dim_use:N \g_testa_dim } - \dim_add:Nn \g_testa_dim { -3pt } - \TYPE{ \dim_use:N \g_testa_dim } - \dim_sub:Nn \g_testa_dim { -3pt } - \TYPE{ \dim_use:N \g_testa_dim } - \dim_sub:Nn \g_testa_dim { 3pt } - \TYPE{ \dim_use:N \g_testa_dim } + \dim_set:Nn \l_tmpa_dim { 0pt } + \dim_add:Nn \l_tmpa_dim { 3pt } + \TYPE{ \dim_use:N \l_tmpa_dim } + \dim_add:Nn \l_tmpa_dim { -3pt } + \TYPE{ \dim_use:N \l_tmpa_dim } + \dim_sub:Nn \l_tmpa_dim { -3pt } + \TYPE{ \dim_use:N \l_tmpa_dim } + \dim_sub:Nn \l_tmpa_dim { 3pt } + \TYPE{ \dim_use:N \l_tmpa_dim } } \TEST{(MUSKIP)~Add~and~sub}{ - \muskip_set:Nn \g_testa_muskip { 0mu } - \muskip_add:Nn \g_testa_muskip { 3mu } - \TYPE{ \muskip_use:N \g_testa_muskip } - \muskip_add:Nn \g_testa_muskip { -3mu } - \TYPE{ \muskip_use:N \g_testa_muskip } - \muskip_sub:Nn \g_testa_muskip { -3mu } - \TYPE{ \muskip_use:N \g_testa_muskip } - \muskip_sub:Nn \g_testa_muskip { 3mu } - \TYPE{ \muskip_use:N \g_testa_muskip } + \muskip_set:Nn \l_tmpa_muskip { 0mu } + \muskip_add:Nn \l_tmpa_muskip { 3mu } + \TYPE{ \muskip_use:N \l_tmpa_muskip } + \muskip_add:Nn \l_tmpa_muskip { -3mu } + \TYPE{ \muskip_use:N \l_tmpa_muskip } + \muskip_sub:Nn \l_tmpa_muskip { -3mu } + \TYPE{ \muskip_use:N \l_tmpa_muskip } + \muskip_sub:Nn \l_tmpa_muskip { 3mu } + \TYPE{ \muskip_use:N \l_tmpa_muskip } } \TEST{(SKIP)~Overflow~(BUT~\maxdimen~!=~maximum~skip?!)}{ - \skip_set:Nn \g_testa_skip {\c_max_dim plus \c_max_dim minus \c_max_dim} - \TYPE{ \skip_use:N \g_testa_skip } + \skip_set:Nn \l_tmpa_skip {\c_max_dim plus \c_max_dim minus \c_max_dim} + \TYPE{ \skip_use:N \l_tmpa_skip } { - \skip_add:Nn \g_testa_skip + \skip_add:Nn \l_tmpa_skip {\c_max_dim plus \c_max_dim minus \c_max_dim } } - \TYPE{ \skip_use:N \g_testa_skip\space (local~add~in~group)} + \TYPE{ \skip_use:N \l_tmpa_skip\space (local~add~in~group)} { - \skip_gadd:Nn \g_testa_skip + \skip_gset_eq:NN \g_tmpb_skip \l_tmpa_skip + \skip_gadd:Nn \g_tmpb_skip {\c_max_dim plus \c_max_dim minus \c_max_dim } } - \TYPE{ \skip_use:N \g_testa_skip } - \skip_add:Nn \g_testa_skip {1pt plus 1pt minus 1pt} - \TYPE{ \skip_use:N \g_testa_skip\space (overflow~by~1pt)} - \skip_add:Nn \g_testa_skip {16384pt plus 16384pt minus 16384pt} + \TYPE{ \skip_use:N \g_tmpb_skip } + \skip_set_eq:NN \l_tmpa_skip \g_tmpb_skip + \skip_add:Nn \l_tmpa_skip {1pt plus 1pt minus 1pt} + \TYPE{ \skip_use:N \l_tmpa_skip\space (overflow~by~1pt)} + \skip_add:Nn \l_tmpa_skip {16384pt plus 16384pt minus 16384pt} % 16384pt > \maxdimen = 16383.99998pt - \TYPE{ \skip_use:N \g_testa_skip\space (add~more~than~"max")} + \TYPE{ \skip_use:N \l_tmpa_skip\space (add~more~than~"max")} } \TEST{(SKIP)~Underflow}{ - \skip_set:Nn \g_testa_skip {-\c_max_dim plus -\c_max_dim minus -\c_max_dim} - \TYPE{ \skip_use:N \g_testa_skip } + \skip_set:Nn \l_tmpa_skip {-\c_max_dim plus -\c_max_dim minus -\c_max_dim} + \TYPE{ \skip_use:N \l_tmpa_skip } { - \skip_sub:Nn \g_testa_skip + \skip_sub:Nn \l_tmpa_skip {\c_max_dim plus \c_max_dim minus \c_max_dim} } - \TYPE{ \skip_use:N \g_testa_skip\space (local~sub~in~group)} + \TYPE{ \skip_use:N \l_tmpa_skip\space (local~sub~in~group)} { - \skip_gsub:Nn \g_testa_skip + \skip_gset_eq:NN \g_tmpb_skip \l_tmpa_skip + \skip_gsub:Nn \g_tmpb_skip {\c_max_dim plus \c_max_dim minus \c_max_dim} } - \TYPE{ \skip_use:N \g_testa_skip } - \skip_sub:Nn \g_testa_skip {1pt plus 1pt minus 1pt} - \TYPE{ \skip_use:N \g_testa_skip\space (overflow~by~1pt)} - \skip_sub:Nn \g_testa_skip {16384pt plus 16384pt minus 16384pt} + \TYPE{ \skip_use:N \g_tmpb_skip } + \skip_set_eq:NN \l_tmpa_skip \g_tmpb_skip + \skip_sub:Nn \l_tmpa_skip {1pt plus 1pt minus 1pt} + \TYPE{ \skip_use:N \l_tmpa_skip\space (overflow~by~1pt)} + \skip_sub:Nn \l_tmpa_skip {16384pt plus 16384pt minus 16384pt} % 16384pt > \maxdimen = 16383.99998pt - \TYPE{ \skip_use:N \g_testa_skip\space (sub~more~than~"max")} + \TYPE{ \skip_use:N \l_tmpa_skip\space (sub~more~than~"max")} } \TEST{(DIM)~Overflow~(BUT~\maxdimen~!=~maximum~dim?!)}{ - \dim_set:Nn \g_testa_dim \c_max_dim - \TYPE{ \dim_use:N \g_testa_dim } - { \dim_add:Nn \g_testa_dim {\c_max_dim} } - \TYPE{ \dim_use:N \g_testa_dim\space (local~add~in~group)} - { \dim_gadd:Nn \g_testa_dim {\c_max_dim} } - \TYPE{ \dim_use:N \g_testa_dim } - \dim_add:Nn \g_testa_dim {1pt} - \TYPE{ \dim_use:N \g_testa_dim\space (overflow~by~1pt)} - \dim_add:Nn \g_testa_dim {16384pt} % > 16383.99998pt - \TYPE{ \dim_use:N \g_testa_dim\space (add~more~than~16383.99998pt)} + \dim_set:Nn \l_tmpa_dim \c_max_dim + \TYPE{ \dim_use:N \l_tmpa_dim } + { \dim_add:Nn \l_tmpa_dim {\c_max_dim} } + \TYPE{ \dim_use:N \l_tmpa_dim\space (local~add~in~group)} + \dim_gset_eq:NN \g_tmpb_dim \l_tmpa_dim + { \dim_gadd:Nn \g_tmpb_dim {\c_max_dim} } + \TYPE{ \dim_use:N \g_tmpb_dim } + \dim_add:Nn \l_tmpa_dim {\c_max_dim} + \dim_add:Nn \l_tmpa_dim {1pt} + \TYPE{ \dim_use:N \l_tmpa_dim\space (overflow~by~1pt)} + \dim_add:Nn \l_tmpa_dim {16384pt} % > 16383.99998pt + \TYPE{ \dim_use:N \l_tmpa_dim\space (add~more~than~16383.99998pt)} } \TEST{(DIM)~Underflow}{ - \dim_set:Nn \g_testa_dim { -\c_max_dim } - \TYPE{ \dim_use:N \g_testa_dim } - { \dim_sub:Nn \g_testa_dim {\c_max_dim} } - \TYPE{ \dim_use:N \g_testa_dim\space (local~sub~in~group)} - { \dim_gsub:Nn \g_testa_dim {\c_max_dim} } - \TYPE{ \dim_use:N \g_testa_dim } - \dim_sub:Nn \g_testa_dim {1pt} - \TYPE{ \dim_use:N \g_testa_dim\space (overflow~by~1pt)} - \dim_sub:Nn \g_testa_dim {16384pt} % > 16383.99998pt - \TYPE{ \dim_use:N \g_testa_dim\space (sub~more~than~16383.99998pt)} + \dim_set:Nn \l_tmpa_dim { -\c_max_dim } + \TYPE{ \dim_use:N \l_tmpa_dim } + { \dim_sub:Nn \l_tmpa_dim {\c_max_dim} } + \TYPE{ \dim_use:N \l_tmpa_dim\space (local~sub~in~group)} + \dim_gset_eq:NN \g_tmpb_dim \l_tmpa_dim + { \dim_gsub:Nn \g_tmpb_dim {\c_max_dim} } + \TYPE{ \dim_use:N \g_tmpb_dim } + \dim_sub:Nn \l_tmpa_dim {\c_max_dim} + \dim_sub:Nn \l_tmpa_dim {1pt} + \TYPE{ \dim_use:N \l_tmpa_dim\space (overflow~by~1pt)} + \dim_sub:Nn \l_tmpa_dim {16384pt} % > 16383.99998pt + \TYPE{ \dim_use:N \l_tmpa_dim\space (sub~more~than~16383.99998pt)} } \TEST { Skip~safety } diff --git a/l3kernel/testfiles/m3skip002.lvt b/l3kernel/testfiles/m3skip002.lvt index 9a6d957c98..30a8f270b5 100644 --- a/l3kernel/testfiles/m3skip002.lvt +++ b/l3kernel/testfiles/m3skip002.lvt @@ -21,23 +21,23 @@ \skip_if_finite:nTF {0pt plus 10mm}{\TRUE}{\FALSE} \skip_if_finite:nTF {0pt plus 1fil}{\TRUE}{\FALSE} \skip_if_finite:nTF {0pt minus 1fil}{\TRUE}{\FALSE} - \skip_set:Nn \g_tmpa_skip {0pt plus 10mm minus 5mm} - \skip_if_finite:nTF {\g_tmpa_skip}{\TRUE}{\FALSE} - \skip_set:Nn \g_tmpa_skip {0pt plus 1fil} - \skip_if_finite:nTF {\g_tmpa_skip}{\TRUE}{\FALSE} - \skip_set:Nn \g_tmpa_skip {0pt plus 1 fil minus 2fill} - \skip_if_finite:nTF {\g_tmpa_skip}{\TRUE}{\FALSE} + \skip_set:Nn \l_tmpa_skip {0pt plus 10mm minus 5mm} + \skip_if_finite:nTF {\l_tmpa_skip}{\TRUE}{\FALSE} + \skip_set:Nn \l_tmpa_skip {0pt plus 1fil} + \skip_if_finite:nTF {\l_tmpa_skip}{\TRUE}{\FALSE} + \skip_set:Nn \l_tmpa_skip {0pt plus 1 fil minus 2fill} + \skip_if_finite:nTF {\l_tmpa_skip}{\TRUE}{\FALSE} \SEPARATOR \skip_if_finite:nT {0pt plus 1fil}{\ERROR} \skip_if_finite:nT {0pt minus 1fil}{\ERROR} - \skip_set:Nn \g_tmpa_skip {0pt plus 1fil} - \skip_if_finite:nT {\g_tmpa_skip}{\ERROR} - \skip_set:Nn \g_tmpa_skip {0pt plus 1 fil minus 2fill} - \skip_if_finite:nT {\g_tmpa_skip}{\ERROR} + \skip_set:Nn \l_tmpa_skip {0pt plus 1fil} + \skip_if_finite:nT {\l_tmpa_skip}{\ERROR} + \skip_set:Nn \l_tmpa_skip {0pt plus 1 fil minus 2fill} + \skip_if_finite:nT {\l_tmpa_skip}{\ERROR} \SEPARATOR \skip_if_finite:nF {0pt plus 10mm}{\ERROR} - \skip_set:Nn \g_tmpa_skip {0pt plus 10mm minus 5mm} - \skip_if_finite:nF {\g_tmpa_skip}{\ERROR} + \skip_set:Nn \l_tmpa_skip {0pt plus 10mm minus 5mm} + \skip_if_finite:nF {\l_tmpa_skip}{\ERROR} \SEPARATOR \skip_if_finite:nTF { (0pt plus 2fil + 1pt plus -1fil * 2) * 3 - 1mm } \TRUE \FALSE diff --git a/l3trial/l3tree/l3tree.dtx b/l3trial/l3tree/l3tree.dtx index 896066de95..4a516c32b8 100644 --- a/l3trial/l3tree/l3tree.dtx +++ b/l3trial/l3tree/l3tree.dtx @@ -151,8 +151,7 @@ % converting from integers to dimensions, this is the conversion % factor. % \begin{macrocode} -\dim_new:N \c_one_sp_dim -\dim_set:Nn \c_one_sp_dim { 1 sp } +\dim_const:Nn \c_one_sp_dim { 1 sp } % \end{macrocode} % \end{variable} %