diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3str.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3str.dtx | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/macros/latex/contrib/l3kernel/l3str.dtx b/macros/latex/contrib/l3kernel/l3str.dtx index 4ebc1af703..fc8594bf0b 100644 --- a/macros/latex/contrib/l3kernel/l3str.dtx +++ b/macros/latex/contrib/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2023-11-09} +% \date{Released 2023-12-08} % % \maketitle % @@ -127,7 +127,11 @@ % Clears the content of the \meta{str~var}. % \end{function} % -% \begin{function}[added = 2015-09-18]{\str_clear_new:N, \str_clear_new:c} +% \begin{function}[added = 2015-09-18] +% { +% \str_clear_new:N, \str_clear_new:c, +% \str_gclear_new:N, \str_gclear_new:c +% } % \begin{syntax} % \cs{str_clear_new:N} \meta{str~var} % \end{syntax} @@ -839,6 +843,10 @@ % code $12$. % \end{variable} % +% \begin{variable}[added = 2023-12-07]{\c_empty_str} +% Constant that is always empty. +% \end{variable} +% % \section{Scratch strings} % % \begin{variable}{\l_tmpa_str, \l_tmpb_str} @@ -855,16 +863,6 @@ % code and so should only be used for short-term storage. % \end{variable} % -% \section{Deprecated functions} -% -% \begin{function}[EXP, added = 2019-11-26] -% {\str_foldcase:n, \str_foldcase:V} -% \begin{syntax} -% \cs{str_foldcase:n} \Arg{tokens} -% \end{syntax} -% A previous name for the functionally-identical \cs{str_casefold:n}. -% \end{function} -% % \end{documentation} % % \begin{implementation} @@ -989,33 +987,53 @@ % \str_gput_right:Nn, \str_gput_right:NV, \str_gput_right:Ne, \str_gput_right:Nx, % \str_gput_right:cn, \str_gput_right:cV, \str_gput_right:ce, \str_gput_right:cx % } -% Simply convert the token list inputs to \meta{strings}. +% Similar to corresponding \pkg{l3tl} base functions, except that +% \cs{__kernel_exp_not:w} is replaced with \cs{__kernel_tl_to_str:w}. +% Just like token list, string constants use \cs{cs_gset_nopar:Npe} +% instead of \cs{__kernel_tl_gset:Ne} so that the scope checking for +% |c| is applied when \pkg{l3debug} is used. +% To maintain backward compatibility, in +% \cs[index=str_put_left:Nn]{str_(g)put_left:Nn} and +% \cs[index=str_put_right:Nn]{str_(g)put_right:Nn}, +% contents of string variables are wrapped in \cs{__kernel_exp_not:w} +% to prevent further expansion. % \begin{macrocode} -\group_begin: - \cs_set_protected:Npn \@@_tmp:n #1 - { - \tl_if_blank:nF {#1} - { - \cs_new_protected:cpe { str_ #1 :Nn } ##1##2 - { - \exp_not:c { tl_ #1 :Ne } ##1 - { \exp_not:N \tl_to_str:n {##2} } - } - \cs_generate_variant:cn { str_ #1 :Nn } - { NV , Ne , Nx , cn , cV , ce , cx } - \@@_tmp:n - } - } - \@@_tmp:n - { set } - { gset } - { const } - { put_left } - { gput_left } - { put_right } - { gput_right } - { } -\group_end: +\cs_new_protected:Npn \str_set:Nn #1#2 + { \__kernel_tl_set:Ne #1 { \__kernel_tl_to_str:w {#2} } } +\cs_gset_protected:Npn \str_gset:Nn #1#2 + { \__kernel_tl_gset:Ne #1 { \__kernel_tl_to_str:w {#2} } } +\cs_new_protected:Npn \str_const:Nn #1#2 + { + \__kernel_chk_if_free_cs:N #1 + \cs_gset_nopar:Npe #1 { \__kernel_tl_to_str:w {#2} } + } +\cs_new_protected:Npn \str_put_left:Nn #1#2 + { + \__kernel_tl_set:Ne #1 + { \__kernel_tl_to_str:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} } + } +\cs_new_protected:Npn \str_gput_left:Nn #1#2 + { + \__kernel_tl_gset:Ne #1 + { \__kernel_tl_to_str:w {#2} \__kernel_exp_not:w \exp_after:wN {#1} } + } +\cs_new_protected:Npn \str_put_right:Nn #1#2 + { + \__kernel_tl_set:Ne #1 + { \__kernel_exp_not:w \exp_after:wN {#1} \__kernel_tl_to_str:w {#2} } + } +\cs_new_protected:Npn \str_gput_right:Nn #1#2 + { + \__kernel_tl_gset:Ne #1 + { \__kernel_exp_not:w \exp_after:wN {#1} \__kernel_tl_to_str:w {#2} } + } +\cs_generate_variant:Nn \str_set:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_gset:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_const:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_put_left:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_gput_left:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_put_right:Nn { NV , Ne , Nx , c , cV , ce , cx } +\cs_generate_variant:Nn \str_gput_right:Nn { NV , Ne , Nx , c , cV , ce , cx } % \end{macrocode} % \end{macro} % @@ -2158,6 +2176,13 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_empty_str} +% An empty string is simply an empty token list. +% \begin{macrocode} +\cs_new_eq:NN \c_empty_str \c_empty_tl +% \end{macrocode} +% \end{variable} +% % \begin{variable}{\l_tmpa_str, \l_tmpb_str, \g_tmpa_str, \g_tmpb_str} % Scratch strings. % \begin{macrocode} |