diff options
Diffstat (limited to 'Master/texmf-dist/source/latex')
19 files changed, 745 insertions, 188 deletions
diff --git a/Master/texmf-dist/source/latex/l3build/l3build.dtx b/Master/texmf-dist/source/latex/l3build/l3build.dtx index 5f1f5fb3c54..8f1d7b1c0de 100644 --- a/Master/texmf-dist/source/latex/l3build/l3build.dtx +++ b/Master/texmf-dist/source/latex/l3build/l3build.dtx @@ -39,8 +39,8 @@ \RequirePackage{expl3} \def\ExplFileName{l3build} \def\ExplFileDescription{L3 Regression test suite} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} \documentclass[full]{l3doc} \renewcommand\partname{Part} \usepackage{multicol,needspace} @@ -1324,7 +1324,6 @@ % in before the test starts. The necessary code should be placed in a % file |regression-test.cfg|. % \begin{macrocode} -\OMIT \ifx\InputIfFileExists\@undefined \newread\@inputcheck \long\def\InputIfFileExists#1#2#3{% @@ -1339,7 +1338,21 @@ \fi \InputIfFileExists{regression-test.cfg} {\LONGTYPEOUT{^^J***^^Jregression-test.cfg in operation^^J***^^J}}{} -\TIMO +% \end{macrocode} +% +% Load the map file early so it does not appear in the log. +% \begin{macrocode} +\ifdefined\pdfoutput + \ifnum\pdfoutput>0 % + \pdfmapfile{pdftex.map}% + \fi +\else + \ifdefined\outputmode + \ifnum\outputmode>0 % + \pdfextension mapfile{pdftex.map}% + \fi + \fi +\fi % \end{macrocode} % % \subsection{Formatting the \texttt{.log} file} diff --git a/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx b/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx index ed4eb58736d..e94691c1f4e 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3sort/l3sort.dtx @@ -37,8 +37,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3sort}{Support package l3kernel too old} @@ -50,7 +50,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: l3sort.dtx 6730 2016-10-19 11:19:38Z joseph $ +\GetIdInfo$Id: l3sort.dtx 6760 2016-11-21 20:35:31Z joseph $ {L3 Experimental sorting functions} %</driver|package> %<*driver> diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3flag.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3flag.dtx index 446504ae65b..e3890c04222 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3flag.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3flag.dtx @@ -36,8 +36,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3flag}{Support package l3kernel too old} @@ -49,7 +49,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: l3flag.dtx 6730 2016-10-19 11:19:38Z joseph $ +\GetIdInfo$Id: l3flag.dtx 6760 2016-11-21 20:35:31Z joseph $ {L3 Experimental flags} %</driver|package> %<*driver> diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx index 41969971c69..c70b9f7c558 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx @@ -36,8 +36,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3regex}{Support package l3kernel too old} @@ -49,7 +49,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: l3regex.dtx 6730 2016-10-19 11:19:38Z joseph $ +\GetIdInfo$Id: l3regex.dtx 6760 2016-11-21 20:35:31Z joseph $ {L3 Experimental regular expressions} %</driver|package> %<*driver> 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 50a67c3858f..5dbea913085 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3tl-build.dtx @@ -36,8 +36,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3tl-build}{Support package l3kernel too old} @@ -49,7 +49,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: l3tl-build.dtx 6730 2016-10-19 11:19:38Z joseph $ +\GetIdInfo$Id: l3tl-build.dtx 6760 2016-11-21 20:35:31Z joseph $ {L3 Experimental token list construction} %</driver|package> %<*driver> diff --git a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx index 70147a113d9..e96b5b65cdd 100644 --- a/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/xgalley/l3galley.dtx @@ -38,8 +38,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3galley}{Support package l3kernel too old} @@ -51,7 +51,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: l3galley.dtx 6730 2016-10-19 11:19:38Z joseph $ +\GetIdInfo$Id: l3galley.dtx 6760 2016-11-21 20:35:31Z joseph $ {L3 Experimental galley code} %</driver|package> %<*driver> diff --git a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx index 4a37d2c3c4e..0c1b6727074 100644 --- a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx @@ -36,8 +36,8 @@ %<*driver|generic|package> \def\ExplFileName{expl3}% \def\ExplFileDescription{L3 programming layer}% -\def\ExplFileDate{2016/10/19}% -\def\ExplFileVersion{6730}% +\def\ExplFileDate{2016/11/21}% +\def\ExplFileVersion{6760}% %</driver|generic|package> %<*driver> \documentclass[full]{l3doc} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3.ins b/Master/texmf-dist/source/latex/l3kernel/l3.ins index c1d041943b0..a60eb19398c 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3.ins @@ -71,6 +71,7 @@ Do not distribute a modified version of this file. \from{l3fp-expo.dtx} {package} \from{l3fp-trig.dtx} {package} \from{l3fp-convert.dtx} {package} + \from{l3fp-random.dtx} {package} \from{l3fp-assign.dtx} {package} \from{l3box.dtx} {package} \from{l3coffins.dtx} {package} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3format.ins b/Master/texmf-dist/source/latex/l3kernel/l3format.ins index 30bfd609096..1e38ca555f3 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3format.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3format.ins @@ -71,6 +71,7 @@ Do not distribute a modified version of this file. \from{l3fp-expo.dtx} {initex} \from{l3fp-trig.dtx} {initex} \from{l3fp-convert.dtx} {initex} + \from{l3fp-random.dtx} {initex} \from{l3fp-assign.dtx} {initex} \from{l3box.dtx} {initex} \from{l3coffins.dtx} {initex} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx index ce51a27a8d5..519a63fd6d9 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-aux.dtx 6685 2016-08-19 16:26:52Z bruno $ +\GetIdInfo$Id: l3fp-aux.dtx 6750 2016-11-21 01:24:26Z bruno $ {L3 Floating-point support functions} \documentclass[full]{l3doc} \begin{document} @@ -939,6 +939,43 @@ % \end{macrocode} % \end{macro} % +% \subsection{Integer floating points} +% +% \begin{macro}[int, EXP, pTF]{\@@_int:w} +% \begin{macro}[aux, EXP]{\@@_int_normal:nnnnn, \@@_int_test:Nw} +% Tests if the floating point argument is an integer. This holds if +% the rounding digit resulting from \cs{@@_decimate:nNnnnn} is~$0$. +% \begin{macrocode} +\prg_new_conditional:Npnn \@@_int:w \s_@@ \@@_chk:w #1 #2 #3; { TF , T , F , p } + { + \if_case:w #1 \exp_stop_f: + \prg_return_true: + \or: \@@_int_normal:nnnnn #3 + \else: \prg_return_false: + \fi: + } +\cs_new:Npn \@@_int_normal:nnnnn #1 #2#3#4#5 + { + \if_int_compare:w #1 > \c_zero + \@@_decimate:nNnnnn { \c_sixteen - #1 } + \@@_int_test:Nw + {#2} {#3} {#4} {#5} + \else: + \prg_return_false: + \fi: + } +\cs_new:Npn \@@_int_test:Nw #1#2; + { + \if_meaning:w 0 #1 + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsection{Small integer floating points} % % \begin{macro}[int, EXP]{\@@_small_int:wTF} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx index 40691eeeff3..68282396cce 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-logic.dtx 6659 2016-08-15 15:37:48Z bruno $ +\GetIdInfo$Id: l3fp-logic.dtx 6759 2016-11-21 17:04:08Z joseph $ {L3 Floating-point conditionals} \begin{document} \DocInput{\jobname.dtx} @@ -316,6 +316,74 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[EXP]{\fp_step_function:nnnN, \fp_step_function:nnnc} +% \begin{macro}[EXP, aux]{\@@_step:wwwN} +% \begin{macro}[EXP, aux]{\@@_step:NnnnN, \@@_step:NfnnN} +% The approach here is much the same as \cs{int_step_function:nnnN} except we +% do not have a convenient low-level way to evaluation each argument to give +% a pure number. Instead, the internal parser is used to leave values in the +% internal format (and avoid a more expensive \texttt{f}-type expansion of +% multiple uses of \texttt{fp_eval:n}). +% \begin{macrocode} +\cs_new:Npn \fp_step_function:nnnN #1#2#3 + { + \exp_after:wN \@@_step:wwwN + \exp:w \exp_end_continue_f:w \@@_parse_o:n {#1} : + \exp:w \exp_end_continue_f:w \@@_parse_o:n {#2} : + \exp:w \exp_end_continue_f:w \@@_parse:n {#3} : + } +\cs_generate_variant:Nn \fp_step_function:nnnN { nnnc } +% \end{macrocode} +% Here, |#1| will be passed to the output on the first pass of the loop. +% To avoid this being in internal form, an \texttt{f}-type expansion is used +% here on that value only. The second and third arguments will be converted +% during the loop itself. +% \begin{macrocode} +\cs_new:Npn \@@_step:wwwN #1 : #2 : #3 : #4 + { + \fp_compare:nNnTF {#2} > 0 + { \@@_step:NfnnN > } + { + \fp_compare:nNnTF {#2} = 0 + { + \__msg_kernel_expandable_error:nnn { kernel } { zero-step } {#4} + \use_none:nnnn + } + { \@@_step:NfnnN < } + } + { \fp_eval:n {#1} } {#2} {#3} #4 + } + +\cs_new:Npn \@@_step:NnnnN #1#2#3#4#5 + { + \fp_compare:nNnF {#2} #1 {#4} + { + #5 {#2} + \@@_step:NfnnN + #1 { \fp_eval:n { #2 + #3 } } {#3} {#4} #5 + } + } +\cs_generate_variant:Nn \@@_step:NnnnN { Nf } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\fp_step_inline:nnnn} +% As for \cs{int_step_inline:nnnn}, create a global function and apply it, +% following up with a break point. +% \begin{macrocode} +\cs_new_protected:Npn \fp_step_inline:nnnn #1#2#3#4 + { + \int_gincr:N \g__prg_map_int + \cs_gset_protected:cpn { __prg_map_ \int_use:N \g__prg_map_int :w } + ##1 {#4} + \fp_step_function:nnnc {#1} {#2} {#3} + { __prg_map_ \int_use:N \g__prg_map_int :w } + \__prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__prg_map_int } + } +% \end{macrocode} +% \end{macro} +% % \subsection{Extrema} % % \begin{macro}[int, EXP]{\@@_minmax_o:Nw} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index d3dbf085569..339595c6d2e 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-parse.dtx 6685 2016-08-19 16:26:52Z bruno $ +\GetIdInfo$Id: l3fp-parse.dtx 6750 2016-11-21 01:24:26Z bruno $ {L3 Floating-point expression parsing} \begin{document} \DocInput{\jobname.dtx} @@ -91,6 +91,8 @@ % in the input stream as an internal floating point number. This % function forms the basis of almost all public \pkg{l3fp} functions. % During evaluation, each token is fully \texttt{f}-expanded. +% +% \cs{@@_parse_o:n} does the same but expands once after its result. % \begin{texnote} % Registers (integers, toks, etc.) are automatically unpacked, % without requiring a function such as \cs{int_use:N}. Invalid @@ -821,7 +823,7 @@ % integer registers from dimensions/skips from muskips, according to % the presence of a period and/or of |pt|. For integers, simply % convert \meta{value}|e|\meta{exponent} to a floating point number -% with \cs{fp_parse:n} (this is somewhat wasteful). For other +% with \cs{@@_parse:n} (this is somewhat wasteful). For other % registers, the decimal rounding provided by \TeX{} does not % accurately represent the binary value that it manipulates, so we % extract this binary value as a number of scaled points with @@ -1783,8 +1785,8 @@ % {\@@_parse_prefix_(:Nw, \@@_parse_lparen_after:NwN} % The left parenthesis is treated as a unary prefix operator because % it appears in exactly the same settings. Commas will be allowed if -% the previous precedence is $16$ (function with multiple arguments) -% or $13$ (unary boolean \enquote{not}). In this case, find an +% the previous precedence is $16$ (function with multiple arguments). +% In this case, find an % operand using the precedence~$1$; otherwise the precedence~$0$. % Once the operand is found, the \texttt{lparen_after} auxiliary makes % sure that there was a closing parenthesis (otherwise it complains), @@ -1825,6 +1827,42 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[aux, EXP, verb]{\@@_parse_prefix_,:Nw} +% \begin{macro}[aux, EXP]{\@@_parse_prefix_):Nw} +% The right parenthesis and the comma can appear as unary prefixes +% when an argument of a multi-argument function is missing (for +% instance the first and last ones in |max(,1,2,)| or in |rand()|). +% In single-argument functions (precedence~$0$ rather than~$1$) forbid +% this. +% \begin{macrocode} +\cs_new:cpn { @@_parse_prefix_,:Nw } #1 + { + \if_int_compare:w #1 = \c_one + \exp_after:wN \@@_parse_one:Nw + \exp_after:wN #1 + \else: + \__msg_kernel_expandable_error:nnn + { kernel } { fp-missing-number } { , } + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w + \exp_after:wN \@@_parse_infix:NN + \exp_after:wN #1 + \exp_after:wN , + \fi: + } +\cs_new:cpn { @@_parse_prefix_):Nw } #1 + { + \if_int_compare:w #1 = \c_one + \else: + \__msg_kernel_expandable_error:nnn + { kernel } { fp-missing-number } { ) } + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w + \fi: + \@@_parse_infix:NN #1 ) + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsubsection{Constants} % % \begin{macro}[aux, EXP] @@ -1939,9 +1977,11 @@ % \@@_parse_word_acot:N , \@@_parse_word_acotd:N, % \@@_parse_word_atan:N , \@@_parse_word_atand:N, % \@@_parse_word_max:N , \@@_parse_word_min:N , +% \@@_parse_word_rand:N , \@@_parse_word_randint:N, % } % Those functions are also unary (not binary), but may receive a % variable number of arguments. +% For |randint| we don't use the first argument~|?|. % \begin{macrocode} \cs_new:Npn \@@_parse_word_acot:N { \@@_parse_function:NNN \@@_acot_o:Nw \use_i:nn } @@ -1955,6 +1995,10 @@ { \@@_parse_function:NNN \@@_minmax_o:Nw 2 } \cs_new:Npn \@@_parse_word_min:N { \@@_parse_function:NNN \@@_minmax_o:Nw 0 } +\cs_new:Npn \@@_parse_word_rand:N + { \@@_parse_function:NNN \@@_rand_o:Nw ? } +\cs_new:Npn \@@_parse_word_randint:N + { \@@_parse_function:NNN \@@_randint_o:Nw ? } % \end{macrocode} % \end{macro} % @@ -2088,6 +2132,18 @@ % \end{macro} % \end{macro} % +% \begin{macro}[int, EXP]{\@@_parse_o:n} +% ^^A todo: optimize, comment, make it work for arrays. +% \begin{macrocode} +\cs_new:Npn \@@_parse_o:n #1 + { + \exp_after:wN \exp_after:wN + \exp_after:wN \@@_exp_after_o:w + \@@_parse:n {#1} + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[aux, EXP]{\@@_parse_operand:Nw} % \begin{macro}[aux, EXP]{\@@_parse_continue:NwN} % The \cs{@@_parse_operand} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx new file mode 100644 index 00000000000..e2708e193fc --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx @@ -0,0 +1,266 @@ +% \iffalse meta-comment +% +%% File: l3fp-random.dtx Copyright (C) 2016 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 +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3kernel bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX Project Team. +%% +%% ----------------------------------------------------------------------- +%% +% +%<*driver> +\documentclass[full]{l3doc} +\GetIdInfo$Id: l3fp-random.dtx 6750 2016-11-21 01:24:26Z bruno $ + {L3 Floating-point random numbers} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{The \textsf{l3fp-random} package\thanks{This file +% has version number \ExplFileVersion, last +% revised \ExplFileDate.}\\ +% Floating point random numbers} +% \author{^^A +% The \LaTeX3 Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% \date{Released \ExplFileDate} +% +% \maketitle +% +% \begin{documentation} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3fp-random} Implementation} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% \begin{macrocode} +%<@@=fp> +% \end{macrocode} +% +% \subsection{Random floating point} +% +% \begin{macro}[EXP, int]{\@@_rand_o:Nw} +% \begin{macro}[EXP, aux]{\@@_rand_o:} +% Check that |random| was called without argument. Random numbers are +% only available if the engine defines a primitive equivalent to +% \pdfTeX{}'s \tn{pdfuniformdeviate}. A random floating point number +% in $[0,1)$, uniformly distributed with equal-spaced steps of +% $10^{-16}$ is obtained by combining two integers in $[0,10^8-1]$. +% \begin{macrocode} +\cs_new:Npn \@@_rand_o:Nw ? #1 @ + { + \tl_if_empty:nTF {#1} + { \@@_rand_o: } + { + \__msg_kernel_expandable_error:nnnnn + { kernel } { fp-num-args } { rand() } { 0 } { 0 } + \exp_after:wN \c_nan_fp + } + } +\cs_if_exist:NTF \pdftex_uniformdeviate:D + { + \cs_new:Npn \@@_rand_o: + { + \@@_parse_o:n + { + . + \exp_after:wN \use_none:n + \__int_value:w \__int_eval:w 1 0000 0000 + + \pdftex_uniformdeviate:D 1 0000 0000 \__int_eval_end: + \exp_after:wN \use_none:n + \__int_value:w \__int_eval:w 1 0000 0000 + + \pdftex_uniformdeviate:D 1 0000 0000 \__int_eval_end: + } + } + } + { + \cs_new:Npn \@@_rand_o: + { + \__msg_kernel_expandable_error:nn { kernel } { fp-no-random } + \exp_after:wN \c_nan_fp + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Random integer} +% +% \begin{macro}[EXP, int]{\@@_randint_o:Nw} +% \begin{macro}[EXP, aux] +% { +% \@@_randint_badarg:w, +% \@@_randint_e:w, +% \@@_randint_narrow_e:nn, +% \@@_randint_wide_e:nn, +% \@@_randint_wide_e:nnn, +% \@@_randint_wide_e:nnnn, +% } +% Enforce that there is one argument (then add first argument~$1$) +% or two arguments. Enforce that they are integers in +% $(-10^{16},10^{16})$ and ordered. +% +% When the range is narrow (less than $2\times 10^9$) we can +% directly use the primitive. Otherwise we use the primitive twice. +% To ensure a uniform distribution we combine two uniformly +% distributed integers into a total range greater or equal to our +% target range and try again if the random number ended up being too +% big. +% +% The strange |+\c_six| ensures that the first argument of +% \cs{@@_randint_wide_e:nnn} is larger than $10^{-8}$ times the +% difference between the end-points even if these are near +% $-10^{16}$ and $+10^{16}$ (their difference is rounded to sixteen +% digits). Note that we cannot just concatenate the two random +% numbers provided by the engine as that may give an integer up to +% (almost) $2\times 10^{16}$ which incurs rounding. +% \begin{macrocode} +\cs_new:Npn \@@_randint_o:Nw ? #1 @ + { + \if_case:w + \__int_eval:w \@@_array_count:n {#1} - \c_one \__int_eval_end: + \exp_after:wN \@@_randint_e:w \c_one_fp #1 + \or: \@@_randint_e:w #1 + \else: + \__msg_kernel_expandable_error:nnnnn + { kernel } { fp-num-args } { randint() } { 1 } { 2 } + \exp_after:wN \c_nan_fp \exp:w + \fi: + \exp_after:wN \exp_end: + } +\cs_new:Npn \@@_randint_badarg:w \s_@@ \@@_chk:w #1#2#3; + { + \@@_int:wTF \s_@@ \@@_chk:w #1#2#3; + { + \if_meaning:w 1 #1 + \if_int_compare:w + \use_i_delimit_by_q_stop:nw #3 \q_stop > \c_sixteen + \exp_after:wN \c_one + \fi: + \fi: + } + { \c_one } + } +\cs_new:Npn \@@_randint_e:w #1; #2; + { + \if_case:w + \@@_randint_badarg:w #1; + \@@_randint_badarg:w #2; + \fp_compare:nNnTF { #1; } > { #2; } { \c_one } { \c_zero } + \fp_compare:nNnTF { #1; + 2e9 } < { #2; } + { \@@_randint_wide_e:nn } + { \@@_randint_narrow_e:nn } + { #1; } { #2; } + \or: + \@@_invalid_operation_tl_o:ff + { randint } { \@@_array_to_clist:n { #1; #2; } } + \exp:w + \fi: + } +\cs_if_exist:NTF \pdftex_uniformdeviate:D + { + \cs_new:Npn \@@_randint_narrow_e:nn #1#2 + { + \@@_parse_o:n + { + #1 + + \pdftex_uniformdeviate:D + \int_eval:n { \fp_to_int:n { #2 - #1 } + \c_one } + } + \exp:w + } + \cs_new:Npn \@@_randint_wide_e:nn #1 #2 + { + \exp_args:Nf \@@_randint_wide_e:nnn + { \fp_to_int:n { ceil ( ( #2 - #1 + \c_six ) * 1e-8 ) } } + {#1} {#2} + } + \cs_new:Npn \@@_randint_wide_e:nnn #1#2#3 + { + \exp_args:Nf \@@_randint_wide_e:nnnn + { + \@@_parse:n + { + #2 + + \pdftex_uniformdeviate:D #1 e 8 + + \pdftex_uniformdeviate:D 1 0000 0000 + } + } + {#1} {#2} {#3} + } + \cs_new:Npn \@@_randint_wide_e:nnnn #1#2#3#4 + { + \fp_compare:nNnTF {#1} > {#4} + { \@@_randint_wide_e:nnn {#2} {#3} {#4} } + { \@@_exp_after_o:w #1 \exp:w } + } + } + { + \cs_new:Npn \@@_randint_narrow_e:nn #1#2 + { + \__msg_kernel_expandable_error:nn { kernel } { fp-no-random } + \exp_after:wN \c_nan_fp \exp:w + } + \cs_new:Npn \@@_randint_wide_e:nn #1#2 + { + \__msg_kernel_expandable_error:nn { kernel } { fp-no-random } + \exp_after:wN \c_nan_fp \exp:w + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macrocode} +\__msg_kernel_new:nnn { kernel } { fp-no-random } + { Random~numbers~unavailable } +% \end{macrocode} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintChanges +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx index cc6299b8dfd..899c1a3bd6b 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-round.dtx 6441 2016-03-24 10:11:59Z joseph $ +\GetIdInfo$Id: l3fp-round.dtx 6750 2016-11-21 01:24:26Z bruno $ {L3 Floating-point rounding} \begin{document} \DocInput{\jobname.dtx} @@ -350,6 +350,7 @@ % % ^^A todo: This macro is intermingled with l3fp-parse. % ^^A todo: Add explanations. +% ^^A todo: This macro f-expands rather than o-expands after itself, is that an issue? % \begin{macro}[aux,EXP]{\@@_round_o:Nw} % The |trunc|, |ceil| and |floor| functions expect one or two % arguments (the second is $0$ by default), and the |round| function @@ -360,8 +361,9 @@ \cs_new:Npn \@@_round_o:Nw #1#2 @ { \if_case:w - \__int_eval:w \@@_array_count:n {#2} - \c_one \__int_eval_end: - \@@_round:Nwn #1 #2 {0} \exp:w + \__int_eval:w \@@_array_count:n {#2} \__int_eval_end: + \@@_round_no_arg_o:Nw #1 \exp:w + \or: \@@_round:Nwn #1 #2 {0} \exp:w \or: \@@_round:Nww #1 #2 \exp:w \else: \@@_round:Nwww #1 #2 @ \exp:w \fi: @@ -370,6 +372,21 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[aux, EXP]{\@@_round_no_arg_o:Nw} +% \begin{macrocode} +\cs_new:Npn \@@_round_no_arg_o:Nw #1 + { + \cs_if_eq:NNTF #1 \@@_round_to_nearest:NNN + { \@@_error:nnnn { num-args } { round () } { 1 } { 3 } } + { + \@@_error:nffn { num-args } + { \@@_round_name_from_cs:N #1 () } { 1 } { 2 } + } + \exp_after:wN \c_nan_fp + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[aux, EXP]{\@@_round:Nwww} % Having three arguments is only allowed for |round|, not |trunc|, % |ceil|, |floor|, so check for that case. If all is well, construct diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx index 3b1843e9b43..2cbbe3e2cb6 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx @@ -38,7 +38,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3fp.dtx 6685 2016-08-19 16:26:52Z bruno $ +\GetIdInfo$Id: l3fp.dtx 6761 2016-11-21 21:48:43Z joseph $ {L3 Floating points} %</driver|package> %<*driver> @@ -91,6 +91,7 @@ % \item Boolean logic: negation $\mathop{!}x$, conjunction % $x\mathop{\&\&}y$, disjunction $x\mathop{\vert\vert}y$, ternary % operator $x\mathop{?}y\mathop{:}z$. +% \item Random numbers: $\mathop{rand}()$, $\mathop{randint}(m,n)$. % \item Exponentials: $\exp x$, $\ln x$, $x^y$. % \item Trigonometry: $\sin x$, $\cos x$, $\tan x$, $\cot x$, $\sec % x$, $\csc x$ expecting their arguments in radians, and @@ -540,6 +541,50 @@ % \texttt{false}. % \end{function} % +% \begin{function}[added = 2016-11-21, rEXP] +% {\fp_step_function:nnnN} +% \begin{syntax} +% \cs{fp_step_function:nnnN} \Arg{initial value} \Arg{step} \Arg{final value} \meta{function} +% \end{syntax} +% This function first evaluates the \meta{initial value}, \meta{step} +% and \meta{final value}, all of which should be floating point expressions. +% The \meta{function} is then placed in front of each \meta{value} +% from the \meta{initial value} to the \meta{final value} in turn +% (using \meta{step} between each \meta{value}). The \meta{step} must +% be non-zero. If the \meta{step} is positive, the loop stops when +% the \meta{value} becomes larger than the \meta{final value}. If the +% \meta{step} is negative, the loop stops when the \meta{value} +% becomes smaller than the \meta{final value}. The \meta{function} +% should absorb one numerical argument. For example +% \begin{verbatim} +% \cs_set:Npn \my_func:n #1 { [I~saw~#1] \quad } +% \fp_step_function:nnnN { 1.0 } { 0.1 } { 1.5 } \my_func:n +% \end{verbatim} +% would print +% \begin{quote} +% [I saw 1.0] \quad +% [I saw 1.1] \quad +% [I saw 1.2] \quad +% [I saw 1.3] \quad +% [I saw 1.4] \quad +% [I saw 1.5] \quad +% \end{quote} +% \end{function} +% +% \begin{function}[added = 2016-11-21] +% {\fp_step_inline:nnnn} +% \begin{syntax} +% \cs{fp_step_inline:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code} +% \end{syntax} +% This function first evaluates the \meta{initial value}, \meta{step} +% and \meta{final value}, all of which should be floating point expressions. +% Then for each \meta{value} from the \meta{initial value} to the +% \meta{final value} in turn (using \meta{step} between each +% \meta{value}), the \meta{code} is inserted into the input stream +% with |#1| replaced by the current \meta{value}. Thus the +% \meta{code} should define a function of one argument~(|#1|). +% \end{function} +% % \section{Some useful constants, and scratch variables} % % \begin{variable}[added = 2012-05-08]{\c_zero_fp, \c_minus_zero_fp} @@ -1135,6 +1180,35 @@ % $\sqrt{\text{\nan{}}}=\text{\nan{}}$. % \end{function} % +% \begin{function}[added = 2016-11-20]{rand} +% \begin{syntax} +% \cs{fp_eval:n} \{ |rand()| \} +% \end{syntax} +% Produces a pseudo-random floating-point number (multiple of +% $10^{-16}$) between $0$~included and $1$~excluded. +% \begin{texnote} +% This is a wrapper around \tn{pdfuniformdeviate}. The random seed +% can be queried using \tn{pdfrandomseed} and set using +% \tn{pdfsetrandomseed}. +% \end{texnote} +% \end{function} +% +% \begin{function}[added = 2016-11-20]{randint} +% \begin{syntax} +% \cs{fp_eval:n} \{ |randint(| \meta{fpexpr} |)| \} +% \cs{fp_eval:n} \{ |randint(| \meta{fpexpr_1} , \meta{fpexpr_2} |)| \} +% \end{syntax} +% Produces a pseudo-random integer between $1$~and \meta{fpexpr} or +% between \meta{fpexpr_1} and \meta{fpexpr_2} inclusive. The bounds +% must be integers in the range $(-10^{16},10^{16})$ and the first +% must be smaller or equal to the second. +% \begin{texnote} +% This is a wrapper around \tn{pdfuniformdeviate}. The random seed +% can be queried using \tn{pdfrandomseed} and set using +% \tn{pdfsetrandomseed}. +% \end{texnote} +% \end{function} +% % \begin{variable}[tested = m3fp-parse001]{inf, nan} % The special values $+\infty$, $-\infty$, and \nan{} are represented % as \texttt{inf}, \texttt{-inf} and \texttt{nan} (see \cs{c_inf_fp}, diff --git a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx index 017e64c4408..ae2238cef24 100644 --- a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx +++ b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx @@ -37,8 +37,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{l3keys2e}{Support package l3kernel too old} @@ -52,8 +52,8 @@ %<package> } \def\ExplFileName{l3keys2e} \def\ExplFileDescription{LaTeX2e option processing using LaTeX3 keys} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} %</driver|package> %<*driver> \documentclass[full]{l3doc} diff --git a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx b/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx index ff94447c900..2591d9d4c7b 100644 --- a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx @@ -38,8 +38,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{xfrac}{Support package l3kernel too old} @@ -54,8 +54,8 @@ \RequirePackage{amstext,graphicx,l3keys2e,textcomp,xparse,xtemplate} \def\ExplFileName{xfrac} \def\ExplFileDescription{L3 Experimental split-level fractions} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} %</driver|package> %<*driver> \documentclass[full]{l3doc} diff --git a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx index 3a142e32fa9..00f10f1c432 100644 --- a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx @@ -41,8 +41,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{xparse}{Support package l3kernel too old} @@ -56,8 +56,8 @@ %<package> } \def\ExplFileName{xparse} \def\ExplFileDescription{L3 Experimental document command parser} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} %</driver|package> %<*driver> \documentclass[full]{l3doc} @@ -195,12 +195,14 @@ % |-NoValue-| if not present. % \item[G] As for \texttt{g} but returns \meta{default} if no value % is given: \texttt{G}\marg{default}. -% \item[k] An optional \emph{key} argument which requires a \emph{value}: -% the key should be a single \meta{token}. If the key is not present, -% returns |-NoValue-|. \emph{This is an experimental type}. -% \item[K] As for \texttt{K} but returns \meta{default} if no value -% is given: \texttt{K}\meta{token}\marg{default}. +% \item[e] An optional set of \emph{embellishments}, each of which requires a +% \emph{value}. If a key is not present, |-NoValue-| is returned. +% The returned data is a token list comprising one braced entry per key, +% ordered as for the key list in the signature. % \emph{This is an experimental type}. +% \item[E] As for \texttt{E} but returns one or more \meta{defaults} +% if values are not given: \texttt{E}\marg{defaults}. See +% Section~\ref{sec:embellishment} for more details. % \end{itemize} % % Using these specifiers, it is possible to create complex input syntax @@ -484,6 +486,25 @@ % take based on this information. % \end{function} % +% \subsection{Default values for \enquote{embellishments}} +% \label{sec:embellishment} +% +% The \texttt{E}-type argument allows one default value per test token. +% This is achieved by giving a list of defaults for each entry in the +% list, for example: +% \begin{verbatim} +% E{^_}{{UP}{DOWN}} +% \end{verbatim} +% If the list of default values is \emph{shorter} than the list of test tokens, +% the special \cs{NoValue} marker will be returned (as for the \texttt{e}-type +% argument). Thus for example +% \begin{verbatim} +% E{^_}{{UP}} +% \end{verbatim} +% has default \texttt{UP} for the |^| test token, but will return the +% \cs{NoValue} marker as a default for |_|. This allows mixing of explicit +% defaults with testing for missing values. +% % \subsection{Argument processors} % \label{sec:processors} % @@ -899,10 +920,12 @@ % \end{macrocode} % \end{variable} % -% \begin{variable}{\l_@@_tmp_tl} +% \begin{variable}{\l_@@_tmp_prop, \l_@@_tmpa_tl, \l_@@_tmpb_tl} % Scratch space. % \begin{macrocode} -\tl_new:N \l_@@_tmp_tl +\prop_new:N \l_@@_tmp_prop +\tl_new:N \l_@@_tmpa_tl +\tl_new:N \l_@@_tmpb_tl % \end{macrocode} % \end{variable} % @@ -1129,8 +1152,8 @@ \cs_new_protected:Npn \@@_count_mandatory:N #1 { \quark_if_recursion_tail_stop:N #1 - \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_count_mandatory:N \l_@@_tmp_tl } + \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmpa_tl + { \exp_after:wN \@@_count_mandatory:N \l_@@_tmpa_tl } { \@@_count_mandatory_aux:N #1 } } \cs_new_protected:Npn \@@_count_mandatory_aux:N #1 @@ -1149,10 +1172,10 @@ % \@@_count_type_+:w, % \@@_count_type_d:w, % \@@_count_type_D:w, +% \@@_count_type_e:w, +% \@@_count_type_E:w, % \@@_count_type_g:w, % \@@_count_type_G:w, -% \@@_count_type_k:w, -% \@@_count_type_K:w, % \@@_count_type_m:w, % \@@_count_type_r:w, % \@@_count_type_R:w, @@ -1202,23 +1225,21 @@ \quark_if_recursion_tail_stop_do:nn {#3} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_g:w - { \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_G:w #1 +\cs_new_protected:Npn \@@_count_type_e:w #1 { \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_k:w #1 +\cs_new_protected:Npn \@@_count_type_E:w #1#2 { - \@@_single_token_check:n {#1} - \quark_if_recursion_tail_stop_do:Nn #1 { \@@_bad_arg_spec:wn } + \quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } -\cs_new_protected:Npn \@@_count_type_K:w #1#2 +\cs_new_protected:Npn \@@_count_type_g:w + { \@@_count_mandatory:N } +\cs_new_protected:Npn \@@_count_type_G:w #1 { - \@@_single_token_check:n {#1} - \quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn } + \quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn } \@@_count_mandatory:N } \cs_new_protected:Npn \@@_count_type_m:w @@ -1320,8 +1341,8 @@ \cs_new_protected:Npn \@@_prepare_signature_bypass:N #1 { \quark_if_recursion_tail_stop:N #1 - \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_prepare_signature:N \l_@@_tmp_tl } + \prop_get:NnNTF \c_@@_shorthands_prop {#1} \l_@@_tmpa_tl + { \exp_after:wN \@@_prepare_signature:N \l_@@_tmpa_tl } { \int_incr:N \l_@@_current_arg_int \@@_prepare_signature_add:N #1 @@ -1415,6 +1436,23 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_add_type_e:w, \@@_add_type_E:w} +% Setting up for the \texttt{e}-type argument is somewhat specialised as +% the |-NoValue-| tokens are inserted by the grabber rather than here. As +% such, all that is needed is to pass data straight through. +% \begin{macrocode} +\cs_new_protected:Npn \@@_add_type_e:w #1 + { \@@_add_type_E:w {#1} { } } +\cs_new_protected:Npn \@@_add_type_E:w #1#2 + { + \@@_flush_m_args: + \@@_add_grabber_optional:N E + \tl_put_right:Nn \l_@@_signature_tl { {#1} {#2} } + \@@_prepare_signature:N + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_add_type_g:w} % The \texttt{g} type is simply an alias for \texttt{G} with the correct % default built-in. @@ -1438,22 +1476,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_add_type_k:w, \@@_add_type_K:w} -% Similar to |d|/|D| type but just one token to store. -% \begin{macrocode} -\cs_new_protected:Npn \@@_add_type_k:w #1 - { \exp_args:NNo \@@_add_type_K:w #1 \c_@@_no_value_tl } -\cs_new_protected:Npn \@@_add_type_K:w #1#2 - { - \@@_flush_m_args: - \@@_add_grabber_optional:N K - \tl_put_right:Nn \l_@@_signature_tl { #1 {#2} } - \@@_prepare_signature:N - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_add_type_l:w} % Finding \texttt{l} arguments is very simple: there is nothing to do % other than add the grabber. @@ -1728,34 +1750,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_add_expandable_type_k:w} -% \begin{macro}{\@@_add_expandable_type_K:w} -% \begin{macrocode} -\cs_new_protected:Npn \@@_add_expandable_type_k:w #1 - { - \exp_args:NNo - \@@_add_expandable_type_K:w #1 \c_@@_no_value_tl - } -\cs_new_protected:Npn \@@_add_expandable_type_K:w #1#2 - { - \@@_add_expandable_grabber_optional:n { K } - \bool_if:NTF \l_@@_all_long_bool - { \cs_set:cpx } - { \cs_set_nopar:cpx } - { \l_@@_expandable_aux_name_tl } ##1 #1 ##2 - { ##1 {##2} } - \tl_put_right:Nx \l_@@_signature_tl - { - \exp_not:c { \l_@@_expandable_aux_name_tl } - \exp_not:n { #1 {#2} } - } - \bool_set_false:N \l_@@_long_bool - \@@_prepare_signature:N - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_add_expandable_type_l:w} % Invalid in expandable contexts (as the next left brace may have been % inserted by \pkg{xparse} due to a failed search for an optional argument). @@ -2067,10 +2061,10 @@ { \@@_grab_D_nested:w \q_nil ##2 \q_stop } \tl_if_in:NnTF \l_@@_nesting_b_tl {#1} { - \tl_set_eq:NN \l_@@_tmp_tl \l_@@_nesting_b_tl + \tl_set_eq:NN \l_@@_tmpa_tl \l_@@_nesting_b_tl \tl_clear:N \l_@@_nesting_b_tl \exp_after:wN \l_@@_fn_tl \exp_after:wN - \q_nil \l_@@_tmp_tl \q_nil \q_@@ \ERROR + \q_nil \l_@@_tmpa_tl \q_nil \q_@@ \ERROR } { \tl_put_right:No \l_@@_nesting_a_tl @@ -2091,6 +2085,109 @@ % \end{macro} % \end{macro} % +% \begin{macro} +% { +% \@@_grab_E:w, \@@_grab_E_long:w, +% \@@_grab_E_trailing:w, \@@_grab_E_long_trailing:w +% } +% \begin{macro}[aux]{\@@_grab_E:nnnNn} +% \begin{macro}[aux]{\@@_grab_E_setup:Nw} +% \begin{macro}[aux]{\@@_grab_E_loop:nnN} +% \begin{macro}[aux]{\@@_grab_E_finalise:} +% Everything here needs to point to a loop. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected_nopar:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \@@_grab_E_long:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected:Npn + { _ignore_spaces } + } +\cs_new_protected:Npn \@@_grab_E_trailing:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected_nopar:Npn + { } + } +\cs_new_protected:Npn \@@_grab_E_long_trailing:w #1#2#3 \l_@@_args_tl + { + \@@_grab_E:nnnNn + {#1} {#2} {#3} + \cs_set_protected:Npn + { } + } +% \end{macrocode} +% A loop is needed here to allow a random ordering of keys. These are +% searched for one at a time, with any not found needing to be tracked: +% they can appear later. The grabbed values are held in a property list +% which is then turned into an ordered list to be passed back to the user. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E:nnnNn #1#2#3#4#5 + { + \exp_after:wN #4 \l_@@_fn_tl ##1##2##3 + { + \prop_put:Nnn \l_@@_tmp_prop {##1} {##3} + \@@_grab_E_loop:nnN {#5} { } ##2 \q_recursion_stop + } + \prop_clear:N \l_@@_tmp_prop + \@@_grab_E_setup:Nw + #1 \q_recursion_tail \q_mark #2 \q_recursion_tail \q_recursion_stop + \cs_set_protected:Npn \@@_grab_E_finalise: + { + \tl_clear:N \l_@@_tmpa_tl + \tl_map_inline:nn {#1} + { + \prop_get:NnNF \l_@@_tmp_prop {####1} \l_@@_tmpb_tl + { \tl_set_eq:NN \l_@@_tmpb_tl \c_@@_no_value_tl } + \tl_set:Nx \l_@@_tmpa_tl + { + \exp_not:V \l_@@_tmpa_tl + { \exp_not:V \l_@@_tmpb_tl } + } + } + \@@_add_arg:V \l_@@_tmpa_tl + #3 \l_@@_args_tl + } + \@@_grab_E_loop:nnN {#5} { } #1 \q_recursion_tail \q_recursion_stop + } +% \end{macrocode} +% To allow for flexible default values, the list of those given may be +% shorter than the number of test tokens. This can readily be achieved +% by storing only the given defaults in the property list. +% \begin{macrocode} +\cs_new_protected:Npn \@@_grab_E_setup:Nw #1#2 \q_mark #3 + { + \quark_if_recursion_tail_stop:N #1 + \quark_if_recursion_tail_stop:n {#3} + \prop_put:Nnn \l_@@_tmp_prop {#1} {#3} + \@@_grab_E_setup:Nw #2 \q_mark + } +\cs_new_protected:Npn \@@_grab_E_loop:nnN #1#2#3#4 \q_recursion_stop + { + \cs_if_eq:NNTF #3 \q_recursion_tail + { \@@_grab_E_finalise: } + { + \use:c { peek_meaning_remove #1 :NTF } #3 + { \l_@@_fn_tl #3 {#2#4} } + { \@@_grab_E_loop:nnN {#1} {#2#3} #4 \q_recursion_stop } + } + } +\cs_new_protected:Npn \@@_grab_E_finalise: { } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\@@_grab_G:w} % \begin{macro}{\@@_grab_G_long:w} % \begin{macro}{\@@_grab_G_trailing:w} @@ -2133,56 +2230,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_grab_K:w, \@@_grab_K_long:w} -% \begin{macro}[aux]{\@@_grab_K_aux:nnnNn} -% Look ahead at one token and if it matches grab an argument. -% \begin{macrocode} -\cs_new_protected:Npn \@@_grab_K:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected_nopar:Npn - { _ignore_spaces } - } -\cs_new_protected:Npn \@@_grab_K_long:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected:Npn - { _ignore_spaces } - } -\cs_new_protected:Npn \@@_grab_K_trailing:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected_nopar:Npn - { } - } -\cs_new_protected:Npn \@@_grab_K_long_trailing:w #1#2#3 \l_@@_args_tl - { - \@@_grab_K_aux:nnnNn - {#1} {#2} {#3} - \cs_set_protected:Npn - { } - } -\cs_new_protected:Npn \@@_grab_K_aux:nnnNn #1#2#3#4#5 - { - \exp_after:wN #4 \l_@@_fn_tl ##1 - { - \@@_add_arg:n {##1} - #3 \l_@@_args_tl - } - \use:c { peek_meaning_remove #5 :NTF } #1 - { \l_@@_fn_tl } - { - \@@_add_arg:n {#2} - #3 \l_@@_args_tl - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\@@_grab_l:w} % \begin{macro}{\@@_grab_l_long:w} % \begin{macro}[aux]{\@@_grab_l_aux:nN} @@ -2901,29 +2948,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}[EXP]{\@@_expandable_grab_K:w} -% \begin{macro}[EXP, aux]{\@@_expandable_grab_K_aux:NNwn} -% As for the |D|-type grabber, use the auxiliary to do the look ahead -% test then reuse it for the grabbing. -% \begin{macrocode} -\cs_new:Npn \@@_expandable_grab_K:w #1 \q_@@ #2 - { #2 { \@@_expandable_grab_K_aux:NNwn #1 \q_@@ #2 } } -\cs_new:Npn \@@_expandable_grab_K_aux:NNwn #1#2#3#4 \q_@@ #5#6 - { - \str_if_eq:onTF { #1 { } #6 { } #2 { } } { { } #2 { } } - { - #1 - { \@@_expandable_grab_K_aux:Nwn #5 #4 \q_@@ } - #6 - } - { #4 {#3} \q_@@ #5 {#6} } - } -\cs_new:Npn \@@_expandable_grab_K_aux:Nwn #1#2 \q_@@ #3 - { #2 {#3} \q_@@ #1 } -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}[EXP]{\@@_expandable_grab_m:w} % \begin{macro}[EXP, aux]{\@@_expandable_grab_m_aux:wNn} % The mandatory case is easy: find the auxiliary after the \cs{q_@@}, and diff --git a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx index 394bb8b72ee..d462fd1f58c 100644 --- a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx @@ -41,8 +41,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2016/10/19] -%<package>\@ifpackagelater{expl3}{2016/10/19} +\RequirePackage{expl3}[2016/11/21] +%<package>\@ifpackagelater{expl3}{2016/11/21} %<package> {} %<package> {% %<package> \PackageError{xtemplate}{Support package l3kernel too old} @@ -56,8 +56,8 @@ %<package> } \def\ExplFileName{xtemplate} \def\ExplFileDescription{L3 Experimental prototype document functions} -\def\ExplFileDate{2016/10/19} -\def\ExplFileVersion{6730} +\def\ExplFileDate{2016/11/21} +\def\ExplFileVersion{6760} %</driver|package> %<*driver> \documentclass[full]{l3doc} |