[latex3-commits] [git/LaTeX3-latex3-latex3] master: Refactor an auxiliary (3a2095aa1)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Dec 3 17:27:34 CET 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/3a2095aa171bb696037b79aa83272c29a5a5683a
>---------------------------------------------------------------
commit 3a2095aa171bb696037b79aa83272c29a5a5683a
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Mon Jul 13 00:42:16 2020 +0200
Refactor an auxiliary
>---------------------------------------------------------------
3a2095aa171bb696037b79aa83272c29a5a5683a
l3kernel/l3regex.dtx | 64 ++++++++++++++++++++++++++--------------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 8b77be659..f81206439 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -1007,6 +1007,23 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_intarray_item:NnF, \@@_intarray_item_aux:nNF}
+% Item of intarray, with a default value.
+% \begin{macrocode}
+\cs_new:Npn \@@_intarray_item:NnF #1#2
+ { \exp_args:Nf \@@_intarray_item_aux:nNF { \int_eval:n {#2} } #1 }
+\cs_new:Npn \@@_intarray_item_aux:nNF #1#2
+ {
+ \if_int_compare:w #1 > \c_zero_int
+ \exp_after:wN \use_i:nn
+ \else:
+ \exp_after:wN \use_ii:nn
+ \fi:
+ { \__kernel_intarray_item:Nn #2 {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsubsection{Constants and variables}
%
% \begin{macro}{\@@_tmp:w}
@@ -5209,42 +5226,25 @@
% range is the difference between the brace balances at the
% \meta{max~pos} and \meta{min~pos}. These two positions are found in
% the corresponding \enquote{submatch} arrays.
-%^^A todo: understand when these int_compare are needed
% \begin{macrocode}
\cs_new_protected:Npn \@@_submatch_balance:n #1
{
\int_eval:n
- {
- \int_compare:nNnTF
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_end_intarray {#1}
- }
- = 0
- { 0 }
- {
- \__kernel_intarray_item:Nn \g_@@_balance_intarray
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_end_intarray {#1}
- }
- }
- -
- \int_compare:nNnTF
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_begin_intarray {#1}
- }
- = 0
- { 0 }
- {
- \__kernel_intarray_item:Nn \g_@@_balance_intarray
- {
- \__kernel_intarray_item:Nn
- \g_@@_submatch_begin_intarray {#1}
- }
- }
- }
+ {
+ \@@_intarray_item:NnF \g_@@_balance_intarray
+ {
+ \__kernel_intarray_item:Nn
+ \g_@@_submatch_end_intarray {#1}
+ }
+ { 0 }
+ -
+ \@@_intarray_item:NnF \g_@@_balance_intarray
+ {
+ \__kernel_intarray_item:Nn
+ \g_@@_submatch_begin_intarray {#1}
+ }
+ { 0 }
+ }
}
% \end{macrocode}
% \end{macro}
More information about the latex3-commits
mailing list.