diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3tl.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3tl.sty | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty index 34238f643f0..e86c27e6c34 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 2498 2011-07-09 17:51:47Z joseph $ +\GetIdInfo$Id: l3tl.dtx 2534 2011-08-10 18:21:44Z joseph $ {L3 Experimental token lists} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -498,24 +498,29 @@ \group_end: \cs_generate_variant:Nn \tl_trim_spaces:N { c } \cs_generate_variant:Nn \tl_gtrim_spaces:N { c } -\cs_new:Npn \tl_head:n #1 { \tl_head:w #1 \q_stop } -\cs_new:Npn \tl_tail:n #1 { \tl_tail:w #1 \q_stop } \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 } } +\cs_new:Npn \tl_tail:n #1 + { \tl_if_blank:nF {#1} { \tl_tail:w #1 \q_stop } } \cs_generate_variant:Nn \tl_head:n { V , v , f } \cs_generate_variant:Nn \tl_tail:n { V , v , f } -\prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF } +\cs_new:Npn \str_head:n #1 { - \exp_after:wN \if_meaning:w \tl_head:w #1 \q_stop #2 - \prg_return_true: - \else: - \prg_return_false: - \fi: + \exp_after:wN \str_head_aux:w + \tl_to_str:n {#1} + { \scan_stop: } ~ \q_stop } +\cs_new_nopar:Npn \str_head_aux:w #1 ~ % + { \tl_head:w #1 { ~ } } \prg_new_conditional:Npnn \tl_if_head_eq_charcode:nN #1#2 { p , T , F , TF } { - \exp_after:wN \if:w - \exp_after:wN \exp_not:N \tl_head:w #1 \q_stop \exp_not:N #2 + \if_charcode:w + \exp_not:N #2 + \str_if_eq:onTF { \use:n #1 ? } { #1 ? } + { \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop } + { \str_head:n {#1} } \prg_return_true: \else: \prg_return_false: @@ -525,11 +530,55 @@ \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNTF { f } \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNT { f } \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNF { f } -\prg_new_conditional:Npnn \tl_if_head_eq_catcode:nN #1#2 { p , T , F , TF } +\prg_new_conditional:Npnn \tl_if_head_eq_catcode:nN #1 #2 { p , T , F , TF } + { + \if_catcode:w + \exp_not:N #2 + \str_if_eq:onTF { \use:n #1 ? } { #1 ? } + { \exp_after:wN \exp_not:N \tl_head:w #1 \q_nil \q_stop } + { + \tl_if_head_begin_group:nTF {#1} + { \c_group_begin_token } + { \c_space_token } + } + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\prg_new_conditional:Npnn \tl_if_head_eq_meaning:nN #1#2 { p , T , F , TF } { - \exp_after:wN \if_catcode:w \exp_after:wN \exp_not:N - \tl_head:w #1 \q_stop \exp_not:N #2 - \prg_return_true: \else: \prg_return_false: \fi: + \str_if_eq:onTF { \use:n #1 ? } { #1 ? } + { \tl_if_head_eq_meaning_aux_normal:nN } + { \tl_if_head_eq_meaning_aux_special:nN } + {#1} #2 + } +\cs_new:Npn \tl_if_head_eq_meaning_aux_normal:nN #1 #2 + { + \exp_after:wN \if_meaning:w \tl_head:w #1 \q_nil \q_stop #2 + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\cs_new:Npn \tl_if_head_eq_meaning_aux_special:nN #1 #2 + { + \if_charcode:w \str_head:n {#1} \exp_not:N #2 + \exp_after:wN \use:n + \else: + \prg_return_false: + \exp_after:wN \use_none:n + \fi: + { + \if_catcode:w \exp_not:N #2 + \tl_if_head_begin_group:nTF {#1} + { \c_group_begin_token } + { \c_space_token } + \prg_return_true: + \else: + \prg_return_false: + \fi: + } } \cs_new_protected:Npn \tl_show:N #1 { \cs_show:N #1 } \cs_generate_variant:Nn \tl_show:N { c } |