[latex3-commits] [l3svn] r7108 - Allow inf, infinity, nan with any mixed uppercase/lowercase

noreply at latex-project.org noreply at latex-project.org
Sat Apr 15 05:13:09 CEST 2017


Author: bruno
Date: 2017-04-15 05:13:08 +0200 (Sat, 15 Apr 2017)
New Revision: 7108

Modified:
   trunk/l3kernel/l3fp-parse.dtx
   trunk/l3kernel/testfiles/m3expl001.luatex.tlg
   trunk/l3kernel/testfiles/m3expl001.ptex.tlg
   trunk/l3kernel/testfiles/m3expl001.tlg
   trunk/l3kernel/testfiles/m3expl001.uptex.tlg
   trunk/l3kernel/testfiles/m3expl001.xetex.tlg
   trunk/l3kernel/testfiles/m3expl003.luatex.tlg
   trunk/l3kernel/testfiles/m3expl003.ptex.tlg
   trunk/l3kernel/testfiles/m3expl003.tlg
   trunk/l3kernel/testfiles/m3expl003.uptex.tlg
   trunk/l3kernel/testfiles/m3expl003.xetex.tlg
   trunk/l3kernel/testfiles/m3fp-parse002.lvt
   trunk/l3kernel/testfiles/m3fp-parse002.tlg
Log:
Allow inf, infinity, nan with any mixed uppercase/lowercase

This is required by IEEE754-2008.


Modified: trunk/l3kernel/l3fp-parse.dtx
===================================================================
--- trunk/l3kernel/l3fp-parse.dtx	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/l3fp-parse.dtx	2017-04-15 03:13:08 UTC (rev 7108)
@@ -986,15 +986,23 @@
 %   the unknown word could be a mistyped function as well as a mistyped
 %   constant, so there is no way to tell whether to look for arguments;
 %   we do not.
+%   The standard requires \enquote{inf} and \enquote{infinity} and
+%   \enquote{nan} to be recognized regardless of case, but we probably
+%   don't want to allow every \pkg{l3fp} word to have an arbitrary
+%   mixture of lower and upper case, so we test and use a
+%   differently-named control sequence.
 %    \begin{macrocode}
 \cs_new:Npn \@@_parse_word:Nw #1#2;
   {
     \cs_if_exist_use:cF { @@_parse_word_#2:N }
       {
-        \__msg_kernel_expandable_error:nnn
-          { kernel } { unknown-fp-word } {#2}
-        \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
-        \@@_parse_infix:NN
+        \cs_if_exist_use:cF { @@_parse_caseless_ \str_fold_case:n {#2} :N }
+          {
+            \__msg_kernel_expandable_error:nnn
+              { kernel } { unknown-fp-word } {#2}
+            \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w
+            \@@_parse_infix:NN
+          }
       }
       #1
   }
@@ -1924,6 +1932,21 @@
 %
 % \begin{macro}[aux, EXP]
 %   {
+%     \@@_parse_caseless_inf:N,
+%     \@@_parse_caseless_infinity:N,
+%     \@@_parse_caseless_nan:N
+%   }
+%   Copies of \cs[no-index]{@@_parse_word_\ldots{}:N} commands, to allow
+%   arbitrary case as mandated by the standard.
+%    \begin{macrocode}
+\cs_new_eq:NN \@@_parse_caseless_inf:N \@@_parse_word_inf:N
+\cs_new_eq:NN \@@_parse_caseless_infinity:N \@@_parse_word_inf:N
+\cs_new_eq:NN \@@_parse_caseless_nan:N \@@_parse_word_nan:N
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[aux, EXP]
+%   {
 %     \@@_parse_word_pt:N , \@@_parse_word_in:N ,
 %     \@@_parse_word_pc:N , \@@_parse_word_cm:N , \@@_parse_word_mm:N ,
 %     \@@_parse_word_dd:N , \@@_parse_word_cc:N , \@@_parse_word_nd:N ,

Modified: trunk/l3kernel/testfiles/m3expl001.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3722,6 +3722,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3710,6 +3710,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl001.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3710,6 +3710,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3710,6 +3710,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3720,6 +3720,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3723,6 +3723,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3711,6 +3711,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl003.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3711,6 +3711,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3711,6 +3711,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -3721,6 +3721,9 @@
 Defining \__fp_parse_word_deg:N on line ...
 Defining \__fp_parse_word_true:N on line ...
 Defining \__fp_parse_word_false:N on line ...
+Defining \__fp_parse_caseless_inf:N on line ...
+Defining \__fp_parse_caseless_infinity:N on line ...
+Defining \__fp_parse_caseless_nan:N on line ...
 Defining \__fp_parse_word_pt:N on line ...
 Defining \__fp_parse_word_in:N on line ...
 Defining \__fp_parse_word_pc:N on line ...

Modified: trunk/l3kernel/testfiles/m3fp-parse002.lvt
===================================================================
--- trunk/l3kernel/testfiles/m3fp-parse002.lvt	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3fp-parse002.lvt	2017-04-15 03:13:08 UTC (rev 7108)
@@ -128,6 +128,21 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\TEST { Variants~of~infinity~and~nan }
+  {
+    \fp_log:n { inF }
+    \fp_log:n { -infty }
+    \fp_log:n { infinity }
+    \fp_log:n { -infInItY }
+    \fp_log:n { -NAN }
+    \fp_log:n { nAn }
+    \fp_log:n { -qnan }
+    \fp_log:n { snan }
+    \fp_log:n { nan123 }
+  }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 % \TESTEXP { Indexing }
 %   {
 %     \fp_eval:n { (\1,\2\3,\4)[\0,\2][\1,\0] + \.\2 } \NEWLINE

Modified: trunk/l3kernel/testfiles/m3fp-parse002.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3fp-parse002.tlg	2017-04-15 03:09:46 UTC (rev 7107)
+++ trunk/l3kernel/testfiles/m3fp-parse002.tlg	2017-04-15 03:13:08 UTC (rev 7108)
@@ -245,3 +245,52 @@
 > 3^\exp_after:wN \tex_wd:D \tex_the:D \l_tmpa_box *2=486.
 > 3\exp_after:wN \tex_ht:D \tex_the:D \l_tmpa_box +2=32.
 ============================================================
+============================================================
+TEST 9: Variants of infinity and nan
+============================================================
+> inF=inf.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Unknown fp word infty.
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+> -infty=nan.
+> infinity=inf.
+> -infInItY=-inf.
+> -NAN=nan.
+> nAn=nan.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Unknown fp word qnan.
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+> -qnan=nan.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Unknown fp word snan.
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+> snan=nan.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Missing * inserted.
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+> nan123=nan.
+============================================================



More information about the latex3-commits mailing list