diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3keys.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3keys.dtx | 110 |
1 files changed, 69 insertions, 41 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx index 8f5f984c79c..113760c9694 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2021-05-11} +% \date{Released 2021-05-25} % % \maketitle % @@ -1006,7 +1006,7 @@ % comma and |#2| will be the active equals sign. % \begin{macrocode} \group_begin: - \cs_set_protected:Npn \@@_tmp:NN #1#2 + \cs_set_protected:Npn \@@_tmp:w #1#2 { % \end{macrocode} % @@ -1016,10 +1016,27 @@ % The use of \cs{s_@@_mark} here prevents loss of braces from the key % argument. % \begin{macrocode} - \cs_new:Npn \keyval_parse:nnn ##1 ##2 ##3 + \cs_if_exist:NTF \tex_expanded:D { - \group_align_safe_begin: - \@@_loop_active:nnw {##1} {##2} \s_@@_mark ##3 #1 \s_@@_tail #1 + \cs_new:Npn \keyval_parse:nnn ##1 ##2 ##3 + { + \__kernel_exp_not:w \tex_expanded:D + { + { + \@@_loop_active:nnw {##1} {##2} + \s_@@_mark ##3 #1 \s_@@_tail #1 + } + } + } + } + { + \cs_new:Npn \keyval_parse:nnn ##1 ##2 ##3 + { + \group_align_safe_begin: + \@@_loop_active:nnw {##1} {##2} + \s_@@_mark ##3 #1 \s_@@_tail #1 + \group_align_safe_end: + } } \cs_new_eq:NN \keyval_parse:NNn \keyval_parse:nnn % \end{macrocode} @@ -1258,17 +1275,17 @@ \cs_new:Npn \@@_end_loop_active:w \s_@@_tail \@@_loop_other:nnw ##1 \s_@@_mark \s_@@_tail , \s_@@_tail , - { \group_align_safe_end: } + { } % \end{macrocode} % \end{macro} % -% The parsing loops are done, so here ends the definition of \cs{@@_tmp:NN}, +% The parsing loops are done, so here ends the definition of \cs{@@_tmp:w}, % which will finally set up the macros. % \begin{macrocode} } \char_set_catcode_active:n { `\, } \char_set_catcode_active:n { `\= } - \@@_tmp:NN , = + \@@_tmp:w , = \group_end: % \end{macrocode} % @@ -1279,24 +1296,32 @@ % \cs{exp_not:n} with the correct arguments. Afterwards they insert the next % iteration of the other loop. % \begin{macrocode} -\cs_new:Npn \@@_pair:nnnn #1 #2 #3 #4 - { - \@@_if_blank:w \s_@@_mark #2 \s_@@_nil \s_@@_stop \@@_blank_key_error:w - \s_@@_mark \s_@@_stop - \group_align_safe_end: - \exp_not:n { #4 { #2 } { #1 } } - \group_align_safe_begin: - \@@_loop_other:nnw {#3} {#4} - } -\cs_new:Npn \@@_key:nn #1 #2 - { - \@@_if_blank:w \s_@@_mark #1 \s_@@_nil \s_@@_stop \@@_blank_key_error:w - \s_@@_mark \s_@@_stop - \group_align_safe_end: - \exp_not:n { #2 { #1 } } - \group_align_safe_begin: - \@@_loop_other:nnw {#2} - } +\group_begin: + \cs_set_protected:Npn \@@_tmp:w #1#2 + { + \cs_new:Npn \@@_pair:nnnn ##1 ##2 ##3 ##4 + { + \@@_if_blank:w \s_@@_mark ##2 \s_@@_nil \s_@@_stop \@@_blank_key_error:w + \s_@@_mark \s_@@_stop + #1 + \exp_not:n { ##4 {##2} {##1} } + #2 + \@@_loop_other:nnw {##3} {##4} + } + \cs_new:Npn \@@_key:nn ##1 ##2 + { + \@@_if_blank:w \s_@@_mark ##1 \s_@@_nil \s_@@_stop \@@_blank_key_error:w + \s_@@_mark \s_@@_stop + #1 + \exp_not:n { ##2 {##1} } + #2 + \@@_loop_other:nnw {##2} + } + } + \cs_if_exist:NTF \tex_expanded:D + { \@@_tmp:w { } { } } + { \@@_tmp:w \group_align_safe_end: \group_align_safe_begin: } +\group_end: % \end{macrocode} % \end{macro} % @@ -1318,11 +1343,10 @@ % \begin{macrocode} \cs_new:Npn \@@_blank_true:w \s_@@_mark \s_@@_stop \@@_trim:nN #1 \@@_key:nn { \@@_loop_other:nnw } -\cs_new:Npn \@@_blank_key_error:w - \s_@@_mark \s_@@_stop \group_align_safe_end: \exp_not:n #1 +\cs_new:Npn \@@_blank_key_error:w #1 \@@_loop_other:nnw { - \__kernel_msg_expandable_error:nn - { keyval } { blank-key-name } + \__kernel_msg_expandable_error:nn { keyval } { blank-key-name } + \@@_loop_other:nnw } % \end{macrocode} % \end{macro} @@ -1346,7 +1370,7 @@ % worth it. % \begin{macrocode} \group_begin: - \cs_set_protected:Npn \@@_tmp:n #1 + \cs_set_protected:Npn \@@_tmp:w #1 { \cs_new:Npn \@@_trim:nN ##1 { @@ -1387,7 +1411,7 @@ ##2 { ##2 { ##1 } } } - \@@_tmp:n { ~ } + \@@_tmp:w { ~ } \group_end: % \end{macrocode} % \end{macro} @@ -1642,14 +1666,14 @@ % Searching for a property means finding the last |.| in the input, % and storing the text before and after it. Everything is turned into % strings, so there is no problem using an \texttt{x}-type expansion. Since -% |\__keys_trim_spaces:n| will turn its argument into a string anyway, this +% \cs{@@_trim_spaces:n} will turn its argument into a string anyway, this % function uses \cs{cs_set_nopar:Npx} instead of \cs{tl_set:Nx} to gain some % speed. % \begin{macrocode} \cs_new_protected:Npn \@@_property_find:n #1 { - \cs_set_nopar:Npx \l__keys_property_str { \__keys_trim_spaces:n { #1 } } - \exp_after:wN \@@_property_find_auxi:w \l__keys_property_str + \cs_set_nopar:Npx \l_@@_property_str { \@@_trim_spaces:n { #1 } } + \exp_after:wN \@@_property_find_auxi:w \l_@@_property_str \s_@@_nil \@@_property_find_auxii:w . \s_@@_nil \@@_property_find_err:w } @@ -1662,7 +1686,7 @@ \@@_property_find_err:w { \cs_set_nopar:Npx \l_keys_path_str - { \str_if_empty:NF \l__keys_module_str { \l__keys_module_str / } #1 } + { \str_if_empty:NF \l_@@_module_str { \l_@@_module_str / } #1 } \@@_property_find_auxi:w #2 \s_@@_nil \@@_property_find_auxiii:w . \s_@@_nil \@@_property_find_auxiv:w } @@ -1675,15 +1699,15 @@ #1 \s_@@_nil \@@_property_find_auxiii:w \s_@@_mark \s_@@_nil \@@_property_find_auxiv:w { - \cs_set_nopar:Npx \l__keys_property_str { . #1 } + \cs_set_nopar:Npx \l_@@_property_str { . #1 } \cs_set_nopar:Npx \l_keys_path_str - { \exp_after:wN \__keys_trim_spaces:n \exp_after:wN { \l_keys_path_str } } + { \exp_after:wN \@@_trim_spaces:n \exp_after:wN { \l_keys_path_str } } \tl_set_eq:NN \l_keys_path_tl \l_keys_path_str } \cs_new_protected:Npn \@@_property_find_err:w #1 \s_@@_nil #2 \@@_property_find_err:w { - \str_clear:N \l__keys_property_str + \str_clear:N \l_@@_property_str \__kernel_msg_error:nnn { keys } { no-property } {#1} } % \end{macrocode} @@ -2753,6 +2777,10 @@ % of groups which apply to a key with the list of those which have been % set active. That requires two mappings, and again a different outcome % depending on whether opt-in or opt-out is set. +% We cannot replace the clist mapping by \cs{clist_if_in:NnTF} because +% catcodes may not be the same; they cannot be normalized easily in the +% clist because of the remote possibility that some items need braces +% if they involve commas or leading/trailing spaces. % \begin{macrocode} \cs_new_protected:Npn \@@_check_groups: { @@ -3060,7 +3088,7 @@ % much faster to just directly strip spaces around |/|. % \begin{macrocode} \group_begin: - \cs_set:Npn \@@_tmp:n #1 + \cs_set:Npn \@@_tmp:w #1 { \cs_new:Npn \@@_trim_spaces:n ##1 { @@ -3072,7 +3100,7 @@ \s_@@_mark \@@_trim_spaces_auxiii:w } } - \@@_tmp:n { ~ } + \@@_tmp:w { ~ } \group_end: \cs_new:Npn \@@_trim_spaces_auxi:w #1 ~ / #2 \s_@@_nil #3 { |