Skip to content

Commit

Permalink
Allow arbitrary trailing args in cs_generate_variant (fixes #418)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bruno Le Floch committed Dec 5, 2017
1 parent e1a7c43 commit fecc29c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
26 changes: 6 additions & 20 deletions l3kernel/l3expan.dtx
Expand Up @@ -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
{
Expand Down Expand Up @@ -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:
}
Expand Down
3 changes: 3 additions & 0 deletions l3kernel/testfiles/m3expan002.lvt
Expand Up @@ -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 }
Expand Down
8 changes: 3 additions & 5 deletions l3kernel/testfiles/m3expan002.tlg
Expand Up @@ -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
Expand Down

0 comments on commit fecc29c

Please sign in to comment.