diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3flag.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3flag.dtx | 77 |
1 files changed, 31 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx index 8c12450f32a..2923b1cbe62 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2017/05/29} +% \date{Released 2017/07/15} % % \maketitle % @@ -84,7 +84,7 @@ % Creates a new flag with a name given by \meta{flag name}, or raises % an error if the name is already taken. The \meta{flag name} may not % contain spaces. The declaration is global, but flags are always -% local variables. The \meta{flag} will initially have zero height. +% local variables. The \meta{flag} initially has zero height. % \end{function} % % \begin{function}{\flag_clear:n} @@ -193,8 +193,12 @@ % Undefine control sequences, starting from the |0| flag, upwards, % until reaching an undefined control sequence. We don't use % \cs{cs_undefine:c} because that would act globally. +% When the option \texttt{check-declarations} is used, check for the +% function defined by \cs{flag_new:n}. % \begin{macrocode} -\cs_new_protected:Npn \flag_clear:n { \@@_clear:wn 0 ; } +\__debug_patch:nnNw + { \exp_args:Nc \__chk_if_exist_var:N { flag~#1 } } { } +\cs_new_protected:Npn \flag_clear:n #1 { \@@_clear:wn 0 ; {#1} } \cs_new_protected:Npn \@@_clear:wn #1 ; #2 { \if_cs_exist:w flag~#2~#1 \cs_end: @@ -235,6 +239,27 @@ % % \subsection{Expandable flag commands} % +% \begin{macro}[EXP,aux]{\@@_chk_exist:n} +% Analogue of \cs{__chk_if_exist_var:N} for flags, and with an +% expandable error. We need to add checks by hand because flags are +% not implemented in terms of other variables. Not all functions need +% to be patched since some are defined in terms of others. +% \begin{macrocode} +%<*package> +\tex_ifodd:D \l@expl@enable@debug@bool + \cs_new:Npn \@@_chk_exist:n #1 + { + \flag_if_exist:nF {#1} + { + \__msg_kernel_expandable_error:nnn + { kernel } { bad-variable } { flag~#1~ } + } + } +\fi: +%</package> +% \end{macrocode} +% \end{macro} +% % \begin{macro}[EXP, pTF]{\flag_if_exist:n} % A flag exist if the corresponding trap \cs[no-index]{flag \meta{flag % name}:n} is defined. @@ -250,6 +275,7 @@ % \begin{macro}[EXP, pTF]{\flag_if_raised:n} % Test if the flag has a non-zero height, by checking the |0| control sequence. % \begin{macrocode} +\__debug_patch:nnNw { \@@_chk_exist:n {#1} } { } \prg_new_conditional:Npnn \flag_if_raised:n #1 { p , T , F , TF } { \if_cs_exist:w flag~#1~0 \cs_end: @@ -266,7 +292,8 @@ % Extract the value of the flag by going through all of the % control sequences starting from |0|. % \begin{macrocode} -\cs_new:Npn \flag_height:n { \@@_height_loop:wn 0; } +\__debug_patch:nnNw { \@@_chk_exist:n {#1} } { } +\cs_new:Npn \flag_height:n #1 { \@@_height_loop:wn 0; {#1} } \cs_new:Npn \@@_height_loop:wn #1 ; #2 { \if_cs_exist:w flag~#2~#1 \cs_end: @@ -292,48 +319,6 @@ % \end{macrocode} % \end{macro} % -% \subsection{Option check-declarations} -% -% \begin{macro}[EXP,aux]{\@@_chk_exist:n} -% In package mode, there is an option to check all variables used are -% defined. Since flags are not implemented in terms of other -% variables, we need to add checks by hand. Not all functions need to -% be patched because some are defined in terms of others. -% \begin{macrocode} -%<*package> -\tex_ifodd:D \l@expl@check@declarations@bool - \cs_set_protected:Npn \flag_clear:n #1 - { - \exp_args:Nc \__chk_if_exist_var:N { flag~#1 } - \@@_clear:wn 0 ; {#1} - } - \cs_set:Npn \@@_chk_exist:n #1 - { - \flag_if_exist:nF {#1} - { - \__msg_kernel_expandable_error:nnn - { kernel } { bad-variable } { flag~#1~ } - } - } - \cs_set:Npn \flag_height:n #1 - { - \@@_chk_exist:n {#1} - \@@_height_loop:wn 0; {#1} - } - \prg_set_conditional:Npnn \flag_if_raised:n #1 { p , T , F , TF } - { - \@@_chk_exist:n {#1} - \if_cs_exist:w flag~#1~0 \cs_end: - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -\fi: -%</package> -% \end{macrocode} -% \end{macro} -% % \begin{macrocode} %</initex|package> % \end{macrocode} |