summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-13 22:19:08 +0000
committerKarl Berry <karl@freefriends.org>2011-08-13 22:19:08 +0000
commit5730d1c679f7a725b75ce80066cc6a6987aee888 (patch)
treedef203d2e98df13d7d8b1f97444810f2c685a974 /Master/texmf-dist/tex/latex/l3kernel/l3tl.sty
parent8fdbc868b3cd64d89d3b4a172779aea071a118c5 (diff)
l3kernel 2564 (13aug11)
git-svn-id: svn://tug.org/texlive/trunk@23540 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3tl.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3kernel/l3tl.sty400
1 files changed, 266 insertions, 134 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty
index e86c27e6c34..b37aa775085 100644
--- a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty
+++ b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty
@@ -46,7 +46,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3tl.dtx 2534 2011-08-10 18:21:44Z joseph $
+\GetIdInfo$Id: l3tl.dtx 2563 2011-08-13 12:23:59Z joseph $
{L3 Experimental token lists}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -175,6 +175,7 @@
\group_begin:
\exp_args:No \etex_everyeof:D { \c_tl_rescan_marker_tl }
\tex_endlinechar:D \c_minus_one
+ \tex_newlinechar:D \c_minus_one
#3
\tl_clear:N \l_tl_rescan_tl
\exp_after:wN \tl_rescan_aux:w \etex_scantokens:D {#4}
@@ -201,6 +202,7 @@
\group_begin:
\etex_everyeof:D { \exp_not:N }
\tex_endlinechar:D \c_minus_one
+ \tex_newlinechar:D \c_minus_one
#3
\tl_set:Nx \l_tl_rescan_tl { \etex_scantokens:D {#4} }
\exp_args:NNNo \group_end:
@@ -213,6 +215,7 @@
\group_begin:
\exp_args:No \etex_everyeof:D { \c_tl_rescan_marker_tl }
\tex_endlinechar:D \c_minus_one
+ \tex_newlinechar:D \c_minus_one
#1
\exp_after:wN \tl_rescan_aux:w \etex_scantokens:D {#2}
\exp_args:No \group_end:
@@ -222,60 +225,53 @@
\cs_new_eq:NN \tl_to_uppercase:n \tex_uppercase:D
\tl_new:N \l_tl_replace_tl
\cs_new_protected_nopar:Npn \tl_replace_once:Nnn
- { \tl_replace_once_aux:NNnn \tl_set_eq:NN }
+ { \tl_replace_aux:NNNnn \tl_replace_once_aux: \tl_set:Nx }
\cs_new_protected_nopar:Npn \tl_greplace_once:Nnn
- { \tl_replace_once_aux:NNnn \tl_gset_eq:NN }
-\cs_new_protected:Npn \tl_replace_once_aux:NNnn #1#2#3#4
+ { \tl_replace_aux:NNNnn \tl_replace_once_aux: \tl_gset:Nx }
+\cs_new_protected_nopar:Npn \tl_replace_all:Nnn
+ { \tl_replace_aux:NNNnn \tl_replace_all_aux: \tl_set:Nx }
+\cs_new_protected_nopar:Npn \tl_greplace_all:Nnn
+ { \tl_replace_aux:NNNnn \tl_replace_all_aux: \tl_gset:Nx }
+\cs_generate_variant:Nn \tl_replace_once:Nnn { c }
+\cs_generate_variant:Nn \tl_greplace_once:Nnn { c }
+\cs_generate_variant:Nn \tl_replace_all:Nnn { c }
+\cs_generate_variant:Nn \tl_greplace_all:Nnn { c }
+\cs_new_protected:Npn \tl_replace_aux:NNNnn #1#2#3#4#5
{
- \cs_set_protected:Npx \tl_tmp:w ##1 #3 ##2 \q_stop
+ \tl_if_empty:nTF {#4}
+ {
+ \msg_kernel_error:nnx { tl } { empty-search-pattern }
+ { \tl_to_str:n {#5} }
+ }
{
- \exp_not:N \quark_if_no_value:nF {##2}
+ \cs_set:Npx \tl_tmp:w ##1##2 #4
{
- \tl_set:No \exp_not:N \l_tl_replace_tl { ##1 \exp_not:n{#4} }
- \exp_not:n
- {
- \cs_set_protected:Npn \tl_tmp:w ##1 \q_nil #3 \q_no_value
- { \tl_put_right:No \l_tl_replace_tl {##1} }
- }
- \exp_not:n { \tl_tmp:w \prg_do_nothing: } ##2
- \exp_not:n { #1 #2 \l_tl_replace_tl }
+ ##2
+ \exp_not:N \q_mark
+ \exp_not:N \use_none_delimit_by_q_stop:w
+ \exp_not:n { \exp_not:n {#5} }
+ ##1
+ }
+ #2 #3
+ {
+ \exp_after:wN #1
+ #3 \q_mark #4 \q_stop
}
}
- \exp_after:wN \tl_tmp:w \exp_after:wN \prg_do_nothing:
- #2 \q_nil #3 \q_no_value \q_stop
}
-\cs_generate_variant:Nn \tl_replace_once:Nnn { c }
-\cs_generate_variant:Nn \tl_greplace_once:Nnn { c }
-\cs_new_protected_nopar:Npn \tl_replace_all:Nnn
- { \tl_replace_all_aux:NNnn \tl_set_eq:NN }
-\cs_new_protected_nopar:Npn \tl_greplace_all:Nnn
- { \tl_replace_all_aux:NNnn \tl_gset_eq:NN }
-\cs_new_protected:Npn \tl_replace_all_aux:NNnn #1#2#3#4
- {
- \tl_clear:N \l_tl_replace_tl
- \cs_set_protected:Npx \tl_tmp:w ##1 #3 ##2 \q_stop
- {
- \exp_not:N \quark_if_no_value:nTF {##2}
- {
- \exp_not:n
- {
- \cs_set_protected:Npn \tl_tmp:w ##1 \q_nil ##2 \q_stop
- { \tl_put_right:No \l_tl_replace_tl {##1} }
- }
- \exp_not:N \tl_tmp:w ##1 \exp_not:N \q_stop
- }
- {
- \exp_not:n { \tl_put_right:No \l_tl_replace_tl }
- { ##1 \exp_not:n{#4} }
- \exp_not:n { \tl_tmp:w \prg_do_nothing: } ##2 \exp_not:N \q_stop
- }
- }
- \exp_after:wN \tl_tmp:w \exp_after:wN \prg_do_nothing:
- #2 \q_nil #3 \q_no_value \q_stop
- #1 #2 \l_tl_replace_tl
- }
-\cs_generate_variant:Nn \tl_replace_all:Nnn { c }
-\cs_generate_variant:Nn \tl_greplace_all:Nnn { c }
+\cs_new:Npn \tl_replace_aux_ii:w #1 \q_mark #2 { \exp_not:o {#1} }
+\cs_new:Npn \tl_replace_all_aux:
+ {
+ \exp_after:wN \tl_replace_aux_ii:w
+ \tl_tmp:w \tl_replace_all_aux: \prg_do_nothing:
+ }
+\cs_new_nopar:Npn \tl_replace_once_aux:
+ {
+ \exp_after:wN \tl_replace_aux_ii:w
+ \tl_tmp:w { \tl_replace_once_aux_end:w \prg_do_nothing: } \prg_do_nothing:
+ }
+\cs_new:Npn \tl_replace_once_aux_end:w #1 \q_mark #2 \q_stop
+ { \exp_not:o {#1} }
\cs_new_protected_nopar:Npn \tl_remove_once:Nn #1#2
{ \tl_replace_once:Nnn #1 {#2} { } }
\cs_new_protected_nopar:Npn \tl_gremove_once:Nn #1#2
@@ -310,26 +306,28 @@
\cs_generate_variant:Nn \tl_if_empty:NT { c }
\cs_generate_variant:Nn \tl_if_empty:NF { c }
\cs_generate_variant:Nn \tl_if_empty:NTF { c }
-\prg_new_conditional:Npnn \tl_if_empty:n #1 { p,TF,T,F} {
- \exp_after:wN \if_meaning:w \exp_after:wN \q_nil \tl_to_str:n {#1} \q_nil
- \prg_return_true:
- \else:
- \prg_return_false:
- \fi:
-}
+\prg_new_conditional:Npnn \tl_if_empty:n #1 { p , TF , T , F }
+ {
+ \exp_after:wN \if_meaning:w \exp_after:wN \q_nil \tl_to_str:n {#1} \q_nil
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
\cs_generate_variant:Nn \tl_if_empty_p:n { V }
\cs_generate_variant:Nn \tl_if_empty:nTF { V }
\cs_generate_variant:Nn \tl_if_empty:nT { V }
\cs_generate_variant:Nn \tl_if_empty:nF { V }
-\cs_new:Npn \tl_if_empty_return:o #1 {
- \exp_after:wN \if_meaning:w \exp_after:wN \q_nil
- \tl_to_str:n \exp_after:wN {#1} \q_nil
- \prg_return_true:
- \else:
- \prg_return_false:
- \fi:
-}
-\prg_new_conditional:Npnn \tl_if_empty:o #1 { p,TF,T,F}
+\cs_new:Npn \tl_if_empty_return:o #1
+ {
+ \exp_after:wN \if_meaning:w \exp_after:wN \q_nil
+ \tl_to_str:n \exp_after:wN {#1} \q_nil
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+\prg_new_conditional:Npnn \tl_if_empty:o #1 { p , TF , T , F }
{ \tl_if_empty_return:o {#1} }
\prg_new_conditional:Npnn \tl_if_eq:NN #1#2 { p , T , F , TF }
{
@@ -379,20 +377,6 @@
\cs_generate_variant:Nn \tl_if_in:nnT { no }
\cs_generate_variant:Nn \tl_if_in:nnF { no }
\cs_generate_variant:Nn \tl_if_in:nnTF { no }
-\prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF }
- {
- \tl_if_blank:nTF {#1}
- { \tl_if_empty:nTF {#1} { \prg_return_false: } { \prg_return_true: } }
- { \tl_if_single_aux:n {#1} }
- }
-\prg_new_conditional:Npnn \tl_if_single:N #1 { p , T , F , TF }
- {
- \tl_if_blank:oTF #1
- { \tl_if_empty:NTF #1 { \prg_return_false: } { \prg_return_true: } }
- { \exp_args:No \tl_if_single_aux:n {#1} }
- }
-\cs_new:Npn \tl_if_single_aux:n #1
- { \tl_if_empty_return:o { \use_none:n #1 } }
\cs_new:Npn \tl_map_function:nN #1#2
{ \tl_map_function_aux:Nn #2 #1 \q_recursion_tail \q_recursion_stop }
\cs_new_nopar:Npn \tl_map_function:NN #1#2
@@ -448,14 +432,9 @@
\if_cs_exist:w #1 \cs_end:
\cs:w #1 \exp_after:wN \cs_end:
\else:
- \exp_after:wN \tl_error_message:
+ \msg_expandable_error:n { Undefined~variable~name~'#1'! }
\fi:
}
-\group_begin:
-\tex_catcode:D `\! = 11 \scan_stop:
-\tex_catcode:D `\ = 11\scan_stop:%
-\cs_gset_nopar:Npn\tl_error_message:{\undefined variable name!}%
-\group_end:%
\cs_new:Npn \tl_length:n #1
{
\int_eval:n
@@ -469,17 +448,14 @@
\cs_new:Npn \tl_length_aux:n #1 { + 1 }
\cs_generate_variant:Nn \tl_length:n { V , o }
\cs_generate_variant:Nn \tl_length:N { c }
-\cs_new:Npn \tl_reverse:n #1
- { \tl_reverse_aux:nN { } #1 \q_recursion_tail \q_recursion_stop }
-\cs_new:Npn \tl_reverse_aux:nN #1#2
+\cs_new:Npn \tl_reverse_items:n #1
+ { \tl_reverse_items_aux:nw #1 \q_recursion_tail \q_recursion_stop }
+\cs_new:Npn \tl_reverse_items_aux:nw #1 #2 \q_recursion_stop
{
- \quark_if_recursion_tail_stop_do:nn {#2} {#1}
- \tl_reverse_aux:nN { #2 #1 }
+ \quark_if_recursion_tail_stop_do:nn {#1} { \use_none:n }
+ \tl_reverse_items_aux:nw #2 \q_recursion_stop
+ {#1}
}
-\cs_generate_variant:Nn \tl_reverse:n {V,o}
-\cs_new_protected_nopar:Npn \tl_reverse:N #1
- { \tl_set:Nf #1 { \tl_reverse:o { #1 \exp_stop_f: } } }
-\cs_generate_variant:Nn \tl_reverse:N { c }
\cs_new:Npn \tl_trim_spaces:n #1
{
\etex_unexpanded:D \exp_after:wN \exp_after:wN \exp_after:wN
@@ -501,24 +477,32 @@
\cs_new:Npn \tl_head:w #1#2 \q_stop {#1}
\cs_new:Npn \tl_tail:w #1#2 \q_stop {#2}
\cs_new:Npn \tl_head:n #1
- { \tl_if_blank:nF {#1} { \tl_head:w #1 \q_stop } }
+ { \tl_head:w #1 { } \q_stop }
\cs_new:Npn \tl_tail:n #1
- { \tl_if_blank:nF {#1} { \tl_tail:w #1 \q_stop } }
+ { \tl_tail_aux:w #1 \q_mark { } \q_mark \q_stop }
+\cs_new:Npn \tl_tail_aux:w #1 #2 \q_mark #3 \q_stop { #2 }
\cs_generate_variant:Nn \tl_head:n { V , v , f }
\cs_generate_variant:Nn \tl_tail:n { V , v , f }
\cs_new:Npn \str_head:n #1
{
\exp_after:wN \str_head_aux:w
\tl_to_str:n {#1}
- { \scan_stop: } ~ \q_stop
+ { { } } ~ \q_stop
}
\cs_new_nopar:Npn \str_head_aux:w #1 ~ %
{ \tl_head:w #1 { ~ } }
+\cs_new:Npn \str_tail:n #1
+ {
+ \exp_after:wN \str_tail_aux:w
+ \reverse_if:N \if_charcode:w
+ \scan_stop: \tl_to_str:n {#1} X X \q_stop
+ }
+\cs_new_nopar:Npn \str_tail_aux:w #1 X #2 \q_stop { \fi: #1 }
\prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 { p , T , F , TF }
{
\if_charcode:w
\exp_not:N #2
- \str_if_eq:onTF { \use:n #1 ? } { #1 ? }
+ \tl_if_head_N_type:nTF { #1 ? }
{ \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop }
{ \str_head:n {#1} }
\prg_return_true:
@@ -534,10 +518,10 @@
{
\if_catcode:w
\exp_not:N #2
- \str_if_eq:onTF { \use:n #1 ? } { #1 ? }
+ \tl_if_head_N_type:nTF { #1 ? }
{ \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop }
{
- \tl_if_head_begin_group:nTF {#1}
+ \tl_if_head_group:nTF {#1}
{ \c_group_begin_token }
{ \c_space_token }
}
@@ -548,7 +532,7 @@
}
\prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF }
{
- \str_if_eq:onTF { \use:n #1 ? } { #1 ? }
+ \tl_if_head_N_type:nTF { #1 ? }
{ \tl_if_head_eq_meaning_aux_normal:nN }
{ \tl_if_head_eq_meaning_aux_special:nN }
{#1} #2
@@ -571,7 +555,7 @@
\fi:
{
\if_catcode:w \exp_not:N #2
- \tl_if_head_begin_group:nTF {#1}
+ \tl_if_head_group:nTF {#1}
{ \c_group_begin_token }
{ \c_space_token }
\prg_return_true:
@@ -580,6 +564,42 @@
\fi:
}
}
+\prg_new_conditional:Npnn \tl_if_head_N_type:n #1 { p , T , F , TF }
+ { \str_if_eq_return:on { \use:n #1 { } } { #1 { } } }
+\prg_new_conditional:Npnn \tl_if_head_group:n #1 { p , T , F , TF }
+ {
+ \if_predicate:w
+ \exp_after:wN \use_none:n
+ \exp_after:wN {
+ \exp_after:wN {
+ \token_to_str:N #1 ?
+ }
+ \c_false_bool
+ }
+ \c_true_bool
+ \prg_return_false:
+ \else:
+ \prg_return_true:
+ \fi:
+ }
+\prg_new_conditional:Npnn \tl_if_head_space:n #1 { p , T , F , TF }
+ {
+ \if_int_compare:w
+ \pdftex_strcmp:D
+ { }
+ { \tl_if_head_space_aux:w \prg_do_nothing: #1 ? ~ }
+ = \c_zero
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+\cs_new:Npn \tl_if_head_space_aux:w #1 ~ %
+ {
+ \exp_not:o {#1}
+ \if_false: { \fi: }
+ \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
+ }
\cs_new_protected:Npn \tl_show:N #1 { \cs_show:N #1 }
\cs_generate_variant:Nn \tl_show:N { c }
\cs_new_eq:NN \tl_show:n \etex_showtokens:D
@@ -590,51 +610,163 @@
\tl_new:N \g_tmpb_tl
\tl_new:N \l_tmpa_tl
\tl_new:N \l_tmpb_tl
-\cs_new:Npn \tl_if_single_item:nTF #1
- { \str_if_eq:onTF { \use_ii:nn #1 {?} ? } {??} }
-\cs_new:Npn \tl_if_single_item:nT #1
- { \str_if_eq:onT { \use_ii:nn #1 {?} ? } {??} }
-\cs_new:Npn \tl_if_single_item:nF #1
- { \str_if_eq:onF { \use_ii:nn #1 {?} ? } {??} }
-\cs_new:Npn \tl_if_single_item_p:n #1
- { \str_if_eq_p:on { \use_ii:nn #1 {?} ? } {??} }
-\prg_new_conditional:Npnn \tl_if_head_begin_group:n #1 { p , T , F , TF }
- {
- \exp_after:wN \use_none:n
- \exp_after:wN {
- \exp_after:wN {
- \token_to_str:N #1 .
- }
- \prg_return_true: \exp_after:wN \use_none:nn \token_to_str:N
- }
+\cs_new:Npn \str_if_eq_return:on #1 #2
+ {
+ \if_int_compare:w
+ \pdftex_strcmp:D { \exp_not:o {#1} } { \exp_not:n {#2} }
+ = \c_zero
+ \prg_return_true:
+ \else:
\prg_return_false:
+ \fi:
}
-\prg_new_conditional:Npnn \tl_if_head_eq_space:n #1 { p , T , F , TF }
+\cs_new:Npn \tl_if_single_p:N { \exp_args:No \tl_if_single_p:n }
+\cs_new:Npn \tl_if_single:NT { \exp_args:No \tl_if_single:nT }
+\cs_new:Npn \tl_if_single:NF { \exp_args:No \tl_if_single:nF }
+\cs_new:Npn \tl_if_single:NTF { \exp_args:No \tl_if_single:nTF }
+\prg_new_conditional:Npnn \tl_if_single:n #1 { p , T , F , TF }
+ { \str_if_eq_return:on { \use_none:nn #1 ?? } {?} }
+\prg_new_conditional:Npnn \tl_if_single_token:n #1 { p , T , F , TF }
{
- \if_false: { \fi:
- \tl_if_head_eq_space_aux:w \prg_do_nothing: #1 ? ~ }
+ \tl_if_head_N_type:nTF {#1}
+ { \str_if_eq_return:on { \use_none:n #1 } { } }
+ { \str_if_eq_return:on { ~ } { #1 } }
}
-\cs_new:Npn \tl_if_head_eq_space_aux:w #1 ~ %
+\cs_new:Npn \tl_act:NNNnn { \tex_romannumeral:D \tl_act_aux:NNNnn }
+\cs_new:Npn \tl_act_aux:NNNnn #1 #2 #3 #4 #5
{
- \tl_if_empty_return:o { #1 }
- \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
+ \tl_act_loop:w #5 \q_tl_act_mark \q_tl_act_stop
+ {#4} #1 #2 #3
+ \tl_act_result:n { }
}
-\prg_new_conditional:Npnn \tl_if_single_token:n #1 { p , T , F , TF }
+\cs_new:Npn \tl_act_loop:w #1 \q_tl_act_stop
{
- \tl_if_head_eq_space:nTF {#1}
+ \tl_if_head_N_type:nTF {#1}
+ { \tl_act_normal:NwnNNN }
{
- \str_if_eq:nnTF {#1} {~}
- \prg_return_true: \prg_return_false:
+ \tl_if_head_group:nTF {#1}
+ { \tl_act_group:nwnNNN }
+ { \tl_act_space:wwnNNN }
}
+ #1 \q_tl_act_stop
+ }
+\cs_new:Npn \tl_act_normal:NwnNNN #1 #2 \q_tl_act_stop #3#4
+ {
+ \if_meaning:w \q_tl_act_mark #1
+ \exp_after:wN \tl_act_end:wn
+ \fi:
+ #4 {#3} #1
+ \tl_act_loop:w #2 \q_tl_act_stop
+ {#3} #4
+ }
+\cs_new:Npn \tl_act_end:wn #1 \tl_act_result:n #2 { \c_zero #2 }
+\cs_new:Npn \tl_act_group:nwnNNN #1 #2 \q_tl_act_stop #3#4#5
+ {
+ #5 {#3} {#1}
+ \tl_act_loop:w #2 \q_tl_act_stop
+ {#3} #4 #5
+ }
+\exp_last_unbraced:NNo
+ \cs_new:Npn \tl_act_space:wwnNNN \c_space_tl #1 \q_tl_act_stop #2#3#4#5
+ {
+ #5 {#2}
+ \tl_act_loop:w #1 \q_tl_act_stop
+ {#2} #3 #4 #5
+ }
+\cs_new:Npn \tl_act_output:n #1 #2 \tl_act_result:n #3
+ { #2 \tl_act_result:n { #3 #1 } }
+\cs_new:Npn \tl_act_reverse_output:n #1 #2 \tl_act_result:n #3
+ { #2 \tl_act_result:n { #1 #3 } }
+\cs_new:Npn \tl_act_group_recurse:Nnn #1#2#3
+ {
+ \exp_args:Nf #1
+ { \exp_after:wN \exp_after:wN \exp_after:wN { #2 {#3} } }
+ }
+\cs_new:Npn \tl_reverse_tokens:n
+ {
+ \tex_romannumeral:D
+ \tl_act_aux:NNNnn
+ \tl_act_reverse_normal:nN
+ \tl_act_reverse_group:nn
+ \tl_act_reverse_space:n
+ { }
+ }
+\cs_new:Npn \tl_act_reverse_space:n #1
+ { \tl_act_reverse_output:n {~} }
+\cs_new:Npn \tl_act_reverse_normal:nN #1 #2
+ { \tl_act_reverse_output:n {#2} }
+\cs_new:Npn \tl_act_reverse_group:nn #1
+ {
+ \tl_act_group_recurse:Nnn
+ \tl_act_reverse_output:n
+ { \tl_reverse_tokens:n }
+ }
+\cs_new:Npn \tl_reverse:n
+ {
+ \tex_romannumeral:D
+ \tl_act_aux:NNNnn
+ \tl_act_reverse_normal:nN
+ \tl_act_reverse_group_preserve:nn
+ \tl_act_reverse_space:n
+ { }
+ }
+\cs_new:Npn \tl_act_reverse_group_preserve:nn #1 #2
+ { \tl_act_reverse_output:n { {#2} } }
+\cs_generate_variant:Nn \tl_reverse:n { o , V }
+\cs_new_protected_nopar:Npn \tl_reverse:N #1
+ { \tl_set:No #1 { \etex_unexpanded:D \tl_reverse:o { #1 { } } } }
+\cs_generate_variant:Nn \tl_reverse:N { c }
+\cs_new:Npn \tl_length_tokens:n #1
+ {
+ \int_eval:n
{
- \str_if_eq:onTF { \use_none:n #1 ? } {?}
- {
- \tl_if_head_begin_group:nTF {#1}
- \prg_return_false: \prg_return_true:
- }
- \prg_return_false:
+ \tl_act_aux:NNNnn
+ \tl_act_length_normal:nN
+ \tl_act_length_group:nn
+ \tl_act_length_space:n
+ { }
+ {#1}
+ }
+ }
+\cs_new:Npn \tl_act_length_normal:nN #1 #2 { 1 + }
+\cs_new:Npn \tl_act_length_space:n #1 { 1 + }
+\cs_new:Npn \tl_act_length_group:nn #1 #2
+ { 2 + \tl_length_tokens:n {#2} + }
+\tl_const:Nn \c_tl_act_uppercase_tl
+ {
+ aA bB cC dD eE fF gG hH iI jJ kK lL mM
+ nN oO pP qQ rR sS tT uU vV wW xX yY zZ
+ }
+\tl_const:Nn \c_tl_act_lowercase_tl
+ {
+ Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm
+ Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz
+ }
+\cs_new:Npn \tl_expandable_uppercase:n
+ { \tex_romannumeral:D \tl_act_case_aux:nn { \c_tl_act_uppercase_tl } }
+\cs_new:Npn \tl_expandable_lowercase:n
+ { \tex_romannumeral:D \tl_act_case_aux:nn { \c_tl_act_lowercase_tl } }
+\cs_new:Npn \tl_act_case_aux:nn
+ {
+ \tl_act_aux:NNNnn
+ \tl_act_case_normal:nN
+ \tl_act_case_group:nn
+ \tl_act_case_space:n
+ }
+\cs_new:Npn \tl_act_case_space:n #1 { \tl_act_output:n {~} }
+\cs_new:Npn \tl_act_case_normal:nN #1 #2
+ {
+ \exp_args:Nf \tl_act_output:n
+ {
+ \exp_args:NNo \prg_case_str:nnn #2 {#1}
+ { \exp_stop_f: #2 }
}
}
+\cs_new:Npn \tl_act_case_group:nn #1 #2
+ {
+ \exp_after:wN \tl_act_output:n \exp_after:wN
+ { \exp_after:wN { \tex_romannumeral:D \tl_act_case_aux:nn {#1} {#2} } }
+ }
\cs_new_protected:Npn \tl_new:Nn #1#2
{
\tl_new:N #1