[latex3-commits] [git/LaTeX3-latex3-latex3] master: Evaluate int constants only once (fixes #861) (eac3d1d0b)

Joseph Wright joseph.wright at morningstar2.co.uk
Sat Feb 27 18:33:53 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/eac3d1d0b9e08bd138291f088783a48d48e2c3e1

>---------------------------------------------------------------

commit eac3d1d0b9e08bd138291f088783a48d48e2c3e1
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sat Feb 27 17:33:53 2021 +0000

    Evaluate int constants only once (fixes #861)


>---------------------------------------------------------------

eac3d1d0b9e08bd138291f088783a48d48e2c3e1
 l3kernel/CHANGELOG.md |  3 +++
 l3kernel/l3int.dtx    | 16 ++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 1fefcf3df..1b3b84c59 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Fixed
+- Evalutate integer constants only once (issue#861)
+
 ### Deprecated
 - `l3docstrip` converted to a stub which simply loads DocStrip: use
    the latter directly 
diff --git a/l3kernel/l3int.dtx b/l3kernel/l3int.dtx
index 85da3a199..1e6217db9 100644
--- a/l3kernel/l3int.dtx
+++ b/l3kernel/l3int.dtx
@@ -1282,6 +1282,7 @@
 % \end{macro}
 %
 % \begin{macro}{\int_const:Nn, \int_const:cn}
+% \begin{macro}{\@@_const:nN}
 % \begin{macro}{\@@_constdef:Nw}
 % \begin{variable}{\c_@@_max_constdef_int}
 % \UnitTested
@@ -1293,24 +1294,26 @@
 %   enabled) this runs some checks that constants would fail.
 %    \begin{macrocode}
 \cs_new_protected:Npn \int_const:Nn #1#2
+  { \exp_args:Ne \@@_const:nN { \int_eval:n {#2} } #1 }
+\cs_new_protected:Npn \@@_const:nN #1#2
   {
-    \int_compare:nNnTF {#2} < \c_zero_int
+    \int_compare:nNnTF {#1} < \c_zero_int
       {
-        \int_new:N #1
+        \int_new:N #2
         \tex_global:D
       }
       {
-        \int_compare:nNnTF {#2} > \c_@@_max_constdef_int
+        \int_compare:nNnTF {#1} > \c_@@_max_constdef_int
           {
-            \int_new:N #1
+            \int_new:N #2
             \tex_global:D
           }
           {
-            \__kernel_chk_if_free_cs:N #1
+            \__kernel_chk_if_free_cs:N #2
             \tex_global:D \@@_constdef:Nw
           }
       }
-    #1 = \@@_eval:w #2 \@@_eval_end:
+    #2 = \@@_eval:w #1 \@@_eval_end:
   }
 \cs_generate_variant:Nn \int_const:Nn { c }
 \if_int_odd:w 0
@@ -1329,6 +1332,7 @@
 % \end{variable}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\int_zero:N, \int_zero:c}
 % \UnitTested





More information about the latex3-commits mailing list.