diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-29 23:03:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-29 23:03:42 +0000 |
commit | 7a50f35d6fd3bd705c78298b1ccc085991638f87 (patch) | |
tree | 7f749391d34aa12a37a30a33c00b3098b2320e7c /Master/texmf-dist/source/latex/l3kernel/l3clist.dtx | |
parent | 0bc9393ae50667d7ff769a76321a9548a70351fc (diff) |
l3kernel 3109 (29dec11)
git-svn-id: svn://tug.org/texlive/trunk@24971 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3clist.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3clist.dtx | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx index f1ef8dfe7b8..e04b2227944 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{l3names} -\GetIdInfo$Id: l3clist.dtx 3029 2011-12-06 22:47:30Z joseph $ +\GetIdInfo$Id: l3clist.dtx 3086 2011-12-22 17:55:46Z bruno $ {L3 Experimental comma separated lists} %</driver|package> %<*driver> @@ -132,7 +132,7 @@ % \cs{clist_set_eq:NN} \meta{comma list1} \meta{comma list2} % \end{syntax} % Sets the content of \meta{comma list1} equal to that of -% \meta{comma list2}. +% \meta{comma list2}. % \end{function} % % \begin{function} @@ -571,6 +571,19 @@ % \meta{comma list}. % \end{function} % +% \begin{function}[EXP, pTF, added = 2011-12-07]{\clist_if_empty:n} +% \begin{syntax} +% \cs{clist_if_empty_p:n} \Arg{comma list} +% \cs{clist_if_empty:nTF} \Arg{comma list} \Arg{true code} \Arg{false code} +% \end{syntax} +% Tests if the \meta{comma list} is empty (containing no items). +% The rules for space trimming are as for other \texttt{n}-type +% comma-list functions, hence the comma list |{~,~,,~}| (without +% outer braces) is empty, while |{~,{},}| (without outer braces) +% contains one element, which happens to be empty: the comma-list +% is not empty. +% \end{function} +% % \section{Internal comma-list functions} % % \begin{function}[added = 2011-07-09, rEXP]{\clist_trim_spaces:n} @@ -693,7 +706,7 @@ { \clist_concat_aux:NNNN \tl_set:Nx } \cs_new_protected_nopar:Npn \clist_gconcat:NNN { \clist_concat_aux:NNNN \tl_gset:Nx } -\cs_new_protected_nopar:Npn \clist_concat_aux:NNNN #1#2#3#4 +\cs_new_protected:Npn \clist_concat_aux:NNNN #1#2#3#4 { #1 #2 { @@ -867,7 +880,7 @@ % \UnitTested % \begin{macro}[aux]{\clist_put_right_aux:NNNn} % \begin{macrocode} -\cs_new_protected:Npn \clist_put_right:Nn +\cs_new_protected_nopar:Npn \clist_put_right:Nn { \clist_put_right_aux:NNNn \clist_concat:NNN \clist_set:Nn } \cs_new_protected_nopar:Npn \clist_gput_right:Nn { \clist_put_right_aux:NNNn \clist_gconcat:NNN \clist_gset:Nn } @@ -893,7 +906,7 @@ % Getting an item from the left of a comma list is pretty easy: just % trim off the first item using the comma. % \begin{macrocode} -\cs_new_protected_nopar:Npn \clist_get:NN #1#2 +\cs_new_protected:Npn \clist_get:NN #1#2 { \exp_after:wN \clist_get_aux:wN #1 , \q_stop #2 } \cs_new_protected:Npn \clist_get_aux:wN #1 , #2 \q_stop #3 { \tl_set:Nn #3 {#1} } @@ -917,7 +930,7 @@ { \clist_pop_aux:NNN \tl_set:Nf } \cs_new_protected_nopar:Npn \clist_gpop:NN { \clist_pop_aux:NNN \tl_gset:Nf } -\cs_new_protected_nopar:Npn \clist_pop_aux:NNN #1#2#3 +\cs_new_protected:Npn \clist_pop_aux:NNN #1#2#3 { \exp_after:wN \clist_pop_aux:wNNN #2 , \q_nil \q_stop #1#2#3 } @@ -1165,7 +1178,7 @@ % The auxiliary function \cs{clist_map_function_aux:Nw} is used % directly in \cs{clist_map_inline:Nn}. Change with care. % \begin{macrocode} -\cs_new_nopar:Npn \clist_map_function:NN #1#2 +\cs_new:Npn \clist_map_function:NN #1#2 { \clist_if_empty:NF #1 { @@ -1313,7 +1326,7 @@ % in a scratch variable, then show that variable, % omitting its name from the $4$-th argument. % \begin{macrocode} -\cs_new_protected_nopar:Npn \clist_show:N #1 +\cs_new_protected:Npn \clist_show:N #1 { \msg_aux_show:Nnx #1 @@ -1542,6 +1555,39 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[EXP, pTF]{\clist_if_empty:n} +% \begin{macro}[aux, EXP]{\clist_if_empty_n_aux:w} +% \begin{macro}[aux, EXP]{\clist_if_empty_n_aux:wNw} +% As usual, we insert a token (here |?|) before grabbing +% any argument: this avoids losing braces. The argument +% of \cs{tl_if_empty:oTF} is empty if |#1| is |?| followed +% by blank spaces (besides, this particular variant of +% the emptyness test is optimized). If the item of the +% comma list is blank, grab the next one. As soon as one +% item is non-blank, exit: the second auxiliary will grab +% \cs{prg_return_false:} as |#2|, unless every item in +% the comma list was blank and the loop actually got broken +% by the trailing |\q_mark \prg_return_false:| item. +% \begin{macrocode} +\prg_new_conditional:Npnn \clist_if_empty:n #1 { p , T , F , TF } + { + \clist_if_empty_n_aux:w ? #1 + , \q_mark \prg_return_false: + , \q_mark \prg_return_true: + \q_stop + } +\cs_new:Npn \clist_if_empty_n_aux:w #1 , + { + \tl_if_empty:oTF { \use_none:nn #1 ? } + { \clist_if_empty_n_aux:w ? } + { \clist_if_empty_n_aux:wNw } + } +\cs_new:Npn \clist_if_empty_n_aux:wNw #1 \q_mark #2#3 \q_stop {#2} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% % \subsection{Deprecated interfaces} % % Deprecated on 2011-05-27, for removal by 2011-08-31. |