diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-11 22:32:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-11 22:32:04 +0000 |
commit | 3cc0c51eddc31f37b82f651016191bf3575f3aac (patch) | |
tree | 85e3f4cfbe245c416571020e0eb1136193596550 /Master/texmf-dist/tex/latex/l3kernel/l3clist.sty | |
parent | c56f30c6154e55286a21f438d5ed545a5169f13b (diff) |
l3kernel 3036 (11dec11)
git-svn-id: svn://tug.org/texlive/trunk@24822 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3clist.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3clist.sty | 174 |
1 files changed, 85 insertions, 89 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty index ded66383b4a..3dd557d6b8a 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty @@ -47,12 +47,12 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3clist.dtx 2896 2011-10-09 20:36:50Z joseph $ +\GetIdInfo$Id: l3clist.dtx 3029 2011-12-06 22:47:30Z joseph $ {L3 Experimental comma separated lists} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \package_check_loaded_expl: -\tl_new:N \l_clist_tmpa_tl +\tl_new:N \l_clist_tmpa_clist \cs_new_protected:Npn \clist_tmp:w { } \cs_new_eq:NN \clist_new:N \tl_new:N \cs_new_eq:NN \clist_new:c \tl_new:c @@ -109,24 +109,23 @@ \cs_new:Npn \clist_trim_spaces_generic_aux_ii:nn #1 #2 { #2 {#1} } \cs_new:Npn \clist_trim_spaces:n #1 { - \clist_trim_spaces_aux:n { } \q_mark #1 , - \q_recursion_tail, \q_recursion_stop - } -\cs_new:Npn \clist_trim_spaces_aux:n #1 - { \clist_trim_spaces_generic:nw - { \clist_trim_spaces_aux_ii:nn {#1} } + { \clist_trim_spaces_aux:nn { } } + \q_mark #1 , + \q_recursion_tail, \q_recursion_stop } -\cs_new:Npn \clist_trim_spaces_aux_ii:nn #1 #2 +\cs_new:Npn \clist_trim_spaces_aux:nn #1 #2 { \quark_if_recursion_tail_stop:n {#2} \tl_if_empty:nTF {#2} { - \clist_trim_spaces_aux:n {#1} \q_mark + \clist_trim_spaces_generic:nw + { \clist_trim_spaces_aux:nn {#1} } \q_mark } { #1 \exp_not:n {#2} - \clist_trim_spaces_aux:n { , } \q_mark + \clist_trim_spaces_generic:nw + { \clist_trim_spaces_aux:nn { , } } \q_mark } } \cs_new_protected:Npn \clist_set:Nn #1#2 @@ -136,27 +135,27 @@ \cs_generate_variant:Nn \clist_set:Nn { NV , No , Nx , c , cV , co , cx } \cs_generate_variant:Nn \clist_gset:Nn { NV , No , Nx , c , cV , co , cx } \cs_new_protected_nopar:Npn \clist_put_left:Nn - { \clist_put_aux:NNnnNn \tl_set_eq:NN \tl_put_left:Nx { } , } + { \clist_put_left_aux:NNNn \clist_concat:NNN \clist_set:Nn } \cs_new_protected_nopar:Npn \clist_gput_left:Nn - { \clist_put_aux:NNnnNn \tl_gset_eq:NN \tl_gput_left:Nx { } , } -\cs_new_protected:Npn \clist_put_aux:NNnnNn #1#2#3#4#5#6 + { \clist_put_left_aux:NNNn \clist_gconcat:NNN \clist_set:Nn } +\cs_new_protected:Npn \clist_put_left_aux:NNNn #1#2#3#4 { - \tl_set:Nx \l_clist_tmpa_tl { \clist_trim_spaces:n {#6} } - \clist_if_empty:NTF #5 - { #1 #5 \l_clist_tmpa_tl } - { - \tl_if_empty:NF \l_clist_tmpa_tl - { #2 #5 { #3 \exp_not:o \l_clist_tmpa_tl #4 } } - } + #2 \l_clist_tmpa_clist {#4} + #1 #3 \l_clist_tmpa_clist #3 } \cs_generate_variant:Nn \clist_put_left:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_put_left:Nn { c , cV , co , cx } \cs_generate_variant:Nn \clist_gput_left:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_gput_left:Nn { c , cV , co , cx } \cs_new_protected:Npn \clist_put_right:Nn - { \clist_put_aux:NNnnNn \tl_set_eq:NN \tl_put_right:Nx , { } } + { \clist_put_right_aux:NNNn \clist_concat:NNN \clist_set:Nn } \cs_new_protected_nopar:Npn \clist_gput_right:Nn - { \clist_put_aux:NNnnNn \tl_gset_eq:NN \tl_gput_right:Nx , { } } + { \clist_put_right_aux:NNNn \clist_gconcat:NNN \clist_gset:Nn } +\cs_new_protected:Npn \clist_put_right_aux:NNNn #1#2#3#4 + { + #2 \l_clist_tmpa_clist {#4} + #1 #3 #3 \l_clist_tmpa_clist + } \cs_generate_variant:Nn \clist_put_right:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_put_right:Nn { c , cV , co , cx } \cs_generate_variant:Nn \clist_gput_right:Nn { NV , No , Nx } @@ -287,36 +286,47 @@ \clist_if_empty:NF #1 { \exp_last_unbraced:NNo \clist_map_function_aux:Nw #2 #1 - , \q_recursion_tail , \q_recursion_stop + , \q_recursion_tail , + \prg_break_point:n { } } } \cs_new:Npn \clist_map_function_aux:Nw #1#2 , { - \quark_if_recursion_tail_stop:n {#2} + \quark_if_recursion_tail_break:n {#2} #1 {#2} \clist_map_function_aux:Nw #1 } \cs_generate_variant:Nn \clist_map_function:NN { c } -\int_new:N \g_clist_map_inline_int +\cs_new:Npn \clist_map_function:nN #1#2 + { + \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #2 } + \q_mark #1, \q_recursion_tail, + \prg_break_point:n { } + } +\cs_new:Npn \clist_map_function_n_aux:Nn #1 #2 + { + \quark_if_recursion_tail_break:n {#2} + \tl_if_empty:nF {#2} { \clist_map_aux_unbrace:Nw #1 #2, } + \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #1 } + \q_mark + } +\cs_new:Npn \clist_map_aux_unbrace:Nw #1 #2, { #1 {#2} } \cs_new_protected:Npn \clist_map_inline:Nn #1#2 { - \int_gincr:N \g_clist_map_inline_int - \cs_gset:cpn { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } - ##1 - {#2} - \exp_args:NNc \clist_map_function:NN #1 - { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } - \int_gdecr:N \g_clist_map_inline_int + \clist_if_empty:NF #1 + { + \int_gincr:N \g_prg_map_int + \cs_gset:cpn { clist_map_ \int_use:N \g_prg_map_int :n } ##1 {#2} + \exp_last_unbraced:Nco \clist_map_function_aux:Nw + { clist_map_ \int_use:N \g_prg_map_int :n } + #1 , \q_recursion_tail , + \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + } } -\cs_new_protected:Npn \clist_map_inline:nn #1#2 +\cs_new_protected:Npn \clist_map_inline:nn #1 { - \int_gincr:N \g_clist_map_inline_int - \cs_gset:cpn { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } - ##1 - {#2} - \exp_args:Nnc \clist_map_function:nN {#1} - { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } - \int_gdecr:N \g_clist_map_inline_int + \clist_set:Nn \l_clist_tmpa_clist {#1} + \clist_map_inline:Nn \l_clist_tmpa_clist } \cs_generate_variant:Nn \clist_map_inline:Nn { c } \cs_new_protected:Npn \clist_map_variable:NNn #1#2#3 @@ -327,61 +337,39 @@ { \clist_map_variable_aux:Nnw #2 {#3} } #1 , \q_recursion_tail , \q_recursion_stop + \prg_break_point:n { } } } -\cs_new_protected:Npn \clist_map_variable_aux:Nnw #1#2#3 , - { - \quark_if_recursion_tail_stop:n {#3} - \tl_set:Nn #1 {#3} - #2 - \clist_map_variable_aux:Nnw #1 {#2} - } \cs_new_protected:Npn \clist_map_variable:nNn #1 { - \tl_set:Nx \l_clist_tmpa_tl { \clist_trim_spaces:n {#1} } - \clist_map_variable:NNn \l_clist_tmpa_tl - } -\cs_generate_variant:Nn \clist_map_variable:NNn { c } -\cs_new:Npn \clist_map_aux_unbrace:Nw #1 #2, { #1 {#2} } -\cs_new:Npn \clist_map_function:nN #1#2 - { - \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #2 } - \q_mark #1, \q_recursion_tail, \q_recursion_stop + \clist_set:Nn \l_clist_tmpa_clist {#1} + \clist_map_variable:NNn \l_clist_tmpa_clist } -\cs_new:Npn \clist_map_function_n_aux:Nn #1 #2 +\cs_new_protected:Npn \clist_map_variable_aux:Nnw #1#2#3, { - \quark_if_recursion_tail_stop:n {#2} - \tl_if_empty:nF {#2} { \clist_map_aux_unbrace:Nw #1 #2, } - \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #1 } - \q_mark + \tl_set:Nn #1 {#3} + \quark_if_recursion_tail_stop:N #1 + \use:n {#2} + \clist_map_variable_aux:Nnw #1 {#2} } -\cs_new_eq:NN \clist_map_break: \use_none_delimit_by_q_recursion_stop:w -\cs_new_eq:NN \clist_map_break:n \use_i_delimit_by_q_recursion_stop:nw +\cs_generate_variant:Nn \clist_map_variable:NNn { c } +\cs_new_eq:NN \clist_map_break: \prg_map_break: +\cs_new_eq:NN \clist_map_break:n \prg_map_break:n \cs_new_protected_nopar:Npn \clist_show:N #1 { - \clist_if_empty:NTF #1 - { - \iow_term:x { Comma~list~\token_to_str:N #1~is~empty } - \tl_show:n { } - } - { - \iow_term:x - { - Comma~list~\token_to_str:N #1~ - contains~the~items~(without~outer~braces): - } - \tl_set:Nx \l_clist_show_tl - { \clist_map_function:NN #1 \clist_show_aux:n } - \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \clist_show_aux:w \l_clist_show_tl } - } + \msg_aux_show:Nnx + #1 + { clist } + { \clist_map_function:NN #1 \msg_aux_show:n } } -\cs_new:Npn \clist_show_aux:n #1 +\cs_new_protected:Npn \clist_show:n #1 { - \iow_newline: > \c_space_tl \c_space_tl - \iow_char:N \{ \exp_not:n {#1} \iow_char:N \} + \clist_set:Nn \l_clist_tmpa_clist {#1} + \msg_aux_show:Nnx + \l_clist_tmpa_clist + { clist } + { \clist_map_function:NN \l_clist_tmpa_clist \msg_aux_show:n } } -\cs_new:Npn \clist_show_aux:w #1 > ~ { } \cs_generate_variant:Nn \clist_show:N { c } \clist_new:N \l_tmpa_clist \clist_new:N \l_tmpb_clist @@ -396,16 +384,21 @@ } } \cs_new:Npn \clist_length_aux:n #1 { +1 } -\cs_new:Npn \clist_length:n #1 +\cs_new:Npx \clist_length:n #1 { - \int_eval:n + \exp_not:N \int_eval:n { 0 - \clist_map_function_aux:Nw \clist_length_n_aux:n #1 - , \q_recursion_tail , \q_recursion_stop + \exp_not:N \clist_length_n_aux:w \c_space_tl + #1 \exp_not:n { , \q_recursion_tail , \q_recursion_stop } } } -\cs_new:Npn \clist_length_n_aux:n #1 { \tl_if_blank:nF {#1} {+1} } +\cs_new:Npx \clist_length_n_aux:w #1 , + { + \exp_not:n { \exp_args:Nf \quark_if_recursion_tail_stop:n } {#1} + \exp_not:N \tl_if_blank:nF {#1} { + \c_one } + \exp_not:N \clist_length_n_aux:w \c_space_tl + } \cs_generate_variant:Nn \clist_length:N { c } \cs_new:Npn \clist_item:Nn #1#2 { @@ -492,6 +485,9 @@ \cs_generate_variant:Nn \clist_set_from_seq:NN { c , cc } \cs_generate_variant:Nn \clist_gset_from_seq:NN { Nc } \cs_generate_variant:Nn \clist_gset_from_seq:NN { c , cc } +\cs_new_protected:Npn \clist_const:Nn #1#2 + { \tl_const:Nx #1 { \clist_trim_spaces:n {#2} } } +\cs_generate_variant:Nn \clist_const:Nn { c , Nx , cx } \cs_new_protected:Npn \clist_trim_spaces:N #1 { \clist_set:No #1 {#1} } \cs_new_protected:Npn \clist_gtrim_spaces:N #1 { \clist_gset:No #1 {#1} } \cs_generate_variant:Nn \clist_trim_spaces:N { c } |