Skip to content

Commit

Permalink
bruno-suggested improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wspr committed Feb 4, 2019
1 parent 2c2f898 commit da4d3d6
Show file tree
Hide file tree
Showing 19 changed files with 656 additions and 385 deletions.
42 changes: 24 additions & 18 deletions l3kernel/l3basics.dtx
Expand Up @@ -751,6 +751,8 @@
% Unlike \cs{use:c}, these functions check for the existence of the control sequence
% when the \texttt{check-declarations} option is in effect.
% This affords a level of safety when testing.
% When checking, these functions consider \cs{relax} and \cs{scan_stop:} to be invalid
% and throw an error.
% \end{function}
%
% \begin{function}[noTF, EXP, added = 2012-11-10]
Expand Down Expand Up @@ -1754,7 +1756,7 @@
\@@_suspended:T \use_none:nnn
\cs_if_exist:NF ##1
{
\__kernel_msg_error:nnx { kernel } { command-not-defined }
\__kernel_msg_error:nnx { kernel } { command-erroneous }
{ \token_to_str:N ##1 }
}
}
Expand All @@ -1764,28 +1766,32 @@
\cs_if_exist:NF ##1
{
\__kernel_msg_expandable_error:nnn
{ kernel } { command-not-defined } { ##1 }
{ kernel } { command-erroneous } { ##1 }
}
}
\cs_set:Npn \__kernel_chk_exp_var_exist:N ##1
{
\@@_suspended:T \use_none:nnn
\cs_if_exist:NF ##1
{
\__kernel_msg_expandable_error:nnn
{ kernel } { non-declared-variable } { ##1 }
}
}
\cs_set:Npn \__kernel_chk_exp_var_exist:NT ##1 ##2
\cs_set:Npn \__kernel_chk_exp_var_exist:NTF ##1 ##2 ##3
{
\@@_suspended:T \use_none:nnnn
\cs_if_exist:NTF ##1
{ ##2 }
{
##3
\__kernel_msg_expandable_error:nnn
{ kernel } { non-declared-variable } { ##1 }
}
}
\cs_set:Npn \__kernel_chk_exp_var_exist:NT ##1 ##2
{
\__kernel_chk_exp_var_exist:NTF ##1 { ##2 } { }
}
\cs_set:Npn \__kernel_chk_exp_var_exist:NF ##1 ##2
{
\__kernel_chk_exp_var_exist:NTF ##1 { } { ##2 }
}
\cs_set:Npn \__kernel_chk_exp_var_exist:N ##1
{
\__kernel_chk_exp_var_exist:NTF ##1 { } { }
}
\cs_set_protected:Npn \__kernel_chk_var_scope:NN
{
\@@_suspended:T \use_none:nnn
Expand All @@ -1811,6 +1817,8 @@
\cs_set:Npn \__kernel_chk_exp_cs_exist:N ##1 { }
\cs_set:Npn \__kernel_chk_exp_var_exist:N ##1 { }
\cs_set:Npn \__kernel_chk_exp_var_exist:NT ##1##2 { ##2 }
\cs_set:Npn \__kernel_chk_exp_var_exist:NF ##1##2 { }
\cs_set:Npn \__kernel_chk_exp_var_exist:NTF ##1##2##3 { ##2 }
\cs_set_protected:Npn \__kernel_chk_var_local:N ##1 { }
\cs_set_protected:Npn \__kernel_chk_var_global:N ##1 { }
\cs_set_protected:Npn \__kernel_chk_var_scope:NN ##1##2 { }
Expand All @@ -1823,8 +1831,8 @@
{ \exp_args:Nc \__kernel_chk_exp_cs_exist:N }
\cs_set:Npn \__kernel_chk_exp_var_exist:c
{ \exp_args:Nc \__kernel_chk_exp_var_exist:N }
\cs_set:Npn \__kernel_chk_exp_var_exist:cT
{ \exp_args:Nc \__kernel_chk_exp_var_exist:NT }
\cs_set:Npn \__kernel_chk_exp_var_exist:cF
{ \exp_args:Nc \__kernel_chk_exp_var_exist:NF }
\tex_ifodd:D \l@expl@check@declarations@bool
\use:c { @@_check-declarations_on: }
\else:
Expand Down Expand Up @@ -2863,13 +2871,11 @@
{
\cs_set:Npn \cs_use:N #1
{
\__kernel_chk_exp_cs_exist:N #1
#1
\exp:w \__kernel_chk_exp_cs_exist:N #1 \exp_after:wN \exp_end: #1
}
\cs_set:Npn \cs_use:c #1
{
\__kernel_chk_exp_cs_exist:c {#1}
\cs:w #1 \cs_end:
\cs:w \__kernel_chk_exp_cs_exist:c {#1} #1 \cs_end:
}
}
{
Expand Down
5 changes: 3 additions & 2 deletions l3kernel/l3int.dtx
Expand Up @@ -1443,8 +1443,9 @@
{
\cs_new:Npn \int_use:c #1
{
\__kernel_chk_exp_var_exist:c {#1}
\tex_the:D \cs:w #1 \cs_end:
\tex_the:D
\__kernel_chk_exp_var_exist:cF {#1} { \c_zero_int }
\cs:w #1 \cs_end:
}
}
{
Expand Down
7 changes: 7 additions & 0 deletions l3kernel/l3msg.dtx
Expand Up @@ -1699,6 +1699,13 @@
LaTeX~has~been~asked~to~use~a~control~sequence~'#1':\\
this~has~not~been~defined~yet.
}
\__kernel_msg_new:nnnn { kernel } { command-erroneous }
{ Control~sequence~#1~undefined~or~invalid. }
{
\c_@@_coding_error_text_tl
LaTeX~has~been~asked~to~use~a~control~sequence~'#1':\\
this~has~not~been~defined~yet~or~is~invalid.
}
\__kernel_msg_new:nnn { kernel } { deprecated-command }
{
The~deprecated~command~'#2'~has~been~or~will~be~removed~on~#1.
Expand Down
15 changes: 9 additions & 6 deletions l3kernel/l3skip.dtx
Expand Up @@ -1671,8 +1671,9 @@
{
\cs_new:Npn \dim_use:c #1
{
\__kernel_chk_exp_var_exist:c {#1}
\tex_the:D \cs:w #1 \cs_end:
\tex_the:D
\__kernel_chk_exp_var_exist:cF {#1} { \c_zero_dim }
\cs:w #1 \cs_end:
}
}
{
Expand Down Expand Up @@ -2026,8 +2027,9 @@
{
\cs_new:Npn \skip_use:c #1
{
\__kernel_chk_exp_var_exist:c {#1}
\tex_the:D \cs:w #1 \cs_end:
\tex_the:D
\__kernel_chk_exp_var_exist:cF {#1} { \c_zero_skip }
\cs:w #1 \cs_end:
}
}
{
Expand Down Expand Up @@ -2306,8 +2308,9 @@
{
\cs_new:Npn \muskip_use:c #1
{
\__kernel_chk_exp_var_exist:c {#1}
\tex_the:D \cs:w #1 \cs_end:
\tex_the:D
\__kernel_chk_exp_var_exist:cF {#1} { \c_zero_muskip }
\cs:w #1 \cs_end:
}
}
{
Expand Down
14 changes: 7 additions & 7 deletions l3kernel/l3tl.dtx
Expand Up @@ -2391,17 +2391,17 @@
{
\cs_new:Npn \tl_use:N #1
{
\tl_if_exist:NTF #1 {#1}
{
\__kernel_msg_expandable_error:nnn
{ kernel } { bad-variable } {#1}
}
\exp:w \__kernel_chk_exp_var_exist:N #1 \exp_after:wN \exp_end: #1
}
\cs_new:Npn \tl_use:c #1
{
\cs:w \__kernel_chk_exp_var_exist:c {#1} #1 \cs_end:
}
}
{
\cs_new:Npn \tl_use:N #1 {#1}
\cs_new_eq:NN \tl_use:N \cs_use:N
\cs_new_eq:NN \tl_use:c \cs_use:c
}
\cs_generate_variant:Nn \tl_use:N { c }
% \end{macrocode}
% \end{macro}
%
Expand Down

0 comments on commit da4d3d6

Please sign in to comment.