[latex3-commits] [git/latex3] master: Allow arbitrary trailing args in cs_generate_variant (fixes #418) (fecc29c)

Bruno Le Floch bruno at le-floch.fr
Tue Dec 5 06:15:58 CET 2017


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

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

commit fecc29ca6742187605bdaa390ec574584f3645df
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Tue Dec 5 00:12:00 2017 -0500

    Allow arbitrary trailing args in cs_generate_variant (fixes #418)
    
    A package quite reasonably uses \cs_generate_variant:Nn with base
    signature "NNw" and variant signature "ccw".  The previous code
    was requiring a second arg of "cc" instead of "ccw" to acheive this
    effect.  But it is reasonable for a programmer to want to always
    write signatures in full.


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

fecc29ca6742187605bdaa390ec574584f3645df
 l3kernel/l3expan.dtx              |   26 ++++++--------------------
 l3kernel/testfiles/m3expan002.lvt |    3 +++
 l3kernel/testfiles/m3expan002.tlg |    8 +++-----
 3 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 14eb838..39bee00 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -1831,20 +1831,7 @@
   }
 \cs_new:Npn \@@_generate_variant_loop_same:w
     #1 \prg_do_nothing: #2#3#4
-  {
-    \if:w N #2 \else:
-      \if:w n #2 \else:
-        \if:w p #2 \else:
-          \if:w T #2 \else:
-            \if:w F #2 \else:
-              \@@_generate_variant_loop_special:NNwNNnn #2#2
-            \fi:
-          \fi:
-        \fi:
-      \fi:
-    \fi:
-    #3 { #1 \@@_generate_variant_same:N #2 }
-  }
+  { #3 { #1 \@@_generate_variant_same:N #2 } }
 \cs_new:Npn \@@_generate_variant_loop_end:nwwwNNnn
     #1#2 \q_mark #3 ~ #4 \q_stop #5#6#7#8
   {
@@ -1905,13 +1892,12 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_generate_variant_same:N #1
   {
-    \if:w N #1
-      N
-    \else:
-      \if:w p #1
-        p
-      \else:
+    \if:w N #1 N \else:
+      \if:w p #1 p \else:
         n
+        \if:w n #1 \else:
+          \@@_generate_variant_loop_special:NNwNNnn #1#1
+        \fi:
       \fi:
     \fi:
   }
diff --git a/l3kernel/testfiles/m3expan002.lvt b/l3kernel/testfiles/m3expan002.lvt
index 8ff76cd..eec8baf 100644
--- a/l3kernel/testfiles/m3expan002.lvt
+++ b/l3kernel/testfiles/m3expan002.lvt
@@ -43,6 +43,9 @@
     \iow_term:x { \cs_meaning:N \foo:xNnTF }
     \iow_term:x { \cs_meaning:N \foo:nNnTF }
     \iow_term:x { \cs_meaning:N \foo:oNnTFF }
+    \cs_new:Npn \foo:NNw { }
+    \cs_generate_variant:Nn \foo:NNw { ccw }
+    \iow_term:x { \cs_meaning:N \foo:ccw }
   }
 
 \TEST { Using~p~arguments }
diff --git a/l3kernel/testfiles/m3expan002.tlg b/l3kernel/testfiles/m3expan002.tlg
index 06f25e0..1a23336 100644
--- a/l3kernel/testfiles/m3expan002.tlg
+++ b/l3kernel/testfiles/m3expan002.tlg
@@ -118,17 +118,15 @@ l. ...  }
 | signature starting with 'oNnTFF', but that is longer than the signature
 | (part after the colon) of '\foo:oNnTF'.
 |...............................................
-*************************************************
-* LaTeX warning: "kernel/invalid-variant"
-* 
-* Variant form 'oNnTFF' invalid for base form '\foo:oNnTF'.
-*************************************************
 \long macro:->\exp_args:NnNo \foo:oNnTF 
 \protected\long macro:->\exp_args:NnNx \foo:oNnTF 
 \long macro:->\exp_args:Nnc \foo:oNnTF 
 undefined
 undefined
 undefined
+Defining \foo:NNw on line ...
+Defining \foo:ccw on line ...
+\long macro:->\exp_args:Ncc \foo:NNw 
 ============================================================
 ============================================================
 TEST 3: Using p arguments





More information about the latex3-commits mailing list