[latex3-commits] [latex3/latex3] main: Always run invalid indentifier checks on str (7e6bb4d99)

github at latex-project.org github at latex-project.org
Thu Oct 26 18:05:45 CEST 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/7e6bb4d99d13e1c5c89f4a56fa5a9768f2ce4401

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

commit 7e6bb4d99d13e1c5c89f4a56fa5a9768f2ce4401
Author: Yukai Chou <muzimuzhi at gmail.com>
Date:   Thu Oct 26 07:17:17 2023 +0800

    Always run invalid indentifier checks on str


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

7e6bb4d99d13e1c5c89f4a56fa5a9768f2ce4401
 l3kernel/l3fp-symbolic.dtx | 67 +++++++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/l3kernel/l3fp-symbolic.dtx b/l3kernel/l3fp-symbolic.dtx
index 2d273fd2c..0a87ddae4 100644
--- a/l3kernel/l3fp-symbolic.dtx
+++ b/l3kernel/l3fp-symbolic.dtx
@@ -440,6 +440,7 @@
 %   loop through letters in |#1|: if it is not a letter, break the loop
 %   and return \texttt{true}.  If the end of the loop is reached
 %   without finding any non-letter, return \texttt{false}.
+%   Note |#1| must be a str (i.e., resulted from \cs{tl_to_str:n}).
 %    \begin{macrocode}
 \prg_new_protected_conditional:Npnn
     \@@_id_if_invalid:n #1 { T , F , TF }
@@ -447,10 +448,10 @@
     \tl_if_empty:nTF {#1}
       { \prg_return_true: }
       {
-        \tl_if_in:onTF { \tl_to_str:n {#1} } { ~ }
+        \tl_if_in:nnTF { #1 } { ~ }
           { \prg_return_true: }
           {
-            \exp_after:wN \@@_id_if_invalid_aux:N \tl_to_str:n {#1}
+            \@@_id_if_invalid_aux:N #1
               { ? \prg_break:n \prg_return_false: }
             \prg_break_point:
           }
@@ -547,14 +548,16 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \fp_clear_variable:n #1
   {
-    \@@_id_if_invalid:nTF {#1}
-      { \msg_error:nnn { fp } { id-invalid } {#1} }
-      { \exp_args:No \@@_clear_variable:n { \tl_to_str:n {#1} } }
+    \exp_args:No \@@_clear_variable:n { \tl_to_str:n {#1} }
   }
 \cs_new_protected:Npn \@@_clear_variable:n #1
   {
-    \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D
-    \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1}
+    \@@_id_if_invalid:nTF {#1}
+      { \msg_error:nnn { fp } { id-invalid } {#1} }
+      {
+        \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D
+        \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1}
+      }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -568,20 +571,22 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \fp_new_variable:n #1
   {
-    \@@_id_if_invalid:nTF {#1}
-      { \msg_error:nnn { fp } { id-invalid } {#1} }
-      { \exp_args:No \@@_new_variable:n { \tl_to_str:n {#1} } }
+    \exp_args:No \@@_new_variable:n { \tl_to_str:n {#1} }
   }
 \cs_new_protected:Npn \@@_new_variable:n #1
   {
-    \cs_if_exist:cT { @@_parse_word_#1:N }
+    \@@_id_if_invalid:nTF {#1}
+      { \msg_error:nnn { fp } { id-invalid } {#1} }
       {
-        \msg_error:nnn
-          { fp } { id-already-defined } {#1}
-        \cs_undefine:c { @@_parse_word_#1:N }
-        \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D
+        \cs_if_exist:cT { @@_parse_word_#1:N }
+        {
+          \msg_error:nnn
+            { fp } { id-already-defined } {#1}
+          \cs_undefine:c { @@_parse_word_#1:N }
+          \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D
+        }
+      \@@_variable_set_parsing:Nn \cs_gset_eq:NN {#1}
       }
-    \@@_variable_set_parsing:Nn \cs_gset_eq:NN {#1}
   }
 %    \end{macrocode}
 % \end{macro}
@@ -606,24 +611,26 @@
 \flag_new:n { @@_symbolic }
 \cs_new_protected:Npn \fp_set_variable:nn #1
   {
-    \@@_id_if_invalid:nTF {#1}
-      { \msg_error:nnn { fp } { id-invalid } {#1} }
-      { \exp_args:No \@@_set_variable:nn { \tl_to_str:n {#1} } }
+    \exp_args:No \@@_set_variable:nn { \tl_to_str:n {#1} }
   }
 \cs_new_protected:Npn \@@_set_variable:nn #1#2
   {
-    \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1}
-    \fp_set:Nn \l_@@_symbolic_fp {#2}
-    \cs_set_nopar:cpn { l_@@_variable_#1_fp }
-      { \flag_ensure_raised:n { @@_symbolic } \c_nan_fp }
-    \flag_clear:n { @@_symbolic }
-    \fp_set:cn { l_@@_variable_#1_fp } { \l_@@_symbolic_fp }
-    \flag_if_raised:nT { @@_symbolic }
+    \@@_id_if_invalid:nTF {#1}
+      { \msg_error:nnn { fp } { id-invalid } {#1} }
       {
-        \msg_error:nneee { fp } { id-loop }
-          { \tl_to_str:n {#1} }
-          { \tl_to_str:n {#2} }
-          { \fp_to_tl:N \l_@@_symbolic_fp }
+        \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1}
+        \fp_set:Nn \l_@@_symbolic_fp {#2}
+        \cs_set_nopar:cpn { l_@@_variable_#1_fp }
+          { \flag_ensure_raised:n { @@_symbolic } \c_nan_fp }
+        \flag_clear:n { @@_symbolic }
+        \fp_set:cn { l_@@_variable_#1_fp } { \l_@@_symbolic_fp }
+        \flag_if_raised:nT { @@_symbolic }
+          {
+            \msg_error:nneee { fp } { id-loop }
+              { #1 }
+              { \tl_to_str:n {#2} }
+              { \fp_to_tl:N \l_@@_symbolic_fp }
+          }
       }
   }
 %    \end{macrocode}





More information about the latex3-commits mailing list.