[latex3-commits] [git/LaTeX3-latex3-latex3] master: Better error message for \intarray_new:Nn with negative size (aeeb055)

Bruno Le Floch bruno at le-floch.fr
Fri May 4 23:18:57 CEST 2018


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

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

commit aeeb0550e0e2efd4d057190392391d819af3c268
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Thu May 3 21:23:56 2018 +0200

    Better error message for \intarray_new:Nn with negative size


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

aeeb0550e0e2efd4d057190392391d819af3c268
 l3kernel/l3intarray.dtx                 |   17 ++++++++++++++---
 l3kernel/testfiles/m3expl001.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl001.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl001.tlg        |    1 +
 l3kernel/testfiles/m3expl001.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl001.xetex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl003.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl003.tlg        |    1 +
 l3kernel/testfiles/m3expl003.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.xetex.tlg  |    1 +
 l3kernel/testfiles/m3intarray001.tlg    |   17 +++++++++++++++++
 12 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index 9ccc892..be8520b 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -147,6 +147,11 @@
 %    \end{macrocode}
 % \end{variable}
 %
+%    \begin{macrocode}
+\__kernel_msg_new:nnn { kernel } { negative-intarray-size }
+  { Size~of~intarray~may~not~be~negative:~#1 }
+%    \end{macrocode}
+%
 % \begin{macro}{\intarray_new:Nn}
 %   Declare |#1| to be a font (arbitrarily |cmr10| at a never-used
 %   size).  Store the array's size as the \tn{hyphenchar} of that font
@@ -166,9 +171,15 @@
     \tex_global:D \tex_font:D #1
       = cmr10~at~ \g_@@_font_int \c_@@_sp_dim \scan_stop:
     \tex_hyphenchar:D #1 = \int_eval:n {#2} \scan_stop:
-    \int_compare:nNnT { \tex_hyphenchar:D #1 } > 0
-      { \tex_fontdimen:D \tex_hyphenchar:D #1 #1 = \c_zero_dim }
-    \int_step_inline:nn { 8 } { \tex_fontdimen:D ##1 #1 = \c_zero_dim }
+    \int_compare:nNnT { \intarray_count:N #1 } < 0
+      {
+        \__kernel_msg_error:nnx { kernel } { negative-intarray-size }
+          { \intarray_count:N #1 }
+      }
+    \int_compare:nNnT { \intarray_count:N #1 } > 0
+      { \__kernel_intarray_gset:Nnn #1 { \intarray_count:N #1 } { 0 } }
+    \int_step_inline:nn { 8 }
+      { \__kernel_intarray_gset:Nnn #1 {##1} { 0 } }
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 35706fe..36ab1a8 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -4223,6 +4223,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index b7d3726..cb219f6 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index fbe882e..6bb0add 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 15d318d..e8ffcae 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 00366cd..b6ba4f9 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -4197,6 +4197,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 35706fe..36ab1a8 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -4223,6 +4223,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index b7d3726..cb219f6 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index fbe882e..6bb0add 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 15d318d..e8ffcae 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -4477,6 +4477,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 00366cd..b6ba4f9 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -4197,6 +4197,7 @@ Defining \c__intarray_sp_dim on line ...
 \c__intarray_sp_dim=\dimen...
 Defining \g__intarray_font_int on line ...
 \g__intarray_font_int=\count...
+Defining message LaTeX/kernel/negative-intarray-size on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
 Defining \__intarray_bounds:NNnTF on line ...
diff --git a/l3kernel/testfiles/m3intarray001.tlg b/l3kernel/testfiles/m3intarray001.tlg
index 7a969ce..32fda6d 100644
--- a/l3kernel/testfiles/m3intarray001.tlg
+++ b/l3kernel/testfiles/m3intarray001.tlg
@@ -135,6 +135,23 @@ use \fontdimen immediately after the \font is loaded.
 0
 1234567
 Defining \g_testc_intarray on line ...
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/negative-intarray-size"
+! 
+! Size of intarray may not be negative: -1
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! Type <return> to continue.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| LaTeX does not know anything more about this error, sorry.
+| 
+| Try typing <return> to proceed.
+| If that doesn't work, type X <return> to quit.
+|...............................................
 ! Font \g_testb_intarray has only 17 fontdimen parameters.
 <recently read> \g_testb_intarray 
 l. ...  }





More information about the latex3-commits mailing list