[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add public \cs_split_function:N (b091b8b)

Joseph Wright joseph.wright at morningstar2.co.uk
Sat Apr 7 09:22:24 CEST 2018


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

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

commit b091b8b046a80183a683afff1e94e40a2831e688
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sat Apr 7 08:21:39 2018 +0100

    Add public \cs_split_function:N
    
    Rather than deal with issues on the naming, by using some x-type
    expansion at point-of-use we can drop the second argument here.


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

b091b8b046a80183a683afff1e94e40a2831e688
 l3kernel/l3basics.dtx                   |  100 ++++++++++++++++---------------
 l3kernel/l3expan.dtx                    |   24 ++++++--
 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 +
 12 files changed, 79 insertions(+), 55 deletions(-)

diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx
index d3c2227..69a330b 100644
--- a/l3kernel/l3basics.dtx
+++ b/l3kernel/l3basics.dtx
@@ -793,6 +793,24 @@
 %   of the result.
 % \end{function}
 %
+% \section{Analysing control sequence names}
+%
+% \begin{function}[EXP, added = 2018-04-06]{\cs_split_function:N}
+%   \begin{syntax}
+%     \cs{cs_split_function:N} \meta{function}
+%   \end{syntax}
+%   Splits the \meta{function} into the \meta{name} (\emph{i.e.}~the part
+%   before the colon) and the \meta{signature} (\emph{i.e.}~after the colon).
+%   This information is then placed in the input stream after the
+%   \meta{processor} function in three parts: the \meta{name}, the
+%   \meta{signature} and a logic token indicating if a colon was found
+%   (to differentiate variables from function names). The \meta{name}
+%   does not include the escape character, and both the \meta{name} and
+%   \meta{signature} are made up of tokens with category code $12$
+%   (other). The \meta{processor} should be a function with argument
+%   specification \texttt{:nnN} (plus any trailing arguments needed).
+% \end{function}
+%
 % \section{Using or removing tokens and arguments}
 %
 % Tokens in the input can be read and used or read and discarded.
@@ -2108,8 +2126,12 @@
   { \@@_generate_conditional_parm:nnNpnn { new } { _protected } }
 \cs_set_protected:Npn \@@_generate_conditional_parm:nnNpnn #1#2#3#4#
   {
-    \__cs_split_function:NN #3 \@@_generate_conditional:nnNnnnnn
-    {#1} {#2} {#4}
+    \use:x
+      {
+        \@@_generate_conditional:nnNnnnnn
+          \cs_split_function:N #3
+      }
+      {#1} {#2} {#4}
   }
 %    \end{macrocode}
 % \end{macro}
@@ -2150,8 +2172,12 @@
   { \@@_generate_conditional_count:nnNnn { new } { _protected } }
 \cs_set_protected:Npn \@@_generate_conditional_count:nnNnn #1#2#3
   {
-    \__cs_split_function:NN #3 \@@_generate_conditional_count:nnNnnnn
-    {#1} {#2}
+    \use:x
+      {
+        \@@_generate_conditional_count:nnNnnnn
+        \cs_split_function:N #3
+      }
+      {#1} {#2}
   }
 \cs_set_protected:Npn \@@_generate_conditional_count:nnNnnnn #1#2#3#4#5
   {
@@ -2302,8 +2328,8 @@
     \use:x
       {
         \exp_not:N \@@_set_eq_conditional:nnNnnNNw
-          \__cs_split_function:NN #2 \prg_do_nothing:
-          \__cs_split_function:NN #3 \prg_do_nothing:
+          \cs_split_function:N #2
+          \cs_split_function:N #3
           \exp_not:N #1
           \tl_to_str:n {#4}
           \exp_not:n { , \q_recursion_tail , \q_recursion_stop }
@@ -2421,22 +2447,6 @@
 %   the marker value $-1$.
 % \end{function}
 %
-% \begin{function}[EXP]{\__cs_split_function:NN}
-%   \begin{syntax}
-%     \cs{__cs_split_function:NN} \meta{function} \meta{processor}
-%   \end{syntax}
-%   Splits the \meta{function} into the \meta{name} (\emph{i.e.}~the part
-%   before the colon) and the \meta{signature} (\emph{i.e.}~after the colon).
-%   This information is then placed in the input stream after the
-%   \meta{processor} function in three parts: the \meta{name}, the
-%   \meta{signature} and a logic token indicating if a colon was found
-%   (to differentiate variables from function names). The \meta{name}
-%   does not include the escape character, and both the \meta{name} and
-%   \meta{signature} are made up of tokens with category code $12$
-%   (other). The \meta{processor} should be a function with argument
-%   specification \texttt{:nnN} (plus any trailing arguments needed).
-% \end{function}
-%
 % \begin{function}[EXP]{\@@_get_function_name:N}
 %   \begin{syntax}
 %     \cs{@@_get_function_name:N} \meta{function}
@@ -2529,19 +2539,14 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[EXP]{\@@_split_function:NN}
+% \begin{macro}[EXP]{\cs_split_function:N}
 % \begin{macro}[EXP]
 %   {\@@_split_function_auxi:w, \@@_split_function_auxii:w}
 %   This function takes a function name and splits it into name with
 %   the escape char removed and argument specification. In addition to
 %   this, a third argument, a boolean \meta{true} or \meta{false} is
 %   returned with \meta{true} for when there is a colon in the function
-%   and \meta{false} if there is not. Lastly, the second argument of
-%   \cs{@@_split_function:NN} is supposed to be a function
-%   taking three variables, one for name, one for signature, and one
-%   for the boolean.  For example,
-%   \cs{@@_split_function:NN} \cs[no-index]{foo_bar:cnx} \cs{use_i:nnn} as input
-%   becomes \cs{use_i:nnn} |{foo_bar}| |{cnx}| \cs{c_true_bool}.
+%   and \meta{false} if there is not.
 %
 %   We cannot use |:| directly as it has the wrong category code so
 %   an |x|-type expansion is used to force the conversion.
@@ -2553,40 +2558,29 @@
 %   then \cs{c_true_bool} as |#3|, and |#4| cleans up until \cs{q_stop}.
 %   Otherwise, the |#1| contains the function name and \cs{q_mark}
 %   \cs{c_true_bool}, |#2| is empty, |#3| is \cs{c_false_bool}, and |#4|
-%   cleans up.  In both cases, |#5| is the \meta{processor}.  The second
+%   cleans up.  The second
 %   auxiliary trims the trailing \cs{q_mark} from the function name if
 %   present (that is, if the original function had no colon).
 %    \begin{macrocode}
 \cs_set_protected:Npn \@@_tmp:w #1
   {
-    \cs_set:Npn \@@_split_function:NN ##1
+    \cs_set:Npn \cs_split_function:N ##1
       {
         \exp_after:wN \exp_after:wN \exp_after:wN \@@_split_function_auxi:w
           \cs_to_str:N ##1 \q_mark \c_true_bool
           #1 \q_mark \c_false_bool \q_stop
       }
     \cs_set:Npn \@@_split_function_auxi:w
-        ##1 #1 ##2 \q_mark ##3##4 \q_stop ##5
-      { \@@_split_function_auxii:w ##5 ##1 \q_mark \q_stop {##2} ##3 }
-    \cs_set:Npn \@@_split_function_auxii:w ##1##2 \q_mark ##3 \q_stop
-      { ##1 {##2} }
+        ##1 #1 ##2 \q_mark ##3##4 \q_stop
+      { \@@_split_function_auxii:w ##1 \q_mark \q_stop {##2} ##3 }
+    \cs_set:Npn \@@_split_function_auxii:w ##1 \q_mark ##2 \q_stop
+      { {##1} }
   }
 \exp_after:wN \@@_tmp:w \token_to_str:N :
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[EXP]
-%   {\@@_get_function_name:N, \@@_get_function_signature:N}
-%   Simple wrappers.
-%    \begin{macrocode}
-\cs_set:Npn \@@_get_function_name:N #1
-  { \@@_split_function:NN #1 \use_i:nnn }
-\cs_set:Npn \@@_get_function_signature:N #1
-  { \@@_split_function:NN #1 \use_ii:nnn }
-%    \end{macrocode}
-% \end{macro}
-%
 % \subsection{Exist or free}
 %
 % A control sequence is said to \emph{exist} (to be used) if has an entry in
@@ -3030,6 +3024,7 @@
 %    \end{macrocode}
 %
 % \begin{macro}[EXP]{\@@_count_signature:N, \@@_count_signature:c}
+% \begin{macro}[EXP]{\@@_count_signature:n}
 % \begin{macro}[EXP]{\@@_count_signature:nnN}
 %   Counting the number of tokens in the signature, \emph{i.e.}, the
 %   number of arguments the function should take.  Since this is not
@@ -3038,7 +3033,9 @@
 %   We need a variant form right away.
 %    \begin{macrocode}
 \cs_new:Npn \@@_count_signature:N #1
-  { \int_eval:n { \@@_split_function:NN #1 \@@_count_signature:nnN } }
+  { \exp_args:Nf \@@_count_signature:n { \cs_split_function:N #1 } }
+\cs_new:Npn \@@_count_signature:n #1
+  { \int_eval:n { \@@_count_signature:nnN #1 } }
 \cs_new:Npn \@@_count_signature:nnN #1#2#3
   {
     \if_meaning:w \c_true_bool #3
@@ -3052,6 +3049,7 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}
 %   {
@@ -3140,8 +3138,12 @@
   }
 \cs_new_protected:Npn \@@_generate_from_signature:NNn #1#2
   {
-    \@@_split_function:NN #2 \@@_generate_from_signature:nnNNNn
-    #1 #2
+    \use:x
+      {
+        \@@_generate_from_signature:nnNNNn
+        \cs_split_function:N #2
+      }
+      #1 #2
   }
 \cs_new_protected:Npn \@@_generate_from_signature:nnNNNn #1#2#3#4#5#6
   {
diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index cdd35b6..ce524c0 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -1565,11 +1565,17 @@
 \cs_new_protected:Npn \cs_generate_variant:Nn #1#2
   {
     \@@_generate_variant:N #1
-    \exp_after:wN \@@_split_function:NN
-    \exp_after:wN #1
-    \exp_after:wN \@@_generate_variant:nnNN
-    \exp_after:wN #1
-    \tl_to_str:n {#2} , \scan_stop: , \q_recursion_stop
+    \use:x
+      {
+        \@@_generate_variant:nnNN
+          \exp_after:wN \cs_split_function:N
+          \exp_after:wN #1
+          \exp_after:wN \exp_not:N
+          \exp_after:wN #1
+          \tl_to_str:n {#2} ,
+            \exp_not:N \scan_stop: ,
+            \exp_not:N \q_recursion_stop
+      }
   }
 \cs_new_protected:Npn \cs_generate_variant:cn
   { \exp_args:Nc \cs_generate_variant:Nn }
@@ -2006,7 +2012,13 @@
 %   }
 %    \begin{macrocode}
 \cs_new_protected:Npn \prg_generate_conditional_variant:Nnn #1
-  { \__cs_split_function:NN #1 \@@_generate_variant:nnNnn }
+  {
+    \use:x
+      {
+        \@@_generate_variant:nnNnn
+          \cs_split_function:N #1
+      }
+  }
 \cs_new_protected:Npn \@@_generate_variant:nnNnn #1#2#3#4#5
   {
     \if_meaning:w \c_false_bool #3
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 933a847..982279f 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -42,6 +42,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 873d834..d5f031f 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 40019d1..2ecc4ce 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 25cbf25..33f3474 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index d4c96bb..d9ea317 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 933a847..982279f 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -42,6 +42,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 873d834..d5f031f 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 40019d1..2ecc4ce 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 25cbf25..33f3474 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index d4c96bb..d9ea317 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -41,6 +41,7 @@ Defining \cs_new_eq:cc on line ...
 Defining \cs_undefine:N on line ...
 Defining \cs_undefine:c on line ...
 Defining \__cs_count_signature:N on line ...
+Defining \__cs_count_signature:n on line ...
 Defining \__cs_count_signature:nnN on line ...
 Defining \__cs_count_signature:c on line ...
 Defining \cs_generate_from_arg_count:NNnn on line ...





More information about the latex3-commits mailing list