[latex3-commits] [git/LaTeX3-latex3-latex3] master: Improve support for uppercase E for exponents (9a453a44f)

Bruno Le Floch bruno at le-floch.fr
Sun Jul 12 19:26:31 CEST 2020


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

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

commit 9a453a44fb62588ba8805da6a0bc6df1128d1d8c
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sat Apr 15 08:50:59 2017 -0400

    Improve support for uppercase E for exponents
    
    This avoids the invalid 2Exp(1) turning into the valid 2exp(1)
    accidentally.


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

9a453a44fb62588ba8805da6a0bc6df1128d1d8c
 l3kernel/l3fp-parse.dtx              | 15 ++++++++-------
 l3kernel/testfiles/m3fp-parse002.lvt |  6 ++++++
 l3kernel/testfiles/m3fp-parse002.tlg | 15 +++++++++++++++
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/l3kernel/l3fp-parse.dtx b/l3kernel/l3fp-parse.dtx
index 28257218e..cb0e481ac 100644
--- a/l3kernel/l3fp-parse.dtx
+++ b/l3kernel/l3fp-parse.dtx
@@ -1643,7 +1643,7 @@
 % \end{macro}
 %
 % \begin{macro}[rEXP]
-%   {\@@_parse_exponent:N, \@@_parse_exponent_aux:N}
+%   {\@@_parse_exponent:N, \@@_parse_exponent_aux:NN}
 %   This function should be called within an \cs{int_value:w}
 %   expansion (or within an integer expression).  It leaves digits of the
 %   exponent behind it in the input stream, and terminates the expansion
@@ -1657,22 +1657,23 @@
 \cs_new:Npn \@@_parse_exponent:N #1
   {
     \if:w e \if:w E \exp_not:N #1 e \else: \exp_not:N #1 \fi:
-      \exp_after:wN \@@_parse_exponent_aux:N
+      \exp_after:wN \@@_parse_exponent_aux:NN
+      \exp_after:wN #1
       \exp:w
     \else:
       0 \@@_parse_return_semicolon:w #1
     \fi:
     \@@_parse_expand:w
   }
-\cs_new:Npn \@@_parse_exponent_aux:N #1
+\cs_new:Npn \@@_parse_exponent_aux:NN #1#2
   {
-    \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #1
-                0 \else: `#1 \fi: > `9 \exp_stop_f:
-      0 \exp_after:wN ; \exp_after:wN e
+    \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #2
+                0 \else: `#2 \fi: > `9 \exp_stop_f:
+      0 \exp_after:wN ; \exp_after:wN #1
     \else:
       \exp_after:wN \@@_parse_exponent_sign:N
     \fi:
-    #1
+    #2
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3fp-parse002.lvt b/l3kernel/testfiles/m3fp-parse002.lvt
index 543b08968..ef0a05dfa 100644
--- a/l3kernel/testfiles/m3fp-parse002.lvt
+++ b/l3kernel/testfiles/m3fp-parse002.lvt
@@ -193,6 +193,12 @@
     \fp_to_tl:n { \infty , 2 , \pi }
   }
 
+\TEST { Exponent~with~E }
+  {
+    \fp_log:n { 1.2E-3 }
+    \fp_log:n { 1.2Exp(1) }
+  }
+
 % \TESTEXP { Indexing }
 %   {
 %     \fp_eval:n { (\1,\2\3,\4)[\0,\2][\1,\0] + \.\2 } \NEWLINE
diff --git a/l3kernel/testfiles/m3fp-parse002.tlg b/l3kernel/testfiles/m3fp-parse002.tlg
index 059db7746..ba2003973 100644
--- a/l3kernel/testfiles/m3fp-parse002.tlg
+++ b/l3kernel/testfiles/m3fp-parse002.tlg
@@ -473,3 +473,18 @@ spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 (nan, 2, nan)
 ============================================================
+============================================================
+TEST 14: Exponent with E
+============================================================
+> 1.2E-3=0.0012.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Unknown fp word Exp.
+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.
+> 1.2Exp(1)=nan.
+============================================================





More information about the latex3-commits mailing list.