[latex3-commits] [git/LaTeX3-latex3-latex3] main: Refactor an internal (db1a06f41)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed May 25 15:01:57 CEST 2022


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

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

commit db1a06f41ec317a18d0f1840a2d786f9fca06e98
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed May 25 14:01:57 2022 +0100

    Refactor an internal
    
    This will help with the introduction of automatic key
    generation.


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

db1a06f41ec317a18d0f1840a2d786f9fca06e98
 l3packages/xtemplate/testfiles/xtemplate003.tlg | 13 ++++-
 l3packages/xtemplate/xtemplate.dtx              | 68 +++++++++++--------------
 2 files changed, 42 insertions(+), 39 deletions(-)

diff --git a/l3packages/xtemplate/testfiles/xtemplate003.tlg b/l3packages/xtemplate/testfiles/xtemplate003.tlg
index 9900b9688..52acd6372 100644
--- a/l3packages/xtemplate/testfiles/xtemplate003.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate003.tlg
@@ -272,11 +272,20 @@ l. ...}
 ============================================================
 TEST 14: Testing code interface: missing var declarations
 ============================================================
-! Package xtemplate Error: Incorrect variable description 'glabol\l_Y_tl '.
+! Undefined control sequence.
+<argument> \MARK 
+                 \msg_error:nnx {xtemplate}{bad-variable}{glabol\l_Y_tl }
+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.
+! Package xtemplate Error: Incorrect variable description 'glabol'.
 For immediate help type H <return>.
  ...                                              
 l. ...}
-The argument 'glabol\l_Y_tl ' is not of the form
+The argument 'glabol' is not of the form
 '<variable>'
 or 
 'global <variable>'.
diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index a2293af29..e550aca02 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -1584,66 +1584,60 @@
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\@@_parse_vars_elt_aux:n}
+% \begin{macro}{\@@_parse_vars_elt_aux:nn}
 % \begin{macro}{\@@_parse_vars_elt_aux:w}
-%   There now needs to be some sanity checking on the variable name
-%   given. This does not apply for \texttt{choice} or
-%   \texttt{code} \enquote{variables}, but in all other cases the variable
-%   needs to exist. Also, the only prefix acceptable is \texttt{global}. So
-%   there are a few related checks to make.
+%   Split off any leading \texttt{global} and they look for the way to
+%   implement.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_parse_vars_elt_aux:n #1
   {
-    \str_if_eq:onTF \l_@@_keytype_tl { choice }
-      { \@@_implement_choices:n {#1} }
+    \@@_parse_vars_elt_aux:w #1 global global \s_@@_stop {#1}
+  }
+\cs_new_protected:Npn \@@_parse_vars_elt_aux:w
+  #1 global #2 global #3 \s_@@_stop #4
+  {
+    \tl_if_blank:nTF {#3}
+      { \@@_parse_vars_elt_aux:nn { } {#1} }
       {
-        \str_if_eq:onTF \l_@@_keytype_tl { code }
-          {
-            \prop_put:Non \l_@@_vars_prop
-              \l_@@_key_name_tl {#1}
-          }
+        \tl_if_blank:nTF {#1}
           {
-            \tl_if_single:nTF {#1}
-              {
-                \cs_if_exist:NF #1
-                  { \@@_create_variable:N #1 }
-                \prop_put:Non \l_@@_vars_prop
-                  \l_@@_key_name_tl {#1}
-              }
-              {
-                \tl_if_in:nnTF {#1} { global }
-                  { \@@_parse_vars_elt_aux:w #1 \s_@@_stop }
-                  {
-                    \msg_error:nnx { xtemplate } { bad-variable }
-                      { \tl_to_str:n {#1} }
-                  }
-              }
+            \exp_args:Nnx \@@_parse_vars_elt_aux:nn
+              { global } { \tl_trim_spaces:n {#2} }
           }
+          { \msg_error:nnn { xtemplate } { bad-variable } { #1 global #2 } }
       }
   }
-\cs_new_protected:Npn \@@_parse_vars_elt_aux:w #1 global #2 \s_@@_stop
+\cs_new_protected:Npn \@@_parse_vars_elt_aux:nn #1#2
   {
-    \tl_if_empty:nTF {#1}
+    \str_case:VnF \l_@@_keytype_tl
       {
-        \tl_if_single:nTF {#2}
+        { choice } { \@@_implement_choices:n {#2} }
+        { code }
           {
-            \cs_if_exist:NF #2
-              { \@@_create_variable:N #2 }
             \prop_put:Non \l_@@_vars_prop
-              \l_@@_key_name_tl { #1 global #2 }
+              \l_@@_key_name_tl {#1#2}
           }
+        { instance }
           {
-            \msg_error:nnx { xtemplate } { bad-variable }
-              { \tl_to_str:n { #1 global #2 } }
+            \prop_put:Non \l_@@_vars_prop
+              \l_@@_key_name_tl {#1#2}
           }
       }
       {
-          \msg_error:nnx { xtemplate } { bad-variable }
-            { \tl_to_str:n { #1 global #2 } }
+        \tl_if_single:nTF {#2}
+          {
+            \cs_if_exist:NF #2
+              { \@@_create_variable:N #2 }
+            \prop_put:Non \l_@@_vars_prop
+              \l_@@_key_name_tl {#1#2}
+          }
+          { \msg_error:nnx { xtemplate } { bad-variable } { #1#2 } }
       }
   }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\@@_create_variable:N}
 %   A shortcut to create non-declared variables. Some types need a name





More information about the latex3-commits mailing list.