diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental')
8 files changed, 416 insertions, 135 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3dt/l3dt.dtx b/Master/texmf-dist/source/latex/l3experimental/l3dt/l3dt.dtx index 63a3218f06a..36454f14c49 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3dt/l3dt.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3dt/l3dt.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3dt.dtx 4420 2013-01-08 20:00:04Z joseph $ +\GetIdInfo$Id: l3dt.dtx 4482 2013-04-24 21:05:12Z joseph $ {L3 Experimental data tables} %</driver|package> %<*driver> @@ -133,7 +133,7 @@ % \cs{dt_add_row:N} \meta{dt} % \end{syntax} % Adds a new row to the \meta{data table}. This will initially contain -% no entries: all keys will be be blank. +% no entries: all keys will be blank. % \end{function} % % \begin{function}{\dt_put:Nnn, \dt_gput:Nnn} diff --git a/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx b/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx index 1b3ac4d507a..b73a9084484 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3sort.dtx 4339 2012-11-24 19:16:43Z joseph $ +\GetIdInfo$Id: l3sort.dtx 4491 2013-05-12 16:22:18Z bruno $ {L3 Experimental sorting functions} %</driver|package> %<*driver> @@ -143,6 +143,11 @@ % and return \texttt{true} if the two items being compared should be % left in the same order, and \texttt{false} if the items should be % swapped. +% \begin{texnote} +% The result is returned within \cs{exp_not:n}, which means that the +% token list will not expand further when appearing in an +% \texttt{x}-type argument expansion. +% \end{texnote} % \end{function} % % \end{documentation} @@ -233,98 +238,6 @@ % \end{variable} % \end{variable} % -% \subsection{Expandable sorting} -% -% Sorting expandably is very different from sorting and assigning to a -% variable. Since tokens cannot be stored, they must remain in the -% input stream, and be read through at every step. It is thus -% necessarily much slower (at best $O(n^2)$) than non-expandable sorting -% functions. -% -% A prototypical version of expandable quicksort is as follows. If the -% argument has no item, return nothing, otherwise partition, using the -% first item as a pivot (argument |#4| of |\__sort:nnNnn|). The -% arguments of \cs{__sort:nnNnn} are 1.~items less than |#4|, 2.~items -% greater than |#4|, 3.~comparison, 4.~pivot, 5.~next item to test. If -% |#5| is the tail of the list, call \cs{tl_sort:nN} on |#1| and on -% |#2|, placing |#4| in between; |\use:ff| expands the parts to make -% \cs{tl_sort:nN} \texttt{f}-expandable. Otherwise, compare |#4| and -% |#5| using |#3|. If they are ordered, place |#5| amongst the -% \enquote{greater} items, otherwise amongst the \enquote{lesser} items, -% and continue partitioning. -% \begin{verbatim} -% \cs_new:Npn \tl_sort:nN #1#2 -% { -% \tl_if_blank:nF {#1} -% { -% \__sort:nnNnn { } { } #2 -% #1 \q_recursion_tail \q_recursion_stop -% } -% } -% \cs_new:Npn \__sort:nnNnn #1#2#3#4#5 -% { -% \quark_if_recursion_tail_stop_do:nn {#5} -% { \use:ff { \tl_sort:nN {#1} #3 {#4} } { \tl_sort:nN {#2} #3 } } -% #3 {#4} {#5} -% { \__sort:nnNnn {#1} { #2 {#5} } #3 {#4} } -% { \__sort:nnNnn { #1 {#5} } {#2} #3 {#4} } -% } -% \cs_generate_variant:Nn \use:nn { ff } -% \end{verbatim} -% There are quite a few optimizations available here: the code below is -% less legible, but twice as fast. -% -% \begin{macro}[EXP]{\tl_sort:nN} -% \begin{macro}[EXP, aux] -% { -% \@@_quick:nNn, \@@_quick:wn, -% \@@_quick:nnNnn, \@@_quick:nnNnwn -% } -% The \cs{@@_quick:nNn} function sorts |#1| using the comparison -% |#2|, then places its third argument (\meta{continuation}) before -% the result. This essentially avoids the rather slow \cs{use:ff}. -% First test if |#1| is blank: if it is, \cs{use_none:n} eats the -% break point, and \cs{@@_quick:wn} removes all until the ending -% break point, unbracing the \meta{continuation}. If it is not blank, -% \cs{@@_quick:wn} simply removes the end of that test until the -% break point. The third auxiliary plays the role of |\__sort:nnNnn| -% above, with an end-test replaced by \cs{__prg_break:}, which skips -% to the break point two lines later, unless |#5| is itself a break -% point. In that case, \cs{@@_quick:nnNnwn} calls the first -% auxiliary, which sorts |#2| and places another call to itself before -% the result. -% \begin{macrocode} -\cs_new:Npn \tl_sort:nN #1#2 { \@@_quick:nNn {#1} #2 { } } -\cs_new:Npn \@@_quick:nNn #1#2 - { - \exp_after:wN \@@_quick:wn - \use_none:n #1 \__prg_break_point: - \@@_quick:nnNnn { } { } #2 - #1 - { \__prg_break_point: } - \__prg_break_point: - } -\cs_new:Npn \@@_quick:wn #1 \__prg_break_point: #2 {#2} -\cs_new:Npn \@@_quick:nnNnn #1#2#3#4#5 - { - \__prg_break: #5 - \@@_quick:nnNnwn {#1} {#2} - \__prg_break_point: - #3 {#4} {#5} - { \@@_quick:nnNnn {#1} { #2 {#5} } } - { \@@_quick:nnNnn { #1 {#5} } {#2} } - #3 {#4} - } -\cs_new:Npn \@@_quick:nnNnwn - #1#2 \__prg_break_point: #3#4 #5 \__prg_break_point: #6 - { - \@@_quick:nNn {#2} #3 - { \@@_quick:nNn {#1} #3 {#6} {#4} } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \subsection{Protected user commands} % % \begin{macro}[int]{\@@_main:NNNnNn} @@ -412,7 +325,7 @@ % \end{macro} % % \begin{macro}{\clist_sort:Nn, \clist_gsort:Nn} -% \begin{macro}[aux]{\@@_sort:NNn} +% \begin{macro}[aux]{\@@_clist:NNn} % The case of empty comma-lists is a little bit special as usual, % and filtered out: there is nothing to sort in that case. % Otherwise, the input is done with \cs{clist_map_inline:Nn}, @@ -426,10 +339,10 @@ % once to unpack the register. % \begin{macrocode} \cs_new_protected_nopar:Npn \clist_sort:Nn - { \@@_sort:NNn \tl_set:Nn } + { \@@_clist:NNn \tl_set:Nn } \cs_new_protected_nopar:Npn \clist_gsort:Nn - { \@@_sort:NNn \tl_gset:Nn } -\cs_new_protected:Npn \@@_sort:NNn #1#2#3 + { \@@_clist:NNn \tl_gset:Nn } +\cs_new_protected:Npn \@@_clist:NNn #1#2#3 { \clist_if_empty:NF #2 { @@ -607,7 +520,7 @@ % then the next item to add to the merger is the first % argument, contents of the \tn{toks} register $A$. % Then shift the pointers $A$ and $B$ to the left, and -% go for one more step fo the merger, unless the left +% go for one more step for the merger, unless the left % block was exhausted ($A$ goes below the threshold). % In that case, all remaining \tn{toks} registers in % the second block, indexed by $C$, should be copied @@ -646,6 +559,323 @@ % \end{macrocode} % \end{macro} % +% \subsection{Expandable sorting} +% +% Sorting expandably is very different from sorting and assigning to a +% variable. Since tokens cannot be stored, they must remain in the +% input stream, and be read through at every step. It is thus +% necessarily much slower (at best $O(n^2\ln n)$) than non-expandable +% sorting functions ($O(n\ln n)$). +% +% A prototypical version of expandable quicksort is as follows. If the +% argument has no item, return nothing, otherwise partition, using the +% first item as a pivot (argument |#4| of |\__sort:nnNnn|). The +% arguments of |\__sort:nnNnn| are 1.~items less than |#4|, 2.~items +% greater or equal to |#4|, 3.~comparison, 4.~pivot, 5.~next item to +% test. If |#5| is the tail of the list, call \cs{tl_sort:nN} on |#1| +% and on |#2|, placing |#4| in between; |\use:ff| expands the parts to +% make \cs{tl_sort:nN} \texttt{f}-expandable. Otherwise, compare |#4| +% and |#5| using |#3|. If they are ordered, place |#5| amongst the +% \enquote{greater} items, otherwise amongst the \enquote{lesser} items, +% and continue partitioning. +% \begin{verbatim} +% \cs_new:Npn \tl_sort:nN #1#2 +% { +% \tl_if_blank:nF {#1} +% { +% \__sort:nnNnn { } { } #2 +% #1 \q_recursion_tail \q_recursion_stop +% } +% } +% \cs_new:Npn \__sort:nnNnn #1#2#3#4#5 +% { +% \quark_if_recursion_tail_stop_do:nn {#5} +% { \use:ff { \tl_sort:nN {#1} #3 {#4} } { \tl_sort:nN {#2} #3 } } +% #3 {#4} {#5} +% { \__sort:nnNnn {#1} { #2 {#5} } #3 {#4} } +% { \__sort:nnNnn { #1 {#5} } {#2} #3 {#4} } +% } +% \cs_generate_variant:Nn \use:nn { ff } +% \end{verbatim} +% There are quite a few optimizations available here: the code below is +% less legible, but more than twice as fast. +% +% In the simple version of the code, |\__sort:nnNnn| is called +% \(O(n\ln n)\) times on average (the number of comparisons required by +% the quicksort algorithm). Hence most of our focus will be on +% optimizing that function. +% +% The first speed up is to avoid testing for the end of the list at +% every call to |\__sort:nnNnn|. For this, the list is prepared by +% changing each \meta{item} of the original token list into +% \meta{command} \Arg{item}, just like sequences are stored. We arrange +% things such that the \meta{command} is the \meta{conditional} provided +% by the user: the loop over the \meta{prepared tokens} then looks like +% \begin{quote} +% \ttfamily +% \cs{cs_new:Npn}~|\__sort_loop:wNn|~\ldots{}~|#6#7|\\ +% ~~|{|\\ +% ~~~~|#6|~\Arg{pivot}~|{#7}|~\meta{loop big}~\meta{loop small}\\ +% ~~~~~~\meta{extra arguments}\\ +% ~~|}|\\ +% |\__sort_loop:wNn|~\ldots{}~\meta{prepared tokens}\\ +% ~~\meta{end-loop}~|{}|~|\q_stop| +% \end{quote} +% In this example, which matches the structure of +% \cs{__sort_quick_split_i:NnnnnNn} and a few other functions below, the +% |\__sort_loop:wNn| auxiliary normally receives the user's +% \meta{conditional} as~|#6| and an \meta{item} as~|#7|. This is +% compared to the \meta{pivot} (the argument~|#5|, not shown here), and +% the \meta{conditional} leaves the \meta{loop big} or \meta{loop small} +% auxiliary, which both have the same form as |\__sort_loop:wNn|, +% receiving the next pair \meta{conditional} \Arg{item} as |#6| +% and~|#7|. At the end, |#6| is the \meta{end-loop} function, which +% terminates the loop. +% +% The second speed up is to minimize the duplicated tokens between the +% \texttt{true} and \texttt{false} branches of the conditional. For +% this, we introduce two versions of |\__sort:nnNnn|, which receive +% the new item as~|#1| and place it either into the list~|#2| of items +% less than the pivot~|#4| or into the list~|#3| of items greater or +% equal to the pivot. +% \begin{verbatim} +% \cs_new:Npn \__sort_i:nnnnNn #1#2#3#4#5#6 +% { +% #5 {#4} {#6} \__sort_ii:nnnnNn \__sort_i:nnnnNn +% {#6} { #2 {#1} } {#3} {#4} +% } +% \cs_new:Npn \__sort_ii:nnnnNn #1#2#3#4#5#6 +% { +% #5 {#4} {#6} \__sort_ii:nnnnNn \__sort_i:nnnnNn +% {#6} {#2} { #3 {#1} } {#4} +% } +% \end{verbatim} +% Note that the two functions have the form of |\__sort_loop:wNn| above, +% receiving as~|#5| the conditional or a function to end the loop. In +% fact, the lists~|#2| and~|#3| must be made of pairs \meta{conditional} +% \Arg{item}, so we have to replace~|{#6}| above by |{|~|#5|~|{#6}|~|}|, +% and |{#1}|~by~|#1|. The actual functions have one more argument, so +% all argument numbers are shifted compared to this code. +% +% The third speed up is to avoid |\use:ff| using a continuation-passing +% style: \cs{__sort_quick_split:NnNn} expects a list followed by +% \cs{q_mark} \Arg{code}, and expands to \meta{code} \meta{sorted list}. +% Sorting the two parts of the list around the pivot is done with +% \begin{quote} +% \ttfamily +% \cs{__sort_quick_split:NnNn} |#2| \ldots{} \cs{q_mark}\\ +% ~~|{|\\ +% ~~~~\cs{__sort_quick_split:NnNn} |#1| \ldots{} \cs{q_mark} \Arg{code}\\ +% ~~~~\Arg{pivot}\\ +% ~~|}| +% \end{quote} +% Items which are larger than the \meta{pivot} are sorted, then placed +% after code that sorts the smaller items, and after the (braced) +% \meta{pivot}. +% +% The fourth speed up is avoid the recursive call to \cs{tl_sort:nN} +% with an empty first argument. For this, we introduce functions +% similar to the |\__sort_i:nnnnNn| of the last example, but aware of +% whether the list of \meta{conditional} \Arg{item} read so far that are +% less than the pivot, and the list of those greater or equal, are empty +% or not: see \cs{__sort_quick_split:NnNn} and functions defined below. +% Knowing whether the lists are empty or not is useless if we do not use +% distinct ending codes as appropriate. The splitting auxiliaries +% communicate to the \meta{end-loop} function (that is initially placed +% after the ``prepared'' list) by placing a specific ending function, +% ignored when looping, but useful at the end. In fact, the +% \meta{end-loop} function does nothing but place the appropriate ending +% function in front of all its arguments. The ending functions take +% care of sorting non-empty sublists, placing the pivot in between, and +% the continuation before. +% +% The final change in fact slows down the code a little, but is required +% to avoid memory issues: schematically, when \TeX{} encounters +% \begin{verbatim} +% \use:n { \use:n { \use:n { ... } ... } ... } +% \end{verbatim} +% the argument of the first \cs{use:n} is not completely read by the +% second \cs{use:n}, hence must remain in memory; then the argument of +% the second \cs{use:n} is not completely read when grabbing the +% argument of the third \cs{use:n}, hence must remain in memory, and so +% on. The memory consumption grows quadratically with the number of +% nested \cs{use:n}. In practice, this means that we must read +% everything until a trailing \cs{q_stop} once in a while, otherwise +% sorting lists of more than a few thousand items would exhaust a +% typical \TeX{}'s memory. +% +% \begin{macro}[EXP]{\tl_sort:nN} +% \begin{macro}[aux, EXP] +% { +% \__sort_quick_prepare:Nnnn, +% \__sort_quick_prepare_end:NNNnw, +% \__sort_quick_cleanup:w +% } +% The code within the \cs{exp_not:f} sorts the list, leaving in most +% cases a leading \cs{exp_not:f}, which stops the expansion, letting +% the result be return within \cs{exp_not:n}. We filter out the case +% of a list with no item, which would otherwise cause problems. Then +% prepare the token list~|#1| by inserting the conditional~|#2| before +% each item. The \texttt{prepare} auxiliary receives the conditional +% as~|#1|, the prepared token list so far as~|#2|, the next prepared +% item as~|#3|, and the item after that as~|#4|. The loop ends +% when~|#4| contains \cs{__prg_break_point:}, then the +% \texttt{prepare_end} auxiliary finds the prepared token list +% as~|#4|. The scene is then set up for \cs{__sort_quick_split:NnNn}, +% which will sort the prepared list and perform the post action placed +% after \cs{q_mark}, namely removing the trailing \cs{s__stop} and +% \cs{q_stop} and leaving \cs{exp_stop_f:} to stop +% \texttt{f}-expansion. +% \begin{macrocode} +\cs_new:Npn \tl_sort:nN #1#2 + { + \exp_not:f + { + \tl_if_blank:nF {#1} + { + \__sort_quick_prepare:Nnnn #2 { } { } + #1 + { \__prg_break_point: \__sort_quick_prepare_end:NNNnw } + \q_stop + } + } + } +\cs_new:Npn \__sort_quick_prepare:Nnnn #1#2#3#4 + { + \__prg_break: #4 \__prg_break_point: + \__sort_quick_prepare:Nnnn #1 { #2 #3 } { #1 {#4} } + } +\cs_new:Npn \__sort_quick_prepare_end:NNNnw #1#2#3#4#5 \q_stop + { + \__sort_quick_split:NnNn #4 \__sort_quick_end:nnTFNn { } + \q_mark { \__sort_quick_cleanup:w \exp_stop_f: } + \s__stop \q_stop + } +\cs_new:Npn \__sort_quick_cleanup:w #1 \s__stop \q_stop {#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[EXP, aux] +% { +% \__sort_quick_split:NnNn, +% \__sort_quick_only_i:NnnnnNn, +% \__sort_quick_only_ii:NnnnnNn, +% \__sort_quick_split_i:NnnnnNn, +% \__sort_quick_split_ii:NnnnnNn +% } +% The \texttt{only_i}, \texttt{only_ii}, \texttt{split_i} and +% \texttt{split_ii} auxiliaries receive a useless first argument, the +% new item~|#2| (that they append to either one of the next two +% arguments), the list~|#3| of items less than the pivot, bigger +% items~|#4|, the pivot~|#5|, a \meta{function}~|#6|, and an +% item~|#7|. The \meta{function} is the user's \meta{conditional} +% except at the end of the list where it is +% \cs{__sort_quick_end:nnTFNn}. The comparison is applied to the +% \meta{pivot} and the \meta{item}, and calls the \texttt{only_i} or +% \texttt{split_i} auxiliaries if the \meta{item} is smaller, and the +% \texttt{only_ii} or \texttt{split_ii} auxiliaries otherwise. In +% both cases, the next auxiliary goes to work right away, with no +% intermediate expansion that would slow down operations. Note that +% the argument~|#2| left for the next call has the form +% \meta{conditional} \Arg{item}, so that the lists~|#3| and~|#4| keep +% the right form to be fed to the next sorting function. +% The \texttt{split} auxiliary differs from these in that it is +% missing three of the arguments, which would be empty, and its first +% argument is always the user's \meta{conditional} rather than an +% ending function. +% \begin{macrocode} +\cs_new:Npn \__sort_quick_split:NnNn #1#2#3#4 + { + #3 {#2} {#4} \__sort_quick_only_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn + \__sort_quick_single_end:nnnwnw + { #3 {#4} } { } { } {#2} + } +\cs_new:Npn \__sort_quick_only_i:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn + \__sort_quick_only_i_end:nnnwnw + { #6 {#7} } { #3 #2 } { } {#5} + } +\cs_new:Npn \__sort_quick_only_ii:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_only_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_only_ii_end:nnnwnw + { #6 {#7} } { } { #4 #2 } {#5} + } +\cs_new:Npn \__sort_quick_split_i:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_split_end:nnnwnw + { #6 {#7} } { #3 #2 } {#4} {#5} + } +\cs_new:Npn \__sort_quick_split_ii:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_split_end:nnnwnw + { #6 {#7} } {#3} { #4 #2 } {#5} + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP, aux] +% { +% \__sort_quick_end:nnTFNn, +% \__sort_quick_single_end:nnnwnw, +% \__sort_quick_only_i_end:nnnwnw, +% \__sort_quick_only_ii_end:nnnwnw, +% \__sort_quick_split_end:nnnwnw, +% } +% The \cs{__sort_quick_end:nnTFNn} appears instead of the user's +% conditional, and receives as its arguments the pivot~|#1|, a fake +% item~|#2|, a \texttt{true} and a \texttt{false} branches |#3| +% and~|#4|, followed by an ending function~|#5| (one of the four +% auxiliaries here) and another copy~|#6| of the fake item. All those +% are discarded except the function~|#5|. This function receives +% lists~|#1| and~|#2| of items less than or greater than the +% pivot~|#3|, then a continuation code~|#5| just after \cs{q_mark}. +% To avoid a memory problem described earlier, all of the ending +% functions read~|#6| until \cs{q_stop} and place~|#6| back into the +% input stream. When the lists |#1| and~|#2| are empty, the +% \texttt{single} auxiliary simply places the continuation~|#5| before +% the pivot~|{#3}|. When |#2|~is empty, |#1|~is sorted and placed +% before the pivot~|{#3}|, taking care to feed the continuation~|#5| +% as a continuation for the function sorting~|#1|. When |#1|~is +% empty, |#2|~is sorted, and the continuation argument is used to +% place the continuation~|#5| and the pivot~|{#3}| before the sorted +% result. Finally, when both lists are non-empty, items larger than +% the pivot are sorted, then items less than the pivot, and the +% continuations are done in such a way to place the pivot in between. +% \begin{macrocode} +\cs_new:Npn \__sort_quick_end:nnTFNn #1#2#3#4#5#6 {#5} +\cs_new:Npn \__sort_quick_single_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { #5 {#3} #6 \q_stop } +\cs_new:Npn \__sort_quick_only_i_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #1 + \__sort_quick_end:nnTFNn { } \q_mark {#5} + {#3} + #6 \q_stop + } +\cs_new:Npn \__sort_quick_only_ii_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #2 + \__sort_quick_end:nnTFNn { } \q_mark { #5 {#3} } + #6 \q_stop + } +\cs_new:Npn \__sort_quick_split_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #2 \__sort_quick_end:nnTFNn { } \q_mark + { + \__sort_quick_split:NnNn #1 + \__sort_quick_end:nnTFNn { } \q_mark {#5} + {#3} + } + #6 \q_stop + } +% \end{macrocode} +% \end{macro} +% % \subsection{Messages} % % \begin{macro}{\@@_too_long_error:NNw} diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx index 7260ca7667f..1ab8905e6aa 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx @@ -35,7 +35,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3regex.dtx 4455 2013-01-22 20:38:19Z bruno $ +\GetIdInfo$Id: l3regex.dtx 4482 2013-04-24 21:05:12Z joseph $ {L3 Experimental regular expressions} %</driver|package> %<*driver> @@ -752,7 +752,7 @@ % integer \meta{position}, with $\texttt{min_pos} - 1 \leq % \meta{position} \leq \texttt{max_pos}$. The lowest and highest % positions correspond to imaginary begin and end markers (with -% inacessible category code and character code). +% inaccessible category code and character code). % \item \emph{Query}: the token list to which we apply the regular % expression. % \item \emph{State}: each state of the \textsc{nfa} is labelled by an @@ -767,7 +767,7 @@ % unique id for all the steps of the matching algorithm. % \end{itemize} % -% To acheive a good performance, we abuse \TeX{}'s registers in two +% To achieve a good performance, we abuse \TeX{}'s registers in two % ways. We access registers directly by number rather than tying them % to control sequence using \cs{int_new:N} and other allocation % functions. And we store integers in \tn{dimen} registers in scaled @@ -913,7 +913,7 @@ % % \begin{macro}[int]{\@@_item_reverse:n} % This function makes showing regular expressions easier, and lets us -% define |\D| in terms of |\d| for instance. There is a subtelty: the +% define |\D| in terms of |\d| for instance. There is a subtlety: the % end of the query is marked by $-2$, and will thus match |\D| and % other negated properties; this case is caught by another part of % the code. @@ -1596,7 +1596,7 @@ % \begin{variable}{\l_@@_catcodes_bool} % We wish to allow constructions such as |\c[^BE](..\cL[a-z]..)|, % where the outer catcode test applies to the whole group, but is -% superseeded by the inner catcode test. For this to work, we need to +% superseded by the inner catcode test. For this to work, we need to % keep track of lists of allowed category codes: % \cs{l_@@_catcodes_int} and \cs{l_@@_default_catcodes_int} are % bitmaps, sums of $4^c$, for all allowed catcodes $c$. The latter is @@ -2018,7 +2018,7 @@ % \end{macrocode} % \end{macro} % -% \subsubsection{Quantifers} +% \subsubsection{Quantifiers} % % \begin{macro}[int]{\@@_compile_quantifier:w} % This looks ahead and finds any quantifier (special character equal @@ -2436,7 +2436,7 @@ % \begin{macro}[aux]{\@@_compile_[:} % In a class, left brackets might introduce a \textsc{posix} character % class, or mean nothing. Immediately following |\c|\meta{category}, -% we must insert the apropriate catcode test, then parse the class; we +% we must insert the appropriate catcode test, then parse the class; we % pre-expand the catcode as an optimization. Otherwise (modes $0$, % $-2$ and $-6$) just parse the class. The mode is updated later. % \begin{macrocode} @@ -2614,7 +2614,7 @@ % using \pkg{l3tl-build} within a \TeX{} group, which automatically % makes sure that options (case-sensitivity and default catcode) are % reset at the end of the group. The argument |#1| is -% \cs{@@_group:nnnN} or a variant thereof. A small subtelty to +% \cs{@@_group:nnnN} or a variant thereof. A small subtlety to % support |\cL(abc)| as a shorthand for |(\cLa\cLb\cLc)|: exit any % pending catcode test, save the category code at the start of the % group as the default catcode for that group, and make sure that the @@ -3093,7 +3093,7 @@ % % \begin{macro}[aux]{\@@_show_one:n} % Every part of the final message go through this function, which adds -% one line to the output, with the apropriate prefix. +% one line to the output, with the appropriate prefix. % \begin{macrocode} \cs_new_protected:Npn \@@_show_one:n #1 { @@ -4082,7 +4082,7 @@ % \tn{toks} register for the target state of the transition, to be % retrieved when matching at the next position. When a thread % succeeds, this property list is copied to -% \cs{l_@@_success_submatches_prop}: only the last sucessful thread +% \cs{l_@@_success_submatches_prop}: only the last successful thread % will remain there. % \begin{macrocode} \prop_new:N \l_@@_current_submatches_prop @@ -4184,7 +4184,7 @@ % First store the query into \tn{toks} and \tn{muskip} registers (see % \cs{@@_query_set:nnn}). Then initialize the variables that should % be set once for each user function (even for multiple -% matches). Namely, the overall matching is not yet sucessful; none of +% matches). Namely, the overall matching is not yet successful; none of % the states should be marked as visited (\tn{dimen} registers), and % we start at step $0$; we pretend that there was a previous match % ending at the start of the query, which was not empty (to avoid @@ -4226,7 +4226,7 @@ % \cs{@@_match_once:}. First initialize some variables: set the % conditional which detects identical empty matches; this match % attempt starts at the previous \texttt{success_pos}, is not yet -% sucessful, and has no submatches yet; clear the array of active +% successful, and has no submatches yet; clear the array of active % threads, and put the starting state $0$ in it. We are then almost % ready to read our first token in the query, but we actually start % one position earlier than the start, and \texttt{get} that token, so @@ -5927,7 +5927,7 @@ % This is not technically a message, but seems related enough to go % there. The arguments are: |#1| is the minimum number of repetitions; % |#2| is the number of allowed extra repetitions ($-1$ for infinite -% number), and |#3| tells us aboud lazyness. +% number), and |#3| tells us about lazyness. % \begin{macrocode} \cs_new:Npn \@@_msg_repeated:nnN #1#2#3 { diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx index 1810468ff7d..19bad05b982 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx @@ -125,7 +125,8 @@ % \texttt{iso885915}, \texttt{latin9} & \textsc{iso 8859-15} \\ % \texttt{iso885916}, \texttt{latin10} & \textsc{iso 8859-16} \\ % \midrule -% Empty & Native (Unicode) string. \\ +% \texttt{clist} & comma-list of integers \\ +% \meta{empty} & native (Unicode) string \\ % \bottomrule % \end{tabular} % \end{table} @@ -1187,6 +1188,47 @@ % \end{macrocode} % \end{macro} % +% \subsubsection{\texttt{clist}} +% +% \begin{macro}[int]{\@@_convert_decode_clist:} +% \begin{macro}[aux, rEXP]{\@@_decode_clist_char:n} +% Convert each integer to the internal form. We first turn +% \cs{g_@@_result_tl} into a clist variable, as this avoids problems +% with leading or trailing commas. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \@@_convert_decode_clist: + { + \clist_set:No \g_@@_result_tl \g_@@_result_tl + \tl_gset:Nx \g_@@_result_tl + { + \exp_args:No \clist_map_function:nN + \g_@@_result_tl \@@_decode_clist_char:n + } + } +\cs_new:Npn \@@_decode_clist_char:n #1 + { #1 \s__tl \int_eval:n {#1} \s__tl } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[int]{\@@_convert_encode_clist:} +% \begin{macro}[aux, rEXP]{\@@_encode_clist_char:n} +% Convert the internal list of character codes to a comma-list of +% character codes. The first line produces a comma-list with a +% leading comma, removed in the next step (this also works in the +% empty case, since \cs{tl_tail:N} does not trigger an error in this +% case). +% \begin{macrocode} +\cs_new_protected_nopar:Npn \@@_convert_encode_clist: + { + \@@_convert_gmap_internal:N \@@_encode_clist_char:n + \tl_gset:Nx \g_@@_result_tl { \tl_tail:N \g_@@_result_tl } + } +\cs_new:Npn \@@_encode_clist_char:n #1 { , #1 } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsubsection{8-bit encodings} % % This section will be entirely rewritten: it is not yet clear in what @@ -1211,7 +1253,7 @@ % \end{syntax} % This declares the encoding \meta{name} to map bytes to Unicode % characters according to the \meta{mapping}, and map those bytes -% which are not mentionned in the \meta{mapping} either to the +% which are not mentioned in the \meta{mapping} either to the % replacement character (if they appear in \meta{missing}), or to % themselves. % @@ -2067,7 +2109,7 @@ % |#3| for the previous range. Otherwise, we call the % \texttt{_continuation} auxiliary again, after shifting the % \enquote{current code point} by |#4| (maximum from the range we just -% checkedd). +% checked). % % Two additional tests are needed: if we reach the end of the list of % range maxima and we are still not done, then we are faced with an @@ -2629,7 +2671,7 @@ % of a byte-order mark. If there is a byte-order mark, use that % endianness, and remove the $4$ bytes, otherwise default to % big-endian, and leave the $4$ bytes in place. The -% \cs{@@_decode_utf_xxxii:Nw} auxiliary recieves $1$ or $2$ as its +% \cs{@@_decode_utf_xxxii:Nw} auxiliary receives $1$ or $2$ as its % first argument indicating endianness, and the string to convert as % its second argument (expanded or not). It sets \cs{@@_tmp:w} to % expand to the character code of either of its two arguments diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-format.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-format.dtx index 7d42697daab..3237dc3aaa4 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-format.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-format.dtx @@ -597,7 +597,7 @@ % \subsection{Formatting integers} % % \begin{macro}[EXP]{\int_format:nn} -% Evalute the first argument and feed it to \cs{@@_int:nn}. +% Evaluate the first argument and feed it to \cs{@@_int:nn}. % \begin{macrocode} \cs_new:Npn \int_format:nn #1 { \exp_args:Nf \@@_int:nn { \int_eval:n {#1} } } @@ -705,7 +705,7 @@ % \subsection{Formatting floating points} % % \begin{macro}[EXP]{\fp_format:nn} -% Evalute the first argument to an internal floating point number, and +% Evaluate the first argument to an internal floating point number, and % feed it to \cs{@@_fp:nn}. % \begin{macrocode} \cs_new:Npn \fp_format:nn #1 diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx index 0a4d72afd2f..836bb0481f2 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx @@ -35,7 +35,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3str.dtx 4452 2013-01-20 10:18:32Z joseph $ +\GetIdInfo$Id: l3str.dtx 4482 2013-04-24 21:05:12Z joseph $ {L3 Experimental strings} %</driver|package> %<*driver> @@ -421,7 +421,7 @@ % characters with category \enquote{other}, as produced by % \cs{__str_to_other:n}. It leaves in the input stream the number of % character tokens in the \meta{other string}, faster than the -% analoguous \cs{str_count:n} function. +% analogous \cs{str_count:n} function. % \end{function} % % \begin{function}[EXP]{\__str_range_unsafe:nnn} @@ -577,7 +577,7 @@ % To speed up this function, we grab and discard $9$ space-delimited % arguments in each iteration of the loop. The loop stops when the % last argument is one of the trailing |X|\meta{number}, and that -% \meta{number} is added to the sum of $9$ that preceeds, to adjust +% \meta{number} is added to the sum of $9$ that precedes, to adjust % the result. % \begin{macrocode} \cs_new_nopar:Npn \str_count_spaces:N diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx index ad4d20f7aba..5c4787cc5aa 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx @@ -114,7 +114,7 @@ % \ldots{} % \cs{__tl_build_end:} % \end{syntax} -% Defines the \meta{tl~var} to contain the contens of \meta{tokens1} +% Defines the \meta{tl~var} to contain the contents of \meta{tokens1} % followed by \meta{tokens2}, \emph{etc.} This is built in such a way % to be more efficient than repeatedly using \cs{tl_put_right:Nn}. The % code in \enquote{\texttt{\ldots{}}} does not need to be diff --git a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx index 60ebd14993f..3bbe92eacc0 100644 --- a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx @@ -1,7 +1,7 @@ % \iffalse % %% File: l3galley.dtx Copyright (C) 1999-2001, 2004-2009 Frank Mittelbach -%% (C) 2010-2012 The LaTeX3 Project +%% (C) 2010-2013 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -37,7 +37,7 @@ % %<*driver|package> \RequirePackage{xparse} -\GetIdInfo$Id: l3galley.dtx 4402 2013-01-08 08:59:44Z bruno $ +\GetIdInfo$Id: l3galley.dtx 4494 2013-05-24 06:27:01Z joseph $ {L3 Experimental galley code} %</driver|package> %<*driver> @@ -260,7 +260,7 @@ % \end{verbatim} % would create a paragraph shape in which the first line is the full % width of the measure, the second line is indented by $2$\,pt on each side, -% the third line by by $4$\,pt and the fourth line and subsequent lines by +% the third line by $4$\,pt and the fourth line and subsequent lines by % $6$\,pt from the edge of the measure on each side. % % The \texttt{single_par} version applies only to a single paragraph, @@ -1087,7 +1087,7 @@ % saved \emph{local} versions, hence the position of the close-of-group % instruction. As this code can be inserted automatically, at the point % of use only the start of a galley level needs to be marked up: the end -% must come in a fixed location. All of this relies on the the +% must come in a fixed location. All of this relies on the % \enquote{color safe} group used inside a box. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_level_end: @@ -1650,7 +1650,7 @@ % parts in advance (the same number of loops would still be needed). % \begin{macrocode} { - \prg_replicate:nn \g@@_previous_par_lines_int + \prg_replicate:nn \g_galley_previous_par_lines_int { \seq_gpop:NN \g_@@_cutout_left_seq \l_@@_tmp_tl \seq_gpop:NN \g_@@_cutout_right_seq \l_@@_tmp_tl @@ -1851,7 +1851,7 @@ \int_compare:nNnTF \tex_parshape:D = \c_zero { \tl_put_right:Nn \l_@@_tmp_tl - { \l@@_total_left_margin_dim \l@@_text_width_dim } + { \l_@@_total_left_margin_dim \l_galley_text_width_dim } } { \tl_put_right:Nx \l_@@_tmp_tl @@ -1879,9 +1879,9 @@ { \int_compare:nNnTF \l_@@_tmp_int > \tex_parshape:D { - \dim_eval:n { \l@@_total_left_margin_dim + ( #1 ) } + \dim_eval:n { \l_@@_total_left_margin_dim + ( #1 ) } \c_space_tl - \dim_eval:n { \l@@_text_width_dim - ( #1 ) } + \dim_eval:n { \l_galley_text_width_dim - ( #1 ) } \c_space_tl } { @@ -1897,10 +1897,19 @@ \int_incr:N \l_@@_tmp_int \tl_put_right:Nx \l_@@_tmp_tl { - \dim_eval:n { \etex_parshapeindent:D \l_@@_tmp_int } - \c_space_tl - \dim_eval:n { \etex_parshapelength:D \l_@@_tmp_int - ( #1 ) } - \c_space_tl + \int_compare:nNnTF \l_@@_tmp_int > \tex_parshape:D + { + \dim_use:N \l_@@_total_left_margin_dim + \c_space_tl + \dim_eval:n { \l_galley_text_width_dim - ( #1 ) } + \c_space_tl + } + { + \dim_eval:n { \etex_parshapeindent:D \l_@@_tmp_int } + \c_space_tl + \dim_eval:n { \etex_parshapelength:D \l_@@_tmp_int - ( #1 ) } + \c_space_tl + } } } % \end{macrocode} |