diff options
author | Karl Berry <karl@freefriends.org> | 2017-03-08 23:01:35 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-03-08 23:01:35 +0000 |
commit | 6fca20c09474a7f6a3559af1c984243a83669f61 (patch) | |
tree | cbfda048c91853241ef903a84a088c1e3a66fd50 /Master/texmf-dist/source/latex/l3kernel | |
parent | ddbc1f2a5f193876d6f1df544e286029c6d671f8 (diff) |
l3 (8mar17)
git-svn-id: svn://tug.org/texlive/trunk@43432 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel')
44 files changed, 2560 insertions, 1783 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx index 7f7774db5e5..55659a6b4e4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/expl3.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/expl3.dtx @@ -23,8 +23,8 @@ %<*driver|generic|package> \def\ExplFileName{expl3}% \def\ExplFileDescription{L3 programming layer}% -\def\ExplFileDate{2017/02/10}% -\def\ExplFileVersion{6878}% +\def\ExplFileDate{2017/03/07}% +\def\ExplFileVersion{6984}% %</driver|generic|package> %<*driver> \documentclass[full]{l3doc} @@ -1714,11 +1714,9 @@ \sys_if_engine_xetex:TF { xdvipdfmx } { - \bool_if:nTF - { - \cs_if_exist_p:N \pdftex_pdfoutput:D - && \int_compare_p:nNn \pdftex_pdfoutput:D > \c_zero - } + \bool_lazy_and:nnTF + { \cs_if_exist_p:N \pdftex_pdfoutput:D } + { \int_compare_p:nNn \pdftex_pdfoutput:D > 0 } { pdfmode } { dvips } } diff --git a/Master/texmf-dist/source/latex/l3kernel/l3.ins b/Master/texmf-dist/source/latex/l3kernel/l3.ins index 3f281392b4e..2c381ced862 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3.ins @@ -67,6 +67,7 @@ and all files in that bundle must be distributed together. \from{l3str.dtx} {package} \from{l3seq.dtx} {package} \from{l3int.dtx} {package} + \from{l3flag.dtx} {package} \from{l3quark.dtx} {package} \from{l3prg.dtx} {package} \from{l3clist.dtx} {package} @@ -94,6 +95,7 @@ and all files in that bundle must be distributed together. \from{l3coffins.dtx} {package} \from{l3color.dtx} {package} \from{l3sys.dtx} {package} + \from{l3deprecation.dtx}{package} \from{l3candidates.dtx} {package} \from{l3luatex.dtx} {package,tex} } diff --git a/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx b/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx index 8d783bd018f..2a788cf80d2 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3alloc.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3alloc.dtx Copyright (C) 1990-2012,2014-2016 The LaTeX3 Project +%% File: l3alloc.dtx Copyright (C) 1990-2012,2014-2017 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 @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3alloc.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3alloc.dtx 6952 2017-02-18 19:07:47Z joseph $ {L3 Register allocation} \begin{document} \DocInput{\jobname.dtx} @@ -51,70 +51,25 @@ % % \begin{documentation} % -% Note that this module is only used for generating an \pkg{expl3}-based -% format. Under \LaTeX{}, the \pkg{etex} package is used for allocation -% management. -% -% This module provides the basic mechanism for allocating \TeX{}'s -% registers. While designing this we have to take into account the -% following characteristics: -% \begin{itemize} -% \item |\box255| is reserved for use in the output routine, so it -% should not be allocated otherwise. -% \item \TeX{} can load up $256$ hyphenation patterns (registers -% \tn{language} $0$ to $255$), -% \item \TeX{} can load no more than $16$ math families, -% \item \TeX{} supports no more than $16$ I/O streams for reading -% (\tn{read}) and $16$ I/O streams for writing (\tn{write}), -% \item \TeX{} supports no more than $256$ inserts. -% \item The other registers (\tn{count}, \tn{dimen}, \tn{skip}, -% \tn{muskip}, \tn{box}, and \tn{toks}) range from $0$ to $32\,767$ -% ($65\,535$ for \LuaTeX{}), but registers numbered above $255$ are -% accessed somewhat less efficiently (except in \LuaTeX{}, where access -% is \enquote[flat}). -% \item Registers could be allocated both globally and locally; the -% use of registers could also be global or local. Here we -% provide support for globally allocated registers for both -% global and local use. -% \end{itemize} -% We also need to allow for some bookkeeping: we need to know which -% register was allocated last and which registers can not be -% allocated by the standard mechanisms. -% -% \section{Internal functions} -% -% Register-based allocation is a low-level process, and is therefore -% only to be used as part of kernel code. -% -% \begin{function}[updated = 2012-11-09]{\__alloc_new:nnnN} -% \begin{syntax} -% \cs{__alloc_new:nnnN} \Arg{type} \Arg{min} \Arg{max} \meta{function} -% \end{syntax} -% Shorthand for allocating new registers. Defines \cs{\meta{type}_new:N} as -% and allocator function of the specified \meta{type}, indexed up from -% \meta{min} to a \meta{max}, and with assignment carried out by -% the \meta{function}. This process will create two token lists, -% \cs{g_\meta{type}_allocation_tl} and \cs{c_\meta{type}_allocation_max_tl}, -% to store the current and maximum allocation numbers, respectively. -% \end{function} -% -% \begin{function}[updated = 2011-09-05]{\__alloc_setup_type:nnn} -% \begin{syntax} -% \cs{__alloc_setup_type:nnn} \Arg{type} \Arg{min} \Arg{max} -% \end{syntax} -% Sets up the storage needed for the administration of registers of -% \Arg{type}, which will start allocating at \meta{min} and will issue -% an error if there is an attempt to allocate past the \meta{max}. -% \end{function} -% -% \begin{function}{\__alloc_reg:nNN} -% \begin{syntax} -% \cs{__alloc_reg:nNN} \Arg{type} \meta{function} \meta{register} -% \end{syntax} -% Preforms the allocation for a new \meta{register} of \meta{type}, -% using the allocator \meta{function} (which will be either a -% primitive \tn{\ldots def} or \tn{chardef}). -% \end{function} +% This module provides the basic mechanism for allocating \TeX{}'s +% registers when operating in format mode. When loaded as a package on +% an existing format, the mechanisms from the latter are used. +% +% The approach used here is informed by the mechanisms used in plain +% \TeX{}/\LaTeX{} but noting that newer engines provide us much more +% flexibility. In addition to this, we do not need allocators for all +% register types: for example \texttt{toks} are not used by \LaTeX3 whilst +% reads/writes are handled using a pool and thus do not need a classical +% allocator. +% +% In classical (non-\LuaTeX{}) engines, there are various restriction on +% registers, for example |\box255| is hard-coded as the output box and +% inserts have to be allocated below this (not in the extended pool). Rather +% than worry about this, allocations for the registers affected (\TeX{} +% |box|, |count|, |dimen| and |skip| types) are simply made only from the +% extended pool. (There is a performance impact in engines other than +% \LuaTeX{} but the free use of registers in \pkg{expl3} means that code +% cannot be sure of obtaining a low-numbered register in any case.) % % \end{documentation} % @@ -130,127 +85,101 @@ %<@@=alloc> % \end{macrocode} % -% \begin{macro}[int]{\@@_new:nnnN} -% Shorthand for defining new register types and their allocators: creates -% the appropriate variables and the allocator function itself. -% \begin{macrocode} -\cs_new_protected:Npn \@@_new:nnnN #1#2#3#4 - { - \@@_setup_type:nnn {#1} {#2} {#3} - \cs_new_protected:cpn { #1 _new:N } ##1 { \@@_reg:nNN {#1} #4 ##1 } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\@@_setup_type:nnn} -% For each type of register we need to \enquote{counters} that hold the -% last allocated global register, plus a constant for the maximum -% allocation. +% \begin{variable}[int] +% { +% \g_@@_int_int , +% \g_@@_dim_int , +% \g_@@_muskip_int , +% \g_@@_int_int , +% \g_@@_box_int +% } +% The core register tracking is done using the same raw \TeX{} count +% registers as reserved by plain \TeX{} and \LaTeXe{}, as there may be the +% odd piece of generic code that needs to work by number. However, as not +% all of our variables work the same way, some of the older registers are +% simply ignored. For the same reason, there is no special status for the +% low-numbers registers other than counts. To avoid having to worry about +% inserts and reflecting the register availability in \eTeX{}, the lower +% register space is unused here (though is available for hard-coded +% use). % \begin{macrocode} -\cs_new_protected:Npn \@@_setup_type:nnn #1#2#3 - { - \tl_new:c { g__ #1 _allocation_tl } - \tl_gset:cx { g__ #1 _allocation_tl } { \int_eval:n {#2} } - \tl_const:cx { c__ #1 _allocation_max_tl } { \int_eval:n {#3} } - } +\tex_countdef:D \g_@@_int_int = 10 ~ +\tex_countdef:D \g_@@_dim_int = 11 ~ +\tex_countdef:D \g_@@_skip_int = 12 ~ +\tex_countdef:D \g_@@_muskip_int = 13 ~ +\tex_countdef:D \g_@@_box_int = 14 ~ +\g_@@_int_int = 255 ~ +\g_@@_dim_int = 255 ~ +\g_@@_skip_int = 255 ~ +\g_@@_muskip_int = 0 ~ +\g_@@_box_int = 255 ~ % \end{macrocode} -% \end{macro} -% -% \begin{macro}{\int_eval:n} -% For bootstrapping purposes, a definition of \cs{int_eval:n} is needed -% in terms of primitives. This is replaced in \pkg{l3int} with a clearer -% one. +% \end{variable} +% +% \begin{variable} +% { +% \g_@@_attribute_int , +% \g_@@_bytecode_int , +% \g_@@_chunkname_int , +% \g_@@_whatsit_int +% } +% To allow \LuaTeX{} to load |ltluatex.lua| for generic \Lua{} support, a +% small number of counts have to be correctly named at the \TeX{} level. +% At present there are no \pkg{expl3} allocators for these concepts so the +% names and numbers of the tracking variables may change. % \begin{macrocode} -\cs_new:Npn \int_eval:n #1 { \tex_number:D \etex_numexpr:D #1 \scan_stop: } +\etex_ifdefined:D \luatex_luatexversion:D + \tex_global:D \tex_countdef:D \g_@@_attribute_int = 21 ~ + \tex_global:D \tex_countdef:D \g_@@_bytecode_int = 22 ~ + \tex_global:D \tex_countdef:D \g_@@_chunkname_int = 23 ~ + \tex_global:D \tex_countdef:D \g_@@_whatsit_int = 24 ~ +\tex_fi:D % \end{macrocode} -% \end{macro} +% \end{variable} % % \begin{macro} % {\box_new:N, \dim_new:N, \int_new:N, \muskip_new:N \skip_new:N} -% To get everything to work correctly for inserts, some register types -% need to have their allocators set up \enquote{early}. It therefore -% makes sense to collect most of them together here. +% Each of the public allocators is a wrapper around the one internal +% function needed here. % \begin{macrocode} -\cs_if_exist:NTF \luatex_luatexversion:D - { \@@_new:nnnN { box } { 0 } \c_max_register_int \tex_chardef:D } - { \@@_new:nnnN { box } { 0 } \c_max_register_int \tex_mathchardef:D } -\@@_new:nnnN { dim } { 0 } \c_max_register_int \tex_dimendef:D -\@@_new:nnnN { int } { 10 } \c_max_register_int \tex_countdef:D -\@@_new:nnnN { muskip } { 0 } \c_max_register_int \tex_muskipdef:D -\@@_new:nnnN { skip } { 0 } \c_max_register_int \tex_skipdef:D -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\insert_new:N} -% For inserts, there is a need to reserve space in various other registers. -% First, the basic allocation is done. -% \begin{macrocode} -\@@_new:nnnN { insert } { 221 } { 254 } \tex_chardef:D -% \end{macrocode} -% Reserve a gap in the \texttt{box}, \texttt{dim}, \texttt{int} and -% \texttt{skip} lists. (An inline token list mapping would read better here, -% but this does not work until \texttt{int} allocation is available!) Note -% that \texttt{box255} is reserved by \TeX{} itself (\LuaTeX{} does make -% this alterable, but that doesn't really do much for us so we ignore -% that!) -% \begin{macrocode} -\tl_const:Nn \c__box_allocation_reserve_begin_tl { 221 } -\tl_const:Nn \c__box_allocation_reserve_end_tl { 255 } -\tl_const:Nn \c__dim_allocation_reserve_begin_tl { 221 } -\tl_const:Nn \c__dim_allocation_reserve_end_tl { 254 } -\tl_const:Nn \c__int_allocation_reserve_begin_tl { 221 } -\tl_const:Nn \c__int_allocation_reserve_end_tl { 254 } -\tl_const:Nn \c__skip_allocation_reserve_begin_tl { 221 } -\tl_const:Nn \c__skip_allocation_reserve_end_tl { 254 } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\@@_reg:nNN} -% This internal macro performs the actual allocation. -% \begin{macrocode} -\cs_new_protected:Npn \@@_reg:nNN #1#2#3 +\cs_new_protected:Npx \box_new:N #1 { - \__chk_if_free_cs:N #3 - \int_compare:nNnTF - { \tl_use:c { g__ #1 _allocation_tl } } - > { \tl_use:c { c__ #1 _allocation_max_tl } } - { \__msg_kernel_fatal:nnx { kernel } { out-of-registers } {#1} } - { - \tex_global:D #2 #3 \tl_use:c { g__ #1 _allocation_tl } \scan_stop: - \iow_log:x - { - \token_to_str:N #3 ~=~ #1 ~register~ - \tl_use:c { g__ #1 _allocation_tl } - } - \@@_next:n {#1} - } + \exp_not:N \@@_reg:nNnN { box } + \cs_if_exist:NTF \luatex_luatexversion:D + { \tex_chardef:D } + { \tex_mathchardef:D } + \c_max_register_int + #1 } +\cs_new_protected:Npn \dim_new:N #1 + { \@@_reg:nNnN { dim } \tex_dimendef:D \c_max_register_int #1 } +\cs_new_protected:Npn \int_new:N #1 + { \@@_reg:nNnN { int } \tex_countdef:D \c_max_register_int #1 } +\cs_new_protected:Npn \muskip_new:N #1 + { \@@_reg:nNnN { muskip } \tex_muskipdef:D \c_max_register_int #1 } +\cs_new_protected:Npn \skip_new:N #1 + { \@@_reg:nNnN { skip } \tex_skipdef:D \c_max_register_int #1 } % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_next:n} -% Set up the next allocation by adding one to the current number, and if -% necessary skipping over a reserved block. +% \begin{macro}[int]{\@@_reg:nNNN} +% The allocator itself is modeled somewhat on \LaTeXe{}'s \tn{e@alloc}, +% though there is no need to set \tn{allocationnumber}. % \begin{macrocode} -\cs_new_protected:Npn \@@_next:n #1 +\cs_new_protected:Npn \@@_reg:nNnN #1#2#3#4 { - \tl_gset:cx { g__ #1 _allocation_tl } + \__chk_if_free_cs:N #4 + \int_compare:nNnTF { \int_use:c { g_@@_ #1 _int } } < {#3} { - \int_eval:n + \int_gincr:c { g_@@_ #1 _int } + \tex_global:D #2 #4 \int_use:c { g_@@_ #1 _int } + \iow_log:x { - \tl_if_exist:cTF { c__ #1 _allocation_reserve_begin_tl } - { - \int_compare:nNnTF - { \tl_use:c { g__ #1 _allocation_tl } + 1 } - = - { \tl_use:c { c__ #1 _allocation_reserve_begin_tl } } - { \tl_use:c { c__ #1 _allocation_reserve_end_tl } } - { \tl_use:c { g__ #1 _allocation_tl } } - } - { \tl_use:c { g__ #1 _allocation_tl } } - + 1 + \token_to_str:N #4 ~=~ #1 ~register~ + \int_use:c { g_@@_ #1 _int } } } + { \__msg_kernel_fatal:nnx { kernel } { out-of-registers } {#1} } } % \end{macrocode} % \end{macro} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx index 6337bf9c86f..6b66f76f239 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3basics.dtx Copyright (C) 1990-2016 The LaTeX3 project +%% File: l3basics.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3basics.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3basics.dtx 6929 2017-02-14 15:53:00Z bruno $ {L3 Basic definitions} %</driver|package> %<*driver> @@ -686,7 +686,7 @@ % \end{texnote} % \end{function} % -% \begin{function}[updated = 2015-08-03]{\cs_show:N, \cs_show:c} +% \begin{function}[updated = 2017-02-14]{\cs_show:N, \cs_show:c} % \begin{syntax} % \cs{cs_show:N} \meta{control sequence} % \end{syntax} @@ -698,6 +698,15 @@ % \end{texnote} % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2017-02-14]{\cs_log:N, \cs_log:c} +% \begin{syntax} +% \cs{cs_log:N} \meta{control sequence} +% \end{syntax} +% Writes the definition of the \meta{control sequence} in the log +% file. See also \cs{cs_show:N} which displays the result in the +% terminal. +% \end{function} +% % \subsection{Converting to and from control sequences} % % \begin{function}[EXP]{\use:c} @@ -1040,7 +1049,7 @@ % \cs{cs_if_eq:NNTF} \Arg{cs_1} \Arg{cs_2} \Arg{true code} \Arg{false code} % \end{syntax} % Compares the definition of two \meta{control sequences} and -% is logically \texttt{true} the same, \emph{i.e.}~if they have exactly +% is logically \texttt{true} if they are the same, \emph{i.e.}~if they have exactly % the same definition when examined with \cs{cs_show:N}. % \end{function} % @@ -1256,6 +1265,15 @@ % such that internal parts of the mechanism are not visible. % \end{function} % +% \begin{function}[updated = 2015-08-03] +% {\__kernel_register_log:N, \__kernel_register_log:c} +% \begin{syntax} +% \cs{__kernel_register_log:N} \meta{register} +% \end{syntax} +% Used to write the contents of a \TeX{} register to the log file in a +% form similar to \cs{__kernel_register_show:N}. +% \end{function} +% % \begin{function}[EXP]{\__prg_case_end:nw} % \begin{syntax} % \cs{__prg_case_end:nw} \Arg{code} \meta{tokens} \cs{q_mark} \Arg{true code} \cs{q_mark} \Arg{false code} \cs{q_stop} @@ -2897,38 +2915,77 @@ % \subsection{Diagnostic functions} % % \begin{macro}[int]{\__kernel_register_show:N, \__kernel_register_show:c} +% \begin{macro}[aux]{\__kernel_register_show_aux:n} % Simply using the \tn{showthe} primitive does not allow for % line-wrapping, so instead use \cs{__msg_show_variable:NNNnn} (defined % in \pkg{l3msg}). This checks that the variable exists (using % \cs{cs_if_exist:NTF}), then displays the third argument, namely -% |>~|\meta{variable}|=|\meta{value}. +% |>~|\meta{variable}|=|\meta{value}. We expand the value before-hand +% as otherwise some integers (such as \tn{currentgrouplevel} or +% \tn{currentgrouptype}) altered by the line-wrapping code would show +% wrong values. % \begin{macrocode} \cs_new_protected:Npn \__kernel_register_show:N #1 + { \exp_args:No \__kernel_register_show_aux:nN { \tex_the:D #1 } #1 } +\cs_new_protected:Npn \__kernel_register_show_aux:nN #1#2 { - \__msg_show_variable:NNNnn #1 \cs_if_exist:NTF ? { } - { > ~ \token_to_str:N #1 = \tex_the:D #1 } + \__msg_show_variable:NNNnn #2 \cs_if_exist:NTF ? { } + { > ~ \token_to_str:N #2 = #1 } } \cs_new_protected:Npn \__kernel_register_show:c { \exp_args:Nc \__kernel_register_show:N } % \end{macrocode} % \end{macro} +% \end{macro} +% +% \begin{macro}[int]{\__kernel_register_log:N, \__kernel_register_log:c} +% Redirect the output of \cs{__kernel_register_show:N} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \__kernel_register_log:N + { \__msg_log_next: \__kernel_register_show:N } +\cs_new_protected:Npn \__kernel_register_log:c + { \exp_args:Nc \__kernel_register_log:N } +% \end{macrocode} +% \end{macro} % % \begin{macro}{\cs_show:N, \cs_show:c} % Some control sequences have a very long name or meaning. Thus, % simply using \TeX{}'s primitive \tn{show} could lead to overlong % lines. The output of this primitive is mimicked to some extent, % then the re-built string is given to \cs{iow_wrap:nnnN} for -% line-wrapping. The \cs{cs_show:c} command converts its argument to -% a control sequence within a group to avoid showing \tn{relax} for -% undefined control sequences. +% line-wrapping. We must expand the meaning before passing it to the +% wrapping code as otherwise we would wrongly see the definitions that +% are in place there. To get correct escape characters, set the +% \tn{escapechar} in a group; this also localizes the assignment +% performed by \texttt{x}-expansion. The \cs{cs_show:c} command also +% converts its argument to a control sequence within a group to avoid +% showing \tn{relax} for undefined control sequences. % \begin{macrocode} \cs_new_protected:Npn \cs_show:N #1 - { \__msg_show_wrap:n { > ~ \token_to_str:N #1 = \cs_meaning:N #1 } } + { + \group_begin: + \int_set:Nn \tex_escapechar:D { `\\ } + \exp_args:NNx + \group_end: + \__msg_show_wrap:n { > ~ \token_to_str:N #1 = \cs_meaning:N #1 } + } \cs_new_protected:Npn \cs_show:c { \group_begin: \exp_args:NNc \group_end: \cs_show:N } % \end{macrocode} % \end{macro} % +% \begin{macro}{\cs_log:N, \cs_log:c} +% Use \cs{cs_show:N} or \cs{cs_show:c} after calling +% \cs{__msg_log_next:} to redirect their output to the log file only. +% Note that \cs{cs_log:c} is not just a variant of \cs{cs_log:N} as +% the csname should be turned to a control sequence within a group +% (see \cs{cs_show:c}). +% \begin{macrocode} +\cs_new_protected:Npn \cs_log:N { \__msg_log_next: \cs_show:N } +\cs_new_protected:Npn \cs_log:c { \__msg_log_next: \cs_show:c } +% \end{macrocode} +% \end{macro} +% % \subsection{Doing nothing functions} % % \begin{macro}[EXP]{\prg_do_nothing:} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx index 239228d0917..0b06dae64f2 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3box.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3box.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Experimental boxes} %</driver|package> %<*driver> @@ -915,13 +915,14 @@ % % \begin{macro}{\box_show:N, \box_show:c} % \begin{macro}{\box_show:Nnn, \box_show:cnn} -% Essentially a wrapper around the internal function. +% Essentially a wrapper around the internal function, but evaluating +% the breadth and depth arguments now outside the group. % \begin{macrocode} \cs_new_protected:Npn \box_show:N #1 { \box_show:Nnn #1 \c_max_int \c_max_int } \cs_generate_variant:Nn \box_show:N { c } -\cs_new_protected:Npn \box_show:Nnn - { \@@_show:NNnn \c_one } +\cs_new_protected:Npn \box_show:Nnn #1#2#3 + { \@@_show:NNff 1 #1 { \int_eval:n {#2} } { \int_eval:n {#3} } } \cs_generate_variant:Nn \box_show:Nnn { c } % \end{macrocode} % \end{macro} @@ -929,29 +930,28 @@ % % \begin{macro}{\box_log:N, \box_log:c} % \begin{macro}{\box_log:Nnn, \box_log:cnn} +% \begin{macro}[aux]{\@@_log:nNnn} % Getting \TeX{} to write to the log without interruption the run is done by % altering the interaction mode. For that, the \eTeX{} extensions are needed. % \begin{macrocode} \cs_new_protected:Npn \box_log:N #1 { \box_log:Nnn #1 \c_max_int \c_max_int } \cs_generate_variant:Nn \box_log:N { c } -\cs_new_protected:Npn \box_log:Nnn #1#2#3 +\cs_new_protected:Npn \box_log:Nnn + { \exp_args:No \@@_log:nNnn { \tex_the:D \etex_interactionmode:D } } +\cs_new_protected:Npn \@@_log:nNnn #1#2#3#4 { - \use:x - { - \etex_interactionmode:D \c_zero - \@@_show:NNnn \c_zero \exp_not:N #1 - { \int_eval:n {#2} } { \int_eval:n {#3} } - \etex_interactionmode:D - = \tex_the:D \etex_interactionmode:D \scan_stop: - } + \int_set:Nn \etex_interactionmode:D { 0 } + \@@_show:NNff 0 #2 { \int_eval:n {#3} } { \int_eval:n {#4} } + \int_set:Nn \etex_interactionmode:D {#1} } \cs_generate_variant:Nn \box_log:Nnn { c } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % -% \begin{macro}[aux]{\@@_show:NNnn} +% \begin{macro}[aux]{\@@_show:NNnn, \@@_show:NNff} % The internal auxiliary to actually do the output uses a group to deal % with breadth and depth values. The \cs{use:n} here gives better output % appearance. Setting \tn{tracingonline} and \tn{errorcontextlines} is @@ -959,19 +959,22 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_show:NNnn #1#2#3#4 { - \group_begin: - \int_set:Nn \tex_showboxbreadth:D {#3} - \int_set:Nn \tex_showboxdepth:D {#4} - \int_set_eq:NN \tex_tracingonline:D #1 - \int_set:Nn \tex_errorcontextlines:D { - \c_one } - \box_if_exist:NTF #2 - { \tex_showbox:D \use:n {#2} } - { - \__msg_kernel_error:nnx { kernel } { variable-not-defined } - { \token_to_str:N #2 } - } - \group_end: + \box_if_exist:NTF #2 + { + \group_begin: + \int_set:Nn \tex_showboxbreadth:D {#3} + \int_set:Nn \tex_showboxdepth:D {#4} + \int_set:Nn \tex_tracingonline:D {#1} + \int_set:Nn \tex_errorcontextlines:D { -1 } + \tex_showbox:D \use:n {#2} + \group_end: + } + { + \__msg_kernel_error:nnx { kernel } { variable-not-defined } + { \token_to_str:N #2 } + } } +\cs_generate_variant:Nn \@@_show:NNnn { NNff } % \end{macrocode} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 9b68994b370..526762d2529 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3candidates.dtx Copyright (C) 2012-2016 The LaTeX3 Project +%% File: l3candidates.dtx Copyright (C) 2012-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3candidates.dtx 6835 2017-01-30 21:25:17Z bruno $ +\GetIdInfo$Id: l3candidates.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Experimental additions to l3kernel} %</driver|package> %<*driver> @@ -90,26 +90,6 @@ % into the kernel. However, real use sometimes leads to better ideas, so functions from this module are % \textbf{not necessarily stable} and we may have to adjust them! % -% \section{Additions to \pkg{l3basics}} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\cs_log:N, \cs_log:c} -% \begin{syntax} -% \cs{cs_log:N} \meta{control sequence} -% \end{syntax} -% Writes the definition of the \meta{control sequence} in the log -% file. See also \cs{cs_show:N} which displays the result in the -% terminal. -% \end{function} -% -% \begin{function}[updated = 2015-08-03] -% {\__kernel_register_log:N, \__kernel_register_log:c} -% \begin{syntax} -% \cs{__kernel_register_log:N} \meta{register} -% \end{syntax} -% Used to write the contents of a \TeX{} register to the log file in a -% form similar to \cs{__kernel_register_show:N}. -% \end{function} -% % \section{Additions to \pkg{l3box}} % % \subsection{Affine transformations} @@ -287,22 +267,6 @@ % % \section{Additions to \pkg{l3clist}} % -% \begin{function}[added = 2014-08-22]{\clist_log:N, \clist_log:c} -% \begin{syntax} -% \cs{clist_log:N} \meta{comma list} -% \end{syntax} -% Writes the entries in the \meta{comma list} in the log file. See -% also \cs{clist_show:N} which displays the result in the terminal. -% \end{function} -% -% \begin{function}[added = 2014-08-22]{\clist_log:n} -% \begin{syntax} -% \cs{clist_log:n} \Arg{tokens} -% \end{syntax} -% Writes the entries in the comma list in the log file. See also -% \cs{clist_show:n} which displays the result in the terminal. -% \end{function} -% % \begin{function}[EXP, added = 2016-12-06] % {\clist_rand_item:N, \clist_rand_item:n, \clist_rand_item:c} % \begin{syntax} @@ -349,18 +313,6 @@ % respectively. The two scale factors should be given as real numbers. % \end{function} % -% \begin{function}[added = 2014-08-22] -% {\coffin_log_structure:N, \coffin_log_structure:c} -% \begin{syntax} -% \cs{coffin_log_structure:N} \meta{coffin} -% \end{syntax} -% This function writes the structural information about the -% \meta{coffin} in the log file. The width, height and depth of the -% typeset material are given, along with the location of all of the -% poles of the coffin. See also \cs{coffin_show_structure:N} which -% displays the result in the terminal. -% \end{function} -% % \section{Additions to \pkg{l3file}} % % \begin{function}[TF, added = 2014-07-02]{\file_if_exist_input:n} @@ -469,35 +421,8 @@ % open stream: intended for tracking down problems. % \end{function} % -% \section{Additions to \pkg{l3fp}} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07] -% {\fp_log:N, \fp_log:c, \fp_log:n} -% \begin{syntax} -% \cs{fp_log:N} \meta{fp~var} -% \cs{fp_log:n} \Arg{floating point expression} -% \end{syntax} -% Evaluates the \meta{floating point expression} and writes the -% result in the log file. -% \end{function} -% % \section{Additions to \pkg{l3int}} % -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\int_log:N, \int_log:c} -% \begin{syntax} -% \cs{int_log:N} \meta{integer} -% \end{syntax} -% Writes the value of the \meta{integer} in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\int_log:n} -% \begin{syntax} -% \cs{int_log:n} \Arg{integer expression} -% \end{syntax} -% Writes the result of evaluating the \meta{integer expression} -% in the log file. -% \end{function} -% % \begin{function}[EXP, added = 2016-12-06]{\int_rand:nn} % \begin{syntax} % \cs{int_rand:nn} \Arg{intexpr_1} \Arg{intexpr_2} @@ -507,16 +432,6 @@ % is only available in \pdfTeX{} and \LuaTeX{}. % \end{function} % -% \section{Additions to \pkg{l3keys}} -% -% \begin{function}[added = 2014-08-22]{\keys_log:nn} -% \begin{syntax} -% \cs{keys_log:nn} \Arg{module} \Arg{key} -% \end{syntax} -% Writes in the log file the function which is used to actually -% implement a \meta{key} for a \meta{module}. -% \end{function} -% % \section{Additions to \pkg{l3msg}} % % In very rare cases it may be necessary to produce errors in an @@ -635,21 +550,6 @@ % than two \meta{boolean expressions}. % \end{function} % -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\bool_log:N, \bool_log:c} -% \begin{syntax} -% \cs{bool_log:N} \meta{boolean} -% \end{syntax} -% Writes the logical truth of the \meta{boolean} in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\bool_log:n} -% \begin{syntax} -% \cs{bool_log:n} \Arg{boolean expression} -% \end{syntax} -% Writes the logical truth of the \meta{boolean expression} in the log -% file. -% \end{function} -% % \section{Additions to \pkg{l3prop}} % % \begin{function}[EXP]{\prop_count:N, \prop_count:c} @@ -678,13 +578,6 @@ % arguments. For that specific task, \cs{prop_item:Nn} is faster. % \end{function} % -% \begin{function}[added = 2014-08-12]{\prop_log:N, \prop_log:c} -% \begin{syntax} -% \cs{prop_log:N} \meta{property list} -% \end{syntax} -% Writes the entries in the \meta{property list} in the log file. -% \end{function} -% % \begin{function}[EXP, added = 2016-12-06] % {\prop_rand_key_value:N, \prop_rand_key_value:c} % \begin{syntax} @@ -755,13 +648,6 @@ % \end{texnote} % \end{function} % -% \begin{function}[added = 2014-08-12]{\seq_log:N, \seq_log:c} -% \begin{syntax} -% \cs{seq_log:N} \meta{sequence} -% \end{syntax} -% Writes the entries in the \meta{sequence} in the log file. -% \end{function} -% % \begin{function}[EXP, added = 2016-12-06]{\seq_rand_item:N, \seq_rand_item:c} % \begin{syntax} % \cs{seq_rand_item:N} \meta{seq~var} @@ -793,51 +679,6 @@ % warning message of some sort. % \end{function} % -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\dim_log:N, \dim_log:c} -% \begin{syntax} -% \cs{dim_log:N} \meta{dimension} -% \end{syntax} -% Writes the value of the \meta{dimension} in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\dim_log:n} -% \begin{syntax} -% \cs{dim_log:n} \Arg{dimension expression} -% \end{syntax} -% Writes the result of evaluating the \meta{dimension expression} -% in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\skip_log:N, \skip_log:c} -% \begin{syntax} -% \cs{skip_log:N} \meta{skip} -% \end{syntax} -% Writes the value of the \meta{skip} in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\skip_log:n} -% \begin{syntax} -% \cs{skip_log:n} \Arg{skip expression} -% \end{syntax} -% Writes the result of evaluating the \meta{skip expression} -% in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\muskip_log:N, \muskip_log:c} -% \begin{syntax} -% \cs{muskip_log:N} \meta{muskip} -% \end{syntax} -% Writes the value of the \meta{muskip} in the log file. -% \end{function} -% -% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\muskip_log:n} -% \begin{syntax} -% \cs{muskip_log:n} \Arg{muskip expression} -% \end{syntax} -% Writes the result of evaluating the \meta{muskip expression} -% in the log file. -% \end{function} -% % \section{Additions to \pkg{l3tl}} % % \begin{function}[EXP,pTF]{\tl_if_single_token:n} @@ -1103,22 +944,6 @@ % argument. % \end{function} % -% \begin{function}[added = 2014-08-22, updated = 2015-08-01]{\tl_log:N, \tl_log:c} -% \begin{syntax} -% \cs{tl_log:N} \meta{tl~var} -% \end{syntax} -% Writes the content of the \meta{tl~var} in the log file. See also -% \cs{tl_show:N} which displays the result in the terminal. -% \end{function} -% -% \begin{function}[added = 2014-08-22]{\tl_log:n} -% \begin{syntax} -% \cs{tl_log:n} \Arg{token list} -% \end{syntax} -% Writes the \meta{token list} in the log file. See also -% \cs{tl_show:n} which displays the result in the terminal. -% \end{function} -% % \begin{function}[EXP, added = 2016-12-06] % {\tl_rand_item:N, \tl_rand_item:c, \tl_rand_item:n} % \begin{syntax} @@ -1136,6 +961,41 @@ % \end{texnote} % \end{function} % +% \begin{function}[EXP, added = 2017-02-17] +% {\tl_range:Nnn, \tl_range:cnn, \tl_range:nnn} +% \begin{syntax} +% \cs{tl_range:Nnn} \meta{tl~var} \Arg{start index} \Arg{end index} +% \cs{tl_range:nnn} \Arg{token list} \Arg{start index} \Arg{end index} +% \end{syntax} +% Leaves in the input stream the items from the \meta{start index} to the +% \meta{end index} inclusive. Positive \meta{indices} are counted +% from the start of the \meta{token list}, $1$~being the first item, and +% negative \meta{indices} are counted from the end of the token list, +% $-1$~being the last item. If either of \meta{start index} or +% \meta{end index} is~$0$, the result is empty. For instance, +% \begin{verbatim} +% \iow_term:x { \tl_range:nnn { abcdef } { 2 } { 5 } } +% \iow_term:x { \tl_range:nnn { abcdef } { -4 } { -1 } } +% \iow_term:x { \tl_range:nnn { abcdef } { -2 } { -1 } } +% \iow_term:x { \tl_range:nnn { abcdef } { 0 } { -1 } } +% \end{verbatim} +% will print \texttt{{b}{c}{d}{e}}, \texttt{{c}{d}{e}{f}}, \texttt{{e}{f}}, and an empty +% line to the terminal. The \meta{start index} must always be smaller than +% or equal to the \meta{end index}: if this is not the case then no output +% is generated. Thus +% \begin{verbatim} +% \iow_term:x { \tl_range:nnn { abcdef } { 5 } { 2 } } +% \iow_term:x { \tl_range:nnn { abcdef } { -1 } { -4 } } +% \end{verbatim} +% both yield empty token lists. +% \begin{texnote} +% The result is returned within the \tn{unexpanded} +% primitive (\cs{exp_not:n}), which means that the \meta{item} +% will not expand further when appearing in an \texttt{x}-type +% argument expansion. +% \end{texnote} +% \end{function} +% % \section{Additions to \pkg{l3tokens}} % % \begin{function}[TF, updated = 2012-12-20]{\peek_N_type:} @@ -1168,35 +1028,6 @@ %<*initex|package> % \end{macrocode} % -% \subsection{Additions to \pkg{l3basics}} -% -% \begin{macrocode} -%<@@=cs> -% \end{macrocode} -% -% \begin{macro}{\cs_log:N, \cs_log:c} -% Use \cs{cs_show:N} or \cs{cs_show:c} after calling -% \cs{__msg_log_next:} to redirect their output to the log file only. -% Note that \cs{cs_log:c} is not just a variant of \cs{cs_log:N} as -% the csname should be turned to a control sequence within a group -% (see \cs{cs_show:c}). -% \begin{macrocode} -\cs_new_protected:Npn \cs_log:N - { \__msg_log_next: \cs_show:N } -\cs_new_protected:Npn \cs_log:c - { \__msg_log_next: \cs_show:c } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\__kernel_register_log:N, \__kernel_register_log:c} -% Redirect the output of \cs{__kernel_register_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \__kernel_register_log:N - { \__msg_log_next: \__kernel_register_show:N } -\cs_generate_variant:Nn \__kernel_register_log:N { c } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3box}} % % \begin{macrocode} @@ -1849,17 +1680,6 @@ %<@@=clist> % \end{macrocode} % -% \begin{macro}{\clist_log:N, \clist_log:c, \clist_log:n} -% Redirect output of \cs{clist_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \clist_log:N - { \__msg_log_next: \clist_show:N } -\cs_new_protected:Npn \clist_log:n - { \__msg_log_next: \clist_show:n } -\cs_generate_variant:Nn \clist_log:N { c } -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\clist_rand_item:n, \clist_rand_item:N, \clist_rand_item:c} % \begin{macro}[aux]{\@@_rand_item:nn} % The |N|-type function is not implemented through the |n|-type @@ -1874,7 +1694,7 @@ { \exp_args:Nf \@@_rand_item:nn { \clist_count:n {#1} } {#1} } \cs_new:Npn \@@_rand_item:nn #1#2 { - \int_compare:nNnF {#1} = \c_zero + \int_compare:nNnF {#1} = 0 { \clist_item:nn {#2} { \int_rand:nn { 1 } {#1} } } } \cs_new:Npn \clist_rand_item:N #1 @@ -2347,17 +2167,6 @@ % \end{macro} % \end{macro} % -% \subsection{Coffin diagnostics} -% -% \begin{macro}{\coffin_log_structure:N, \coffin_log_structure:c} -% Redirect output of \cs{coffin_show_structure:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \coffin_log_structure:N - { \__msg_log_next: \coffin_show_structure:N } -\cs_generate_variant:Nn \coffin_log_structure:N { c } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3file}} % % \begin{macrocode} @@ -2477,49 +2286,12 @@ % \end{macrocode} % \end{macro} % -% \subsection{Additions to \pkg{l3fp-assign}} -% -% \begin{macrocode} -%<@@=fp> -% \end{macrocode} -% -% \begin{macro}{\fp_log:N, \fp_log:c, \fp_log:n} -% Redirect output of \cs{fp_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \fp_log:N - { \__msg_log_next: \fp_show:N } -\cs_new_protected:Npn \fp_log:n - { \__msg_log_next: \fp_show:n } -\cs_generate_variant:Nn \fp_log:N { c } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3int}} % % \begin{macrocode} %<@@=int> % \end{macrocode} % -% \begin{macro}{\int_log:N, \int_log:c} -% Redirect output of \cs{int_show:N} to the log. This is not just a -% copy of \cs{__kernel_register_log:N} because of subtleties -% involving \tn{currentgrouplevel} and \tn{currentgrouptype}. See -% \cs{int_show:N} for details. -% \begin{macrocode} -\cs_new_protected:Npn \int_log:N - { \__msg_log_next: \int_show:N } -\cs_generate_variant:Nn \int_log:N { c } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\int_log:n} -% Redirect output of \cs{int_show:n} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \int_log:n - { \__msg_log_next: \int_show:n } -% \end{macrocode} -% \end{macro} -% % \begin{macro}[EXP]{\int_rand:nn} % \begin{macro}[aux, EXP] % { @@ -2556,12 +2328,12 @@ \@@_rand:ww #2; #1; } { - \int_compare:nNnTF {#1} > \c_zero + \int_compare:nNnTF {#1} > 0 { \int_compare:nNnTF { #2 - #1 } < \c__fp_rand_size_int } { \int_compare:nNnTF {#2} < { #1 + \c__fp_rand_size_int } } { \exp_args:Nf \@@_rand_narrow:nn - { \int_eval:n { #2 - #1 + \c_one } } {#1} + { \int_eval:n { #2 - #1 + 1 } } {#1} } { \fp_to_int:n { randint(#1,#2) } } } @@ -2603,20 +2375,6 @@ } % \end{macrocode} % -% \subsection{Additions to \pkg{l3keys}} -% -% \begin{macrocode} -%<@@=keys> -% \end{macrocode} -% -% \begin{macro}{\keys_log:nn} -% Redirect output of \cs{keys_show:nn} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \keys_log:nn - { \__msg_log_next: \keys_show:nn } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3msg}} % % \begin{macrocode} @@ -2737,17 +2495,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\bool_log:N, \bool_log:c, \bool_log:n} -% Redirect output of \cs{bool_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \bool_log:N - { \__msg_log_next: \bool_show:N } -\cs_new_protected:Npn \bool_log:n - { \__msg_log_next: \bool_show:n } -\cs_generate_variant:Nn \bool_log:N { c } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3prop}} % % \begin{macrocode} @@ -2765,11 +2512,11 @@ { \int_eval:n { - \c_zero + 0 \prop_map_function:NN #1 \@@_count:nn } } -\cs_new:Npn \@@_count:nn #1#2 { + \c_one } +\cs_new:Npn \@@_count:nn #1#2 { + 1 } \cs_generate_variant:Nn \prop_count:N { c } % \end{macrocode} % \end{macro} @@ -2804,15 +2551,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\prop_log:N, \prop_log:c} -% Redirect output of \cs{prop_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \prop_log:N - { \__msg_log_next: \prop_show:N } -\cs_generate_variant:Nn \prop_log:N { c } -% \end{macrocode} -% \end{macro} -% % \begin{macro}[EXP] % {\prop_rand_key_value:N, \prop_rand_key_value:c} % \begin{macro}[aux, EXP]{\@@_rand:NN, \@@_rand_item:Nw} @@ -2836,10 +2574,10 @@ } \cs_new:Npn \@@_rand_item:Nw #1#2 \s_@@ \@@_pair:wn #3 \s_@@ #4 { - \int_compare:nNnF {#2} > \c_one + \int_compare:nNnF {#2} > 1 { \use_i_delimit_by_q_stop:nw { #1 {#3} \exp_not:n {#4} } } \exp_after:wN \@@_rand_item:Nw \exp_after:wN #1 - \__int_value:w \int_eval:n { #2 - \c_one } \s_@@ + \__int_value:w \int_eval:n { #2 - 1 } \s_@@ } \cs_generate_variant:Nn \prop_rand_key_value:N { c } % \end{macrocode} @@ -2944,15 +2682,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\seq_log:N, \seq_log:c} -% Redirect output of \cs{seq_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \seq_log:N - { \__msg_log_next: \seq_show:N } -\cs_generate_variant:Nn \seq_log:N { c } -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\seq_rand_item:N, \seq_rand_item:c} % Importantly, \cs{seq_item:Nn} only evaluates its argument once. % \begin{macrocode} @@ -2995,36 +2724,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\dim_log:N, \dim_log:c, \dim_log:n} -% Diagnostics. Redirect output of \cs{dim_show:n} to the log. -% \begin{macrocode} -\cs_new_eq:NN \dim_log:N \__kernel_register_log:N -\cs_new_eq:NN \dim_log:c \__kernel_register_log:c -\cs_new_protected:Npn \dim_log:n - { \__msg_log_next: \dim_show:n } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\skip_log:N, \skip_log:c, \skip_log:n} -% Diagnostics. Redirect output of \cs{skip_show:n} to the log. -% \begin{macrocode} -\cs_new_eq:NN \skip_log:N \__kernel_register_log:N -\cs_new_eq:NN \skip_log:c \__kernel_register_log:c -\cs_new_protected:Npn \skip_log:n - { \__msg_log_next: \skip_show:n } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\muskip_log:N, \muskip_log:c, \muskip_log:n} -% Diagnostics. Redirect output of \cs{muskip_show:n} to the log. -% \begin{macrocode} -\cs_new_eq:NN \muskip_log:N \__kernel_register_log:N -\cs_new_eq:NN \muskip_log:c \__kernel_register_log:c -\cs_new_protected:Npn \muskip_log:n - { \__msg_log_next: \muskip_show:n } -% \end{macrocode} -% \end{macro} -% % \subsection{Additions to \pkg{l3tl}} % % \begin{macrocode} @@ -3640,11 +3339,11 @@ { \token_if_expandable:NTF #1 { - \bool_if:nTF + \bool_lazy_any:nTF { - \token_if_protected_macro_p:N #1 - || \token_if_protected_long_macro_p:N #1 - || \token_if_eq_meaning_p:NN \q_recursion_tail #1 + { \token_if_eq_meaning_p:NN \q_recursion_tail #1 } + { \token_if_protected_macro_p:N #1 } + { \token_if_protected_long_macro_p:N #1 } } { \use_ii:nn } { \use_i:nn } @@ -3786,11 +3485,9 @@ #2 \q_recursion_stop } { - \bool_if:nTF - { - \token_if_cs_p:N #1 - || ! ( \int_compare_p:nNn { `#1 } = { "0307 } ) - } + \bool_lazy_or:nnTF + { \token_if_cs_p:N #1 } + { ! \int_compare_p:nNn { `#1 } = { "0307 } } { \@@_change_case_output:Vwn \c__unicode_dotless_i_tl } { \@@_change_case_output:nwn { i } @@ -3923,15 +3620,15 @@ #3 \q_recursion_stop } { - \bool_if:nT + \bool_lazy_and:nnT + { ! \token_if_cs_p:N #2 } { - ! \token_if_cs_p:N #2 - && - ( - \int_compare_p:nNn { `#2 } = { "0300 } - || \int_compare_p:nNn { `#2 } = { "0301 } - || \int_compare_p:nNn { `#2 } = { "0303 } - ) + \bool_lazy_any_p:n + { + { \int_compare_p:nNn { `#2 } = { "0300 } } + { \int_compare_p:nNn { `#2 } = { "0301 } } + { \int_compare_p:nNn { `#2 } = { "0303 } } + } } { \@@_change_case_output:Vwn \c__unicode_dot_above_tl } #1 #2#3 \q_recursion_stop @@ -3978,11 +3675,9 @@ #3 \q_recursion_stop } { - \bool_if:nTF - { - ! \token_if_cs_p:N #2 - && \int_compare_p:nNn { `#2 } = { "0307 } - } + \bool_lazy_and:nnTF + { ! \token_if_cs_p:N #2 } + { \int_compare_p:nNn { `#2 } = { "0307 } } { #1 } { #1 #2 } #3 \q_recursion_stop @@ -4559,11 +4254,9 @@ % \begin{macrocode} \cs_new:Npn \@@_change_case_mixed_nl:Nnw #1 { - \bool_if:nTF - { - \int_compare_p:nNn { `#1 } = { `i } - || \int_compare_p:nNn { `#1 } = { `I } - } + \bool_lazy_or:nnTF + { \int_compare_p:nNn { `#1 } = { `i } } + { \int_compare_p:nNn { `#1 } = { `I } } { \@@_change_case_output:nwn { I } \@@_change_case_mixed_nl:Nw @@ -4583,14 +4276,12 @@ #3 \q_recursion_stop } { - \bool_if:nTF + \bool_lazy_and:nnTF + { ! ( \token_if_cs_p:N #2 ) } { - ! ( \token_if_cs_p:N #2 ) - && - ( - \int_compare_p:nNn { `#2 } = { `j } - || \int_compare_p:nNn { `#2 } = { `J } - ) + \bool_lazy_or_p:nn + { \int_compare_p:nNn { `#2 } = { `j } } + { \int_compare_p:nNn { `#2 } = { `J } } } { \@@_change_case_output:nwn { J } @@ -4644,23 +4335,7 @@ % \end{macrocode} % \end{variable} % -% -% \begin{macro}{\tl_log:N, \tl_log:c} -% Redirect output of \cs{tl_show:N} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \tl_log:N - { \__msg_log_next: \tl_show:N } -\cs_generate_variant:Nn \tl_log:N { c } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\tl_log:n} -% Redirect output of \cs{tl_show:n} to the log. -% \begin{macrocode} -\cs_new_protected:Npn \tl_log:n - { \__msg_log_next: \tl_show:n } -% \end{macrocode} -% \end{macro} +% \subsubsection{Other additions to \pkg{l3tl}} % % \begin{macro}{\tl_rand_item:n, \tl_rand_item:N, \tl_rand_item:c} % Importantly \cs{tl_item:nn} only evaluates its argument once. @@ -4675,6 +4350,105 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\tl_range:Nnn, \tl_range:cnn, \tl_range:nnn} +% \begin{macro}[aux] +% {\@@_range:nnnw, \@@_range:nnw, \@@_range_normalize:nn, \@@_range_collect:w, \@@_range_skip:w} +% To avoid checking for the end of the token list at every step, start +% by counting the number $l$ of items and \enquote{normalizing} the +% bounds, namely clamping them to the interval $[0,l]$ and dealing +% with negative indices. More precisely, \cs{@@_range:nnw} receives +% the number of items to skip at the beginning of the token list, and +% the index of the last item to keep. If nothing should be kept, +% leave |{}|: this stops the \texttt{f}-expansion of \cs{tl_head:f} +% and that function produces an empty result. Otherwise, repeatedly +% call \cs{@@_range_skip:w} to delete |#1| items from the input stream +% (the extra brace group avoids an off-by-one mistake), then +% repeatedly call \cs{@@_range_collect:w} to store in its second +% argument the items to be kept. Eventually, the result is a brace +% group followed by the rest of the token list, and \cs{tl_head:f} +% cleans up and gives the result in \cs{exp_not:n}. +% \begin{macrocode} +\cs_new:Npn \tl_range:Nnn { \exp_args:No \tl_range:nnn } +\cs_generate_variant:Nn \tl_range:Nnn { c } +\cs_new:Npn \tl_range:nnn #1#2#3 + { + \tl_head:f + { + \exp_args:Nf \@@_range:nnnw { \tl_count:n {#1} } {#2} {#3} + #1 + } + } +\cs_new:Npn \@@_range:nnnw #1#2#3 + { + \exp_args:Nff \@@_range:nnw + { + \exp_args:Nf \@@_range_normalize:nn + { \int_eval:n { #2 - 1 } } {#1} + } + { + \exp_args:Nf \@@_range_normalize:nn + { \int_eval:n {#3} } {#1} + } + } +\cs_new:Npn \@@_range:nnw #1#2 + { + \if_int_compare:w #2 > #1 \exp_stop_f: \else: + \exp_after:wN { \exp_after:wN } + \fi: + \exp_after:wN \@@_range_collect:w + \__int_value:w \__int_eval:w #2 - #1 \exp_after:wN ; + \exp_after:wN { \exp_after:wN } + \exp:w \@@_range_skip:w #1 ; { } + } +\cs_new:Npn \@@_range_skip:w #1 ; #2 + { + \if_int_compare:w #1 > 0 \exp_stop_f: + \exp_after:wN \@@_range_skip:w + \__int_value:w \__int_eval:w #1 - 1 \exp_after:wN ; + \else: + \exp_after:wN \exp_end: + \fi: + } +\cs_new:Npn \@@_range_collect:w #1 ; #2#3 + { + \if_int_compare:w #1 > 1 \exp_stop_f: + \exp_after:wN \@@_range_collect:w + \__int_value:w \__int_eval:w #1 - 1 \exp_after:wN ; + \fi: + { #2 {#3} } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}[EXP, aux]{\@@_range_normalize:nn} +% This function converts an \meta{index} argument into an explicit +% position in the token list (a result of $0$ denoting \enquote{out of +% bounds}). Expects two explicit integer arguments: the \meta{index} +% |#1| and the string count~|#2|. If |#1| is negative, replace it by +% $|#1| + |#2| + 1$, then limit to the range $[0, |#2|]$. +% \begin{macrocode} +\cs_new:Npn \@@_range_normalize:nn #1#2 + { + \int_eval:n + { + \if_int_compare:w #1 < 0 \exp_stop_f: + \if_int_compare:w #1 < -#2 \exp_stop_f: + 0 + \else: + #1 + #2 + 1 + \fi: + \else: + \if_int_compare:w #1 < #2 \exp_stop_f: + #1 + \else: + #2 + \fi: + \fi: + } + } +% \end{macrocode} +% \end{macro} +% % \subsection{Additions to \pkg{l3tokens}} % % \begin{macrocode} @@ -4713,10 +4487,10 @@ \cs_new_protected:Npn \@@_execute_branches_N_type: { \if_int_odd:w - \if_catcode:w \exp_not:N \l_peek_token { \c_two \fi: - \if_catcode:w \exp_not:N \l_peek_token } \c_two \fi: - \if_meaning:w \l_peek_token \c_space_token \c_two \fi: - \c_one + \if_catcode:w \exp_not:N \l_peek_token { 0 \exp_stop_f: \fi: + \if_catcode:w \exp_not:N \l_peek_token } 0 \exp_stop_f: \fi: + \if_meaning:w \l_peek_token \c_space_token 0 \exp_stop_f: \fi: + 1 \exp_stop_f: \exp_after:wN \@@_N_type:w \token_to_meaning:N \l_peek_token \q_mark \@@_N_type_aux:nnw diff --git a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx index 12aea777839..f85046e2a98 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3clist.dtx @@ -26,7 +26,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3clist.dtx 6842 2017-02-06 21:51:22Z joseph $ +\GetIdInfo$Id: l3clist.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Comma separated lists} %</driver|package> %<*driver> @@ -677,6 +677,22 @@ % Displays the entries in the comma list in the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\clist_log:N, \clist_log:c} +% \begin{syntax} +% \cs{clist_log:N} \meta{comma list} +% \end{syntax} +% Writes the entries in the \meta{comma list} in the log file. See +% also \cs{clist_show:N} which displays the result in the terminal. +% \end{function} +% +% \begin{function}[added = 2014-08-22]{\clist_log:n} +% \begin{syntax} +% \cs{clist_log:n} \Arg{tokens} +% \end{syntax} +% Writes the entries in the comma list in the log file. See also +% \cs{clist_show:n} which displays the result in the terminal. +% \end{function} +% % \section{Constant and scratch comma lists} % % \begin{variable}[added = 2012-07-02]{\c_empty_clist} @@ -1641,11 +1657,11 @@ #1 \exp_not:n { , \q_recursion_tail , \q_recursion_stop } } } -\cs_new:Npn \@@_count:n #1 { + \c_one } +\cs_new:Npn \@@_count:n #1 { + 1 } \cs_new:Npx \@@_count:w #1 , { \exp_not:n { \exp_args:Nf \quark_if_recursion_tail_stop:n } {#1} - \exp_not:N \tl_if_blank:nF {#1} { + \c_one } + \exp_not:N \tl_if_blank:nF {#1} { + 1 } \exp_not:N \@@_count:w \c_space_tl } % \end{macrocode} @@ -1743,11 +1759,11 @@ } \cs_new:Npn \@@_item:nnnN #1#2#3#4 { - \int_compare:nNnTF {#2} < \c_zero + \int_compare:nNnTF {#2} < 0 { \int_compare:nNnTF {#2} < { - #1 } { \use_none_delimit_by_q_stop:w } - { \exp_args:Nf #4 { \int_eval:n { #2 + \c_one + #1 } } } + { \exp_args:Nf #4 { \int_eval:n { #2 + 1 + #1 } } } } { \int_compare:nNnTF {#2} > {#1} @@ -1759,7 +1775,7 @@ \cs_generate_variant:Nn \@@_item:nnnN { ffo, ff } \cs_new:Npn \@@_item_N_loop:nw #1 #2, { - \int_compare:nNnTF {#1} = \c_zero + \int_compare:nNnTF {#1} = 0 { \use_i_delimit_by_q_stop:nw { \exp_not:n {#2} } } { \exp_args:Nf \@@_item_N_loop:nw { \int_eval:n { #1 - 1 } } } } @@ -1795,7 +1811,7 @@ \exp_args:No \tl_if_blank:nTF {#2} { \@@_item_n_loop:nw {#1} \prg_do_nothing: } { - \int_compare:nNnTF {#1} = \c_zero + \int_compare:nNnTF {#1} = 0 { \exp_args:No \@@_item_n_end:n {#2} } { \exp_args:Nf \@@_item_n_loop:nw @@ -1842,6 +1858,17 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\clist_log:N, \clist_log:c, \clist_log:n} +% Redirect output of \cs{clist_show:N} and \cs{clist_show:n} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \clist_log:N + { \__msg_log_next: \clist_show:N } +\cs_new_protected:Npn \clist_log:n + { \__msg_log_next: \clist_show:n } +\cs_generate_variant:Nn \clist_log:N { c } +% \end{macrocode} +% \end{macro} +% % \subsection{Scratch comma lists} % % \begin{variable}{\l_tmpa_clist, \l_tmpb_clist} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx index 848eeefaa71..2cdab0d37ad 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3coffins.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3coffins.dtx Copyright(C) 2010-2016 The LaTeX3 Project +%% File: l3coffins.dtx Copyright(C) 2010-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3coffins.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3coffins.dtx 6906 2017-02-12 20:07:58Z bruno $ {L3 Coffin code layer} %</driver|package> %<*driver> @@ -309,6 +309,16 @@ % direction of the pole. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-01] +% {\coffin_log_structure:N, \coffin_log_structure:c} +% \begin{syntax} +% \cs{coffin_log_structure:N} \meta{coffin} +% \end{syntax} +% This function writes the structural information about the +% \meta{coffin} in the log file. See also \cs{coffin_show_structure:N} +% which displays the result in the terminal. +% \end{function} +% % \subsection{Constants and variables} % % \begin{variable}{\c_empty_coffin} @@ -1679,6 +1689,15 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\coffin_log_structure:N, \coffin_log_structure:c} +% Redirect output of \cs{coffin_show_structure:N} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \coffin_log_structure:N + { \__msg_log_next: \coffin_show_structure:N } +\cs_generate_variant:Nn \coffin_log_structure:N { c } +% \end{macrocode} +% \end{macro} +% % \subsection{Messages} % % \begin{macrocode} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx b/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx new file mode 100644 index 00000000000..01c880e3d50 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3deprecation.dtx @@ -0,0 +1,161 @@ +% \iffalse meta-comment +% +%% File: l3deprecation.dtx (C) Copyright 2017 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 development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full]{l3doc} +%</driver> +%<*driver|package> +\GetIdInfo$Id: l3deprecation.dtx 6966 2017-02-20 03:39:43Z bruno $ + {L3 Deprecation errors} +%</driver|package> +%<*driver> +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \pkg{l3deprecation} package\\ Deprecation errors^^A +% \thanks{This file describes v\ExplFileVersion, +% last revised \ExplFileDate.}^^A +% } +% +% \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} +% +% \section{\pkg{l3deprecation} documentation} +% +% A few commands have had to be deprecated over the years. This module +% defines deprecated and deleted commands to produce an error. +% +% \begin{macro}{\deprecation_error:} +% \begin{syntax} +% \cs{deprecation_error:} +% \end{syntax} +% Defines commands that will soon become deprecated to produce errors. +% \end{macro} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3deprecation} implementation} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% \begin{macrocode} +%<@@=deprecation> +% \end{macrocode} +% +% \begin{macro}[aux]{\@@_error:Nnn} +% The \tn{outer} definition here ensures the command will not appear +% in an argument. Use this auxiliary on all commands that have been +% removed since 2015. +% \begin{macrocode} +\cs_new_protected:Npn \@@_error:Nnn #1#2#3 + { + \etex_protected:D \tex_outer:D \tex_edef:D #1 + { + \exp_not:N \__msg_kernel_expandable_error:nnnnn + { kernel } { deprecated-command } + { \tl_to_str:n {#3} } { \token_to_str:N #1 } { \tl_to_str:n {#2} } + \exp_not:N \__msg_kernel_error:nnxxx + { kernel } { deprecated-command } + { \tl_to_str:n {#3} } { \token_to_str:N #1 } { \tl_to_str:n {#2} } + } + } +\@@_error:Nnn \c_job_name_tl { \c_sys_jobname_str } { 2017-01-01 } +\@@_error:Nnn \dim_case:nnn { \dim_case:nnF } { 2015-07-14 } +\@@_error:Nnn \int_case:nnn { \int_case:nnF } { 2015-07-14 } +\@@_error:Nnn \int_from_binary:n { \int_from_bin:n } { 2016-01-05 } +\@@_error:Nnn \int_from_hexadecimal:n { \int_from_hex:n } { 2016-01-05 } +\@@_error:Nnn \int_from_octal:n { \int_from_oct:n } { 2016-01-05 } +\@@_error:Nnn \int_to_binary:n { \int_to_bin:n } { 2016-01-05 } +\@@_error:Nnn \int_to_hexadecimal:n { \int_to_hex:n } { 2016-01-05 } +\@@_error:Nnn \int_to_octal:n { \int_to_oct:n } { 2016-01-05 } +\@@_error:Nnn \luatex_if_engine_p: { \sys_if_engine_luatex_p: } { 2017-01-01 } +\@@_error:Nnn \luatex_if_engine:F { \sys_if_engine_luatex:F } { 2017-01-01 } +\@@_error:Nnn \luatex_if_engine:T { \sys_if_engine_luatex:T } { 2017-01-01 } +\@@_error:Nnn \luatex_if_engine:TF { \sys_if_engine_luatex:TF } { 2017-01-01 } +\@@_error:Nnn \pdftex_if_engine_p: { \sys_if_engine_pdftex_p: } { 2017-01-01 } +\@@_error:Nnn \pdftex_if_engine:F { \sys_if_engine_pdftex:F } { 2017-01-01 } +\@@_error:Nnn \pdftex_if_engine:T { \sys_if_engine_pdftex:T } { 2017-01-01 } +\@@_error:Nnn \pdftex_if_engine:TF { \sys_if_engine_pdftex:TF } { 2017-01-01 } +\@@_error:Nnn \prop_get:cn { \prop_item:cn } { 2016-01-05 } +\@@_error:Nnn \prop_get:Nn { \prop_item:Nn } { 2016-01-05 } +\@@_error:Nnn \quark_if_recursion_tail_break:N { } { 2015-07-14 } +\@@_error:Nnn \quark_if_recursion_tail_break:n { }{ 2015-07-14 } +\@@_error:Nnn \scan_align_safe_stop: { protected~commands } { 2017-01-01 } +\@@_error:Nnn \str_case:nnn { \str_case:nnF } { 2015-07-14 } +\@@_error:Nnn \str_case:onn { \str_case:onF } { 2015-07-14 } +\@@_error:Nnn \str_case_x:nnn { \str_case_x:nnF } { 2015-07-14 } +\@@_error:Nnn \tl_case:cnn { \tl_case:cnF } { 2015-07-14 } +\@@_error:Nnn \tl_case:Nnn { \tl_case:NnF } { 2015-07-14 } +\@@_error:Nnn \xetex_if_engine_p: { \sys_if_engine_xetex_p: } { 2017-01-01 } +\@@_error:Nnn \xetex_if_engine:F { \sys_if_engine_xetex:F } { 2017-01-01 } +\@@_error:Nnn \xetex_if_engine:T { \sys_if_engine_xetex:T } { 2017-01-01 } +\@@_error:Nnn \xetex_if_engine:TF { \sys_if_engine_xetex:TF } { 2017-01-01 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\deprecation_error:} +% Some commands were more recently deprecated and not yet removed; +% only make these into errors if the user requests it. This allows +% testing code even if it relies on other packages: load all other +% packages, call \cs{deprecation_error:}, and load the code that one is +% interested in testing. +% \begin{macrocode} +\cs_new_protected:Npn \deprecation_error: + { + \@@_error:Nnn \tl_to_lowercase:n { } { 2017-12-31 } + \@@_error:Nnn \tl_to_uppercase:n { } { 2017-12-31 } + \@@_error:Nnn \ior_get_str:NN { \ior_str_get:NN } { 2017-12-31 } + \@@_error:Nnn \c_minus_one { - 1 } { 2018-12-31 } + \@@_error:Nnn \sort_ordered: { \sort_return_same: } { 2018-12-31 } + \@@_error:Nnn \sort_reversed: { \sort_return_swapped: } { 2018-12-31 } + \cs_set_eq:NN \deprecation_error: \scan_stop: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx b/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx index c1f0e04c7aa..73c126ed443 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3doc.dtx @@ -62,7 +62,7 @@ Do not distribute a modified version of this file. % %<*driver|class> \RequirePackage{expl3,xparse,calc} -\GetIdInfo$Id: l3doc.dtx 6847 2017-02-07 15:05:44Z bruno $ +\GetIdInfo$Id: l3doc.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Experimental documentation class} %</driver|class> % @@ -1165,6 +1165,9 @@ Do not distribute a modified version of this file. % % \begin{macro}[int, pTF]{\@@_date_compare:nNn} % \begin{macro}[aux]{\@@_date_compare_aux:nnnNnnn, \@@_date_compare_aux:w} +% Expects |#1| and |#3| to be dates in the format YYYY-MM-DD (but +% accepts YYYY or YYYY-MM too). Compares them using |#2| (one of |<|, +% |=|, |>|), filling in zeros for missing data. % \begin{macrocode} \prg_new_conditional:Npnn \@@_date_compare:nNn #1#2#3 { TF , T , F , p } { \@@_date_compare_aux:w #1--- \q_mark #2 #3--- \q_stop } @@ -1232,6 +1235,8 @@ Do not distribute a modified version of this file. } \msg_new:nnn { l3doc } { deprecated-function } { The~deprecated~function(s)~'#1'~should~have~been~removed~on~#2. } +\msg_new:nnn { l3doc } { date-format } + { The~date~'#1'~should~be~given~in~YYYY-MM-DD~format. } % \end{macrocode} % % \subsection{Options and configuration} @@ -2137,8 +2142,8 @@ Do not distribute a modified version of this file. \bool_set_true:N \l_@@_macro_noTF_bool \bool_set_true:N \l_@@_macro_TF_bool } , - added .tl_set:N = \l_@@_date_added_tl , - updated .tl_set:N = \l_@@_date_updated_tl , + added .code:n = { \@@_date_set:Nn \l_@@_date_added_tl {#1} }, + updated .code:n = { \@@_date_set:Nn \l_@@_date_updated_tl {#1} } , deprecated .code:n = { \@@_deprecated_on:n {#1} } , tested .code:n = { } , label .code:n = @@ -2152,7 +2157,22 @@ Do not distribute a modified version of this file. } % \end{macrocode} % +% \begin{macro}[aux]{\@@_date_set:Nn} +% Minimal check that the date is not given in the YYYY/MM/DD format. +% Eventually we should check the input more carefully. +% \begin{macrocode} +\cs_new_protected:Npn \@@_date_set:Nn #1#2 + { + \tl_if_in:nnT {#2} { / } + { \msg_error:nnn { l3doc } { date-format } {#2} } + \tl_set:Nn #1 {#2} + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[aux]{\@@_deprecated_on:n} +% The date comparison function expects two dates in the YYYY-MM-DD +% format (|-|~is not subtraction here). % Complain if a deprecated function should have been removed earlier. % In any case, mark it as internal to suppress the text % \enquote{documented on page \ldots{}}. @@ -2472,11 +2492,9 @@ Do not distribute a modified version of this file. % \begin{macrocode} \cs_new:Npn \@@_typeset_dates: { - \bool_if:nF - { - \tl_if_empty_p:N \l_@@_date_added_tl && - \tl_if_empty_p:N \l_@@_date_updated_tl - } + \bool_lazy_and:nnF + { \tl_if_empty_p:N \l_@@_date_added_tl } + { \tl_if_empty_p:N \l_@@_date_updated_tl } { \midrule } \tl_if_empty:NF \l_@@_date_added_tl { @@ -2638,7 +2656,7 @@ Do not distribute a modified version of this file. \hbox:n { \strut - \int_compare:nNnT \l_@@_macro_int = \c_zero + \int_compare:nNnT \l_@@_macro_int = 0 { \HD@target } } \vskip \int_eval:n { \l_@@_macro_int - 1 } \baselineskip @@ -2967,12 +2985,12 @@ Do not distribute a modified version of this file. % \begin{macrocode} \cs_new_protected:Npn \@@_macro_end_check_tested: { - \bool_if:nT + \bool_lazy_all:nT { - \g_@@_checktest_bool && - ! \l_@@_macro_aux_bool && - ! \l_@@_macro_var_bool && - ! \l_@@_macro_tested_bool + { \g_@@_checktest_bool } + { ! \l_@@_macro_aux_bool } + { ! \l_@@_macro_var_bool } + { ! \l_@@_macro_tested_bool } } { \seq_gput_right:Nx \g_@@_not_tested_seq @@ -3034,11 +3052,9 @@ Do not distribute a modified version of this file. } \cs_new_protected:Npn \@@_print_documented: { - \bool_if:nT - { - ! \l_@@_macro_aux_bool && - ! \l_@@_macro_internal_bool - } + \bool_lazy_or:nnF + { \l_@@_macro_aux_bool } + { \l_@@_macro_internal_bool } { \int_set:Nn \l_@@_tmpa_int { \seq_count:N \g_@@_nested_names_seq } @@ -3512,8 +3528,8 @@ Do not distribute a modified version of this file. % \begin{macrocode} \cs_new_protected:Npn \@@_show_functions_defined: { - \bool_if:nT - { \g_@@_typeset_implementation_bool && \g_@@_checkfunc_bool } + \bool_lazy_and:nnT + { \g_@@_typeset_implementation_bool } { \g_@@_checkfunc_bool } { \iow_term:x { \c_@@_iow_separator_tl \iow_newline: } \iow_open:Nn \g_@@_func_iow { \c_sys_jobname_str .cmds } @@ -4346,8 +4362,8 @@ page_precedence "rnaA" % \c_sixteen, % \c_thirty_two, % \c_hundred_one, -% \c_twohundred_fifty_five, -% \c_twohundred_fifty_six, +% \c_two_hundred_fifty_five, +% \c_two_hundred_fifty_six, % \c_thousand, % \c_ten_thousand, % \c_ten_thousand_one diff --git a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx index 20e53271c95..ca45f93242b 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3drivers.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3drivers.dtx Copyright(C) 2011-2016 The LaTeX3 Project +%% File: l3drivers.dtx Copyright(C) 2011-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3drivers.dtx 6809 2017-01-01 06:33:13Z bruno $ +\GetIdInfo$Id: l3drivers.dtx 6954 2017-02-18 20:26:11Z joseph $ {L3 Experimental drivers} %</driver|package> %<*driver> @@ -420,7 +420,7 @@ % % \subsection{Inserting \TeX{} material} % -% \begin{function}{\__driver_draw_hbox:nnnnnn} +% \begin{function}{\__driver_draw_hbox:Nnnnnnn} % \begin{syntax} % \cs{__driver_draw_hbox:Nnnnnnn} \meta{box} % \Arg{a} \Arg{b} \Arg{c} \Arg{d} \Arg{x} \Arg{y} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx index 2b15d471d7b..db0cfc7e94a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3expan.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3expan.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3expan.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Argument expansion} %</driver|package> %<*driver> @@ -1426,11 +1426,11 @@ %\cs_new_eq:NN \exp:w \tex_romannumeral:D % \end{macrocode} % So to stop the expansion sequence in a controlled way all we need -% to provide is \cs{c_zero} as part of expanded tokens. As this is +% to provide is a constant integer zero as part of expanded tokens. As this is % an integer constant it will immediately stop % \cs{tex_romannumerl:D}'s search for a number. % \begin{macrocode} -%\cs_new_eq:NN \exp_end: \c_zero +%\int_const:Nn \exp_end: { 0 } % \end{macrocode} % (Note that according to our specification all tokens we expand % initiated by \cs{exp:w} are supposed to be expandable (as well as diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx index fee42ad5736..6ea0556fab4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3file.dtx Copyright (C) 1990-2016 The LaTeX3 Project +%% File: l3file.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3file.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3file.dtx 6964 2017-02-20 02:59:41Z bruno $ {L3 File and I/O operations} %</driver|package> %<*driver> @@ -691,9 +691,9 @@ 0 \tl_map_function:NN \l_@@_internal_name_tl \@@_name_sanitize_aux:n } - \c_two + { 2 } } - = \c_zero + = 0 { \tl_remove_all:Nn \l_@@_internal_name_tl { " } \tl_if_in:NnT \l_@@_internal_name_tl { ~ } @@ -714,10 +714,7 @@ } } \cs_new:Npn \@@_name_sanitize_aux:n #1 - { - \token_if_eq_charcode:NNT #1 " - { + \c_one } - } + { \token_if_eq_charcode:NNT #1 " { + 1 } } % \end{macrocode} % \end{macro} % \end{macro} @@ -925,7 +922,7 @@ % but non-existent stream number. Unlike writing, there is no concept % of reading from the log. % \begin{macrocode} -\cs_new_eq:NN \c_term_ior \c_sixteen +\int_const:Nn \c_term_ior { 16 } % \end{macrocode} % \end{variable} % @@ -964,14 +961,14 @@ \prop_new:N \g_@@_streams_prop %<*package> \int_step_inline:nnnn - { \c_zero } - { \c_one } + { 0 } + { 1 } { \cs_if_exist:NTF \normalend { \tex_count:D 38 \scan_stop: } { \tex_count:D 16 \scan_stop: - \cs_if_exist:NT \loccount { - \c_one } + \cs_if_exist:NT \loccount { - 1 } } } { @@ -1100,7 +1097,7 @@ % \begin{macrocode} \cs_new_protected:Npn \ior_close:N #1 { - \int_compare:nT { - \c_one < #1 < \c_sixteen } + \int_compare:nT { -1 < #1 < \c_term_ior } { \tex_closein:D #1 \prop_gremove:NV \g_@@_streams_prop #1 @@ -1147,21 +1144,23 @@ % % \begin{macro}[pTF]{\ior_if_eof:N} % To test if some particular input stream is exhausted the following -% conditional is provided. +% conditional is provided. The primitive test can only deal with +% numbers in the range $[0,15]$ so we catch outliers (they are +% exhausted). % \begin{macrocode} -\prg_new_conditional:Nnn \ior_if_eof:N { p , T , F , TF } +\prg_new_conditional:Npnn \ior_if_eof:N #1 { p , T , F , TF } { \cs_if_exist:NTF #1 { - \if_int_compare:w #1 = \c_sixteen - \prg_return_true: - \else: - \if_eof:w #1 - \prg_return_true: - \else: - \prg_return_false: - \fi: - \fi: + \int_compare:nTF { -1 < #1 < \c_term_ior } + { + \if_eof:w #1 + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + { \prg_return_true: } } { \prg_return_true: } } @@ -1184,7 +1183,7 @@ { \use:x { - \int_set:Nn \tex_endlinechar:D { - \c_one } + \int_set:Nn \tex_endlinechar:D { -1 } \exp_not:n { \etex_readline:D #1 to #2 } \int_set:Nn \tex_endlinechar:D { \int_use:N \tex_endlinechar:D } } @@ -1213,11 +1212,22 @@ % % \begin{variable}{\c_log_iow, \c_term_iow} % Here we allocate two output streams for writing to the transcript -% file only (\cs{c_log_iow}) and to both the terminal and -% transcript file (\cs{c_term_iow}). +% file only (\cs{c_log_iow}) and to both the terminal and transcript +% file (\cs{c_term_iow}). Recent \LuaTeX{} provide $128$ write +% streams; we also use \cs{c_term_iow} as the first non-allowed write +% stream so its value depends on the engine. % \begin{macrocode} -\cs_new_eq:NN \c_log_iow \c_minus_one -\int_const:Nn \c_term_iow { 128 } +\int_const:Nn \c_log_iow { -1 } +\int_const:Nn \c_term_iow + { + \cs_if_exist:NTF \luatex_directlua:D + { + \int_compare:nNnTF \luatex_luatexversion:D > { 80 } + { 128 } + { 16 } + } + { 16 } + } % \end{macrocode} % \end{variable} % @@ -1226,15 +1236,12 @@ % \begin{macrocode} \seq_new:N \g_@@_streams_seq %<*initex> -\seq_set_eq:NN \g_@@_streams_seq \g__ior_streams_seq -\cs_if_exist:NT \luatex_directlua:D +\use:x { - \int_compare:nNnT \luatex_luatexversion:D > { 80 } + \exp_not:n { \seq_gset_split:Nnn \g_@@_streams_seq { } } { - \int_step_inline:nnnn { 16 } { 1 } { 127 } - { - \seq_gput_right:Nn \g_@@_streams_seq {#1} - } + \int_step_function:nnnN { 0 } { 1 } { \c_term_iow } + \prg_do_nothing: } } %</initex> @@ -1255,14 +1262,14 @@ \prop_new:N \g_@@_streams_prop %<*package> \int_step_inline:nnnn - { \c_zero } - { \c_one } + { 0 } + { 1 } { \cs_if_exist:NTF \normalend { \tex_count:D 39 \scan_stop: } { \tex_count:D 17 \scan_stop: - \cs_if_exist:NT \loccount { - \c_one } + \cs_if_exist:NT \loccount { - 1 } } } { @@ -1339,7 +1346,7 @@ % \begin{macrocode} \cs_new_protected:Npn \iow_close:N #1 { - \int_compare:nT { - \c_one < #1 < \c_sixteen } + \int_compare:nT { - \c_log_iow < #1 < \c_term_iow } { \tex_immediate:D \tex_closeout:D #1 \prop_gremove:NV \g_@@_streams_prop #1 @@ -1386,7 +1393,8 @@ % % \subsubsection{Immediate writing} % -% \begin{macro}[aux]{\@@_with:Nnn, \@@_with_aux:nNnn} +% \begin{macro}[int]{\@@_with:Nnn} +% \begin{macro}[aux]{\@@_with_aux:nNnn} % If the integer~|#1| is equal to~|#2|, just leave~|#3| in the input % stream. Otherwise, pass the old value to an auxiliary, which sets % the integer to the new value, runs the code, and restores the @@ -1406,6 +1414,7 @@ } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\iow_now:Nn, \iow_now:Nx, \iow_now:cn, \iow_now:cx} % This routine writes the second argument onto the output stream without @@ -1464,7 +1473,14 @@ % used by the messaging system, but is designed such that it is % available for other uses. % -% \begin{macro}[var, added = 2012-06-24]{\l_iow_line_count_int} +% \begin{macro}{\c_catcode_other_space_tl} +% Create a space with category code $12$: an \enquote{other} space. +% \begin{macrocode} +\tl_const:Nx \c_catcode_other_space_tl { \char_generate:nn { `\ } { 12 } } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\l_iow_line_count_int} % This is the \enquote{raw} number of characters in a line which % can be written to the terminal. % The standard value is the line length typically used by @@ -1473,96 +1489,102 @@ \int_new:N \l_iow_line_count_int \int_set:Nn \l_iow_line_count_int { 78 } % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux]{\l_@@_target_count_int} -% This stores the target line count: the full number of characters -% in a line, minus any part for a leader at the start of each line. +% \begin{variable}{\l_@@_newline_tl} +% The token list inserted to produce a new line, with the +% \meta{run-on text}. % \begin{macrocode} -\int_new:N \l_@@_target_count_int +\tl_new:N \l_@@_newline_tl % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux] -% { -% \l_@@_current_line_int, -% \l_@@_current_word_int, -% \l_@@_current_indentation_int -% } -% These store the number of characters in the line and word currently -% being constructed, and the current indentation, respectively. +% \begin{variable}{\l_@@_line_target_int} +% This stores the target line count: the full number of characters +% in a line, minus any part for a leader at the start of each line. % \begin{macrocode} -\int_new:N \l_@@_current_line_int -\int_new:N \l_@@_current_word_int -\int_new:N \l_@@_current_indentation_int +\int_new:N \l_@@_line_target_int % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux] -% { -% \l_@@_current_line_tl, -% \l_@@_current_word_tl, -% \l_@@_current_indentation_tl -% } -% These hold the current line of text and current word, -% and a number of spaces for indentation, respectively. -% \begin{macrocode} -\tl_new:N \l_@@_current_line_tl -\tl_new:N \l_@@_current_word_tl -\tl_new:N \l_@@_current_indentation_tl +% \begin{macro}[aux]{\@@_set_indent:n} +% \begin{macro}[aux]{\@@_unindent:w} +% \begin{variable}{\l_@@_one_indent_tl, \l_@@_one_indent_int} +% The \texttt{one_indent} variables hold one indentation marker and +% its length. The \cs{@@_unindent:w} auxiliary removes one +% indentation. The function \cs{@@_set_indent:n} (that could possibly +% be public) sets the indentation in a consistent way. We set it to +% four spaces by default. +% \begin{macrocode} +\tl_new:N \l_@@_one_indent_tl +\int_new:N \l_@@_one_indent_int +\cs_new:Npn \@@_unindent:w { } +\cs_new_protected:Npn \@@_set_indent:n #1 + { + \tl_set:Nx \l_@@_one_indent_tl + { \exp_args:No \__str_to_other_fast:n { \tl_to_str:n {#1} } } + \int_set:Nn \l_@@_one_indent_int { \str_count:N \l_@@_one_indent_tl } + \exp_last_unbraced:NNo + \cs_set:Npn \@@_unindent:w \l_@@_one_indent_tl { } + } +\exp_args:Nx \@@_set_indent:n { \prg_replicate:nn { 4 } { ~ } } % \end{macrocode} -%\end{macro} +% \end{variable} +% \end{macro} +% \end{macro} % -% \begin{macro}[aux]{\l_@@_wrap_tl} -% Used for the expansion step before detokenizing, and for the output -% from wrapping text: fully expanded and with lines which are not -% overly long. +% \begin{variable}{\l_@@_indent_tl, \l_@@_indent_int} +% The current indentation (some copies of \cs{l_@@_one_indent_tl}) and +% its number of characters. % \begin{macrocode} -\tl_new:N \l_@@_wrap_tl +\tl_new:N \l_@@_indent_tl +\int_new:N \l_@@_indent_int % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux]{\l_@@_newline_tl} -% The token list inserted to produce the new line, with the -% \meta{run-on text}. +% \begin{variable}{\l_@@_line_tl, \l_@@_line_part_tl} +% These hold the current line of text and a partial line to be added +% to it, respectively. % \begin{macrocode} -\tl_new:N \l_@@_newline_tl +\tl_new:N \l_@@_line_tl +\tl_new:N \l_@@_line_part_tl % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux]{\l_@@_line_start_bool} -% Boolean to avoid adding a space at the beginning of forced newlines, -% and to know when to add the indentation. +% \begin{variable}{\l_@@_line_break_bool} +% Indicates whether the line was broken precisely at a chunk boundary. % \begin{macrocode} -\bool_new:N \l_@@_line_start_bool +\bool_new:N \l_@@_line_break_bool % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}{\c_catcode_other_space_tl} -% Create a space with category code $12$: an \enquote{other} space. +% \begin{variable}{\l_@@_wrap_tl} +% Used for the expansion step before detokenizing, and for the output +% from wrapping text: fully expanded and with lines which are not +% overly long. % \begin{macrocode} -\tl_const:Nx \c_catcode_other_space_tl { \char_generate:nn { `\ } { 12 } } +\tl_new:N \l_@@_wrap_tl % \end{macrocode} -% \end{macro} +% \end{variable} % -% \begin{macro}[aux]{\c_@@_wrap_marker_tl} -% \begin{macro}[aux] +% \begin{variable}{\c_@@_wrap_marker_tl} +% \begin{variable} % { % \c_@@_wrap_end_marker_tl, % \c_@@_wrap_newline_marker_tl, % \c_@@_wrap_indent_marker_tl, % \c_@@_wrap_unindent_marker_tl % } -% Every special action of the wrapping code is preceded by +% Every special action of the wrapping code is starts with % the same recognizable string, \cs{c_@@_wrap_marker_tl}. % Upon seeing that \enquote{word}, the wrapping code reads % one space-delimited argument to know what operation to % perform. The setting of \tn{escapechar} here is not % very important, but makes \cs{c_@@_wrap_marker_tl} look -% nicer. +% marginally nicer. % \begin{macrocode} \group_begin: - \int_set:Nn \tex_escapechar:D { - \c_one } + \int_set:Nn \tex_escapechar:D { -1 } \tl_const:Nx \c_@@_wrap_marker_tl { \tl_to_str:n { \^^I \^^O \^^W \^^_ \^^W \^^R \^^A \^^P } } \group_end: @@ -1571,26 +1593,32 @@ { \tl_const:cx { c_@@_wrap_ #1 _marker_tl } { - \c_catcode_other_space_tl \c_@@_wrap_marker_tl - \c_catcode_other_space_tl #1 \c_catcode_other_space_tl } } % \end{macrocode} -% \end{macro} -% \end{macro} +% \end{variable} +% \end{variable} % % \begin{macro}{\iow_indent:n} -% \begin{macro}[aux]{\@@_indent:n, \@@_indent_error:n} -% We give a (protected) error definition to \cs{iow_indent:n} -% when outside messages. Within wrapped message, it places -% the instruction for increasing the indentation before its -% argument, and the instruction for unindenting afterwards. -% Note that there will be no forced line-break, so the indentation -% only changes when the next line is started. -% \begin{macrocode} +% \begin{macro}[EXP,aux]{\@@_indent:n} +% \begin{macro}[EXP,aux]{\@@_indent_error:n} +% We set \cs{iow_indent:n} to produce an error when outside +% messages. Within wrapped message, it is set to \cs{@@_indent:n} when +% valid and otherwise to \cs{@@_indent_error:n}. The first places the +% instruction for increasing the indentation before its argument, and +% the instruction for unindenting afterwards. The second produces an +% error expandably. Note that there will be no forced line-break, so +% the indentation only changes when the next line is started. +% \begin{macrocode} +\cs_new_protected:Npn \iow_indent:n #1 + { + \__msg_kernel_error:nnnnn { kernel } { iow-indent } + { \iow_wrap:nnnN } { \iow_indent:n } {#1} + #1 + } \cs_new:Npx \@@_indent:n #1 { \c_@@_wrap_indent_marker_tl @@ -1599,36 +1627,28 @@ } \cs_new:Npn \@@_indent_error:n #1 { - \__msg_kernel_expandable_error:nn { kernel } { indent-outside-wrapping-code } + \__msg_kernel_expandable_error:nnnnn { kernel } { iow-indent } + { \iow_wrap:nnnN } { \iow_indent:n } {#1} #1 } -\cs_new_protected:Npn \iow_indent:n { \@@_indent_error:n } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}{\iow_wrap:nnnN} % \begin{macro}[aux]{\@@_wrap_set:Nx} % The main wrapping function works as follows. First give |\\|, % \verb*|\ | and other formatting commands the correct definition for -% messages, before fully-expanding the input. In package mode, the -% expansion uses \LaTeXe{}'s \cs{protect} mechanism. Afterwards, set -% the newline marker (two assignments to fully expand, then convert -% to a string) and its length, and initialize some registers. -% There is then a loop over each word in the input, which will do the -% actual wrapping. After the loop, the resulting text is passed on to -% the function which has been given as a post-processor. -% The argument |#4| is available for additional set up steps for -% the output. The definition of |\\| and \verb*|\ | use an -% \enquote{other} space rather than a normal space, because the latter -% might be absorbed by \TeX{} to end a number or other \texttt{f}-type -% expansions. The \cs{tl_to_str:N} step converts the \enquote{other} -% space back to a normal space. +% messages and perform the given setup~|#3|. The definition of +% \verb*|\ | uses an \enquote{other} space rather than a normal space, +% because the latter might be absorbed by \TeX{} to end a number or +% other \texttt{f}-type expansions. % \begin{macrocode} \cs_new_protected:Npn \iow_wrap:nnnN #1#2#3#4 { \group_begin: - \int_set:Nn \tex_escapechar:D { - \c_one } + \int_set:Nn \tex_escapechar:D { -1 } \cs_set:Npx \{ { \token_to_str:N \{ } \cs_set:Npx \# { \token_to_str:N \# } \cs_set:Npx \} { \token_to_str:N \} } @@ -1639,48 +1659,39 @@ \cs_set_eq:NN \ \c_catcode_other_space_tl \cs_set_eq:NN \iow_indent:n \@@_indent:n #3 -%<*initex> +% \end{macrocode} +% Then fully-expand the input: in package mode, the expansion uses +% \LaTeXe{}'s \cs{protected} mechanism. As soon as the expansion is +% done, reset \cs{iow_indent:n} to its error definition: it only works +% in the first argument of \cs{iow_wrap:nnnN}. +% \begin{macrocode} +%<*initex> \tl_set:Nx \l_@@_wrap_tl {#1} %</initex> %<*package> \@@_wrap_set:Nx \l_@@_wrap_tl {#1} %</package> + \cs_set_eq:NN \iow_indent:n \@@_indent_error:n % \end{macrocode} -% To warn users that \cs{iow_indent:n} only works in the first argument -% of \cs{iow_wrap:nnnN} reset \cs{iow_indent:n} to its error -% definition. Then store a newline character and the run-on text as a -% string in \cs{l_@@_newline_tl}, and set some variables. The first -% line's target count is equal to the length of the whole line. The -% value \cs{l_@@_target_count_int} is altered later on by -% \cs{@@_wrap_set_target:}. +% Afterwards, set the newline marker (two assignments to fully expand, +% then convert to a string) and initialize the target count for lines +% (the first line has target count \cs{l_iow_line_count_int} instead). % \begin{macrocode} - \cs_set_eq:NN \iow_indent:n \@@_indent_error:n \tl_set:Nx \l_@@_newline_tl { \iow_newline: #2 } \tl_set:Nx \l_@@_newline_tl { \tl_to_str:N \l_@@_newline_tl } - \int_set_eq:NN \l_@@_target_count_int \l_iow_line_count_int - \tl_clear:N \l_@@_current_indentation_tl - \int_zero:N \l_@@_current_line_int - \tl_set:Nn \l_@@_current_line_tl { \use_none:n } - \bool_set_true:N \l_@@_line_start_bool -% \end{macrocode} -% After some setup above (in particular the odd setting of the current line -% to \cs{use_none:n}), a loop goes through space-delimited words in the -% message, recognizing special markers. To make sure that the first line -% behaves identically to others, start with a newline marker: the -% \cs{use_none:n} above avoids actually getting a new line in the output. -% \begin{macrocode} - \use:x - { - \exp_not:n { \tl_clear:N \l_@@_wrap_tl } - \@@_wrap_loop:w - \tl_to_str:N \c_@@_wrap_newline_marker_tl - \tl_to_str:N \l_@@_wrap_tl - \tl_to_str:N \c_@@_wrap_end_marker_tl - \c_space_tl \c_space_tl - \exp_not:N \q_stop - } - \exp_args:NNo \group_end: - #4 \l_@@_wrap_tl + \int_set:Nn \l_@@_line_target_int + { \l_iow_line_count_int - \str_count:N \l_@@_newline_tl + 1 } +% \end{macrocode} +% There is then a loop over the input, which will store the wrapped +% result in \cs{l_@@_wrap_tl}. After the loop, the resulting text is +% passed on to the function which has been given as a post-processor. +% The \cs{tl_to_str:N} step converts the \enquote{other} spaces back +% to normal spaces. The \texttt{f}-expansion removes a leading space +% from \cs{l_@@_wrap_tl}. +% \begin{macrocode} + \@@_wrap_do: + \exp_args:NNf \group_end: + #4 { \tl_to_str:N \l_@@_wrap_tl } } % \end{macrocode} % As using the generic loader will mean that \cs{protected@edef} is @@ -1694,160 +1705,342 @@ % \end{macro} % \end{macro} % -% \begin{macro}[aux]{\@@_wrap_set_target:} -% This is called at the beginning of every line (both those forced by -% |\\| and those due to line-breaking). The initial call does -% nothing except redefine \cs{@@_wrap_set_target:} itself (within the -% group in which \cs{iow_wrap:nnnN} works). The next call (at the -% beginning of the second line) disables any later call and sets the -% \cs{l_@@_target_count_int} to the correct value, namely the -% \cs{l_iow_line_count_int} shortened by the length of the run-on -% text (the shift by~$1$ is due to the presence of \cs{iow_newline:} -% in \cs{l_@@_newline_tl}). -% This is a bit of a hack to measure the string length of the run on text -% without the \pkg{l3str} module (which is still experimental). This should -% be replaced once the string module is finalised with something a little -% cleaner. -% \begin{macrocode} -\cs_new_protected:Npn \@@_wrap_set_target: +% \begin{macro}[aux]{\@@_wrap_do:, \@@_wrap_start:w} +% Escape spaces. Set up a few variables, in particular the initial +% value of \cs{l_@@_wrap_tl}: the space will stop the +% \texttt{f}-expansion of the main wrapping function and +% \cs{use_none:n} will remove a newline marker inserted by later code. +% The main loop consists of repeatedly calling the \texttt{chunk} +% auxiliary to wrap chunks delimited by (newline or indentation) +% markers. +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_do: { - \cs_set_protected:Npn \@@_wrap_set_target: + \tl_set:Nx \l_@@_wrap_tl { - \cs_set_protected:Npn \@@_wrap_set_target: { } - \tl_replace_all:Nnn \l_@@_newline_tl { ~ } { \c_space_tl } - \int_set:Nn \l_@@_target_count_int - { \l_iow_line_count_int - \tl_count:N \l_@@_newline_tl + \c_one } + \exp_args:No \__str_to_other_fast:n \l_@@_wrap_tl + \c_@@_wrap_end_marker_tl } + \exp_after:wN \@@_wrap_start:w \l_@@_wrap_tl + } +\cs_new_protected:Npn \@@_wrap_start:w + { + \bool_set_false:N \l_@@_line_break_bool + \tl_clear:N \l_@@_line_tl + \tl_clear:N \l_@@_line_part_tl + \tl_set:Nn \l_@@_wrap_tl { ~ \use_none:n } + \int_zero:N \l_@@_indent_int + \tl_clear:N \l_@@_indent_tl + \@@_wrap_chunk:nw { \l_iow_line_count_int } } % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_wrap_loop:w} -% The loop grabs one word in the input, and checks whether it is -% the special marker, or a normal word. +% \begin{macro}[aux]{\@@_wrap_chunk:nw, \@@_wrap_next:nw} +% The \texttt{chunk} and \texttt{next} auxiliaries are defined +% indirectly to obtain the expansions of \cs{c_catcode_other_space_tl} +% and \cs{c_@@_wrap_marker_tl} in their definition. The \texttt{next} +% auxiliary calls a function corresponding to the type of marker (its +% |##2|), which can be \texttt{newline} or \texttt{indent} or +% \texttt{unindent} or \texttt{end}. The first argument of the +% \texttt{chunk} auxiliary is a target number of characters and the +% second is some string to wrap. If the chunk is empty simply call +% \texttt{next}. Otherwise, set up a call to \cs{@@_wrap_line:nw}, +% including the indentation if the current line is empty, and +% including a trailing space (|#1|) before the +% \cs{@@_wrap_end_chunk:w} auxiliary. % \begin{macrocode} -\cs_new_protected:Npn \@@_wrap_loop:w #1 ~ % +\cs_set_protected:Npn \@@_tmp:w #1#2 { - \tl_set:Nn \l_@@_current_word_tl {#1} - \tl_if_eq:NNTF \l_@@_current_word_tl \c_@@_wrap_marker_tl - { \@@_wrap_special:w } - { \@@_wrap_word: } + \cs_new_protected:Npn \@@_wrap_chunk:nw ##1##2 #2 + { + \tl_if_empty:nTF {##2} + { + \tl_clear:N \l_@@_line_part_tl + \@@_wrap_next:nw {##1} + } + { + \tl_if_empty:NTF \l_@@_line_tl + { + \@@_wrap_line:nw + { \l_@@_indent_tl } + ##1 - \l_@@_indent_int ; + } + { \@@_wrap_line:nw { } ##1 ; } + ##2 #1 + \@@_wrap_end_chunk:w 7 6 5 4 3 2 1 0 \q_stop + } + } + \cs_new_protected:Npn \@@_wrap_next:nw ##1##2 #1 + { \use:c { @@_wrap_##2:n } {##1} } } +\exp_args:NVV \@@_tmp:w \c_catcode_other_space_tl \c_@@_wrap_marker_tl % \end{macrocode} % \end{macro} % -% \begin{macro}[aux]{\@@_wrap_word:} -% \begin{macro}[aux]{\@@_wrap_word_fits:} -% \begin{macro}[aux]{\@@_wrap_word_newline:} -% For a normal word, update the line count, then test if the current -% word would fit in the current line, and call the appropriate function. -% If the word fits in the current line, add it to the line, preceded by -% a space unless it is the first word of the line. -% Otherwise, the current line is added to the result, with the run-on text. -% The current word (and its character count) are then put in the new line. -% \begin{macrocode} -\cs_new_protected:Npn \@@_wrap_word: +% \begin{macro}[aux]{\@@_wrap_line:nw} +% \begin{macro}[EXP,aux] +% { +% \@@_wrap_line_loop:w, +% \@@_wrap_line_aux:Nw, +% \@@_wrap_line_end:NnnnnnnnN, +% \@@_wrap_line_end:nw, +% \@@_wrap_end_chunk:w +% } +% This is followed by \Arg{string} \meta{intexpr} |;|. It stores the +% \meta{string} and up to \meta{intexpr} characters from the current +% chunk into \cs{l_@@_line_part_tl}. Characters are grabbed 8~at a +% time and left in \cs{l_@@_line_part_tl} by the \texttt{line_loop} +% auxiliary. When $k<8$ remain to be found, the \texttt{line_aux} +% auxiliary calls the \texttt{line_end} auxiliary followed by (the +% single digit) $k$, then $7-k$ empty brace groups, then the chunk's +% remaining characters. The \texttt{line_end} auxiliary leaves +% $k$~characters from the chunk in the line part, then ends the +% assignment. Ignore the \cs{use_none:nnnnn} line for now. If the +% next character is a space the line can be broken there: +% store what we found into the result and get the next line. +% Otherwise some work is needed to find a break-point. So far we have +% ignored what happens if the chunk is shorter than the requested +% number of characters: this is dealt with by the \texttt{end_chunk} +% auxiliary, which gets treated like a character by the rest of the +% code. It ends up being called either as one of the arguments +% |#2|--|#9| of the \texttt{line_loop} auxiliary or as one of the +% arguments |#2|--|#8| of the \texttt{line_end} auxiliary. In both +% cases stop the assignment and work out how many characters are still +% needed. The weird \cs{use_none:nnnnn} ensures that the required +% data is in the right place. +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_line:nw #1 + { + \tex_edef:D \l_@@_line_part_tl { \if_false: } \fi: + #1 + \exp_after:wN \@@_wrap_line_loop:w + \__int_value:w \__int_eval:w + } +\cs_new:Npn \@@_wrap_line_loop:w #1 ; #2#3#4#5#6#7#8#9 + { + \if_int_compare:w #1 < 8 \exp_stop_f: + \@@_wrap_line_aux:Nw #1 + \fi: + #2 #3 #4 #5 #6 #7 #8 #9 + \exp_after:wN \@@_wrap_line_loop:w + \__int_value:w \__int_eval:w #1 - 8 ; + } +\cs_new:Npn \@@_wrap_line_aux:Nw #1#2#3 \exp_after:wN #4 ; + { + #2 + \exp_after:wN \@@_wrap_line_end:NnnnnnnnN + \exp_after:wN #1 + \exp:w \exp_end_continue_f:w + \exp_after:wN \exp_after:wN + \if_case:w #1 \exp_stop_f: + \prg_do_nothing: + \or: \use_none:n + \or: \use_none:nn + \or: \use_none:nnn + \or: \use_none:nnnn + \or: \use_none:nnnnn + \or: \use_none:nnnnnn + \or: \use_none:nnnnnnn + \fi: + { } { } { } { } { } { } { } #3 + } +\cs_new:Npn \@@_wrap_line_end:NnnnnnnnN #1#2#3#4#5#6#7#8#9 + { + #2 #3 #4 #5 #6 #7 #8 + \use_none:nnnnn \__int_eval:w 8 - ; #9 + \token_if_eq_charcode:NNTF \c_space_token #9 + { \@@_wrap_line_end:nw { } } + { \if_false: { \fi: } \@@_wrap_break:w #9 } + } +\cs_new:Npn \@@_wrap_line_end:nw #1 + { + \if_false: { \fi: } + \@@_wrap_store_do:n {#1} + \@@_wrap_next_line:w + } +\cs_new:Npn \@@_wrap_end_chunk:w + #1 \__int_eval:w #2 - #3 ; #4#5 \q_stop { - \int_set:Nn \l_@@_current_word_int - { \exp_args:No \str_count_ignore_spaces:n \l_@@_current_word_tl } - \int_add:Nn \l_@@_current_line_int { \l_@@_current_word_int } - \int_compare:nNnTF \l_@@_current_line_int < \l_@@_target_count_int - { \@@_wrap_word_fits: } - { \@@_wrap_word_newline: } - \@@_wrap_loop:w + \if_false: { \fi: } + \exp_args:Nf \@@_wrap_next:nw { \int_eval:n { #2 - #4 } } } -\cs_new_protected:Npn \@@_wrap_word_fits: +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[EXP,aux]{\@@_wrap_break:w} +% \begin{macro}[EXP,aux] +% { +% \@@_wrap_break_first:w, +% \@@_wrap_break_none:w, +% \@@_wrap_break_loop:w, +% \@@_wrap_break_end:w, +% } +% Functions here are defined indirectly: \cs{@@_tmp:w} is eventually +% called with an \enquote{other} space as its argument. The goal is +% to remove from \cs{l_@@_line_part_tl} the part after the last space. +% In most cases this is done by repeatedly calling the +% \texttt{break_loop} auxiliary, which leaves \enquote{words} +% (delimited by spaces) until it hits the trailing space: then its +% argument |##3| is |?| \cs{@@_wrap_break_end:w} instead of a single +% token, and that \texttt{break_end} auxiliary leaves in the +% assignment the line until the last space, then calls +% \cs{@@_wrap_line_end:nw} to finish up the line and move on to the +% next. If there is no space in \cs{l_@@_line_part_tl} then the +% \texttt{break_first} auxiliary calls the \texttt{break_none} +% auxiliary. In that case, if the current line is empty, the complete +% word (including |##4|, characters beyond what we had grabbed) is +% added to the line, making it over-long. Otherwise, the word will be +% used for the following line (and the last space of the line so far +% is removed because it was inserted due to the presence of a marker). +% \begin{macrocode} +\cs_set_protected:Npn \@@_tmp:w #1 { - \bool_if:NTF \l_@@_line_start_bool + \cs_new:Npn \@@_wrap_break:w { - \bool_set_false:N \l_@@_line_start_bool - \tl_put_right:Nx \l_@@_current_line_tl - { \l_@@_current_indentation_tl \l_@@_current_word_tl } - \int_add:Nn \l_@@_current_line_int - { \l_@@_current_indentation_int } + \tex_edef:D \l_@@_line_part_tl + { \if_false: } \fi: + \exp_after:wN \@@_wrap_break_first:w + \l_@@_line_part_tl + #1 + { ? \@@_wrap_break_end:w } + \q_mark } + \cs_new:Npn \@@_wrap_break_first:w ##1 #1 ##2 { - \tl_put_right:Nx \l_@@_current_line_tl - { ~ \l_@@_current_word_tl } - \int_incr:N \l_@@_current_line_int + \use_none:nn ##2 \@@_wrap_break_none:w + \@@_wrap_break_loop:w ##1 #1 ##2 } - } -\cs_new_protected:Npn \@@_wrap_word_newline: - { - \@@_wrap_set_target: - \tl_put_right:Nx \l_@@_wrap_tl - { \l_@@_current_line_tl \l_@@_newline_tl } - \int_set:Nn \l_@@_current_line_int + \cs_new:Npn \@@_wrap_break_none:w ##1##2 #1 ##3 \q_mark ##4 #1 { - \l_@@_current_word_int - + \l_@@_current_indentation_int + \tl_if_empty:NTF \l_@@_line_tl + { ##2 ##4 \@@_wrap_line_end:nw { } } + { \@@_wrap_line_end:nw { \@@_wrap_trim:N } ##2 ##4 #1 } } - \tl_set:Nx \l_@@_current_line_tl - { \l_@@_current_indentation_tl \l_@@_current_word_tl } + \cs_new:Npn \@@_wrap_break_loop:w ##1 #1 ##2 #1 ##3 + { + \use_none:n ##3 + ##1 #1 + \@@_wrap_break_loop:w ##2 #1 ##3 + } + \cs_new:Npn \@@_wrap_break_end:w ##1 #1 ##2 ##3 #1 ##4 \q_mark + { ##1 \@@_wrap_line_end:nw { } ##3 } } +\exp_args:NV \@@_tmp:w \c_catcode_other_space_tl % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} % -% \begin{macro}[aux]{\@@_wrap_special:w} -% \begin{macro}[aux]{\@@_wrap_newline:w} -% \begin{macro}[aux]{\@@_wrap_indent:w} -% \begin{macro}[aux]{\@@_wrap_unindent:w} -% \begin{macro}[aux]{\@@_wrap_end:w} -% When the \enquote{special} marker is encountered, -% read what operation to perform, as a space-delimited -% argument, perform it, and remember to loop. -% In fact, to avoid spurious spaces when two special -% actions follow each other, we look ahead for another -% copy of the marker. -% Forced newlines are almost identical to those caused by overflow, -% except that here the word is empty. -% To indent more, add four spaces to the start of the indentation -% token list. To reduce indentation, rebuild the indentation token -% list using \cs{prg_replicate:nn}. -% At the end, we simply save the last line (without the run-on text), -% and prevent the loop. -% \begin{macrocode} -\cs_new_protected:Npn \@@_wrap_special:w #1 ~ #2 ~ #3 ~ % +% \begin{macro}[aux]{\@@_wrap_next_line:w} +% The special case where the end of a line coincides with the end of a +% chunk is detected here, to avoid a spurious empty line. Otherwise, +% call \cs{@@_wrap_line:nw} to find characters for the next line +% (remembering to account for the indentation). +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_next_line:w #1#2 \q_stop { - \use:c { @@_wrap_#1: } - \str_if_eq_x:nnTF { #2~#3 } { ~ \c_@@_wrap_marker_tl } - { \@@_wrap_special:w } - { \@@_wrap_loop:w #2 ~ #3 ~ } + \tl_clear:N \l_@@_line_tl + \token_if_eq_meaning:NNTF #1 \@@_wrap_end_chunk:w + { + \tl_clear:N \l_@@_line_part_tl + \bool_set_true:N \l_@@_line_break_bool + \@@_wrap_next:nw { \l_@@_line_target_int } + } + { + \@@_wrap_line:nw + { \l_@@_indent_tl } + \l_@@_line_target_int - \l_@@_indent_int ; + #1 #2 \q_stop + } } -\cs_new_protected:Npn \@@_wrap_newline: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux]{\@@_wrap_indent:, \@@_wrap_unindent:} +% These functions are called after a chunk has been wrapped, when +% encountering \texttt{indent}/\texttt{unindent} markers. Add the +% line part (last line part of the previous chunk) to the line so far +% and reset a boolean denoting the presence of a line-break. Most +% importantly, add or remove one indent from the current indent (both +% the integer and the token list). Finally, continue wrapping. +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_indent:n #1 { - \@@_wrap_set_target: - \tl_put_right:Nx \l_@@_wrap_tl - { \l_@@_current_line_tl \l_@@_newline_tl } - \int_zero:N \l_@@_current_line_int - \tl_clear:N \l_@@_current_line_tl - \bool_set_true:N \l_@@_line_start_bool + \tl_put_right:Nx \l_@@_line_tl { \l_@@_line_part_tl } + \bool_set_false:N \l_@@_line_break_bool + \int_add:Nn \l_@@_indent_int { \l_@@_one_indent_int } + \tl_put_right:No \l_@@_indent_tl { \l_@@_one_indent_tl } + \@@_wrap_chunk:nw {#1} } -\cs_new_protected:Npx \@@_wrap_indent: +\cs_new_protected:Npn \@@_wrap_unindent:n #1 { - \int_add:Nn \l_@@_current_indentation_int \c_four - \tl_put_right:Nx \exp_not:N \l_@@_current_indentation_tl - { \c_space_tl \c_space_tl \c_space_tl \c_space_tl } + \tl_put_right:Nx \l_@@_line_tl { \l_@@_line_part_tl } + \bool_set_false:N \l_@@_line_break_bool + \int_sub:Nn \l_@@_indent_int { \l_@@_one_indent_int } + \tl_set:Nx \l_@@_indent_tl + { \exp_after:wN \@@_unindent:w \l_@@_indent_tl } + \@@_wrap_chunk:nw {#1} } -\cs_new_protected:Npn \@@_wrap_unindent: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux]{\@@_wrap_newline:, \@@_wrap_end:} +% These functions are called after a chunk has been line-wrapped, when +% encountering a \texttt{newline}/\texttt{end} marker. Unless we just +% took a line-break, store the line part and the line so far into the +% whole \cs{l_@@_wrap_tl}, trimming a trailing space. In the +% \texttt{newline} case look for a new line (of length +% \cs{l_@@_line_target_int}) in a new chunk. +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_newline:n #1 { - \int_sub:Nn \l_@@_current_indentation_int \c_four - \tl_set:Nx \l_@@_current_indentation_tl - { \prg_replicate:nn \l_@@_current_indentation_int { ~ } } + \bool_if:NF \l_@@_line_break_bool + { \@@_wrap_store_do:n { \@@_wrap_trim:N } } + \bool_set_false:N \l_@@_line_break_bool + \@@_wrap_chunk:nw { \l_@@_line_target_int } } -\cs_new_protected:Npn \@@_wrap_end: +\cs_new_protected:Npn \@@_wrap_end:n #1 { - \tl_put_right:Nx \l_@@_wrap_tl - { \l_@@_current_line_tl } - \use_none_delimit_by_q_stop:w + \bool_if:NF \l_@@_line_break_bool + { \@@_wrap_store_do:n { \@@_wrap_trim:N } } + \bool_set_false:N \l_@@_line_break_bool } % \end{macrocode} % \end{macro} +% +% \begin{macro}[aux]{\@@_wrap_store_do:n} +% First add the last line part to the line, then append it to +% \cs{l_@@_wrap_tl} with the appropriate new line (with +% \enquote{run-on} text), possibly with its last space removed (|#1| +% is empty or \cs{@@_wrap_trim:N}). +% \begin{macrocode} +\cs_new_protected:Npn \@@_wrap_store_do:n #1 + { + \tl_set:Nx \l_@@_line_tl + { \l_@@_line_tl \l_@@_line_part_tl } + \tl_set:Nx \l_@@_wrap_tl + { + \l_@@_wrap_tl + \l_@@_newline_tl + #1 \l_@@_line_tl + } + \tl_clear:N \l_@@_line_tl + } +% \end{macrocode} % \end{macro} -% \end{macro} -% \end{macro} +% +% \begin{macro}[EXP, aux]{\@@_wrap_trim:N, \@@_wrap_trim:w} +% Remove one trailing \enquote{other} space from the argument. +% \begin{macrocode} +\cs_set_protected:Npn \@@_tmp:w #1 + { + \cs_new:Npn \@@_wrap_trim:N ##1 + { \tl_if_empty:NF ##1 { \exp_after:wN \@@_wrap_trim:w ##1 \q_stop } } + \cs_new:Npn \@@_wrap_trim:w ##1 #1 \q_stop {##1} + } +\exp_args:NV \@@_tmp:w \c_catcode_other_space_tl +% \end{macrocode} % \end{macro} % % \subsection{Messages} @@ -1878,8 +2071,13 @@ { File~names~must~contain~balanced~numbers~of~quotes~("). } -\__msg_kernel_new:nnn { kernel } { indent-outside-wrapping-code } - { Only~\iow_wrap:nnnN~(arg~1)~allows~\iow_indent:n } +\__msg_kernel_new:nnnn { kernel } { iow-indent } + { Only~#1 (arg~1)~allows~#2 } + { + The~command~#2 can~only~be~used~in~messages~ + which~will~be~wrapped~using~#1.~ + It~was~called~with~argument~'#3'. + } % \end{macrocode} % % \subsection{Deprecated functions} @@ -1887,7 +2085,15 @@ % \begin{macro}[added = 2012-06-24, updated = 2012-07-31, deprecated=2017-12-31]{\ior_get_str:NN} % For removal after 2017-12-31. % \begin{macrocode} -\cs_new_eq:NN \ior_get_str:NN \ior_str_get:NN +\cs_new_protected:Npn \ior_get_str:NN + { + \__msg_kernel_warning:nnxxx { kernel } { deprecated-command } + { 2017-12-31 } + { \token_to_str:N \ior_get_str:NN } + { \token_to_str:N \ior_str_get:NN } + \cs_gset_eq:NN \ior_get_str:NN \ior_str_get:NN + \ior_str_get:NN + } % \end{macrocode} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx new file mode 100644 index 00000000000..5afe7e646a7 --- /dev/null +++ b/Master/texmf-dist/source/latex/l3kernel/l3flag.dtx @@ -0,0 +1,351 @@ +% \iffalse meta-comment +% +%% File: l3flag.dtx Copyright (C) 2011-2012,2014-2017 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 development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. +% +%<*driver> +\documentclass[full]{l3doc} +%</driver> +%<*driver|package> +\GetIdInfo$Id: l3flag.dtx 6969 2017-02-20 18:32:23Z bruno $ + {L3 Flags} +%</driver|package> +%<*driver> +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \title{^^A +% The \textsf{l3flag} package: expandable flags^^A +% \thanks{This file describes v\ExplFileVersion, +% last revised \ExplFileDate.}^^A +% } +% +% \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} +% +% Flags are the only data-type that can be modified in expansion-only +% contexts. This module is meant mostly for kernel use: in almost all +% cases, booleans or integers should be preferred to flags because they +% are very significantly faster. +% +% A flag can hold any non-negative value, which we call its +% \meta{height}. In expansion-only contexts, a flag can only be +% \enquote{raised}: this increases the \meta{height} by $1$. The \meta{height} +% can also be queried expandably. However, decreasing it, or setting it +% to zero requires non-expandable assignments. +% +% Flag variables are always local. They are referenced by a \meta{flag +% name} such as \texttt{str_missing}. The \meta{flag name} is used as +% part of \cs{use:c} constructions hence is expanded at point of use. +% It must expand to character tokens only, with no spaces. +% +% A typical use case of flags would be to keep track of whether an +% exceptional condition has occured during expandable processing, and +% produce a meaningful (non-expandable) message after the end of the +% expandable processing. This is exemplified by \pkg{l3str-convert}, +% which for performance reasons performs conversions of individual +% characters expandably and for readability reasons produces a single +% error message describing incorrect inputs that were encountered. +% +% Flags should not be used without carefully considering the fact that +% raising a flag takes a time and memory proportional to its height. +% Flags should not be used unless unavoidable. +% +% \section{Setting up flags} +% +% \begin{function}{\flag_new:n} +% \begin{syntax} +% \cs{flag_new:n} \Arg{flag name} +% \end{syntax} +% Creates a new flag with a name given by \meta{flag name}, or raises +% an error if the name is already taken. The \meta{flag name} may not +% contain spaces. The declaration is global, but flags are always +% local variables. The \meta{flag} will initially have zero height. +% \end{function} +% +% \begin{function}{\flag_clear:n} +% \begin{syntax} +% \cs{flag_clear:n} \Arg{flag name} +% \end{syntax} +% The \meta{flag}'s height is set to zero. The assignment is local. +% \end{function} +% +% \begin{function}{\flag_clear_new:n} +% \begin{syntax} +% \cs{flag_clear_new:n} \Arg{flag name} +% \end{syntax} +% Ensures that the \meta{flag} exists globally by applying +% \cs{flag_new:n} if necessary, then applies \cs{flag_clear:n}, setting +% the height to zero locally. +% \end{function} +% +% \begin{function}{\flag_show:n} +% \begin{syntax} +% \cs{flag_show:n} \Arg{flag name} +% \end{syntax} +% Displays the \meta{flag}'s height in the terminal. +% \end{function} +% +% \begin{function}{\flag_log:n} +% \begin{syntax} +% \cs{flag_log:n} \Arg{flag name} +% \end{syntax} +% Writes the \meta{flag}'s height to the log file. +% \end{function} +% +% \section{Expandable flag commands} +% +% \begin{function}[EXP,pTF]{\flag_if_exist:n} +% \begin{syntax} +% \cs{flag_if_exist:n} \Arg{flag name} +% \end{syntax} +% This function returns \texttt{true} if the \meta{flag name} +% references a flag that has been defined previously, and +% \texttt{false} otherwise. +% \end{function} +% +% \begin{function}[EXP,pTF]{\flag_if_raised:n} +% \begin{syntax} +% \cs{flag_if_raised:n} \Arg{flag name} +% \end{syntax} +% This function returns \texttt{true} if the \meta{flag} has non-zero +% height, and \texttt{false} if the \meta{flag} has zero height. +% \end{function} +% +% \begin{function}[EXP]{\flag_height:n} +% \begin{syntax} +% \cs{flag_height:n} \Arg{flag name} +% \end{syntax} +% Expands to the height of the \meta{flag} as an integer denotation. +% \end{function} +% +% \begin{function}[EXP]{\flag_raise:n} +% \begin{syntax} +% \cs{flag_raise:n} \Arg{flag name} +% \end{syntax} +% The \meta{flag}'s height is increased by $1$ locally. +% \end{function} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3flag} implementation} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% \begin{macrocode} +%<@@=flag> +% \end{macrocode} +% +% \TestFiles{m3flag001} +% +% \subsection{Non-expandable flag commands} +% +% The height $h$ of a flag (initially zero) is stored by setting control +% sequences of the form \cs[no-index]{flag \meta{name} \meta{integer}} +% to \tn{relax} for $0\leq\meta{integer}<h$. When a flag is raised, a +% \enquote{trap} function \cs[no-index]{flag \meta{name}} is called. +% The existence of this function is also used to test for the existence +% of a flag. +% +% \begin{macro}{\flag_new:n} +% For each flag, we define a \enquote{trap} function, which by default +% simply increases the flag by $1$ by letting the appropriate control +% sequence to \tn{relax}. This can be done expandably! +% \begin{macrocode} +\cs_new_protected:Npn \flag_new:n #1 + { + \cs_new:cpn { flag~#1 } ##1 ; + { \exp_after:wN \use_none:n \cs:w flag~#1~##1 \cs_end: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\flag_clear:n} +% \begin{macro}[aux]{\@@_clear:wn} +% Undefine control sequences, starting from the |0| flag, upwards, +% until reaching an undefined control sequence. We don't use +% \cs{cs_undefine:c} because that would act globally. +% \begin{macrocode} +\cs_new_protected:Npn \flag_clear:n { \@@_clear:wn 0 ; } +\cs_new_protected:Npn \@@_clear:wn #1 ; #2 + { + \if_cs_exist:w flag~#2~#1 \cs_end: + \cs_set_eq:cN { flag~#2~#1 } \tex_undefined:D + \exp_after:wN \@@_clear:wn + \__int_value:w \__int_eval:w 1 + #1 + \else: + \use_i:nnn + \fi: + ; {#2} + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\flag_clear_new:n} +% As for other datatypes, clear the \meta{flag} or create a new one, +% as appropriate. +% \begin{macrocode} +\cs_new_protected:Npn \flag_clear_new:n #1 + { \flag_if_exist:nTF {#1} { \flag_clear:n } { \flag_new:n } {#1} } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\flag_show:n, \flag_log:n} +% Show the height (terminal or log file) using appropriate \pkg{l3msg} +% auxiliaries. +% \begin{macrocode} +\cs_new_protected:Npn \flag_show:n #1 + { + \exp_args:Nc \__msg_show_variable:NNNnn { flag~#1 } \cs_if_exist:NTF ? { } + { > ~ flag ~ #1 ~ height = \flag_height:n {#1} } + } +\cs_new_protected:Npn \flag_log:n + { \__msg_log_next: \flag_show:n } +% \end{macrocode} +% \end{macro} +% +% \subsection{Expandable flag commands} +% +% \begin{macro}[EXP, pTF]{\flag_if_exist:n} +% A flag exist if the corresponding trap \cs[no-index]{flag \meta{flag +% name}:n} is defined. +% \begin{macrocode} +\prg_new_conditional:Npnn \flag_if_exist:n #1 { p , T , F , TF } + { + \cs_if_exist:cTF { flag~#1 } + { \prg_return_true: } { \prg_return_false: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP, pTF]{\flag_if_raised:n} +% Test if the flag has a non-zero height, by checking the |0| control sequence. +% \begin{macrocode} +\prg_new_conditional:Npnn \flag_if_raised:n #1 { p , T , F , TF } + { + \if_cs_exist:w flag~#1~0 \cs_end: + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\flag_height:n} +% \begin{macro}[EXP, aux]{\@@_height_loop:wn, \@@_height_end:wn} +% Extract the value of the flag by going through all of the +% control sequences starting from |0|. +% \begin{macrocode} +\cs_new:Npn \flag_height:n { \@@_height_loop:wn 0; } +\cs_new:Npn \@@_height_loop:wn #1 ; #2 + { + \if_cs_exist:w flag~#2~#1 \cs_end: + \exp_after:wN \@@_height_loop:wn \__int_value:w \__int_eval:w 1 + + \else: + \exp_after:wN \@@_height_end:wn + \fi: + #1 ; {#2} + } +\cs_new:Npn \@@_height_end:wn #1 ; #2 {#1} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[EXP]{\flag_raise:n} +% Simply apply the trap to the height, after expanding the latter. +% \begin{macrocode} +\cs_new:Npn \flag_raise:n #1 + { + \cs:w flag~#1 \exp_after:wN \cs_end: + \__int_value:w \flag_height:n {#1} ; + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Option check-declarations} +% +% \begin{macro}[EXP,aux]{\@@_chk_exist:n} +% In package mode, there is an option to check all variables used are +% defined. Since flags are not implemented in terms of other +% variables, we need to add checks by hand. Not all functions need to +% be patched because some are defined in terms of others. +% \begin{macrocode} +%<*package> +\tex_ifodd:D \l@expl@check@declarations@bool + \cs_set_protected:Npn \flag_clear:n #1 + { + \exp_args:Nc \__chk_if_exist_var:N { flag~#1 } + \@@_clear:wn 0 ; {#1} + } + \cs_set:Npn \@@_chk_exist:n #1 + { + \flag_if_exist:nF {#1} + { + \__msg_kernel_expandable_error:nnn + { kernel } { bad-variable } { flag~#1~ } + } + } + \cs_set:Npn \flag_height:n #1 + { + \@@_chk_exist:n {#1} + \@@_height_loop:wn 0; {#1} + } + \prg_set_conditional:Npnn \flag_if_raised:n #1 { p , T , F , TF } + { + \@@_chk_exist:n {#1} + \if_cs_exist:w flag~#1~0 \cs_end: + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\fi: +%</package> +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</initex|package> +% \end{macrocode} +% +% \end{implementation} +% +% \PrintIndex diff --git a/Master/texmf-dist/source/latex/l3kernel/l3format.ins b/Master/texmf-dist/source/latex/l3kernel/l3format.ins index d49a7794f86..14d71ea4463 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3format.ins +++ b/Master/texmf-dist/source/latex/l3kernel/l3format.ins @@ -61,12 +61,13 @@ and all files in that bundle must be distributed together. \from{l3basics.dtx} {initex} \from{l3expan.dtx} {initex} \from{l3tl.dtx} {initex} - \from{l3seq.dtx} {initex} \from{l3str.dtx} {initex} + \from{l3seq.dtx} {initex} % ======== FORMAT ONLY ========= \from{l3alloc.dtx} {initex} % ============================== \from{l3int.dtx} {initex} + \from{l3flag.dtx} {initex} \from{l3quark.dtx} {initex} \from{l3prg.dtx} {initex} \from{l3clist.dtx} {initex} @@ -94,6 +95,7 @@ and all files in that bundle must be distributed together. \from{l3coffins.dtx} {initex} \from{l3color.dtx} {initex} \from{l3sys.dtx} {initex} + \from{l3deprecation.dtx}{initex} \from{l3candidates.dtx} {initex} \from{l3luatex.dtx} {initex,tex} % ======== FORMAT ONLY ========= @@ -125,6 +127,6 @@ Do not distribute a modified version of this file. \endpreamble \nopostamble \generate{\file{expl3.lua} {\from{l3luatex.dtx}{lua,package}}} -\generate{\file{l3format.lua}{\from{l3luatex.dtx}{fontloader}}} +\generate{\file{l3format.lua}{\from{l3luatex.dtx}{lua,initex}}} \endbatchfile diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx index d696a2ba2e5..71433549d51 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-assign.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-assign.dtx Copyright (C) 2011-2016 The LaTeX3 project +%% File: l3fp-assign.dtx Copyright (C) 2011-2017 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 @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-assign.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-assign.dtx 6906 2017-02-12 20:07:58Z bruno $ {L3 Floating-point assignments} \begin{document} \DocInput{\jobname.dtx} @@ -181,6 +181,17 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\fp_log:N, \fp_log:c, \fp_log:n} +% Redirect output of \cs{fp_show:N} and \cs{fp_show:n} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \fp_log:N + { \__msg_log_next: \fp_show:N } +\cs_new_protected:Npn \fp_log:n + { \__msg_log_next: \fp_show:n } +\cs_generate_variant:Nn \fp_log:N { c } +% \end{macrocode} +% \end{macro} +% % \subsection{Some useful constants and scratch variables} % % \begin{variable}{\c_one_fp, \c_e_fp} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx index 382bfb3ecc3..de3bae56fd4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-aux.dtx Copyright(C) 2011-2014,2016 The LaTeX3 Project +%% File: l3fp-aux.dtx Copyright(C) 2011-2014,2016-2017 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 @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-aux.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-aux.dtx 6968 2017-02-20 16:08:44Z bruno $ {L3 Floating-point support functions} \documentclass[full]{l3doc} \begin{document} @@ -301,6 +301,22 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_@@_prec_int, \c_@@_half_prec_int, \c_@@_block_int} +% The number of digits of floating points. +% \begin{macrocode} +\int_const:Nn \c_@@_prec_int { 16 } +\int_const:Nn \c_@@_half_prec_int { 8 } +\int_const:Nn \c_@@_block_int { 4 } +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\c_@@_myriad_int} +% Blocks have $4$~digits so this integer is useful. +% \begin{macrocode} +\int_const:Nn \c_@@_myriad_int { 10000 } +% \end{macrocode} +% \end{variable} +% % \begin{variable}[int]{\c_@@_max_exponent_int} % Normal floating point numbers have an exponent at most % \texttt{max_exponent} in absolute value. Larger numbers are rounded @@ -319,6 +335,14 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_@@_max_exp_exponent_int} +% If a number's exponent is larger than that, its exponential +% overflows/underflows. +% \begin{macrocode} +\int_const:Nn \c_@@_max_exp_exponent_int { 5 } +% \end{macrocode} +% \end{variable} +% % \begin{macro}[int, EXP]{\@@_zero_fp:N, \@@_inf_fp:N} % In case of overflow or underflow, we have to output % a zero or infinity with a given sign. @@ -372,7 +396,7 @@ % turned to $2$ (negative), $1$ (\texttt{nan}) to $1$, and $2$ to $0$. % \begin{macrocode} \cs_new:Npn \@@_neg_sign:N #1 - { \__int_eval:w \c_two - #1 \__int_eval_end: } + { \__int_eval:w 2 - #1 \__int_eval_end: } % \end{macrocode} % \end{macro} % @@ -391,9 +415,9 @@ \cs_new:Npn \@@_sanitize:Nw #1 #2; { \if_case:w - \if_int_compare:w #2 > \c_@@_max_exponent_int \c_one \else: - \if_int_compare:w #2 < - \c_@@_max_exponent_int \c_two \else: - \if_meaning:w 1 #1 \c_three \else: \c_zero \fi: \fi: \fi: + \if_int_compare:w #2 > \c_@@_max_exponent_int 1 ~ \else: + \if_int_compare:w #2 < - \c_@@_max_exponent_int 2 ~ \else: + \if_meaning:w 1 #1 3 ~ \else: 0 ~ \fi: \fi: \fi: \or: \exp_after:wN \@@_overflow:w \or: \exp_after:wN \@@_underflow:w \or: \exp_after:wN \@@_sanitize_zero:w @@ -717,7 +741,7 @@ { \cs:w @@_decimate_ - \if_int_compare:w \__int_eval:w #1 > \c_sixteen + \if_int_compare:w \__int_eval:w #1 > \c_@@_prec_int tiny \else: \__int_to_roman:w \__int_eval:w #1 @@ -760,7 +784,8 @@ % The arguments are as follows: |#1| indicates which function is % being defined; after one step of expansion, |#2| yields the % \enquote{extra digits} which are then converted by -% \cs{@@_round_digit:Nw} to the \meta{rounding} digit. +% \cs{@@_round_digit:Nw} to the \meta{rounding} digit (note the |+| +% separating blocks of digits to avoid overflowing \TeX{}'s integers). % This triggers the \texttt{f}-expansion of % \cs{@@_decimate_pack:nnnnnnnnnnw},\footnote{No, the argument % spec is not a mistake: the function calls an auxiliary to @@ -799,21 +824,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP, aux] -% {\@@_round_digit:Nw, \@@_decimate_pack:nnnnnnnnnnw} -% % ^^A \cs{@@_round_digit:Nw} moved to \pkg{l3fp-round}. -% \cs{@@_round_digit:Nw} will receive the \enquote{extra digits} -% as its argument, and its expansion is triggered by \cs{__int_value:w}. -% If the first digit is neither $0$ nor $5$, then it is the \meta{rounding} -% digit. Otherwise, if the remaining digits are not all zero, we need -% to add $1$ to that leading digit to get the rounding digit. Some caution -% is required, though, because there may be more than $10$ -% \enquote{extra digits}, and this may overflow \TeX{}'s integers. -% Instead of feeding the digits directly to \cs{@@_round_digit:Nw}, -% they come split into several blocks, separated by $+$. Hence the first -% \cs{__int_eval:w} here. -% \begin{macrocode} -% \end{macrocode} +% \begin{macro}[EXP, aux]{\@@_decimate_pack:nnnnnnnnnnw} % The computation of the \meta{rounding} digit leaves an unfinished % \cs{__int_value:w}, which expands the following functions. This % allows us to repack nicely the digits we keep. Those digits come @@ -942,8 +953,8 @@ } \cs_new:Npn \@@_int_normal:nnnnn #1 #2#3#4#5 { - \if_int_compare:w #1 > \c_zero - \@@_decimate:nNnnnn { \c_sixteen - #1 } + \if_int_compare:w #1 > 0 \exp_stop_f: + \@@_decimate:nNnnnn { \c_@@_prec_int - #1 } \@@_int_test:Nw {#2} {#3} {#4} {#5} \else: @@ -1007,8 +1018,8 @@ \cs_new:Npn \@@_small_int_true:wTF #1; #2#3 { #2 {#1} } \cs_new:Npn \@@_small_int_normal:NnwTF #1#2#3; { - \if_int_compare:w #2 > \c_zero - \@@_decimate:nNnnnn { \c_sixteen - #2 } + \if_int_compare:w #2 > 0 \exp_stop_f: + \@@_decimate:nNnnnn { \c_@@_prec_int - #2 } \@@_small_int_test:NnnwNnw #3 #1 {#2} \else: @@ -1021,7 +1032,7 @@ \if_meaning:w 0 #1 \exp_after:wN \@@_small_int_true:wTF \__int_value:w \if_meaning:w 2 #5 - \fi: - \if_int_compare:w #6 > \c_eight + \if_int_compare:w #6 > \c_@@_half_prec_int 1 0000 0000 \else: #3 @@ -1045,13 +1056,13 @@ % \begin{macrocode} \cs_new:Npn \@@_array_count:n #1 { - \__int_value:w \__int_eval:w \c_zero + \__int_value:w \__int_eval:w 0 \@@_array_count_loop:Nw #1 { ? \__prg_break: } ; \__prg_break_point: \__int_eval_end: } \cs_new:Npn \@@_array_count_loop:Nw #1#2; - { \use_none:n #1 + \c_one \@@_array_count_loop:Nw } + { \use_none:n #1 + 1 \@@_array_count_loop:Nw } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx index 8bdb1f07152..6b4ed3846d3 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-basics.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-basics.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point arithmetic} \begin{document} \DocInput{\jobname.dtx} @@ -92,7 +92,7 @@ % |{0000}|. % \begin{macrocode} \cs_new:Npn \@@_basics_pack_low:NNNNNw #1 #2#3#4#5 #6; - { + #1 - \c_one ; {#2#3#4#5} {#6} ; } + { + #1 - 1 ; {#2#3#4#5} {#6} ; } \cs_new:Npn \@@_basics_pack_high:NNNNNw #1 #2#3#4#5 #6; { \if_meaning:w 2 #1 @@ -101,7 +101,7 @@ ; {#2#3#4#5} {#6} } \cs_new:Npn \@@_basics_pack_high_carry:w \fi: ; #1 - { \fi: + \c_one ; {1000} } + { \fi: + 1 ; {1000} } % \end{macrocode} % \end{macro} % @@ -116,7 +116,7 @@ \cs_new:Npn \@@_basics_pack_weird_low:NNNNw #1 #2#3#4 #5; { \if_meaning:w 2 #1 - + \c_one + + 1 \fi: \__int_eval_end: #2#3#4; {#5} ; @@ -196,14 +196,15 @@ { \if_case:w \if_meaning:w #2 #4 - #2 \exp_stop_f: + #2 \else: \if_int_compare:w #2 > #4 \exp_stop_f: - \c_three + 3 \else: - \c_four + 4 \fi: \fi: + \exp_stop_f: \exp_after:wN \@@_add_zeros_o:Nww \__int_value:w \or: \exp_after:wN \@@_add_normal_o:Nww \__int_value:w \or: \exp_after:wN \@@_add_inf_o:Nww \__int_value:w @@ -393,7 +394,7 @@ \cs_new:Npn \@@_add_significand_pack:NNNNNNN #1 #2#3#4#5#6#7 { \if_meaning:w 2 #1 - + \c_one + + 1 \fi: ; #2 #3 #4 #5 #6 #7 ; } @@ -444,7 +445,7 @@ \cs_new:Npn \@@_add_significand_carry_o:wwwNN #1; #2; #3#4; #5#6 { - + \c_one + + 1 \exp_after:wN \@@_basics_pack_weird_high:NNNNNNNNw \__int_value:w \__int_eval:w 1 1 #1 \exp_after:wN \@@_basics_pack_weird_low:NNNNw @@ -489,7 +490,7 @@ \cs_new:Npn \@@_sub_npos_ii_o:Nnwnw #1 #2; #3; { \exp_after:wN \@@_sub_npos_i_o:Nnwnw - \__int_value:w \__int_eval:w \c_two - #1 \__int_eval_end: + \__int_value:w \@@_neg_sign:N #1 #3; #2; } % \end{macrocode} @@ -517,7 +518,7 @@ \exp_after:wN \@@_sub_back_near_o:nnnnnnnnN \else: \exp_after:wN \@@_decimate:nNnnnn \exp_after:wN - { \__int_value:w \__int_eval:w #2 - #4 - \c_one \exp_after:wN } + { \__int_value:w \__int_eval:w #2 - #4 - 1 \exp_after:wN } \exp_after:wN \@@_sub_back_far_o:NnnwnnnnN \fi: #5 @@ -546,7 +547,7 @@ \cs_new:Npn \@@_sub_back_near_o:nnnnnnnnN #1#2#3#4 #5#6#7#8 #9 { \exp_after:wN \@@_sub_back_near_after:wNNNNw - \__int_value:w \__int_eval:w 10#5#6 - #1#2 - \c_eleven + \__int_value:w \__int_eval:w 10#5#6 - #1#2 - 11 \exp_after:wN \@@_sub_back_near_pack:NNNNNNw \__int_value:w \__int_eval:w 11#7#8 - #3#4 \exp_after:wN ; } @@ -594,7 +595,7 @@ \cs_new:Npn \@@_sub_back_shift_ii:ww #1 0 ; #2#3 ; { \if_meaning:w @ #1 @ - - \c_seven + - 7 - \exp_after:wN \use_i:nnn \exp_after:wN \@@_sub_back_shift_iii:NNNNNNNNw \__int_value:w #2#3 0 ~ 123456789; @@ -637,13 +638,14 @@ \if_case:w \if_int_compare:w 1 #2 = #5#6 \use_i:nnnn #7 \exp_stop_f: \if_int_compare:w #3 = \use_none:n #7#8 0 \exp_stop_f: - \c_zero + 0 \else: - \if_int_compare:w #3 > \use_none:n #7#8 0 - \fi: \c_one + \if_int_compare:w #3 > \use_none:n #7#8 0 - \fi: 1 \fi: \else: - \if_int_compare:w 1 #2 > #5#6 \use_i:nnnn #7 - \fi: \c_one + \if_int_compare:w 1 #2 > #5#6 \use_i:nnnn #7 - \fi: 1 \fi: + \exp_stop_f: \exp_after:wN \@@_sub_back_quite_far_o:wwNN \or: \exp_after:wN \@@_sub_back_very_far_o:wwwwNN \else: \exp_after:wN \@@_sub_back_not_far_o:wwwwNN @@ -678,7 +680,7 @@ \exp_after:wN \use_ii:nn \fi: { ; {1000} {0000} {0000} {0000} ; } - { - \c_one ; {9999} {9999} {9999} {9999} ; } + { - 1 ; {9999} {9999} {9999} {9999} ; } } % \end{macrocode} % \end{macro} @@ -687,7 +689,7 @@ % \begin{macro}[aux, rEXP]{\@@_sub_back_not_far_o:wwwwNN} % In the present case, $x$ and $y$ have different exponents, but % $y$~is large enough that $x-y$ has a smaller exponent than~$x$. -% Decrement the exponent (with |- \c_one|). Then proceed in a way +% Decrement the exponent (with |-1|). Then proceed in a way % similar to the \texttt{near} auxiliaries seen earlier, but % multiplying $x$ by~$10$ (|#30| and |#40| below), and with the added % quirk that the \meta{rounding} digit has to be taken into account. @@ -701,9 +703,9 @@ % \begin{macrocode} \cs_new:Npn \@@_sub_back_not_far_o:wwwwNN #1 ~ #2; #3 ~ #4; #5#6 { - - \c_one + - 1 \exp_after:wN \@@_sub_back_near_after:wNNNNw - \__int_value:w \__int_eval:w 1#30 - #1 - \c_eleven + \__int_value:w \__int_eval:w 1#30 - #1 - 11 \exp_after:wN \@@_sub_back_near_pack:NNNNNNw \__int_value:w \__int_eval:w 11 0000 0000 + #40 - #2 - \exp_after:wN \@@_round_neg:NNN @@ -736,7 +738,7 @@ \cs_new:Npn \@@_sub_back_very_far_ii_o:nnNwwNN #1#2 ; #3 ; #4 ~ #5; #6#7 { \exp_after:wN \@@_basics_pack_high:NNNNNw - \__int_value:w \__int_eval:w 1#4 - #1 - \c_one + \__int_value:w \__int_eval:w 1#4 - #1 - 1 \exp_after:wN \@@_basics_pack_low:NNNNNw \__int_value:w \__int_eval:w 2#5 - #2 - \exp_after:wN \@@_round_neg:NNN @@ -767,7 +769,7 @@ { \@@_mul_cases_o:NnNnww * - { - \c_two + } + { - 2 + } \@@_mul_npos_o:Nww { } } @@ -798,24 +800,24 @@ #1#2#3#4 \s_@@ \@@_chk:w #5#6#7; \s_@@ \@@_chk:w #8#9 { \if_case:w \__int_eval:w - \if_int_compare:w #5 #8 = \c_eleven - \c_one + \if_int_compare:w #5 #8 = 11 ~ + 1 \else: \if_meaning:w 3 #8 - \c_three + 3 \else: \if_meaning:w 3 #5 - \c_two + 2 \else: - \if_int_compare:w #5 #8 = \c_ten - \c_nine #2 - \c_two + \if_int_compare:w #5 #8 = 10 ~ + 9 #2 - 2 \else: - (#5 #2 #8) / \c_two * \c_two + \c_seven + (#5 #2 #8) / 2 * 2 + 7 \fi: \fi: \fi: \fi: - \if_meaning:w #6 #9 - \c_one \fi: + \if_meaning:w #6 #9 - 1 \fi: \__int_eval_end: \@@_case_use:nw { #3 0 } \or: \@@_case_use:nw { #3 2 } @@ -974,7 +976,7 @@ % \begin{macrocode} \cs_new:Npn \@@_mul_significand_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7 { - - \c_one + - 1 \exp_after:wN \@@_basics_pack_high:NNNNNw \__int_value:w \__int_eval:w 1#3#4 \exp_after:wN \@@_basics_pack_low:NNNNNw @@ -998,7 +1000,7 @@ % Filtering special floating point is very similar to what we did for % multiplications, with a few variations. Invalid operation % exceptions display |/| rather than |*|. In the formula for -% dispatch, we replace |- \c_two +| by |-|. The case of normal +% dispatch, we replace |- 2 +| by |-|. The case of normal % numbers is treated using \cs{@@_div_npos_o:Nww} rather than % \cs{@@_mul_npos_o:Nww}. There are two additional cases: if the % first operand is normal and the second is a zero, then the division @@ -1049,7 +1051,7 @@ \__int_value:w \__int_eval:w #3 - #6 \exp_after:wN \@@_div_significand_i_o:wnnw - \__int_value:w \__int_eval:w #7 \use_i:nnnn #8 + \c_one ; + \__int_value:w \__int_eval:w #7 \use_i:nnnn #8 + 1 ; #4 {#7}{#8}#9 ; #1 @@ -1404,7 +1406,7 @@ { 0 \exp_after:wN \@@_div_significand_iv:wwnnnnnnn - \__int_value:w \__int_eval:w (\c_two * #2 #3) / #6 #7 ; % <- P + \__int_value:w \__int_eval:w ( 2 * #2 #3) / #6 #7 ; % <- P #2 ; {#3} {#4} {#5} {#6} {#7} } @@ -1461,7 +1463,7 @@ % \begin{macrocode} \cs_new:Npn \@@_div_significand_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9 { - + \c_five * #1 + + 5 * #1 \exp_after:wN \@@_div_significand_vi:Nw \__int_value:w \__int_eval:w -20 + 2*#2#3 - #1*#6#7 + \exp_after:wN \@@_div_significand_v:NN @@ -1473,9 +1475,9 @@ \cs_new:Npn \@@_div_significand_vi:Nw #1#2; { \if_meaning:w 0 #1 - \if_int_compare:w \__int_eval:w #2 > \c_zero + \c_one \fi: + \if_int_compare:w \__int_eval:w #2 > 0 + 1 \fi: \else: - \if_meaning:w - #1 - \else: + \fi: \c_one + \if_meaning:w - #1 - \else: + \fi: 1 \fi: ; } @@ -1565,7 +1567,7 @@ \cs_new:Npn \@@_div_significand_large_o:wwwNNNNwN #1; #2; #3; #4#5#6#7#8; #9 { - + \c_one + + 1 \exp_after:wN \@@_basics_pack_weird_high:NNNNNNNNw \__int_value:w \__int_eval:w 1 #1 #2 \exp_after:wN \@@_basics_pack_weird_low:NNNNw @@ -1621,12 +1623,12 @@ \if_int_odd:w #1 \exp_stop_f: \exp_after:wN \@@_sqrt_npos_auxi_o:wwnnN \fi: - #1 / \c_two + #1 / 2 \@@_sqrt_Newton_o:wwn 56234133; 0; {#2#3} {#4#5} 0 } -\cs_new:Npn \@@_sqrt_npos_auxi_o:wwnnN #1 / \c_two #2; 0; #3#4#5 +\cs_new:Npn \@@_sqrt_npos_auxi_o:wwnnN #1 / 2 #2; 0; #3#4#5 { - ( #1 + \c_one ) / \c_two + ( #1 + 1 ) / 2 \@@_pack_eight:wNNNNNNNN \@@_sqrt_npos_auxii_o:wNNNNNNNN ; @@ -1710,7 +1712,7 @@ \exp_after:wN \@@_use_none_until_s:w \fi: \exp_after:wN \@@_sqrt_Newton_o:wwn - \__int_value:w \__int_eval:w (#1 + #3 * 1 0000 0000 / #1) / \c_two ; + \__int_value:w \__int_eval:w (#1 + #3 * 1 0000 0000 / #1) / 2 ; #1; {#3} } % \end{macrocode} @@ -1880,15 +1882,15 @@ \cs_new:Npn \@@_sqrt_auxiii_o:wnnnnnnnn #1; #2#3#4#5#6#7#8#9 { - \if_int_compare:w #1 > \c_one + \if_int_compare:w #1 > 1 \exp_stop_f: \exp_after:wN \@@_sqrt_auxiv_o:NNNNNw \__int_value:w \__int_eval:w (#1#2 %) \else: - \if_int_compare:w #1#2 > \c_one + \if_int_compare:w #1#2 > 1 \exp_stop_f: \exp_after:wN \@@_sqrt_auxv_o:NNNNNw \__int_value:w \__int_eval:w (#1#2#3 %) \else: - \if_int_compare:w #1#2#3 > \c_one + \if_int_compare:w #1#2#3 > 1 \exp_stop_f: \exp_after:wN \@@_sqrt_auxvi_o:NNNNNw \__int_value:w \__int_eval:w (#1#2#3#4 %) \else: @@ -1906,7 +1908,7 @@ { \@@_sqrt_auxviii_o:nnnnnnn {0000000#1} {#2#3#4#5#6} } \cs_new:Npn \@@_sqrt_auxvii_o:NNNNNw 1#1#2#3#4#5#6; { - \if_int_compare:w #1#2 = \c_zero + \if_int_compare:w #1#2 = 0 \exp_stop_f: \exp_after:wN \@@_sqrt_auxx_o:Nnnnnnnn \fi: \@@_sqrt_auxviii_o:nnnnnnn {00000000} {000#1#2#3#4#5} @@ -1982,7 +1984,7 @@ \@@_sqrt_auxii_o:NnnnnnnnN \@@_sqrt_auxxii_o:nnnnnnnnw #2 {#1} - {#3} { #4 + \c_one } #5 + {#3} { #4 + 1 } #5 } % \end{macrocode} % \end{macro} @@ -2001,11 +2003,11 @@ % \begin{macrocode} \cs_new:Npn \@@_sqrt_auxxii_o:nnnnnnnnw 0; #1#2#3#4#5#6#7#8 #9; { - \if_int_compare:w #1#2 > \c_zero - \if_int_compare:w #1#2 = \c_one - \if_int_compare:w #3#4 = \c_zero - \if_int_compare:w #5#6 = \c_zero - \if_int_compare:w #7#8 = \c_zero + \if_int_compare:w #1#2 > 0 \exp_stop_f: + \if_int_compare:w #1#2 = 1 \exp_stop_f: + \if_int_compare:w #3#4 = 0 \exp_stop_f: + \if_int_compare:w #5#6 = 0 \exp_stop_f: + \if_int_compare:w #7#8 = 0 \exp_stop_f: \@@_sqrt_auxxiii_o:w \fi: \fi: @@ -2055,7 +2057,7 @@ \exp_after:wN \@@_basics_pack_low:NNNNNw \__int_value:w \__int_eval:w 1 0000 0000 + #4#5 - \if_int_compare:w #6 > #1 \exp_stop_f: + \c_one \fi: + \if_int_compare:w #6 > #1 \exp_stop_f: + 1 \fi: + \exp_after:wN \@@_round:NNN \exp_after:wN 0 \exp_after:wN 0 diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx index 728085952a1..fa3fe89a2ac 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-convert.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-convert.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-convert.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point conversion} \begin{document} \DocInput{\jobname.dtx} @@ -124,22 +124,21 @@ % \enquote{invalid_operation} exception. In the normal case, % decrement the exponent and unbrace the $4$ brace groups, then in a % second step grab the first digit (previously hidden in braces) to -% order the various parts correctly. Finally trim zeros. +% order the various parts correctly. % \begin{macrocode} \cs_new:Npn \@@_to_scientific_dispatch:w \s_@@ \@@_chk:w #1#2 { \if_meaning:w 2 #2 \exp_after:wN - \exp:w \exp_end_continue_f:w \fi: \if_case:w #1 \exp_stop_f: - \@@_case_return:nw { 0 } + \@@_case_return:nw { 0.000000000000000e0 } \or: \exp_after:wN \@@_to_scientific_normal:wnnnnn \or: \@@_case_use:nw { - \@@_invalid_operation:nnw + \exp_args:Nf \@@_invalid_operation:nnw { - \exp_after:wN 1 - \exp_after:wN e - \int_use:N \c_@@_max_exponent_int + \@@_expand:n + { { 1.000000000000000e } \int_use:N \c_@@_max_exponent_int } } { fp_to_scientific } } @@ -147,7 +146,7 @@ \@@_case_use:nw { \@@_invalid_operation:nnw - { 0 } + { 0.000000000000000e0 } { fp_to_scientific } } \fi: @@ -156,17 +155,13 @@ \cs_new:Npn \@@_to_scientific_normal:wnnnnn \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; { - \if_int_compare:w #2 = \c_one - \exp_after:wN \@@_to_scientific_normal:wNw - \else: - \exp_after:wN \@@_to_scientific_normal:wNw - \exp_after:wN e - \__int_value:w \__int_eval:w #2 - \c_one - \fi: + \exp_after:wN \@@_to_scientific_normal:wNw + \exp_after:wN e + \__int_value:w \__int_eval:w #2 - 1 ; #3 #4 #5 #6 ; } \cs_new:Npn \@@_to_scientific_normal:wNw #1 ; #2#3; - { \@@_trim_zeros:w #2.#3 ; #1 } + { #2.#3 #1 } % \end{macrocode} % \end{macro} % @@ -239,17 +234,17 @@ \cs_new:Npn \@@_to_decimal_normal:wnnnnn \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; { - \int_compare:nNnTF {#2} > \c_zero + \int_compare:nNnTF {#2} > 0 { - \int_compare:nNnTF {#2} < \c_sixteen + \int_compare:nNnTF {#2} < \c_@@_prec_int { - \@@_decimate:nNnnnn { \c_sixteen - #2 } + \@@_decimate:nNnnnn { \c_@@_prec_int - #2 } \@@_to_decimal_large:Nnnw } { \exp_after:wN \exp_after:wN \exp_after:wN \@@_to_decimal_huge:wnnnn - \prg_replicate:nn { #2 - \c_sixteen } { 0 } ; + \prg_replicate:nn { #2 - \c_@@_prec_int } { 0 } ; } {#3} {#4} {#5} {#6} } @@ -264,7 +259,7 @@ \cs_new:Npn \@@_to_decimal_large:Nnnw #1#2#3#4; { \exp_after:wN \@@_trim_zeros:w \__int_value:w - \if_int_compare:w #2 > \c_zero + \if_int_compare:w #2 > 0 \exp_stop_f: #2 \fi: \exp_stop_f: @@ -290,7 +285,11 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[aux, EXP]{\@@_to_tl_dispatch:w, \@@_to_tl_normal:nnnnn} +% \begin{macro}[aux, EXP] +% { +% \@@_to_tl_dispatch:w, \@@_to_tl_normal:nnnnn, +% \@@_to_tl_scientific:wnnnnn, \@@_to_tl_scientific:wNw +% } % A structure similar to \cs{@@_to_scientific_dispatch:w} and % \cs{@@_to_decimal_dispatch:w}, but without the \enquote{invalid operation} % exception. First filter special cases. We express normal numbers @@ -309,19 +308,22 @@ } \cs_new:Npn \@@_to_tl_normal:nnnnn #1 { - \if_int_compare:w #1 > \c_sixteen - \exp_after:wN \@@_to_scientific_normal:wnnnnn - \else: - \if_int_compare:w #1 < - \c_two - \exp_after:wN \exp_after:wN - \exp_after:wN \@@_to_scientific_normal:wnnnnn - \else: - \exp_after:wN \exp_after:wN - \exp_after:wN \@@_to_decimal_normal:wnnnnn - \fi: - \fi: + \int_compare:nTF + { -2 <= #1 <= \c_@@_prec_int } + { \@@_to_decimal_normal:wnnnnn } + { \@@_to_tl_scientific:wnnnnn } \s_@@ \@@_chk:w 1 0 {#1} } +\cs_new:Npn \@@_to_tl_scientific:wnnnnn + \s_@@ \@@_chk:w 1 #1 #2 #3#4#5#6 ; + { + \exp_after:wN \@@_to_tl_scientific:wNw + \exp_after:wN e + \__int_value:w \__int_eval:w #2 - 1 + ; #3 #4 #5 #6 ; + } +\cs_new:Npn \@@_to_tl_scientific:wNw #1 ; #2#3; + { \@@_trim_zeros:w #2.#3 ; #1 } % \end{macrocode} % \end{macro} % @@ -411,7 +413,7 @@ \@@_case_return:nw { \exp_after:wN \c_zero_fp } \else: \exp_after:wN \@@_from_dim:wNw - \__int_value:w \__int_eval:w #1 - \c_four + \__int_value:w \__int_eval:w #1 - 4 \if_meaning:w - #2 \exp_after:wN , \exp_after:wN 2 \__int_value:w \else: diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx index 5f9a05d834b..d085fd70484 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-expo.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-expo.dtx Copyright (C) 2011-2014,2016 The LaTeX3 Project +%% File: l3fp-expo.dtx Copyright (C) 2011-2014,2016,2017 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 @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-expo.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-expo.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point exponential-related functions} \begin{document} \DocInput{\jobname.dtx} @@ -167,7 +167,7 @@ { %^^A todo: ln(1) should be "exact zero", not "underflow" \exp_after:wN \@@_sanitize:Nw \__int_value:w % for the overall sign - \if_int_compare:w #1 < \c_one + \if_int_compare:w #1 < 1 \exp_stop_f: 2 \else: 0 @@ -198,8 +198,8 @@ \__int_value:w \if_case:w #1 \exp_stop_f: \or: - \if_int_compare:w #2 < \c_four - \__int_eval:w \c_ten - #2 + \if_int_compare:w #2 < 4 \exp_stop_f: + \__int_eval:w 10 - #2 \else: 6 \fi: @@ -236,7 +236,7 @@ { #1#2; {#3#4#5#6} {#7} } \cs_new:Npn \@@_ln_x_iii_var:NNNNNw #1 #2#3#4#5 #6; { - #1#2#3#4#5 + \c_one ; + #1#2#3#4#5 + 1 ; {#1#2#3#4#5} {#6} } % \end{macrocode} @@ -476,7 +476,7 @@ { \@@_ln_Taylor_loop:www 21 ; {0000}{0000}{0000}{0000}{0000}{0000} ; } \cs_new:Npn \@@_ln_Taylor_loop:www #1; #2; #3; { - \if_int_compare:w #1 = \c_one + \if_int_compare:w #1 = 1 \exp_stop_f: \@@_ln_Taylor_break:w \fi: \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl ; #1; @@ -484,7 +484,7 @@ \@@_fixed_mul:wwn #3; { \exp_after:wN \@@_ln_Taylor_loop:www - \__int_value:w \__int_eval:w #1 - \c_two ; + \__int_value:w \__int_eval:w #1 - 2 ; } #3; } @@ -546,11 +546,11 @@ \cs_new:Npn \@@_ln_exponent:wn #1; #2 { \if_case:w #2 \exp_stop_f: - \c_zero \@@_case_return:nw { \@@_fixed_to_float:Nw 2 } + 0 \@@_case_return:nw { \@@_fixed_to_float:Nw 2 } \or: \exp_after:wN \@@_ln_exponent_one:ww \__int_value:w \else: - \if_int_compare:w #2 > \c_zero + \if_int_compare:w #2 > 0 \exp_stop_f: \exp_after:wN \@@_ln_exponent_small:NNww \exp_after:wN 0 \exp_after:wN \@@_fixed_sub:wwn \__int_value:w @@ -568,7 +568,7 @@ % \begin{macrocode} \cs_new:Npn \@@_ln_exponent_one:ww 1; #1; { - \c_zero + 0 \exp_after:wN \@@_fixed_sub:wwn \c_@@_ln_x_fixed_tl ; #1; \@@_fixed_to_float:wN 0 } @@ -580,7 +580,7 @@ % \begin{macrocode} \cs_new:Npn \@@_ln_exponent_small:NNww #1#2#3; #4#5#6#7#8#9; { - \c_four + 4 \exp_after:wN \@@_fixed_mul:wwn \c_@@_ln_x_fixed_tl ; {#3}{0000}{0000}{0000}{0000}{0000} ; @@ -635,29 +635,29 @@ \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 \__int_value:w #1 \__int_eval:w - \if_int_compare:w #4 < - \c_eight - \c_one + \if_int_compare:w #4 < - \c_@@_half_prec_int + 1 \exp_after:wN \@@_add_big_i_o:wNww - \__int_value:w \__int_eval:w \c_one - #4 ; + \__int_value:w \__int_eval:w 1 - #4 ; 0 {1000}{0000}{0000}{0000} ; #5; \exp:w \else: - \if_int_compare:w #4 > \c_five % cf \c_@@_max_exponent_int + \if_int_compare:w #4 > \c_@@_max_exp_exponent_int \exp_after:wN \@@_exp_overflow: \exp:w \else: - \if_int_compare:w #4 < \c_zero + \if_int_compare:w #4 < 0 \exp_stop_f: \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: { - \c_zero + 0 \@@_decimate:nNnnnn { - #4 } \@@_exp_Taylor:Nnnwn } { - \@@_decimate:nNnnnn { \c_sixteen - #4 } + \@@_decimate:nNnnnn { \c_@@_prec_int - #4 } \@@_exp_pos_large:NnnNwn } #5 @@ -666,10 +666,10 @@ \exp:w \fi: \fi: - \exp_after:wN \c_zero + \exp_after:wN \exp_end: } \cs_new:Npn \@@_exp_overflow: - { + \c_two * \c_@@_max_exponent_int ; {1000} {0000} {0000} {0000} ; } + { + 2 * \c_@@_max_exponent_int ; {1000} {0000} {0000} {0000} ; } % \end{macrocode} % \end{macro} % @@ -695,7 +695,7 @@ { \@@_exp_Taylor_loop:www 10 ; #1 ; #1 ; \s__stop } \cs_new:Npn \@@_exp_Taylor_loop:www #1; #2; #3; { - \if_int_compare:w #1 = \c_one + \if_int_compare:w #1 = 1 \exp_stop_f: \exp_after:wN \@@_exp_Taylor_break:Nww \fi: \@@_fixed_div_int:wwN #3 ; #1 ; @@ -861,28 +861,31 @@ % \subsection{Power} % % Raising a number $a$ to a power $b$ leads to many distinct situations. -% \begin{center} +% \begin{center}\def\abs#1{\lvert #1\rvert} % \begin{tabular}{>{$}c<{$}|*8{>{$}l<{$}}} -% a^b &-\infty&-y &-n &\pm 0&+n &+y &+\infty&\nan \\ -% \hline -% +\infty&+0 &+0 &+0 &+1&+\infty &+\infty&+\infty&\nan \\ -% 1<x &+0 &+x^{-y}&+x^{-n} &+1&+x^{n} &+x^{y} &+\infty&\nan \\ -% +1 &+1 &+1 &+1 &+1&+1 &+1 &+1 &+1 \\ -% 0<x<1 &+\infty&+x^{-y}&+x^{-n} &+1&+x^{n} &+x^{y} &+0 &\nan \\ -% +0 &+\infty&+\infty&+\infty &+1&+0 &+0 &+0 &\nan \\ -% -0 &\nan &\nan &\pm\infty &+1&\pm 0 &+0 &+0 &\nan \\ -% -1<-x<0&\nan &\nan &\pm x^{-n}&+1&\pm x^{n}&\nan &+0 &\nan \\ -% -1 &\nan &\nan &\pm 1 &+1&\pm 1 &\nan &\nan &\nan \\ -% -x<-1 &+0 &\nan &\pm x^{-n}&+1&\pm x^{n}&\nan &\nan &\nan \\ -% -\infty&+0 &+0 &\pm 0 &+1&\pm\infty&\nan &\nan &\nan \\ -% \nan &\nan &\nan &\nan &+1&\nan &\nan &\nan &\nan \\ +% a^b &-\infty &(-\infty,-0) &-p/5^k &\pm 0 &+p/5^k &(0,\infty) &+\infty &\nan \\ \hline +% +\infty &+0 &\multicolumn{2}{c}{$+0$} &+1 &\multicolumn{2}{c}{$+\infty$} &+\infty &\nan \\ +% (1,\infty) &+0 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+1 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+\infty &\nan \\ +% +1 &+1 &\multicolumn{2}{c}{$+1$} &+1 &\multicolumn{2}{c}{$+1$} &+1 &+1 \\ +% (0,1) &+\infty &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+1 &\multicolumn{2}{c}{$+\abs{a}^{b}$} &+0 &\nan \\ +% +0 &+\infty &\multicolumn{2}{c}{$+\infty$} &+1 &\multicolumn{2}{c}{$+0$} &+0 &\nan \\ +% -0 &+\infty &\nan &(-1)^p\infty &+1 &(-1)^p 0 &+0 &+0 &\nan \\ +% (-1,0) &+\infty &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &+0 &\nan \\ +% -1 &+1 &\nan &(-1)^p &+1 &(-1)^p &\nan &+1 &\nan \\ +% (-\infty,-1) &+0 &\nan &(-1)^p\abs{a}^{b} &+1 &(-1)^p\abs{a}^{b} &\nan &+\infty &\nan \\ +% -\infty &+0 &+0 &(-1)^p 0 &+1 &(-1)^p\infty &\nan &+\infty &\nan \\ +% \nan &\nan &\nan &\nan &+1 &\nan &\nan &\nan &\nan \\ % \end{tabular} % \end{center} +% We distinguished in this table the cases of finite (positive or +% negative) exponents of the form $b=p/q$ with $q$~odd (hence +% necessarily a power of~$5$), as $(-1)^{p/q}=(-1)^p$ is defined in that +% case. % One peculiarity of this operation is that $\nan^0 = 1^\nan = 1$, % because this relation is obeyed for any number, even $\pm\infty$. % % \begin{macro}[int, EXP]+\@@_^_o:ww+ -% We cram a most of the tests into a single function to save csnames. +% We cram most of the tests into a single function to save csnames. % First treat the case $b=0$: $a^0=1$ for any $a$, even \texttt{nan}. % Then test the sign of $a$. % \begin{itemize} @@ -935,9 +938,9 @@ % power or $\infty$ to a negative power, and $+\infty$ otherwise. % Thus, if the type of $a$ and the sign of $b$ coincide, the result % is~$0$, since those conveniently take the same possible values, $0$ -% and~$2$. Otherwise, either $a=\pm 0$ with $b<0$ and we have a -% division by zero, or $a=\pm\infty$ and $b>0$ and the result is also -% $+\infty$, but without any exception. +% and~$2$. Otherwise, either $a=\pm\infty$ and $b>0$ and the result +% is $+\infty$, or $a=\pm 0$ with $b<0$ and we have a division by zero +% unless $b=-\infty$. % \begin{macrocode} \cs_new:Npn \@@_pow_zero_or_inf:ww \s_@@ \@@_chk:w #1#2; \s_@@ \@@_chk:w #3#4 @@ -948,14 +951,17 @@ \if_meaning:w #1 #4 \@@_case_return_o:Nw \c_zero_fp \fi: - \if_meaning:w 0 #1 + \if_meaning:w 2 #1 + \@@_case_return_o:Nw \c_inf_fp + \fi: + \if_meaning:w 2 #3 + \@@_case_return_o:Nw \c_inf_fp + \else: \@@_case_use:nw { \@@_division_by_zero_o:NNww \c_inf_fp ^ \s_@@ \@@_chk:w #1 #2 ; } - \else: - \@@_case_return_o:Nw \c_inf_fp \fi: \s_@@ \@@_chk:w #3#4 } @@ -981,7 +987,7 @@ \s_@@ \@@_chk:w 1 #1#2#3; \s_@@ \@@_chk:w #4#5 { \if_int_compare:w \__str_if_eq_x:nn { #2 #3 } - { 1 {1000} {0000} {0000} {0000} } = \c_zero + { 1 {1000} {0000} {0000} {0000} } = 0 \exp_stop_f: \if_int_compare:w #4 #1 = 32 \exp_stop_f: \exp_after:wN \@@_case_return_ii_o:ww \fi: @@ -993,7 +999,7 @@ \exp_after:wN #5 \or: \if_meaning:w 2 #5 \exp_after:wN \reverse_if:N \fi: - \if_int_compare:w #2 > \c_zero + \if_int_compare:w #2 > 0 \exp_stop_f: \exp_after:wN \@@_case_return_o:Nww \exp_after:wN \c_inf_fp \else: @@ -1028,7 +1034,7 @@ \exp_after:wN \@@_sanitize:Nw \exp_after:wN 0 \__int_value:w - \if:w #1 \if_int_compare:w #3 > \c_zero 0 \else: 2 \fi: + \if:w #1 \if_int_compare:w #3 > 0 \exp_stop_f: 0 \else: 2 \fi: \exp_after:wN \@@_pow_npos_aux:NNnww \exp_after:wN + \exp_after:wN \@@_fixed_to_float:wN @@ -1060,7 +1066,7 @@ } \cs_new:Npn \@@_pow_exponent:wnN #1; #2 { - \if_int_compare:w #2 > \c_zero + \if_int_compare:w #2 > 0 \exp_stop_f: \exp_after:wN \@@_pow_exponent:Nwnnnnnw % n\ln(10) - (-\ln(x)) \exp_after:wN + \else: @@ -1092,7 +1098,7 @@ } \cs_new:Npn \@@_pow_B:wwN #1#2#3#4#5#6; #7; { - \if_int_compare:w #7 < \c_zero + \if_int_compare:w #7 < 0 \exp_stop_f: \exp_after:wN \@@_pow_C_neg:w \__int_value:w - \else: \if_int_compare:w #7 < 22 \exp_stop_f: @@ -1107,7 +1113,7 @@ } \cs_new:Npn \@@_pow_C_overflow:w #1; #2; #3 { - + \c_two * \c_@@_max_exponent_int + + 2 * \c_@@_max_exponent_int \exp_after:wN \@@_fixed_continue:wn \c_@@_one_fixed_tl ; } \cs_new:Npn \@@_pow_C_neg:w #1 ; 1 @@ -1128,7 +1134,7 @@ \else: \exp_after:wN \@@_pow_C_overflow:w \__int_value:w \fi: - \__int_eval:w #1 - \c_one \exp_after:wN ; + \__int_eval:w #1 - 1 \exp_after:wN ; \fi: } \cs_new:Npn \@@_pow_C_pack:w @@ -1145,7 +1151,7 @@ % undefined. This is invalid, unless $|a|^b$ turns out to be $+0$ or % \texttt{nan}, in which case we return that as $a^b$. In particular, % since the underflow detection occurs before \cs{@@_pow_neg:www} is -% called, |(-0.1)**(12345.6)| will give $+0$ rather than complaining +% called, |(-0.1)**(12345.67)| will give $+0$ rather than complaining % that the sign is not defined. % \begin{macrocode} \cs_new:Npn \@@_pow_neg:www \s_@@ \@@_chk:w #1#2; #3; #4; @@ -1153,7 +1159,7 @@ \if_case:w \@@_pow_neg_case:w #4 ; \exp_after:wN \@@_pow_neg_aux:wNN \or: - \if_int_compare:w \__int_eval:w #1 / \c_two = \c_one + \if_int_compare:w \__int_eval:w #1 / 2 = 1 \exp_stop_f: \@@_invalid_operation_o:Nww ^ #3; #4; \exp:w \exp_end_continue_f:w \exp_after:wN \exp_after:wN @@ -1169,7 +1175,7 @@ \exp_after:wN \s_@@ \exp_after:wN \@@_chk:w \exp_after:wN #2 - \__int_value:w \__int_eval:w \c_two - #3 \__int_eval_end: + \__int_value:w \__int_eval:w 2 - #3 \__int_eval_end: } % \end{macrocode} % ^^A todo: is this \@@_exp_after_o:w necessary? Appropriate? @@ -1178,66 +1184,53 @@ % \begin{macro}[aux, rEXP] % { % \@@_pow_neg_case:w, \@@_pow_neg_case_aux:nnnnn, -% \@@_pow_neg_case_aux:NNNNNNNNw +% \@@_pow_neg_case_aux:w % } -% This function expects a floating point number, and \enquote{returns} -% $-1$ if it is an even integer, $0$ if it is an odd integer, and $1$ -% if it is not an integer. Zeros are even, $\pm\infty$ and -% \texttt{nan} are non-integers. The sign of normal numbers is -% irrelevant to parity. If the exponent is greater than sixteen, then -% the number is even. If the exponent is non-positive, the number -% cannot be an integer. We also separate the ranges of exponent -% $[1,8]$ and $[9,16]$. In the former case, check that the last $8$ -% digits are zero (otherwise we don't have an integer). In both -% cases, consider the appropriate $8$ digits, either |#4#5| or |#2#3|, -% remove the first few: we are then left with \meta{digit} -% \meta{digits} |;| which would be the digits surrounding the decimal -% period. If the \meta{digits} are non-zero, the number is not an -% integer. Otherwise, check the parity of the \meta{digit} and return -% \cs{c_zero} or |-|\cs{c_one}. +% This function expects a floating point number, and determines its +% \enquote{parity}. It should be used after \cs{if_case:w} or in an +% integer expression. It gives $-1$ if the number is an even integer +% divided by some power of~$5$, $0$~if the number is an odd integer +% divided by some power of~$5$, and $1$~otherwise. Zeros and +% $\pm\infty$ are even (because very large finite floating points are +% even), while \texttt{nan} is a non-integer. The sign of normal +% numbers is irrelevant to parity. The idea is to repeatedly multiply +% the number by~$5$ (by halving the mantissa and shifting the +% exponent) until the mantissa is odd (this can only happen at most +% $53$ times since $2^{54}>10^{16}$): if the resulting exponent is +% larger than $16$ the parity is even, if it is exactly $16$ the +% parity is odd, and otherwise we should return~$1$. Of course there +% is a shortcut: we stop as soon as the exponent exceeds~$16$. % \begin{macrocode} \cs_new:Npn \@@_pow_neg_case:w \s_@@ \@@_chk:w #1#2#3; { \if_case:w #1 \exp_stop_f: - -\c_one + -1 \or: \@@_pow_neg_case_aux:nnnnn #3 - \else: \c_one + \or: -1 + \else: 1 \fi: + \exp_stop_f: } \cs_new:Npn \@@_pow_neg_case_aux:nnnnn #1#2#3#4#5 + { \@@_pow_neg_case_aux:w #1 ; #2 #3 ; #4 #5 ; } +\cs_new:Npn \@@_pow_neg_case_aux:w #1 ; #2 ; #3 ; { - \if_int_compare:w #1 > \c_eight - \if_int_compare:w #1 > \c_sixteen - -\c_one - \else: - \exp_after:wN \exp_after:wN - \exp_after:wN \@@_pow_neg_case_aux:NNNNNNNNw - \prg_replicate:nn { \c_sixteen - #1 } { 0 } #4#5 ; - \fi: + \if_int_compare:w #1 > \c_@@_prec_int + -1 \else: - \if_int_compare:w #1 > \c_zero - \if_int_compare:w #4#5 = \c_zero - \exp_after:wN \exp_after:wN - \exp_after:wN \@@_pow_neg_case_aux:NNNNNNNNw - \prg_replicate:nn { \c_eight - #1 } { 0 } #2#3 ; + \if_int_odd:w #3 \exp_stop_f: + \if_int_compare:w #1 = \c_@@_prec_int + 0 \else: - \c_one + 1 \fi: \else: - \c_one - \fi: - \fi: - } -\cs_new:Npn \@@_pow_neg_case_aux:NNNNNNNNw #1#2#3#4#5#6#7#8#9; - { - \if_int_compare:w 0 #9 = \c_zero - \if_int_odd:w #8 \exp_stop_f: - \c_zero - \else: - -\c_one + \exp_after:wN \@@_pow_neg_case_aux:w + \__int_value:w \__int_eval:w #1 + 1 \exp_after:wN ; + \__int_value:w \__int_eval:w (#2 + 1) / 2 - 1 \exp_after:wN ; + \__int_value:w \__int_eval:w + \if_int_odd:w #2 \exp_stop_f: 5000 0000 + \fi: #3 / 2 ; \fi: - \else: - \c_one \fi: } % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx index 1e8fe4b7cb5..59f734632b4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-extended.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-extended.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-extended.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-points with extended precision} \begin{document} \DocInput{\jobname.dtx} @@ -140,7 +140,7 @@ \cs_new:Npn \@@_fixed_add_one:wN #1#2; #3 { \exp_after:wN #3 \exp_after:wN - { \__int_value:w \__int_eval:w \c_ten_thousand + #1 } #2 ; + { \__int_value:w \__int_eval:w \c_@@_myriad_int + #1 } #2 ; } % \end{macrocode} % \end{macro} @@ -213,8 +213,8 @@ \exp_after:wN \@@_pack:NNNNNw \__int_value:w \__int_eval:w \c_@@_trailing_shift_int + #4*#9 + #5*#8 + #6*#7 - + ( #5*#9 + #6*#8 + #6*#9 / \c_ten_thousand ) - / \c_ten_thousand ; ; + + ( #5*#9 + #6*#8 + #6*#9 / \c_@@_myriad_int ) + / \c_@@_myriad_int ; ; } % \end{macrocode} % \end{macro} @@ -276,7 +276,7 @@ { \exp_after:wN \@@_fixed_div_int_after:Nw \exp_after:wN #8 - \__int_value:w \__int_eval:w - \c_one + \__int_value:w \__int_eval:w - 1 \@@_fixed_div_int:wnN #1; {#7} \@@_fixed_div_int_auxi:wnn #2; {#7} \@@_fixed_div_int_auxi:wnn @@ -288,7 +288,7 @@ \cs_new:Npn \@@_fixed_div_int:wnN #1; #2 #3 { \exp_after:wN #3 - \__int_value:w \__int_eval:w #1 / #2 - \c_one ; + \__int_value:w \__int_eval:w #1 / #2 - 1 ; {#2} {#1} } @@ -300,7 +300,7 @@ \exp_after:wN \@@_fixed_div_int:wnN \__int_value:w \__int_eval:w #3 - #1*#2 \__int_eval_end: } -\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1; #2 #3 { + #1 + \c_two ; } +\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1; #2 #3 { + #1 + 2 ; } \cs_new:Npn \@@_fixed_div_int_pack:Nw #1 #2; { + #1; {#2} } \cs_new:Npn \@@_fixed_div_int_after:Nw #1 #2; { #1 {#2} } % \end{macrocode} @@ -430,7 +430,7 @@ } \cs_new:Npn \@@_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 ; { - #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c_ten_thousand + #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c_@@_myriad_int + #1*#3 + #5*#7 ; ; } % \end{macrocode} @@ -612,7 +612,7 @@ \cs_new:Npn \@@_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5; #6#7#8; #9 { #9 (#4* #1 *#7) - #9 (#5*#6+#4* #2 *#7+#3*#8) / \c_ten_thousand + #9 (#5*#6+#4* #2 *#7+#3*#8) / \c_@@_myriad_int } % \end{macrocode} % \end{macro} @@ -639,7 +639,7 @@ \exp_after:wN \@@_ep_to_fixed_auxi:www \__int_value:w \__int_eval:w 1 0000 0000 + #2 \exp_after:wN ; \exp:w \exp_end_continue_f:w - \prg_replicate:nn { \c_four - \int_max:nn {#1} { -32 } } { 0 } ; + \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } ; } \cs_new:Npn \@@_ep_to_fixed_auxi:www 1#1; #2; #3#4#5#6#7; { @@ -678,7 +678,7 @@ \cs_new:Npn \@@_ep_to_ep:wwN #1,#2#3#4#5#6#7; #8 { \exp_after:wN #8 - \__int_value:w \__int_eval:w #1 + \c_four + \__int_value:w \__int_eval:w #1 + 4 \exp_after:wN \use_i:nn \exp_after:wN \@@_ep_to_ep_loop:N \__int_value:w \__int_eval:w 1 0000 0000 + #2 \__int_eval_end: @@ -687,7 +687,7 @@ \cs_new:Npn \@@_ep_to_ep_loop:N #1 { \if_meaning:w 0 #1 - - \c_one + - 1 \else: \@@_ep_to_ep_end:www #1 \fi: @@ -698,7 +698,7 @@ { \fi: \if_meaning:w ; #1 - - \c_two * \c_@@_max_exponent_int + - 2 * \c_@@_max_exponent_int \@@_ep_to_ep_zero:ww \fi: \@@_pack_twice_four:wNNNNNNNN @@ -938,9 +938,9 @@ \cs_new:Npn \@@_ep_div_esti:wwwwn #1,#2#3; #4, { \exp_after:wN \@@_ep_div_estii:wwnnwwn - \__int_value:w \__int_eval:w 10 0000 0000 / ( #2 + \c_one ) + \__int_value:w \__int_eval:w 10 0000 0000 / ( #2 + 1 ) \exp_after:wN ; - \__int_value:w \__int_eval:w #4 - #1 + \c_one , + \__int_value:w \__int_eval:w #4 - #1 + 1 , {#2} #3; } \cs_new:Npn \@@_ep_div_estii:wwnnwwn #1; #2,#3#4#5; #6; #7 @@ -1057,8 +1057,8 @@ \exp_after:wN \@@_ep_isqrt_auxii:wwnnnwn \__int_value:w \__int_eval:w \int_if_odd:nTF {#1} - { (\c_one - #1) / \c_two , 535 , { 0 } { } } - { \c_one - #1 / \c_two , 168 , { } { 0 } } + { (1 - #1) / 2 , 535 , { 0 } { } } + { 1 - #1 / 2 , 168 , { } { 0 } } } \cs_new:Npn \@@_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6; #7 { @@ -1099,13 +1099,13 @@ \fi: \exp_after:wN \@@_ep_isqrt_esti:wwwnnwn \__int_value:w \__int_eval:w - (#1 + 1 0050 0000 #4 / (#1 * #3)) / \c_two , + (#1 + 1 0050 0000 #4 / (#1 * #3)) / 2 , #1, #3, {#4} } \cs_new:Npn \@@_ep_isqrt_estii:wwwnnwn #1, #2, #3, #4#5 { \exp_after:wN \@@_ep_isqrt_estiii:NNNNNwwwn - \__int_value:w \__int_eval:w 1000 0000 + #2 * #2 #5 * \c_five + \__int_value:w \__int_eval:w 1000 0000 + #2 * #2 #5 * 5 \exp_after:wN , \__int_value:w \__int_eval:w 10000 + #2 ; } \cs_new:Npn \@@_ep_isqrt_estiii:NNNNNwwwn 1#1#2#3#4#5#6, 1#7#8; #9; @@ -1207,7 +1207,7 @@ \cs_new:Npn \@@_fixed_to_float:Nw #1#2; { \@@_fixed_to_float:wN #2; #1 } \cs_new:Npn \@@_fixed_to_float:wN #1#2#3#4#5#6; #7 { - + \__int_eval:w \c_four % for the 8-digit-at-the-start thing. + + \__int_eval:w \c_@@_block_int % for the 8-digit-at-the-start thing. \exp_after:wN \exp_after:wN \exp_after:wN \@@_fixed_to_loop:N \exp_after:wN \use_none:n @@ -1222,7 +1222,7 @@ \cs_new:Npn \@@_fixed_to_loop:N #1 { \if_meaning:w 0 #1 - - \c_one + - 1 \exp_after:wN \@@_fixed_to_loop:N \else: \exp_after:wN \@@_fixed_to_loop_end:w @@ -1243,12 +1243,12 @@ } \cs_new:Npn \@@_fixed_to_float_zero:w ; 0000 0000 0000 0000 ; { - - \c_two * \c_@@_max_exponent_int ; + - 2 * \c_@@_max_exponent_int ; {0000} {0000} {0000} {0000} ; } \cs_new:Npn \@@_fixed_to_float_pack:ww #1 ; #2#3 ; ; { - \if_int_compare:w #2 > \c_four + \if_int_compare:w #2 > 4 \exp_stop_f: \exp_after:wN \@@_fixed_to_float_round_up:wnnnnw \fi: ; #1 ; @@ -1258,7 +1258,7 @@ \exp_after:wN \@@_basics_pack_high:NNNNNw \__int_value:w \__int_eval:w 1 #1#2 \exp_after:wN \@@_basics_pack_low:NNNNNw - \__int_value:w \__int_eval:w 1 #3#4 + \c_one ; + \__int_value:w \__int_eval:w 1 #3#4 + 1 ; } % \end{macrocode} % \end{macro} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx index fa1b7538c83..3beb67d2dc4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-logic.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-logic.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Floating-point conditionals} \begin{document} \DocInput{\jobname.dtx} @@ -170,7 +170,7 @@ \if_int_compare:w #4 < #1 - \fi: 1 \fi: \else: - \if_int_compare:w #1#4 = \c_zero + \if_int_compare:w #1#4 = 0 \exp_stop_f: 0 \else: 1 @@ -178,7 +178,7 @@ \fi: \exp_stop_f: } -\cs_new:Npn \@@_compare_nan:w #1 \exp_stop_f: { \c_two } +\cs_new:Npn \@@_compare_nan:w #1 \fi: \exp_stop_f: { 2 \exp_stop_f: } % \end{macrocode} % \end{macro} % @@ -445,7 +445,7 @@ \@@_compare_back:ww \s_@@ \@@_chk:w #4#5; \s_@@ \@@_chk:w #2#3; - = #1 \c_one + = #1 1 \exp_stop_f: \@@_minmax_auxii:ww \else: \@@_minmax_auxi:ww @@ -570,12 +570,12 @@ \cs_new:Npn \@@_ternary_loop_break:w #1 \fi: #2 \@@_ternary_break_point:n #3 { - \c_zero = \c_zero \fi: + 0 = 0 \exp_stop_f: \fi: \exp_after:wN \@@_ternary_auxii:NwwN } \cs_new:Npn \@@_ternary_loop:Nw \s_@@ \@@_chk:w #1#2; { - \if_int_compare:w #1 > \c_zero + \if_int_compare:w #1 > 0 \exp_stop_f: \exp_after:wN \@@_ternary_map_break: \fi: \@@_ternary_loop:Nw diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index 5fe3aaac4d9..1aa0956212d 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-parse.dtx 6877 2017-02-10 03:59:09Z bruno $ +\GetIdInfo$Id: l3fp-parse.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point expression parsing} \begin{document} \DocInput{\jobname.dtx} @@ -195,17 +195,17 @@ % already found, |12345|. This integer is unfinished, causing the % second \cs{exp_after:wN} to expand, and to trigger the construction % \cs{exp:w}, which expands |\operand:w|, defined to read -% what follows and make a number out of it, then leave \cs{c_zero}, the +% what follows and make a number out of it, then leave \cs{exp_end:}, the % number, and a semicolon in the input stream. Once |\operand:w| is % done expanding, we obtain essentially % \begin{quote}\ttfamily % \cs{exp_after:wN} |\add:ww| \cs{__int_value:w} 12345 ; \newline -% \cs{exp:w} \cs{c_zero} 333444 ; +% \cs{exp:w} \cs{exp_end:} 333444 ; % \end{quote} % where in fact \cs{exp_after:wN} has already been expanded, % \cs{__int_value:w} has already seen |12345|, and % \cs{exp:w} is still looking for a number. It finds -% \cs{c_zero}, hence expands to nothing. Now, \cs{__int_value:w} sees +% \cs{exp_end:}, hence expands to nothing. Now, \cs{__int_value:w} sees % the \texttt{;}, which cannot be part of a number. The expansion % stops, and we are left with % \begin{quote}\ttfamily @@ -499,33 +499,33 @@ % \item If the next token is a control sequence, it could be the % special marker \cs{s_@@_mark}, and % otherwise it is a case of juxtaposing numbers, such as -% |2\c_three|, with an implied multiplication. +% |2\c_zero|, with an implied multiplication. % \item If the next token is a letter, it is also a case of % juxtaposition, as letters cannot be proper infix operators. % \item Otherwise (including in the case of digits), if the token is a % known infix operator, the appropriate % |\__fp_infix_|\meta{operator}|:N| function is built, and if it % does not exist, we complain. In particular, the juxtaposition -% |\c_three 2| is disallowed. +% |\c_zero 2| is disallowed. % \end{itemize} % % In the above, we need to test whether a character token~|#1| is a % digit: % \begin{verbatim} -% \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: +% \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: % is a digit % \else: % not a digit % \fi: % \end{verbatim} -% To exclude |0|, replace \cs{c_nine} by \cs{c_ten}. The use of +% To exclude |0|, replace |9| by |10|. The use of % \cs{token_to_str:N} ensures that a digit with any catcode is detected. % To test if a character token is a letter, we need to work with its % character code, testing if |`#1| lies in $[65,90]$ (uppercase letters) % or $[97,112]$ (lowercase letters) % \begin{verbatim} % \if_int_compare:w \__int_eval:w -% ( `#1 \if_int_compare:w `#1 > `Z - 32 \fi: ) / 26 = \c_three +% ( `#1 \if_int_compare:w `#1 > `Z - 32 \fi: ) / 26 = 3 \exp_stop_f: % is a letter % \else: % not a letter @@ -698,7 +698,7 @@ { \cs_new:cpn { @@_parse_digits_ #1 :N } ##1 { - \if_int_compare:w \c_nine < 1 \token_to_str:N ##1 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N ##1 \exp_stop_f: \token_to_str:N ##1 \exp_after:wN #2 \exp:w \else: \@@_parse_return_semicolon:w #3 ##1 @@ -745,7 +745,7 @@ \exp_after:wN \@@_parse_one_register:NN \fi: \else: - \if_int_compare:w \c_nine < 1 \token_to_str:N #2 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f: \exp_after:wN \exp_after:wN \exp_after:wN \@@_parse_one_digit:NN \else: @@ -940,7 +940,7 @@ \exp_after:wN #1 \exp:w \exp_end_continue_f:w \exp_after:wN \@@_sanitize:wN - \__int_value:w \__int_eval:w \c_zero \@@_parse_trim_zeros:N + \__int_value:w \__int_eval:w 0 \@@_parse_trim_zeros:N } % \end{macrocode} % \end{macro} @@ -956,8 +956,8 @@ { \if_int_compare:w \__int_eval:w - ( `#2 \if_int_compare:w `#2 > `Z - \c_thirty_two \fi: ) / 26 - = \c_three + ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26 + = 3 \exp_stop_f: \exp_after:wN \@@_parse_word:Nw \exp_after:wN #1 \exp_after:wN #2 @@ -1005,13 +1005,12 @@ \exp_end_continue_f:w \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #1 - \c_zero + 0 \else: \__int_eval:w - ( `#1 \if_int_compare:w `#1 > `Z - \c_thirty_two \fi: ) - / 26 + ( `#1 \if_int_compare:w `#1 > `Z - 32 \fi: ) / 26 \fi: - = \c_three + = 3 \exp_stop_f: \exp_after:wN #1 \exp:w \exp_after:wN \@@_parse_letters:N \exp:w @@ -1100,7 +1099,7 @@ { \fi: \fi: - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: \exp_after:wN \@@_parse_large:N \else: \exp_after:wN \@@_parse_zero: @@ -1123,7 +1122,7 @@ \cs_new:Npn \@@_parse_strim_zeros:N #1 { \if:w 0 \exp_not:N #1 - - \c_one + - 1 \exp_after:wN \@@_parse_strim_zeros:N \exp:w \else: \@@_parse_strim_end:w #1 @@ -1133,7 +1132,7 @@ \cs_new:Npn \@@_parse_strim_end:w #1 \fi: \@@_parse_expand:w { \fi: - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: \exp_after:wN \@@_parse_small:N \else: \exp_after:wN \@@_parse_zero: @@ -1191,7 +1190,7 @@ % We leave \meta{digits} \meta{zeros} in the input stream: the % functions used to grab digits are such that this constitutes digits % $1$ through~$8$ of the significand. Then prepare to pack $8$~more -% digits, with an exponent shift of \cs{c_zero} (this shift is used in +% digits, with an exponent shift of zero (this shift is used in % the case of a large significand). If |#4|~is a digit, leave it % behind for the packing function, and read $6$~more digits to reach a % total of $15$~digits: further digits are involved in the rounding. @@ -1202,9 +1201,9 @@ { #1 #2 \exp_after:wN \@@_parse_pack_trailing:NNNNNNww - \exp_after:wN \c_zero + \exp_after:wN 0 \__int_value:w \__int_eval:w 1 - \if_int_compare:w \c_nine < 1 \token_to_str:N #4 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: \token_to_str:N #4 \exp_after:wN \@@_parse_small_trailing:wwNN \__int_value:w 1 @@ -1226,14 +1225,14 @@ % stream. If the \meta{next~token} is a digit, it is the $16$th % digit, we keep it, then the \texttt{small_round} auxiliary considers % this digit and all further digits to perform the rounding: the -% function expands to nothing, to |+\c_zero| or to |+\c_one|. +% function expands to nothing, to |+0| or to |+1|. % Otherwise, there is no $16$-th digit, so we put a~$0$, and look for % an exponent. % \begin{macrocode} \cs_new:Npn \@@_parse_small_trailing:wwNN 1 #1 ; #2; #3 #4 { #1 #2 - \if_int_compare:w \c_nine < 1 \token_to_str:N #4 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: \token_to_str:N #4 \exp_after:wN \@@_parse_small_round:NN \exp_after:wN #4 @@ -1260,7 +1259,7 @@ % argument is~$2$. The \texttt{trailing} function has an exponent % shift as its first argument, which we add to the exponent found in % the |e...| syntax. If the trailing digits cause a carry, the -% integer expression for the leading digits is incremented (|+ \c_one| +% integer expression for the leading digits is incremented (|+1| % in the code below). If the leading digits propagate this carry all % the way up, the function \cs{@@_parse_pack_carry:w} increments the % exponent, and changes the significand from |0000...| to |1000...|: @@ -1269,7 +1268,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_pack_trailing:NNNNNNww #1 #2 #3#4#5#6 #7; #8 ; { - \if_meaning:w 2 #2 + \c_one \fi: + \if_meaning:w 2 #2 + 1 \fi: ; #8 + #1 ; {#3#4#5#6} {#7}; } \cs_new:Npn \@@_parse_pack_leading:NNNNNww #1 #2#3#4#5 #6; #7; @@ -1279,7 +1278,7 @@ ; 0 {#2#3#4#5} {#6} } \cs_new:Npn \@@_parse_pack_carry:w \fi: ; 0 #1 - { \fi: + \c_one ; 0 {1000} } + { \fi: + 1 ; 0 {1000} } % \end{macrocode} % \end{macro} % @@ -1325,10 +1324,10 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_large_leading:wwNN 1 #1 ; #2; #3 #4 { - + \c_eight - #3 + + \c_@@_half_prec_int - #3 \exp_after:wN \@@_parse_pack_leading:NNNNNww \__int_value:w \__int_eval:w 1 #1 - \if_int_compare:w \c_nine < 1 \token_to_str:N #4 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: \exp_after:wN \@@_parse_large_trailing:wwNN \__int_value:w 1 \token_to_str:N #4 \exp_after:wN \@@_parse_digits_vi:N @@ -1346,7 +1345,7 @@ \else: #2 \exp_after:wN \@@_parse_pack_trailing:NNNNNNww - \exp_after:wN \c_zero + \exp_after:wN 0 \__int_value:w 1 0000 0000 \@@_parse_exponent:Nw #4 \fi: @@ -1376,16 +1375,16 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_large_trailing:wwNN 1 #1 ; #2; #3 #4 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #4 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #4 \exp_stop_f: \exp_after:wN \@@_parse_pack_trailing:NNNNNNww - \exp_after:wN \c_eight + \exp_after:wN \c_@@_half_prec_int \__int_value:w \__int_eval:w 1 #1 \token_to_str:N #4 \exp_after:wN \@@_parse_large_round:NN \exp_after:wN #4 \exp:w \else: \exp_after:wN \@@_parse_pack_trailing:NNNNNNww - \__int_value:w \__int_eval:w \c_seven - #3 \exp_stop_f: + \__int_value:w \__int_eval:w 7 - #3 \exp_stop_f: \__int_value:w \__int_eval:w 1 #1 \if:w . \exp_not:N #4 \exp_after:wN \@@_parse_small_trailing:wwNN @@ -1412,15 +1411,15 @@ % small or large). It should appear in an integer expression. This % function reads digits one by one, until reaching a non-digit, and % adds~$1$ to the integer expression for each digit. If all digits -% found are~$0$, the function ends the expression by |;\c_zero|, -% otherwise by |;\c_one|. This is done by switching the loop to +% found are~$0$, the function ends the expression by |;0|, +% otherwise by |;1|. This is done by switching the loop to % |round_up| at the first non-zero digit, thus we avoid to test % whether digits are~$0$ or not once we see a first non-zero digit. % \begin{macrocode} \cs_new:Npn \@@_parse_round_loop:N #1 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: - + \c_one + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: + + 1 \if:w 0 \token_to_str:N #1 \exp_after:wN \@@_parse_round_loop:N \exp:w @@ -1429,18 +1428,18 @@ \exp:w \fi: \else: - \@@_parse_return_semicolon:w \c_zero #1 + \@@_parse_return_semicolon:w 0 #1 \fi: \@@_parse_expand:w } \cs_new:Npn \@@_parse_round_up:N #1 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: - + \c_one + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: + + 1 \exp_after:wN \@@_parse_round_up:N \exp:w \else: - \@@_parse_return_semicolon:w \c_one #1 + \@@_parse_return_semicolon:w 1 #1 \fi: \@@_parse_expand:w } @@ -1451,7 +1450,7 @@ % After the loop \cs{@@_parse_round_loop:N}, this function fetches an % exponent with \cs{@@_parse_exponent:N}, and combines it with the % number of digits counted by \cs{@@_parse_round_loop:N}. At the same -% time, the result \cs{c_zero} or \cs{c_one} is added to the +% time, the result |0| or |1| is added to the % surrounding integer expression. % \begin{macrocode} \cs_new:Npn \@@_parse_round_after:wN #1; #2 @@ -1467,11 +1466,11 @@ % Here, |#1|~is the digit that we are currently rounding (we only care % whether it is even or odd). If |#2|~is not a digit, then fetch an % exponent and expand to |;|\meta{exponent} only. Otherwise, we will -% expand to |+\c_zero| or |+\c_one|, then |;|\meta{exponent}. To +% expand to |+0| or |+1|, then |;|\meta{exponent}. To % decide which, call \cs{@@_round_s:NNNw} to know whether to round up, % giving it as arguments a sign~$0$ (all explicit numbers are % positive), the digit |#1|~to round, the first following digit~|#2|, -% and either |+\c_zero| or |+\c_one| depending on whether the +% and either |+0| or |+1| depending on whether the % following digits are all zero or not. This last argument is % obtained by \cs{@@_parse_round_loop:N}, whose number of digits we % discard by multiplying it by~$0$. The exponent which follows the @@ -1479,7 +1478,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_small_round:NN #1#2 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #2 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f: + \exp_after:wN \@@_round_s:NNNw \exp_after:wN 0 @@ -1487,7 +1486,7 @@ \exp_after:wN #2 \__int_value:w \__int_eval:w \exp_after:wN \@@_parse_round_after:wN - \__int_value:w \__int_eval:w \c_zero * \__int_eval:w \c_zero + \__int_value:w \__int_eval:w 0 * \__int_eval:w 0 \exp_after:wN \@@_parse_round_loop:N \exp:w \else: @@ -1520,7 +1519,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_large_round:NN #1#2 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #2 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #2 \exp_stop_f: + \exp_after:wN \@@_round_s:NNNw \exp_after:wN 0 @@ -1528,7 +1527,7 @@ \exp_after:wN #2 \__int_value:w \__int_eval:w \exp_after:wN \@@_parse_large_round_aux:wNN - \__int_value:w \__int_eval:w \c_one + \__int_value:w \__int_eval:w 1 \exp_after:wN \@@_parse_round_loop:N \else: %^^A could be dot, or e, or other \exp_after:wN \@@_parse_large_round_test:NN @@ -1553,12 +1552,12 @@ \exp_after:wN \@@_parse_round_after:wN \__int_value:w \__int_eval:w #1 \if:w . \exp_not:N #3 - + \c_zero * \__int_eval:w \c_zero + + 0 * \__int_eval:w 0 \exp_after:wN \@@_parse_round_loop:N \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN ; - \exp_after:wN \c_zero + \exp_after:wN 0 \exp_after:wN #3 \fi: } @@ -1633,7 +1632,7 @@ \cs_new:Npn \@@_parse_exponent_aux:N #1 { \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #1 - \c_zero \else: `#1 \fi: > `9 \exp_stop_f: + 0 \else: `#1 \fi: > `9 \exp_stop_f: 0 \exp_after:wN ; \exp_after:wN e \else: \exp_after:wN \@@_parse_exponent_sign:N @@ -1665,7 +1664,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_exponent_body:N #1 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: \token_to_str:N #1 \exp_after:wN \@@_parse_exponent_digits:N \exp:w @@ -1692,7 +1691,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_exponent_digits:N #1 { - \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 9 < 1 \token_to_str:N #1 \exp_stop_f: \token_to_str:N #1 \exp_after:wN \@@_parse_exponent_digits:N \exp:w @@ -1723,7 +1722,8 @@ \if_catcode:w \scan_stop: \exp_not:N #1 \if_meaning:w \scan_stop: #1 \if_int_compare:w - \__str_if_eq_x:nn { \s_@@ } { \exp_not:N #1 } = \c_zero + \__str_if_eq_x:nn { \s_@@ } { \exp_not:N #1 } + = 0 \exp_stop_f: 0 \__msg_kernel_expandable_error:nnn { kernel } { fp-after-e } { floating~point~ } @@ -1737,7 +1737,7 @@ \else: \if_int_compare:w \__str_if_eq_x:nn { \__int_value:w #1 } { \tex_the:D #1 } - = \c_zero + = 0 \exp_stop_f: \__int_value:w #1 \else: 0 @@ -1826,7 +1826,7 @@ \exp_after:wN #1 \exp:w \exp_end_continue_f:w \exp_after:wN \@@_sanitize:wN - \__int_value:w \__int_eval:w \c_zero \@@_parse_strim_zeros:N + \__int_value:w \__int_eval:w 0 \@@_parse_strim_zeros:N } % \end{macrocode} % \end{macro} @@ -2111,6 +2111,8 @@ % \end{macro} % % \begin{macro}[aux, EXP]{\@@_parse_word_round:N, \@@_parse_round:Nw} +% \begin{macro}[aux, deprecated = 2017-12-31]{round+, round0, round-} +% This looks for |+|, |-|, |0| after |round|. That syntax is deprecated. % \begin{macrocode} \cs_new:Npn \@@_parse_word_round:N #1#2 { @@ -2133,6 +2135,7 @@ #1 #2 \@@_round_to_nearest:NNN #3#4 { #2 #1 #3 } % \end{macrocode} % \end{macro} +% \end{macro} % % \subsection{Main functions} % @@ -2231,7 +2234,7 @@ \if_catcode:w \scan_stop: \exp_not:N #2 \if_int_compare:w \__str_if_eq_x:nn { \s_@@_mark } { \exp_not:N #2 } - = \c_zero + = 0 \exp_stop_f: \exp_after:wN \exp_after:wN \exp_after:wN \@@_parse_infix_mark:NNN \else: @@ -2241,9 +2244,8 @@ \else: \if_int_compare:w \__int_eval:w - ( `#2 \if_int_compare:w `#2 > `Z - \c_thirty_two \fi: ) - / 26 - = \c_three + ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26 + = 3 \exp_stop_f: \exp_after:wN \exp_after:wN \exp_after:wN \@@_parse_infix_juxtapose:N \else: @@ -2592,29 +2594,20 @@ % } % \begin{macrocode} \cs_new:cpn { @@_parse_infix_<:N } #1 - { - \@@_parse_compare:NNNNNNN #1 \c_one - \c_zero \c_zero \c_zero \c_zero < - } + { \@@_parse_compare:NNNNNNN #1 1 0 0 0 0 < } \cs_new:cpn { @@_parse_infix_=:N } #1 - { - \@@_parse_compare:NNNNNNN #1 \c_one - \c_zero \c_zero \c_zero \c_zero = - } + { \@@_parse_compare:NNNNNNN #1 1 0 0 0 0 = } \cs_new:cpn { @@_parse_infix_>:N } #1 - { - \@@_parse_compare:NNNNNNN #1 \c_one - \c_zero \c_zero \c_zero \c_zero > - } + { \@@_parse_compare:NNNNNNN #1 1 0 0 0 0 > } \cs_new:cpn { @@_parse_infix_!:N } #1 { \exp_after:wN \@@_parse_compare:NNNNNNN \exp_after:wN #1 - \exp_after:wN \c_zero - \exp_after:wN \c_one - \exp_after:wN \c_one - \exp_after:wN \c_one - \exp_after:wN \c_one + \exp_after:wN 0 + \exp_after:wN 1 + \exp_after:wN 1 + \exp_after:wN 1 + \exp_after:wN 1 } \cs_new:Npn \@@_parse_excl_error: { @@ -2636,7 +2629,7 @@ { \if_case:w \if_catcode:w \scan_stop: \exp_not:N #7 - \c_four + 4 \exp_stop_f: \else: \__int_eval:w `#7 - `< \__int_eval_end: \fi: @@ -2676,12 +2669,13 @@ { \if_int_odd:w \if_meaning:w \c_zero_fp #3 - \c_zero + 0 \else: \if_case:w \@@_compare_back:ww #8 #2 \exp_stop_f: #5 \or: #6 \or: #7 \else: #4 \fi: \fi: + \exp_stop_f: \exp_after:wN \@@_parse_apply_compare_aux:NNwN \exp_after:wN \c_one_fp \else: @@ -2748,7 +2742,7 @@ { \@@_new_function:Ncfnn #1 { @@_user_ \cs_to_str:N #1 } - { \int_eval:n { \tl_count:n {#2} / \c_two } } + { \int_eval:n { \tl_count:n {#2} / 2 } } {#2} } \cs_new_protected:Npn \@@_new_function:NNnnn #1#2#3#4#5 diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx index a8e3f199dba..c5da3f78998 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-random.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-random.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-random.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point random numbers} \begin{document} \DocInput{\jobname.dtx} @@ -239,7 +239,7 @@ \cs_new:Npn \@@_randint_o:Nw ? #1 @ { \if_case:w - \__int_eval:w \@@_array_count:n {#1} - \c_one \__int_eval_end: + \__int_eval:w \@@_array_count:n {#1} - 1 \__int_eval_end: \exp_after:wN \@@_randint_e:w \c_one_fp #1 \or: \@@_randint_e:w #1 \else: @@ -255,19 +255,19 @@ { \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 + \use_i_delimit_by_q_stop:nw #3 \q_stop > \c_@@_prec_int + 1 \exp_stop_f: \fi: \fi: } - { \c_one } + { 1 \exp_stop_f: } } \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; } > { #2; } { 1 } { 0 } \exp_stop_f: \exp_after:wN \exp_after:wN \exp_after:wN \@@_randint_e:wnn \@@_parse:n { #2; - #1; } { #1; } { #2; } \or: diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx index 9f9e0d0f352..31a0ba85783 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-round.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-round.dtx 6968 2017-02-20 16:08:44Z bruno $ {L3 Floating-point rounding} \begin{document} \DocInput{\jobname.dtx} @@ -73,6 +73,14 @@ % % \subsection{Rounding tools} % +% \begin{variable}{\c_@@_five_int} +% This is used as the half-point for which numbers are rounded +% up/down. +% \begin{macrocode} +\int_const:Nn \c_@@_five_int { 5 } +% \end{macrocode} +% \end{variable} +% % Floating point operations often yield a result that cannot be exactly % represented in a significand with $16$ digits. In that case, we need to % round the exact result to a representable number. The \textsc{ieee} @@ -98,16 +106,16 @@ % (but there is not interface for that yet). % % The rounding tools available in this module are many variations on a -% base function \cs{@@_round:NNN}, which expands to \cs{c_zero} or -% \cs{c_one} depending on whether the final result should be rounded up +% base function \cs{@@_round:NNN}, which expands to |0\exp_stop_f:| or +% |1\exp_stop_f:| depending on whether the final result should be rounded up % or down. % \begin{itemize} % \item \cs{@@_round:NNN} \meta{sign} \meta{digit_1} \meta{digit_2} -% can expand to \cs{c_zero} or \cs{c_one}. +% can expand to |0\exp_stop_f:| or |1\exp_stop_f:|. % \item \cs{@@_round_s:NNNw} \meta{sign} \meta{digit_1} \meta{digit_2} -% \meta{more digits}|;| can expand to |\c_zero ;| or |\c_one ;|. +% \meta{more digits}|;| can expand to |0\exp_stop_f:;| or |1\exp_stop_f:;|. % \item \cs{@@_round_neg:NNN} \meta{sign} \meta{digit_1} \meta{digit_2} -% can expand to \cs{c_zero} or \cs{c_one}. +% can expand to |0\exp_stop_f:| or |1\exp_stop_f:|. % \end{itemize} % See implementation comments for details on the syntax. % @@ -127,8 +135,8 @@ % \end{syntax} % If rounding the number $\meta{final sign} % \meta{digit_1}.\meta{digit_2}$ to an integer rounds it towards zero -% (truncates it), this function expands to \cs{c_zero}, and otherwise -% to \cs{c_one}. Typically used within the scope of an +% (truncates it), this function expands to |0\exp_stop_f:|, and otherwise +% to |1\exp_stop_f:|. Typically used within the scope of an % \cs{__int_eval:w}, to add~$1$ if needed, and thereby round % correctly. The result depends on the rounding mode. % @@ -137,9 +145,9 @@ % rounding towards~$-\infty$ or towards~$+\infty$. Also recall that % \meta{final sign} is~$0$ for positive, and~$2$ for negative. % -% By default, the functions below return \cs{c_zero}, but this is +% By default, the functions below return |0\exp_stop_f:|, but this is % superseded by \cs{@@_round_return_one:}, which instead returns -% \cs{c_one}, expanding everything and removing \cs{c_zero} in the +% |1\exp_stop_f:|, expanding everything and removing |0\exp_stop_f:| in the % process. In the case of rounding towards~$\pm\infty$ or % towards~$0$, this is not really useful, but it prepares us for the % \enquote{round to nearest, ties to even} mode. @@ -155,29 +163,29 @@ % or up towards $+\infty$. % \begin{macrocode} \cs_new:Npn \@@_round_return_one: - { \exp_after:wN \c_one \exp:w } + { \exp_after:wN 1 \exp_after:wN \exp_stop_f: \exp:w } \cs_new:Npn \@@_round_to_ninf:NNN #1 #2 #3 { \if_meaning:w 2 #1 - \if_int_compare:w #3 > \c_zero + \if_int_compare:w #3 > 0 \exp_stop_f: \@@_round_return_one: \fi: \fi: - \c_zero + 0 \exp_stop_f: } -\cs_new:Npn \@@_round_to_zero:NNN #1 #2 #3 { \c_zero } +\cs_new:Npn \@@_round_to_zero:NNN #1 #2 #3 { 0 \exp_stop_f: } \cs_new:Npn \@@_round_to_pinf:NNN #1 #2 #3 { \if_meaning:w 0 #1 - \if_int_compare:w #3 > \c_zero + \if_int_compare:w #3 > 0 \exp_stop_f: \@@_round_return_one: \fi: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new:Npn \@@_round_to_nearest:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_five + \if_int_compare:w #3 > \c_@@_five_int \@@_round_return_one: \else: \if_meaning:w 5 #3 @@ -186,11 +194,11 @@ \fi: \fi: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new:Npn \@@_round_to_nearest_ninf:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_five + \if_int_compare:w #3 > \c_@@_five_int \@@_round_return_one: \else: \if_meaning:w 5 #3 @@ -199,18 +207,18 @@ \fi: \fi: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new:Npn \@@_round_to_nearest_zero:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_five + \if_int_compare:w #3 > \c_@@_five_int \@@_round_return_one: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new:Npn \@@_round_to_nearest_pinf:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_five + \if_int_compare:w #3 > \c_@@_five_int \@@_round_return_one: \else: \if_meaning:w 5 #3 @@ -219,7 +227,7 @@ \fi: \fi: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new_eq:NN \@@_round:NNN \@@_round_to_nearest:NNN % \end{macrocode} @@ -231,9 +239,9 @@ % \cs{@@_round_s:NNNw} \meta{final sign} \meta{digit} \meta{more digits} |;| % \end{syntax} % Similar to \cs{@@_round:NNN}, but with an extra semicolon, this -% function expands to |\c_zero ;| if rounding $\meta{final sign} +% function expands to |0\exp_stop_f:;| if rounding $\meta{final sign} % \meta{digit}.\meta{more digits}$ to an integer truncates, and to -% |\c_one ;| otherwise. The \meta{more digits} part must be a digit, +% |1\exp_stop_f:;| otherwise. The \meta{more digits} part must be a digit, % followed by something that does not overflow a \cs{int_use:N} % \cs{__int_eval:w} construction. The only relevant information about % this piece is whether it is zero or not. @@ -247,7 +255,7 @@ \if_int_odd:w 0 \if_meaning:w 0 #3 1 \fi: \if_meaning:w 5 #3 1 \fi: \exp_stop_f: - \if_int_compare:w \__int_eval:w #4 > \c_zero + \if_int_compare:w \__int_eval:w #4 > 0 \exp_stop_f: 1 + \fi: \fi: @@ -269,11 +277,11 @@ % \begin{macrocode} \cs_new:Npn \@@_round_digit:Nw #1 #2; { - \if_int_odd:w \if_meaning:w 0 #1 \c_one \else: - \if_meaning:w 5 #1 \c_one \else: - \c_zero \fi: \fi: - \if_int_compare:w \__int_eval:w #2 > \c_zero - \__int_eval:w \c_one + + \if_int_odd:w \if_meaning:w 0 #1 1 \else: + \if_meaning:w 5 #1 1 \else: + 0 \fi: \fi: \exp_stop_f: + \if_int_compare:w \__int_eval:w #2 > 0 \exp_stop_f: + \__int_eval:w 1 + \fi: \fi: #1 @@ -295,15 +303,15 @@ % \begin{syntax} % \cs{@@_round_neg:NNN} \meta{final sign} \meta{digit_1} \meta{digit_2} % \end{syntax} -% This expands to \cs{c_zero} or \cs{c_one} after doing the following +% This expands to |0\exp_stop_f:| or |1\exp_stop_f:| after doing the following % test. Starting from a number of % the form $ \meta{final sign}0.\meta{15 digits}\meta{digit_1} $ with exactly % $15$ (non-all-zero) digits before \meta{digit_1}, subtract from it % $\meta{final sign}0.0\ldots{}0\meta{digit_2}$, where there are $16$~zeros. % If in the current rounding mode the result should be rounded down, -% then this function returns \cs{c_one}. Otherwise, \emph{i.e.}, +% then this function returns |1\exp_stop_f:|. Otherwise, \emph{i.e.}, % if the result is rounded back to the first operand, then this function -% returns \cs{c_zero}. +% returns |0\exp_stop_f:|. % % It turns out that this negative \enquote{round to nearest} % is identical to the positive one. And this is the default mode. @@ -311,20 +319,20 @@ \cs_new_eq:NN \@@_round_to_ninf_neg:NNN \@@_round_to_pinf:NNN \cs_new:Npn \@@_round_to_zero_neg:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_zero + \if_int_compare:w #3 > 0 \exp_stop_f: \@@_round_return_one: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new_eq:NN \@@_round_to_pinf_neg:NNN \@@_round_to_ninf:NNN \cs_new_eq:NN \@@_round_to_nearest_neg:NNN \@@_round_to_nearest:NNN \cs_new_eq:NN \@@_round_to_nearest_ninf_neg:NNN \@@_round_to_nearest_pinf:NNN \cs_new:Npn \@@_round_to_nearest_zero_neg:NNN #1 #2 #3 { - \if_int_compare:w #3 > \c_four + \if_int_compare:w #3 < \c_@@_five_int \else: \@@_round_return_one: \fi: - \c_zero + 0 \exp_stop_f: } \cs_new_eq:NN \@@_round_to_nearest_pinf_neg:NNN \@@_round_to_nearest_ninf:NNN \cs_new_eq:NN \@@_round_neg:NNN \@@_round_to_nearest_neg:NNN @@ -459,19 +467,19 @@ } \cs_new:Npn \@@_round_normal:NwNNnw #1#2 \s_@@ \@@_chk:w 1#3#4#5; { - \@@_decimate:nNnnnn { \c_sixteen - #4 - #2 } + \@@_decimate:nNnnnn { \c_@@_prec_int - #4 - #2 } \@@_round_normal:NnnwNNnn #5 #1 #3 {#4} {#2} } \cs_new:Npn \@@_round_normal:NnnwNNnn #1#2#3#4; #5#6 { \exp_after:wN \@@_round_normal:NNwNnn \__int_value:w \__int_eval:w - \if_int_compare:w #2 > \c_zero + \if_int_compare:w #2 > 0 \exp_stop_f: 1 \__int_value:w #2 \exp_after:wN \@@_round_pack:Nw \__int_value:w \__int_eval:w 1#3 + \else: - \if_int_compare:w #3 > \c_zero + \if_int_compare:w #3 > 0 \exp_stop_f: 1 \__int_value:w #3 + \fi: \fi: @@ -483,7 +491,7 @@ 0000 0000 0000 0000 ; #6 } \cs_new:Npn \@@_round_pack:Nw #1 - { \if_meaning:w 2 #1 + \c_one \fi: \__int_eval_end: } + { \if_meaning:w 2 #1 + 1 \fi: \__int_eval_end: } \cs_new:Npn \@@_round_normal:NNwNnn #1 #2 { \if_meaning:w 0 #2 @@ -508,7 +516,7 @@ \else: \exp_after:wN \@@_round_special_aux:Nw \exp_after:wN #4 - \__int_value:w \__int_eval:w \c_one + \__int_value:w \__int_eval:w 1 \if_meaning:w 1 #1 -#6 \else: +#5 \fi: \fi: ; diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx index e6ce10175fa..685274306b0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-traps.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-traps.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-traps.dtx 6923 2017-02-14 03:07:25Z bruno $ {L3 Floating-point exception trapping} \begin{document} \DocInput{\jobname.dtx} @@ -72,51 +72,19 @@ % % \subsection{Flags} % -% \begin{macro}{\fp_flag_off:n} -% Function to turn a flag off. Simply undefine it. -% \begin{macrocode} -\cs_new_protected:Npn \fp_flag_off:n #1 - { \cs_set_eq:cN { l_@@_ #1 _flag_token } \tex_undefined:D } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[EXP]{\fp_flag_on:n} -% Function to turn a flag on expandably: use \TeX{}'s automatic -% assignment to \cs{scan_stop:}. -% \begin{macrocode} -\cs_new:Npn \fp_flag_on:n #1 - { \exp_args:Nc \use_none:n { l_@@_ #1 _flag_token } } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[EXP,pTF]{\fp_if_flag_on:n} -% Returns true if the flag is on, false otherwise. -% \begin{macrocode} -\prg_new_conditional:Npnn \fp_if_flag_on:n #1 { p , T , F , TF } - { - \if_cs_exist:w l_@@_ #1 _flag_token \cs_end: - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -% \end{macrocode} -% \end{macro} -% -% \begin{variable}[aux] +% \begin{variable} % { -% \l_@@_invalid_operation_flag_token , -% \l_@@_division_by_zero_flag_token , -% \l_@@_overflow_flag_token , -% \l_@@_underflow_flag_token , +% flag fp_invalid_operation, +% flag fp_division_by_zero, +% flag fp_overflow, +% flag fp_underflow % } -% The \textsc{ieee} standard defines five exceptions. We currently -% don't support the \enquote{inexact} exception. +% Flags to denote exceptions. % \begin{macrocode} -\cs_new_eq:NN \l_@@_invalid_operation_flag_token \tex_undefined:D -\cs_new_eq:NN \l_@@_division_by_zero_flag_token \tex_undefined:D -\cs_new_eq:NN \l_@@_overflow_flag_token \tex_undefined:D -\cs_new_eq:NN \l_@@_underflow_flag_token \tex_undefined:D +\flag_new:n { fp_invalid_operation } +\flag_new:n { fp_division_by_zero } +\flag_new:n { fp_overflow } +\flag_new:n { fp_underflow } % \end{macrocode} % \end{variable} % @@ -124,7 +92,7 @@ % % Exceptions can be trapped to obtain custom behaviour. When an invalid % operation or a division by zero is trapped, the trap receives as -% arguments the result as an $N$-type floating point number, the +% arguments the result as an |N|-type floating point number, the % function name (multiple letters for prefix operations, or a single % symbol for infix operations), and the operand(s). When an overflow or % underflow is trapped, the trap receives the resulting overly large or @@ -199,7 +167,7 @@ { #1 \@@_error:nnfn { invalid } {##2} { \fp_to_tl:n { ##3; } } { } - \fp_flag_on:n { invalid_operation } + \flag_raise:n { fp_invalid_operation } ##1 } \exp_args:Nno \use:n @@ -208,7 +176,7 @@ #1 \@@_error:nffn { invalid-ii } { \fp_to_tl:n { ##2; } } { \fp_to_tl:n { ##3; } } {##1} - \fp_flag_on:n { invalid_operation } + \flag_raise:n { fp_invalid_operation } \exp_after:wN \c_nan_fp } \exp_args:Nno \use:n @@ -216,7 +184,7 @@ { #1 \@@_error:nffn { invalid } {##1} {##2} { } - \fp_flag_on:n { invalid_operation } + \flag_raise:n { fp_invalid_operation } \exp_after:wN \c_nan_fp } } @@ -249,7 +217,7 @@ { #1 \@@_error:nnfn { zero-div } {##2} { \fp_to_tl:n { ##3; } } { } - \fp_flag_on:n { division_by_zero } + \flag_raise:n { fp_division_by_zero } \exp_after:wN ##1 } \exp_args:Nno \use:n @@ -258,7 +226,7 @@ #1 \@@_error:nffn { zero-div-ii } { \fp_to_tl:n { ##3; } } { \fp_to_tl:n { ##4; } } {##2} - \fp_flag_on:n { division_by_zero } + \flag_raise:n { fp_division_by_zero } \exp_after:wN ##1 } } @@ -321,7 +289,7 @@ { \fp_to_tl:n { \s_@@ \@@_chk:w ##1##2##3; } } { \token_if_eq_meaning:NNF 0 ##2 { - } #4 } {#2} - \fp_flag_on:n {#2} + \flag_raise:n { fp_#2 } #3 ##2 } } @@ -337,7 +305,7 @@ % \@@_division_by_zero_o:Nnw, \@@_division_by_zero_o:NNww, % \@@_overflow:w , \@@_underflow:w % } -% Initialize the two control sequences (to log properly their +% Initialize the control sequences (to log properly their % existence). Then set invalid operations to trigger an error, and % division by zero, overflow, and underflow to act silently on their % flag. diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx index e1ab93969d5..af5b1b478c7 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-trig.dtx @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-trig.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-trig.dtx 6943 2017-02-17 16:47:59Z bruno $ {L3 Floating-point trigonometric functions} \begin{document} \DocInput{\jobname.dtx} @@ -112,7 +112,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 \@@_sin_series_o:NNwwww - \@@_ep_to_float:wwN #3 \c_zero + \@@_ep_to_float:wwN #3 0 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { sin } { sind } } } @@ -139,7 +139,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 \@@_sin_series_o:NNwwww - \@@_ep_to_float:wwN 0 \c_two + \@@_ep_to_float:wwN 0 2 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { cos } { cosd } } } @@ -169,7 +169,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 \@@_sin_series_o:NNwwww - \@@_ep_inv_to_float:wwN #3 \c_zero + \@@_ep_inv_to_float:wwN #3 0 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { csc } { cscd } } } @@ -195,7 +195,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 \@@_sin_series_o:NNwwww - \@@_ep_inv_to_float:wwN 0 \c_two + \@@_ep_inv_to_float:wwN 0 2 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { sec } { secd } } } @@ -222,7 +222,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 - \@@_tan_series_o:NNwwww 0 #3 \c_one + \@@_tan_series_o:NNwwww 0 #3 1 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { tan } { tand } } } @@ -252,7 +252,7 @@ \or: \@@_case_use:nw { \@@_trig:NNNNNwn #1 - \@@_tan_series_o:NNwwww 2 #3 \c_three + \@@_tan_series_o:NNwwww 2 #3 3 } \or: \@@_case_use:nw { \@@_invalid_operation_o:fw { #1 { cot } { cotd } } } @@ -306,7 +306,7 @@ \exp_after:wN #4 \__int_value:w \__int_eval:w #5 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN - \if_int_compare:w #7 > #1 \c_zero \c_one + \if_int_compare:w #7 > #1 0 1 \exp_stop_f: #1 \@@_trig_large:ww \@@_trigd_large:ww \else: #1 \@@_trig_small:ww \@@_trigd_small:ww @@ -397,16 +397,16 @@ { \exp_after:wN \@@_trigd_large_auxii:wNw \__int_value:w \__int_eval:w #1 + #2 - - (#1 + #2 - \c_four) / \c_nine * \c_nine \__int_eval_end: + - (#1 + #2 - 4) / 9 * 9 \__int_eval_end: #3; #4; #5{#6#7#8#9}; } \cs_new:Npn \@@_trigd_large_auxii:wNw #1; #2#3; { - + (#1#2 - \c_four) / \c_nine * \c_two + + (#1#2 - 4) / 9 * 2 \exp_after:wN \@@_trigd_large_auxiii:www \__int_value:w \__int_eval:w #1#2 - - (#1#2 - \c_four) / \c_nine * \c_nine \__int_eval_end: #3 ; + - (#1#2 - 4) / 9 * 9 \__int_eval_end: #3 ; } \cs_new:Npn \@@_trigd_large_auxiii:www #1; #2; #3! { @@ -414,7 +414,7 @@ \exp_after:wN \@@_use_i_until_s:nw \exp_after:wN \@@_fixed_continue:wn \else: - + \c_one + + 1 \fi: \@@_fixed_sub:wwn {9000}{0000}{0000}{0000}{0000}{0000}; {#1}#2{0000}{0000}; @@ -659,11 +659,11 @@ \cs_new:Npn \@@_trig_large_auxi:wwwwww #1, #2, #3, #4! { \prg_replicate:nn {#1} { \@@_trig_large_auxii:ww } - \prg_replicate:nn { #2 - #1 * \c_eight } + \prg_replicate:nn { #2 - #1 * 8 } { \@@_trig_large_auxiii:wNNNNNNNN } - \prg_replicate:nn { #3 - #2 * \c_eight } + \prg_replicate:nn { #3 - #2 * 8 } { \@@_trig_large_auxiv:wN } - \prg_replicate:nn { \c_eight } { \@@_pack_twice_four:wNNNNNNNN } + \prg_replicate:nn { 8 } { \@@_pack_twice_four:wNNNNNNNN } \@@_trig_large_auxv:www ; } @@ -703,7 +703,7 @@ \exp_after:wN \@@_use_i_until_s:nw \exp_after:wN \@@_trig_large_auxvii:w \__int_value:w \__int_eval:w \c_@@_leading_shift_int - \prg_replicate:nn { \c_thirteen } + \prg_replicate:nn { 13 } { \@@_trig_large_auxvi:wnnnnnnnn } + \c_@@_trailing_shift_int - \c_@@_middle_shift_int \@@_use_i_until_s:nw @@ -769,7 +769,7 @@ \exp_after:wN \@@_use_i_until_s:nw \exp_after:wN \@@_trig_large_auxxi:w \__int_value:w \__int_eval:w \c_@@_leading_shift_int - \prg_replicate:nn { \c_thirteen } + \prg_replicate:nn { 13 } { \@@_trig_large_auxx:wNNNNN } + \c_@@_trailing_shift_int - \c_@@_middle_shift_int ; @@ -778,13 +778,13 @@ { \exp_after:wN \@@_trig_large_pack:NNNNNw \__int_value:w \__int_eval:w \c_@@_middle_shift_int - #2 \c_eight * #3#4#5#6 + #2 8 * #3#4#5#6 #1; #2 } \cs_new:Npn \@@_trig_large_auxxi:w #1; { \exp_after:wN \@@_ep_mul_raw:wwwwN - \__int_value:w \__int_eval:w \c_zero \@@_ep_to_ep_loop:N #1 ; ; ! + \__int_value:w \__int_eval:w 0 \@@_ep_to_ep_loop:N #1 ; ; ! 0,{7853}{9816}{3397}{4483}{0961}{5661}; \@@_trig_small:ww } @@ -832,7 +832,7 @@ \exp_after:wN \@@_sin_series_aux_o:NNnwww \exp_after:wN #1 \__int_value:w - \if_int_odd:w \__int_eval:w (#3 + \c_two) / \c_four \__int_eval_end: + \if_int_odd:w \__int_eval:w (#3 + 2) / 4 \__int_eval_end: #2 \else: \if_meaning:w #2 0 2 \else: 0 \fi: @@ -842,7 +842,7 @@ } \cs_new:Npn \@@_sin_series_aux_o:NNnwww #1#2#3 #4; #5,#6; { - \if_int_odd:w \__int_eval:w #3 / \c_two \__int_eval_end: + \if_int_odd:w \__int_eval:w #3 / 2 \__int_eval_end: \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn @@ -920,7 +920,7 @@ { \exp_after:wN \@@_tan_series_aux_o:Nnwww \__int_value:w - \if_int_odd:w \__int_eval:w #3 / \c_two \__int_eval_end: + \if_int_odd:w \__int_eval:w #3 / 2 \__int_eval_end: \exp_after:wN \reverse_if:N \fi: \if_meaning:w #1#2 2 \else: 0 \fi: @@ -945,7 +945,7 @@ \@@_fixed_mul_sub_back:wwwn#3;{10000}{0000}{0000}{0000}{0000}{0000}; { \reverse_if:N \if_int_odd:w - \__int_eval:w (#2 - \c_one) / \c_two \__int_eval_end: + \__int_eval:w (#2 - 1) / 2 \__int_eval_end: \exp_after:wN \@@_reverse_args:Nww \fi: \@@_ep_div:wwwwn 0, @@ -1052,7 +1052,7 @@ \cs_new:Npn \@@_atan_dispatch_o:NNnNw #1#2#3#4#5@ { \if_case:w - \__int_eval:w \@@_array_count:n {#5} - \c_one \__int_eval_end: + \__int_eval:w \@@_array_count:n {#5} - 1 \__int_eval_end: \exp_after:wN #1 \exp_after:wN #4 \c_one_fp #5 \exp:w \or: #2 #4 #5 \exp:w @@ -1086,13 +1086,14 @@ \if_meaning:w 3 #5 \@@_case_return_ii_o:ww \fi: \if_case:w \if_meaning:w #2 #5 - \if_meaning:w 1 #2 \c_ten \else: \c_zero \fi: + \if_meaning:w 1 #2 10 \else: 0 \fi: \else: - \if_int_compare:w #2 > #5 \c_one \else: \c_two \fi: + \if_int_compare:w #2 > #5 \exp_stop_f: 1 \else: 2 \fi: \fi: - \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 \c_two } - \or: \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 \c_four } - \or: \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 \c_zero } + \exp_stop_f: + \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 2 } + \or: \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 4 } + \or: \@@_case_return:nw { \@@_atan_inf_o:NNNw #1 #3 0 } \fi: \@@_atan_normal_o:NNnwNnw #1 \s_@@ \@@_chk:w #2#3#4; @@ -1121,7 +1122,7 @@ \exp_after:wN \@@_atan_combine_o:NwwwwwN \exp_after:wN #2 \__int_value:w \__int_eval:w - \if_meaning:w 2 #5 \c_seven - \fi: #3 \exp_after:wN ; + \if_meaning:w 2 #5 7 - \fi: #3 \exp_after:wN ; \c_@@_one_fixed_tl ; {0000}{0000}{0000}{0000}{0000}{0000}; 0,{0000}{0000}{0000}{0000}{0000}{0000}; #1 @@ -1169,11 +1170,11 @@ \exp_after:wN #1 \__int_value:w \__int_eval:w \if_meaning:w 2 #4 - \c_seven - \__int_eval:w + 7 - \__int_eval:w \fi: \if_int_compare:w - \@@_ep_compare:wwww #2,#3; #5,#6; > \c_zero - \c_three - + \@@_ep_compare:wwww #2,#3; #5,#6; > 0 \exp_stop_f: + 3 - \exp_after:wN \@@_reverse_args:Nww \fi: \@@_atan_div:wnwwnw #2,#3; #5,#6; @@ -1204,14 +1205,14 @@ \exp_stop_f: \exp_after:wN \@@_atan_near:wwwn \fi: - \c_zero + 0 \@@_ep_div:wwwwn #1,{#2}#3; #4,{#5}#6; \@@_atan_auxi:ww } \cs_new:Npn \@@_atan_near:wwwn - \c_zero \@@_ep_div:wwwwn #1,#2; #3, + 0 \@@_ep_div:wwwwn #1,#2; #3, { - \c_one + 1 \@@_ep_to_fixed:wwn #1 - #3, #2; \@@_atan_near_aux:wwn } @@ -1258,14 +1259,14 @@ % \begin{macrocode} \cs_new:Npn \@@_atan_Taylor_loop:www #1; #2; #3; { - \if_int_compare:w #1 = - \c_one + \if_int_compare:w #1 = -1 \exp_stop_f: \@@_atan_Taylor_break:w \fi: \exp_after:wN \@@_fixed_div_int:wwN \c_@@_one_fixed_tl ; #1; \@@_rrot:www \@@_fixed_mul_sub_back:wwwn #2; #3; { \exp_after:wN \@@_atan_Taylor_loop:www - \__int_value:w \__int_eval:w #1 - \c_two ; + \__int_value:w \__int_eval:w #1 - 2 ; } #3; } @@ -1315,7 +1316,7 @@ \@@_fixed_mul:wwn #3; #4; { \exp_after:wN \@@_atan_combine_aux:ww - \__int_value:w \__int_eval:w #2 / \c_two ; #2; + \__int_value:w \__int_eval:w #2 / 2 ; #2; } } { #7 \@@_fixed_to_float:wN \@@_fixed_to_float_rad:wN } @@ -1378,7 +1379,7 @@ \cs_new:Npn \@@_acos_o:w #1 \s_@@ \@@_chk:w #2#3; @ { \if_case:w #2 \exp_stop_f: - \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 \c_four } + \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 4 } \or: \@@_case_use:nw { @@ -1410,7 +1411,7 @@ \cs_new:Npn \@@_asin_normal_o:NfwNnnnnw #1#2#3 \s_@@ \@@_chk:w 1#4#5#6#7#8#9; { - \if_int_compare:w #5 < \c_one + \if_int_compare:w #5 < 1 \exp_stop_f: \exp_after:wN \@@_use_none_until_s:w \fi: \if_int_compare:w \__int_eval:w #5 + #6#7 + #8#9 = 1000 0001 ~ @@ -1513,7 +1514,7 @@ \@@_acsc_normal_o:NfwNnw #1 { #1 { asec } { asecd } } \@@_reverse_args:Nww } - \or: \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 \c_four } + \or: \@@_case_use:nw { \@@_atan_inf_o:NNNw #1 0 4 } \else: \@@_case_return_same_o:w \fi: \s_@@ \@@_chk:w #2 #3; @@ -1532,7 +1533,7 @@ % \begin{macrocode} \cs_new:Npn \@@_acsc_normal_o:NfwNnw #1#2#3 \s_@@ \@@_chk:w 1#4#5#6; { - \int_compare:nNnTF {#5} < \c_one + \int_compare:nNnTF {#5} < 1 { \@@_invalid_operation_o:fw {#2} \s_@@ \@@_chk:w 1#4{#5}#6; diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx index ea20f8d1bc8..14b450c1320 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp.dtx Copyright (C) 2011-2016 The LaTeX3 Project +%% File: l3fp.dtx Copyright (C) 2011-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3fp.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp.dtx 6923 2017-02-14 03:07:25Z bruno $ {L3 Floating points} %</driver|package> %<*driver> @@ -136,12 +136,15 @@ % for higher-level commands. For example, one could provide a function % to typeset nicely the result of floating point computations. % \begin{verbatim} +% \documentclass{article} % \usepackage{xparse, siunitx} % \ExplSyntaxOn % \NewDocumentCommand { \calcnum } { m } % { \num { \fp_to_scientific:n {#1} } } % \ExplSyntaxOff +% \begin{document} % \calcnum { 2 pi * sin ( 2.3 ^ 5 ) } +% \end{document} % \end{verbatim} % % \section{Creating and initialising floating point variables} @@ -315,7 +318,7 @@ % result in (almost) the shortest possible form. Numbers in the % ranges $(0,10^{-3})$ and $[10^{16},\infty)$ are expressed in % scientific notation with trailing zeros trimmed and no decimal -% separator when there is a single significant digit (see +% separator when there is a single significant digit (this differs from % \cs{fp_to_scientific:n}). Numbers in the range $[10^{-3},10^{16})$ % are expressed in a decimal notation without exponent, with trailing % zeros trimmed, and no decimal separator for integer values (see @@ -362,7 +365,7 @@ % \texttt{true} if the \meta{relation} is obeyed. Two floating point % numbers $x$ and~$y$ may obey four mutually exclusive relations: % $x<y$, $x=y$, $x>y$, or $x$ and~$y$ are not ordered. The latter -% case occurs exactly when either operand is~\nan{}, and this relation +% case occurs exactly when one or both operands is~\nan{}, and this relation % is denoted by the symbol~|?|. Note that a~\nan{} is distinct from % any value, even another~\nan{}, hence $x=x$ is not true for % a~\nan{}. To test if a value is~\nan{}, compare it to an arbitrary @@ -406,7 +409,7 @@ % computed, even if one comparison is \texttt{false}. Two floating % point numbers $x$ and~$y$ may obey four mutually exclusive % relations: $x<y$, $x=y$, $x>y$, or $x$ and~$y$ are not ordered. The -% latter case occurs exactly when one of the operands is~\nan{}, and +% latter case occurs exactly when one or both operands is~\nan{}, and % this relation is denoted by the symbol~|?|. Each \meta{relation} % can be any (non-empty) combination of |<|, |=|, |>|, and~|?|, plus % an optional leading~|!| (which negates the \meta{relation}), with @@ -632,7 +635,8 @@ % % \enquote{Exceptions} may occur when performing some floating point % operations, such as \texttt{0 / 0}, or \texttt{10 ** 1e9999}. The -% \textsc{IEEE} standard defines $5$ types of exceptions. +% relevant \textsc{IEEE} standard defines $5$ types of exceptions, +% of which we implement~$4$. % \begin{itemize} % \item \emph{Overflow} occurs whenever the result of an operation is % too large to be represented as a normal floating point number. This @@ -641,68 +645,38 @@ % too close to $0$ to be represented as a normal floating point % number. This results in $\pm 0$. % \item \emph{Invalid operation} occurs for operations with no defined -% outcome, for instance $0/0$, or $\sin(\infty)$, and almost any -% operation involving a \nan{}. This normally results in a \nan{}, -% except for conversion functions whose target type does not have a -% notion of \nan{} (\emph{e.g.}, \cs{fp_to_dim:n}). +% outcome, for instance $0/0$ or $\sin(\infty)$, and results in a \nan{}. +% It also occurs for conversion functions whose target type does not +% have the appropriate infinite or \nan{} value (\emph{e.g.}, +% \cs{fp_to_dim:n}). % \item \emph{Division by zero} occurs when dividing a non-zero number -% by $0$, or when evaluating \emph{e.g.}, $\ln(0)$ or $\cot(0)$. This -% results in $\pm\infty$. -% \item \emph{Inexact} occurs whenever the result of a computation is -% not exact, in other words, almost always. At the moment, this -% exception is entirely ignored in \LaTeX3. +% by $0$, or when evaluating functions at poles, \emph{e.g.}, +% $\ln(0)$ or $\cot(0)$. This results in $\pm\infty$. +% \item [\emph{(not yet)}] \emph{Inexact} occurs whenever the result of +% a computation is not exact, in other words, almost always. At the +% moment, this exception is entirely ignored in \LaTeX3. % \end{itemize} -% To each exception is associated a \enquote{flag}, which can be either -% \emph{on} or \emph{off}. By default, the \enquote{invalid operation} -% exception triggers an (expandable) error, and raises the corresponding -% flag. Other exceptions only raise the corresponding flag. The state -% of the flag can be tested -% and modified. The behaviour when an exception occurs can be modified -% (using \cs{fp_trap:nn}) to either produce an error and turn the flag -% on, or only turn the flag on, or do nothing at all. -% -% \begin{function}[EXP, pTF, added = 2012-08-08, tested = m3fp-traps001] -% {\fp_if_flag_on:n} -% \begin{syntax} -% \cs{fp_if_flag_on_p:n} \Arg{exception} -% \cs{fp_if_flag_on:nTF} \Arg{exception} \Arg{true code} \Arg{false code} -% \end{syntax} -% Tests if the flag for the \meta{exception} is on, which normally -% means the given \meta{exception} has occurred. -% \emph{This function is experimental, and may be altered or removed.} -% \end{function} -% -% \begin{function}[added = 2012-08-08, tested = m3fp-traps001] -% {\fp_flag_off:n} -% \begin{syntax} -% \cs{fp_flag_off:n} \Arg{exception} -% \end{syntax} -% Locally turns off the flag which indicates whether the -% \meta{exception} has occurred. -% \emph{This function is experimental, and may be altered or removed.} -% \end{function} -% -% \begin{function}[EXP, added = 2012-08-08, tested = m3fp-traps001] -% {\fp_flag_on:n} -% \begin{syntax} -% \cs{fp_flag_on:n} \Arg{exception} -% \end{syntax} -% Locally turns on the flag to indicate (or pretend) that the -% \meta{exception} has occurred. Note that this function is -% expandable: it is used internally by \pkg{l3fp} to signal when -% exceptions do occur. -% \emph{This function is experimental, and may be altered or removed.} -% \end{function} -% -% \begin{function}[added = 2012-07-19, updated = 2012-08-08, +% To each exception we associate a \enquote{flag}: \texttt{fp_overflow}, +% \texttt{fp_underflow}, \texttt{fp_invalid_operation} and +% \texttt{fp_division_by_zero}. The state of these flags can be tested +% and modified with commands from \pkg{l3flag} +% +% By default, the \enquote{invalid operation} exception triggers an +% (expandable) error, and raises the corresponding flag. Other +% exceptions raise the corresponding flag but do not trigger an error. +% The behaviour when an exception occurs can be modified (using +% \cs{fp_trap:nn}) to either produce an error and raise the flag, or +% only raise the flag, or do nothing at all. +% +% \begin{function}[added = 2012-07-19, updated = 2017-02-13, % tested = m3fp-traps001]{\fp_trap:nn} % \begin{syntax} % \cs{fp_trap:nn} \Arg{exception} \Arg{trap type} % \end{syntax} -% All occurrences of the \meta{exception} (\texttt{invalid_operation}, -% \texttt{division_by_zero}, \texttt{overflow}, or \texttt{underflow}) -% within the current group are treated as \meta{trap type}, which can -% be +% All occurrences of the \meta{exception} (\texttt{overflow}, +% \texttt{underflow}, \texttt{invalid_operation} or +% \texttt{division_by_zero}) within the current +% group are treated as \meta{trap type}, which can be % \begin{itemize} % \item \texttt{none}: the \meta{exception} will be entirely % ignored, and leave no trace; @@ -715,6 +689,16 @@ % \emph{This function is experimental, and may be altered or removed.} % \end{function} % +% \begin{variable} +% { +% flag fp_overflow, +% flag fp_underflow, +% flag fp_invalid_operation, +% flag fp_division_by_zero +% } +% Flags denoting the occurrence of various floating-point exceptions. +% \end{variable} +% % \section{Viewing floating points} % % \begin{function}[added = 2012-05-08, updated = 2015-08-07, @@ -727,6 +711,16 @@ % result in the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-07] +% {\fp_log:N, \fp_log:c, \fp_log:n} +% \begin{syntax} +% \cs{fp_log:N} \meta{fp~var} +% \cs{fp_log:n} \Arg{floating point expression} +% \end{syntax} +% Evaluates the \meta{floating point expression} and writes the +% result in the log file. +% \end{function} +% % \section{Floating point expressions} % % \subsection{Input of floating point numbers} \label{sec:l3fp:fp-floats} @@ -774,11 +768,17 @@ % replaced by $\pm\infty$), or an underflow (resulting in $\pm 0$). % % The result is thus $\pm 0$ if and only if \meta{significand} contains no -% non-zero digit (\emph{i.e.}, consists only in~|0| characters, and an -% optional |.| character), or if there is an underflow. Note that a +% non-zero digit (\emph{i.e.}, consists only in characters~|0|, and an +% optional period), or if there is an underflow. Note that a % single dot is currently a valid floating point number, equal to~$+0$, % but that is not guaranteed to remain true. % +% The \meta{significand} must be non-empty, so |e1| and |e-1| are not +% valid floating point numbers. Note that the latter could be mistaken +% with the difference of \enquote{\texttt{e}} and $1$. To avoid +% confusions, the base of natural logarithms cannot be input as |e| and +% should be input as \texttt{exp(1)} or \cs{c_e_fp}. +% % Special numbers are input as follows: % \begin{itemize} % \item \texttt{inf} represents $+\infty$, and can be preceded by any @@ -789,13 +789,6 @@ % \nan{}. % \end{itemize} % -% Note that~|e-1| is not a representation of $10^{-1}$, because it could -% be mistaken with the difference of \enquote{\texttt{e}} and $1$. This -% is consistent with several other programming languages. However, in -% order to avoid confusions, |e-1| is not considered to be this -% difference either. To input the base of natural logarithms, use -% \texttt{exp(1)} or \cs{c_e_fp}. -% % \subsection{Precedence of operators} % \label{sec:l3fp:fp-precedence} % @@ -932,11 +925,14 @@ % \end{syntax} % Raises \meta{operand_1} to the power \meta{operand_2}. This % operation is right associative, hence \texttt{2 ** 2 ** 3} equals -% $2^{2^{3}} = 256$. The \enquote{invalid operation} exception occurs -% if \meta{operand_1} is negative or $-0$, and \meta{operand_2} is not -% an integer, unless the result is zero (in that case, the sign is -% chosen arbitrarily to be $+0$). \enquote{Division by zero} occurs -% when raising $\pm 0$ to a strictly negative power. +% $2^{2^{3}} = 256$. If \meta{operand_1} is negative or $-0$ then: +% the result's sign is $+$ if the \meta{operand_2} is infinite and +% $(-1)^p$ if the \meta{operand_2} is $p/q$ with $p$ integer and $q$ +% odd; the result is $+0$ if +% |abs(|\meta{operand_1}|)^|\meta{operand_2} evaluates to zero; in +% other cases the \enquote{invalid operation} exception occurs because +% the sign cannot be determined. \enquote{Division by zero} occurs +% when raising $\pm 0$ to a finite strictly negative power. % \enquote{Underflow} and \enquote{overflow} occur when appropriate. % \end{function} % @@ -1281,7 +1277,7 @@ % \section{Disclaimer and roadmap} % % The package may break down if the escape character is among -% |0123456789_+|; if it receives a \TeX{} primitive conditional affected +% |0123456789_+|, or if it receives a \TeX{} primitive conditional affected % by \cs{exp_not:N}. % % The following need to be done. I'll try to time-order the items. @@ -1336,7 +1332,6 @@ % \item Document that \pkg{l3trial/l3fp-types} introduces tools for % adding new types. % \item In subsection~\ref{sec:l3fp:fp-floats}, write a grammar. -% \item Fix the |TWO BARS| business with the index. % \item It would be nice if the \texttt{parse} auxiliaries for each % operation were set up in the corresponding module, rather than % centralizing in \pkg{l3fp-parse}. diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx index cef7ea6897b..bc5675b9a9d 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3int.dtx Copyright (C) 1990-2016 The LaTeX3 Project +%% File: l3int.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3int.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3int.dtx 6949 2017-02-18 16:04:10Z joseph $ {L3 Integers} %</driver|package> %<*driver> @@ -777,11 +777,25 @@ % on the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\int_log:N, \int_log:c} +% \begin{syntax} +% \cs{int_log:N} \meta{integer} +% \end{syntax} +% Writes the value of the \meta{integer} in the log file. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\int_log:n} +% \begin{syntax} +% \cs{int_log:n} \Arg{integer expression} +% \end{syntax} +% Writes the result of evaluating the \meta{integer expression} +% in the log file. +% \end{function} +% % \section{Constant integers} % % \begin{variable} % { -% \c_minus_one , % \c_zero , % \c_one , % \c_two , @@ -805,7 +819,7 @@ % \c_two_hundred_fifty_six , % \c_one_thousand , % \c_ten_thousand -% } +% } % Integer values used with primitive tests and assignments: % self-terminating nature makes these more convenient and faster than % literal numbers. @@ -999,19 +1013,11 @@ % \subsection{Integer expressions} % % \begin{macro}{\int_eval:n} -% Wrapper for \cs{@@_eval:w}. Can be used in an integer expression -% or directly in the input stream. In format mode, there is already -% a definition in \pkg{l3alloc} for bootstrapping, which is therefore -% corrected to the \enquote{real} version here. +% Wrapper for \cs{@@_eval:w}: can be used in an integer expression +% or directly in the input stream. % \begin{macrocode} -%<*initex> -\cs_set:Npn \int_eval:n #1 - { \@@_value:w \@@_eval:w #1 \@@_eval_end: } -%</initex> -%<*package> \cs_new:Npn \int_eval:n #1 { \@@_value:w \@@_eval:w #1 \@@_eval_end: } -%</package> % \end{macrocode} % \end{macro} % @@ -1098,12 +1104,12 @@ \cs_new:Npn \@@_div_truncate:NwNw #1#2; #3#4; { \if_meaning:w 0 #1 - \c_zero + 0 \else: ( #1#2 \if_meaning:w - #1 + \else: - \fi: - ( \if_meaning:w - #3 - \fi: #3#4 - \c_one ) / \c_two + ( \if_meaning:w - #3 - \fi: #3#4 - 1 ) / 2 ) \fi: / #3#4 @@ -1922,13 +1928,13 @@ { \exp_args:Nf \@@_to_Base:nn { \int_eval:n {#1} } } \cs_new:Npn \@@_to_base:nn #1#2 { - \int_compare:nNnTF {#1} < \c_zero + \int_compare:nNnTF {#1} < 0 { \exp_args:No \@@_to_base:nnN { \use_none:n #1 } {#2} - } { \@@_to_base:nnN {#1} {#2} \c_empty_tl } } \cs_new:Npn \@@_to_Base:nn #1#2 { - \int_compare:nNnTF {#1} < \c_zero + \int_compare:nNnTF {#1} < 0 { \exp_args:No \@@_to_Base:nnN { \use_none:n #1 } {#2} - } { \@@_to_Base:nnN {#1} {#2} \c_empty_tl } } @@ -1996,7 +2002,7 @@ \cs_new:Npn \@@_to_letter:n #1 { \exp_after:wN \exp_after:wN - \if_case:w \@@_eval:w #1 - \c_ten \@@_eval_end: + \if_case:w \@@_eval:w #1 - 10 \@@_eval_end: a \or: b \or: c @@ -2029,7 +2035,7 @@ \cs_new:Npn \@@_to_Letter:n #1 { \exp_after:wN \exp_after:wN - \if_case:w \@@_eval:w #1 - \c_ten \@@_eval_end: + \if_case:w \@@_eval:w #1 - 10 \@@_eval_end: A \or: B \or: C @@ -2234,11 +2240,11 @@ % Wrappers around the generic function. % \begin{macrocode} \cs_new:Npn \int_from_bin:n #1 - { \int_from_base:nn {#1} \c_two } + { \int_from_base:nn {#1} { 2 } } \cs_new:Npn \int_from_hex:n #1 - { \int_from_base:nn {#1} \c_sixteen } + { \int_from_base:nn {#1} { 16 } } \cs_new:Npn \int_from_oct:n #1 - { \int_from_base:nn {#1} \c_eight } + { \int_from_base:nn {#1} { 8 } } % \end{macrocode} % \end{macro} % @@ -2288,7 +2294,7 @@ \int_eval:n { ( - \c_zero + 0 \exp_after:wN \@@_from_roman:NN \tl_to_str:n {#1} \q_recursion_tail \q_recursion_tail \q_recursion_stop ) @@ -2318,7 +2324,7 @@ } } \cs_new:Npn \@@_from_roman_error:w #1 \q_recursion_stop #2 - { #2 * \c_zero - \c_one } + { #2 * 0 - 1 } % \end{macrocode} % \end{macro} % \end{macro} @@ -2328,24 +2334,14 @@ % % \begin{macro}{\int_show:N, \int_show:c} % \UnitTested -% This is very similar to other registers done using -% \cs{__kernel_register_show:N}, but differs because the variable -% |#1| may be \tn{currentgrouplevel} or \tn{currentgrouptype}, in -% which case the value must be expanded in the current scope rather -% than when processing \cs{iow_wrap:nnnN}. +% \begin{macro}[aux]{\@@_show:nN} +% Diagnostics. % \begin{macrocode} -\cs_new_protected:Npn \int_show:N #1 - { - \use:x - { - \exp_not:n - { \__msg_show_variable:NNNnn #1 \cs_if_exist:NTF ? { } } - { > ~ \token_to_str:N #1 = \tex_the:D #1 } - } - } +\cs_new_eq:NN \int_show:N \__kernel_register_show:N \cs_generate_variant:Nn \int_show:N { c } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\int_show:n} % \UnitTested @@ -2357,6 +2353,22 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\int_log:N, \int_log:c} +% Diagnostics. +% \begin{macrocode} +\cs_new_eq:NN \int_log:N \__kernel_register_log:N +\cs_generate_variant:Nn \int_log:N { c } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\int_log:n} +% Redirect output of \cs{int_show:n} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \int_log:n + { \__msg_log_next: \int_show:n } +% \end{macrocode} +% \end{macro} +% % \subsection{Constant integers} % % \begin{variable}{\c_zero} @@ -2390,19 +2402,6 @@ % \end{macrocode} % \end{variable} % -% \begin{variable}{\c_minus_one} -% The actual allocation mechanism is in \pkg{l3alloc}; it requires -% \cs{c_one} to be defined. In package mode, reuse \tn{m@ne}. -% \begin{macrocode} -%<*package> -\cs_new_eq:NN \c_minus_one \m@ne -%</package> -%<*initex> -\int_const:Nn \c_minus_one { -1 } -%</initex> -% \end{macrocode} -% \end{variable} -% % \begin{variable}{\c_thirty_two} % One middling value. % \begin{macrocode} @@ -2469,6 +2468,21 @@ % \end{variable} % \end{variable} % +% \subsection{Deprecated} +% +% \begin{variable}[deprecated = 2018-12-31]{\c_minus_one} +% The actual allocation mechanism is in \pkg{l3alloc}; it requires +% \cs{c_one} to be defined. In package mode, reuse \tn{m@ne}. +% \begin{macrocode} +%<*package> +\cs_new_eq:NN \c_minus_one \m@ne +%</package> +%<*initex> +\int_const:Nn \c_minus_one { -1 } +%</initex> +% \end{macrocode} +% \end{variable} +% % \begin{macrocode} %</initex|package> % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx index 202cc321018..e437fcfe1d1 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3keys.dtx 6811 2017-01-01 08:50:54Z joseph $ +\GetIdInfo$Id: l3keys.dtx 6906 2017-02-12 20:07:58Z bruno $ {L3 Key-value interfaces} %</driver|package> %<*driver> @@ -791,10 +791,20 @@ % \begin{syntax} % \cs{keys_show:nn} \Arg{module} \Arg{key} % \end{syntax} -% Shows the information associated to the \meta{key} for a \meta{module}, +% Displays in the terminal +% the information associated to the \meta{key} for a \meta{module}, % including the function which is used to actually implement it. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-09]{\keys_log:nn} +% \begin{syntax} +% \cs{keys_log:nn} \Arg{module} \Arg{key} +% \end{syntax} +% Writes in the log file the information associated to the \meta{key} +% for a \meta{module}. See also \cs{keys_show:nn} which displays the +% result in the terminal. +% \end{function} +% % \section{Low-level interface for parsing key--val lists} % % To re-cap from earlier, a key--value list is input of the form @@ -2439,6 +2449,14 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\keys_log:nn} +% Redirect output of \cs{keys_show:nn} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \keys_log:nn + { \__msg_log_next: \keys_show:nn } +% \end{macrocode} +% \end{macro} +% % \subsection{Messages} % % For when there is a need to complain. diff --git a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx index c37e446ac83..90d9ceb11ae 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3luatex.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3luatex.dtx Copyright (C) 2010-2016 The LaTeX3 Project +%% File: l3luatex.dtx Copyright (C) 2010-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package&tex> -\GetIdInfo$Id: l3luatex.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3luatex.dtx 6953 2017-02-18 19:07:54Z joseph $ {L3 Experimental LuaTeX-specific functions} %</driver|package&tex> %<*driver> @@ -277,96 +277,39 @@ l3kernel.charcat = charcat % \end{macrocode} % \end{macro} % -% \begin{macrocode} -%</lua> -% \end{macrocode} +% \subsection{Generic \Lua{} and font support} % % \begin{macrocode} -%</initex|package> +%<*initex> % \end{macrocode} % -% \subsection{Format mode code: font loader} -% +% A small amount of generic code is used by almost all \LuaTeX{} material so +% needs to be loaded by the format. % \begin{macrocode} -%<*fontloader> +attribute_count_name = "g__alloc_attribute_int" +bytecode_count_name = "g__alloc_bytecode_int" +chunkname_count_name = "g__alloc_chunkname_int" +whatsit_count_name = "g__alloc_whatsit_int" +require("ltluatex") % \end{macrocode} % -% In format mode, there needs to be a font loader available to let us -% use OpenType fonts. For testing, this is provided by -% \texttt{fontloader.lua} from the Speedata Publisher system -% (\url{https://github.com/speedata/publisher}). The code there is designed -% to be self-contained and has a certain number of build-in assumptions, -% so there is a small amount of compatibility required. -% -% The code we load looks up \texttt{texmf} tree files using -% \texttt{kpse.filelist}, which isn't part of the standard \texttt{kpse} -% library. The interface is emulated using metatable. +% With the above available the font loader code used by plain \TeX{} and +% \LaTeXe{} when used with \LuaTeX{} can be loaded here. This is thus being +% treated more-or-less as part of the engine itself. % \begin{macrocode} -kpse.filelist = setmetatable({}, { - __index = function (t, key) - return kpse.lookup(key) - end -}) +require("luaotfload-main") +local _void = luaotfload.main() % \end{macrocode} -% There is a built-in assumption in \texttt{fontloader.lua} that various -% environmental variables are set. We deal with that by intercepting the -% relevant names and returning something sane. % \begin{macrocode} -local os_getenv = os.getenv -function os.getenv (var) - if var == "SP_FONT_PATH" then return "" end - return os_getenv(var) -end +%</initex> % \end{macrocode} -% As detailed in -% \url{https://github.com/speedata/publisher/blob/develop/COPYING}, the current -% license for Speedata Publisher is \textsc{AGPLv3}. We therefore only -% load the file and use its public interfaces rather than copying/modifying -% the code itself. Note though that we do have permission to use -% \texttt{fontloader.lua} as a public domain work -% (\url{http://chat.stackexchange.com/transcript/message/27273687#27273687}): -% if we want to develop a richer loader we may want to take advantage of that -% (which also applies to the simple shaper in the related \texttt{fonts.lua} -% file). -% \begin{macrocode} -local fontloader = require("fontloader.lua") -% \end{macrocode} -% That done, register a callback which at present simply passes everything -% through. There's no attempt to pick up font settings (which presumably -% will be needed). Syntax is coerced to the same as for \XeTeX{}. +% % \begin{macrocode} -callback.register("define_font", - function (name, size, id) - local opts, opttab, otfeatures = "", { }, { } - if string.match(name, "^%[") then - name, opts = string.match(name, "^%[([^%]]*)%][^:]*:?(.*)") - end - if opts ~= "" then - for _,kv in ipairs(string.explode(opts,";")) do - if string.match(kv, "=") then - local k, v = string.match(kv, "([^=]*)=?(.*)") - opttab[k] = v - else - if string.match(kv, "^+") then - otfeatures[string.sub(kv,2,-1)] = "true" - elseif string.match(kv, "^-") then - otfeatures[string.sub(kv,2,-1)] = "false" - else - otfeatures[kv] = "true" - end - end - end - end - if next(otfeatures) then - opttab["otfeatures"] = otfeatures - end - return select(2, fontloader.define_font(name, size, opttab)) - end -) +%</lua> % \end{macrocode} % % \begin{macrocode} -%</fontloader> +%</initex|package> % \end{macrocode} % %\end{implementation} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx index f44a405ac15..1c67bad74fa 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3msg.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3msg.dtx 6966 2017-02-20 03:39:43Z bruno $ {L3 Messages} %</driver|package> %<*driver> @@ -805,6 +805,14 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\l_@@_line_context_bool} +% Controls whether the line context is shown as part of the decoration +% of all (non-expandable) messages. +% \begin{macrocode} +\bool_new:N \l_@@_line_context_bool +% \end{macrocode} +% \end{variable} +% % \subsection{Creating messages} % % Messages are created and used separately, so there two parts to @@ -1061,7 +1069,7 @@ } \__iow_with:Nnn \tex_newlinechar:D { `\^^J } { - \__iow_with:Nnn \tex_errorcontextlines:D { - \c_one } + \__iow_with:Nnn \tex_errorcontextlines:D { -1 } { \group_begin: \cs_set_protected:Npn & @@ -1111,7 +1119,7 @@ % deliberate change by a user this is only set in format mode. % \begin{macrocode} %<*initex> -\int_gset:Nn \tex_errorcontextlines:D { - \c_one } +\int_gset:Nn \tex_errorcontextlines:D { -1 } %</initex> % \end{macrocode} % @@ -1126,11 +1134,31 @@ % A function for issuing messages: both the text and order could % in principle vary. % \begin{macrocode} -\cs_new:Npn \msg_fatal_text:n #1 { Fatal~#1~error } -\cs_new:Npn \msg_critical_text:n #1 { Critical~#1~error } -\cs_new:Npn \msg_error_text:n #1 { #1~error } -\cs_new:Npn \msg_warning_text:n #1 { #1~warning } -\cs_new:Npn \msg_info_text:n #1 { #1~info } +\cs_new:Npn \msg_fatal_text:n #1 + { + Fatal~#1~error + \bool_if:NT \l_@@_line_context_bool { ~ \msg_line_context: } + } +\cs_new:Npn \msg_critical_text:n #1 + { + Critical~#1~error + \bool_if:NT \l_@@_line_context_bool { ~ \msg_line_context: } + } +\cs_new:Npn \msg_error_text:n #1 + { + #1~error + \bool_if:NT \l_@@_line_context_bool { ~ \msg_line_context: } + } +\cs_new:Npn \msg_warning_text:n #1 + { + #1~warning + \bool_if:NT \l_@@_line_context_bool { ~ \msg_line_context: } + } +\cs_new:Npn \msg_info_text:n #1 + { + #1~info + \bool_if:NT \l_@@_line_context_bool { ~ \msg_line_context: } + } % \end{macrocode} % \end{macro} % @@ -1611,13 +1639,13 @@ \prop_put:cnn { l_@@_redirect_ #2 _prop } {#3} {#2} \@@_kernel_warning:nnxxxx { kernel } { message-redirect-loop } - { \seq_item:Nn \l_@@_class_loop_seq { \c_one } } - { \seq_item:Nn \l_@@_class_loop_seq { \c_two } } + { \seq_item:Nn \l_@@_class_loop_seq { 1 } } + { \seq_item:Nn \l_@@_class_loop_seq { 2 } } {#3} { \seq_map_function:NN \l_@@_class_loop_seq \@@_redirect_loop_list:n - { \seq_item:Nn \l_@@_class_loop_seq { \c_one } } + { \seq_item:Nn \l_@@_class_loop_seq { 1 } } } } { \@@_redirect_loop_chk:onn \l_@@_class_tl {#2} {#3} } @@ -1845,6 +1873,11 @@ LaTeX~has~been~asked~to~use~a~control~sequence~'#1':\\ this~has~not~been~defined~yet. } +\@@_kernel_new:nnn { kernel } { deprecated-command } + { + The~deprecated~command~'#2'~has~been~or~will~be~removed~on~#1. + \tl_if_empty:nF {#3} { ~Use~instead~'#3'. } + } \@@_kernel_new:nnnn { kernel } { empty-search-pattern } { Empty~search~pattern. } { @@ -2177,12 +2210,17 @@ % show command is called, rather than in the group created by % \cs{iow_wrap:nnnN}. This is only important for expressions % involving the \tn{currentgrouplevel} or \tn{currentgrouptype}. -% This does not lead to double expansion because the -% \texttt{x}-expansion of |#1| |{#2}| is a string in all cases where -% \cs{@@_show_wrap:Nn} is used. +% On the other hand we want the expression to be converted to a string +% with the usual escape character, hence within the wrapping code. % \begin{macrocode} \cs_new_protected:Npn \@@_show_wrap:Nn #1#2 - { \exp_args:Nx \@@_show_wrap:n { > ~ \tl_to_str:n {#2} = #1 {#2} } } + { + \exp_args:Nx \@@_show_wrap:n + { + > ~ \exp_not:n { \tl_to_str:n {#2} } = + \exp_not:N \tl_to_str:n { #1 {#2} } + } + } % \end{macrocode} % \end{macro} % @@ -2243,7 +2281,7 @@ { \__iow_with:Nnn \tex_newlinechar:D { 10 } { - \__iow_with:Nnn \tex_errorcontextlines:D { - \c_one } + \__iow_with:Nnn \tex_errorcontextlines:D { -1 } { \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN { \exp_after:wN \l_@@_internal_tl } diff --git a/Master/texmf-dist/source/latex/l3kernel/l3names.dtx b/Master/texmf-dist/source/latex/l3kernel/l3names.dtx index 3865cbf8ad5..013d5bf0546 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3names.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3names.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3names.dtx Copyright (C) 1990-2016 The LaTeX3 project +%% File: l3names.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3names.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3names.dtx 6962 2017-02-19 22:58:35Z joseph $ {L3 Namespace for primitives} %</driver|package> %<*driver> @@ -816,11 +816,12 @@ \__kernel_primitive:NN \luatexversion \luatex_luatexversion:D \__kernel_primitive:NN \mathdisplayskipmode \luatex_mathdisplayskipmode:D \__kernel_primitive:NN \matheqnogapstep \luatex_matheqnogapstep:D - \__kernel_primitive:NN \mathoption \luatex_mathoption:D \__kernel_primitive:NN \mathnolimitsmode \luatex_mathnolimitsmode:D + \__kernel_primitive:NN \mathoption \luatex_mathoption:D \__kernel_primitive:NN \mathrulesfam \luatex_mathrulesfam:D \__kernel_primitive:NN \mathscriptsmode \luatex_mathscriptsmode:D \__kernel_primitive:NN \mathstyle \luatex_mathstyle:D + \__kernel_primitive:NN \mathsurroundmode \luatex_mathsurroundmode:D \__kernel_primitive:NN \mathsurroundskip \luatex_mathsurroundskip:D \__kernel_primitive:NN \nohrule \luatex_nohrule:D \__kernel_primitive:NN \nokerns \luatex_nokerns:D @@ -828,13 +829,16 @@ \__kernel_primitive:NN \nospaces \luatex_nospaces:D \__kernel_primitive:NN \novrule \luatex_novrule:D \__kernel_primitive:NN \outputbox \luatex_outputbox:D + \__kernel_primitive:NN \pagebottomoffset \luatex_pagebottomoffset:D \__kernel_primitive:NN \pageleftoffset \luatex_pageleftoffset:D + \__kernel_primitive:NN \pagerightoffset \luatex_pagerightoffset:D \__kernel_primitive:NN \pagetopoffset \luatex_pagetopoffset:D \__kernel_primitive:NN \pdfextension \luatex_pdfextension:D \__kernel_primitive:NN \pdffeedback \luatex_pdffeedback:D \__kernel_primitive:NN \pdfvariable \luatex_pdfvariable:D \__kernel_primitive:NN \postexhyphenchar \luatex_postexhyphenchar:D \__kernel_primitive:NN \posthyphenchar \luatex_posthyphenchar:D + \__kernel_primitive:NN \predisplaygapfactor \luatex_predisplaygapfactor:D \__kernel_primitive:NN \preexhyphenchar \luatex_preexhyphenchar:D \__kernel_primitive:NN \prehyphenchar \luatex_prehyphenchar:D \__kernel_primitive:NN \savecatcodetable \luatex_savecatcodetable:D @@ -858,15 +862,13 @@ \__kernel_primitive:NN \bodydir \luatex_bodydir:D \__kernel_primitive:NN \boxdir \luatex_boxdir:D \__kernel_primitive:NN \leftghost \luatex_leftghost:D + \__kernel_primitive:NN \linedir \luatex_linedir:D \__kernel_primitive:NN \localbrokenpenalty \luatex_localbrokenpenalty:D \__kernel_primitive:NN \localinterlinepenalty \luatex_localinterlinepenalty:D \__kernel_primitive:NN \localleftbox \luatex_localleftbox:D \__kernel_primitive:NN \localrightbox \luatex_localrightbox:D \__kernel_primitive:NN \mathdir \luatex_mathdir:D - \__kernel_primitive:NN \linedir \luatex_linedir:D - \__kernel_primitive:NN \pagebottomoffset \luatex_pagebottomoffset:D \__kernel_primitive:NN \pagedir \luatex_pagedir:D - \__kernel_primitive:NN \pagerightoffset \luatex_pagerightoffset:D \__kernel_primitive:NN \pardir \luatex_pardir:D \__kernel_primitive:NN \rightghost \luatex_rightghost:D \__kernel_primitive:NN \textdir \luatex_textdir:D diff --git a/Master/texmf-dist/source/latex/l3kernel/l3oldmodules.dtx b/Master/texmf-dist/source/latex/l3kernel/l3oldmodules.dtx index ddd243e7fe3..349c59adbdd 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3oldmodules.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3oldmodules.dtx @@ -21,7 +21,7 @@ % for those people who are interested. % %<*driver|oldmodules> -\def\ExplFileDate{2017/02/10} +\def\ExplFileDate{2017/03/07} %</driver|oldmodules> %<*driver> \documentclass[full]{l3doc} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx index 320c9d230e7..9ed983c9afb 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prg.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3prg.dtx 6811 2017-01-01 08:50:54Z joseph $ +\GetIdInfo$Id: l3prg.dtx 6906 2017-02-12 20:07:58Z bruno $ {L3 Control structures} %</driver|package> %<*driver> @@ -312,6 +312,21 @@ % terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\bool_log:N, \bool_log:c} +% \begin{syntax} +% \cs{bool_log:N} \meta{boolean} +% \end{syntax} +% Writes the logical truth of the \meta{boolean} in the log file. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\bool_log:n} +% \begin{syntax} +% \cs{bool_log:n} \Arg{boolean expression} +% \end{syntax} +% Writes the logical truth of the \meta{boolean expression} in the log +% file. +% \end{function} +% % \begin{function}[EXP, pTF, added=2012-03-03] % {\bool_if_exist:N, \bool_if_exist:c} % \begin{syntax} @@ -345,7 +360,7 @@ % A boolean expression is an expression which given input in the form % of predicate functions and boolean variables, return boolean % \meta{true} or \meta{false}. It supports the logical operations And, -% Or and Not as the well-known infix operators |&&|, \verb"||" and |!| +% Or and Not as the well-known infix operators |&&| and \verb"||" and prefix~|!| % with their usual precedences (namely, |&&| binds more tightly than % \verb"||"). In % addition to this, parentheses can be used to isolate @@ -849,6 +864,17 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\bool_log:N, \bool_log:c, \bool_log:n} +% Redirect output of \cs{bool_show:N} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \bool_log:N + { \__msg_log_next: \bool_show:N } +\cs_new_protected:Npn \bool_log:n + { \__msg_log_next: \bool_show:n } +\cs_generate_variant:Nn \bool_log:N { c } +% \end{macrocode} +% \end{macro} +% % \begin{variable}{\l_tmpa_bool, \l_tmpb_bool, \g_tmpa_bool, \g_tmpb_bool} % A few booleans just if you need them. % \begin{macrocode} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx index cb4deb613d7..290d45e463e 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3prop.dtx Copyright (C) 1990-2016 The LaTeX3 Project +%% File: l3prop.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3prop.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3prop.dtx 6906 2017-02-12 20:07:58Z bruno $ {L3 Property lists} %</driver|package> %<*driver> @@ -414,6 +414,13 @@ % Displays the entries in the \meta{property list} in the terminal. % \end{function} % +% \begin{function}[added = 2014-08-12, updated = 2015-08-01]{\prop_log:N, \prop_log:c} +% \begin{syntax} +% \cs{prop_log:N} \meta{property list} +% \end{syntax} +% Writes the entries in the \meta{property list} in the log file. +% \end{function} +% % \section{Scratch property lists} % % \begin{variable}[added = 2012-06-23]{\l_tmpa_prop, \l_tmpb_prop} @@ -1114,6 +1121,15 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\prop_log:N, \prop_log:c} +% Redirect output of \cs{prop_show:N} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \prop_log:N + { \__msg_log_next: \prop_show:N } +\cs_generate_variant:Nn \prop_log:N { c } +% \end{macrocode} +% \end{macro} +% % \begin{macrocode} %</initex|package> % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx index 2516c123615..90c38e62699 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3quark.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3quark.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3quark.dtx 6947 2017-02-17 21:27:18Z bruno $ {L3 Quarks} %</driver|package> %<*driver> @@ -206,8 +206,9 @@ % \cs{quark_if_recursion_tail_stop:N} \meta{token} % \end{syntax} % Tests if \meta{token} contains only the marker -% \cs{q_recursion_tail}, and if so terminates the recursion this is -% part of using \cs{use_none_delimit_by_q_recursion_stop:w}. The +% \cs{q_recursion_tail}, and if so uses +% \cs{use_none_delimit_by_q_recursion_stop:w} to terminate the +% recursion that this belongs to. The % recursion input must include the marker tokens \cs{q_recursion_tail} % and \cs{q_recursion_stop} as the last two items. % \end{function} @@ -218,8 +219,9 @@ % \cs{quark_if_recursion_tail_stop:n} \Arg{token list} % \end{syntax} % Tests if the \meta{token list} contains only -% \cs{q_recursion_tail}, and if so terminates the recursion this is -% part of using \cs{use_none_delimit_by_q_recursion_stop:w}. The +% \cs{q_recursion_tail}, and if so uses +% \cs{use_none_delimit_by_q_recursion_stop:w} to terminate the +% recursion that this belongs to. The % recursion input must include the marker tokens \cs{q_recursion_tail} % and \cs{q_recursion_stop} as the last two items. % \end{function} @@ -229,8 +231,9 @@ % \cs{quark_if_recursion_tail_stop_do:Nn} \meta{token} \Arg{insertion} % \end{syntax} % Tests if \meta{token} contains only the marker -% \cs{q_recursion_tail}, and if so terminates the recursion this is -% part of using \cs{use_none_delimit_by_q_recursion_stop:w}. The +% \cs{q_recursion_tail}, and if so uses +% \cs{use_none_delimit_by_q_recursion_stop:w} to terminate the +% recursion that this belongs to. The % recursion input must include the marker tokens \cs{q_recursion_tail} % and \cs{q_recursion_stop} as the last two items. The \meta{insertion} % code is then added to the input stream after the recursion has @@ -243,8 +246,9 @@ % \cs{quark_if_recursion_tail_stop_do:nn} \Arg{token list} \Arg{insertion} % \end{syntax} % Tests if the \meta{token list} contains only -% \cs{q_recursion_tail}, and if so terminates the recursion this is -% part of using \cs{use_none_delimit_by_q_recursion_stop:w}. The +% \cs{q_recursion_tail}, and if so uses +% \cs{use_none_delimit_by_q_recursion_stop:w} to terminate the +% recursion that this belongs to. The % recursion input must include the marker tokens \cs{q_recursion_tail} % and \cs{q_recursion_stop} as the last two items. The \meta{insertion} % code is then added to the input stream after the recursion has @@ -505,7 +509,7 @@ % a string like |aabc| instead of a single token.\footnote{It may % still loop in special circumstances however!} % \begin{macrocode} -\prg_new_conditional:Nnn \quark_if_nil:N { p, T , F , TF } +\prg_new_conditional:Npnn \quark_if_nil:N #1 { p, T , F , TF } { \if_meaning:w \q_nil #1 \prg_return_true: @@ -513,7 +517,7 @@ \prg_return_false: \fi: } -\prg_new_conditional:Nnn \quark_if_no_value:N { p, T , F , TF } +\prg_new_conditional:Npnn \quark_if_no_value:N #1 { p, T , F , TF } { \if_meaning:w \q_no_value #1 \prg_return_true: @@ -549,13 +553,13 @@ % second case, the result is not empty since the first~|?!| in the % definition of \cs{quark_if_nil:n} stop~|#3|. % \begin{macrocode} -\prg_new_conditional:Nnn \quark_if_nil:n { p, T , F , TF } +\prg_new_conditional:Npnn \quark_if_nil:n #1 { p, T , F , TF } { \__tl_if_empty_return:o { \@@_if_nil:w {} #1 {} ? ! \q_nil ? ? ! } } \cs_new:Npn \@@_if_nil:w #1 \q_nil #2 ? #3 ? ! { #1 #2 } -\prg_new_conditional:Nnn \quark_if_no_value:n { p, T , F , TF } +\prg_new_conditional:Npnn \quark_if_no_value:n #1 { p, T , F , TF } { \__tl_if_empty_return:o { \@@_if_no_value:w {} #1 {} ? ! \q_no_value ? ? ! } diff --git a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx index dbc4e4dd295..b78874e1227 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3seq.dtx 6842 2017-02-06 21:51:22Z joseph $ +\GetIdInfo$Id: l3seq.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Sequences and stacks} %</driver|package> %<*driver> @@ -858,6 +858,13 @@ % Displays the entries in the \meta{sequence} in the terminal. % \end{function} % +% \begin{function}[added = 2014-08-12, updated = 2015-08-01]{\seq_log:N, \seq_log:c} +% \begin{syntax} +% \cs{seq_log:N} \meta{sequence} +% \end{syntax} +% Writes the entries in the \meta{sequence} in the log file. +% \end{function} +% % \section{Internal sequence functions} % % \begin{variable}{\s__seq} @@ -1703,14 +1710,14 @@ } \cs_new:Npn \@@_item:nN #1#2 { - \int_compare:nNnTF {#1} < \c_zero - { \int_eval:n { \seq_count:N #2 + \c_one + #1 } } + \int_compare:nNnTF {#1} < 0 + { \int_eval:n { \seq_count:N #2 + 1 + #1 } } {#1} } \cs_new:Npn \@@_item:nnn #1#2#3 { \use_none:n #2 - \int_compare:nNnTF {#1} = \c_one + \int_compare:nNnTF {#1} = 1 { \__prg_break:n { \exp_not:n {#3} } } { \exp_args:Nf \@@_item:nnn { \int_eval:n { #1 - 1 } } } } @@ -1856,7 +1863,7 @@ \seq_map_function:NN #1 \@@_count:n } } -\cs_new:Npn \@@_count:n #1 { + \c_one } +\cs_new:Npn \@@_count:n #1 { + 1 } \cs_generate_variant:Nn \seq_count:N { c } % \end{macrocode} % \end{macro} @@ -2007,6 +2014,15 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\seq_log:N, \seq_log:c} +% Redirect output of \cs{seq_show:N} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \seq_log:N + { \__msg_log_next: \seq_show:N } +\cs_generate_variant:Nn \seq_log:N { c } +% \end{macrocode} +% \end{macro} +% % \subsection{Scratch sequences} % % \begin{variable}{\l_tmpa_seq, \l_tmpb_seq, \g_tmpa_seq, \g_tmpb_seq} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx index 838657d7950..8bc399e2d24 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3skip.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % %% File: l3skip.dtx Copyright (C) 2004-2011 Frank Mittelbach, The LaTeX3 Project -%% (C) 2012-2016 The LaTeX3 Project +%% (C) 2012-2017 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 @@ -25,7 +25,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3skip.dtx 6809 2017-01-01 06:33:13Z bruno $ +\GetIdInfo$Id: l3skip.dtx 6968 2017-02-20 16:08:44Z bruno $ {L3 Dimensions and skips} %</driver|package> %<*driver> @@ -525,6 +525,21 @@ % on the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\dim_log:N, \dim_log:c} +% \begin{syntax} +% \cs{dim_log:N} \meta{dimension} +% \end{syntax} +% Writes the value of the \meta{dimension} in the log file. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\dim_log:n} +% \begin{syntax} +% \cs{dim_log:n} \Arg{dimension expression} +% \end{syntax} +% Writes the result of evaluating the \meta{dimension expression} +% in the log file. +% \end{function} +% % \section{Constant dimensions} % % \begin{variable}{\c_max_dim} @@ -700,7 +715,7 @@ % % \section{Viewing \texttt{skip} variables} % -% \begin{function}{\skip_show:N, \skip_show:c} +% \begin{function}[updated = 2015-08-03]{\skip_show:N, \skip_show:c} % \begin{syntax} % \cs{skip_show:N} \meta{skip} % \end{syntax} @@ -715,6 +730,21 @@ % on the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\skip_log:N, \skip_log:c} +% \begin{syntax} +% \cs{skip_log:N} \meta{skip} +% \end{syntax} +% Writes the value of the \meta{skip} in the log file. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\skip_log:n} +% \begin{syntax} +% \cs{skip_log:n} \Arg{skip expression} +% \end{syntax} +% Writes the result of evaluating the \meta{skip expression} +% in the log file. +% \end{function} +% % \section{Constant skips} % % \begin{variable}[updated = 2012-11-02]{\c_max_skip} @@ -897,7 +927,7 @@ % % \section{Viewing \texttt{muskip} variables} % -% \begin{function}{\muskip_show:N, \muskip_show:c} +% \begin{function}[updated = 2015-08-03]{\muskip_show:N, \muskip_show:c} % \begin{syntax} % \cs{muskip_show:N} \meta{muskip} % \end{syntax} @@ -912,6 +942,21 @@ % on the terminal. % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-03]{\muskip_log:N, \muskip_log:c} +% \begin{syntax} +% \cs{muskip_log:N} \meta{muskip} +% \end{syntax} +% Writes the value of the \meta{muskip} in the log file. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\muskip_log:n} +% \begin{syntax} +% \cs{muskip_log:n} \Arg{muskip expression} +% \end{syntax} +% Writes the result of evaluating the \meta{muskip expression} +% in the log file. +% \end{function} +% % \section{Constant muskips} % % \begin{variable}{\c_max_muskip} @@ -1425,7 +1470,7 @@ ##1 . ##2 \tl_to_str:n { pt } } { - \int_compare:nNnTF {#2} > \c_zero + \int_compare:nNnTF {#2} > { 0 } { #1 . #2 } { #1 } } @@ -1492,6 +1537,16 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\dim_log:N, \dim_log:c, \dim_log:n} +% Diagnostics. Redirect output of \cs{dim_show:n} to the log. +% \begin{macrocode} +\cs_new_eq:NN \dim_log:N \__kernel_register_log:N +\cs_new_eq:NN \dim_log:c \__kernel_register_log:c +\cs_new_protected:Npn \dim_log:n + { \__msg_log_next: \dim_show:n } +% \end{macrocode} +% \end{macro} +% % \subsection{Constant dimensions} % % \begin{variable}{\c_zero_dim, \c_max_dim} @@ -1644,7 +1699,7 @@ { \if_int_compare:w \__str_if_eq_x:nn { \skip_eval:n { #1 } } { \skip_eval:n { #2 } } - = \c_zero + = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: @@ -1734,6 +1789,16 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\skip_log:N, \skip_log:c, \skip_log:n} +% Diagnostics. Redirect output of \cs{skip_show:n} to the log. +% \begin{macrocode} +\cs_new_eq:NN \skip_log:N \__kernel_register_log:N +\cs_new_eq:NN \skip_log:c \__kernel_register_log:c +\cs_new_protected:Npn \skip_log:n + { \__msg_log_next: \skip_show:n } +% \end{macrocode} +% \end{macro} +% % \subsection{Constant skips} % % \begin{macro}{\c_zero_skip, \c_max_skip} @@ -1924,6 +1989,16 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\muskip_log:N, \muskip_log:c, \muskip_log:n} +% Diagnostics. Redirect output of \cs{muskip_show:n} to the log. +% \begin{macrocode} +\cs_new_eq:NN \muskip_log:N \__kernel_register_log:N +\cs_new_eq:NN \muskip_log:c \__kernel_register_log:c +\cs_new_protected:Npn \muskip_log:n + { \__msg_log_next: \muskip_show:n } +% \end{macrocode} +% \end{macro} +% % \subsection{Constant muskips} % % \begin{macro}{\c_zero_muskip} diff --git a/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx b/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx index 265ae84fc05..5307712d1c4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3sort.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3sort.dtx 6847 2017-02-07 15:05:44Z bruno $ +\GetIdInfo$Id: l3sort.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Sorting functions} %</driver|package> %<*driver> @@ -199,26 +199,26 @@ \cs_new_protected:Npn \@@_shrink_range: { \int_set:Nn \l_@@_A_int - { \l_@@_true_max_int - \l_@@_min_int + \c_one } - \int_set:Nn \l_@@_block_int { \c_max_register_int / \c_two } + { \l_@@_true_max_int - \l_@@_min_int + 1 } + \int_set:Nn \l_@@_block_int { \c_max_register_int / 2 } \@@_shrink_range_loop: \int_set:Nn \l_@@_max_int { \int_compare:nNnTF - { \l_@@_block_int * \c_three / \c_two } > \l_@@_A_int + { \l_@@_block_int * 3 / 2 } > \l_@@_A_int { \l_@@_min_int - + ( \l_@@_A_int - \c_one ) / \c_two - + \l_@@_block_int / \c_four - - \c_one + + ( \l_@@_A_int - 1 ) / 2 + + \l_@@_block_int / 4 + - 1 } - { \l_@@_true_max_int - \l_@@_block_int / \c_two } + { \l_@@_true_max_int - \l_@@_block_int / 2 } } } \cs_new_protected:Npn \@@_shrink_range_loop: { \if_int_compare:w \l_@@_A_int < \l_@@_block_int - \tex_divide:D \l_@@_block_int \c_two + \tex_divide:D \l_@@_block_int 2 \exp_stop_f: \exp_after:wN \@@_shrink_range_loop: \fi: } @@ -251,8 +251,8 @@ %<*package> \cs_new_protected:Npn \@@_compute_range: { - \int_set:Nn \l_@@_min_int { \tex_count:D 15 + \c_one } - \int_set:Nn \l_@@_true_max_int { \c_max_register_int + \c_one } + \int_set:Nn \l_@@_min_int { \tex_count:D 15 + 1 } + \int_set:Nn \l_@@_true_max_int { \c_max_register_int + 1 } \@@_shrink_range: \if_meaning:w \loctoks \tex_undefined:D \else: \if_meaning:w \loctoks \scan_stop: \else: @@ -288,8 +288,8 @@ { \cs_gset_protected:Npn \@@_compute_range: { - \int_set:Nn \l_@@_min_int { #1 + \c_one } - \int_set:Nn \l_@@_true_max_int { \c_max_register_int + \c_one } + \int_set:Nn \l_@@_min_int { #1 + 1 } + \int_set:Nn \l_@@_true_max_int { \c_max_register_int + 1 } \@@_shrink_range: } } @@ -300,9 +300,9 @@ { ( \c_max_register_int + 1 ) * 3 / 4 } \cs_new_protected:Npn \@@_compute_range: { - \int_set_eq:NN \l_@@_min_int \c_zero - \int_set:Nn \l_@@_true_max_int { \c_max_register_int + \c_one } - \int_set_eq:NN \l_@@_max_int \c_@@_max_length_int + \int_set:Nn \l_@@_min_int { 0 } + \int_set:Nn \l_@@_true_max_int { \c_max_register_int + 1 } + \int_set:Nn \l_@@_max_int { \c_@@_max_length_int } } %</initex> % \end{macrocode} @@ -335,12 +335,12 @@ \@@_too_long_error:NNw #3 #5 \fi: \tex_toks:D \l_@@_top_int {##1} - \tex_advance:D \l_@@_top_int \c_one + \int_incr:N \l_@@_top_int } \int_set:Nn \l_@@_length_int { \l_@@_top_int - \l_@@_min_int } \cs_set:Npn \@@_compare:nn ##1 ##2 { #6 } - \int_set_eq:NN \l_@@_block_int \c_one + \int_set:Nn \l_@@_block_int { 1 } \@@_level: \use:x { @@ -464,7 +464,7 @@ \if_int_compare:w #3 < \l_@@_top_int #1 #2 { \tex_the:D \tex_toks:D #3 } \exp_after:wN \@@_toks:NNw \exp_after:wN #1 \exp_after:wN #2 - \__int_value:w \__int_eval:w #3 + \c_one \exp_after:wN ; + \__int_value:w \__int_eval:w #3 + 1 \exp_after:wN ; \fi: } % \end{macrocode} @@ -522,9 +522,9 @@ \l_@@_B_int \l_@@_A_int \l_@@_C_int \l_@@_top_int \@@_copy_block: - \tex_advance:D \l_@@_A_int - \c_one - \tex_advance:D \l_@@_B_int - \c_one - \tex_advance:D \l_@@_C_int - \c_one + \int_decr:N \l_@@_A_int + \int_decr:N \l_@@_B_int + \int_decr:N \l_@@_C_int \exp_after:wN \@@_merge_blocks_aux: \exp_after:wN \@@_merge_blocks: \fi: @@ -542,8 +542,8 @@ \cs_new_protected:Npn \@@_copy_block: { \tex_toks:D \l_@@_C_int \tex_toks:D \l_@@_B_int - \tex_advance:D \l_@@_C_int \c_one - \tex_advance:D \l_@@_B_int \c_one + \int_incr:N \l_@@_C_int + \int_incr:N \l_@@_B_int \if_int_compare:w \l_@@_B_int = \l_@@_end_int \use_i:nn \fi: @@ -621,8 +621,8 @@ \cs_new_protected:Npn \@@_return_same: { \tex_toks:D \l_@@_B_int \tex_toks:D \l_@@_C_int - \tex_advance:D \l_@@_B_int - \c_one - \tex_advance:D \l_@@_C_int - \c_one + \int_decr:N \l_@@_B_int + \int_decr:N \l_@@_C_int \if_int_compare:w \l_@@_C_int < \l_@@_top_int \use_i:nn \fi: @@ -645,8 +645,8 @@ \cs_new_protected:Npn \@@_return_swapped: { \tex_toks:D \l_@@_B_int \tex_toks:D \l_@@_A_int - \tex_advance:D \l_@@_B_int - \c_one - \tex_advance:D \l_@@_A_int - \c_one + \int_decr:N \l_@@_B_int + \int_decr:N \l_@@_A_int \if_int_compare:w \l_@@_A_int < \l_@@_begin_int \@@_merge_blocks_end: \use_i:nn \fi: @@ -665,8 +665,8 @@ \cs_new_protected:Npn \@@_merge_blocks_end: { \tex_toks:D \l_@@_B_int \tex_toks:D \l_@@_C_int - \tex_advance:D \l_@@_B_int - \c_one - \tex_advance:D \l_@@_C_int - \c_one + \int_decr:N \l_@@_B_int + \int_decr:N \l_@@_C_int \if_int_compare:w \l_@@_B_int < \l_@@_begin_int \use_i:nn \fi: @@ -1086,8 +1086,24 @@ % \begin{macro}[deprecated = 2018-12-31]{\sort_ordered:, \sort_reversed:} % These functions were renamed for consistency. % \begin{macrocode} -\cs_new_eq:NN \sort_ordered: \sort_return_same: -\cs_new_eq:NN \sort_reversed: \sort_return_swapped: +\cs_new_protected:Npn \sort_ordered: + { + \__msg_kernel_warning:nnxxx { kernel } { deprecated-command } + { 2018-12-31 } + { \token_to_str:N \sort_ordered: } + { \token_to_str:N \sort_return_same: } + \cs_gset_eq:NN \sort_ordered: \sort_return_same: + \sort_return_same: + } +\cs_new_protected:Npn \sort_reversed: + { + \__msg_kernel_warning:nnxxx { kernel } { deprecated-command } + { 2018-12-31 } + { \token_to_str:N \sort_reversed: } + { \token_to_str:N \sort_return_swapped: } + \cs_gset_eq:NN \sort_reversed: \sort_return_swapped: + \sort_return_swapped: + } % \end{macrocode} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3str.dtx b/Master/texmf-dist/source/latex/l3kernel/l3str.dtx index ea75d3e69d1..ef628bab6a3 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3str.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3str.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3str.dtx Copyright (C) 2011-2016 The LaTeX3 Project +%% File: l3str.dtx Copyright (C) 2011-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3str.dtx 6809 2017-01-01 06:33:13Z bruno $ +\GetIdInfo$Id: l3str.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Strings} %</driver|package> %<*driver> @@ -612,6 +612,15 @@ % time quadratic in the character count of the string. % \end{function} % +% \begin{function}[rEXP]{\__str_to_other_fast:n} +% \begin{syntax} +% \cs{__str_to_other_fast:n} \Arg{token list} +% \end{syntax} +% Same behaviour \cs{__str_to_other:n} but only restricted-expandable. +% It takes a time linear in the character count of the string. +% It is used for \cs{iow_wrap:nnnN}. +% \end{function} +% % \begin{function}[EXP]{\__str_count:n} % \begin{syntax} % \cs{__str_count:n} \Arg{other string} @@ -802,7 +811,7 @@ % \begin{macrocode} \cs_new:Npn \@@_if_eq_x_return:nn #1 #2 { - \if_int_compare:w \@@_if_eq_x:nn {#1} {#2} = \c_zero + \if_int_compare:w \@@_if_eq_x:nn {#1} {#2} = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: @@ -826,7 +835,7 @@ { \if_int_compare:w \@@_if_eq_x:nn { \exp_not:n {#1} } { \exp_not:n {#2} } - = \c_zero + = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: \fi: } \cs_generate_variant:Nn \str_if_eq_p:nn { V , o } @@ -839,7 +848,7 @@ \cs_generate_variant:Nn \str_if_eq:nnTF { nV , no , VV } \prg_new_conditional:Npnn \str_if_eq_x:nn #1#2 { p , T , F , TF } { - \if_int_compare:w \@@_if_eq_x:nn {#1} {#2} = \c_zero + \if_int_compare:w \@@_if_eq_x:nn {#1} {#2} = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: \fi: } % \end{macrocode} @@ -853,7 +862,7 @@ \prg_new_conditional:Npnn \str_if_eq:NN #1#2 { p , TF , T , F } { \if_int_compare:w \@@_if_eq_x:nn { \tl_to_str:N #1 } { \tl_to_str:N #2 } - = \c_zero \prg_return_true: \else: \prg_return_false: \fi: + = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: \fi: } \cs_generate_variant:Nn \str_if_eq:NNT { c , Nc , cc } \cs_generate_variant:Nn \str_if_eq:NNF { c , Nc , cc } @@ -976,6 +985,38 @@ % \end{macro} % \end{macro} % +% \begin{macro}[rEXP, int]{\@@_to_other_fast:n} +% \begin{macro}[rEXP, aux]{\@@_to_other_fast_loop:w, \@@_to_other_fast_end:w} +% The difference with \cs{@@_to_other:n} is that the converted part is +% left in the input stream, making these commands only +% restricted-expandable. +% \begin{macrocode} +\cs_new:Npn \@@_to_other_fast:n #1 + { + \exp_after:wN \@@_to_other_fast_loop:w \tl_to_str:n {#1} ~ + A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \q_stop + } +\group_begin: +\tex_lccode:D `\* = `\ % +\tex_lccode:D `\A = `\A +\tex_lowercase:D + { + \group_end: + \cs_new:Npn \@@_to_other_fast_loop:w + #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 ~ + { + \if_meaning:w A #9 + \@@_to_other_fast_end:w + \fi: + #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * #9 + \@@_to_other_fast_loop:w * + } + \cs_new:Npn \@@_to_other_fast_end:w #1 * A #2 \q_stop {#1} + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \begin{macro}[EXP] % {\str_item:Nn, \str_item:cn, \str_item:nn, \str_item_ignore_spaces:nn} % \begin{macro}[EXP, aux]{\@@_item:nn, \@@_item:w} @@ -1017,7 +1058,7 @@ } \cs_new:Npn \@@_item:w #1; #2; { - \int_compare:nNnTF {#1} < \c_zero + \int_compare:nNnTF {#1} < 0 { \int_compare:nNnTF {#1} < {-#2} { \use_none_delimit_by_q_stop:w } @@ -1059,7 +1100,7 @@ % \begin{macrocode} \cs_new:Npn \@@_skip_exp_end:w #1; { - \if_int_compare:w #1 > \c_eight + \if_int_compare:w #1 > 8 \exp_stop_f: \exp_after:wN \@@_skip_loop:wNNNNNNNN \else: \exp_after:wN \@@_skip_end:w @@ -1068,7 +1109,7 @@ #1 ; } \cs_new:Npn \@@_skip_loop:wNNNNNNNN #1; #2#3#4#5#6#7#8#9 - { \exp_after:wN \@@_skip_exp_end:w \__int_value:w \__int_eval:w #1 - \c_eight ; } + { \exp_after:wN \@@_skip_exp_end:w \__int_value:w \__int_eval:w #1 - 8 ; } \cs_new:Npn \@@_skip_end:w #1 ; { \exp_after:wN \@@_skip_end:NNNNNNNN @@ -1108,7 +1149,7 @@ { \exp_after:wN \@@_range:w \__int_value:w \@@_count:n {#1} \exp_after:wN ; - \__int_value:w \__int_eval:w #2 - \c_one \exp_after:wN ; + \__int_value:w \__int_eval:w #2 - 1 \exp_after:wN ; \__int_value:w \__int_eval:w #3 ; #1 \q_stop } @@ -1140,11 +1181,11 @@ { \int_eval:n { - \if_int_compare:w #1 < \c_zero + \if_int_compare:w #1 < 0 \exp_stop_f: \if_int_compare:w #1 < -#2 \exp_stop_f: - \c_zero + 0 \else: - #1 + #2 + \c_one + #1 + #2 + 1 \fi: \else: \if_int_compare:w #1 < #2 \exp_stop_f: @@ -1177,7 +1218,7 @@ { \@@_collect_loop:wn #1 ; { } } \cs_new:Npn \@@_collect_loop:wn #1 ; { - \if_int_compare:w #1 > \c_seven + \if_int_compare:w #1 > 7 \exp_stop_f: \exp_after:wN \@@_collect_loop:wnNNNNNNN \else: \exp_after:wN \@@_collect_end:wn @@ -1187,13 +1228,13 @@ \cs_new:Npn \@@_collect_loop:wnNNNNNNN #1; #2 #3#4#5#6#7#8#9 { \exp_after:wN \@@_collect_loop:wn - \__int_value:w \__int_eval:w #1 - \c_seven ; + \__int_value:w \__int_eval:w #1 - 7 ; { #2 #3#4#5#6#7#8#9 } } \cs_new:Npn \@@_collect_end:wn #1 ; { \exp_after:wN \@@_collect_end:nnnnnnnnw - \if_case:w \if_int_compare:w #1 > \c_zero #1 \else: 0 \fi: \exp_stop_f: + \if_case:w \if_int_compare:w #1 > 0 \exp_stop_f: #1 \else: 0 \fi: \exp_stop_f: \or: \or: \or: \or: \or: \or: \fi: } \cs_new:Npn \@@_collect_end:nnnnnnnnw #1#2#3#4#5#6#7#8 #9 \q_stop @@ -1231,7 +1272,7 @@ \if_meaning:w X #9 \use_i_delimit_by_q_stop:nw \fi: - \c_nine + \@@_count_spaces_loop:w + 9 + \@@_count_spaces_loop:w } % \end{macrocode} % \end{macro} @@ -1280,9 +1321,9 @@ \int_eval:n { #1 - { X \c_eight } { X \c_seven } { X \c_six } - { X \c_five } { X \c_four } { X \c_three } - { X \c_two } { X \c_one } { X \c_zero } + { X 8 } { X 7 } { X 6 } + { X 5 } { X 4 } { X 3 } + { X 2 } { X 1 } { X 0 } \q_stop } } @@ -1291,7 +1332,7 @@ \if_meaning:w X #9 \exp_after:wN \use_none_delimit_by_q_stop:w \fi: - \c_nine + \@@_count_loop:NNNNNNNNN + 9 + \@@_count_loop:NNNNNNNNN } % \end{macrocode} % \end{macro} @@ -1561,7 +1602,7 @@ % \LaTeXe{} and Con\TeX{}t MkII and MkIV). % \begin{macrocode} %<*initex> - \tex_chardef:D \g_@@_data_ior \c_zero + \tex_chardef:D \g_@@_data_ior = 0 \scan_stop: %</initex> %<*package> \tex_chardef:D \g_@@_data_ior @@ -1624,7 +1665,7 @@ \@@_parse_auxi:w #1#2 \q_stop \else: \if_int_compare:w \__str_if_eq_x:nn - { \exp_not:n {#2} } { ~Conditional~Mappings~ } = \c_zero + { \exp_not:n {#2} } { ~Conditional~Mappings~ } = 0 \exp_stop_f: \cs_set_protected:Npn \@@_parse:w ##1 \q_stop { } \fi: \fi: @@ -1658,7 +1699,7 @@ { \tl_if_blank:nF {#7} { - \if_int_compare:w \__str_if_eq_x:nn { #5 ~ } {#7} = \c_zero + \if_int_compare:w \__str_if_eq_x:nn { #5 ~ } {#7} = 0 \exp_stop_f: \else: \tl_const:cx { c_@@_title_ \utex_char:D "#1 _tl } @@ -1675,7 +1716,7 @@ % \begin{macrocode} \cs_set_protected:Npn \@@_parse_auxi:w #1 ;~ #2 ;~ #3 ; #4 \q_stop { - \if_int_compare:w \__str_if_eq_x:nn {#2} { C } = \c_zero + \if_int_compare:w \__str_if_eq_x:nn {#2} { C } = 0 \exp_stop_f: \if_int_compare:w \tex_lccode:D "#1 = "#3 \scan_stop: \else: \tl_const:cx @@ -1683,7 +1724,7 @@ { \utex_char:D "#3 ~ } \fi: \else: - \if_int_compare:w \__str_if_eq_x:nn {#2} { F } = \c_zero + \if_int_compare:w \__str_if_eq_x:nn {#2} { F } = 0 \exp_stop_f: \@@_parse_auxii:w #1 ~ #3 ~ \q_stop \fi: \fi: @@ -1699,7 +1740,7 @@ { \use:n { \@@_parse_auxii:w #1 ~ lower ~ #2 ~ } ~ \q_stop \use:n { \@@_parse_auxii:w #1 ~ upper ~ #4 ~ } ~ \q_stop - \if_int_compare:w \__str_if_eq_x:nn {#3} {#4} = \c_zero + \if_int_compare:w \__str_if_eq_x:nn {#3} {#4} = 0 \exp_stop_f: \else: \use:n { \@@_parse_auxii:w #1 ~ title ~ #3 ~ } ~ \q_stop \fi: diff --git a/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx index faca036fc44..a664fbd67da 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3sys.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3sys.dtx 6811 2017-01-01 08:50:54Z joseph $ +\GetIdInfo$Id: l3sys.dtx 6976 2017-02-22 16:49:53Z stonezeng $ {L3 Experimental system/runtime functions} %</driver|package> %<*driver> @@ -84,7 +84,7 @@ % \end{texnote} % \end{variable} % -% \subsection{Engine} +% \section{Engine} % % \begin{function}[added = 2015-09-07, EXP, pTF] % { @@ -110,7 +110,7 @@ % |luatex|, |pdftex|, |ptex|, |uptex| or |xetex|. % \end{variable} % -% \subsection{Output format} +% \section{Output format} % % \begin{function}[added = 2015-09-19, EXP, pTF] % { @@ -268,11 +268,8 @@ % \begin{variable}{\c_sys_output_str} % This is a simple enough concept: the two views here are complementary. % \begin{macrocode} -\bool_if:nTF - { - \cs_if_exist_p:N \pdftex_pdfoutput:D - && \int_compare_p:nNn \pdftex_pdfoutput:D > \c_zero - } +\int_compare:nNnTF + { \cs_if_exist_use:NF \pdftex_pdfoutput:D { 0 } } > { 0 } { \cs_new_eq:NN \sys_if_output_dvi:T \use_none:n \cs_new_eq:NN \sys_if_output_dvi:F \use:n diff --git a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx index 1acb5e14625..d3bffb0668a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3tl.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3tl.dtx Copyright (C) 1990-2016 The LaTeX3 Project +%% File: l3tl.dtx Copyright (C) 1990-2017 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 @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3tl.dtx 6842 2017-02-06 21:51:22Z joseph $ +\GetIdInfo$Id: l3tl.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Token lists} %</driver|package> %<*driver> @@ -1021,6 +1021,22 @@ % \end{texnote} % \end{function} % +% \begin{function}[added = 2014-08-22, updated = 2015-08-01]{\tl_log:N, \tl_log:c} +% \begin{syntax} +% \cs{tl_log:N} \meta{tl~var} +% \end{syntax} +% Writes the content of the \meta{tl~var} in the log file. See also +% \cs{tl_show:N} which displays the result in the terminal. +% \end{function} +% +% \begin{function}[added = 2014-08-22, updated = 2015-08-07]{\tl_log:n} +% \begin{syntax} +% \cs{tl_log:n} \Arg{token list} +% \end{syntax} +% Writes the \meta{token list} in the log file. See also +% \cs{tl_show:n} which displays the result in the terminal. +% \end{function} +% % \section{Constant token lists} % % \begin{variable}{\c_empty_tl} @@ -1473,7 +1489,7 @@ \group_begin: \exp_args:No \etex_everyeof:D { \c_@@_rescan_marker_tl \exp_not:N } \int_compare:nNnT \tex_endlinechar:D = { 32 } - { \tex_endlinechar:D - \c_one } + { \int_set:Nn \tex_endlinechar:D { -1 } } \tex_newlinechar:D \tex_endlinechar:D #3 \scan_stop: \exp_args:No \@@_set_rescan:n { \tl_to_str:n {#4} } @@ -1570,7 +1586,7 @@ \tex_catcode:D `\^^@ = 12 \scan_stop: \cs_new_protected:Npn \@@_set_rescan:n #1 { - \int_compare:nNnTF \tex_newlinechar:D < \c_zero + \int_compare:nNnTF \tex_newlinechar:D < 0 { \use_ii:nn } { \char_set_lccode:nn { 0 } { \tex_newlinechar:D } @@ -1585,7 +1601,7 @@ \cs_new_protected:Npn \@@_set_rescan_single:nn #1 { \int_compare:nNnTF - { \char_value_catcode:n { `#1 } / \c_three } = \c_four + { \char_value_catcode:n { `#1 } / 3 } = 4 { \@@_set_rescan_single_aux:nn {#1} } { \int_compare:nNnTF { `#1 } < { `\~ } @@ -1598,7 +1614,7 @@ } \cs_new_protected:Npn \@@_set_rescan_single_aux:nn #1#2 { - \tex_endlinechar:D - \c_one + \int_set:Nn \tex_endlinechar:D { -1 } \use:x { \exp_not:N \use:n @@ -1618,7 +1634,7 @@ \char_value_catcode:n { \exp_last_unbraced:Nf ` \str_head:n {#2} ~ } } - = \c_ten { ~ } + = { 10 } { ~ } \exp_after:wN \@@_rescan:w \exp_after:wN \prg_do_nothing: \etex_scantokens:D { #2 #1 } @@ -2309,7 +2325,7 @@ \int_eval:n { 0 \tl_map_function:NN #1 \@@_count:n } } -\cs_new:Npn \@@_count:n #1 { + \c_one } +\cs_new:Npn \@@_count:n #1 { + 1 } \cs_generate_variant:Nn \tl_count:n { V , o } \cs_generate_variant:Nn \tl_count:N { c } % \end{macrocode} @@ -2897,14 +2913,14 @@ } \cs_new:Npn \@@_item_aux:nn #1#2 { - \int_compare:nNnTF {#1} < \c_zero - { \int_eval:n { \tl_count:n {#2} + \c_one + #1 } } + \int_compare:nNnTF {#1} < 0 + { \int_eval:n { \tl_count:n {#2} + 1 + #1 } } {#1} } \cs_new:Npn \@@_item:nn #1#2 { \__quark_if_recursion_tail_break:nN {#2} \__prg_break: - \int_compare:nNnTF {#1} = \c_one + \int_compare:nNnTF {#1} = 1 { \__prg_break:n { \exp_not:n {#2} } } { \exp_args:Nf \@@_item:nn { \int_eval:n { #1 - 1 } } } } @@ -2941,6 +2957,17 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\tl_log:N, \tl_log:c, \tl_log:n} +% Redirect output of \cs{tl_show:N} and \cs{tl_show:n} to the log. +% \begin{macrocode} +\cs_new_protected:Npn \tl_log:N + { \__msg_log_next: \tl_show:N } +\cs_generate_variant:Nn \tl_log:N { c } +\cs_new_protected:Npn \tl_log:n + { \__msg_log_next: \tl_show:n } +% \end{macrocode} +% \end{macro} +% % \subsection{Scratch token lists} % % \begin{variable}{\g_tmpa_tl, \g_tmpb_tl} @@ -2970,9 +2997,23 @@ % For removal after 2017-12-31. % \begin{macrocode} \cs_new_protected:Npn \tl_to_lowercase:n #1 - { \tex_lowercase:D {#1} } + { + \__msg_kernel_warning:nnxxx { kernel } { deprecated-command } + { 2017-12-31 } + { \token_to_str:N \tl_to_lowercase:n } + { } + \cs_gset_eq:NN \tl_to_lowercase:n \tex_lowercase:D + \tex_lowercase:D {#1} + } \cs_new_protected:Npn \tl_to_uppercase:n #1 - { \tex_uppercase:D {#1} } + { + \__msg_kernel_warning:nnxxx { kernel } { deprecated-command } + { 2017-12-31 } + { \token_to_str:N \tl_to_uppercase:n } + { } + \cs_gset_eq:NN \tl_to_uppercase:n \tex_uppercase:D + \tex_uppercase:D {#1} + } % \end{macrocode} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx index 34bdf48ad68..cfae476c2df 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3token.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3token.dtx @@ -24,7 +24,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3token.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3token.dtx 6967 2017-02-20 14:51:30Z bruno $ {L3 Experimental token manipulation} %</driver|package> %<*driver> @@ -1174,37 +1174,37 @@ % } % \begin{macrocode} \cs_new_protected:Npn \char_set_catcode_escape:N #1 - { \char_set_catcode:nn { `#1 } \c_zero } + { \char_set_catcode:nn { `#1 } { 0 } } \cs_new_protected:Npn \char_set_catcode_group_begin:N #1 - { \char_set_catcode:nn { `#1 } \c_one } + { \char_set_catcode:nn { `#1 } { 1 } } \cs_new_protected:Npn \char_set_catcode_group_end:N #1 - { \char_set_catcode:nn { `#1 } \c_two } + { \char_set_catcode:nn { `#1 } { 2 } } \cs_new_protected:Npn \char_set_catcode_math_toggle:N #1 - { \char_set_catcode:nn { `#1 } \c_three } + { \char_set_catcode:nn { `#1 } { 3 } } \cs_new_protected:Npn \char_set_catcode_alignment:N #1 - { \char_set_catcode:nn { `#1 } \c_four } + { \char_set_catcode:nn { `#1 } { 4 } } \cs_new_protected:Npn \char_set_catcode_end_line:N #1 - { \char_set_catcode:nn { `#1 } \c_five } + { \char_set_catcode:nn { `#1 } { 5 } } \cs_new_protected:Npn \char_set_catcode_parameter:N #1 - { \char_set_catcode:nn { `#1 } \c_six } + { \char_set_catcode:nn { `#1 } { 6 } } \cs_new_protected:Npn \char_set_catcode_math_superscript:N #1 - { \char_set_catcode:nn { `#1 } \c_seven } + { \char_set_catcode:nn { `#1 } { 7 } } \cs_new_protected:Npn \char_set_catcode_math_subscript:N #1 - { \char_set_catcode:nn { `#1 } \c_eight } + { \char_set_catcode:nn { `#1 } { 8 } } \cs_new_protected:Npn \char_set_catcode_ignore:N #1 - { \char_set_catcode:nn { `#1 } \c_nine } + { \char_set_catcode:nn { `#1 } { 9 } } \cs_new_protected:Npn \char_set_catcode_space:N #1 - { \char_set_catcode:nn { `#1 } \c_ten } + { \char_set_catcode:nn { `#1 } { 10 } } \cs_new_protected:Npn \char_set_catcode_letter:N #1 - { \char_set_catcode:nn { `#1 } \c_eleven } + { \char_set_catcode:nn { `#1 } { 11 } } \cs_new_protected:Npn \char_set_catcode_other:N #1 - { \char_set_catcode:nn { `#1 } \c_twelve } + { \char_set_catcode:nn { `#1 } { 12 } } \cs_new_protected:Npn \char_set_catcode_active:N #1 - { \char_set_catcode:nn { `#1 } \c_thirteen } + { \char_set_catcode:nn { `#1 } { 13 } } \cs_new_protected:Npn \char_set_catcode_comment:N #1 - { \char_set_catcode:nn { `#1 } \c_fourteen } + { \char_set_catcode:nn { `#1 } { 14 } } \cs_new_protected:Npn \char_set_catcode_invalid:N #1 - { \char_set_catcode:nn { `#1 } \c_fifteen } + { \char_set_catcode:nn { `#1 } { 15 } } % \end{macrocode} % \end{macro} % @@ -1229,37 +1229,37 @@ % } % \begin{macrocode} \cs_new_protected:Npn \char_set_catcode_escape:n #1 - { \char_set_catcode:nn {#1} \c_zero } + { \char_set_catcode:nn {#1} { 0 } } \cs_new_protected:Npn \char_set_catcode_group_begin:n #1 - { \char_set_catcode:nn {#1} \c_one } + { \char_set_catcode:nn {#1} { 1 } } \cs_new_protected:Npn \char_set_catcode_group_end:n #1 - { \char_set_catcode:nn {#1} \c_two } + { \char_set_catcode:nn {#1} { 2 } } \cs_new_protected:Npn \char_set_catcode_math_toggle:n #1 - { \char_set_catcode:nn {#1} \c_three } + { \char_set_catcode:nn {#1} { 3 } } \cs_new_protected:Npn \char_set_catcode_alignment:n #1 - { \char_set_catcode:nn {#1} \c_four } + { \char_set_catcode:nn {#1} { 4 } } \cs_new_protected:Npn \char_set_catcode_end_line:n #1 - { \char_set_catcode:nn {#1} \c_five } + { \char_set_catcode:nn {#1} { 5 } } \cs_new_protected:Npn \char_set_catcode_parameter:n #1 - { \char_set_catcode:nn {#1} \c_six } + { \char_set_catcode:nn {#1} { 6 } } \cs_new_protected:Npn \char_set_catcode_math_superscript:n #1 - { \char_set_catcode:nn {#1} \c_seven } + { \char_set_catcode:nn {#1} { 7 } } \cs_new_protected:Npn \char_set_catcode_math_subscript:n #1 - { \char_set_catcode:nn {#1} \c_eight } + { \char_set_catcode:nn {#1} { 8 } } \cs_new_protected:Npn \char_set_catcode_ignore:n #1 - { \char_set_catcode:nn {#1} \c_nine } + { \char_set_catcode:nn {#1} { 9 } } \cs_new_protected:Npn \char_set_catcode_space:n #1 - { \char_set_catcode:nn {#1} \c_ten } + { \char_set_catcode:nn {#1} { 10 } } \cs_new_protected:Npn \char_set_catcode_letter:n #1 - { \char_set_catcode:nn {#1} \c_eleven } + { \char_set_catcode:nn {#1} { 11 } } \cs_new_protected:Npn \char_set_catcode_other:n #1 - { \char_set_catcode:nn {#1} \c_twelve } + { \char_set_catcode:nn {#1} { 12 } } \cs_new_protected:Npn \char_set_catcode_active:n #1 - { \char_set_catcode:nn {#1} \c_thirteen } + { \char_set_catcode:nn {#1} { 13 } } \cs_new_protected:Npn \char_set_catcode_comment:n #1 - { \char_set_catcode:nn {#1} \c_fourteen } + { \char_set_catcode:nn {#1} { 14 } } \cs_new_protected:Npn \char_set_catcode_invalid:n #1 - { \char_set_catcode:nn {#1} \c_fifteen } + { \char_set_catcode:nn {#1} { 15 } } % \end{macrocode} % \end{macro} % @@ -1418,26 +1418,26 @@ % \begin{macrocode} \cs_new:Npn \@@_generate_aux:w #1 ; #2 ; { - \if_int_compare:w #2 = \c_thirteen + \if_int_compare:w #2 = 13 \exp_stop_f: \__msg_kernel_expandable_error:nn { kernel } { char-active } \else: - \if_int_compare:w #2 = \c_ten - \if_int_compare:w #1 = \c_zero + \if_int_compare:w #2 = 10 \exp_stop_f: + \if_int_compare:w #1 = 0 \exp_stop_f: \__msg_kernel_expandable_error:nn { kernel } { char-null-space } \else: \__msg_kernel_expandable_error:nn { kernel } { char-space } \fi: \else: \if_int_odd:w 0 - \if_int_compare:w #2 < \c_one 1 \fi: - \if_int_compare:w #2 = \c_five 1 \fi: - \if_int_compare:w #2 = \c_nine 1 \fi: - \if_int_compare:w #2 > \c_thirteen 1 \fi: \exp_stop_f: + \if_int_compare:w #2 < 1 \exp_stop_f: 1 \fi: + \if_int_compare:w #2 = 5 \exp_stop_f: 1 \fi: + \if_int_compare:w #2 = 9 \exp_stop_f: 1 \fi: + \if_int_compare:w #2 > 13 \exp_stop_f: 1 \fi: \exp_stop_f: \__msg_kernel_expandable_error:nn { kernel } { char-invalid-catcode } \else: \if_int_odd:w 0 - \if_int_compare:w #1 < \c_zero 1 \fi: + \if_int_compare:w #1 < 0 \exp_stop_f: 1 \fi: \if_int_compare:w #1 > \c_@@_max_int 1 \fi: \exp_stop_f: \__msg_kernel_expandable_error:nn { kernel } { char-out-of-range } @@ -1885,7 +1885,7 @@ ##1 \tl_to_str:n { ma } ##2 \c_colon_str ##3 \exp_not:N \q_stop } { - \if_int_compare:w \__str_if_eq_x:nn { #2 } { cro } = \c_zero + \if_int_compare:w \__str_if_eq_x:nn { #2 } { cro } = 0 \exp_stop_f: \prg_return_true: \else: \prg_return_false: |