summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3expan.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3kernel/l3expan.sty162
1 files changed, 116 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty b/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty
index f7a458e9a88..6dceea954ad 100644
--- a/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty
+++ b/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty
@@ -46,7 +46,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3bootstrap}
-\GetIdInfo$Id: l3expan.dtx 4073 2012-08-10 01:33:13Z bruno $
+\GetIdInfo$Id: l3expan.dtx 4149 2012-08-28 10:50:40Z bruno $
{L3 Argument expansion}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -56,6 +56,7 @@
\cs_new:Npn \::: #1 {#1}
\cs_new:Npn \::n #1 \::: #2#3 { #1 \::: { #2 {#3} } }
\cs_new:Npn \::N #1 \::: #2#3 { #1 \::: {#2#3} }
+\cs_new:Npn \::p #1 \::: #2#3# { #1 \::: {#2#3} }
\cs_new:Npn \::c #1 \::: #2#3
{ \exp_after:wN \__exp_arg_next:Nnn \cs:w #3 \cs_end: {#1} {#2} }
\cs_new:Npn \::o #1 \::: #2#3
@@ -109,8 +110,6 @@
{ \exp_after:wN #1 \exp_after:wN #2 \exp_after:wN {#3} }
\cs_new:Npn \exp_args:NNNo #1#2#3#4
{ \exp_after:wN #1 \exp_after:wN#2 \exp_after:wN #3 \exp_after:wN {#4} }
-\cs_new:Npn \exp_args:cc #1#2
- { \cs:w #1 \exp_after:wN \cs_end: \cs:w #2 \cs_end: }
\cs_new:Npn \exp_args:NNc #1#2#3
{ \exp_after:wN #1 \exp_after:wN #2 \cs:w # 3\cs_end: }
\cs_new:Npn \exp_args:Ncc #1#2#3
@@ -313,80 +312,151 @@
\exp_after:wN #1
\exp_after:wN \__cs_generate_variant:nnNN
\exp_after:wN #1
- \etex_detokenize:D {#2} , ? , \q_recursion_stop
+ \etex_detokenize:D {#2} , \scan_stop: , \q_recursion_stop
}
\group_begin:
- \tex_lccode:D `\Z = `\d \scan_stop:
- \tex_lccode:D `\? =`\\ \scan_stop:
+ \tex_catcode:D `\M = 12 \scan_stop:
+ \tex_catcode:D `\A = 12 \scan_stop:
\tex_catcode:D `\P = 12 \scan_stop:
\tex_catcode:D `\R = 12 \scan_stop:
- \tex_catcode:D `\O = 12 \scan_stop:
- \tex_catcode:D `\T = 12 \scan_stop:
- \tex_catcode:D `\E = 12 \scan_stop:
- \tex_catcode:D `\C = 12 \scan_stop:
- \tex_catcode:D `\Z = 12 \scan_stop:
\tex_lowercase:D
{
\group_end:
\cs_new_protected:Npn \__cs_generate_variant:N #1
{
- \exp_after:wN \__cs_generate_variant:w
- \token_to_meaning:N #1
- \q_mark \cs_new_protected_nopar:Npx
- ? PROTECTEZ
- \q_mark \cs_new_nopar:Npx
- \q_stop
+ \exp_after:wN \if_meaning:w \exp_not:N #1 #1
+ \cs_set_eq:NN \__cs_tmp:w \cs_new_protected_nopar:Npx
+ \else:
+ \exp_after:wN \__cs_generate_variant:ww
+ \token_to_meaning:N #1 MA \q_mark
+ \q_mark \cs_new_protected_nopar:Npx
+ PR
+ \q_mark \cs_new_nopar:Npx
+ \q_stop
+ \fi:
}
- \cs_new_protected:Npn \__cs_generate_variant:w
- #1 ? PROTECTEZ #2 \q_mark #3 #4 \q_stop
+ \cs_new_protected:Npn \__cs_generate_variant:ww #1 MA #2 \q_mark
+ { \__cs_generate_variant:wwNw #1 }
+ \cs_new_protected:Npn \__cs_generate_variant:wwNw
+ #1 PR #2 \q_mark #3 #4 \q_stop
{
\cs_set_eq:NN \__cs_tmp:w #3
}
}
\cs_new_protected:Npn \__cs_generate_variant:nnNN #1#2#3#4
- { \__cs_generate_variant:Nnnw #4 {#1}{#2} }
+ {
+ \if_meaning:w \c_false_bool #3
+ \__msg_kernel_error:nnx { kernel } { missing-colon }
+ { \token_to_str:c {#1} }
+ \exp_after:wN \use_none_delimit_by_q_recursion_stop:w
+ \fi:
+ \__cs_generate_variant:Nnnw #4 {#1}{#2}
+ }
\cs_new_protected:Npn \__cs_generate_variant:Nnnw #1#2#3#4 ,
{
- \if:w ? #4
+ \if_meaning:w \scan_stop: #4
\exp_after:wN \use_none_delimit_by_q_recursion_stop:w
\fi:
- \exp_after:wN \__cs_generate_variant:NNn
- \exp_after:wN #1
- \cs:w
- #2 :
- \__cs_generate_variant_loop:NwN
- ? #3
- \q_mark #4 \__cs_generate_variant_loop_end:w
- \q_mark \__cs_generate_variant_loop_error:wnNNnn
- \q_stop
- \cs_end:
- {#4}
+ \use:x
+ {
+ \exp_not:N \__cs_generate_variant:wwNN
+ \__cs_generate_variant_loop:nNwN { }
+ #4
+ \__cs_generate_variant_loop_end:nwwwNNnn
+ \q_mark
+ #3 ~
+ { ~ { } \fi: \__cs_generate_variant_loop_long:wNNnn } ~
+ { }
+ \q_stop
+ \exp_not:N #1 {#2} {#4}
+ }
\__cs_generate_variant:Nnnw #1 {#2} {#3}
}
-\cs_new:Npn \__cs_generate_variant_loop:NwN #1 #2 \q_mark #3
- { #3 \__cs_generate_variant_loop:NwN #2 \q_mark }
-\cs_new:Npn \__cs_generate_variant_loop_end:w #1#2 \q_mark #3 \q_stop {#2}
-\cs_new:Npn \__cs_generate_variant_loop_error:wnNNnn
- #1 \q_stop \cs_end: #2 #3#4#5#6
+\cs_new:Npn \__cs_generate_variant_loop:nNwN #1#2#3 \q_mark #4
+ {
+ \if:w #2 #4
+ \exp_after:wN \__cs_generate_variant_loop_same:w
+ \else:
+ \if:w N #4 \else:
+ \if:w n #4 \else:
+ \__cs_generate_variant_loop_invalid:NNwNNnn #4#2
+ \fi:
+ \fi:
+ \fi:
+ #1
+ \prg_do_nothing:
+ #2
+ \__cs_generate_variant_loop:nNwN { } #3 \q_mark
+ }
+\cs_new:Npn \__cs_generate_variant_loop_same:w
+ #1 \prg_do_nothing: #2#3#4
+ {
+ #3 { #1 \__cs_generate_variant_same:N #2 }
+ }
+\cs_new:Npn \__cs_generate_variant_loop_end:nwwwNNnn
+ #1#2 \q_mark #3 ~ #4 \q_stop #5#6#7#8
{
- \cs_end: {#2}
- \__msg_kernel_error:nnxx { kernel } { variant-too-long }
- { \tl_to_str:n {#2} } { \token_to_str:N #4 }
- #3 #4 {#5} {#6}
+ \scan_stop: \scan_stop: \fi:
+ \exp_not:N \q_mark
+ \exp_not:N \q_stop
+ \exp_not:N #6
+ \exp_not:c { #7 : #8 #1 #3 }
+ }
+\cs_new:Npn \__cs_generate_variant_loop_long:wNNnn #1 \q_stop #2#3#4#5
+ {
+ \exp_not:n
+ {
+ \q_mark
+ \__msg_kernel_error:nnxx { kernel } { variant-too-long }
+ {#5} { \token_to_str:N #3 }
+ \use_none:nnnn
+ \q_stop
+ #3
+ #3
+ }
+ }
+\cs_new:Npn \__cs_generate_variant_loop_invalid:NNwNNnn
+ #1#2 \fi: \fi: \fi: #3 \q_stop #4#5#6#7
+ {
+ \fi: \fi: \fi:
+ \exp_not:n
+ {
+ \q_mark
+ \__msg_kernel_error:nnxxxx { kernel } { invalid-variant }
+ {#7} { \token_to_str:N #5 } {#1} {#2}
+ \use_none:nnnn
+ \q_stop
+ #5
+ #5
+ }
+ }
+\cs_new:Npn \__cs_generate_variant_same:N #1
+ {
+ \if:w N #1
+ N
+ \else:
+ \if:w p #1
+ p
+ \else:
+ n
+ \fi:
+ \fi:
}
-\cs_new_protected:Npn \__cs_generate_variant:NNn #1 #2 #3
+\cs_new_protected:Npn \__cs_generate_variant:wwNN
+ #1 \q_mark #2 \q_stop #3#4
{
- \cs_if_free:NTF #2
+ #2
+ \cs_if_free:NTF #4
{
\group_begin:
- \__cs_generate_internal_variant:n {#3}
- \__cs_tmp:w #2 { \exp_not:c { exp_args:N #3 } \exp_not:N #1 }
+ \__cs_generate_internal_variant:n {#1}
+ \__cs_tmp:w #4 { \exp_not:c { exp_args:N #1 } \exp_not:N #3 }
\group_end:
}
{
\iow_log:x
{
- Variant~\token_to_str:N #2~%
+ Variant~\token_to_str:N #4~%
already~defined;~ not~ changing~ it~on~line~%
\tex_the:D \tex_inputlineno:D
}