diff options
author | Karl Berry <karl@freefriends.org> | 2019-08-26 21:05:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-08-26 21:05:47 +0000 |
commit | bfd55e1fa306b0e1c0db5fc689fb45b81d5da0c8 (patch) | |
tree | 7abd27cdb5a328a0ba00c48698439588ec5edab8 /Master/texmf-dist/source/latex/l3kernel/l3prop.dtx | |
parent | 69257bb16c7433813887ca515263e76c85c6c0e9 (diff) |
l3 (26aug19)
git-svn-id: svn://tug.org/texlive/trunk@51962 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3prop.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3prop.dtx | 108 |
1 files changed, 65 insertions, 43 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx index 7b0fb5aa39f..d79073065dc 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2019-08-14} +% \date{Released 2019-08-25} % % \maketitle % @@ -339,6 +339,10 @@ % % \section{Mapping to property lists} % +% All mappings are done at the current group level, \emph{i.e.}~any +% local assignments made by the \meta{function} or \meta{code} discussed +% below remain in effect after the loop. +% % \begin{function}[updated = 2013-01-08, rEXP] % {\prop_map_function:NN, \prop_map_function:cN} % \begin{syntax} @@ -634,6 +638,13 @@ % \end{variable} % \end{variable} % +% \begin{variable}{\l_@@_internal_prop} +% Property list used by \cs{prop_set_from_keyval:Nn} and others. +% \begin{macrocode} +\prop_new:N \l_@@_internal_prop +% \end{macrocode} +% \end{variable} +% % \begin{macro}{\prop_set_from_keyval:Nn, \prop_set_from_keyval:cn} % \begin{macro}{\prop_gset_from_keyval:Nn, \prop_gset_from_keyval:cn} % \begin{macro}{\prop_const_from_keyval:Nn, \prop_const_from_keyval:cn} @@ -647,69 +658,80 @@ % \@@_from_keyval_value:n, % \@@_from_keyval_value:w % } -% Loop through items separated by commas, with \cs{q_mark} to avoid -% losing braces. After checking for termination, split the item at -% the first then at the second |=| (which ought to be the first of the -% trailing~|=|). At both splits, trim spaces and -% call \cs{@@_from_keyval_key:w}, then \cs{@@_from_keyval_value:w}, -% followed by the trimmed material, \cs{q_nil}, the subsequent part of -% the item, and the trailing |=|'s and \cs{q_stop}. After finding the -% \meta{key} just store it after \cs{q_stop}. After finding the -% \meta{value} ignore completely empty items (both trailing~|=| were -% used as delimiters and all parts are empty); if the remaining -% part~|#2| consists exactly of the second trailing~|=| (namely there -% was exactly one |=|~in the item) then output one key--value pair for -% the property list; otherwise complain about a missing or extra~|=|. +% To avoid tracking throughout the loop the variable name and whether +% the assignment is local/global, do everything in a scratch variable +% and empty it afterwards to avoid wasting memory. Loop through items +% separated by commas, with \cs{prg_do_nothing:} to avoid losing +% braces. After checking for termination, split the item at the first +% and then at the second |=| (which ought to be the first of the +% trailing~|=| that we added). For both splits trim spaces and call a +% function (first \cs{@@_from_keyval_key:w} then +% \cs{@@_from_keyval_value:w}), followed by the trimmed material, +% \cs{q_nil}, the subsequent part of the item, and the trailing |=|'s +% and \cs{q_stop}. After finding the \meta{key} just store it after +% \cs{q_stop}. After finding the \meta{value} ignore completely empty +% items (both trailing~|=| were used as delimiters and all parts are +% empty); if the remaining part~|#2| consists exactly of the second +% trailing~|=| (namely there was exactly one |=|~in the item) then +% output one key--value pair for the property list; otherwise complain +% about a missing or extra~|=|. % \begin{macrocode} \cs_new_protected:Npn \prop_set_from_keyval:Nn #1#2 - { \tl_set:Nx #1 { \@@_from_keyval:n {#2} } } + { + \prop_clear:N \l_@@_internal_prop + \@@_from_keyval:n {#2} + \prop_set_eq:NN #1 \l_@@_internal_prop + \prop_clear:N \l_@@_internal_prop + } \cs_generate_variant:Nn \prop_set_from_keyval:Nn { c } \cs_new_protected:Npn \prop_gset_from_keyval:Nn #1#2 - { \tl_gset:Nx #1 { \@@_from_keyval:n {#2} } } + { + \prop_clear:N \l_@@_internal_prop + \@@_from_keyval:n {#2} + \prop_gset_eq:NN #1 \l_@@_internal_prop + \prop_clear:N \l_@@_internal_prop + } \cs_generate_variant:Nn \prop_gset_from_keyval:Nn { c } \cs_new_protected:Npn \prop_const_from_keyval:Nn #1#2 - { \tl_const:Nx #1 { \@@_from_keyval:n {#2} } } + { + \prop_clear:N \l_@@_internal_prop + \@@_from_keyval:n {#2} + \tl_const:Nx #1 { \exp_not:o \l_@@_internal_prop } + \prop_clear:N \l_@@_internal_prop + } \cs_generate_variant:Nn \prop_const_from_keyval:Nn { c } -\cs_new:Npn \@@_from_keyval:n #1 +\cs_new_protected:Npn \@@_from_keyval:n #1 { - \s_@@ - \@@_from_keyval_loop:w \q_mark #1 , + \@@_from_keyval_loop:w \prg_do_nothing: #1 , \q_recursion_tail , \q_recursion_stop } -\cs_new:Npn \@@_from_keyval_loop:w #1 , +\cs_new_protected:Npn \@@_from_keyval_loop:w #1 , { - \quark_if_recursion_tail_stop:o { \use_none:n #1 } + \quark_if_recursion_tail_stop:o {#1} \@@_from_keyval_split:Nw \@@_from_keyval_key:n - #1 = = \q_stop { \use_none:n #1 } - \@@_from_keyval_loop:w \q_mark + #1 = = \q_stop {#1} + \@@_from_keyval_loop:w \prg_do_nothing: } -\cs_new:Npn \@@_from_keyval_split:Nw #1#2 = - { - \tl_trim_spaces_apply:oN { \use_none:n #2 } #1 - \q_nil - } -\cs_new:Npn \@@_from_keyval_key:n #1 - { \@@_from_keyval_key:w #1 } -\cs_new:Npn \@@_from_keyval_key:w #1 \q_nil #2 \q_stop +\cs_new_protected:Npn \@@_from_keyval_split:Nw #1#2 = + { \tl_trim_spaces_apply:oN {#2} #1 } +\cs_new_protected:Npn \@@_from_keyval_key:n #1 + { \@@_from_keyval_key:w #1 \q_nil } +\cs_new_protected:Npn \@@_from_keyval_key:w #1 \q_nil #2 \q_stop { \@@_from_keyval_split:Nw \@@_from_keyval_value:n - \q_mark #2 \q_stop {#1} + \prg_do_nothing: #2 \q_stop {#1} } -\cs_new:Npn \@@_from_keyval_value:n #1 - { \@@_from_keyval_value:w #1 } -\cs_new:Npn \@@_from_keyval_value:w #1 \q_nil #2 \q_stop #3#4 +\cs_new_protected:Npn \@@_from_keyval_value:n #1 + { \@@_from_keyval_value:w #1 \q_nil } +\cs_new_protected:Npn \@@_from_keyval_value:w #1 \q_nil #2 \q_stop #3#4 { \tl_if_empty:nF { #3 #1 #2 } { \str_if_eq:nnTF {#2} { = } + { \prop_put:Nnn \l_@@_internal_prop {#3} {#1} } { - \exp_not:N \@@_pair:wn \tl_to_str:n {#3} - \s_@@ { \exp_not:n {#1} } - } - { - \__kernel_msg_expandable_error:nnf - { kernel } { prop-keyval } - { \exp_after:wN \exp_stop_f: #4 } + \__kernel_msg_error:nnx { kernel } { prop-keyval } + { \exp_not:o {#4} } } } } |