summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-03-31 00:04:47 +0000
committerKarl Berry <karl@freefriends.org>2010-03-31 00:04:47 +0000
commit3ab55a61f6f8d2218a8f3175bc7481ce162b60d3 (patch)
treef606e0c2117a8058213441400e50ba25400ba94a /Master/texmf-dist/source/latex/expl3
parent035ea73193af75f6ade46e306603e61d82b24950 (diff)
expl3 1881 (30mar10)
git-svn-id: svn://tug.org/texlive/trunk@17631 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3')
-rw-r--r--Master/texmf-dist/source/latex/expl3/expl3.dtx220
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3.ins118
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3alloc.dtx182
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3basics.dtx120
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3box.dtx114
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3calc.dtx4
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3candidates.dtx101
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3clist.dtx92
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3doc.dtx9
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3expan.dtx171
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3file.dtx426
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3final.dtx199
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3format.ins81
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3int.dtx101
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3intexpr.dtx435
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3io.dtx1288
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3keys.dtx459
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3keyval.dtx422
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3msg.dtx415
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3names.dtx92
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3num.dtx35
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3precom.dtx78
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3prg.dtx64
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3prop.dtx51
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3quark.dtx8
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3seq.dtx87
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3skip.dtx135
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3tl.dtx1028
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3token.dtx114
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3toks.dtx76
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3vers.dtx6
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3xref.dtx10
-rw-r--r--Master/texmf-dist/source/latex/expl3/source3.tex414
33 files changed, 4396 insertions, 2759 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/expl3.dtx b/Master/texmf-dist/source/latex/expl3/expl3.dtx
index 2ffb707a1bc..7f8292d609a 100644
--- a/Master/texmf-dist/source/latex/expl3/expl3.dtx
+++ b/Master/texmf-dist/source/latex/expl3/expl3.dtx
@@ -37,7 +37,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: expl3.dtx 1677 2009-11-02 08:24:04Z joseph $
+\GetIdInfo$Id: expl3.dtx 1866 2010-03-23 08:29:27Z joseph $
{L3 Experimental code bundle wrapper}%
%\iffalse
%<*driver>
@@ -310,8 +310,6 @@
% \item[box] box register;
% \item[skip] `rubber' lengths;
% \item[dim] `rigid' lengths;
-% \item[num] A `fake' integer type using only macros. Useful for
-% setting up allocation routines;
% \item[seq] `sequence': a data-type used to implement lists (with
% access at both ends) and stacks;
% \item[prop] property list;
@@ -330,8 +328,46 @@
% characters. It provides two ways to store these token lists: within
% macros and as token registers (toks). \LaTeX3 retains the name `toks'
% for the later, and adopts the name `token list variables' (tl vars)
-% for macros used to store tokens. In most circumstances, the tl var
-% data type is more convenient for storing token lists.
+% for macros used to store tokens.
+%
+%\subsubsection{Variables: guidance}
+%
+% Although \TeX\ provides token registers for certain programming
+% tasks, \LaTeX3 is written so that token list variables can be used
+% for all stored lists of tokens. The \cs{toks_\ldots} functions are
+% therefore for internal use within \LaTeX3 and for supporting
+% \LaTeXe, and should not be needed in new \LaTeX3-based code.
+%
+% Both comma lists and sequences both have similar characteristics.
+% They both use special delimiters to mark out one entry from the
+% next, and are both accessible at both ends. In general, it is
+% easier to create comma lists `by hand' as they can be typed
+% in directly. User input often takes the form of a comma separated
+% list and so there are many cases where this is the obvious
+% data type to use. On the other hand, sequences use special internal
+% tokens to separate entries. This means that they can be used to
+% contain material that comma lists cannot (such as items that may
+% themselves contain commas!). In general, comma lists should be
+% preferred for creating fixed lists inside programs and for
+% handling user input where commas will not occur. On the other
+% hand, sequences should be used to store arbitrary lists of
+% data.
+%
+% \pkg{expl3} implements stacks using the sequence data structure.
+% Thus creating stacks involves first creating a sequence, and
+% then using the sequence functions which work in a stack manner
+% (\cs{seq_push:Nn}, \emph{etc}.).
+%
+% Due to the nature of the underlying \TeX\ implementation, it is
+% possible to assign values to token list variables and comma lists
+% without first declaring them. However, this is \emph{not supported
+% behaviour}. The \LaTeX3 coding convention is that all variables must
+% be declared before use.
+%
+% The expl3 package can be loaded with the "check-declarations" option
+% to verify that all variables are declared before use. This has a
+% performance implication and is therefore intended for testing during
+% development and not for use in production documents.
%
%\subsubsection{Functions: argument specifications}
%
@@ -449,12 +485,25 @@
% name (via~|\csname| \ldots |\endcsname|). This command name is the
% single token that is passed to the function as the argument. Hence
% \begin{quote}
-% "\seq_gpush:cV { g_file_name_stack } \l_tmpa_tl"
+% "\seq_gpush:cV { g_file_name_seq } \l_tmpa_tl"
% \end{quote}
% is equivalent to
% \begin{quote}
-% "\seq_gpush:NV \g_file_name_stack \l_tmpa_tl".
+% "\seq_gpush:NV \g_file_name_seq \l_tmpa_tl".
% \end{quote}
+% Remember that \texttt{c} arguments are \emph{fully expanded} by
+% \TeX\ when creating csnames. This means that (a) the entire
+% argument must be expandable and (b) any variables will be
+% converted to their content. So the preceding examples are also
+% equivalent to
+% \begin{quote}
+% "\tl_new:N \g_file_seq_name_tl" \\
+% "\tl_gset:Nn \g_file_seq_name_tl { g_file_name_seq }" \\
+% "\seq_gpush:cV { \g_file_seq_name_tl } \l_tmpa_tl".
+% \end{quote}
+% (Token list variables are expandable and do not require an
+% accessor function. Other variable types require the appropriate
+% \cs{<var>_use:N} functions to be used in this context.)
% \item[V] Value of a variable.\\
% This means that the contents of the register in question is used as the
% argument, be it an integer, a length-type register, a token list variable
@@ -685,9 +734,6 @@
% This sets up the basic naming scheme and renames all
% the \TeX\ primitives.
% }
-% \explpkg{l3num}{
-% This implements the `fake integer' datatype \texttt{num}.
-% }
% \explpkg{l3prg}{
% Program control structures such as boolean data type |bool|, generic
% do-while loops, case-switches, sorting routines and stepwise loops.
@@ -813,6 +859,12 @@
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
% \end{macrocode}
+%
+% Load \pkg{etex} as otherwise we are likely to get into trouble
+% with registers.
+% \begin{macrocode}
+\RequirePackage{etex}
+% \end{macrocode}
%
% We already loaded \pkg{l3names} at the beginning of the \texttt{dtx} file.
%
@@ -826,7 +878,6 @@
l3basics,
l3expan,
l3tl,
- l3num,
l3intexpr,
l3quark,
l3seq,
@@ -835,9 +886,9 @@
l3prg,
l3clist,
l3token,
- l3io,
l3prop,
l3msg,
+ l3io,
l3skip,
}
% \end{macrocode}
@@ -853,6 +904,151 @@
l3file
}
% \end{macrocode}
+%
+%\begin{macro}{\_l_expl_check_declarations_bool}
+% To indicate that token list variables should exist before
+% assignment, a flag is created and a single option provided.
+% \begin{macrocode}
+\bool_new:N \_l_expl_check_declarations_bool
+\DeclareOption{check-declarations}{
+ \bool_set_true:N \_l_expl_check_declarations_bool
+}
+\ProcessOptions \scan_stop:
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\_tl_check_exists:N}
+% If the option is active, redefine token list variable functions to
+% be picky.
+% \begin{macrocode}
+\bool_if:NT \_l_expl_check_declarations_bool {
+ \msg_kernel_new:nnnn { check } { non-declared-variable }
+ { The~variable~#1~has~not~been~declared~\msg_line_context:. }
+ {
+ Checking~is~active,~and~you~have~tried~do~so~something~like: \\
+ \c_space_tl \c_space_tl \tl_set:Nn #1 ~
+ \iow_char:N \{ ~ ... ~ \iow_char:N \} \\
+ without~first~having: \\
+ \c_space_tl \c_space_tl \tl_new:N #1 \\
+ \\
+ LaTeX~will~create~the~variable~and~continue.
+ }
+ \cs_set_protected:Npn \_tl_check_exists:N #1
+ {
+ \cs_if_exist:NF #1
+ {
+ \msg_kernel_error:nnx { check } { non-declared-variable }
+ { \token_to_str:N #1 }
+ }
+ }
+ \cs_set_protected:Npn \tl_set:Nn #1#2
+ {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:n {#2} }
+ }
+ \cs_set_protected:Npn \tl_set:Nx #1#2
+ {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 {#2}
+ }
+ \cs_set_protected:Npn \tl_gset:Nn #1#2
+ {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:n {#2} }
+ }
+ \cs_set_protected:Npn \tl_gset:Nx #1#2
+ {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 {#2}
+ }
+ \cs_set_protected:Npn \tl_set_eq:NN #1#2
+ {
+ \_tl_check_exists:N #1
+ \_tl_check_exists:N #2
+ \cs_set_eq:NN #1 #2
+ }
+ \cs_set_protected:Npn \tl_gset_eq:NN #1#2
+ {
+ \_tl_check_exists:N #1
+ \_tl_check_exists:N #2
+ \cs_gset_eq:NN #1 #2
+ }
+ \cs_set_protected:Npn \tl_put_right:Nn #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} }
+ }
+ \cs_set_protected:Npn \tl_put_right:NV #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 }
+ }
+ \cs_set_protected:Npn \tl_put_right:Nv #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} }
+ }
+ \cs_set_protected:Npn \tl_put_right:No #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:o {#2} }
+ }
+ \cs_set_protected:Npn \tl_put_right:Nx #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 #2 }
+ }
+ \cs_set_protected:Npn \tl_gput_right:Nn #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} }
+ }
+ \cs_set_protected:Npn \tl_gput_right:NV #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 }
+ }
+ \cs_set_protected:Npn \tl_gput_right:Nv #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} }
+ }
+ \cs_set_protected:Npn \tl_gput_right:Nx #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 #2 }
+ }
+ \cs_set_protected:Npn \tl_put_left:Nn #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_put_left:NV #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_put_left:Nv #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_put_left:No #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { \exp_not:o {#2} \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_put_left:Nx #1#2 {
+ \_tl_check_exists:N #1
+ \cs_set_nopar:Npx #1 { #2 \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_gput_left:Nn #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_gput_left:NV #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_gput_left:Nv #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 }
+ }
+ \cs_set_protected:Npn \tl_gput_left:Nx #1#2 {
+ \_tl_check_exists:N #1
+ \cs_gset_nopar:Npx #1 { #2 \exp_not:V #1 }
+ }
+}
+% \end{macrocode}
+%\end{macro}
+%
%</package>
%
% \end{implementation}
diff --git a/Master/texmf-dist/source/latex/expl3/l3.ins b/Master/texmf-dist/source/latex/expl3/l3.ins
new file mode 100644
index 00000000000..4d6718c0431
--- /dev/null
+++ b/Master/texmf-dist/source/latex/expl3/l3.ins
@@ -0,0 +1,118 @@
+
+\input docstrip.tex
+\askforoverwritefalse
+
+\preamble
+
+
+EXPERIMENTAL CODE
+
+Do not distribute this file without also distributing the
+source files specified above.
+
+Do not distribute a modified version of this file.
+
+
+\endpreamble
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+% wrapper package for the expl3 bundle
+\generate{\file{expl3.sty}{\from{expl3.dtx}{package}}}
+
+
+% l3names.sty sets up the naming scheme for TeX primitives.
+\generate{\file{l3names.sty}{\from{l3names.dtx}{package}}}
+
+
+
+% Define some basic commands to get us started with the new
+% programming style.
+\generate{\file{l3basics.sty}{\from{l3basics.dtx}{package,trace}}}
+
+
+% Define some basic commands that check various conditions
+% related to defining commands eg defined/undefined global/local
+% Not sure how much of this really makes sense as a package, but...
+\generate{\file{l3chk.sty}{\from{l3chk.dtx}{package,trace}}}
+
+
+%% toks register handling (can be compiled with check module)
+\generate{\file{l3toks.sty}{\from{l3toks.dtx}{package,trace}}}
+
+
+%% token lists
+\generate{\file{l3tl.sty}{\from{l3tl.dtx}{package,trace}}}
+
+
+%% LaTeX3 expansion module
+\generate{\file{l3expan.sty}{\from{l3expan.dtx}{package,trace}}}
+
+
+%% LaTeX3 quarks.
+\generate{\file{l3quark.sty}{\from{l3quark.dtx}{package,trace}}}
+
+
+%% LaTeX3 sequences.
+\generate{\file{l3seq.sty}{\from{l3seq.dtx}{package,trace}}}
+
+
+%% LaTeX3 clists.
+\generate{\file{l3clist.sty}{\from{l3clist.dtx}{package,trace}}}
+
+
+%% LaTeX3 property lists.
+\generate{\file{l3prop.sty}{\from{l3prop.dtx}{package,trace}}}
+
+
+%% LaTeX3 fake integer macros. --- this is still needed in places such as xor !!!
+\generate{\file{l3num.sty}{\from{l3num.dtx}{package,trace}}}
+
+%% LaTeX3 integer registers. (can be compiled with check module)
+\generate{\file{l3int.sty}{\from{l3int.dtx}{package,trace}}}
+
+%% LaTeX3 integer expressions.
+\generate{\file{l3intexpr.sty}{\from{l3intexpr.dtx}{package,trace}}}
+
+
+%% LaTeX3 skip registers.
+\generate{\file{l3skip.sty}{\from{l3skip.dtx}{package,trace}}}
+
+
+%% LaTeX3 precompilation
+\generate{\file{l3precom.sty}{\from{l3precom.dtx}{package,precompile,trace}}}
+
+%% LaTeX3 I/O module.
+\generate{\file{l3io.sty}{\from{l3io.dtx}{package,trace}}}
+
+%% LaTeX3 program control structures (loops, booleans, ...)
+\generate{\file{l3prg.sty}{\from{l3prg.dtx}{package}}}
+
+%% LaTeX3 box module
+\generate{\file{l3box.sty}{\from{l3box.dtx}{package}}}
+
+%% LaTeX3 messages
+\generate{\file{l3msg.sty}{\from{l3msg.dtx}{package}}}
+
+%% LaTeX3 tokens
+\generate{\file{l3token.sty}{\from{l3token.dtx}{package}}}
+
+%% LaTeX3 cross references
+\generate{\file{l3xref.sty}{\from{l3xref.dtx}{package}}}
+%%\generate{\file{l3xref-test.tex}{\from{l3xref.dtx}{testfile}}}
+
+%% LaTeX3 calc module
+\generate{\file{l3calc.sty}{\from{l3calc.dtx}{package}}}
+
+%% LaTeX3 keyval modules
+\generate{\file{l3keyval.sty}{\from{l3keyval.dtx}{package}}}
+\generate{\file{l3keys.sty}{\from{l3keys.dtx}{package}}}
+
+%% LaTeX3 file loading
+\generate{\file{l3file.sty}{\from{l3file.dtx}{package}}}
+
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx
index a2031c45493..5c5d82b13ad 100644
--- a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx
@@ -32,11 +32,11 @@
%%
%% -----------------------------------------------------------------------
%
-%<*driver|package>
+%<*driver>
\RequirePackage{l3names}
-%</driver|package>
+%</driver>
%\fi
-\GetIdInfo$Id: l3alloc.dtx 1362 2009-05-28 20:19:21Z joseph $
+\GetIdInfo$Id: l3alloc.dtx 1867 2010-03-23 13:03:12Z will $
{L3 Experimental register allocation}%
%\iffalse
%<*driver>
@@ -64,6 +64,10 @@
%
% \section{Allocating registers and the like}
%
+% Note that this module is only used for generating an pkg{expl3}-based
+% format. Under \LaTeXe, the |etex.sty| 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:
@@ -92,6 +96,21 @@
%
% \section{Functions}
%
+%
+% \begin{function}{\alloc_new:nnnN}
+% \begin{syntax}
+% "\alloc_new:nnnN" \Arg{type} \Arg{min} \Arg{max} <alloc_cmd>
+% \end{syntax}
+% Shorthand for allocating new registers. Defines \cs{<type>_new:N} and
+% \cs{<type>_new_local:N} allocators of the specified <type>, indexed up from
+% <min> for global registers and down from <max> for local registers, with
+% registers assigned using the function <alloc_cmd>.
+%
+% Internally uses "\alloc_setup_type:nnn" and "\alloc_reg:NnNN"
+% defined below in case you want finer-grained control.
+% \end{function}
+%
+%
% \begin{function}{\alloc_setup_type:nnn}
% \begin{syntax}
% "\alloc_setup_type:nnn" \Arg{type} \Arg{g_start_num} \Arg{l_start_num}
@@ -126,10 +145,9 @@
%
% \subsection{Internal functions}
%
-% \begin{function}{ \alloc_next_g:n |
-% \alloc_next_l:n }
+% \begin{function}{ \alloc_next:Nn }
% \begin{syntax}
-% "\alloc_next_g:n" \Arg{type}
+% "\alloc_next:Nn" "l"/"g" \Arg{type}
% \end{syntax}
% These functions find the next free register for the specified type.
% \end{function}
@@ -137,12 +155,7 @@
% \subsection{Module code}
%
% \begin{macrocode}
-%<*package>
-\ProvidesExplPackage
- {\filename}{\filedate}{\fileversion}{\filedescription}
-\package_check_loaded_expl:
-%</package>
-%<*initex|package>
+%<*initex>
% \end{macrocode}
%
% \begin{macro}{\alloc_setup_type:nnn}
@@ -150,114 +163,101 @@
% last allocated global or local register. We also need a sequence
% to store the `exceptions'.
% \begin{macrocode}
-\cs_new_nopar:Npn \alloc_setup_type:nnn #1 #2 #3{
- \num_new:c {g_ #1 _allocation_num}
- \num_new:c {l_ #1 _allocation_num}
- \seq_new:c {g_ #1 _allocation_seq}
- \num_set:cn {g_ #1 _allocation_num}{#2}
- \num_set:cn {l_ #1 _allocation_num}{#3}
+\cs_new_nopar:Npn \alloc_setup_type:nnn #1#2#3 {
+ \seq_new:c {g_#1_allocation_seq}
+ \tl_new:cn {g_#1_allocation_tl } {#2}
+ \tl_new:cn {l_#1_allocation_tl } {#3}
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\alloc_next_g:n}
-% \begin{macro}{\alloc_next_l:n}
-% These routines find the next free register. For globally allocated
-% registers we first increment the counter that keeps track of them.
-% \begin{macrocode}
-\cs_new_nopar:Npn \alloc_next_g:n #1 {
- \num_gincr:c {g_ #1 _allocation_num}
-% \end{macrocode}
-% Then we need to check whether we have run out of registers.
+% \begin{macro}{\alloc_next:Nn}
+% This routine finds the next free register. For globally allocated
+% registers we first increment the counter that keeps track of them;
+% for local registers, decrement.
% \begin{macrocode}
- \intexpr_compare:nTF {
- \num_use:c{g_ #1 _allocation_num} = \num_use:c{l_ #1 _allocation_num}
- }
- {\iow_term:x{We~ ran~ out~ of~ registers~ of~ type~ g_#1!}}
- {
-% \end{macrocode}
-% We also need to check whether the value of the counter already
-% occurs in the list of already allocated registers.
-% \begin{macrocode}
- \seq_if_in:cxT {g_ #1 _allocation_seq}
- {\num_use:c{g_ #1 _allocation_num}}
-% \end{macrocode}
-% If it does, we find the next value.
-% \begin{macrocode}
- { \iow_term:x{\num_use:c{g_ #1 _allocation_num}~already~allocated!}
- \alloc_next_g:n {#1} }
+\cs_new_nopar:Npn \alloc_next:Nn #1#2 {
+ \tl_set:cx {#1_#2_allocation_tl}
+ {
+ \intexpr_eval:n
+ {
+ \tl_use:c {#1_#2_allocation_tl}
+ \if:w #1 g + \else: - \fi: 1
+ }
}
% \end{macrocode}
-% By now the |.._allocation_num| counter will contain the number of
-% the register we will assign a control seuence for.
+% Then we need to check whether we have run out of registers.
% \begin{macrocode}
- }
+ \intexpr_compare:nNnTF
+ { \tl_use:c{g_#2_allocation_tl} } = { \tl_use:c{l_#2_allocation_tl} }
+ {
+ \iow_term:x {
+ We~ ran~ out~ of~
+ \if:w #1 g \scan_stop: global~ \else: local~ \fi:
+ 'l#2!'~ registers!
+ }
+ }
% \end{macrocode}
-% For the locally allocated registers we have a similar function.
+% We also need to check whether the value of the counter already
+% occurs in the list of already allocated registers.
% \begin{macrocode}
-\cs_new_nopar:Npn \alloc_next_l:n #1 {
- \num_gdecr:c {l_ #1 _allocation_num}
+ {
+ \seq_if_in:cxTF {g_#2_allocation_seq} {\tl_use:c{#1_#2_allocation_tl}}
+ {
+ \iow_log:x{ \tl_use:c{#1_#2_allocation_tl}~already~allocated. }
+ \alloc_next:Nn #1 {#2}
+ }
% \end{macrocode}
-% (Will: should that be "\num_decr" (no "g") ?!)
+% By now the |.._allocation_tl| counter will contain the number of
+% the register we will assign a control sequence for.
% \begin{macrocode}
- \intexpr_compare:nTF {
- \num_use:c{g_ #1 _allocation_num} = \num_use:c{l_ #1 _allocation_num}
- }
- {\iow_term:x{We~ ran~ out~ of~ registers~ of~ type~ l_#1!}}
- {
- \seq_if_in:cxTF {g_ #1 _allocation_seq}
- {\num_use:c{l_ #1 _allocation_num}}
- { \iow_term:x{\num_use:c{l_ #1 _allocation_num}~already~allocated!}
- \alloc_next_l:n {#1} }
- { \iow_term:x{\num_use:c{l_ #1 _allocation_num}~free!} }
+ { \iow_log:x{\tl_use:c{#1_#2_allocation_tl}~free.} }
}
- }
+}
% \end{macrocode}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\alloc_reg:NnNN}
-% This internal macro performs the actual allocation. Its first
-% argument is either 'g' for a globally allocated register or `l'
-% for a locally allocated register. The second argument is the
-% type of register to allocate, the third argument is the command
-% to use and the fourth argument is the control sequence that is to
-% be defined to point to the register.
-% \begin{macrocode}
-\cs_new_nopar:Npn \alloc_reg:NnNN #1 #2 #3 #4{
-% \end{macrocode}
-% It first checks that the control sequence that is to denote the
-% register does not already exist.
+% This internal macro performs the actual allocation. Its first
+% argument is either `|g|' for a globally allocated register or `|l|'
+% for a locally allocated register. The second argument is the
+% type of register to allocate, the third argument is the command
+% to use and the fourth argument is the control sequence that is to
+% be defined to point to the register.
% \begin{macrocode}
+\cs_new_nopar:Npn \alloc_reg:NnNN #1#2#3#4 {
\chk_if_free_cs:N #4
-% \end{macrocode}
-% Next, it decides whether a prefix is needed for the allocation
-% command;
-% \begin{macrocode}
\if:w #1 g
\exp_after:wN \pref_global:D
\fi:
-% \end{macrocode}
-% And finally the actual allocation takes place.
-% \begin{macrocode}
- #3 #4 \num_use:c{#1_ #2 _allocation_num}
+ #3 #4 \tl_use:c{#1_ #2 _allocation_tl}
%%\cs_record_meaning:N#1
-% \end{macrocode}
-% All that's left to do is write a message in the log file.
-% \begin{macrocode}
\iow_log:x{
- \token_to_str:N#4=#2~register~\num_use:c{#1_ #2 _allocation_num}}
-% \end{macrocode}
-% Finally, it calls |\alloc_next_|\meta{\texttt{\textup g}/\texttt{\textup l}} to find the next free register
-% number.
-% \begin{macrocode}
- \use:c{alloc_next_#1:n} {#2}
+ \token_to_str:N#4~=~#2~register~\tl_use:c{#1_#2_allocation_tl}
+ }
+ \alloc_next:Nn #1 {#2}
}
% \end{macrocode}
% \end{macro}
%
+%
+% \begin{macro}{\alloc_new:nnnN}
+% Shorthand for defining new register types and their allocators:
+% \begin{macrocode}
+\cs_new:Npn \alloc_new:nnnN #1#2#3#4 {
+ \alloc_setup_type:nnn {#1} {#2} {#3}
+ \cs_new_nopar:cpn {#1_new:N} ##1 {
+ \alloc_reg:NnNN g {#1} #4 ##1
+ }
+ \cs_new_nopar:cpn {#1_new_local:N} ##1 {
+ \alloc_reg:NnNN l {#1} #4 ##1
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
-%</initex|package>
+%</initex>
% \end{macrocode}
%
% \begin{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3basics.dtx b/Master/texmf-dist/source/latex/expl3/l3basics.dtx
index f49489bd17f..d4466987e6d 100644
--- a/Master/texmf-dist/source/latex/expl3/l3basics.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3basics.dtx
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3basics.dtx 1700 2009-11-04 21:15:58Z joseph $
+\GetIdInfo$Id: l3basics.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental basic definitions}
%\iffalse
%<*driver>
@@ -438,13 +438,25 @@
% \begin{syntax}
% "\use:c" \Arg{cs}
% \end{syntax}
-% Function that returns to the input stream the control sequence created from
+% Function that returns to the input stream the control sequence created from
% its argument. Requires two expansions before a control sequence is returned.
% \begin{texnote}
% "\use:c" is \LaTeXe's "\@nameuse".
% \end{texnote}
% \end{function}
%
+% \begin{function}{ \use:x }
+% \begin{syntax}
+% "\use:x" \Arg{expandable tokens}
+% \end{syntax}
+% Function that fully expands its argument before passing it to the input
+% stream. Contents of the argument must be fully expandable.
+% \begin{texnote}
+% Lua\TeX\ provides "\expanded" which performs this operation in an expandable
+% manner, but we cannot assume this behaviour on all platforms yet.
+% \end{texnote}
+% \end{function}
+%
% \begin{function}{ \use_none:n / (EXP) |
% \use_none:nn / (EXP) |
% \use_none:nnn / (EXP) |
@@ -1113,14 +1125,20 @@
%
% \subsection{Undefining functions}
%
-% \begin{function}{
+% \begin{function}{
+% \cs_undefine:N |
+% \cs_undefine:c |
% \cs_gundefine:N |
% \cs_gundefine:c
% }
% \begin{syntax}
% "\cs_gundefine:N" <cs>
% \end{syntax}
-% Undefines the control sequence globally.
+% Undefines the control sequence locally or globally.
+% In a global context, this is useful for reclaiming a small amount of
+% memory but shouldn't often be needed for this purpose.
+% In a local context, this can be useful if you need to clear a definition
+% before applying a short-term modification to something.
% \end{function}
%
%
@@ -1603,6 +1621,20 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\use:x}
+% Fully expands its argument and passes it to the input stream.
+% Uses "\cs_tmp:" as a scratch register but does not affect it.
+% \begin{macrocode}
+\cs_set_protected:Npn \use:x #1 {
+ \group_begin:
+ \cs_set:Npx \cs_tmp: {#1}
+ \exp_args:wN
+ \group_end:
+ \cs_tmp:
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\use:n}
% \begin{macro}{\use:nn}
% \begin{macro}{\use:nnn}
@@ -1825,25 +1857,25 @@
% function into name and signature and then use, e.g., |\cs_set:Npn|
% to define it with.
% \begin{macrocode}
-\cs_set:Npn \prg_set_conditional:Npnn #1{
+\cs_set_protected:Npn \prg_set_conditional:Npnn #1{
\prg_get_parm_aux:nw{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_set:Npn {parm}
}
}
-\cs_set:Npn \prg_new_conditional:Npnn #1{
+\cs_set_protected:Npn \prg_new_conditional:Npnn #1{
\prg_get_parm_aux:nw{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_new:Npn {parm}
}
}
-\cs_set:Npn \prg_set_protected_conditional:Npnn #1{
+\cs_set_protected:Npn \prg_set_protected_conditional:Npnn #1{
\prg_get_parm_aux:nw{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_set_protected:Npn {parm}
}
}
-\cs_set:Npn \prg_new_protected_conditional:Npnn #1{
+\cs_set_protected:Npn \prg_new_protected_conditional:Npnn #1{
\prg_get_parm_aux:nw{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_new_protected:Npn {parm}
@@ -1860,27 +1892,27 @@
% into name and signature and then use, e.g., |\cs_set:Npn| to
% define it with.
% \begin{macrocode}
-\cs_set:Npn \prg_set_conditional:Nnn #1{
+\cs_set_protected:Npn \prg_set_conditional:Nnn #1{
\exp_args:Nnf \prg_get_count_aux:nn{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_set:Npn {count}
}{\cs_get_arg_count_from_signature:N #1}
}
-\cs_set:Npn \prg_new_conditional:Nnn #1{
+\cs_set_protected:Npn \prg_new_conditional:Nnn #1{
\exp_args:Nnf \prg_get_count_aux:nn{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_new:Npn {count}
}{\cs_get_arg_count_from_signature:N #1}
}
-\cs_set:Npn \prg_set_protected_conditional:Nnn #1{
+\cs_set_protected:Npn \prg_set_protected_conditional:Nnn #1{
\exp_args:Nnf \prg_get_count_aux:nn{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_set_protected:Npn {count}
}{\cs_get_arg_count_from_signature:N #1}
}
-\cs_set:Npn \prg_new_protected_conditional:Nnn #1{
+\cs_set_protected:Npn \prg_new_protected_conditional:Nnn #1{
\exp_args:Nnf \prg_get_count_aux:nn{
\cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
\cs_new_protected:Npn {count}
@@ -1892,10 +1924,10 @@
% \begin{macro}{\prg_set_eq_conditional:NNn,\prg_new_eq_conditional:NNn}
% The obvious setting-equal functions.
% \begin{macrocode}
-\cs_set:Npn \prg_set_eq_conditional:NNn #1#2#3 {
+\cs_set_protected:Npn \prg_set_eq_conditional:NNn #1#2#3 {
\prg_set_eq_conditional_aux:NNNn \cs_set_eq:cc #1#2 {#3}
}
-\cs_set:Npn \prg_new_eq_conditional:NNn #1#2#3 {
+\cs_set_protected:Npn \prg_new_eq_conditional:NNn #1#2#3 {
\prg_set_eq_conditional_aux:NNNn \cs_new_eq:cc #1#2 {#3}
}
% \end{macrocode}
@@ -2303,7 +2335,7 @@
% \begin{macro}{\c_sixteen}
% We need the constants |\c_minus_one| and |\c_sixteen| now for
% writing information to the log and the terminal and |\c_zero|
-% which is used by some functions in the \textsf{l3num}module. The
+% which is used by some functions in the \textsf{l3alloc} module. The
% rest are defined in the \textsf{l3int} module -- at least for the
% ones that can be defined with |\tex_chardef:D| or
% |\tex_mathchardef:D|. For other constants the \textsf{l3int} module is
@@ -2343,10 +2375,10 @@
% similar one for writing to both the log file and the terminal.
%
% \begin{macrocode}
-\cs_set_nopar:Npn \iow_log:x {
+\cs_set_protected_nopar:Npn \iow_log:x {
\tex_immediate:D \iow_shipout_x:Nn \c_minus_one
}
-\cs_set_nopar:Npn \iow_term:x {
+\cs_set_protected_nopar:Npn \iow_term:x {
\tex_immediate:D \iow_shipout_x:Nn \c_sixteen
}
% \end{macrocode}
@@ -2356,7 +2388,7 @@
% \begin{macro}{\msg_kernel_bug:x}
% This will show internal errors.
% \begin{macrocode}
-\cs_set_nopar:Npn \msg_kernel_bug:x #1 {
+\cs_set_protected_nopar:Npn \msg_kernel_bug:x #1 {
\iow_term:x { This~is~a~LaTeX~bug:~check~coding! }
\tex_errmessage:D {#1}
}
@@ -2383,7 +2415,7 @@
% issued. We have to make sure we don't put the argument into the
% conditional processing since it may be an |\if...| type function!
% \begin {macrocode}
-\cs_set_nopar:Npn \chk_if_free_cs:N #1{
+\cs_set_protected_nopar:Npn \chk_if_free_cs:N #1{
\cs_if_free:NF #1
{
\msg_kernel_bug:x {Command~name~`\token_to_str:N #1'~
@@ -2398,7 +2430,9 @@
line~\tex_the:D \tex_inputlineno:D}
%</trace>
}
-\cs_set_nopar:Npn \chk_if_free_cs:c { \exp_args:Nc \chk_if_free_cs:N }
+\cs_set_protected_nopar:Npn \chk_if_free_cs:c {
+ \exp_args:Nc \chk_if_free_cs:N
+}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2408,14 +2442,16 @@
% This function issues a warning message when the control sequence
% in its argument does not exist.
% \begin{macrocode}
-\cs_set_nopar:Npn \chk_if_exist_cs:N #1 {
+\cs_set_protected_nopar:Npn \chk_if_exist_cs:N #1 {
\cs_if_exist:NF #1
{
\msg_kernel_bug:x {Command~ `\token_to_str:N #1'~
not~ yet~ defined!}
}
}
-\cs_set_nopar:Npn \chk_if_exist_cs:c {\exp_args:Nc \chk_if_exist_cs:N }
+\cs_set_protected_nopar:Npn \chk_if_exist_cs:c {
+ \exp_args:Nc \chk_if_exist_cs:N
+}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2764,9 +2800,9 @@
%
% \begin{macrocode}
\cs_set_protected:Npn \cs_set_eq:NN #1 { \cs_set_eq:NwN #1=~ }
-\cs_set_nopar:Npn \cs_set_eq:cN { \exp_args:Nc \cs_set_eq:NN }
-\cs_set_nopar:Npn \cs_set_eq:Nc { \exp_args:NNc \cs_set_eq:NN }
-\cs_set_nopar:Npn \cs_set_eq:cc { \exp_args:Ncc \cs_set_eq:NN }
+\cs_set_protected_nopar:Npn \cs_set_eq:cN { \exp_args:Nc \cs_set_eq:NN }
+\cs_set_protected_nopar:Npn \cs_set_eq:Nc { \exp_args:NNc \cs_set_eq:NN }
+\cs_set_protected_nopar:Npn \cs_set_eq:cc { \exp_args:Ncc \cs_set_eq:NN }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2782,9 +2818,9 @@
\chk_if_free_cs:N #1
\cs_set_eq:NN #1
}
-\cs_new_nopar:Npn \cs_new_eq:cN { \exp_args:Nc \cs_new_eq:NN }
-\cs_new_nopar:Npn \cs_new_eq:Nc { \exp_args:NNc \cs_new_eq:NN }
-\cs_new_nopar:Npn \cs_new_eq:cc { \exp_args:Ncc \cs_new_eq:NN }
+\cs_new_protected_nopar:Npn \cs_new_eq:cN { \exp_args:Nc \cs_new_eq:NN }
+\cs_new_protected_nopar:Npn \cs_new_eq:Nc { \exp_args:NNc \cs_new_eq:NN }
+\cs_new_protected_nopar:Npn \cs_new_eq:cc { \exp_args:Ncc \cs_new_eq:NN }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2797,9 +2833,9 @@
% \begin{macro}{\cs_gset_eq:cc}
% \begin{macrocode}
\cs_new_protected:Npn \cs_gset_eq:NN { \pref_global:D \cs_set_eq:NN }
-\cs_new_nopar:Npn \cs_gset_eq:Nc { \exp_args:NNc \cs_gset_eq:NN }
-\cs_new_nopar:Npn \cs_gset_eq:cN { \exp_args:Nc \cs_gset_eq:NN }
-\cs_new_nopar:Npn \cs_gset_eq:cc { \exp_args:Ncc \cs_gset_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gset_eq:Nc { \exp_args:NNc \cs_gset_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gset_eq:cN { \exp_args:Nc \cs_gset_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gset_eq:cc { \exp_args:Ncc \cs_gset_eq:NN }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2815,9 +2851,9 @@
\chk_if_free_cs:N #1
\pref_global:D \cs_set_eq:NN #1
}
-\cs_new_nopar:Npn \cs_gnew_eq:cN { \exp_args:Nc \cs_gnew_eq:NN }
-\cs_new_nopar:Npn \cs_gnew_eq:Nc { \exp_args:NNc \cs_gnew_eq:NN }
-\cs_new_nopar:Npn \cs_gnew_eq:cc { \exp_args:Ncc \cs_gnew_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gnew_eq:cN { \exp_args:Nc \cs_gnew_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gnew_eq:Nc { \exp_args:NNc \cs_gnew_eq:NN }
+\cs_new_protected_nopar:Npn \cs_gnew_eq:cc { \exp_args:Ncc \cs_gnew_eq:NN }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2827,13 +2863,21 @@
%
% \subsection{Undefining functions}
%
-% \begin{macro}{\cs_gundefine:N }
-% \begin{macro}{\cs_gundefine:c }
+% \begin{macro}{\cs_undefine:N , \cs_undefine:c }
+% \begin{macro}{\cs_gundefine:N , \cs_gundefine:c }
% The following function is used to free the main memory from the
% definition of some function that isn't in use any longer.
% \begin{macrocode}
-\cs_new_nopar:Npn \cs_gundefine:N #1{\cs_gset_eq:NN #1\c_undefined:D}
-\cs_new_nopar:Npn \cs_gundefine:c #1{
+\cs_new_protected_nopar:Npn \cs_undefine:N #1 {
+ \cs_set_eq:NN #1 \c_undefined:D
+}
+\cs_new_protected_nopar:Npn \cs_undefine:c #1 {
+ \cs_set_eq:cN {#1} \c_undefined:D
+}
+\cs_new_protected_nopar:Npn \cs_gundefine:N #1 {
+ \cs_gset_eq:NN #1 \c_undefined:D
+}
+\cs_new_protected_nopar:Npn \cs_gundefine:c #1 {
\cs_gset_eq:cN {#1} \c_undefined:D
}
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3box.dtx b/Master/texmf-dist/source/latex/expl3/l3box.dtx
index bf619435d63..0031dfc9f4f 100644
--- a/Master/texmf-dist/source/latex/expl3/l3box.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3box.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3box.dtx Copyright (C) 2005-2009 LaTeX3 project
+%% File: l3box.dtx Copyright (C) 2005-2010 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3box.dtx 1375 2009-06-01 12:28:52Z joseph $
+\GetIdInfo$Id: l3box.dtx 1867 2010-03-23 13:03:12Z will $
{L3 Experimental Box module}
%\iffalse
%<*driver>
@@ -69,18 +69,18 @@
%
% \section{Generic functions}
%
-% \begin{function}{%
-% \box_new:N |
-% \box_new:c |
-%^^A \box_new_l:N
-% }
+% \begin{function}{ \box_new:N |
+% \box_new:c |
+% \box_new_local:N |
+% \box_new_local:c }
% \begin{syntax}
% "\box_new:N" <box>
% \end{syntax}
% Defines <box> to be a new variable of type "box".
+% With the |local| variant, the variable is only available within the
+% current group level (or below).
% \begin{texnote}
% "\box_new:N" is the equivalent of plain \TeX{}'s \tn{newbox}.
-% However, the internal register allocation is done differently.
% \end{texnote}
% \end{function}
%
@@ -305,7 +305,7 @@
% \begin{syntax}
% "\hbox_set:Nn" <box> \Arg{contents}
% \end{syntax}
-% Sets <box> to be a vertical mode box containing \m{contents}. It has
+% Sets <box> to be a horizontal mode box containing \m{contents}. It has
% it's natural size. "\hbox_gset:Nn" does it globally.
% \end{function}
%
@@ -338,6 +338,18 @@
%
%
% \begin{function}{%
+% \hbox_overlap_left:n |
+% \hbox_overlap_right:n |
+% }
+% \begin{syntax}
+% "\hbox_overlap_left:n" <contents>
+% \end{syntax}
+% Places a <box> of width zero containing <contents> in a way the it overlaps
+% with surrounding material (sticking out to the left or right).
+% \end{function}
+%
+%
+% \begin{function}{%
% \hbox_set_inline_begin:N |
% \hbox_set_inline_begin:c |
% \hbox_set_inline_end: |
@@ -496,36 +508,42 @@
% \subsection{Generic boxes}
%
% \begin{macro}{\box_new:N,\box_new:c}
-%^^A \begin{macro}{\box_new_l:N}
+% \begin{macro}{\box_new_local:N,\box_new_local:c}
% Defining a new \m{box} register.
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {box} \c_zero \c_max_register_num
+\alloc_new:nnnN {box} \c_zero \c_max_register_int \tex_mathchardef:D
% \end{macrocode}
% Now, remember that |\box255| has a special role in \TeX, it
% shouldn't be allocated\dots
% \begin{macrocode}
\seq_put_right:Nn \g_box_allocation_seq {255}
-\cs_new_nopar:Npn \box_new:N #1 {\alloc_reg:NnNN g {box} \tex_mathchardef:D #1}
-\cs_new_nopar:Npn \box_new_l:N #1 {\alloc_reg:NnNN l {box} \tex_mathchardef:D #1}
%</initex>
% \end{macrocode}
% When we run on top of \LaTeX, we just use its allocation
% mechanism.
% \begin{macrocode}
%<*package>
-\cs_new:Npn \box_new:N #1 {
+\cs_new_protected:Npn \box_new:N #1 {
\chk_if_free_cs:N #1
\newbox #1
}
+\cs_new_protected:Npn \box_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newbox \locbox
+ #1
+}
%</package>
% \end{macrocode}
-%
+%
% \begin{macrocode}
\cs_generate_variant:Nn \box_new:N {c}
+\cs_generate_variant:Nn \box_new_local:N {c}
% \end{macrocode}
% \end{macro}
-%^^A \end{macro}
+% \end{macro}
%
% \begin{macro}{\if_hbox:N}
% \begin{macro}{\if_vbox:N}
@@ -592,7 +610,7 @@
% Assigning the contents of a box to be another box.
% This clears the second box globally (that's how \TeX{} does it).
% \begin{macrocode}
-\cs_new_nopar:Npn \box_set_eq:NN #1#2 {\tex_setbox:D #1 \tex_box:D #2}
+\cs_new_protected_nopar:Npn \box_set_eq:NN #1#2 {\tex_setbox:D #1 \tex_box:D #2}
\cs_generate_variant:Nn \box_set_eq:NN {cN,Nc,cc}
% \end{macrocode}
% \end{macro}
@@ -601,7 +619,7 @@
% \box_gset_eq:Nc,\box_gset_eq:cc}
% Global version of the above.
% \begin{macrocode}
-\cs_new_nopar:Npn \box_gset_eq:NN {\pref_global:D\box_set_eq:NN}
+\cs_new_protected_nopar:Npn \box_gset_eq:NN {\pref_global:D\box_set_eq:NN}
\cs_generate_variant:Nn \box_gset_eq:NN {cN,Nc,cc}
% \end{macrocode}
% \end{macro}
@@ -617,9 +635,9 @@
% \begin{macro}{\box_gset_to_last:N,\box_gset_to_last:c}
% Set a box to the previous box.
% \begin{macrocode}
-\cs_new_nopar:Npn \box_set_to_last:N #1{\tex_setbox:D#1\l_last_box}
+\cs_new_protected_nopar:Npn \box_set_to_last:N #1{\tex_setbox:D#1\l_last_box}
\cs_generate_variant:Nn \box_set_to_last:N {c}
-\cs_new_nopar:Npn \box_gset_to_last:N {\pref_global:D \box_set_to_last:N}
+\cs_new_protected_nopar:Npn \box_gset_to_last:N {\pref_global:D \box_set_to_last:N}
\cs_generate_variant:Nn \box_gset_to_last:N {c}
% \end{macrocode}
% \end{macro}
@@ -645,9 +663,9 @@
% \begin{macro}{\box_gclear:N,\box_gclear:c}
% Clear a \m{box} register.
% \begin{macrocode}
-\cs_new_nopar:Npn \box_clear:N #1{\box_set_eq:NN #1 \c_empty_box }
+\cs_new_protected_nopar:Npn \box_clear:N #1{\box_set_eq:NN #1 \c_empty_box }
\cs_generate_variant:Nn \box_clear:N {c}
-\cs_new_nopar:Npn \box_gclear:N {\pref_global:D\box_clear:N}
+\cs_new_protected_nopar:Npn \box_gclear:N {\pref_global:D\box_clear:N}
\cs_generate_variant:Nn \box_gclear:N {c}
% \end{macrocode}
% \end{macro}
@@ -713,7 +731,7 @@
% \begin{macro}{\vbox:n}
% Put a vertical box directly into the input stream.
% \begin{macrocode}
-\cs_new_nopar:Npn \vbox:n {\tex_vbox:D \scan_stop:}
+\cs_new_protected_nopar:Npn \vbox:n {\tex_vbox:D \scan_stop:}
% \end{macrocode}
% \end{macro}
%
@@ -721,9 +739,9 @@
% \begin{macro}{\vbox_gset:Nn,\vbox_gset:cn}
% Storing material in a vertical box with a natural height.
% \begin{macrocode}
-\cs_new:Npn \vbox_set:Nn #1#2 {\tex_setbox:D #1 \tex_vbox:D {#2}}
+\cs_new_protected:Npn \vbox_set:Nn #1#2 {\tex_setbox:D #1 \tex_vbox:D {#2}}
\cs_generate_variant:Nn \vbox_set:Nn {cn}
-\cs_new_nopar:Npn \vbox_gset:Nn {\pref_global:D \vbox_set:Nn}
+\cs_new_protected_nopar:Npn \vbox_gset:Nn {\pref_global:D \vbox_set:Nn}
\cs_generate_variant:Nn \vbox_gset:Nn {cn}
% \end{macrocode}
% \end{macro}
@@ -733,11 +751,11 @@
% \begin{macro}{\vbox_gset_to_ht:Nnn,\vbox_gset_to_ht:cnn,\vbox_gset_to_ht:ccn}
% Storing material in a vertical box with a specified height.
% \begin{macrocode}
-\cs_new:Npn \vbox_set_to_ht:Nnn #1#2#3 {
+\cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3 {
\tex_setbox:D #1 \tex_vbox:D to #2 {#3}
}
\cs_generate_variant:Nn \vbox_set_to_ht:Nnn {cnn}
-\cs_new_nopar:Npn \vbox_gset_to_ht:Nnn { \pref_global:D \vbox_set_to_ht:Nnn }
+\cs_new_protected_nopar:Npn \vbox_gset_to_ht:Nnn { \pref_global:D \vbox_set_to_ht:Nnn }
\cs_generate_variant:Nn \vbox_gset_to_ht:Nnn {cnn,ccn}
% \end{macrocode}
% \end{macro}
@@ -751,10 +769,10 @@
% Storing material in a vertical box. This type is useful in
% environment definitions.
% \begin{macrocode}
-\cs_new_nopar:Npn \vbox_set_inline_begin:N #1 {
+\cs_new_protected_nopar:Npn \vbox_set_inline_begin:N #1 {
\tex_setbox:D #1 \tex_vbox:D \c_group_begin_token }
\cs_new_eq:NN \vbox_set_inline_end: \c_group_end_token
-\cs_new_nopar:Npn \vbox_gset_inline_begin:N {
+\cs_new_protected_nopar:Npn \vbox_gset_inline_begin:N {
\pref_global:D \vbox_set_inline_begin:N }
\cs_new_eq:NN \vbox_gset_inline_end: \c_group_end_token
% \end{macrocode}
@@ -768,8 +786,8 @@
% \begin{macro}{\vbox_to_zero:n}
% Put a vertical box directly into the input stream.
% \begin{macrocode}
-\cs_new:Npn \vbox_to_ht:nn #1#2{\tex_vbox:D to \dim_eval:n{#1}{#2}}
-\cs_new:Npn \vbox_to_zero:n #1 {\tex_vbox:D to \c_zero_dim {#1}}
+\cs_new_protected:Npn \vbox_to_ht:nn #1#2{\tex_vbox:D to \dim_eval:n{#1}{#2}}
+\cs_new_protected:Npn \vbox_to_zero:n #1 {\tex_vbox:D to \c_zero_dim {#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -777,7 +795,7 @@
% \begin{macro}{\vbox_set_split_to_ht:NNn}
% Splitting a vertical box in two.
% \begin{macrocode}
-\cs_new_nopar:Npn \vbox_set_split_to_ht:NNn #1#2#3{
+\cs_new_protected_nopar:Npn \vbox_set_split_to_ht:NNn #1#2#3{
\tex_setbox:D #1 \tex_vsplit:D #2 to #3
}
% \end{macrocode}
@@ -806,7 +824,7 @@
% \begin{macro}{\hbox:n}
% Put a horizontal box directly into the input stream.
% \begin{macrocode}
-\cs_new_nopar:Npn \hbox:n {\tex_hbox:D \scan_stop:}
+\cs_new_protected_nopar:Npn \hbox:n {\tex_hbox:D \scan_stop:}
% \end{macrocode}
% \end{macro}
%
@@ -815,9 +833,9 @@
% Assigning the contents of a box to be another box.
% This clears the second box globally (that's how \TeX{} does it).
% \begin{macrocode}
-\cs_new:Npn \hbox_set:Nn #1#2 {\tex_setbox:D #1 \tex_hbox:D {#2}}
+\cs_new_protected:Npn \hbox_set:Nn #1#2 {\tex_setbox:D #1 \tex_hbox:D {#2}}
\cs_generate_variant:Nn \hbox_set:Nn {cn}
-\cs_new_nopar:Npn \hbox_gset:Nn {\pref_global:D \hbox_set:Nn}
+\cs_new_protected_nopar:Npn \hbox_gset:Nn {\pref_global:D \hbox_set:Nn}
\cs_generate_variant:Nn \hbox_gset:Nn {cn}
% \end{macrocode}
% \end{macro}
@@ -827,17 +845,16 @@
% \begin{macro}{\hbox_gset_to_wd:Nnn,\hbox_gset_to_wd:cnn}
% Storing material in a horizontal box with a specified width.
% \begin{macrocode}
-\cs_new:Npn \hbox_set_to_wd:Nnn #1#2#3 {
+\cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3 {
\tex_setbox:D #1 \tex_hbox:D to \dim_eval:n{#2} {#3}
}
\cs_generate_variant:Nn \hbox_set_to_wd:Nnn {cnn}
-\cs_new_nopar:Npn \hbox_gset_to_wd:Nnn {\pref_global:D \hbox_set_to_wd:Nnn }
+\cs_new_protected_nopar:Npn \hbox_gset_to_wd:Nnn {\pref_global:D \hbox_set_to_wd:Nnn }
\cs_generate_variant:Nn \hbox_gset_to_wd:Nnn {cnn}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-%
% \begin{macro}{\hbox_set_inline_begin:N,\hbox_set_inline_begin:c}
% \begin{macro}{\hbox_set_inline_end:}
% \begin{macro}{\hbox_gset_inline_begin:N,\hbox_gset_inline_begin:c}
@@ -845,12 +862,12 @@
% Storing material in a horizontal box. This type is useful in
% environment definitions.
% \begin{macrocode}
-\cs_new_nopar:Npn \hbox_set_inline_begin:N #1 {
+\cs_new_protected_nopar:Npn \hbox_set_inline_begin:N #1 {
\tex_setbox:D #1 \tex_hbox:D \c_group_begin_token
}
\cs_generate_variant:Nn \hbox_set_inline_begin:N {c}
\cs_new_eq:NN \hbox_set_inline_end: \c_group_end_token
-\cs_new_nopar:Npn \hbox_gset_inline_begin:N {
+\cs_new_protected_nopar:Npn \hbox_gset_inline_begin:N {
\pref_global:D \hbox_set_inline_begin:N
}
\cs_generate_variant:Nn \hbox_gset_inline_begin:N {c}
@@ -865,12 +882,25 @@
% \begin{macro}{\hbox_to_zero:n}
% Put a horizontal box directly into the input stream.
% \begin{macrocode}
-\cs_new:Npn \hbox_to_wd:nn #1#2 {\tex_hbox:D to #1 {#2}}
-\cs_new:Npn \hbox_to_zero:n #1 {\tex_hbox:D to \c_zero_skip {#1}}
+\cs_new_protected:Npn \hbox_to_wd:nn #1#2 {\tex_hbox:D to #1 {#2}}
+\cs_new_protected:Npn \hbox_to_zero:n #1 {\tex_hbox:D to \c_zero_skip {#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
+%
+% \begin{macro}{\hbox_overlap_left:n}
+% \begin{macro}{\hbox_overlap_right:n}
+% Put a zero-sized box with the contents pushed against one side (which
+% makes it stick out on the other) directly into the input stream.
+% \begin{macrocode}
+\cs_new_protected:Npn \hbox_overlap_left:n #1 {\hbox_to_zero:n {\tex_hss:D #1}}
+\cs_new_protected:Npn \hbox_overlap_right:n #1 {\hbox_to_zero:n {#1 \tex_hss:D}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
% \begin{macro}{\hbox_unpack:N,\hbox_unpack:c}
% \begin{macro}{\hbox_unpack_clear:N,\hbox_unpack_clear:c}
% Unpacking a box and if requested also clear it.
diff --git a/Master/texmf-dist/source/latex/expl3/l3calc.dtx b/Master/texmf-dist/source/latex/expl3/l3calc.dtx
index c9519f13ca4..0e525ab5704 100644
--- a/Master/texmf-dist/source/latex/expl3/l3calc.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3calc.dtx
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3calc.dtx 1362 2009-05-28 20:19:21Z joseph $
+\GetIdInfo$Id: l3calc.dtx 1776 2010-02-07 21:51:23Z joseph $
{L3 Experimental calc module}
%\iffalse
%<*driver>
@@ -296,7 +296,7 @@
% \begin{macro}{\l_calc_current_type_int}
% Here we define some registers and pointers we will need.
% \begin{macrocode}
-\tl_new:Nn\l_calc_expression_tl{}
+\tl_new:N \l_calc_expression_tl
\cs_new_nopar:Npn \g_calc_A_register{}
\cs_new_nopar:Npn \l_calc_B_register{}
\int_new:N \l_calc_current_type_int
diff --git a/Master/texmf-dist/source/latex/expl3/l3candidates.dtx b/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
index 63385cbcd41..b753191559d 100644
--- a/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3candidates.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3extra.dtx Copyright (C) 2005-2009 LaTeX3 project
+%% File: l3candidates.dtx Copyright (C) 2005-2009 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
@@ -47,13 +47,13 @@
%\iffalse
\documentclass[full]{l3doc}
\begin{document}
-\DocInput{l3extra.dtx}
+\DocInput{l3candidates.dtx}
\end{document}
%</driver>
% \fi
%
%
-% \title{The \textsf{l3extra} package\thanks{This file
+% \title{The \textsf{l3candidates} package\thanks{This file
% has version number \fileversion, last
% revised \filedate.}}
% \author{\Team}
@@ -78,17 +78,6 @@
% \section{Functions for functions}
%
%
-% \begin{function}{\exp_arg:x}
-% \begin{syntax}
-% "\exp_arg:x" \Arg{text}
-% \end{syntax}
-% Fully expands <text> before passing it to the input stream.
-% Not expandable.
-% \begin{texnote}
-% In pdf\TeX\ 1.5 and Lua\TeX, this can be done expandably with "\expanded".
-% \end{texnote}
-% \end{function}
-%
%
% \section{Functions for token lists}
%
@@ -192,6 +181,28 @@
% \end{function}
%
%
+% \begin{function}{\clist_if_in_numrange:nn / (TF)}
+% \begin{syntax}
+% "\clist_if_in_numrange:nnTF" \Arg{intexpr} \Arg{numrange}
+% \Arg{true} \Arg{false}
+% \end{syntax}
+% When parsing user input to specify whether numerical elements
+% should be displayed/operated upon, it is common to use input such as
+% `|-4,7-11,17-|' to indicate ranged but sometimes discontiguous sets.
+% (In this particular example, we'd be specifying
+% $x\le4 \wedge 7\le x\le 11 \wedge x\ge 17$.)
+% This function can be used to test whether the input number
+% (actually <intexpr>) exists within the specified <numrange>.
+%
+% <numrange> need not be sorted and may contain overlapping ranges.
+% Numbers inside ranges may consist of integer expressions or anything
+% considered by \TeX\ to be a number
+% (such as `|`\A|', which is decimal number 65).
+%
+% This function could probably be made expandable with sufficient effort.
+% \end{function}
+%
+%
%
% \end{documentation}
%
@@ -209,19 +220,6 @@
%<*initex|package>
% \end{macrocode}
%
-% \begin{macro}{\exp_arg:x}
-% \begin{macrocode}
-\cs_new:Npn \exp_arg:x #1
- {
- \group_begin:
- \cs_set:Npx \cs_tmp: {#1}
- \exp_args:wN
- \group_end:
- \cs_tmp:
- }
-% \end{macrocode}
-% \end{macro}
-%
%
% \begin{macro}{\tl_trim_spaces:n,\tl_trim_spaces:N}
% \begin{macrocode}
@@ -279,9 +277,9 @@
}
\cs_new:Npn \char_transform:NN
{
- \msg_error:nn {l3extra} {naked-char-transform}
+ \msg_error:nn {l3prg} {naked-char-transform}
}
-\msg_new:nnn {l3extra} {naked-char-transform}
+\msg_new:nnn {l3prg} {naked-char-transform}
{
This command can only appear within the first\\
argument of \string\tl_transform:nn.
@@ -313,9 +311,9 @@
\seq_set_eq:NN \l_tmpa_seq #1
\seq_set_eq:NN \l_tmpb_seq #2
\prg_stepwise_inline:nnnn{1}{1}{\l_tmpa_int}{
- \seq_pop:NN \l_tmpa_seq \l_tmpa_tl
- \seq_pop:NN \l_tmpb_seq \l_tmpb_tl
- \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl
+ \seq_pop:NN \l_tmpa_seq \l_kernel_tmpa_tl
+ \seq_pop:NN \l_tmpb_seq \l_kernel_tmpb_tl
+ \exp_args:NVV #3 \l_kernel_tmpa_tl \l_kernel_tmpb_tl
}
}{\ERROR}
}
@@ -364,6 +362,45 @@
% \end{macrocode}
% \end{macro}
%
+%
+%
+% \begin{macro}[TF]{\clist_if_in_numrange:nn}
+% A `numrange' is like |-2,5-8,17-| (can be unsorted).
+% \begin{macrocode}
+\prg_new_conditional:Nnn \clist_if_in_numrange:nn {TF,T,F} {
+ \bool_set_false:N \l_clist_numrange_bool
+ \clist_map_inline:nn {#2} {
+ \_clist_numrange_parse:nw {#1} ##1 - \q_marker - \q_nil
+ }
+ \bool_if:NTF \l_clist_numrange_bool \prg_return_true: \prg_return_false:
+}
+\cs_set:Npn \_clist_numrange_success: {
+ \bool_set_true:N \l_clist_numrange_bool
+ \clist_map_break:
+}
+\cs_set:Npn \_clist_numrange_parse:nw #1 #2 - #3 - #4 \q_nil {
+ \tl_if_empty:nTF {#4}{
+ \intexpr_compare:nT {#1=#2} {\_clist_numrange_success:}
+ }{
+ \tl_if_empty:nTF {#3}{
+ \intexpr_compare:nT {#1>=#2} {\_clist_numrange_success:}
+ }{
+ \tl_if_empty:nTF {#2}{
+ \intexpr_compare:nT {#1<=#3} {\_clist_numrange_success:}
+ }{
+ \intexpr_compare:nT {#1>=#2} {
+ \intexpr_compare:nT {#1<=#3}
+ {\_clist_numrange_success:}
+ }
+ }
+ }
+ }
+}
+\bool_new:N \l_clist_numrange_bool
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3clist.dtx b/Master/texmf-dist/source/latex/expl3/l3clist.dtx
index 0f6276b47d2..4ae2d84d587 100644
--- a/Master/texmf-dist/source/latex/expl3/l3clist.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3clist.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3clist.dtx Copyright (C) 2005-2008 Frank Mittelbach, LaTeX3 project
+%% File: l3clist.dtx Copyright (C) 2005-2010 Frank Mittelbach, 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3clist.dtx 1713 2009-11-06 07:02:42Z will $
+\GetIdInfo$Id: l3clist.dtx 1878 2010-03-29 07:15:02Z joseph $
{L3 Experimental comma separated lists}
%\iffalse
%<*driver>
@@ -570,10 +570,10 @@
% \begin{macro}{\clist_set_eq:cc}
% We can set one \meta{clist} equal to another.
% \begin{macrocode}
-\cs_new_eq:NN \clist_set_eq:NN \cs_set_eq:NN
-\cs_new_eq:NN \clist_set_eq:cN \cs_set_eq:cN
-\cs_new_eq:NN \clist_set_eq:Nc \cs_set_eq:Nc
-\cs_new_eq:NN \clist_set_eq:cc \cs_set_eq:cc
+\cs_new_eq:NN \clist_set_eq:NN \tl_set_eq:NN
+\cs_new_eq:NN \clist_set_eq:cN \tl_set_eq:cN
+\cs_new_eq:NN \clist_set_eq:Nc \tl_set_eq:Nc
+\cs_new_eq:NN \clist_set_eq:cc \tl_set_eq:cc
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -587,10 +587,10 @@
% \begin{macro}{\clist_gset_eq:cc}
% An of course globally which seems to be needed far more often.
% \begin{macrocode}
-\cs_new_eq:NN \clist_gset_eq:NN \cs_gset_eq:NN
-\cs_new_eq:NN \clist_gset_eq:cN \cs_gset_eq:cN
-\cs_new_eq:NN \clist_gset_eq:Nc \cs_gset_eq:Nc
-\cs_new_eq:NN \clist_gset_eq:cc \cs_gset_eq:cc
+\cs_new_eq:NN \clist_gset_eq:NN \tl_gset_eq:NN
+\cs_new_eq:NN \clist_gset_eq:cN \tl_gset_eq:cN
+\cs_new_eq:NN \clist_gset_eq:Nc \tl_gset_eq:Nc
+\cs_new_eq:NN \clist_gset_eq:cc \tl_gset_eq:cc
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -612,9 +612,9 @@
% \begin{macro}{\clist_if_empty_err:N}
% Signals an error if the comma-list is empty.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_if_empty_err:N #1 {
+\cs_new_protected_nopar:Npn \clist_if_empty_err:N #1 {
\if_meaning:w #1 \c_empty_tl
- \tl_clear:N \l_testa_tl % catch prefixes
+ \tl_clear:N \l_kernel_testa_tl % catch prefixes
\msg_kernel_bug:x {Empty~comma-list~`\token_to_str:N #1'}
\fi:
}
@@ -644,7 +644,7 @@
% \m{false~case} may contain incomplete |\if_charcode:w|
% statements.
% \begin{macrocode}
-\prg_new_conditional:Nnn \clist_if_in:Nn {TF,T,F} {
+\prg_new_protected_conditional:Nnn \clist_if_in:Nn {TF,T,F} {
\cs_set:Npn \clist_tmp:w ##1,#2,##2##3 \q_stop {
\if_meaning:w \q_no_value ##2
\prg_return_false: \else: \prg_return_true: \fi:
@@ -688,13 +688,13 @@
% |\clist_get:NN |\meta{comma-list}\meta{cmd} defines \meta{cmd} to be the
% left-most element of \meta{comma-list}.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_get:NN #1 {
+\cs_new_protected_nopar:Npn \clist_get:NN #1 {
\clist_if_empty_err:N #1
\exp_after:wN \clist_get_aux:w #1,\q_stop
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn \clist_get_aux:w #1,#2\q_stop #3 { \tl_set:Nn #3{#1} }
+\cs_new_protected:Npn \clist_get_aux:w #1,#2\q_stop #3 { \tl_set:Nn #3{#1} }
% \end{macrocode}
% \begin{macrocode}
\cs_generate_variant:Nn \clist_get:NN {cN}
@@ -711,7 +711,7 @@
% \meta{cmd} using \meta{def$\sb2$}, and assigns the tail of
% \meta{comma-list} to \meta{comma-list} using \meta{def$\sb1$}.
% \begin{macrocode}
-\cs_new:Npn \clist_pop_aux:nnNN #1#2#3 {
+\cs_new_protected:Npn \clist_pop_aux:nnNN #1#2#3 {
\clist_if_empty_err:N #3
\exp_after:wN \clist_pop_aux:w #3,\q_nil\q_stop #1#2#3
}
@@ -719,7 +719,7 @@
% After the assignmnets below, if there was only one element in the original
% clist, it now contains only |\q_nil|.
% \begin{macrocode}
-\cs_new:Npn \clist_pop_aux:w #1,#2\q_stop #3#4#5#6 {
+\cs_new_protected:Npn \clist_pop_aux:w #1,#2\q_stop #3#4#5#6 {
#4 #6 {#1}
#3 #5 {#2}
\quark_if_nil:NTF #5 { #3 #5 {} }{ \clist_pop_auxi:w #2 #3#5 }
@@ -744,7 +744,7 @@
% \begin{macro}{\clist_display:N}
% \begin{macro}{\clist_display:c}
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_display:N #1 {
+\cs_new_protected_nopar:Npn \clist_display:N #1 {
\iow_term:x { Comma-list~\token_to_str:N #1~contains~
the~elements~(without~outer~braces): }
\toks_clear:N \l_tmpa_toks
@@ -753,7 +753,7 @@
\toks_put_right:Nx \l_tmpa_toks {^^J>~}
}
\toks_put_right:Nx \l_tmpa_toks {
- \iow_space: \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
+ \c_space_tl \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
}
}
\toks_show:N \l_tmpa_toks
@@ -776,7 +776,7 @@
% implemented here. Since |\tl_if_empty:nF| is expandable prefixes
% are still allowed.
% \begin{macrocode}
-\cs_new:Npn \clist_put_aux:NNnnNn #1#2#3#4#5#6 {
+\cs_new_protected:Npn \clist_put_aux:NNnnNn #1#2#3#4#5#6 {
\clist_if_empty:NTF #5 { #1 #5 {#6} } {
\tl_if_empty:nF {#6} { #2 #5{#3#6#4} }
}
@@ -793,7 +793,7 @@
% \begin{macro}{\clist_put_left:co}
% The operations for adding to the left.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_put_left:Nn {
+\cs_new_protected_nopar:Npn \clist_put_left:Nn {
\clist_put_aux:NNnnNn \tl_set:Nn \tl_put_left:Nn {} ,
}
\cs_generate_variant:Nn \clist_put_left:Nn {NV,No,Nx,cn,cV,co}
@@ -815,7 +815,7 @@
% \begin{macro}{\clist_gput_left:co}
% Global versions.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_gput_left:Nn {
+\cs_new_protected_nopar:Npn \clist_gput_left:Nn {
\clist_put_aux:NNnnNn \tl_gset:Nn \tl_gput_left:Nn {} ,
}
\cs_generate_variant:Nn \clist_gput_left:Nn {NV,No,Nx,cn,cV,co}
@@ -837,7 +837,7 @@
% \begin{macro}{\clist_put_right:co}
% Adding something to the right side is almost the same.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_put_right:Nn {
+\cs_new_protected_nopar:Npn \clist_put_right:Nn {
\clist_put_aux:NNnnNn \tl_set:Nn \tl_put_right:Nn , {}
}
\cs_generate_variant:Nn \clist_put_right:Nn {NV,No,Nx,cn,cV,co}
@@ -859,7 +859,7 @@
% \begin{macro}{\clist_gput_right:co}
% And here the global variants.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_gput_right:Nn {
+\cs_new_protected_nopar:Npn \clist_gput_right:Nn {
\clist_put_aux:NNnnNn \tl_gset:Nn \tl_gput_right:Nn , {}
}
\cs_generate_variant:Nn \clist_gput_right:Nn {NV,No,Nx,cn,cV,co}
@@ -938,7 +938,7 @@
% every operation globally.
% \begin{macrocode}
\int_new:N \g_clist_inline_level_int
-\cs_new:Npn \clist_map_inline:Nn #1#2 {
+\cs_new_protected:Npn \clist_map_inline:Nn #1#2 {
\clist_if_empty:NF #1 {
\int_gincr:N \g_clist_inline_level_int
\cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
@@ -956,7 +956,7 @@
}
}
\cs_generate_variant:Nn \clist_map_inline:Nn {c}
-\cs_new:Npn \clist_map_inline:nn #1#2 {
+\cs_new_protected:Npn \clist_map_inline:nn #1#2 {
\tl_if_empty:nF {#1} {
\int_gincr:N \g_clist_inline_level_int
\cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
@@ -979,7 +979,7 @@
% |\clist_map_variable:NNn| \meta{comma-list} \meta{temp} \meta{action} assigns
% \meta{temp} to each element and executes \meta{action}.
% \begin{macrocode}
-\cs_new:Npn \clist_map_variable:nNn #1#2#3 {
+\cs_new_protected:Npn \clist_map_variable:nNn #1#2#3 {
\tl_if_empty:nF {#1} {
\clist_map_variable_aux:Nnw #2 {#3} #1
, \q_recursion_tail , \q_recursion_stop
@@ -988,7 +988,7 @@
% \end{macrocode}
% Something for v/V
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_map_variable:NNn {\exp_args:No \clist_map_variable:nNn}
+\cs_new_protected_nopar:Npn \clist_map_variable:NNn {\exp_args:No \clist_map_variable:nNn}
\cs_generate_variant:Nn\clist_map_variable:NNn {cNn}
% \end{macrocode}
% \end{macro}
@@ -1000,7 +1000,7 @@
% |#3| and then check if that's the stop marker. If it is, break the
% loop. If not, execute the action |#2| and continue.
% \begin{macrocode}
-\cs_new:Npn \clist_map_variable_aux:Nnw #1#2#3,{
+\cs_new_protected:Npn \clist_map_variable_aux:Nnw #1#2#3,{
\cs_set_nopar:Npn #1{#3}
\quark_if_recursion_tail_stop:N #1
#2 \clist_map_variable_aux:Nnw #1{#2}
@@ -1021,17 +1021,17 @@
% of commas between items, so if either list is empty we have to avoid
% adding a comma.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_concat_aux:NNNN #1#2#3#4 {
- \toks_set:No \l_tmpa_toks {#3}
- \toks_set:No \l_tmpb_toks {#4}
+\cs_new_protected_nopar:Npn \clist_concat_aux:NNNN #1#2#3#4 {
+ \tl_set:No \l_tmpa_tl {#3}
+ \tl_set:No \l_tmpb_tl {#4}
#1 #2 {
- \toks_use:N \l_tmpa_toks
- \toks_if_empty:NF \l_tmpa_toks { \toks_if_empty:NF \l_tmpb_toks , }
- \toks_use:N \l_tmpb_toks
+ \exp_not:V \l_tmpa_tl
+ \tl_if_empty:NF \l_tmpa_tl { \tl_if_empty:NF \l_tmpb_tl , }
+ \exp_not:V \l_tmpb_tl
}
}
-\cs_new_nopar:Npn \clist_concat:NNN { \clist_concat_aux:NNNN \tl_set:Nx }
-\cs_new_nopar:Npn \clist_gconcat:NNN { \clist_concat_aux:NNNN \tl_gset:Nx }
+\cs_new_protected_nopar:Npn \clist_concat:NNN { \clist_concat_aux:NNNN \tl_set:Nx }
+\cs_new_protected_nopar:Npn \clist_gconcat:NNN { \clist_concat_aux:NNNN \tl_gset:Nx }
\cs_generate_variant:Nn \clist_concat:NNN {ccc}
\cs_generate_variant:Nn \clist_gconcat:NNN {ccc}
% \end{macrocode}
@@ -1055,12 +1055,12 @@
% from left to right. For each element check if the element is
% already present in the list.
% \begin{macrocode}
-\cs_new:Npn \clist_remove_duplicates_aux:NN #1#2 {
+\cs_new_protected:Npn \clist_remove_duplicates_aux:NN #1#2 {
\clist_clear:N \l_clist_remove_clist
\clist_map_function:NN #2 \clist_remove_duplicates_aux:n
#1 #2 \l_clist_remove_clist
}
-\cs_new:Npn \clist_remove_duplicates_aux:n #1 {
+\cs_new_protected:Npn \clist_remove_duplicates_aux:n #1 {
\clist_if_in:NnF \l_clist_remove_clist {#1} {
\clist_put_right:Nn \l_clist_remove_clist {#1}
}
@@ -1069,10 +1069,10 @@
% The high level functions are just for telling if it should be a
% local or global setting.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_remove_duplicates:N {
+\cs_new_protected_nopar:Npn \clist_remove_duplicates:N {
\clist_remove_duplicates_aux:NN \clist_set_eq:NN
}
-\cs_new_nopar:Npn \clist_gremove_duplicates:N {
+\cs_new_protected_nopar:Npn \clist_gremove_duplicates:N {
\clist_remove_duplicates_aux:NN \clist_gset_eq:NN
}
% \end{macrocode}
@@ -1088,13 +1088,13 @@
% The same general idea is used for removing elements: the parent
% functions just set things up for the internal ones.
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_remove_element:Nn {
+\cs_new_protected_nopar:Npn \clist_remove_element:Nn {
\clist_remove_element_aux:NNn \clist_set_eq:NN
}
-\cs_new_nopar:Npn \clist_gremove_element:Nn {
+\cs_new_protected_nopar:Npn \clist_gremove_element:Nn {
\clist_remove_element_aux:NNn \clist_gset_eq:NN
}
-\cs_new:Npn \clist_remove_element_aux:NNn #1#2#3 {
+\cs_new_protected:Npn \clist_remove_element_aux:NNn #1#2#3 {
\clist_clear:N \l_clist_remove_clist
\cs_set:Npn \clist_remove_element_aux:n ##1 {
\tl_if_eq:nnF {#3} {##1} {
@@ -1131,7 +1131,7 @@
\cs_new_eq:NN \clist_push:NV \clist_put_left:NV
\cs_new_eq:NN \clist_push:No \clist_put_left:No
\cs_new_eq:NN \clist_push:cn \clist_put_left:cn
-\cs_new_nopar:Npn \clist_pop:NN {\clist_pop_aux:nnNN \tl_set:Nn \tl_set:Nn}
+\cs_new_protected_nopar:Npn \clist_pop:NN {\clist_pop_aux:nnNN \tl_set:Nn \tl_set:Nn}
\cs_generate_variant:Nn \clist_pop:NN {cN}
% \end{macrocode}
% \end{macro}
@@ -1161,7 +1161,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \clist_gpop:NN {\clist_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn}
+\cs_new_protected_nopar:Npn \clist_gpop:NN {\clist_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn}
\cs_generate_variant:Nn \clist_gpop:NN {cN}
% \end{macrocode}
% \end{macro}
diff --git a/Master/texmf-dist/source/latex/expl3/l3doc.dtx b/Master/texmf-dist/source/latex/expl3/l3doc.dtx
index c78b348da4a..3aad9e48257 100644
--- a/Master/texmf-dist/source/latex/expl3/l3doc.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3doc.dtx
@@ -77,7 +77,7 @@ Do not distribute a modified version of this file.
% \end{macrocode}
%
%<*driver|class>
-\GetIdInfo$Id: l3doc.dtx 1762 2010-01-09 10:05:37Z joseph $
+\GetIdInfo$Id: l3doc.dtx 1786 2010-02-09 12:52:45Z joseph $
{L3 Experimental documentation class}
%</driver|class>
%
@@ -1334,7 +1334,6 @@ Do not distribute a modified version of this file.
% \end{macrocode}
%
% \begin{macrocode}
-\iow_new:N \g_write_func_stream
\iow_open:Nn \g_write_func_stream { \jobname.cmds }
% \end{macrocode}
%
@@ -1441,7 +1440,8 @@ Do not distribute a modified version of this file.
\g@addto@macro \PrintIndex { \AtEndDocument{ \typeout{^^J
========================================^^J
Generate~the~index~by~executing^^J
- \msg_four_spaces: makeindex~-s~l3doc.ist~-o~\jobname.ind~\jobname.idx^^J
+ \c_space_tl \c_space_tl \c_space_tl \c_space_tl
+ makeindex~-s~l3doc.ist~-o~\jobname.ind~\jobname.idx^^J
========================================^^J
}}
}
@@ -1464,7 +1464,8 @@ Do not distribute a modified version of this file.
\g@addto@macro \PrintChanges { \AtEndDocument{ \typeout{^^J
========================================^^J
Generate~the~change~list~by~executing^^J
- \msg_four_spaces: makeindex~-s~gglo.ist~~-o~\jobname.gls~\jobname.glo^^J
+ \c_space_tl \c_space_tl \c_space_tl \c_space_tl
+ makeindex~-s~gglo.ist~~-o~\jobname.gls~\jobname.glo^^J
========================================^^J
}}
}
diff --git a/Master/texmf-dist/source/latex/expl3/l3expan.dtx b/Master/texmf-dist/source/latex/expl3/l3expan.dtx
index 617e3f27572..1a77ea97d71 100644
--- a/Master/texmf-dist/source/latex/expl3/l3expan.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3expan.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3expan.dtx 1673 2009-11-02 05:40:42Z will $
+\GetIdInfo$Id: l3expan.dtx 1873 2010-03-24 08:32:54Z joseph $
{L3 Experimental Argument Expansion module}
%\iffalse
%<*driver>
@@ -112,26 +112,36 @@
%
% \subsection{Methods for defining variants}
%
-% \begin{function}{\cs_generate_variant:Nn}
-% \begin{syntax}
-% "\cs_generate_variant:Nn" <function> <variant argument>
-% "\cs_generate_variant:Nn " "\foo:Nn" "{c}"
-% "\cs_generate_variant:Nn" "\foo:Nn" "{c,Nx,cx}"
-% \end{syntax}
-% This function greatly simplify the task of defining
-% variantions on a base function with differing expansion control.
-% The first example is equivalent to writing
-% \begin{verbatim}
-% \cs_set_nopar:Npn \foo:cn { \exp_args:Nc \foo:Nn }
-% \end{verbatim}
-% If used with a comma-separated list of variants, it does so for each
-% variant form, i.e., the second example is equivalent to
-% \begin{verbatim}
-% \cs_set_nopar:Npn \foo:cn { \exp_args:Nc \foo:Nn }
-% \cs_set_nopar:Npn \foo:Nx { \exp_args:NNx \foo:Nn }
-% \cs_set_nopar:Npn \foo:cx { \exp_args:Ncx \foo:Nn }
-% \end{verbatim}
-% \end{function}
+%
+%\begin{function}{ \cs_generate_variant:Nn }
+% \begin{syntax}
+% \cs{cs_generate_variant:Nn} \meta{parent control sequence}
+% ~~\Arg{variant argument specifier}
+% \end{syntax}
+% The \meta{parent control sequence} is first separated into the
+% \meta{base name} and \meta{original} argument specifier. The
+% \meta{variant} is then used to modify this by replacing the beginning
+% of the \meta{original} with the \meta{variant}. Thus the \meta{variant}
+% must be no longer than the \meta{original} argument specifier. This
+% new specifier is used to create a modified function which will expand
+% its arguments as required. So for example
+% \begin{verbatim}
+% \cs_set:Npn \foo:Nn #1#2 { code here }
+% \cs_generate_variant:Nn \foo:Nn { c }
+% \end{verbatim}
+% will create a new function \cs{foo:cn} which will expand its first
+% argument into a control sequence name and pass the result to
+% \cs{foo:Nn}. Similarly
+% \begin{verbatim}
+% \cs_generate_variant:Nn \foo:Nn { NV }
+% \cs_generate_variant:Nn \foo:Nn { cV }
+% \end{verbatim}
+% would generate the functions \cs{foo:NV} and \cs{foo:cV} in the
+% same way. \cs{cs_generate_variant:Nn} can only be applied if the
+% \meta{parent control sequence} is already defined. If the
+% \meta{parent control sequence} is protected then the new sequence
+% will also be protected.
+%\end{function}
%
% \paragraph{Internal functions} \mbox{}
%
@@ -210,22 +220,6 @@
% try to finish any "\if... \fi:" itself!
%
%
-% \begin{function}{\exp_arg:x}
-% \begin{syntax}
-% "\exp_arg:x" \Arg{arg}
-% \end{syntax}
-% <arg> is expanded fully using an "x" expansion.
-%
-% When pdf\TeX\ 1.50 arrives, it will contain a primitive for
-% performing the equivalent of an "x" expansion after only one
-% expansion and most importantly: as an expandable operation.
-%
-% However, we will not be using the expandable command "\expanded"
-% until it is broadly available; note that as of \TeX~Live~2009,
-% only Lua\TeX\ supports this primitive. Until further notice,
-% "\exp_arg:x" will remain \emph{unexpandable}.
-% \end{function}
-%
%
%
% \section{Manipulating the first argument}
@@ -396,14 +390,14 @@
% \end{function}
%
% \begin{function}{\exp_not:o |
-% \exp_not:d |
% \exp_not:f }
% \begin{syntax}
% "\exp_not:o" \Arg{token list}
% \end{syntax}
% Same as "\exp_not:n" except <token list> is expanded once for the
-% "o" type and twice for the "d" type and the result of this expansion
-% is then prohibited from being expanded further.
+% "o" type and for the "f" type the token list is expanded until an
+% unexpandable token is found, and the result of these expansions is then
+% prohibited from being expanded further.
% \end{function}
%
% \begin{function}{\exp_not:V |
@@ -677,24 +671,15 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\::x,\exp_arg:x}
+% \begin{macro}{\::x}
% This function is used to expand an argument fully.
% We could use the new expandable primitive "\expanded" here, but we
% don't want to create incompatibilities between engines.
% \begin{macrocode}
-%%\cs_new_eq:NN \exp_arg:x \expanded % Move eventually.
-%%\cs_if_free:NTF\exp_arg:x{
- \cs_new:Npn \::x #1 \::: #2#3 {
+ \cs_new_protected:Npn \::x #1 \::: #2#3 {
\cs_set_nopar:Npx \l_exp_tl {{#3}}
\exp_after:wN \exp_arg_next:nnn \l_exp_tl {#1}{#2}
}
-%%}
-%%{
-%% \cs_new:Npn\::x#1\:::#2#3{
-%% \exp_after:wN\exp_arg_next:nnn
-%% \exp_after:wN{\exp_arg:x{#3}}{#1}{#2}
-%% }
-%%}
% \end{macrocode}
% \end{macro}
%
@@ -857,7 +842,7 @@
\cs_set_nopar:Npn \exp_args:Nf {\::f\:::}
\cs_set_nopar:Npn \exp_args:Nv {\::v\:::}
\cs_set_nopar:Npn \exp_args:NV {\::V\:::}
-\cs_set_nopar:Npn \exp_args:Nx {\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nx {\::x\:::}
% \end{macrocode}
% \end{macro}
%
@@ -875,25 +860,25 @@
\cs_set_nopar:Npn \exp_args:NNf {\::N\::f\:::}
\cs_set_nopar:Npn \exp_args:NNv {\::N\::v\:::}
\cs_set_nopar:Npn \exp_args:NNV {\::N\::V\:::}
-\cs_set_nopar:Npn \exp_args:NNx {\::N\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:NNx {\::N\::x\:::}
-\cs_set_nopar:Npn \exp_args:Ncx {\::c\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Ncx {\::c\::x\:::}
\cs_set_nopar:Npn \exp_args:Nfo {\::f\::o\:::}
\cs_set_nopar:Npn \exp_args:Nff {\::f\::f\:::}
\cs_set_nopar:Npn \exp_args:Ncf {\::c\::f\:::}
\cs_set_nopar:Npn \exp_args:Nnf {\::n\::f\:::}
\cs_set_nopar:Npn \exp_args:Nno {\::n\::o\:::}
\cs_set_nopar:Npn \exp_args:NnV {\::n\::V\:::}
-\cs_set_nopar:Npn \exp_args:Nnx {\::n\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nnx {\::n\::x\:::}
\cs_set_nopar:Npn \exp_args:Noc {\::o\::c\:::}
\cs_set_nopar:Npn \exp_args:Noo {\::o\::o\:::}
-\cs_set_nopar:Npn \exp_args:Nox {\::o\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nox {\::o\::x\:::}
\cs_set_nopar:Npn \exp_args:NVV {\::V\::V\:::}
-\cs_set_nopar:Npn \exp_args:Nxo {\::x\::o\:::}
-\cs_set_nopar:Npn \exp_args:Nxx {\::x\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nxo {\::x\::o\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nxx {\::x\::x\:::}
% \end{macrocode}
% \end{macro}
%
@@ -917,23 +902,23 @@
\cs_set_nopar:Npn \exp_args:NNNV {\::N\::N\::V\:::}
\cs_set_nopar:Npn \exp_args:NNno {\::N\::n\::o\:::}
-\cs_set_nopar:Npn \exp_args:NNnx {\::N\::n\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:NNnx {\::N\::n\::x\:::}
\cs_set_nopar:Npn \exp_args:NNoo {\::N\::o\::o\:::}
-\cs_set_nopar:Npn \exp_args:NNox {\::N\::o\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:NNox {\::N\::o\::x\:::}
\cs_set_nopar:Npn \exp_args:Nnnc {\::n\::n\::c\:::}
\cs_set_nopar:Npn \exp_args:Nnno {\::n\::n\::o\:::}
-\cs_set_nopar:Npn \exp_args:Nnnx {\::n\::n\::x\:::}
-\cs_set_nopar:Npn \exp_args:Nnox {\::n\::o\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nnnx {\::n\::n\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nnox {\::n\::o\::x\:::}
\cs_set_nopar:Npn \exp_args:NcNc {\::c\::N\::c\:::}
\cs_set_nopar:Npn \exp_args:NcNo {\::c\::N\::o\:::}
\cs_set_nopar:Npn \exp_args:Ncco {\::c\::c\::o\:::}
\cs_set_nopar:Npn \exp_args:Ncco {\::c\::c\::o\:::}
-\cs_set_nopar:Npn \exp_args:Nccx {\::c\::c\::x\:::}
-\cs_set_nopar:Npn \exp_args:Ncnx {\::c\::n\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Nccx {\::c\::c\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Ncnx {\::c\::n\::x\:::}
-\cs_set_nopar:Npn \exp_args:Noox {\::o\::o\::x\:::}
+\cs_set_protected_nopar:Npn \exp_args:Noox {\::o\::o\::x\:::}
\cs_set_nopar:Npn \exp_args:Nooo {\::o\::o\::o\:::}
% \end{macrocode}
% \end{macro}
@@ -943,15 +928,11 @@
%
%
% \begin{macro}{\exp_not:o}
-% \begin{macro}{\exp_not:d}
% \begin{macro}{\exp_not:f}
% \begin{macro}{\exp_not:v}
% \begin{macro}{\exp_not:V}
% \begin{macrocode}
\cs_new:Npn\exp_not:o#1{\exp_not:n\exp_after:wN{#1}}
-\cs_new:Npn\exp_not:d#1{
- \exp_not:n\exp_after:wN\exp_after:wN\exp_after:wN{#1}
-}
\cs_new:Npn\exp_not:f#1{
\exp_not:n\exp_after:wN{\tex_romannumeral:D -`0 #1}
}
@@ -966,7 +947,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\exp_not:c}
% A helper function.
@@ -995,7 +975,7 @@
% signature. For example, for a base function "\tl_set:Nn" which
% needs a "c" variant form, we want the new signature to be "cn".
% \begin{macrocode}
-\cs_new:Npn \cs_generate_variant:Nn #1 {
+\cs_new_protected:Npn \cs_generate_variant:Nn #1 {
\chk_if_exist_cs:N #1
\cs_split_function:NN #1 \cs_generate_variant_aux:nnNn
}
@@ -1033,7 +1013,8 @@
% If not, then define it and then additionally check if
% the |\exp_args:N| form needed is defined.
% \begin{macrocode}
- \cs_new_nopar:cpx {
+ \_cs_generate_variant_aux:ccpx { #1 : #2 }
+ {
#1:#3 \use:c{use_none:\cs_generate_variant_aux:N #3 ?}#2
}
{
@@ -1069,6 +1050,50 @@
% \end{macro}
% \end{macro}
% \end{macro}
+%
+%\begin{macro}[aux]{\_cs_generate_variant_aux:Ncpx}
+%\begin{macro}[aux]{\_cs_generate_variant_aux:ccpx}
+%\begin{macro}[aux]{\_cs_generate_variant_aux:w}
+% The idea here is to pick up protected parent functions, using the
+% nature of the meaning string that they generate. The test here is
+% almost the same as \cs{tl_if_empty:nTF}, but has to be hard-coded as
+% that function is not yet available and because it has to match both
+% long and short macros.
+% \begin{macrocode}
+\group_begin:
+ \tex_lccode:D `\Z = `\d \scan_stop:
+ \tex_lccode:D `\? =`\\ \scan_stop:
+ \tex_catcode:D `\P = 12 \scan_stop:
+ \tex_catcode:D `\R = 12 \scan_stop:
+ \tex_catcode:D `\O = 12 \scan_stop:
+ \tex_catcode:D `\T = 12 \scan_stop:
+ \tex_catcode:D `\E = 12 \scan_stop:
+ \tex_catcode:D `\C = 12 \scan_stop:
+ \tex_catcode:D `\Z = 12 \scan_stop:
+\tex_lowercase:D {
+ \group_end:
+ \cs_new_nopar:Npn \_cs_generate_variant_aux:Ncpx #1
+ {
+ \exp_after:wN \_cs_generate_variant_aux:w
+ \tex_meaning:D #1 ? PROTECTEZ \q_nil
+ }
+ \cs_new_nopar:Npn \_cs_generate_variant_aux:ccpx
+ { \exp_args:Nc \_cs_generate_variant_aux:Ncpx}
+ \cs_new:Npn \_cs_generate_variant_aux:w
+ #1 ? PROTECTEZ #2 \q_nil
+ {
+ \exp_after:wN \tex_ifx:D \exp_after:wN
+ \q_nil \etex_detokenize:D {#1} \q_nil
+ \exp_after:wN \cs_new_protected_nopar:cpx
+ \tex_else:D
+ \exp_after:wN \cs_new_nopar:cpx
+ \tex_fi:D
+ }
+}
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
%
% \begin{macro}{\cs_generate_internal_variant:n}
@@ -1076,7 +1101,7 @@
% and if not define it via the
% |\::| commands using the chars in |#1|
% \begin{macrocode}
-\cs_new:Npn \cs_generate_internal_variant:n #1 {
+\cs_new_protected:Npn \cs_generate_internal_variant:n #1 {
\cs_if_free:cT { exp_args:N #1 }{
% \end{macrocode}
% We use "new" to log the definition if we have to make one.
diff --git a/Master/texmf-dist/source/latex/expl3/l3file.dtx b/Master/texmf-dist/source/latex/expl3/l3file.dtx
index 951ee5e8df6..8d672b074c4 100644
--- a/Master/texmf-dist/source/latex/expl3/l3file.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3file.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3file.dtx Copyright (C) 2009 LaTeX3 project
+%% File: l3file.dtx Copyright (C) 2009-2010 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -37,7 +37,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3file.dtx 1676 2009-11-02 08:18:16Z will $
+\GetIdInfo$Id: l3file.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental file loading}
%\iffalse
%<*driver>
@@ -61,118 +61,83 @@
% \maketitle
%
% \begin{documentation}
+%
+% \section{Loading files}
%
-%\section{Loading files}
+% In contrast to the \pkg{l3io} module, which deals with the lowest
+% level of file management, the \pkg{l3file} module provides a higher
+% level interface for handling file contents. This involves providing
+% convenient wrappers around many of the functions in \pkg{l3io}
+% to make them more generally accessible.
%
-% The need to test if a file is available and to load a file if found is
-% covered at a low level here.
+% It is important to remember that \TeX\ will attempt to locate
+% files using both the operating system path and entries in the
+% \TeX\ file database (most \TeX\ systems use such a database). Thus
+% the `current path' for \TeX\ is somewhat broader than that for other
+% programs.
%
-%\begin{function}{
-% \file_if_exist_p:n|
-% \file_if_exist:n / (TF)
-%}
-% \begin{syntax}
-% "\file_if_exist:nTF" <file> <true code> <false code>
-% \end{syntax}
-% Tests if <file> exists.
-% \begin{texnote}
-% This is \LaTeXe's \cs{IfFileExists}, although it does not return
-% name of the file (\emph{cf.}~\cs{@filef@und}).
-% \end{texnote}
-%\end{function}
+%\begin{variable}{ \g_file_current_name_tl }
+% Contains the name of the current LaTeX file. This variable
+% should not be modified: it is intended for information only. It
+% will be equal to \cs{c_job_name_tl} at the start of a \LaTeX\
+% run and will be modified each time a file is read using
+% \cs{file_input:n}.
+%\end{variable}
%
-%\begin{function}{\file_add_path:nN}
+%\begin{function}{
+% \file_if_exist:n / (TF) |
+% \file_if_exist:V / (TF)
+%}
% \begin{syntax}
-% "\file_add_path:nN" <file> <tl~var.>
+% \cs{file_if_exist:nTF} \Arg{file name} \Arg{true code} \Arg{false code}
% \end{syntax}
-% Searches for <file> on the \TeX\ path and using
-% \cs{l_file_search_path_clist}. If <file> is found, <tl~var.> is set
-% to the file name plus any path information needed. If <file> is not
-% found, <tl~var.> will be blank.
-% \begin{texnote}
-% This is similar to obtaining \cs{@filef@und} from \LaTeXe's
-% \cs{IfFileExists}.
-% \end{texnote}
+% Searches for \meta{file name} using the current \TeX\ search
+% path and the additional paths controlled by
+% \cs{file_path_include:n}). The branching versions then leave
+% either \meta{true code} or \meta{false code} in the input stream,
+% as appropriate to the truth of the test and the variant of the
+% function chosen.
%\end{function}
%
-%\begin{function}{\file_input:n}
+%\begin{function}{
+% \file_input:n |
+% \file_input:V
+%}
% \begin{syntax}
-% "\file_input:n" <file>
+% \cs{file_input:n} \Arg{file name}
% \end{syntax}
-% Inputs <file> if it found (according to the same rule as for
-% \cs{file_if_exist:n}.
-% \begin{texnote}
-% This acts in a similar way to \LaTeXe's \cs{input}, as it will not
-% lead to a \TeX\ loop if the file is not found.
-% \end{texnote}
+% Searches for \meta{file name} in the path as detailed for
+% \cs{file_if_exist:nTF}, and if found reads in the file as
+% additional \LaTeX\ source. All files read are recorded
+% for information and the file name stack is updated by this
+% function.
%\end{function}
%
-%\begin{function}{\file_input_no_record:n}
+%\begin{function}{ \file_path_include:n }
% \begin{syntax}
-% "\file_input_no_record:n" <file>
+% \cs{file_path_include:n} \Arg{path}
% \end{syntax}
-% Inputs <file> if it found (according to the same rule as for
-% \cs{file_if_exist:n}, but does not add it to
-% \cs{g_file_record_clist}. The file is still added to
-% \cs{g_file_record_full_clist}.
-% \begin{texnote}
-% This is similar to \LaTeXe's \cs{@input@}.
-% \end{texnote}
+% Adds \meta{path} to the list of those used to search for files
+% by the \cs{file_input:n} and \cs{file_if_exist:n} function. The
+% assignment is local.
%\end{function}
%
-%\begin{function}{
-% \file_input_no_check:n|
-% \file_input_no_check_no_record:n|
-%}
+%\begin{function}{ \file_path_remove:n }
% \begin{syntax}
-% "\file_input_no_check:n" <file>
+% \cs{file_path_remove:n} \Arg{path}
% \end{syntax}
-% Inputs <file> directly without checking if it exists. The
-% \texttt{no_record} version does not record the input in
-% \begin{texnote}\cs{g_file_record_clist}.
-% These are simple wrappers around the \TeX\ \cs{input} primitive
-% \end{texnote}
+% Removes \meta{path} from the list of those used to search for files
+% by the \cs{file_input:n} and \cs{file_if_exist:n} function. The
+% assignment is local.
%\end{function}
%
-%\begin{function}{
-% \file_list:|
-% \file_list_full:|
-%}
+%\begin{function}{ \file_list: }
% \begin{syntax}
-% "\file_list:" <file>
+% \cs{file_list:}
% \end{syntax}
-% Lists files loaded in current \LaTeX\ run: the \texttt{full} version
-% lists all files.
+% This function will list all files loaded using \cs{file_input:n}
+% in the log file.
%\end{function}
-%
-%\section{Variables and constants}
-%
-%\begin{variable}{
-% \g_file_record_clist|
-% \g_file_record_full_clist
-%}
-% Used to track the files that have been loaded.
-%\end{variable}
-%
-%\begin{variable}{\l_file_search_path_clist}
-% List of paths to search for a file in addition to those searched by
-% \TeX.
-% \begin{texnote}
-% This is \cs{input@path} in \LaTeXe.
-% \end{texnote}
-%\end{variable}
-%
-%\begin{variable}{\l_file_test_read_stream}
-% Input stream used to carry out file tests.
-%\end{variable}
-%
-%\begin{variable}{\l_file_tmp_bool}
-% Internal scratch switch.
-%\end{variable}
-%
-%\begin{variable}{\l_file_tmp_tl}
-% Internal scratch token list variable.
-%\end{variable}
%
% \end{documentation}
%
@@ -190,219 +155,196 @@
%<*initex|package>
% \end{macrocode}
%
-%\begin{macro}{\g_file_record_clist}
-%\begin{macro}{\g_file_record_full_clist}
-% When files are read with logging, the names are added here. There are
-% two lists, one for everything and one for only those items which might
-% later be listed (as in \LaTeXe's \cs{listfiles}).
+%\begin{macro}{\g_file_current_name_tl}
+%\begin{macro}{\g_file_stack_seq}
+% The name of the current file should be available at all times.
% \begin{macrocode}
-\clist_new:N \g_file_record_clist
-\clist_new:N \g_file_record_full_clist
+\tl_new:N \g_file_current_name_tl
+\seq_new:N \g_file_stack_seq
% \end{macrocode}
-%\end{macro}
+%
+% For the format the file name needs to be picked up at the start of the
+% file. In package mode the current file name is collected from LaTeX2e.
+% \begin{macrocode}
+%</initex|package>
+%<*initex>
+\toks_put_right:Nn \tex_everyjob:D {
+ \tl_gset:Nx \g_file_current_name_tl { \tex_jobname:D }
+}
+%</initex>
+%<*package>
+\tl_gset_eq:NN \g_file_current_name_tl \@currname
+%</package>
+%<*initex|package>
+% \end{macrocode}
+%\end{macro}
%\end{macro}
%
-%\begin{macro}{\l_file_search_path_clist}
-% Checking input needs a stream to work with
+%\begin{macro}{\g_file_record_seq}
+% The total list of files used is recorded separately from the
+% stack.
% \begin{macrocode}
-\clist_new:N \l_file_search_path_clist
+\seq_new:N \g_file_record_seq
% \end{macrocode}
-%\end{macro}
%
-%\begin{macro}{\l_file_test_read_stream}
-% Checking input needs a stream to work with
+% The current file name should be included in the file list!
% \begin{macrocode}
-\ior_new:N \l_file_test_read_stream
+%</initex|package>
+%<*initex>
+\toks_put_right:Nn \tex_everyjob:D {
+ \seq_gput_right:NV \g_file_record_seq \g_file_current_name_tl
+}
+%</initex>
+%<*initex|package>
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{\l_file_tmp_bool}
-% A flag is needed for internal purposes.
+%\begin{macro}{\l_file_search_path_seq}
+% The current search path.
% \begin{macrocode}
-\bool_new:N \l_file_tmp_bool
+\seq_new:N \l_file_search_path_seq
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{\l_file_tmp_tl}
-% A scratch token list variable.
+%\begin{macro}{\l_file_search_path_saved_seq}
+% The current search path has to be saved for package use.
% \begin{macrocode}
-\tl_new:N \l_file_tmp_tl
+%</initex|package>
+%<*package>
+\seq_new:N \l_file_search_path_saved_seq
+%</package>
+%<*initex|package>
% \end{macrocode}
%\end{macro}
-%
-%\begin{macro}{\file_if_exist_p:n}
+%
+%\begin{macro}{\l_file_name_tl}
+%\begin{macro}{\g_file_test_stream}
%\begin{macro}[TF]{\file_if_exist:n}
-%\begin{macro}[aux]{\file_if_exist_path:n}
+%\begin{macro}[TF]{\file_if_exist:V}
%\begin{macro}[aux]{\file_if_exist_aux:n}
-% Checking if a file exists takes place in two parts. First, there is
-% a simple check ``here''. If that fails, then there is a loop over
-% the current search path.
+% Checking if a file exists takes place in two parts. First, look on
+% the TeX path, then look on the LaTeX path. The
+% token list \cs{l_file_name_tl} is used as a marker for finding
+% the file, and is also needed by \cs{file_input:n}.
% \begin{macrocode}
-\prg_new_conditional:Nnn \file_if_exist:n {p,TF,T,F} {
- \ior_open:Nn \l_file_test_read_stream {#1}
- \ior_if_eof:NTF \l_file_test_read_stream {
- \file_if_exist_path:n {#1}
- }{
- \ior_close:N \l_file_test_read_stream
- \prg_return_true:
- }
-}
-\cs_new_nopar:Npn \file_if_exist_path:n #1 {
- \bool_set_false:N \l_file_tmp_bool
- \cs_set_nopar:Npn \file_if_exist_aux:n ##1 {
- \ior_open:Nn \l_file_test_read_stream { #1 ##1 }
- \ior_if_eof:NF \l_file_test_read_stream {
- \bool_set_true:N \l_file_tmp_bool
- \clist_map_break:
+\tl_new:N \l_file_name_tl
+\prg_new_protected_conditional:Nnn \file_if_exist:n { T , F , TF } {
+ \ior_open:Nn \g_file_test_stream {#1}
+ \ior_if_eof:NTF \g_file_test_stream
+ { \file_if_exist_path_aux:n {#1} }
+ {
+ \ior_close:N \g_file_test_stream
+ \tl_set:Nn \l_file_name_tl {#1}
+ \prg_return_true:
}
- }
+}
+\cs_new_protected_nopar:Npn \file_if_exist_path_aux:n #1 {
+ \tl_clear:N \l_file_name_tl
%</initex|package>
%<*package>
- \cs_if_exist:NT \input@path {
- \cs_set_eq:NN \l_file_search_path_clist \input@path
- }
+ \cs_if_exist:NT \input@path
+ {
+ \seq_set_eq:NN \l_file_search_path_saved_seq
+ \l_file_search_path_seq
+ \clist_map_inline:Nn \input@path
+ { \seq_put_right:Nn \l_file_search_path_seq {##1} }
+ }
%</package>
%<*initex|package>
- \clist_map_function:NN \l_file_search_path_clist \file_if_exist_aux:n
- \ior_close:N \l_file_test_read_stream
- \bool_if:NTF \l_file_tmp_bool {
- \prg_return_true:
- }{
- \prg_return_false:
- }
-}
-\cs_new_nopar:Npn \file_if_exist_aux:n #1 { }
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\file_add_path:nN}
-%\begin{macro}[aux]{\file_add_path_search:n}
-%\begin{macro}[aux]{\file_add_path_aux:n}
-% Checking if a file exists takes place in two parts. First, there is
-% a simple check ``here''. If that fails, then there is a loop over
-% the current search path.
-% \begin{macrocode}
-\cs_new_nopar:Npn \file_add_path:nN #1#2 {
- \tl_clear:N #2
- \ior_open:Nn \l_file_test_read_stream {#1}
- \ior_if_eof:NTF \l_file_test_read_stream {
- \file_add_path_search:nN {#1} #2
- }{
- \tl_set:Nn #2 {#1}
- }
- \ior_close:N \l_file_test_read_stream
-}
-\cs_new_nopar:Npn \file_add_path_search:nN #1#2 {
- \cs_set_nopar:Npn \file_add_path_aux:n ##1 {
- \ior_open:Nn \l_file_test_read_stream { ##1 #1 }
- \ior_if_eof:NF \l_file_test_read_stream {
- \tl_set:Nn #2 { ##1 #1 }
- \clist_map_break:
- }
- }
+ \seq_map_inline:Nn \l_file_search_path_seq
+ {
+ \ior_open:Nn \g_file_test_stream { ##1 #1 }
+ \ior_if_eof:NF \g_file_test_stream
+ {
+ \tl_set:Nn \l_file_name_tl { ##1 #1 }
+ \seq_map_break:
+ }
+ }
%</initex|package>
%<*package>
- \cs_if_exist:NT \input@path {
- \cs_set_eq:NN \l_file_search_path_clist \input@path
- }
+ \cs_if_exist:NT \input@path
+ {
+ \seq_set_eq:NN \l_file_search_path_seq
+ \l_file_search_path_saved_seq
+ }
%</package>
%<*initex|package>
- \clist_map_function:NN \l_file_search_path_clist \file_add_path_aux:n
+ \ior_close:N \g_file_test_stream
+ \tl_if_empty:NTF \l_file_name_tl
+ { \prg_return_false: }
+ { \prg_return_true: }
}
-\cs_new_nopar:Npn \file_add_path_aux:n #1 { }
+\cs_generate_variant:Nn \file_if_exist:nT { V }
+\cs_generate_variant:Nn \file_if_exist:nF { V }
+\cs_generate_variant:Nn \file_if_exist:nTF { V }
% \end{macrocode}
%\end{macro}
-%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%\end{macro}
%
%\begin{macro}{\file_input:n}
-%\begin{macro}{\file_input_no_record:n}
-% \cs{file_add_path:nN} will return an empty token list variable if the
-% file is not found. This is used rather than \cs{file_if_exist:nT} here
-% as it saves running the same loop twice.
+%\begin{macro}{\file_input:V}
+% Most of the work is done by the file test above.
% \begin{macrocode}
-\cs_new:Npn \file_input:n #1 {
- \file_add_path:nN {#1} \l_file_tmp_tl
- \tl_if_empty:NF \l_file_tmp_tl {
- \file_input_no_check:n \l_file_tmp_tl
- }
-}
-\cs_new:Npn \file_input_no_record:n #1 {
- \file_add_path:nN {#1} \l_file_tmp_tl
- \tl_if_empty:NF \l_file_tmp_tl {
- \file_input_no_check_no_record:n \l_file_tmp_tl
- }
-}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\file_input_no_check:n}
-% File input records what is going on before setting to work.
-% \begin{macrocode}
-\cs_new_nopar:Npn \file_input_no_check:n #1 {
- \clist_gput_right:Nx \g_file_record_clist {#1}
- \wlog{ADDING: #1}
+\cs_new_protected_nopar:Npn \file_input:n #1 {
+ \file_if_exist:nT {#1}
+ {
%</initex|package>
%<*package>
- \@addtofilelist {#1}
+ \@addtofilelist {#1}
%</package>
%<*initex|package>
- \clist_gput_right:Nx \g_file_record_full_clist {#1}
- \tex_input:D #1 ~
+ \seq_gpush:NV \g_file_stack_seq \g_file_current_name_tl
+ \tl_gset:Nn \g_file_current_name_tl {#1}
+ \tex_expandafter:D \tex_input:D \l_file_name_tl ~
+ \seq_gpop:NN \g_file_stack_seq \g_file_current_name_tl
+ }
}
+\cs_generate_variant:Nn \file_input:n { V }
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\file_input_no_check_no_record:n}
-% Inputting a file without adding to the main record is basically the
-% same: even in this case the file goes on the full log.
+%\end{macro}
+%
+%\begin{macro}{\file_path_include:n}
+%\begin{macro}{\file_path_remove:n}
+% Wrapper functions to manage the search path.
% \begin{macrocode}
-\cs_new_nopar:Npn \file_input_no_check_no_record:n #1 {
- \clist_gput_right:Nx \g_file_record_full_clist {#1}
- \tex_input:D #1 ~
+\cs_new_protected_nopar:Npn \file_path_include:n #1 {
+ \seq_put_right:Nn \l_file_search_path_seq {#1}
+ \seq_remove_duplicates:N \l_file_search_path_seq
+}
+\cs_new_protected_nopar:Npn \file_path_remove:n #1 {
+ \seq_remove_element:Nn \l_file_search_path_seq {#1}
}
% \end{macrocode}
%\end{macro}
+%\end{macro}
%
%\begin{macro}{\file_list:}
-%\begin{macro}{\file_list_full:}
-%\begin{macro}[aux]{\file_list:N}
-% Two functions to list all files used to the log: the \texttt{full}
-% version includes everything whereas the standard version uses the
-% shorter record.
+%\begin{macro}[aux]{\file_list_aux:n}
+% A function to list all files used to the log.
% \begin{macrocode}
-\cs_new_nopar:Npn \file_list: {
- \file_list:N \g_file_record_clist
-}
-\cs_new_nopar:Npn \file_list_full: {
- \file_list:N \g_file_record_full_clist
-}
-\cs_new_nopar:Npn \file_list:N #1 {
- \clist_remove_duplicates:N #1
- \iow_log:x { *~File~List~* }
- \clist_map_function:NN #1 \file_list_aux:n
- \iow_log:x { ************* }
-}
-\cs_new_nopar:Npn \file_list_aux:n #1 {
- \iow_log:x { #1 }
+\cs_new_protected_nopar:Npn \file_list: {
+ \seq_remove_duplicates:N \g_file_record_seq
+ \iow_log:n { *~File~List~* }
+ \seq_map_function:NN \g_file_record_seq \file_list_aux:n
+ \iow_log:n { ************* }
}
+\cs_new_protected_nopar:Npn \file_list_aux:n #1 { \iow_log:n {#1} }
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\end{macro}
%
% When used as a package, there is a need to hold onto the standard
% file list as well as the new one here.
% \begin{macrocode}
%</initex|package>
%<*package>
-% \begin{macrocode}
\AtBeginDocument{
- \clist_put_right:NV \g_file_record_clist \@filelist
- \clist_put_right:NV \g_file_record_full_clist \@filelist
+ \clist_map_inline:Nn \@filelist
+ { \seq_put_right:Nn \g_file_record_seq {#1} }
}
%</package>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3final.dtx b/Master/texmf-dist/source/latex/expl3/l3final.dtx
index b9f61d473b2..d5ceed0477a 100644
--- a/Master/texmf-dist/source/latex/expl3/l3final.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3final.dtx
@@ -37,7 +37,7 @@
%</driver|package>
%<*-ini>
%\fi
-\GetIdInfo$Id: l3final.dtx 1670 2009-11-01 22:34:54Z will $
+\GetIdInfo$Id: l3final.dtx 1857 2010-03-21 21:32:09Z joseph $
{L3 Experimental final module}
%\iffalse
%</-ini>
@@ -56,32 +56,155 @@
%\section{Finalising \textsf{expl3}}
%
% This module is the end of \pkg{expl3}, and finishes off the
-% format. It also contains the loading code for the rest of \LaTeX3.
+% format. It also contains the loading code for the rest of \LaTeX3,
+% along with those parts of the document structure which need to be
+% in place for the rest of \LaTeX3 to load successfully.
%
-%\begin{function}{\par}
+%\begin{function}{
+% \execute_at_document_begin:n |
+% \execute_at_document_end:n |
+% \execute_at_text_begin:n |
+% \execute_at_text_end:n |
+%}
% \begin{syntax}
-% "\par"
+% "\execute_at_document_begin:n" \marg{code}
% \end{syntax}
-% \cs{par} needs to be defined, as \TeX\ uses it in some runaway
-% situtations.
+% Executes \meta{code} at the stated place in the document.
+% \cs{execute_at_document_begin:n} code is executed at the
+% beginning of |\begin{document}|, while \cs{execute_at_text_begin:n}
+% is at the end of |\begin{document}|, \emph{i.e}.~the start of the
+% text. In the same way, \cs{execute_at_text_end:n} code is run
+% by |\end{document}| immediately, while
+% \cs{execute_at_document_end:n} is the final part of the document
+% before calling \cs{tex_end:D}.
+% \begin{texnote}
+% \cs{execute_at_text_begin:n} is similar to \cs{AtBeginDocument}
+% in \LaTeXe, while \cs{execute_at_text_end:n} is similar to
+% \cs{AtEndDocument}.
+% \end{texnote}
%\end{function}
+%
+%\begin{variable}{
+% \g_execute_document_begin_tl |
+% \g_execute_document_end_tl |
+% \g_execute_text_begin_tl |
+% \g_execute_text_end_tl |
+%}
+% The \meta{code} stored by the \cs{execute_at\ldots} functions is
+% stored in these token registers.
+%\end{variable}
%
-%\begin{function}{\latex_format_dump:}
+%\begin{function}{\par}
% \begin{syntax}
-% "\latex_format_dump:"
+% "\par"
% \end{syntax}
-% Dumps the format, settting category codes back to user space and
-% undefines itself (as it can only every be used once).
+% \cs{par} needs to be defined, as \TeX\ uses it in some runaway
+% situations.
%\end{function}
%
+%\subsection{Minimal document support}
+%
+% Some temporary material to allow testing of the \pkg{xpackages} in
+% \texttt{initex} mode.
+%
+%\begin{macro}{\g_execute_document_begin_tl}
+%\begin{macro}{\g_execute_document_end_tl}
+%\begin{macro}{\g_execute_text_begin_tl}
+%\begin{macro}{\g_execute_text_end_tl}
+% Token registers to hold material to be executed at the start
+% and end of the document.
+% \begin{macrocode}
+%<*initex>
+\tl_new:N \g_execute_document_begin_tl
+\tl_new:N \g_execute_document_end_tl
+\tl_new:N \g_execute_text_begin_tl
+\tl_new:N \g_execute_text_end_tl
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\execute_at_document_begin:n}
+%\begin{macro}{\execute_at_document_end:n}
+%\begin{macro}{\execute_at_text_begin:n}
+%\begin{macro}{\execute_at_text_end:n}
+% Four commands which add material to the token registers. In each
+% case, the commands are set up to self-deactivate as the first thing
+% that will happen when the hooks are executed.
+% \begin{macrocode}
+\cs_new_protected:Npn \execute_at_document_begin:n #1 {
+ \tl_gput_right:Nn \g_execute_document_begin_tl {#1}
+}
+\cs_new_protected:Npn \execute_at_document_end:n #1 {
+ \tl_gput_right:Nn \g_execute_document_end_tl {#1}
+}
+\cs_new_protected:Npn \execute_at_text_begin:n #1 {
+ \tl_gput_right:Nn \g_execute_text_begin_tl {#1}
+}
+\cs_new_protected:Npn \execute_at_text_end:n #1 {
+ \tl_gput_right:Nn \g_execute_text_end_tl {#1}
+}
+\execute_at_document_begin:n {
+ \tl_gclear:N \g_execute_document_begin_tl
+ \cs_set_eq:NN \execute_at_document_begin:n \use:n
+}
+\execute_at_document_end:n {
+ \tl_gclear:N \g_execute_document_end_tl
+ \cs_set_eq:NN \execute_at_document_end:n \use:n
+}
+\execute_at_text_begin:n {
+ \tl_gclear:N \g_execute_text_begin_tl
+ \cs_set_eq:NN \execute_at_text_begin:n \use:n
+}
+\execute_at_text_end:n {
+ \tl_gclear:N \g_execute_text_end_tl
+ \cs_set_eq:NN \execute_at_text_end:n \use:n
+}
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+% Two \emph{temporary} functions to allow testing: these are
+% very basic and just do enough for things to work! The real
+% implementation of the document environment will end up somewhere
+% else in the end.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \document {
+ \tl_use:N \g_execute_document_begin_tl
+ % Code will go here
+ \tl_use:N \g_execute_text_begin_tl
+}
+\cs_new_protected_nopar:Npn \enddocument {
+ \tl_use:N \g_execute_text_end_tl
+ % Code will go here
+ \tl_use:N \g_execute_document_end_tl
+ \tex_end:D
+}
+% \end{macrocode}
+%
+% No-ops for \cs{begin} and \cs{end}, so that they can be used in
+% error messages, \emph{etc}.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \begin #1 { }
+\cs_new_protected_nopar:Npn \end #1 { }
+% \end{macrocode}
+%
%\subsection{Higher-level \LaTeX3}
%
% Here, the rest of \LaTeX3 is loaded in a `chain'.
% \begin{macrocode}
-\clist_map_inline:nn {
- xparse ,
- xtemplate ,
-} { \file_input_no_record:n { #1 .ltx } }
+\clist_map_inline:nn
+ {
+ xparse ,
+ xtemplate ,
+ }
+ {
+ \file_if_exist:nT { #1 .ltx }
+ { \tex_input:D #1 .ltx ~ }
+ }
% \end{macrocode}
%
%\subsection{Dumping the format}
@@ -90,45 +213,55 @@
% \TeX\ has a nasty habit of inserting a command with the name \cs{par}
% so we had better make sure that that command at least has a definition.
% \begin{macrocode}
-%<*initex>
\cs_set_eq:NN \par \tex_par:D
% \end{macrocode}
%\end{macro}
%
+% Until the start of the document, \cs{tex_everypar:D} is set up to
+% print an error if there is any text. Using \cs{tex_nullfont:D} means
+% that whitespace is not important between material in the preamble.
+% \begin{macrocode}
+\msg_kernel_new:nnnn { document } { missing-begin-document }
+ {Missing \begin{document}.}
+ {
+ You've tried to print something before \begin{document}\\%
+ This probably means there's a mistake somewhere in your source.%
+ }
+\tex_everypar:D {
+ \msg_kernel_error:nn { document } { missing-begin-document }
+}
+\tex_nullfont:D
+% \end{macrocode}
+%
%\begin{macro}{\ExplSyntaxOff}
% We re-define \cs{ExplSyntaxOff} as the version that comes through
% from \pkg{l3names} is defined using \TeX\ primitives, which we no
% longer have! Here, we can also make a fixed decision about the
% category codes to fix.
% \begin{macrocode}
-%<*initex>
-\cs_set_nopar:Npn \ExplSyntaxOff {
- \intexpr_if_odd:nT { \ExplSyntaxStatus } {
- \tl_set:Nn \ExplSyntaxStatus { 0 }
- \char_set_catcode:nn { 126 } { 13 }
- \char_set_catcode:nn { 32 } { 10 }
- \char_set_catcode:nn { 9 } { 10 }
- \char_set_catcode:nn { 95 } { 8 }
- \char_set_catcode:nn { 58 } { 12 }
- \tex_endlinechar:D = 13 \scan_stop:
- }
+\cs_set_protected_nopar:Npn \ExplSyntaxOff {
+ \intexpr_if_odd:nT { \ExplSyntaxStatus }
+ {
+ \tl_set:Nn \ExplSyntaxStatus { 0 }
+ \char_set_catcode:nn { 126 } { 13 }
+ \char_set_catcode:nn { 32 } { 10 }
+ \char_set_catcode:nn { 9 } { 10 }
+ \char_set_catcode:nn { 95 } { 8 }
+ \char_set_catcode:nn { 58 } { 12 }
+ \tex_endlinechar:D = 13 \scan_stop:
+ }
}
% \end{macrocode}
%\end{macro}
%
%\begin{macro}{\latex_format_dump:}
-% The last action to take is to dump the format. So that the document
-% starts with user category codes, \cs{ExplSyntaxOff} is called along
-% with tokenizing \cs{tex_dump:D} before actually calling it.
+% The last action to take is to dump the format.
% \begin{macrocode}
-\cs_new_nopar:Npn \latex_format_dump: {
+\use:n {
\ExplSyntaxOff
- \cs_gundefine:N \latex_format_dump:
\tex_dump:D
}
-\latex_format_dump:
%</initex>
% \end{macrocode}
-%\end{macro}
%
%\endinput
diff --git a/Master/texmf-dist/source/latex/expl3/l3format.ins b/Master/texmf-dist/source/latex/expl3/l3format.ins
new file mode 100644
index 00000000000..fc3e62d85f0
--- /dev/null
+++ b/Master/texmf-dist/source/latex/expl3/l3format.ins
@@ -0,0 +1,81 @@
+
+\input docstrip.tex
+\askforoverwritefalse
+
+\preamble
+
+
+EXPERIMENTAL CODE
+
+Do not distribute this file without also distributing the
+source files specified above.
+
+Do not distribute a modified version of this file.
+
+
+\endpreamble
+% stop docstrip adding \endinput
+\postamble
+\endpostamble
+
+\keepsilent
+
+% generate the format file
+\generate{%
+ \file{latex3.ltx}{%
+ \from{l3names.dtx}{initex} % The naming conventions
+ \from{l3basics.dtx}{initex} % Initialisations
+ \from{l3expan.dtx}{initex} % Controlling expansion of arguments
+ \from{l3tl.dtx}{initex} % token list variables
+ \from{l3intexpr.dtx}{initex} %
+ \from{l3quark.dtx}{initex} % quarks
+ \from{l3seq.dtx}{initex} % Sequences and stacks
+%
+ \from{l3alloc.dtx}{initex} % Register allocations
+%
+ \from{l3toks.dtx}{initex} % dealing with token registers
+ \from{l3int.dtx}{initex} % dealing with integer registers
+ \from{l3prg.dtx}{initex} % Program control structures
+ \from{l3clist.dtx}{initex} % Comma separated lists
+ \from{l3token.dtx}{initex} % token investigation
+ \from{l3prop.dtx}{initex} % property lists
+ \from{l3msg.dtx}{initex} % setting up for user communication
+ \from{l3io.dtx}{initex} % dealing with I/O
+ \from{l3skip.dtx}{initex} % dealing with skip registers
+ \from{l3box.dtx}{initex} % dealing with box registers
+ \from{l3keyval.dtx}{initex} %
+ \from{l3keys.dtx}{initex} %
+%
+% \from{l3precom.dtx}{initex,precompile} %
+%
+ \from{l3calc.dtx}{initex} %
+ \from{l3xref.dtx}{initex} % Cross references
+ \from{l3file.dtx}{initex} % file loading
+%
+ \from{l3vers.dtx}{initex} % Version information
+%
+%
+% \from{l3chk.dtx}{initex} % Checking functions
+%
+ \from{l3final.dtx}{initex} % Final wrap-up
+ }
+}
+
+% generate higher-level material
+\generate{%
+ \file{xparse.ltx}{\from{xparse.dtx}{initex}}
+ \file{xtemplate.ltx}{\from{xtemplate.dtx}{initex}}
+}
+
+\Msg{}
+\Msg{*************************************}
+\Msg{*}
+\Msg{* Now run (PDF)INITEX on lbase.ltx}
+\Msg{*}
+\Msg{* On an up to date system, run }
+\Msg{* pdftex -ini -etex *latex3.ltx }
+\Msg{*}
+\Msg{*************************************}
+\Msg{}
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/expl3/l3int.dtx b/Master/texmf-dist/source/latex/expl3/l3int.dtx
index 8b61ae04eab..df635a93fe3 100644
--- a/Master/texmf-dist/source/latex/expl3/l3int.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3int.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3int.dtx 1621 2009-10-25 06:36:19Z will $
+\GetIdInfo$Id: l3int.dtx 1867 2010-03-23 13:03:12Z will $
{L3 Experimental Integer module}
%\iffalse
%<*driver>
@@ -74,21 +74,18 @@
%
% \section{Functions}
%
-% \begin{function}{%
-% \int_new:N |
-% \int_new:c |
-%^^A \int_new_l:N |
-% }
+% \begin{function}{ \int_new:N |
+% \int_new:c |
+% \int_new_local:N |
+% \int_new_local:c }
% \begin{syntax}
% "\int_new:N" <int>
% \end{syntax}
-% Globally defines <int> to be a new variable of type "int" although
-% you can still choose if it should be a an "\l_" or "\g_" type.
-% There is no way to define constant counters with these functions.
-%^^A The function "\int_new_l:N" defines <int> locally only.
+% Defines <int> to be a new variable of type "int".
+% With the |local| variant, the variable is only available within the
+% current group level (or below).
% \begin{texnote}
% "\int_new:N" is the equivalent to plain \TeX{}'s \tn{newcount}.
-% However, the internal register allocation is done differently.
% \end{texnote}
% \end{function}
%
@@ -341,6 +338,10 @@
% <int> register.
% \end{variable}
%
+% \begin{variable}{\c_max_register_int}
+% Maximum number of registers.
+% \end{variable}
+%
%
% \begin{variable}{%
% \l_tmpa_int |
@@ -456,32 +457,35 @@
% \subsection{Allocation and setting}
%
% \begin{macro}{\int_new:N,\int_new:c}
-%^^A \begin{macro}{\int_new_l:N}
-% Allocation of a new internal counter is already done above. Here we define
-% the next likely variant.
-%
+% \begin{macro}{\int_new_local:N,\int_new_local:c}
% For the \LaTeX3 format:
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {int} {11} \c_max_register_num
-\cs_new_nopar:Npn \int_new:N #1 {\alloc_reg:NnNN g {int} \tex_countdef:D#1}
-\cs_new_nopar:Npn \int_new_l:N #1 {\alloc_reg:NnNN l {int} \tex_countdef:D#1}
+\alloc_new:nnnN {int} {11} {\c_max_register_int} \tex_countdef:D
%</initex>
% \end{macrocode}
% For `l3in2e':
% \begin{macrocode}
%<*package>
-\cs_new_nopar:Npn \int_new:N #1 {
+\cs_new_protected_nopar:Npn \int_new:N #1 {
\chk_if_free_cs:N #1
\newcount #1
}
+\cs_new_protected_nopar:Npn \int_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newcount \loccount
+ #1
+}
%</package>
% \end{macrocode}
% \begin{macrocode}
\cs_generate_variant:Nn \int_new:N {c}
+\cs_generate_variant:Nn \int_new_local:N {c}
% \end{macrocode}
% \end{macro}
-%^^A \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\int_set:Nn}
@@ -491,12 +495,12 @@
% Setting counters is again something that I would like to make
% uniform at the moment to get a better overview.
% \begin{macrocode}
-\cs_new_nopar:Npn \int_set:Nn #1#2{#1 \intexpr_eval:w #2\intexpr_eval_end:
+\cs_new_protected_nopar:Npn \int_set:Nn #1#2{#1 \intexpr_eval:w #2\intexpr_eval_end:
%<*check>
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \int_gset:Nn {
+\cs_new_protected_nopar:Npn \int_gset:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -521,17 +525,17 @@
% Incrementing and decrementing of integer registers is done with
% the following functions.
% \begin{macrocode}
-\cs_new_nopar:Npn \int_incr:N #1{\int_advance:w#1\c_one
+\cs_new_protected_nopar:Npn \int_incr:N #1{\int_advance:w#1\c_one
%<*check>
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \int_decr:N #1{\int_advance:w#1\c_minus_one
+\cs_new_protected_nopar:Npn \int_decr:N #1{\int_advance:w#1\c_minus_one
%<*check>
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \int_gincr:N {
+\cs_new_protected_nopar:Npn \int_gincr:N {
% \end{macrocode}
% We make sure that a local variable is not updated globally by
% changing the internal test (i.e.\ |\chk_local_or_pref_global:N|) before
@@ -546,7 +550,7 @@
%</check>
%<-check> \pref_global:D
\int_incr:N}
-\cs_new_nopar:Npn \int_gdecr:N {
+\cs_new_protected_nopar:Npn \int_gdecr:N {
%<*check>
\pref_global_chk:
%</check>
@@ -556,10 +560,10 @@
% With the |\int_add:Nn| functions we can shorten the above code.
% If this makes it too slow \ldots
% \begin{macrocode}
-\cs_set_nopar:Npn \int_incr:N #1{\int_add:Nn#1\c_one}
-\cs_set_nopar:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one}
-\cs_set_nopar:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one}
-\cs_set_nopar:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one}
+\cs_set_protected_nopar:Npn \int_incr:N #1{\int_add:Nn#1\c_one}
+\cs_set_protected_nopar:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one}
+\cs_set_protected_nopar:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one}
+\cs_set_protected_nopar:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one}
% \end{macrocode}
%
% \begin{macrocode}
@@ -584,12 +588,12 @@
% \begin{macro}{\int_gzero:c}
% Functions that reset an \m{int} register to zero.
% \begin{macrocode}
-\cs_new_nopar:Npn \int_zero:N #1 {#1=\c_zero}
+\cs_new_protected_nopar:Npn \int_zero:N #1 {#1=\c_zero}
\cs_generate_variant:Nn \int_zero:N {c}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \int_gzero:N #1 {\pref_global:D #1=\c_zero}
+\cs_new_protected_nopar:Npn \int_gzero:N #1 {\pref_global:D #1=\c_zero}
\cs_generate_variant:Nn \int_gzero:N {c}
% \end{macrocode}
% \end{macro}
@@ -608,7 +612,7 @@
% Adding and substracting to and from a counter \ldots
% We should think of using these functions
% \begin{macrocode}
-\cs_new_nopar:Npn \int_add:Nn #1#2{
+\cs_new_protected_nopar:Npn \int_add:Nn #1#2{
% \end{macrocode}
% We need to say |by| in case the first argument is a register
% accessed by its number, e.g., |\count23|. Not that it should
@@ -625,13 +629,13 @@
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \int_gadd:Nn {
+\cs_new_protected_nopar:Npn \int_gadd:Nn {
%<*check>
\pref_global_chk:
%</check>
%<-check> \pref_global:D
\int_add:Nn }
-\cs_new_nopar:Npn \int_gsub:Nn {
+\cs_new_protected_nopar:Npn \int_gsub:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -692,7 +696,7 @@
% character \TeX{} produces to the character we actually want which
% will give us letters with category code~11.%
% \begin{macrocode}
-\cs_new_nopar:Npn \int_roman_lcuc_mapping:Nnn #1#2#3{
+\cs_new_protected_nopar:Npn \int_roman_lcuc_mapping:Nnn #1#2#3{
\cs_set_nopar:cpn {int_to_lc_roman_#1:}{#2}
\cs_set_nopar:cpn {int_to_uc_roman_#1:}{#3}
}
@@ -927,16 +931,23 @@
% As stated, most constants can be defined as |\tex_chardef:D| or
% |\tex_mathchardef:D| but that's engine dependent.
% \begin{macrocode}
-\cs_new_nopar:Npn \int_const:Nn #1#2 {
- \intexpr_compare:nNnTF {#2} > \c_minus_one {
- \intexpr_compare:nNnTF {#2} > \c_max_register_num {
- \int_new:N #1 \int_set:Nn #1{#2}
- } {
- \chk_if_free_cs:N #1 \tex_mathchardef:D #1 = \intexpr_eval:n{#2}
+\cs_new_protected_nopar:Npn \int_const:Nn #1#2 {
+ \intexpr_compare:nTF { #2 > \c_minus_one }
+ {
+ \intexpr_compare:nTF { #2 > \c_max_register_int }
+ {
+ \int_new:N #1
+ \int_gset:Nn #1 {#2}
+ }
+ {
+ \chk_if_free_cs:N #1
+ \tex_global:D \tex_mathchardef:D #1 = \intexpr_eval:n {#2}
+ }
+ }
+ {
+ \int_new:N #1
+ \int_gset:Nn #1 {#2}
}
- } {
- \int_new:N #1 \int_set:Nn #1{#2}
- }
}
% \end{macrocode}
% \end{macro}
diff --git a/Master/texmf-dist/source/latex/expl3/l3intexpr.dtx b/Master/texmf-dist/source/latex/expl3/l3intexpr.dtx
index 25c95f8356a..4c43e63e6db 100644
--- a/Master/texmf-dist/source/latex/expl3/l3intexpr.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3intexpr.dtx
@@ -61,255 +61,247 @@
% \maketitle
%
% \begin{documentation}
+%
+% Calculation and comparison of integer values can be carried out
+% using literal numbers, \texttt{int} registers, constants and
+% integers stored in token list variables. The standard operators
+% \texttt{+}, \texttt{-}, \texttt{/} and \texttt{*} and
+% parentheses can be used within such expressions to carry
+% arithmetic operations. This module carries out these functions
+% on \emph{integer expressions} (`\texttt{int expr}').
%
-% This module sets up evaluation of integer expressions and allows
-% mixing |int| and |num| registers.
-%
-% An integer expression is one that contains integers in the form of
-% numbers, registers containg numbers, i.e., |int| and |num| registers
-% plus constants like |\c_one|, standard operators "+", "-", "/" and
-% "*" and parentheses to group sub-expressions.
-%
-% \section{Functions}
+%\section{Calculating and comparing integers}
%
-% \begin{function}{%
-% \intexpr_eval:n / (EXP)
-% }
+% \begin{function}{\intexpr_eval:n / (EXP)}
% \begin{syntax}
-% "\intexpr_eval:n" \Arg{int~expr}
+% "\intexpr_eval:n" \Arg{int~expr}
% \end{syntax}
-% The result of this expansion is a properly terminated <number>,
-% i.e., one that can be used with "\if_case:w" and others. For example,
-% \begin{quote}
-% |\intexpr_eval:n{ 5 + 4*3 - (3+4*5) }|
-% \end{quote}
-% evaluates to $-6$. The result is returned after two expansions so
-% if you find that you need to pass on the result to another function
-% using the expansion engine, the recommendation is to use an "f" type
-% expansion if in an expandable context or "x" otherwise.
+% Evaluates an <integer expression>, expanding to a properly
+% terminated <number> that can be used in any situation that
+% demands one, or which can be typeset. For example,
+%\begin{verbatim}
+% \intexpr_eval:n{ 5 + 4*3 - (3+4*5) }
+%\end{verbatim}
+% evaluates to \(-6\). Two expansions are necessary to convert the
+% <expression> into the <number> it represents. Full expansion to
+% the <number> can be carried out using an \texttt{f} expansion
+% in an expandable context or a \texttt{x} expansion in other
+% cases.
% \end{function}
%
-%
-% \begin{function}{%
-% \intexpr_compare_p:n / (EXP) |
-% \intexpr_compare:n / (TF)(EXP)
-% }
+%\begin{function}{
+% \intexpr_compare_p:n / (EXP) |
+% \intexpr_compare:n / (TF) (EXP)
+%}
% \begin{syntax}
-% "\intexpr_compare_p:n" \Arg{<int~expr1> <rel> <int~expr2>}
+% "\intexpr_compare_p:n" \Arg{<int~expr1> <rel> <int~expr2>}
+% "\intexpr_compare:nTF" \Arg{<int~expr1> <rel> <int~expr2>}
+% ~~~~<true code> <false code>
% \end{syntax}
-% Compares <int~expr1> with <int~expr2> using C-like relational
-% operators, i.e.
+% Evaluates <integer expression 1> and <integer expression 2> as
+% described for \cs{intexpr_eval:n}, and then carries out a
+% comparison of the resulting integers using C-like operators:
% \begin{center}
-% \begin{tabular}{ll@{\hspace{2cm}}ll}
-% Less than & "<" & Less than or equal & "<=" \\
-% Greater than & "<" & Greater than or equal & ">=" \\
-% Equal & "==" or "=" & Not equal & "!="
-% \end{tabular}
+% \begin{tabular}{ll@{\hspace{2cm}}ll}
+% Less than & "<" & Less than or equal & "<=" \\
+% Greater than & "<" & Greater than or equal & ">=" \\
+% Equal & "==" or "=" & Not equal & "!="
+% \end{tabular}
% \end{center}
-% Both integer expressions are evaluated fully in the process. Note
-% the syntax, which allows natural input in the style of
+% Based on the result of the comparison either the <true code>
+% or <false code> is executed. Both integer expressions are evaluated
+% fully in the process. Note the syntax, which allows natural input in
+% the style of
% \begin{quote}
% |\intexpr_compare_p:n {5+3 != \l_tmpb_int}|
% \end{quote}
-% "=" is added for the sake of \TeX\ users accustomed to using a
-% single equal sign.
+% \texttt{=} is available as comparator (in addition to those
+% familiar to C users) as standard \TeX\ practice is to compare
+% values using a single \texttt{=}.
% \end{function}
%
%
-% \begin{function}{%
-% \intexpr_compare_p:nNn / (EXP) |
-% \intexpr_compare:nNn / (TF)(EXP)
-% }
-% \begin{syntax}
-% "\intexpr_compare_p:nNn" \Arg{int~expr1}<rel>\Arg{int~expr2}
-% \end{syntax}
-% Compares <int~expr1> with <int~expr2> using one of the relations
-% "=", ">" or "<". This is faster than the variant above but at the
-% cost of requiring a little more typing and not supporting the
-% extended set of relational operators. Note that if both expressions
-% are normal integer variables as in
-% \begin{quote}
-% "\intexpr_compare:nNnTF \l_temp_int < \c_zero {negative}{non-negative}"
-% \end{quote}
-% you can safely omit the braces.
-% \end{function}
-%
-%
-% \begin{function}{%
-% \intexpr_max:nn / (EXP)|
-% \intexpr_min:nn / (EXP)|
-% }
-% \begin{syntax}
-% "\intexpr_max:nn" \Arg{int~expr1} \Arg{int~expr2}
-% \end{syntax}
-% Return the largest or smallest of two integer expressions.
-% \end{function}
-%
-% \begin{function}{%
-% \intexpr_abs:n / (EXP)|
-% }
-% \begin{syntax}
-% "\intexpr_abs:n" \Arg{int~expr}
-% \end{syntax}
-% Return the numerical value of an integer expression.
-% \end{function}
-%
-% \begin{function}{%
-% \intexpr_if_odd:n / (EXP)(TF) |
-% \intexpr_if_odd_p:n / (EXP) |
-% \intexpr_if_even:n / (EXP)(TF) |
-% \intexpr_if_even_p:n / (EXP) |
-% }
-% \begin{syntax}
-% "\intexpr_if_odd:nTF" \Arg{int~expr} \Arg{true} \Arg{false}
-% \end{syntax}
-% These functions test if an integer expression is even or odd.
-% \end{function}
-%
-%
-%
-%
-%
-%
-% \begin{function}{%
-% \intexpr_div_truncate:nn / (EXP) |
-% \intexpr_div_round:nn / (EXP) |
-% \intexpr_mod:nn / (EXP) |
-% }
-% \begin{syntax}
-% "\intexpr_div_truncate:n" \Arg{int~expr} \Arg{int~expr} \\
-% "\intexpr_mod:nn" \Arg{int~expr} \Arg{int~expr}
-% \end{syntax}
-% If
-% you want the result of a division to be truncated use
-% "\intexpr_div_truncate:nn". "\intexpr_div_round:nn" is added for
-% completeness. "\intexpr_mod:nn" returns the remainder of a division.
-% \end{function}
-%
-%
-%
-%
-%
-%
-%
-%
-%
-%
-%
-% \section{Primitive functions}
-%
-%
-% \begin{function}{%
-% \intexpr_value:w |
-% }
-% \begin{syntax}
-% "\intexpr_value:w" <integer> \\
-% "\intexpr_value:w" <tokens> <optional space>
-% \end{syntax}
-% Expands <tokens> until an <integer> is formed. One space may be
-% gobbled in the process.
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{number}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{%
-% \intexpr_eval:w |
-% \intexpr_eval_end: |
-% }
+%\begin{function}{
+% \intexpr_compare_p:nNn / (EXP) |
+% \intexpr_compare:nNn / (TF)(EXP)
+%}
% \begin{syntax}
-% "\intexpr_eval:w" <int expr> "\intexpr_eval_end:"
+% "\intexpr_compare_p:nNn" \Arg{int~expr1} <rel> \Arg{int~expr2}
% \end{syntax}
-% Evaluates <int expr>. The evaluation stops when an
-% unexpandable token of catcode other than 12 is reached or
-% "\intexpr_end:" is read. The latter is gobbled by the scanner
-% mechanism.
-% \begin{texnote}
-% This is the \eTeX{} primitive \tn{numexpr}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{%
-% \if_intexpr_compare:w |
-% }
+% Evaluates <integer expression 1> and <integer expression 2> as
+% described for \cs{intexpr_eval:n}, then compares the two
+% results using one of the relations \texttt{=}, "<" or
+% ">". These functions are faster than the \texttt{n}
+% variants described above but do not support an extended set
+% of relational operators.
+%\end{function}
+%
+%
+%\begin{function}{
+% \intexpr_max:nn / (EXP)|
+% \intexpr_min:nn / (EXP)
+%}
% \begin{syntax}
-% "\if_intexpr_compare:w" <number1> <rel> <number2> <true> "\else:" <false> "\fi:"
+% "\intexpr_max:nn" \Arg{int~expr1} \Arg{int~expr2}
% \end{syntax}
-% Compare two numbers. It is recommended to use "\intexpr_eval:n" to
-% correctly evaluate and terminate these numbers. <rel> is one of
-% "<", "=" or ">" with catcode 12.
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{ifnum}.
-% \end{texnote}
+% Evaluates <integer expression 1> and <integer expression 2> as
+% described for \cs{intexpr_eval:n}, expanding to the larger or
+% smaller of the two resulting <numbers> (for \texttt{max} and
+% \texttt{min}, respectively).
% \end{function}
%
-% \begin{function}{%
-% \if_intexpr_odd:w |
-% }
+%\begin{function}{\intexpr_abs:n / (EXP)}
% \begin{syntax}
-% "\if_intexpr_odd:w" <number> <true> "\else:" <false> "\fi:"
+% "\intexpr_abs:n" \Arg{int~expr}
% \end{syntax}
-% Execute <true> if <number> is odd, <false> otherwise.
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{ifodd}.
-% \end{texnote}
+% Evaluates <integer expression> as described for \cs{intexpr_eval:n}
+% and expands to the absolute value of the resulting <number>.
% \end{function}
%
-% \begin{function}{%
-% \if_intexpr_case:w |
-% \or: |
-% }
+%\begin{function}{
+% \intexpr_if_odd:n / (EXP)(TF) |
+% \intexpr_if_odd_p:n / (EXP) |
+% \intexpr_if_even:n / (EXP)(TF) |
+% \intexpr_if_even_p:n / (EXP) |
+%}
% \begin{syntax}
-% "\if_intexpr_case:w" <number> <case0> "\or:" <case1> "\or:" "..." "\else:"
-% <default> "\fi:"
+% "\intexpr_if_odd:nTF" \Arg{int~expr} \Arg{true} \Arg{false}
% \end{syntax}
-% Chooses case <number>. If you wish to use negative numbers as well,
-% you can offset them with "\intexpr_eval:n".
-% \begin{texnote}
-% These are the \TeX{} primitives \tn{ifcase} and \tn{or}.
-% \end{texnote}
+% Evaluates <integer expression> as described for \cs{intexpr_eval:n}
+% and execute <true code> or <false code> depending on whether
+% the resulting <number> is odd or even.
% \end{function}
%
-%^^A Keep the documenation-checking happy
-%\ExplSyntaxOn
-%\seq_gput_right:Nx \g_doc_macros_seq { \token_to_str:N \or: }
-%\ExplSyntaxOff
-%
-% \begin{function}{%
-% \intexpr_while_do:nn |
-% \intexpr_until_do:nn |
-% \intexpr_do_while:nn |
-% \intexpr_do_until:nn |
-% }
+%\begin{function}{
+% \intexpr_div_truncate:nn / (EXP) |
+% \intexpr_div_round:nn / (EXP) |
+% \intexpr_mod:nn / (EXP) |
+%}
+% \begin{syntax}
+% "\intexpr_div_truncate:nn" \Arg{int~expr1} \Arg{int~expr2}
+% "\intexpr_mod:nn" \Arg{int~expr1} \Arg{int~expr2}
+% \end{syntax}
+% Evaluates <integer expression 1> and <integer expression 2> as
+% described for \cs{intexpr_eval:n}, expanding to the appropriate
+% result of division of the resulting <numbers>. The
+% \texttt{truncate} function expands to the integer part of the
+% division with the decimal simply discarded, whereas
+% \texttt{round} will use the decimal part to round the integer
+% up if appropriate. The \texttt{mod} function expands to the integer
+% remainder of the division.
+%\end{function}
+%
+% \section{Primitive (internal) functions}
+%
+%\begin{function}{
+% \if_num:w / (EXP) |
+% \if_inexpr_compare:w / (EXP)
+%}
+% \begin{syntax}
+% "\if_num:w" <number1> <rel> <number2> <true> "\else:" <false> "\fi:"
+% \end{syntax}
+% Compare two integers using <rel>, which must be one of
+% \texttt{=}, "<" or ">" with category code \(12\).
+% The \cs{else:} branch is optional.
+% \begin{texnote}
+% These are both names for the \TeX\ primitive \cs{ifnum}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{
+% \if_intexpr_case:w / (EXP) |
+% \if_case:w / (EXP) |
+% \or: / (EXP)
+%}
+% \begin{syntax}
+% "\if_case:w" <number> <case0> "\or:" <case1> "\or:" "..." "\else:"
+% <default> "\fi:"
+% \end{syntax}
+% Selects a case to execute based on the value of <number>. The first
+% case (<case0>) is executed if <number> is \(0\), the second
+% (<case1>) if the <number> is \(1\), \emph{etc}. The
+% <number> may be a literal, a constant or an integer
+% expression (\emph{e.g}.~using \cs{intexpr_eval:n}).
+% \begin{texnote}
+% These are the \TeX\ primitives \cs{ifcase} (with two
+% different names depending on context) and \cs{or}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{\intexpr_value:w / (EXP)}
+% \begin{syntax}
+% "\intexpr_value:w" <integer>
+% "\intexpr_value:w" <tokens> <optional space>
+% \end{syntax}
+% Expands <tokens> until an <integer> is formed. One space may be
+% gobbled in the process.
+% \begin{texnote}
+% This is the \TeX\ primitive \tn{number}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{
+% \intexpr_eval:w / (EXP) |
+% \intexpr_eval_end:
+%}
+% \begin{syntax}
+% "\intexpr_eval:w" <int expr> "\intexpr_eval_end:"
+% \end{syntax}
+% Evaluates <integer expression> as described for \cs{intexpr_eval:n}.
+% The evalution stops when an unexpandable token with category code
+% other than \(12\) is read or when \cs{intexpr_eval_end:} is
+% reached. The latter is gobbled by the scanner mechanism:
+% \cs{intexpr_eval_end:} itself is unexpandable but used correctly
+% the entire construct is expandable.
+% \begin{texnote}
+% This is the \eTeX\ primitive \cs{numexpr}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{\if_intexpr_odd:w / (EXP)}
+% \begin{syntax}
+% "\if_intexpr_odd:w" <tokens> <true> "\else:" <false> "\fi:"
+% "\if_intexpr_odd:w" <number> <true> "\else:" <false> "\fi:"
+% \end{syntax}
+% Expands <tokens> until a non-numeric tokens is found, and
+% tests whether the resulting <number> is odd. If so, <true code>
+% is executed. The \cs{else:} branch is optional.
+% \begin{texnote}
+% This is the \TeX\ primitive \cs{ifodd}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{
+% \intexpr_while_do:nn / (EXP) |
+% \intexpr_until_do:nn / (EXP) |
+% \intexpr_do_while:nn / (EXP) |
+% \intexpr_do_until:nn / (EXP)
+%}
% \begin{syntax}
-% "\intexpr_while_do:nn" \Arg{<int~expr1> <rel> <int~expr2>} \Arg{code}
+% "\intexpr_while_do:nn" \Arg{<int~expr1> <rel> <int~expr2>} \Arg{code}
% \end{syntax}
-% "\intexpr_while_do:nn" tests the integer expressions against each
-% other using a C-like <rel> as in "\intexpr_compare_p:n" and if true
-% performs the <code> until the test fails. "\intexpr_do_while:nn" is
-% similar but executes the <code> first and then performs the check,
-% thus ensuring that the body is executed at least once. The `until'
-% versions are similar but continue the loop as long as the test is
-% false. They could be omitted as it is just a matter of switching the
-% arguments in the test.
+% In the case of the \texttt{while_do} version, the integer
+% comparison is evaluated as described for \cs{intexpr_compare_p:n},
+% and if \texttt{true} execute the <code>. The test and code then
+% alternate until the result is <false>. The \texttt{do_while}
+% alternative first executes the <code> and then evaluates the integer
+% comparison. In the \texttt{until} cases, the <code> is executed
+% if the test is \texttt{false}: the loop is ended when the relation
+% is \texttt{true}.
% \end{function}
%
-% \begin{function}{%
-% \intexpr_while_do:nNnn |
-% \intexpr_until_do:nNnn |
-% \intexpr_do_while:nNnn |
-% \intexpr_do_until:nNnn |
-% }
+%\begin{function}{
+% \intexpr_while_do:nNnn / (EXP) |
+% \intexpr_until_do:nNnn / (EXP) |
+% \intexpr_do_while:nNnn / (EXP) |
+% \intexpr_do_until:nNnn / (EXP)
+%}
% \begin{syntax}
% "\intexpr_while_do:nNnn" <int expr> <rel> <int~expr> \Arg{code}
% \end{syntax}
-% Exactly as above but instead using the syntax of
-% "\intexpr_compare_p:nNn".
-% \end{function}
-%
-%
-%
-%
+% These behave in the same manner as the preceding loops but use the
+% relation logic described for \cs{intexpr_compare_p:nNn}.
+%\end{function}
%
% \end{documentation}
%
@@ -328,6 +320,17 @@
%<*initex|package>
% \end{macrocode}
%
+% \begin{macro}{\if_num:w}
+% \begin{macro}{\if_case:w}
+% Here are the remaining primitives for number comparisons and
+% expressions.
+% \begin{macrocode}
+\cs_new_eq:NN \if_num:w \tex_ifnum:D
+\cs_new_eq:NN \if_case:w \tex_ifcase:D
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\intexpr_value:w}
% \begin{macro}{\intexpr_eval:n,\intexpr_eval:w,\intexpr_eval_end:}
% \begin{macro}{\if_intexpr_compare:w}
@@ -634,6 +637,14 @@
% \end{macro}
% \end{macro}
% \end{macro}
+%
+%\begin{macro}{\c_max_register_int}
+% This is here as this particular integer is needed both in package
+% mode and to bootstrap \pkg{l3alloc}
+% \begin{macrocode}
+\tex_mathchardef:D \c_max_register_int = 32767 \scan_stop:
+% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
%</initex|package>
diff --git a/Master/texmf-dist/source/latex/expl3/l3io.dtx b/Master/texmf-dist/source/latex/expl3/l3io.dtx
index a1223daaa6f..ba99da22abe 100644
--- a/Master/texmf-dist/source/latex/expl3/l3io.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3io.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3io.dtx Copyright (C) 1990-2009 LaTeX3 project
+%% File: l3io.dtx Copyright (C) 1990-2010 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3io.dtx 1668 2009-11-01 22:13:36Z will $
+\GetIdInfo$Id: l3io.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental i/o module}
%\iffalse
%<*driver>
@@ -46,7 +46,7 @@
%\iffalse
\documentclass[full]{l3doc}
\begin{document}
-\DocInput{l3io.dtx}
+ \DocInput{l3io.dtx}
\end{document}
%</driver>
% \fi
@@ -59,266 +59,320 @@
% \date{\filedate}
% \maketitle
%
-% \begin{documentation}
-%
-% \TeX{} is capable of reading from and writing up to 16 individual
-% streams. These i/o operations are accessable in \LaTeX3 with functions
-% from the "\io.." modules. In most cases it will be
-% sufficiant for the programmer to use the functions provided by the
-% auxiliary file module, but here are the necessary functions for
-% manipulating private streams.
-%
-% Sometimes it is not known beforehand how much text is going to be
-% written with a single call. As a result some internal \TeX{} buffer
-% may overflow. To avoid this kind of problem, \LaTeX3 maintains beside
-% direct write operations like "\iow_now:Nx" also so called ``long''
-% writes where the output is broken into individual lines on every blank
-% in the text to be written. The resulting files are difficult to read
-% for humans but since they usually serve only as internal storage this
-% poses no problem.
-%
-% Beside the functions that immediately act (e.g., "\iow_now:Nx",
-% etc.) we also have deferred operations that are saved away until the
-% next page is finished. This allow to expand the <tokens> at the right
-% time to get correct page numbers etc.
-%
-% \section{Functions for output streams}
-%
-% \begin{function}{ \iow_new:N |
-% \iow_new:c }
-% \begin{syntax}
-% "\iow_new:N" <stream>
-% \end{syntax}
-% Defines <stream> to be a new identifer denoting an output stream for
-% use in subsequent functions.
-% \begin{texnote}
-% "\iow_new:N" corresponds to the plain \TeX{} \tn{newwrite}
-% allocation routine.
-% \end{texnote}
+%\begin{documentation}
+%
+% Reading and writing from file streams is handled in \LaTeX3 using
+% functions with prefixes \cs{iow_\ldots} (file reading) and
+% \cs{ior_\ldots} (file writing). Many of the basic functions are
+% very similar, with reading and writing using the same syntax and
+% function concepts. As a result, the reading and writing functions
+% are documented together where this makes sense.
+%
+% As \TeX\ is limited to \(16\) input streams and \(16\) output
+% streams, direct use of the streams by the programmer is not
+% supported in \LaTeX3. Instead, an internal pool of streams is
+% maintained, and these are allocated and deallocated as needed
+% by other modules. As a result, the programmer should close streams
+% when they are no longer needed, to release them for other processes.
+%
+% Reading from or writing to a file requires a \meta{stream} to
+% be used. This is a csname which refers to the file being processed,
+% and is independent of the name of the file (except of course that
+% the file name is needed when the file is opened).
+%
+%\section{Opening and closing streams}
+%
+%\begin{function}{
+% \iow_new:N |
+% \iow_new:c |
+% \ior_new:N |
+% \ior_new:c
+%}
+% \begin{syntax}
+% "\iow_new:N" <stream>
+% \end{syntax}
+% Reserves the name <stream> for use in accessing a file stream.
+% This operation does not open a raw \TeX\ stream, which is handled
+% internally using a pool and is should not be accessed directly by
+% the programmer.
+%\end{function}
+%
+%\begin{function}{
+% \iow_open:Nn |
+% \iow_open:cn |
+% \ior_open:Nn |
+% \ior_open:cn
+%}
+% \begin{syntax}
+% "\iow_open:Nn" <stream> \Arg{file name}
+% "\iow_open:Nn" <stream> \Arg{file name}
+% \end{syntax}
+% Opens <file name> for writing (\cs{iow_\ldots}) or reading
+% (\cs{ior_\ldots}) using <stream> as the csname by which the
+% file is accessed. If <stream> was already open (for either writing
+% or reading) it is closed before the new operation begins. The
+% <stream> is available for access immediately after issuing an
+% \texttt{open} instruction. The <stream> will remain allocated
+% to <file name> until a \texttt{close} instruction is given or at
+% the end of the \TeX\ run.
+%
+% Opening a file for writing will clear any existing content in the
+% file (\emph{i.e}.~writing is \emph{not} additive). As the total
+% number of writing streams is limited, it may well be best to save
+% material to be written to an intermediate storage format (for example
+% a token list or toks), and to write the material in one `shot'
+% from this variable. In this way the file stream is only required
+% for a limited time.
+%\end{function}
+%
+%\begin{function}{
+% \iow_close:N |
+% \iow_close:c |
+% \ior_close:N |
+% \ior_close:c
+%}
+% \begin{syntax}
+% "\iow_close:N" <stream>
+% "\ior_close:N" <stream>
+% \end{syntax}
+% Closes <stream>, freeing up one of the underlying \TeX\ streams
+% for reuse. Streams should always be closed when they are finished
+% with as this ensures that they remain available to other
+% programmers (the resources here are limited). The name of
+% the <stream> will be freed at this stage, to ensure that any
+% further attempts to write to it result in an error.
+%\end{function}
+%
+%\begin{function}{
+% \iow_open_streams: |
+% \iow_open_streams:
+%}
+% \begin{syntax}
+% "\iow_open_streams:"
+% \end{syntax}
+% Displays a list of the file names associated with each open
+% stream: intended for tracking down problems.
+%\end{function}
+%
+%\subsection{Writing to files}
+%
+%\begin{function}{
+% \iow_now:Nx |
+% \iow_now:Nn
+%}
+% \begin{syntax}
+% "\iow_now:Nx" <stream> \Arg{tokens}
+% \end{syntax}
+% \cs{iow_now:Nx} immediately writes the expansion of <tokens> to the
+% output <stream>. If the <stream> is not open output goes to the
+% terminal. The variant \cs{iow_now:Nn} writes out <tokens> without any
+% further expansion.
+% \begin{texnote}
+% These are the equivalent of \TeX's "\immediate\write" with and
+% without expansion control.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{
+% \iow_log:n |
+% \iow_log:x |
+% \iow_term:n |
+% \iow_term:x
+%}
+% \begin{syntax}
+% "\iow_log:x" \Arg{tokens}
+% \end{syntax}
+% These are dedicated functions which write to the log (transcript)
+% file and the terminal, respectively. They are equivalent to using
+% \cs{iow_now:N(n/x)} to the streams \cs{c_iow_log_stream} and
+% \cs{c_iow_term_stream}. The writing takes place immediately.
% \end{function}
-%
-% \begin{function}{ \iow_open:Nn |
-% \iow_open:cn }
-% \begin{syntax}
-% "\iow_open:Nn" <stream> \Arg{file name}
-% \end{syntax}
-% Opens output stream <stream> to write to <file name>. The output
-% stream is immediately available for use. If the <stream> was already
-% used as an output stream to some other file, this file gets closed
-% first.\footnote{This is a precaution since on some OS it is possible
-% to open the same file for output more than once which then results in
-% some internal errors at the end of the run.} Also, all output streams
-% still open at the end of the \TeX{} run will be automatically closed.
-% \end{function}
-%
-% \begin{function}{ \iow_close:N }
-% \begin{syntax}
-% "\iow_open:Nn" <stream>
-% \end{syntax}
-% Closes output stream <stream>.
-% \end{function}
-%
-% \subsection{Immediate writing}
-%
-% \begin{function}{ \iow_now:Nx |
-% \iow_now:Nn }
-% \begin{syntax}
-% "\iow_now:Nx" <stream> \Arg{tokens}
-% \end{syntax}
-% "\iow_now:Nx" immediately writes the expansion of <tokens> to the
-% output stream <stream>. If <stream> is not open output goes to the
-% terminal. The variant "\iow_now:Nn" writes out <tokens> without any
-% further expansion.
-% \begin{texnote}
-% These are the equivalent of \TeX's "\immediate\write" with and without
-% expansion control.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{ \iow_log:n | \iow_log:x |
-% \iow_term:x | \iow_term:n }
-% \begin{syntax}
-% "\iow_log:x" \Arg{tokens}
-% \end{syntax}
-% These functions write to the log file (also known as the transcript file) or
-% to the terminal respectively. They are equivalent to "\iow_now:Nx" where
-% <stream> is the transcript file ("\c_iow_log_stream") or the terminal
-% ("\c_iow_term_stream").
-% \end{function}
-%
-% \begin{function}{ \iow_now_buffer_safe:Nn |
-% \iow_now_buffer_safe:Nx }
-% \begin{syntax}
-% "\iow_now_buffer_safe:Nn" <stream> \Arg{tokens}
-% \end{syntax}
-% Like "\iow_now:Nx" but splits <tokens> at every blank into separate
-% lines. When potentially (very) long token lists are being written, this
-% avoids the problem of
-% buffer overflow when reading back the file.
-% \end{function}
-%
-% \begin{function}{ \iow_now_when_avail:Nn |
-% \iow_now_when_avail:cn }
-% \begin{syntax}
-% "\iow_now_when_avail:Nn" <stream> \Arg{tokens}
-% \end{syntax}
-% This special function first checks if the <stream> is open for writing.
-% If not it does nothing otherwise it behaves like "\iow_now:Nn".
-% \end{function}
-%
-% \subsection{Deferred writing}
-%
-% \begin{function}{ \iow_shipout:Nn | \iow_shipout:Nx }
-% \begin{syntax}
-% "\iow_shipout_x:Nn" <stream> \Arg{tokens}
-% \end{syntax}
-% These functions write <tokens> to the specified <stream>, but unlike with
-% "\iow_now:Nn" which write the material immediately, "\iow_shipout:Nn" waits
-% until the processing of the current page has finished.
-% \end{function}
-%
-% \begin{function}{ \iow_shipout_x:Nn | \iow_shipout_x:Nx }
-% \begin{syntax}
-% "\iow_shipout_x:Nn" <stream> \Arg{tokens}
-% \end{syntax}
-% More useful than the "\iow_shipout:Nn" functions, these functions also write
-% <tokens> to <stream> at the end of the processing of the current page;
-% however, before <tokens> are written they are subjected to a further
-% "x" expansion stage.
-%
-% This is useful for writing messages that depend
-% on counters (such as the page number) that are not known until the page has
-% been completed.
-%
-% "\iow_shipout_x:Nn" always needs "{}" around the second argument.
-% \begin{texnote}
-% "\iow_shipout_x:Nn" is equivalent to \TeX's \tn{write}.
-% \end{texnote}
-% \end{function}
-%
-% \subsection{Special characters for writing}
-%
-% \begin{function}{\iow_newline:}
-% \begin{syntax}
-% "\iow_newline:"
-% \end{syntax}
-% Function that produces a new line when used within the <token list>
-% that gets written some output stream in non-verbatim mode.
-% \end{function}
-%
-% \begin{function}{\iow_space:}
-% \begin{syntax}
-% "\iow_space:"
-% \end{syntax}
-% Function that produces a space when used within the <token list>
-% that gets written to some output stream in an expanding mode.
-% \end{function}
-%
-% \begin{function}{\iow_char:N}
-% \begin{syntax}
-% "\iow_space:N" "\"<char>
-% "\iow_space:N" "\%"
-% \end{syntax}
-% Inserts <char> into the output stream. Useful when trying to write difficult
-% characters such as "%", "{", "}", etc., in messages.
+%
+%\begin{function}{
+% \iow_now_buffer_safe:Nn |
+% \iow_now_buffer_safe:Nx
+%}
+% \begin{syntax}
+% "\iow_now_buffer_safe:Nn" <stream> \Arg{tokens}
+% \end{syntax}
+% Immediately write <tokens> expanded to <stream>, with every space
+% converted into a newline. This mean that the file can be
+% read back without the danger that very long lines overflow
+% \TeX's buffer.
% \end{function}
-%
-% \section{Functions for input streams}
-%
-% \begin{function}{\ior_new:N}
-% \begin{syntax}
-% "\ior_new:N" <stream>
-% \end{syntax}
-% This function defines <stream> to be a new input stream constant.
-% \begin{texnote}
-% This is the new name and new implementation for plain \TeX's
-% \tn{newread}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{\ior_open:Nn}
-% \begin{syntax}
-% "\ior_open:Nn" <stream> \Arg{file name}
-% \end{syntax}
-% This function opens <stream> as an input stream for the external file
-% <file name>. If <file name> doesn't exist or is an empty file the
-% stream is considered to be fully read, a condition which can be tested
-% with "\ior_if_eof:NTF" etc. If <stream> was already used to read from some
-% other file this file will be closed first. The input stream is ready
-% for immediate use.
-% \end{function}
-%
-% \begin{function}{\ior_close:N}
-% \begin{syntax}
-% "\ior_close:N" <stream>
-% \end{syntax}
-% This function closes the read stream <stream>.
-% \begin{texnote}
-% This is a new name for \tn{closein} but it is considered bad practice
-% to make use of this knowledge :-)
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{ \ior_if_eof_p:N / (EXP) | \ior_if_eof:N / (TF)(EXP) }
-% \begin{syntax}
-% "\ior_if_eof:NTF" <stream> \Arg{true code} \Arg{false code}
-% \end{syntax}
-% Conditional that tests if some input stream is fully read. The
-% condition is also true if the input stream is not open.
-% \end{function}
-%
-% \begin{function}{\if_eof:w}
-% \begin{syntax}
-% "\if_eof:w" <stream> <true code> "\else:" <false code> "\fi:"
-% \end{syntax}
-% \begin{texnote}
-% This is the primitive \tn{ifeof} but we allow only a <stream> and not
-% a plain number after it.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}{ \ior_to:NN |
-% \ior_gto:NN }
-% \begin{syntax}
-% "\ior_to:NN" <stream> <tl var.>
-% \end{syntax}
-% Functions that reads one or more lines (until an equal number of left
-% and right braces are found) from the input stream <stream> and places
-% the result locally or globally into the token list variable.
-% If <stream> is not open, input is requested from the terminal.
-% \end{function}
-%
-% \section{Constants}
-%
-% \begin{variable}{\c_iow_comment_char |
-% \c_iow_lbrace_char |
-% \c_iow_rbrace_char}
-% Constants that can be used to represent comment character, left and
-% right brace in token lists that should be written to a file.
-% \end{variable}
-%
-% \begin{variable}{ \c_iow_term_stream | \c_ior_term_stream }
-% Input or output stream denoting the terminal. If used as an input
-% stream the user is prompted with the name of the token list variable
-% (that is used
-% in the call "\ior_to:NN" or "\ior_gto:NN") followed by an equal sign.
-% If you don't want an automatic prompt of this sort ``misuse''
-% "\c_iow_log_stream" as an input stream.
-% \end{variable}
-%
-% \begin{variable}{ \c_iow_log_stream | \c_ior_log_stream }
-% Output stream that writes only to the transcript file (e.g., the
-% ".log" file on most systems). You may ``misuse'' this stream as an
-% input stream. In this case it acts as a terminal stream without user
-% prompting.
-% \end{variable}
-%
-%
-% \end{documentation}
-%
-% \begin{implementation}
-%
-% \section{\pkg{l3io} implementation}
+%
+%\begin{function}{
+% \iow_now_when_avail:Nn |
+% \iow_now_when_avail:cn |
+% \iow_now_when_avail:Nx |
+% \iow_now_when_avail:cx
+%}
+% \begin{syntax}
+% "\iow_now_when_avail:Nn" <stream> \Arg{tokens}
+% \end{syntax}
+% If <stream> is open, writes the <tokens> to the <stream> in the
+% same manner as \cs{iow_now:N(n/x)}. If the <stream> is not open,
+% the <tokens> are simply thrown away.
+%\end{function}
+%
+%\begin{function}{
+% \iow_shipout:Nx |
+% \iow_shipout:Nn
+%}
+% \begin{syntax}
+% "\iow_shipout:Nx" <stream> \Arg{tokens}
+% \end{syntax}
+% Write <tokens> to <stream> at the point at which the current page
+% is finished. The <tokens> are either written unexpanded
+% (\cs{iow_shipout:Nn}) or expanded only at the point that the
+% function is used (\cs{iow_shipout:Nx}), \emph{i.e}.~no expansion
+% takes place when writing to the file.
+%\end{function}
+%
+%\begin{function}{
+% \iow_shipout_x:Nx |
+% \iow_shipout_x:Nn
+%}
+% \begin{syntax}
+% "\iow_shipout_x:Nx" <stream> \Arg{tokens}
+% \end{syntax}
+% Write <tokens> to <stream> at the point at which the current page
+% is finished. The <tokens> are expanded at the time of writing
+% in addition to any expansion at the time of use of the function.
+% This makes these functions suitable for including material finalised
+% during the page building process (such as the page number integer).
+% \begin{texnote}
+% These are the equivalent of \TeX's \cs{write} with and
+% without expansion control at point of use.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{\iow_newline: / (EXP) }
+% \begin{syntax}
+% "\iow_newline:"
+% \end{syntax}
+% Function to add a new line within the <tokens> written to a file.
+% The function has no effect if writing is taking place without
+% expansion (\emph{e.g}.~in a \cs{iow_now:Nn} call).
+%\end{function}
+%
+%\begin{function}{\iow_char:N / (EXP) }
+% \begin{syntax}
+% "\iow_char:N" "\"<char>
+% "\iow_char:N" "\%"
+% \end{syntax}
+% Inserts <char> into the output stream. Useful when trying to write
+% difficult characters such as "%", "{", "}", \emph{etc}.~in messages,
+% for example:
+% \begin{verbatim}
+% \iow_now:Nx \g_my_stream { \iow_char:N \{ text \iow_char:N \} }
+% \end{verbatim}
+% The function has no effect if writing is taking place without
+% expansion (\emph{e.g}.~in a \cs{iow_now:Nn} call).
+%\end{function}
+%
+%\subsection{Reading from files}
+%
+%\begin{function}{
+% \ior_to:NN |
+% \ior_gto:NN
+%}
+% \begin{syntax}
+% "\ior_to:NN" <stream> <token list variable>
+% \end{syntax}
+% Functions that reads one or more lines (until an equal number of left
+% and right braces are found) from the input stream <stream> and places
+% the result locally or globally into the <token list variable>.
+% If <stream> is not open, input is requested from the terminal.
+%\end{function}
+%
+%\begin{function}{
+% \ior_if_eof_p:N / (EXP) |
+% \ior_if_eof:N / (EXP) (TF)
+%}
+% \begin{syntax}
+% "\ior_if_eof:NTF" <stream> \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Tests if the end of a <stream> has been reached during a reading
+% operation. The test will also return a \texttt{true} value if
+% the <stream> is not open or the <file name> associated with
+% a <stream> does not exist at all.
+%\end{function}
+%
+%\section{Internal functions}
+%
+%\begin{function}{
+% \iow_raw_new:N |
+% \iow_raw_new:c |
+% \ior_raw_new:N |
+% \ior_raw_new:c
+%}
+% \begin{syntax}
+% "\iow_raw_new:N" <stream>
+% \end{syntax}
+% Creates a new low-level <stream> for use in subsequent functions.
+% As allocations are made using a pool \emph{do not use this function!}
+% \begin{texnote}
+% This is \LaTeXe's \cs{newwrite}.
+% \end{texnote}
+%\end{function}
+%
+%\begin{function}{\if_eof:w / (EXP) }
+% \begin{syntax}
+% "\if_eof:w" <stream> <true code> "\else:" <false code> "\fi:"
+% \end{syntax}
+% Tests if the end of <stream> has been reached during a reading
+% operation.
+% \begin{texnote}
+% This is the primitive \cs{ifeof}.
+% \end{texnote}
+%\end{function}
+%
+%\section{Variables and constants}
+%
+%\begin{variable}{\c_io_streams_tl}
+% A list of the positions available for stream allocation (numbers
+% \(0\) to \(15\)).
+%\end{variable}
+%
+%\begin{variable}{
+% \c_iow_term_stream |
+% \c_ior_term_stream |
+% \c_iow_log_stream |
+% \c_ior_log_stream
+%}
+% Fixed stream numbers for accessing to the log and the terminal. The
+% reading and writing values are the same but are provided so that the
+% meaning is clear.
+%\end{variable}
+%
+%\begin{variable}{
+% \g_iow_streams_prop |
+% \g_ior_streams_prop
+%}
+% Allocation records for streams, linking the stream number to
+% the current name being used for that stream.
+%\end{variable}
+%
+%\begin{variable}{
+% \g_iow_tmp_stream |
+% \g_ior_tmp_stream
+%}
+% Used when creating new streams at the \TeX\ level.
+%\end{variable}
+%
+%\begin{variable}{
+% \l_iow_stream_int |
+% \l_ior_stream_int
+%}
+% Number of stream currently being allocated.
+%\end{variable}
+%
+%\end{documentation}
+%
+%\begin{implementation}
+%
+%\section{\pkg{l3io} implementation}
%
% We start by ensuring that the required packages are loaded.
% \begin{macrocode}
@@ -329,317 +383,545 @@
%</package>
%<*initex|package>
% \end{macrocode}
+%
+%\subsection{Variables and constants}
+%
+%\begin{macro}{\c_iow_term_stream}
+%\begin{macro}{\c_ior_term_stream}
+%\begin{macro}{\c_iow_log_stream}
+%\begin{macro}{\c_ior_log_stream}
+% Here we allocate two output streams for writing to the transcript
+% file only (\cs{c_iow_log_stream}) and to both the terminal and
+% transcript file (\cs{c_iow_term_stream}). Both can be used to read
+% from and have equivalent \cs{c_ior} versions.
+% \begin{macrocode}
+\cs_new_eq:NN \c_iow_term_stream \c_sixteen
+\cs_new_eq:NN \c_ior_term_stream \c_sixteen
+\cs_new_eq:NN \c_iow_log_stream \c_minus_one
+\cs_new_eq:NN \c_ior_log_stream \c_minus_one
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\c_iow_streams_tl}
+%\begin{macro}{\c_ior_streams_tl}
+% The list of streams available, by number.
+% \begin{macrocode}
+\tl_const:Nn \c_iow_streams_tl
+ {
+ \c_zero
+ \c_one
+ \c_two
+ \c_three
+ \c_four
+ \c_five
+ \c_six
+ \c_seven
+ \c_eight
+ \c_nine
+ \c_ten
+ \c_eleven
+ \c_twelve
+ \c_thirteen
+ \c_fourteen
+ \c_fifteen
+ }
+\cs_new_eq:NN \c_ior_streams_tl \c_iow_streams_tl
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\g_iow_streams_prop}
+%\begin{macro}{\g_ior_streams_prop}
+% The allocations for streams are stored in property lists, which
+% are set up to have a 'full' set of allocations from the start.
+% In package mode, a few slots are always taken, so these are
+% blocked off from use.
+% \begin{macrocode}
+\prop_new:N \g_iow_streams_prop
+\prop_new:N \g_ior_streams_prop
+%</initex|package>
+%<*package>
+\prop_put:Nnn \g_iow_streams_prop { 0 } { LaTeX2e~reserved }
+\prop_put:Nnn \g_iow_streams_prop { 1 } { LaTeX2e~reserved }
+\prop_put:Nnn \g_iow_streams_prop { 2 } { LaTeX2e~reserved }
+\prop_put:Nnn \g_ior_streams_prop { 0 } { LaTeX2e~reserved }
+%</package>
+%<*initex|package>
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
%
-% This section is primarily concerned with input and output streams.
-% The naming conventions for i/o streams is |ior| (for read) and |iow|
-% (for write) as module names. e.g.\ |\c_ior_test_stream| is an input stream
-% variable called `test'.
-%
-% \subsection{Output streams}
-%
-% \begin{macro}{\iow_new:N,\iow_new:c}
-% Allocation of new output streams is done by these functions.
-% As we currently do not distribute a new allocation module we nick
-% the |\newwrite| function.
+%\begin{macro}{\l_iow_stream_int}
+%\begin{macro}{\l_ior_stream_int}
+% Used to track the number allocated to the stream being created:
+% this is taken from the property list but does alter.
% \begin{macrocode}
+\int_new:N \l_iow_stream_int
+\cs_new_eq:NN \l_ior_stream_int \l_iow_stream_int
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%\subsection{Stream management}
+%
+%\begin{macro}{\iow_raw_new:N}
+%\begin{macro}{\ior_raw_new:N}
+% The lowest level for stream management is actually creating raw \TeX\
+% streams. As these are very limited (even with \eTeX) this should not
+% be addressed directly.
+% \begin{macrocode}
+%</initex|package>
%<*initex>
-\alloc_setup_type:nnn {iow} \c_zero \c_sixteen
-\cs_new_nopar:Npn \iow_new:N #1 {\alloc_reg:NnNN g {iow} \tex_chardef:D #1}
+\alloc_setup_type:nnn { iow } \c_zero \c_sixteen
+\cs_new_protected_nopar:Npn \iow_raw_new:N #1 {
+ \alloc_reg:NnNN g { iow } \tex_chardef:D #1
+}
+\alloc_setup_type:nnn { ior } \c_zero \c_sixteen
+\cs_new_protected_nopar:Npn \ior_raw_new:N #1 {
+ \alloc_reg:NnNN g { ior } \tex_chardef:D #1
+}
%</initex>
%<*package>
-\cs_set_eq:NN \iow_new:N \newwrite
+\cs_set_eq:NN \iow_raw_new:N \newwrite
+\cs_set_eq:NN \ior_raw_new:N \newread
%</package>
-\cs_generate_variant:Nn \iow_new:N {c}
+%<*initex|package>
+\cs_generate_variant:Nn \iow_raw_new:N { c }
+\cs_generate_variant:Nn \ior_raw_new:N { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_new:N}
+%\begin{macro}{\iow_new:c}
+%\begin{macro}{\ior_new:N}
+%\begin{macro}{\ior_new:c}
+% These are not needed but are included for consistency with other
+% variable types.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \iow_new:N #1 {
+ \cs_gnew_eq:NN #1 \c_iow_log_stream
+}
+\cs_generate_variant:Nn \iow_new:N { c }
+\cs_new_protected_nopar:Npn \ior_new:N #1 {
+ \cs_gnew_eq:NN #1 \c_ior_log_stream
+}
+\cs_generate_variant:Nn \ior_new:N { c }
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\iow_open:Nn,\iow_open:cn}
-% To open streams for reading or writing the following two functions
-% are provided. The streams are opened immediately.
-%
-% From some bad experiences on the mainframe, I learned that it is
-% better to force the close before opening a dataset for writing.
-% We have to check whether this is also necessary in case of
-% |\tex_openin:D|.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_open:Nn}
+%\begin{macro}{\iow_open:cn}
+%\begin{macro}{\ior_open:Nn}
+%\begin{macro}{\ior_open:cn}
+% In both cases, opening a stream starts with a call to the closing
+% function: this is safest. There is then a loop through the
+% allocation number list to find the first free stream number.
+% When one is found the allocation can take place, the information
+% can be stored and finally the file can actually be opened.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_open:Nn #1#2 {
+\cs_new_protected_nopar:Npn \iow_open:Nn #1#2 {
\iow_close:N #1
- \tex_immediate:D \tex_openout:D #1#2 \scan_stop:
+ \int_set:Nn \l_iow_stream_int { \c_sixteen }
+ \tl_map_function:NN \c_iow_streams_tl \iow_alloc_write:n
+ \intexpr_compare:nTF { \l_iow_stream_int = \c_sixteen }
+ { \msg_kernel_error:nn { iow } { streams-exhausted } }
+ {
+ \iow_stream_alloc:N #1
+ \prop_gput:NVn \g_iow_streams_prop \l_iow_stream_int {#2}
+ \tex_immediate:D \tex_openout:D #1#2 \scan_stop:
+ }
}
-\cs_generate_variant:Nn \iow_open:Nn {c}
+\cs_generate_variant:Nn \iow_open:Nn { c }
+\cs_new_protected_nopar:Npn \ior_open:Nn #1#2 {
+ \ior_close:N #1
+ \int_set:Nn \l_ior_stream_int { \c_sixteen }
+ \tl_map_function:NN \c_ior_streams_tl \ior_alloc_read:n
+ \intexpr_compare:nTF { \l_ior_stream_int = \c_sixteen }
+ { \msg_kernel_error:nn { ior } { streams-exhausted } }
+ {
+ \ior_stream_alloc:N #1
+ \prop_gput:NVn \g_ior_streams_prop \l_ior_stream_int {#2}
+ \tex_openin:D #1#2 \scan_stop:
+ }
+}
+\cs_generate_variant:Nn \ior_open:Nn { c }
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\iow_close:N}
-% Since we close output streams prior to opening, a separate closing
-% operation is probably not necessary. But here it is, just in
-% case\ldots. Actually you will need this if you intend to write
-% and then read in the same pass from a stream.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}[aux]{\iow_alloc_write:n}
+%\begin{macro}[aux]{\ior_alloc_read:n}
+% These functions are used to see if a particular stream is available.
+% The property list contains file names for streams in use, so
+% any unused ones are for the taking.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_close:N { \tex_immediate:D \tex_closeout:D }
+\cs_new_protected_nopar:Npn \iow_alloc_write:n #1 {
+ \prop_if_in:NnF \g_iow_streams_prop {#1}
+ {
+ \int_set:Nn \l_iow_stream_int {#1}
+ \tl_map_break:
+ }
+}
+\cs_new_protected_nopar:Npn \ior_alloc_read:n #1 {
+ \prop_if_in:NnF \g_iow_streams_prop {#1}
+ {
+ \int_set:Nn \l_ior_stream_int {#1}
+ \tl_map_break:
+ }
+}
% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\c_iow_term_stream,\c_ior_term_stream}
-% \begin{macro}{\c_iow_log_stream,\c_ior_log_stream}
-% Here we allocate two output streams for writing to the transcript
-% file only (|\c_iow_log_stream|) and to both the terminal and transcript
-% file (|\c_iow_term_stream|). Both can be used to read from and have
-% equivalent "\c_ior" versions.
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}[aux]{\iow_stream_alloc:N}
+%\begin{macro}[aux]{\ior_stream_alloc:N}
+%\begin{macro}[aux]{\iow_stream_alloc_aux:}
+%\begin{macro}[aux]{\ior_stream_alloc_aux:}
+%\begin{macro}[aux]{\g_iow_tmp_stream}
+%\begin{macro}[aux]{\g_ior_tmp_stream}
+% Allocating a raw stream is much easier in initex mode than for
+% the package. For the format, all streams will be allocated by
+% \pkg{l3io} and so there is a simple check to see if a raw
+% stream is actually available. On the other hand, for the
+% package there will be non-managed streams. So if the managed
+% one is not open, a check is made to see if some other managed
+% stream is available before deciding to open a new one. If a new
+% one is needed, we get the number allocated by \LaTeXe\ to get
+% `back on track' with allocation.
% \begin{macrocode}
-\cs_new_eq:NN \c_iow_term_stream \c_sixteen
-\cs_new_eq:NN \c_ior_term_stream \c_sixteen
-\cs_new_eq:NN \c_iow_log_stream \c_minus_one
-\cs_new_eq:NN \c_ior_log_stream \c_minus_one
+\cs_new_protected_nopar:Npn \iow_stream_alloc:N #1 {
+ \cs_if_exist:cTF { g_iow_ \int_use:N \l_iow_stream_int _stream }
+ { \cs_gset_eq:Nc #1 { g_iow_ \int_use:N \l_iow_stream_int _stream } }
+ {
+%</initex|package>
+%<*package>
+ \iow_stream_alloc_aux:
+ \intexpr_compare:nT { \l_iow_stream_int = \c_sixteen }
+ {
+ \iow_raw_new:N \g_iow_tmp_stream
+ \int_set:Nn \l_iow_stream_int { \g_iow_tmp_stream }
+ \cs_gset_eq:cN
+ { g_iow_ \int_use:N \l_iow_stream_int _stream }
+ \g_iow_tmp_stream
+ }
+%</package>
+%<*initex>
+ \iow_raw_new:c { g_iow_ \int_use:N \l_iow_stream_int _stream }
+%</initex>
+%<*initex|package>
+ \cs_gset_eq:Nc #1 { g_iow_ \int_use:N \l_iow_stream_int _stream }
+ }
+}
+%</initex|package>
+%<*package>
+\cs_new_protected_nopar:Npn \iow_stream_alloc_aux: {
+ \int_incr:N \l_iow_stream_int
+ \intexpr_compare:nT
+ { \l_iow_stream_int < \c_sixteen }
+ {
+ \cs_if_exist:cTF { g_iow_ \int_use:N \l_iow_stream_int _stream }
+ {
+ \prop_if_in:NVT \g_iow_streams_prop \l_iow_stream_int
+ { \iow_stream_alloc_aux: }
+ }
+ { \iow_stream_alloc_aux: }
+ }
+}
+%</package>
+%<*initex|package>
+\cs_new_protected_nopar:Npn \ior_stream_alloc:N #1 {
+ \cs_if_exist:cTF { g_ior_ \int_use:N \l_ior_stream_int _stream }
+ { \cs_gset_eq:Nc #1 { g_ior_ \int_use:N \l_ior_stream_int _stream } }
+ {
+%</initex|package>
+%<*package>
+ \ior_stream_alloc_aux:
+ \intexpr_compare:nT { \l_ior_stream_int = \c_sixteen }
+ {
+ \ior_raw_new:N \g_ior_tmp_stream
+ \int_set:Nn \l_ior_stream_int { \g_ior_tmp_stream }
+ \cs_gset_eq:cN
+ { g_ior_ \int_use:N \l_iow_stream_int _stream }
+ \g_ior_tmp_stream
+ }
+%</package>
+%<*initex>
+ \ior_raw_new:c { g_ior_ \int_use:N \l_ior_stream_int _stream }
+%</initex>
+%<*initex|package>
+ \cs_gset_eq:Nc #1 { g_ior_ \int_use:N \l_ior_stream_int _stream }
+ }
+}
+%</initex|package>
+%<*package>
+\cs_new_protected_nopar:Npn \ior_stream_alloc_aux: {
+ \int_incr:N \l_ior_stream_int
+ \intexpr_compare:nT
+ { \l_ior_stream_int < \c_sixteen }
+ {
+ \cs_if_exist:cTF { g_ior_ \int_use:N \l_ior_stream_int _stream }
+ {
+ \prop_if_in:NVT \g_ior_streams_prop \l_ior_stream_int
+ { \ior_stream_alloc_aux: }
+ }
+ { \ior_stream_alloc_aux: }
+ }
+}
+%</package>
+%<*initex|package>
% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \paragraph{Immediate writing}
-%
-% \begin{macro}{\iow_now:Nx}
-% An abbreviation for an often used operation, which immediately
-% writes its second argument expanded to the output stream.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_close:N}
+%\begin{macro}{\iow_close:c}
+%\begin{macro}{\iow_close:N}
+%\begin{macro}{\iow_close:c}
+% Closing a stream is not quite the reverse of opening one. First,
+% the close operation is easier than the open one, and second as the
+% stream is actually a number we can use it directly to show that the
+% slot has been freed up.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_now:Nx { \tex_immediate:D \iow_shipout_x:Nn }
+\cs_new_protected_nopar:Npn \iow_close:N #1 {
+ \cs_if_exist:NT #1
+ {
+ \intexpr_compare:nF { #1 = \c_minus_one }
+ {
+ \tex_immediate:D \tex_closeout:D #1
+ \prop_gdel:NV \g_iow_streams_prop #1
+ \cs_gundefine:N #1
+ }
+ }
+}
+\cs_generate_variant:Nn \iow_close:N { c }
+\cs_new_protected_nopar:Npn \ior_close:N #1 {
+ \cs_if_exist:NT #1
+ {
+ \intexpr_compare:nF { #1 = \c_minus_one }
+ {
+ \tex_closeout:D #1
+ \prop_gdel:NV \g_ior_streams_prop #1
+ \cs_gundefine:N #1
+ }
+ }
+}
+\cs_generate_variant:Nn \ior_close:N { c }
% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\iow_now:Nn}
-% This routine writes the second argument onto the output
-% stream without expansion. If this stream isn't open, the output goes to
-% the terminal instead.
-% If the first argument is no output stream at all, we get an
-% internal error.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_open_streams:}
+%\begin{macro}{\ior_open_streams:}
+% Simply show the property lists.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_now:Nn #1#2 {
- \iow_now:Nx #1 { \exp_not:n {#2} }
+\cs_new_protected_nopar:Npn \iow_open_streams: {
+ \prop_display:N \g_iow_streams_prop
+}
+\cs_new_protected_nopar:Npn \ior_open_streams: {
+ \prop_display:N \g_ior_streams_prop
}
% \end{macrocode}
-% \end{macro}
+%\end{macro}
+%\end{macro}
%
-%
-% \begin{macro}{\iow_log:n,\iow_log:x,\iow_term:n,\iow_term:x}
-% Now we redefine two functions for which we needed a definition
-% very early on.
+% Text for the error messages.
% \begin{macrocode}
-\cs_set_nopar:Npn \iow_log:x { \iow_now:Nx \c_iow_log_stream }
-\cs_new_nopar:Npn \iow_log:n { \iow_now:Nn \c_iow_log_stream }
-\cs_set_nopar:Npn \iow_term:x { \iow_now:Nx \c_iow_term_stream }
-\cs_new_nopar:Npn \iow_term:n { \iow_now:Nn \c_iow_term_stream }
+\msg_kernel_new:nnnn { iow } { streams-exhausted }
+ {Output streams exhausted}
+ {%
+ TeX can only open up to 16 output streams at one time.\\%
+ All 16 are currently in use, and something wanted to open
+ another one.%
+ }
+\msg_kernel_new:nnnn { ior } { streams-exhausted }
+ {Input streams exhausted}
+ {%
+ TeX can only open up to 16 input streams at one time.\\%
+ All 16 are currently in use, and something wanted to open
+ another one.%
+ }
% \end{macrocode}
-% "\iow_term:x" isn't exactly equivalent to the old |\typeout| since
-% we need to control expansion in the function we provide for the user.
-% \end{macro}
-%
-%
-% \begin{macro}{\iow_now_when_avail:Nn,\iow_now_when_avail:cn}
-% |\iow_now_when_avail:Nn | \m{stream} \m{code}. This routine writes
-% its second argument unexpanded to the stream given by the first
-% argument, provided that this stream was opened for writing. Note,
-% that |#| characters get doubled within \m{code}.
+%
+%\subsection{Immediate writing}
%
-% In this routine we have to check whether or not the output stream
-% that was requested is defined at all.
-% So we check if the name is still free.
+%\begin{macro}{\iow_now:Nx}
+% An abbreviation for an often used operation, which immediately
+% writes its second argument expanded to the output stream.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \iow_now:Nx { \tex_immediate:D \iow_shipout_x:Nn }
+% \end{macrocode}
+%\end{macro}
%
+%\begin{macro}{\iow_now:Nn}
+% This routine writes the second argument onto the output stream without
+% expansion. If this stream isn't open, the output goes to the terminal
+% instead. If the first argument is no output stream at all, we get an
+% internal error.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_now_when_avail:Nn #1 {
- \cs_if_free:NTF #1 {\use_none:n} {\iow_now:Nn #1}
+\cs_new_protected_nopar:Npn \iow_now:Nn #1#2 {
+ \iow_now:Nx #1 { \exp_not:n {#2} }
}
-\cs_generate_variant:Nn \iow_now_when_avail:Nn {c}
% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\iow_now_buffer_safe:Nn,\iow_now_buffer_safe:Nx}
-% \begin{macro}[aux]{\iow_now_buffer_safe_expanded_aux:w}
-% Another type of writing onto an output stream is used for
-% potentially long token sequences. We break the output lines at
-% every blank in the second argument. This avoids the problem of
-% buffer overflow when reading back, or badly broken lines on
-% systems with limited file records. The only thing we have to
-% take care of, is the danger of two blanks in succession since
-% these get converted into a |\par| when we read the stuff back.
-% But this can happen only if things like
-% two spaces find their way into the second argument.
-% Usually, multiple spaces are removed by \TeX's scanner.
+%\end{macro}
+%
+%\begin{macro}{\iow_log:n}
+%\begin{macro}{\iow_log:x}
+%\begin{macro}{\iow_term:n}
+%\begin{macro}{\iow_term:x}
+% Now we redefine two functions for which we needed a definition
+% very early on.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_now_buffer_safe_aux:w #1#2#3 {
- \group_begin: \tex_newlinechar:D`\ #1#2{#3} \group_end:
+\cs_set_protected_nopar:Npn \iow_log:x { \iow_now:Nx \c_iow_log_stream }
+\cs_new_protected_nopar:Npn \iow_log:n { \iow_now:Nn \c_iow_log_stream }
+\cs_set_protected_nopar:Npn \iow_term:x { \iow_now:Nx \c_iow_term_stream }
+\cs_new_protected_nopar:Npn \iow_term:n { \iow_now:Nn \c_iow_term_stream }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_now_when_avail:Nn}
+%\begin{macro}{\iow_now_when_avail:cn}
+%\begin{macro}{\iow_now_when_avail:Nx}
+%\begin{macro}{\iow_now_when_avail:cx}
+% For writing only if the stream requested is open at all.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \iow_now_when_avail:Nn #1 {
+ \cs_if_free:NTF #1 { \use_none:n } { \iow_now:Nn #1 }
+}
+\cs_generate_variant:Nn \iow_now_when_avail:Nn { c }
+\cs_new_protected_nopar:Npn \iow_now_when_avail:Nx #1 {
+ \cs_if_free:NTF #1 { \use_none:n } { \iow_now:Nx #1 }
}
-\cs_new_nopar:Npn \iow_now_buffer_safe:Nx {
+\cs_generate_variant:Nn \iow_now_when_avail:Nx { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\iow_now_buffer_safe:Nn}
+%\begin{macro}{\iow_now_buffer_safe:Nx}
+%\begin{macro}[aux]{\iow_now_buffer_safe_expanded_aux:w}
+% Another type of writing onto an output stream is used for
+% potentially long token sequences. We break the output lines at
+% every blank in the second argument. This avoids the problem of
+% buffer overflow when reading back, or badly broken lines on
+% systems with limited file records. The only thing we have to
+% take care of, is the danger of two blanks in succession since
+% these get converted into a \cs{par} when we read the stuff back.
+% But this can happen only if things like two spaces find their way
+% into the second argument. Usually, multiple spaces are removed by
+% \TeX's scanner.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \iow_now_buffer_safe:Nn {
\iow_now_buffer_safe_aux:w \iow_now:Nx
}
-\cs_new_nopar:Npn \iow_now_buffer_safe:Nn {
+\cs_new_protected_nopar:Npn \iow_now_buffer_safe:Nx {
\iow_now_buffer_safe_aux:w \iow_now:Nn
}
+\cs_new_protected_nopar:Npn \iow_now_buffer_safe_aux:w #1#2#3 {
+ \group_begin: \tex_newlinechar:D`\ #1#2 {#3} \group_end:
+}
% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-%
-% \paragraph{Deferred writing}
-%
-% \begin{macro}{\iow_shipout_x:Nn,\iow_shipout_x:Nx}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\subsection{Deferred writing}
+%
+%\begin{macro}{\iow_shipout_x:Nn}
+%\begin{macro}{\iow_shipout_x:Nx}
% First the easy part, this is the primitive.
% \begin{macrocode}
\cs_set_eq:NN \iow_shipout_x:Nn \tex_write:D
-\cs_generate_variant:Nn \iow_shipout_x:Nn {Nx}
+\cs_generate_variant:Nn \iow_shipout_x:Nn {Nx }
% \end{macrocode}
-% \end{macro}
+%\end{macro}
+%\end{macro}
%
-% \begin{macro}{\iow_shipout:Nn,\iow_shipout:Nx}
+%\begin{macro}{\iow_shipout:Nn}
+%\begin{macro}{\iow_shipout:Nx}
% With \eTeX\ available deferred writing is easy.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_shipout:Nn #1#2{
+\cs_new_protected_nopar:Npn \iow_shipout:Nn #1#2 {
\iow_shipout_x:Nn #1 { \exp_not:n {#2} }
}
-\cs_generate_variant:Nn \iow_shipout:Nn {Nx}
+\cs_generate_variant:Nn \iow_shipout:Nn { Nx }
% \end{macrocode}
-% \end{macro}
-%
-% `Buffer safe' forms of these functions are not possible since the deferred
-% writing will restore the value of |\tex_newlinechar:D| before it will have
-% a chance to act. But on the other hand it is nevertheless possible
-% to make all deferred writes long by setting the |\tex_newlinechar:D|
-% inside the output routine just before the |\tex_shipout:D|. The only
-% disadvantage of this method is the fact that messages to the
-% terminal during this time will also then break at spaces. But we
-% should consider this.
+%\end{macro}
+%\end{macro}
%
-% \paragraph{Special characters for writing}
+%\section{Special characters for writing}
%
-% \begin{macro}{\iow_newline:}
-% Global variable holding the character that forces a new line when
-% something is written to an output stream.
+%\begin{macro}{\iow_newline:}
+% Global variable holding the character that forces a new line when
+% something is written to an output stream.
% \begin{macrocode}
-\cs_new_nopar:Npn \iow_newline: {^^J}
+\cs_new_nopar:Npn \iow_newline: { ^^J }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\iow_space:}
-% Global variable holding the character that inserts a space char when
-% writing to an output stream.
-% \begin{macrocode}
-\cs_new_nopar:Npn \iow_space: {~}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\iow_char:N}
+%\begin{macro}{\iow_char:N}
% Function to write any escaped char to an output stream.
% \begin{macrocode}
\cs_new:Npn \iow_char:N #1 { \cs_to_str:N #1 }
% \end{macrocode}
-% \end{macro}
+%\end{macro}
%
+%\subsection{Reading input}
%
-% \begin{macro}{\c_iow_comment_char}
-% \begin{macro}{\c_iow_lbrace_char}
-% \begin{macro}{\c_iow_rbrace_char}
-% TODO: remove these in favour of "\iow_char:N" (Will, Apr 2009)
-%
-% We also need to be able to write braces and the comment character. We
-% achieve this by defining global constants to expand into a version of
-% these characters with |\tex_catcode:D|${}=12$.
-% \begin{macrocode}
-\tl_new:Nx \c_iow_comment_char {\cs_to_str:N\%}
-% \end{macrocode}
-% To avoid another allocation function which is probably only
-% necessary here we use the |\cs_set_nopar:Npx| command directly.
-% \begin{macrocode}
-\tl_new:Nx \c_iow_lbrace_char{\cs_to_str:N\{}
-\tl_new:Nx \c_iow_rbrace_char{\cs_to_str:N\}}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
-% \subsection{Input streams}
-%
-% \begin{macro}{\ior_new:N}
-% Allocation of new input streams is done by this function.
-% As we currently do not distribute a new allocation module we nick
-% the |\newwread| function.
-% \begin{macrocode}
-%<*initex>
-\alloc_setup_type:nnn {ior} \c_zero \c_sixteen
-\cs_new_nopar:Npn \ior_new:N #1 {\alloc_reg:NnNN g {ior} \tex_chardef:D #1}
-%</initex>
-%<package>\cs_set_eq:NN \ior_new:N \newread
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\ior_open:Nn}
-% \begin{macro}{\ior_close:N}
-% Processing of input-streams (via |\tex_openin:D| and |closein|) is
-% always `immediate' as far as \TeX{} is concerned. An extra
-% |\tex_immediate:D| is silently ignored.
-% \begin{macrocode}
-\cs_set_eq:NN \ior_close:N \tex_closein:D
-\cs_new_nopar:Npn \ior_open:Nn #1#2 {
- \ior_close:N #1 \scan_stop:
- \tex_openin:D #1#2 \scan_stop:
-}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-%
-% \begin{macro}{\if_eof:w}
+%\begin{macro}{\if_eof:w}
+% A simple primitive renaming.
% \begin{macrocode}
\cs_new_eq:NN \if_eof:w \tex_ifeof:D
% \end{macrocode}
-% \end{macro}
-%
+%\end{macro}
%
-% \begin{macro}{\ior_if_eof_p:N}
-% \begin{macro}[TF]{\ior_if_eof:N}
-% |\ior_if_eof:NTF | \m{stream} \m{true case} \m{false case}. To
-% test if some particular input stream is exhausted the following
-% conditional is provided:
+%\begin{macro}{\ior_if_eof_p:N}
+%\begin{macro}[TF]{\ior_if_eof:N}
+% To test if some particular input stream is exhausted the following
+% conditional is provided. As the pool model means that closed
+% streams are undefined control sequences, the test has two parts.
% \begin{macrocode}
-\prg_new_conditional:Nnn \ior_if_eof:N {p,TF,T,F} {
- \tex_ifeof:D #1 \prg_return_true: \else: \prg_return_false: \fi:
+\prg_new_conditional:Nnn \ior_if_eof:N { p , TF , T , F } {
+ \cs_if_exist:NTF #1
+ { \tex_ifeof:D #1 \prg_return_true: \else: \prg_return_false: \fi: }
+ { \prg_return_true: }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
-%
-%
-%
-% \begin{macro}{\ior_to:NN}
-% \begin{macro}{\ior_gto:NN}
-% And here we read from files.
+%
+%\begin{macro}{\ior_to:NN}
+%\begin{macro}{\ior_gto:NN}
+% And here we read from files.
% \begin{macrocode}
-\cs_new_nopar:Npn \ior_to:NN #1#2 {
+\cs_new_protected_nopar:Npn \ior_to:NN #1#2 {
\tex_read:D #1 to #2
-%<check> \chk_local_or_pref_global:N #2
}
-\cs_new_nopar:Npn \ior_gto:NN {
-%<+check> \pref_global_chk:
-%<-check> \pref_global:D
- \ior_to:NN
+\cs_new_protected_nopar:Npn \ior_gto:NN {
+ \pref_global:D \ior_to:NN
}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macrocode}
%</initex|package>
% \end{macrocode}
-%
-% Show token usage:
-% \begin{macrocode}
-%<*showmemory>
-\showMemUsage
-%</showmemory>
-% \end{macrocode}
-%
-% \end{implementation}
-% \PrintIndex
-%
-% \endinput
+%\end{macro}
+%\end{macro}
+%
+% \end{implementation} \ No newline at end of file
diff --git a/Master/texmf-dist/source/latex/expl3/l3keys.dtx b/Master/texmf-dist/source/latex/expl3/l3keys.dtx
index e67d54223de..5cea3f4d1e5 100644
--- a/Master/texmf-dist/source/latex/expl3/l3keys.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3keys.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3keys.dtx Copyright (C) 2009 LaTeX3 project
+%% File: l3keys.dtx Copyright (C) 2009-2010 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
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3keys.dtx 1766 2010-01-12 08:59:24Z joseph $
+\GetIdInfo$Id: l3keys.dtx 1863 2010-03-22 20:15:06Z joseph $
{L3 Experimental key-value support}
%\iffalse
%<*driver>
@@ -91,8 +91,8 @@
% \emph{properties} of the key:
%\begin{verbatim}
% \keys_define:nn { module }
-% key-one .code:n = code including parameter #1,
-% key-two .set = \l_module_store_tl
+% key-one .code:n = code including parameter #1,
+% key-two .tl_set:N = \l_module_store_tl
% }
%\end{verbatim}
% These values can then be set as with other key--value approaches:
@@ -136,7 +136,7 @@
% Key names may contain any tokens, as they are handled internally
% using \cs{tl_to_str:n}. As will be discussed in
% section~\ref{sec:subdivision}, it is suggested that the character
-% ``\texttt{/}'' is reserved for sub-division of keys into logical
+% `\texttt{/}' is reserved for sub-division of keys into logical
% groups. Macros are \emph{not} expanded when creating key names,
% and so
%\begin{verbatim}
@@ -148,23 +148,38 @@
% will create a key called \cs{l_module_tmp_tl}, and not one called
% \texttt{key}.
%
-%\subsection{Creating keys}
+%\section{Creating keys}
%
%\begin{function}{\keys_define:nn}
% \begin{syntax}
% "\keys_define:nn" \Arg{module} \Arg{keyval list}
% \end{syntax}
% Parses the <keyval list> and defines the keys listed there for
-% <module>. This function is designed for use in code, and therefore
-% does not check the category codes of characters or ignore spaces.
+% <module>. The <module> name should be a text value, but there are
+% no restrictions on the nature of the text. In practice the
+% <module> should be chosen to be unique to the module in question
+% (unless deliberately adding keys to an existing module).
+%
+% The <keyval list> should consist of one or more key names along
+% with an associated key \emph{property}. The properties of a key
+% determine how it acts. The individual properties are described
+% in the following text; a typical use of \cs{keys_define:nn} might
+% read
+% \begin{verbatim}
+% \keys_define:nn { mymodule } {
+% keyname .code:n = Some~code~using~#1,
+% keyname .value_required:
+% }
+% \end{verbatim}
+% where the properties of the key begin from the \texttt{.} after
+% the key name.
+%
+% The \cs{keys_define:nn} function does not skip spaces in the
+% input, and does not check the category codes for \texttt{,} and
+% \texttt{=} tokens. This means that it is intended for use with
+% code blocks and other environments where spaces are ignored.
%\end{function}
%
-% Setting up and altering keys is carried out using one or more
-% properties. The properties determine how a key acts, and may require
-% zero, one or two argument: this is indicated by an argument specifier,
-% in the same way as a standard \LaTeX3 function.
-%
-%
%\begin{function}{
% .bool_set:N |
% .bool_gset:N
@@ -173,15 +188,19 @@
% <key> .bool_set:N = <bool>
% \end{syntax}
% Defines <key> to set <bool> to <value> (which must be either
-% \texttt{true} or \texttt{false}).
+% \texttt{true} or \texttt{false}). Here, <bool> is a \LaTeX3
+% boolean variable (\emph{i.e}.~created using \cs{bool_new:N}).
+% If the variable does not exist, it will be created at the point
+% that the key is set up.
%\end{function}
%
%\begin{function}{.choice:}
% \begin{syntax}
% <key> .choice:
% \end{syntax}
-% Sets <key> to act as a multiple choice key. Creating choices
-% is discussed in section~\ref{sec:choice}.
+% Sets <key> to act as a multiple choice key. Each valid choice
+% for <key> must then be created, as discussed in
+% section~\ref{sec:choice}.
%\end{function}
%
%\begin{function}{
@@ -191,28 +210,30 @@
% \begin{syntax}
% <key> .choice_code:n = <code>
% \end{syntax}
-% Stores <code> for use when |.generate_choices:n| creates one or more
-% choice sub-keys of the current key. Inside <code>,
+% Stores <code> for use when \texttt{.generate_choices:n} creates one
+% or more choice sub-keys of the current key. Inside <code>,
% \cs{l_keys_choice_tl} contains the name of the choice made, and
% \cs{l_keys_choice_int} is the position of the choice in the list
-% given to |.generate_choices:n|.
+% given to \texttt{.generate_choices:n}. Choices are discussed in
+% detail in section~\ref{sec:choice}.
%\end{function}
%
%\begin{function}{
-% .code:n|
+% .code:n |
% .code:x
% }
% \begin{syntax}
% <key> .code:n = <code>
% \end{syntax}
% Stores the <code> for execution when <key> is called. The <code> can
-% include one parameter (|#1|), which will be the <value> given for the
-% <key>.
+% include one parameter ("#1"), which will be the <value> given for the
+% <key>. The \texttt{.code:x} variant will expand <code> at the point
+% where the <key> is created.
%\end{function}
%
%\begin{function}{
-% .default:n|
-% .default:V|
+% .default:n |
+% .default:V
% }
% \begin{syntax}
% <key> .default:n = <default>
@@ -226,13 +247,14 @@
% key .default:n = World
% }
% \keys_set:nn { module} {
-% key = Fred, % Prints "Hello Fred"
-% key, % Prints "Hello World"
-% key = , % Prints "Hello "
+% key = Fred, % Prints 'Hello Fred'
+% key, % Prints 'Hello World'
+% key = , % Prints 'Hello '
% }
% \end{verbatim}
% \begin{texnote}
-% The <default> is stored as a token list variable.
+% The <default> is stored as a token list variable, and therefore
+% should not contain unescaped "#" tokens.
% \end{texnote}
%\end{function}
%
@@ -245,8 +267,12 @@
% \begin{syntax}
% <key> .dim_set:N = <dimension>
% \end{syntax}
-% Sets <key> to store the value it is given in <dimension>,
-% which is created if it does not already exist.
+% Sets <key> to store the value it is given in <dimension>. Here,
+% <dimension> is a \LaTeX3 \texttt{dim} variable
+% (\emph{i.e}.~created using \cs{dim_new:N}) or a \LaTeXe\
+% \texttt{dimen} (\emph{i.e} created using \cs{newdimen}). If the
+% variable does not exist, it will be created at the point that the
+% key is set up.
%\end{function}
%
%\begin{function}{.generate_choices:n}
@@ -255,8 +281,9 @@
% \end{syntax}
% Makes <key> a multiple choice key, accepting the choices specified
% in <comma list>. Each choice will execute code which should
-% previously have been defined using |.choice_code:n| or
-% |.choice_code:x|.
+% previously have been defined using \texttt{.choice_code:n} or
+% \texttt{.choice_code:x}. Choices are discussed in detail in
+% section~\ref{sec:choice}.
%\end{function}
%
%\begin{function}{
@@ -268,20 +295,25 @@
% \begin{syntax}
% <key> .int_set:N = <integer>
% \end{syntax}
-% Sets <key> to store the value it is given in <integer>,
-% which is created if it does not already exist.
+% Sets <key> to store the value it is given in <integer>. Here,
+% <integer> is a \LaTeX3 \texttt{int} variable
+% (\emph{i.e}.~created using \cs{int_new:N}) or a \LaTeXe\
+% \texttt{count} (\emph{i.e} created using \cs{newcount}). If the
+% variable does not exist, it will be created at the point that the
+% key is set up.
%\end{function}
%
%\begin{function}{
-% .meta:n|
+% .meta:n |
% .meta:x
%}
% \begin{syntax}
-% <key> .meta:n = <keys>
+% <key> .meta:n = <multiple keys>
% \end{syntax}
-% Makes <key> a meta-key, which will set several other <keys> in
-% one go. If <key> is given with a value, it is passed through to
-% the subsidiary <keys> for processing.
+% Makes <key> a meta-key, which will set <multiple keys> in
+% one go. If <key> is given with a value at the time the key
+% is used, then the value will be passed through to the subsidiary
+% <keys> for processing (as "#1").
%\end{function}
%
%\begin{function}{
@@ -294,7 +326,12 @@
% <key> .skip_set:N = <skip>
% \end{syntax}
% Sets <key> to store the value it is given in <skip>, which is
-% created if it does not already exist.
+% created if it does not already exist. Here,
+% <skip> is a \LaTeX3 \texttt{skip} variable
+% (\emph{i.e}.~created using \cs{skip_new:N}) or a \LaTeXe\
+% \texttt{skip} (\emph{i.e} created using \cs{newskip}). If the
+% variable does not exist, it will be created at the point that the
+% key is set up.
%\end{function}
%
%\begin{function}{
@@ -311,22 +348,31 @@
% <key> .tl_set:N = <token list variable>
% \end{syntax}
% Sets <key> to store the value it is given in <token list variable>,
-% which is created if it does not already exist. The \texttt{x}
-% type properties perform an expansion as well as storing the value.
+% which is created if it does not already exist. Here,
+% <token list variable> is a \LaTeX3 \texttt{tl} variable
+% (\emph{i.e}.~created using \cs{tl_new:N}) or a \LaTeXe\
+% macro with no arguments (\emph{i.e}.~created using
+% \cs{newcommand} or \cs{def}). If the variable does not exist, it
+% will be created at the point that the key is set up. The \texttt{x}
+% variants perform an \texttt{x} expansion at the time the <value>
+% passed to the <key> is saved to the <token list variable>.
%\end{function}
%
%\begin{function}{
-% .value_forbidden:|
-% .value_required:|
+% .value_forbidden: |
+% .value_required: |
% }
% \begin{syntax}
% <key> .value_forbidden:
% \end{syntax}
-% Flags for forbidding and requiring a <value> for <key>. Any <value>
-% given will be ignored.
+% Flags for forbidding and requiring a <value> for <key>. Giving a
+% <value> for a <key> which has the \texttt{.value_forbidden:}
+% property set will result in an error. In the same way, if a <key> has
+% the \texttt{.value_required:} property set then a <value> must be
+% given when the <key> is used.
%\end{function}
%
-%\subsection{Sub-dividing keys}
+%\section{Sub-dividing keys}
%\label{sec:subdivision}
%
% When creating large numbers of keys, it may be desirable to divide
@@ -344,7 +390,7 @@
% }
%\end{verbatim}
% As illustrated, the best choice of token for sub-dividing keys in
-% this way is ``\texttt{/}''. This is because of the method that is
+% this way is `\texttt{/}'. This is because of the method that is
% used to represent keys internally. Both of the above code fragments
% set the same key, which has full name \texttt{module/subgroup/key}.
%
@@ -373,7 +419,7 @@
%\begin{verbatim}
% \keys_define:nn { module } {
% key .choice_code:n = {
-% You~gave~choice~``\l_keys_choice_tl'',~
+% You~gave~choice~``\int_use:N \l_keys_choice_tl'',~
% which~is~in~position~
% \int_use:N\l_keys_choice_int\space
% in~the~list.
@@ -383,18 +429,21 @@
% }
% }
%\end{verbatim}
-% Following common computing practice, \cs{l_keys_choice_int} starts
-% from $0$ for the first choice. This means that it can be used
-% directly with \cs{if_case:w} and so on.
+% Following common computing practice, \cs{l_keys_choice_int} is
+% indexed from \(0\) (as an offset), so that the value of
+% \cs{l_keys_choice_int} for the first choice in a list will be
+% zero. This means that \cs{l_keys_choice_int} can be used directly
+% with \cs{if_case:w} and so on.
%
%\begin{variable}{
-% \l_keys_choice_tl|
-% \l_keys_choice_int|
+% \l_keys_choice_int |
+% \l_keys_choice_tl
%}
-% Inside the code block, the variables \cs{l_keys_choice_tl} and
+% Inside the code block for a choice generated using
+% \texttt{.generate_choice:}, the variables \cs{l_keys_choice_tl} and
% \cs{l_keys_choice_int} are available to indicate the name of the
% current choice, and its position in the comma list. The position
-% is indexed from \(1\).
+% is indexed from \(0\).
%\end{variable}
%
% On the other hand, it is sometimes useful to create choices which
@@ -412,12 +461,15 @@
%
% It is possible to mix the two methods, but manually-created choices
% should \emph{not} use \cs{l_keys_choice_tl} or \cs{l_keys_choice_int}.
+% These variables do not have defined behaviour when used outside of
+% code created using \texttt{.generate_choices:n}
+% (\emph{i.e}.~anything might happen!).
%
-%\subsection{Setting keys}
+%\section{Setting keys}
%
%\begin{function}{
-% \keys_set:nn|
-% \keys_set:nV|
+% \keys_set:nn |
+% \keys_set:nV |
% \keys_set:nv
%}
% \begin{syntax}
@@ -437,7 +489,7 @@
%\begin{verbatim}
% \keys_define:nn { module } {
% unknown .code:n =
-% You~tried~to~set~key~`\l_keys_path_tl'~to~`#1'
+% You~tried~to~set~key~'\l_keys_path_tl'~to~'#1'
% }
%\end{verbatim}
%
@@ -445,7 +497,7 @@
% When processing an unknown key, the name of the key is available
% as \cs{l_keys_key_tl}. Note that this will have been processed
% using \cs{tl_to_str:N}. The value passed to the key (if any) is
-% available as the macro parameter |#1|.
+% available as the macro parameter "#1".
%\end{variable}
%
%\subsection{Examining keys: internal representation}
@@ -455,26 +507,34 @@
% "\keys_if_exist:nnTF" \Arg{module} \Arg{key} \Arg{true code}
% ~~~~\Arg{false code}
% \end{syntax}
-% Tests if <key> exists for <module>, by checking for the existence
-% of the internal function \cs{keys > <module>/<key>.cmd:n}.
+% Tests if <key> exists for <module>, \emph{i.e}.~if any code has
+% been defined for <key>.
+% \begin{texnote}
+% The function works by testing for the existence of the internal
+% function \cs{keys > <module>/<key>.cmd:n}.
+% \end{texnote}
%\end{function}
%
%\begin{function}{\keys_show:nn}
% \begin{syntax}
% "\keys_show:nn" \Arg{module} \Arg{key}
% \end{syntax}
-% Shows the internal representation of a <key>. The function which
-% executes a <key> is called \cs{keys > <module>/<key>.cmd:n}.
+% Shows the internal representation of a <key>.
+% \begin{texnote}
+% Keys are stored as functions with names of the format
+% \cs{keys > <module>/<key>.cmd:n}.
+% \end{texnote}
%\end{function}
%
-%\subsection{Internal functions}
+%\section{Internal functions}
%
%\begin{function}{\keys_bool_set:NN}
% \begin{syntax}
% "\keys_bool_set:NN" <bool> <scope>
% \end{syntax}
% Creates code to set <bool> when <key> is given, with setting using
-% <scope>.
+% <scope> (\texttt{l} or \texttt{g} for local or global,
+% respectively). <bool> should be a \LaTeX3 boolean variable.
%\end{function}
%
%\begin{function}{\keys_choice_code_store:x}
@@ -546,7 +606,8 @@
% \begin{syntax}
% "\keys_execute:"
% \end{syntax}
-% Executes <key>.
+% Executes <key> (where the name of the <key> will be stored
+% internally).
%\end{function}
%
%\begin{function}{\keys_execute_unknown:}
@@ -556,7 +617,7 @@
% Handles unknown <key> names.
%\end{function}
%
-%\begin{function}{\keys_if_value_requirement:nTF}
+%\begin{function}{\keys_if_value_requirement:nTF / (EXP)}
% \begin{syntax}
% "\keys_if_value_requirement:nTF" \Arg{requirement}
% ~~~~\Arg{true code} \Arg{false code}
@@ -565,7 +626,7 @@
%\end{function}
%
%\begin{function}{
-% \keys_meta_make:n|
+% \keys_meta_make:n |
% \keys_meta_make:x
%}
% \begin{syntax}
@@ -620,7 +681,7 @@
% \begin{syntax}
% "\keys_value_or_default:n" \Arg{value}
% \end{syntax}
-% Sets \cs{l_keys_value_toks} to <value>, or <default> if
+% Sets \cs{l_keys_value_tl} to <value>, or <default> if
% <value> was not given and if <default> is available.
%\end{function}
%
@@ -643,20 +704,22 @@
% \texttt{int}, etc.) are given explicitly.
%\end{function}
%
-%\subsection{Variables and constants}
+%\section{Variables and constants}
%
%\begin{variable}{
-% \c_keys_properties_root_tl|
+% \c_keys_properties_root_tl |
% \c_keys_root_tl
%}
-% The root paths for keys and properties.
+% The root paths for keys and properties, used to generate the
+% names of the functions which store these items.
%\end{variable}
%
%\begin{variable}{
-% \c_keys_value_forbidden_tl|
+% \c_keys_value_forbidden_tl |
% \c_keys_value_required_tl
%}
-% Marker text containers.
+% Marker text containers: by storing the values the code can make
+% comparisons slightly faster.
%\end{variable}
%
%\begin{variable}{\l_keys_choice_code_tl}
@@ -664,26 +727,21 @@
%\end{variable}
%
%\begin{variable}{
-% \l_keys_module_tl|
-% \l_keys_path_tl|
+% \l_keys_module_tl |
+% \l_keys_path_tl |
% \l_keys_property_tl
%}
-% Various key paths need to be stored.
-%\end{variable}
-%
-%\begin{variable}{
-% \l_keys_nesting_seq|
-% \l_keys_nesting_tl
-%}
-% To allow safe nesting of \cs{keys_define:nn} and \cs{keys_set:nn}.
+% Various key paths need to be stored. These are flexible items
+% that are set during the key reading process.
%\end{variable}
%
%\begin{variable}{\l_keys_no_value_bool}
-% A marker for ``no value'' as key input.
+% A marker for `no value' as key input.
%\end{variable}
%
-%\begin{variable}{\l_keys_value_toks}
-% Holds the currently supplied value.
+%\begin{variable}{\l_keys_value_tl}
+% Holds the currently supplied value, in a token register as
+% there may be "#" tokens.
%\end{variable}
%
%\end{documentation}
@@ -706,8 +764,8 @@
%\begin{macro}{\c_keys_properties_root_tl}
% Where the keys are really stored.
% \begin{macrocode}
-\tl_new:Nn \c_keys_root_tl { keys~>~ }
-\tl_new:Nn \c_keys_properties_root_tl { keys_properties }
+\tl_const:Nn \c_keys_root_tl { keys~>~ }
+\tl_const:Nn \c_keys_properties_root_tl { keys_properties }
% \end{macrocode}
%\end{macro}
%\end{macro}
@@ -716,8 +774,8 @@
%\begin{macro}{\c_keys_value_required_tl}
% Two marker token lists.
% \begin{macrocode}
-\tl_new:Nn \c_keys_value_forbidden_tl { forbidden }
-\tl_new:Nn \c_keys_value_required_tl { required }
+\tl_const:Nn \c_keys_value_forbidden_tl { forbidden }
+\tl_const:Nn \c_keys_value_required_tl { required }
% \end{macrocode}
%\end{macro}
%\end{macro}
@@ -760,16 +818,6 @@
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{\l_keys_nesting_seq}
-%\begin{macro}{\l_keys_nesting_tl}
-% For nesting.
-% \begin{macrocode}
-\seq_new:N \l_keys_nesting_seq
-\tl_new:Nn \l_keys_nesting_tl { none }
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
%\begin{macro}{\l_keys_no_value_bool}
% To indicate that no value has been given.
% \begin{macrocode}
@@ -777,10 +825,10 @@
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{\l_keys_value_toks}
-% A token register for the given value.
+%\begin{macro}{\l_keys_value_tl}
+% A token variable for the given value.
% \begin{macrocode}
-\toks_new:N \l_keys_value_toks
+\tl_new:N \l_keys_value_tl
% \end{macrocode}
%\end{macro}
%
@@ -789,7 +837,7 @@
%\begin{macro}{\keys_bool_set:NN}
% Boolean keys are really just choices, but all done by hand.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_bool_set:NN #1#2 {
+\cs_new_protected_nopar:Npn \keys_bool_set:NN #1#2 {
\keys_cmd_set:nx { \l_keys_path_tl / true } {
\exp_not:c { bool_ #2 set_true:N }
\exp_not:N #1
@@ -810,9 +858,9 @@
%
%\begin{macro}{\keys_choice_code_store:x}
% The code for making multiple choices is stored in a token list as there should
-% not be any |#| tokens.
+% not be any "#" tokens.
% \begin{macrocode}
-\cs_new:Npn \keys_choice_code_store:x #1 {
+\cs_new_protected:Npn \keys_choice_code_store:x #1 {
\tl_set:cx { \c_keys_root_tl \l_keys_path_tl .choice_code_tl } {#1}
}
% \end{macrocode}
@@ -823,7 +871,7 @@
% if that fails call the unknown key. That will exist, as it is created
% when a choice is first made. So there is no need for any escape code.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_choice_find:n #1 {
+\cs_new_protected_nopar:Npn \keys_choice_find:n #1 {
\keys_execute_aux:nn { \l_keys_path_tl / #1 } {
\keys_execute_aux:nn { \l_keys_path_tl / unknown } { }
}
@@ -835,7 +883,7 @@
% To make a choice from a key, two steps: set the code, and set the
% unknown key.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_choice_make: {
+\cs_new_protected_nopar:Npn \keys_choice_make: {
\keys_cmd_set:nn { \l_keys_path_tl } {
\keys_choice_find:n {##1}
}
@@ -852,7 +900,7 @@
% Creating multiple-choices means setting up the ``indicator'' code,
% then applying whatever the user wanted.
% \begin{macrocode}
-\cs_new:Npn \keys_choices_generate:n #1 {
+\cs_new_protected:Npn \keys_choices_generate:n #1 {
\keys_choice_make:
\int_zero:N \l_keys_choice_int
\cs_if_exist:cTF {
@@ -867,7 +915,7 @@
}
\clist_map_function:nN {#1} \keys_choices_generate_aux:n
}
-\cs_new_nopar:Npn \keys_choices_generate_aux:n #1 {
+\cs_new_protected_nopar:Npn \keys_choices_generate_aux:n #1 {
\keys_cmd_set:nx { \l_keys_path_tl / #1 } {
\exp_not:n { \tl_set:Nn \l_keys_choice_tl } {#1}
\exp_not:n { \int_set:Nn \l_keys_choice_int }
@@ -886,19 +934,21 @@
% Creating a new command means setting properties and then creating
% a function with the correct number of arguments.
% \begin{macrocode}
-\cs_new:Npn \keys_cmd_set:nn #1#2 {
+\cs_new_protected:Npn \keys_cmd_set:nn #1#2 {
\keys_cmd_set_aux:n {#1}
\cs_generate_from_arg_count:cNnn { \c_keys_root_tl #1 .cmd:n }
\cs_set:Npn 1 {#2}
}
-\cs_new:Npn \keys_cmd_set:nx #1#2 {
+\cs_new_protected:Npn \keys_cmd_set:nx #1#2 {
\keys_cmd_set_aux:n {#1}
\cs_generate_from_arg_count:cNnn { \c_keys_root_tl #1 .cmd:n }
\cs_set:Npx 1 {#2}
}
-\cs_new_nopar:Npn \keys_cmd_set_aux:n #1 {
+\cs_new_protected_nopar:Npn \keys_cmd_set_aux:n #1 {
\keys_property_undefine:n { #1 .default_tl }
- \tl_set:cn { \c_keys_root_tl #1 .req_tl } { }
+ \cs_if_free:cT { \c_keys_root_tl #1 .req_tl }
+ { \tl_new:c { \c_keys_root_tl #1 .req_tl } }
+ \tl_clear:c { \c_keys_root_tl #1 .req_tl }
}
% \end{macrocode}
%\end{macro}
@@ -909,7 +959,9 @@
%\begin{macro}{\keys_default_set:V}
% Setting a default value is easy.
% \begin{macrocode}
-\cs_new:Npn \keys_default_set:n #1 {
+\cs_new_protected:Npn \keys_default_set:n #1 {
+ \cs_if_free:cT { \c_keys_root_tl \l_keys_path_tl .default_tl }
+ { \tl_new:c { \c_keys_root_tl \l_keys_path_tl .default_tl } }
\tl_set:cn { \c_keys_root_tl \l_keys_path_tl .default_tl } {#1}
}
\cs_generate_variant:Nn \keys_default_set:n { V }
@@ -921,18 +973,10 @@
% The main key-defining function mainly sets up things for \pkg{l3keyval}
% to use.
% \begin{macrocode}
-\cs_new:Npn \keys_define:nn #1#2 {
+\cs_new_protected:Npn \keys_define:nn #1#2 {
\tl_set:Nn \l_keys_module_tl {#1}
- \cs_set_eq:NN \KV_key_no_value_elt:n \keys_define_elt:n
- \cs_set_eq:NN \KV_key_value_elt:nn \keys_define_elt:nn
- \seq_push:NV \l_keys_nesting_seq \l_keys_nesting_tl
- \tl_set:Nn \l_keys_nesting_tl { define }
- \KV_parse_no_space_removal_no_sanitize:n {#2}
- \seq_pop:NN \l_keys_nesting_seq \l_keys_nesting_tl
- \cs_set_eq:Nc \KV_key_no_value_elt:n
- { keys_ \l_keys_nesting_tl _elt:n }
- \cs_set_eq:Nc \KV_key_value_elt:nn
- { keys_ \l_keys_nesting_tl _elt:nn }
+ \KV_process_no_space_removal_no_sanitize:NNn
+ \keys_define_elt:n \keys_define_elt:nn {#2}
}
% \end{macrocode}
%\end{macro}
@@ -941,11 +985,11 @@
%\begin{macro}{\keys_define_elt:nn}
% The element processors for defining keys.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_define_elt:n #1 {
+\cs_new_protected_nopar:Npn \keys_define_elt:n #1 {
\bool_set_true:N \l_keys_no_value_bool
\keys_define_elt_aux:nn {#1} { }
}
-\cs_new:Npn \keys_define_elt:nn #1#2 {
+\cs_new_protected:Npn \keys_define_elt:nn #1#2 {
\bool_set_false:N \l_keys_no_value_bool
\keys_define_elt_aux:nn {#1} {#2}
}
@@ -955,7 +999,7 @@
%\begin{macro}[aux]{\keys_define_elt_aux:nn}
% The auxiliary function does most of the work.
% \begin{macrocode}
-\cs_new:Npn \keys_define_elt_aux:nn #1#2 {
+\cs_new_protected:Npn \keys_define_elt_aux:nn #1#2 {
\keys_property_find:n {#1}
\cs_set_eq:Nc \keys_tmp:w
{ \c_keys_properties_root_tl \l_keys_property_tl }
@@ -975,7 +1019,7 @@
% can be made for required values without needing anything set
% explicitly.
% \begin{macrocode}
-\cs_new:Npn \keys_define_key:n #1 {
+\cs_new_protected:Npn \keys_define_key:n #1 {
\bool_if:NTF \l_keys_no_value_bool {
\intexpr_compare:nTF {
\exp_args:Nc \cs_get_arg_count_from_signature:N
@@ -1000,12 +1044,12 @@
% key itself, then look for the \texttt{unknown} key with the same
% path. If both of these fail, complain!
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_execute: {
+\cs_new_protected_nopar:Npn \keys_execute: {
\keys_execute_aux:nn { \l_keys_path_tl } {
\keys_execute_unknown:
}
}
-\cs_new_nopar:Npn \keys_execute_unknown: {
+\cs_new_protected_nopar:Npn \keys_execute_unknown: {
\keys_execute_aux:nn { \l_keys_module_tl / unknown } {
\msg_kernel_error:nnxx { keys } { key-unknown } { \l_keys_path_tl }
{ \l_keys_module_tl }
@@ -1019,10 +1063,10 @@
% do not run away (hence the nine empty groups), but that the module
% can clean up the spare groups at the end of executing the key.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_execute_aux:nn #1#2 {
+\cs_new_protected_nopar:Npn \keys_execute_aux:nn #1#2 {
\cs_set_eq:Nc \keys_tmp:w { \c_keys_root_tl #1 .cmd:n }
\cs_if_exist:NTF \keys_tmp:w {
- \exp_args:NV \keys_tmp:w \l_keys_value_toks
+ \exp_args:NV \keys_tmp:w \l_keys_value_tl
}{
#2
}
@@ -1062,11 +1106,11 @@
%\begin{macro}{\keys_meta_make:x}
% To create a met-key, simply set up to pass data through.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_meta_make:n #1 {
+\cs_new_protected_nopar:Npn \keys_meta_make:n #1 {
\exp_last_unbraced:NNo \keys_cmd_set:nn \l_keys_path_tl
\exp_after:wN { \exp_after:wN \keys_set:nn \exp_after:wN { \l_keys_module_tl } {#1} }
}
-\cs_new_nopar:Npn \keys_meta_make:x #1 {
+\cs_new_protected_nopar:Npn \keys_meta_make:x #1 {
\keys_cmd_set:nx { \l_keys_path_tl } {
\exp_not:N \keys_set:nn { \l_keys_module_tl } {#1}
}
@@ -1081,7 +1125,7 @@
% Searching for a property means finding the last ``\texttt{.}'' in
% the input, and storing the text before and after it.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_property_find:n #1 {
+\cs_new_protected_nopar:Npn \keys_property_find:n #1 {
\tl_set:Nx \l_keys_path_tl { \l_keys_module_tl / }
\tl_if_in:nnTF {#1} {.} {
\keys_property_find_aux:n {#1}
@@ -1089,10 +1133,10 @@
\msg_kernel_error:nnx { keys } { key-no-property } {#1}
}
}
-\cs_new_nopar:Npn \keys_property_find_aux:n #1 {
+\cs_new_protected_nopar:Npn \keys_property_find_aux:n #1 {
\keys_property_find_aux:w #1 \q_stop
}
-\cs_new_nopar:Npn \keys_property_find_aux:w #1 . #2 \q_stop {
+\cs_new_protected_nopar:Npn \keys_property_find_aux:w #1 . #2 \q_stop {
\tl_if_in:nnTF {#2} { . } {
\tl_set:Nx \l_keys_path_tl {
\l_keys_path_tl \tl_to_str:n {#1} .
@@ -1116,7 +1160,7 @@
\cs_new_nopar:Npn \keys_property_new:nn #1#2 {
\cs_new:cpn { \c_keys_properties_root_tl #1 } {#2}
}
-\cs_new_nopar:Npn \keys_property_new_arg:nn #1#2 {
+\cs_new_protected_nopar:Npn \keys_property_new_arg:nn #1#2 {
\cs_new:cpn { \c_keys_properties_root_tl #1 } ##1 {#2}
}
% \end{macrocode}
@@ -1126,7 +1170,7 @@
%\begin{macro}{\keys_property_undefine:n}
% Removing a property means undefining it.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_property_undefine:n #1 {
+\cs_new_protected_nopar:Npn \keys_property_undefine:n #1 {
\cs_set_eq:cN { \c_keys_root_tl #1 } \c_undefined
}
% \end{macrocode}
@@ -1138,18 +1182,10 @@
% The main setting function just does the set up to get \pkg{l3keyval}
% to do the hard work.
% \begin{macrocode}
-\cs_new:Npn \keys_set:nn #1#2 {
+\cs_new_protected:Npn \keys_set:nn #1#2 {
\tl_set:Nn \l_keys_module_tl {#1}
- \cs_set_eq:NN \KV_key_no_value_elt:n \keys_set_elt:n
- \cs_set_eq:NN \KV_key_value_elt:nn \keys_set_elt:nn
- \seq_push:NV \l_keys_nesting_seq \l_keys_nesting_tl
- \tl_set:Nn \l_keys_nesting_tl { set }
- \KV_parse_space_removal_sanitize:n {#2}
- \seq_pop:NN \l_keys_nesting_seq \l_keys_nesting_tl
- \cs_set_eq:Nc \KV_key_no_value_elt:n
- { keys_ \l_keys_nesting_tl _elt:n }
- \cs_set_eq:Nc \KV_key_value_elt:nn
- { keys_ \l_keys_nesting_tl _elt:nn }
+ \KV_process_space_removal_sanitize:NNn
+ \keys_set_elt:n \keys_set_elt:nn {#2}
}
\cs_generate_variant:Nn \keys_set:nn { nV, nv }
% \end{macrocode}
@@ -1162,11 +1198,11 @@
% The two element processors are almost identical, and pass the data
% through to the underlying auxiliary, which does the work.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_set_elt:n #1 {
+\cs_new_protected_nopar:Npn \keys_set_elt:n #1 {
\bool_set_true:N \l_keys_no_value_bool
\keys_set_elt_aux:nn {#1} { }
}
-\cs_new:Npn \keys_set_elt:nn #1#2 {
+\cs_new_protected:Npn \keys_set_elt:nn #1#2 {
\bool_set_false:N \l_keys_no_value_bool
\keys_set_elt_aux:nn {#1} {#2}
}
@@ -1179,7 +1215,7 @@
% then checks to see if the a value is required or forbidden. If
% everything passes, move on to execute the code.
% \begin{macrocode}
-\cs_new:Npn \keys_set_elt_aux:nn #1#2 {
+\cs_new_protected:Npn \keys_set_elt_aux:nn #1#2 {
\tl_set:Nx \l_keys_key_tl { \tl_to_str:n {#1} }
\tl_set:Nx \l_keys_path_tl { \l_keys_module_tl / \l_keys_key_tl }
\keys_value_or_default:n {#2}
@@ -1194,13 +1230,13 @@
\keys_set_elt_aux:
}
}
-\cs_new_nopar:Npn \keys_set_elt_aux: {
+\cs_new_protected_nopar:Npn \keys_set_elt_aux: {
\keys_if_value_requirement:nTF { forbidden } {
\bool_if:NTF \l_keys_no_value_bool {
\keys_execute:
}{
\msg_kernel_error:nnxx { keys } { value-forbidden }
- { \l_keys_path_tl } { \toks_use:N \l_keys_value_toks }
+ { \l_keys_path_tl } { \tl_use:N \l_keys_value_tl }
}
}{
\keys_execute:
@@ -1227,14 +1263,14 @@
%\end{macro}
%
%\begin{macro}{\keys_value_or_default:n}
-% If a value is given, return it as |#1|, otherwise send a default if
+% If a value is given, return it as "#1", otherwise send a default if
% available.
% \begin{macrocode}
-\cs_new:Npn \keys_value_or_default:n #1 {
- \toks_set:Nn \l_keys_value_toks {#1}
+\cs_new_protected:Npn \keys_value_or_default:n #1 {
+ \tl_set:Nn \l_keys_value_tl {#1}
\bool_if:NT \l_keys_no_value_bool {
\cs_if_exist:cT { \c_keys_root_tl \l_keys_path_tl .default_tl } {
- \toks_set:Nv \l_keys_value_toks {
+ \tl_set:Nv \l_keys_value_tl {
\c_keys_root_tl \l_keys_path_tl .default_tl
}
}
@@ -1247,7 +1283,7 @@
% Values can be required or forbidden by having the appropriate marker
% set.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_value_requirement:n #1 {
+\cs_new_protected_nopar:Npn \keys_value_requirement:n #1 {
\tl_set_eq:cc { \c_keys_root_tl \l_keys_path_tl .req_tl }
{ c_keys_value_ #1 _tl }
}
@@ -1259,7 +1295,7 @@
% Setting a variable takes the type and scope separately so that
% it is easy to make a new variable if needed.
% \begin{macrocode}
-\cs_new_nopar:Npn \keys_variable_set:NnNN #1#2#3#4 {
+\cs_new_protected_nopar:Npn \keys_variable_set:NnNN #1#2#3#4 {
\cs_if_exist:NF #1 {
\use:c { #2 _new:N } #1
}
@@ -1500,67 +1536,58 @@
% For when there is a need to complain.
% \begin{macrocode}
\msg_kernel_new:nnnn { keys } { choice-unknown }
- {%
- Choice `#2' unknown for key `#1':\\%
- the key is being ignored.%
- }
- {%
- The key `#1' takes a limited number of values.\\%
- The input you gave, `#2', was not on the list accepted.\\%
- Perhaps this is a typing error?%
+ { Choice~'#2'~unknown~for~key~'#1'. }
+ {
+ The~key~'#1'~takes~a~limited~number~of~values.\\
+ The~input~given,~'#2',~is~not~on~the~list~accepted.
}
\msg_kernel_new:nnnn { keys } { generate-choices-before-code }
- {%
- Cannot create choices for key `#1':\\%
- no code has been defined.%
- }
- {%
- Code for use by .generate_choices:n should first be defined\\%
- using .choice_code:n or .choice_code:x.%
+ { No~code~available~to~generate~choices~for~key~'#1'. }
+ {
+ \l_msg_coding_error_text_tl
+ Before~using~.generate_choices:n~the~code~should~be~defined\\%
+ with~.choice_code:n~or~.choice_code:x.
}
\msg_kernel_new:nnnn { keys } { key-no-property }
- {No property given in definition of key `#1'.}
- {%
- Inside \token_to_str:N \keys_define:nn \msg_space: each key name
- needs a property:\\%
- \msg_two_spaces: #1 .<property>:\\%
- I did not find a ``.'' to indicate the start of a property.%
+ { No~property~given~in~definition~of~key~'#1'. }
+ {
+ \c_msg_coding_error_text_tl
+ Inside~\token_to_str:N \keys_define:nn \c_space_tl each~key~name
+ needs~a~property: \\
+ ~ ~ #1 .<property> \\
+ LaTeX~did~not~find~a~'.'~to~indicate~the~start~of~a~property.
}
\msg_kernel_new:nnnn { keys } { key-unknown }
- {The key `#1' is unknown and is being ignored.}
- {%
- The module `#2' does not seem to implement a key called `#1'.\\%
- I also checked for code to handle a unknown key, and did not
- find any.%
- Check that you have spelled the key name correctly.%
- }
-\msg_kernel_new:nnnn { keys } { property-unknown }
- {The key property `#1' is unknown.}
- {%
- You have asked for key `#2' to have the property `#1'.\\%
- However, I don't know the property `#1': this line will be ignored.%
+ { The~key~'#1'~is~unknown~and~is~being~ignored. }
+ {
+ The~module~'#2'~does~not~have~a~key~called~#1'.\\
+ Check~that~you~have~spelled~the~key~name~correctly.
}
\msg_kernel_new:nnnn { keys } { property-requires-value }
- {The property `#1' requires a value.}
- {%
- You have tried to set the property `#2' for key `#1'.\\%
- However, you did not give a value for this property, and one is
- needed.\\%
- The entire line will be ignored.%
+ { The property '#1' requires a value. }
+ {
+ \l_msg_coding_error_text_tl
+ LaTeX~was~asked~to~set~property~'#2'~for~key~'#1'.\\
+ No~value~was~given~for~the~property,~and~one~is~required.
+ }
+\msg_kernel_new:nnnn { keys } { property-unknown }
+ { The key property '#1' is unknown. }
+ {
+ \l_msg_coding_error_text_tl
+ LaTeX~has~been~asked~to~set~the~property~'#1'~for~key~'#2':\\
+ this~property~is~not~defined.
}
\msg_kernel_new:nnnn { keys } { value-forbidden }
- {The key `#1' does not taken a value.}
- {%
- The key `#1' should be given without a value.\\%
- You gave `#1 = #2'; I will ignore `#2' and carry out whatever\\%
- key `#1' is supposed to do.%
+ { The~key~'#1'~does~not~taken~a~value. }
+ {
+ The~key~'#1'~should~be~given~without~a~value.\\
+ LaTeX~will~ignore~the~given~value~'#2'.
}
\msg_kernel_new:nnnn { keys } { value-required }
- {The key `#1' requires a value.}
- {%
- The key `#1' should be given with a value.\\%
- You gave `#1', but should have given `#1 = <value>'.\\%
- I will ignore the key entirely.\\%
+ { The~key~'#1'~requires~a~value. }
+ {
+ The~key~'#1'~must~have~a~value.\\
+ No~value~was~present:~the~key~will~be~ignored.
}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/expl3/l3keyval.dtx b/Master/texmf-dist/source/latex/expl3/l3keyval.dtx
index 79ea988459a..086827188f4 100644
--- a/Master/texmf-dist/source/latex/expl3/l3keyval.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3keyval.dtx
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3keyval.dtx 1424 2009-07-13 06:05:25Z joseph $
+\GetIdInfo$Id: l3keyval.dtx 1872 2010-03-24 07:53:45Z mittelba $
{L3 Experimental keyval processing}
%\iffalse
%<*driver>
@@ -60,116 +60,199 @@
% \maketitle
%
% \begin{documentation}
+%
+% A key--value list is input of the form
+%\begin{verbatim}
+% KeyOne = ValueOne ,
+% KeyTwo = ValueTwo ,
+% KeyThree ,
+%\end{verbatim}
+% where each key--value pair is separated by a comma from the rest of
+% the list, and each key--value pair does not necessarily contain an
+% equals sign or a value! Processing this type of input correctly
+% requires a number of careful steps, to correctly account for
+% braces, spaces and the category codes of separators.
+%
+% This module provides the low-level machinery for processing arbitrary
+% key--value lists. The \pkg{l3keys} module provides a higher-level
+% interface for managing run-time settings using key--value input,
+% while other parts of \LaTeX3 also use key--value input based on
+% \pkg{l3keyval} (for example the \pkg{xtemplate} module).
+%
+%\section{Features of \pkg{l3keyval}}
+%
+% As \pkg{l3keyval} is a low-level module, its functions are
+% restricted to converting a \meta{keyval list} into keys and values
+% for further processing. Each key and value (or key alone)
+% has to be processed further by a function provided when
+% \pkg{l3keyval} is called. Typically, this will be \emph{via}
+% one of the \cs{KV_process\ldots} functions:
+%\begin{verbatim}
+% \KV_process_space_removal_sanitize:NNn
+% \my_processor_function_one:n
+% \my_processor_function_two:nn
+% { <keyval list> }
+%\end{verbatim}
+% The two processor functions here handle the cases where there is
+% only a key, and where there is both a key and value, respectively.
+%
+% \pkg{l3keyval} parses key--value lists in a manner that does not
+% double "#" tokens or expand any input. The module has processor
+% functions which will sanitize the category codes of \texttt{=}
+% and \texttt{,} tokens (for use in the document body) as well
+% as faster versions which do not do this (for use inside code
+% blocks). Spaces can be removed from each end of the key and
+% value (again for the document body), again with faster code
+% to be used where this is not necessary. Values which are wrapped
+% in braces will have exactly one set removed, meaning that
+%\begin{verbatim}
+% key = {value here},
+%\end{verbatim}
+% and
+%\begin{verbatim}
+% key = value here,
+%\end{verbatim}
+% are treated as identical (assuming that space removal is in force).
+% \pkg{l3keyval}
+%
+%\section{Functions for keyval processing}
%
-% This module only provides functions for extracting keys and values
-% from a list. How this information is used is up to the programmer.
-% The \pkg{l3keys} module provides a higher-level interface for
-% managing run-time key--value input.
-%
-% A \meta{keyval list} is a list consisting of
-% \begin{verbatim}
-% key 1 = value 1 ,
-% key 2 ,
-% key 3 = value 3 ,
-% \end{verbatim}
+% The \pkg{l3keyval} module should be accessed \emph{via} a small
+% set of external functions. These correctly set up the module
+% internals for use by other parts of \LaTeX3.
%
-% The function names for retrieving the keys and values are long but
-% explain what they do. All these functions start with the name
-% |\KV_parse_|. If a value is surrounded by braces, one level (and
-% only one) is removed from the value. This is useful if you need to
-% input a value which contains |=| or |,|. There are two primary
-% actions we can take on a \meta{keyval list}.
-% \begin{itemize}
-% \item A \meta{keyval list} can be sanitized so that top level active
-% commas or equal signs are converted into catcode 12. When
-% declaring templates in the preamble one can probably safely assume
-% that there are no active commas or equals; these things should
-% only be active in the document. The name for this is either
-% |no_sanitize| or |sanitize|.
-% \item Spaces on either side of a key or value can be trimmed. When
-% using the \LaTeX3 programming interface, spaces are automatically
-% ignored so there it would be a waste of time to search for extra
-% spaces since there would be none. At the document level however,
-% spaces must be removed. The name for this is either
-% |no_space_removal| or |space_removal|. Note that when
-% |space_removal| is called you get an additional option where you
-% can decide if one level of braces should be stripped from the key
-% and/or value; see the description of the boolean
-% |\l_KV_remove_one_level_of_braces_bool| for details.
-% \end{itemize}
-%
-% During the parsing process, keys or values are not expanded and no
-% |#|s are doubled. When the parsing process is over, the keys and
-% values are executed in the form
-% \begin{quote}
-% "\KV_key_value_elt:nn{key 1}{value 1}" \\
-% "\KV_key_no_value_elt:n{key 2}" \\
-% "\KV_key_value_elt:nn{key 3}{value 3}"
-% \end{quote}
-% It is up to the programmer to provide a suitable definition of these
-% two functions before starting the parsing process.
-%
-%
-% \section{Functions}
+% In all cases, two functions have to be supplied by the programmer
+% to apply to the items from the <keyval list> after \pkg{l3keyval}
+% has separated out the entries. The first function should take
+% one argument, and will receive the names of keys for which no
+% value was supplied. The second function should take two arguments:
+% a key name and the associated value.
+%
+%\begin{function}{\KV_process_space_removal_sanitize:NNn}
+% \begin{syntax}
+% "\KV_process_space_removal_sanitize:NNn"
+% ~~~~<function 1> <function 2> \Arg{keyval list}
+% \end{syntax}
+% Parses the <keyval list> splitting it into keys and associated
+% values. Spaces are removed from the ends of both the key and
+% value by this function, and the category codes of non-braced
+% \texttt{=} and \texttt{,} tokens are normalised so that
+% parsing is `category code safe'. After parsing is completed,
+% <function 1> is used to process keys without values and
+% <function 2> deals with keys which have associated values.
+%\end{function}
+%
+%\begin{function}{\KV_process_space_removal_no_sanitize:NNn}
+% \begin{syntax}
+% "\KV_process_space_removal_no_sanitize:NNn"
+% ~~~~<function 1> <function 2> \Arg{keyval list}
+% \end{syntax}
+% Parses the <keyval list> splitting it into keys and associated
+% values. Spaces are removed from the ends of both the key and
+% value by this function, but category codes are not normalised.
+% After parsing is completed, <function 1> is used to process keys
+% without values and <function 2> deals with keys which have
+% associated values.
+%\end{function}
+%
+%\begin{function}{\KV_process_no_space_removal_no_sanitize:NNn}
+% \begin{syntax}
+% "\KV_process_no_space_removal_no_sanitize:NNn"
+% ~~~~<function 1> <function 2> \Arg{keyval list}
+% \end{syntax}
+% Parses the <keyval list> splitting it into keys and associated
+% values. Spaces are \emph{not} removed from the ends of
+% the key and value, and category codes are \emph{not} normalised.
+% After parsing is completed, <function 1> is used to process keys
+% without values and <function 2> deals with keys which have
+% associated values.
+%\end{function}
+%
+% \begin{variable}{\l_KV_remove_one_level_of_braces_bool}
+% This boolean controls whether or not one level of braces is
+% stripped from the key and value. The default value for this
+% boolean is \texttt{true} so that exactly one level of braces is
+% stripped. For certain applications it is desirable to keep the
+% braces in which case the programmer just has to set the boolean
+% false temporarily. Only applicable when spaces are being
+% removed.
+% \end{variable}
%
-% \begin{function}{
-% \KV_parse_no_space_removal_no_sanitize:n |
-% }
+%\section{Internal functions}
+%
+% The remaining functions provided by \pkg{l3keyval} do not
+% have any protection for nesting of one call to the module
+% inside another. They should therefore not be called directly by
+% other modules.
+%
+% \begin{function}{\KV_parse_no_space_removal_no_sanitize:n}
% \begin{syntax}
% "\KV_parse_no_space_removal_no_sanitize:n" \Arg{keyval list}
% \end{syntax}
-% Parses the keys and values literally. For use when spaces are
-% ignored and |=| and |,| have normal catcodes.
+% Parses the keys and values, passing the results to
+% \cs{KV_key_no_value_elt:n} and \cs{KV_key_value_elt:nn} as
+% appropriate. Spaces are not removed in the parsing process and
+% the category codes of \texttt{=} and \texttt{,} are not
+% normalised.
% \end{function}
%
-% \begin{function}{
-% \KV_parse_space_removal_no_sanitize:n |
-% }
+% \begin{function}{\KV_parse_space_removal_no_sanitize:n}
% \begin{syntax}
% "\KV_parse_space_removal_no_sanitize:n" \Arg{keyval list}
% \end{syntax}
-% As above but also removes spaces around keys and values. For use
-% when spaces are not ignored.
+% Parses the keys and values, passing the results to
+% \cs{KV_key_no_value_elt:n} and \cs{KV_key_value_elt:nn} as
+% appropriate. Spaces are removed in the parsing process from the
+% ends of the key and value, but the category codes of \texttt{=}
+% and \texttt{,} are not normalised.
% \end{function}
%
-% \begin{function}{
-% \KV_parse_space_removal_sanitize:n |
-% }
+% \begin{function}{\KV_parse_space_removal_sanitize:n}
% \begin{syntax}
% "\KV_parse_space_removal_sanitize:n" \Arg{keyval list}
% \end{syntax}
-% As above but additionally also replaces top-level active |=| and
-% |,| with harmless versions.
+% Parses the keys and values, passing the results to
+% \cs{KV_key_no_value_elt:n} and \cs{KV_key_value_elt:nn} as
+% appropriate. Spaces are removed in the parsing process from the
+% ends of the key and value and the category codes of \texttt{=}
+% and \texttt{,} are normalised at the outer level
+% (\emph{i.e}.~only unbraced tokens are affected).
% \end{function}
%
-% \begin{variable}{
-% \l_KV_remove_one_level_of_braces_bool |
-% }
-% \begin{syntax}
-% \end{syntax}
-% This boolean controls whether or not one level of braces is
-% stripped from the key and value. The default value for this
-% boolean is \meta{true} so that exactly one level of braces is
-% stripped. For certain applications it is desirable to keep the
-% braces in which case the programmer just has to set the boolean
-% false temporarily. Setting this boolean has no effect when you
-% call the |no_space_removal| functions since not stripping braces
-% is a rare request and would clutter the otherwise elegant code of
-% the |no_space_removal| functions for very little gain. If you need
-% to preserve braces choose the slower |space_removal| functions.
-% \end{variable}
-%
% \begin{function}{
% \KV_key_no_value_elt:n |
-% \KV_key_value_elt:nn |
+% \KV_key_value_elt:nn
% }
% \begin{syntax}
% "\KV_key_no_value_elt:n" \Arg{key} \\
-% "\KV_key_value_elt:n" \Arg{key} \Arg{value}
+% "\KV_key_value_elt:n" \Arg{key} \Arg{value}
% \end{syntax}
-% Functions returned by the |\KV_parse_| functions. The default
-% definition of these two functions is an error message!
+% Used by \cs{KV_parse\ldots} functions to further process
+% keys with no values and keys with values, respectively. The
+% standard definitions are error functions: the programmer should
+% provide appropriate definitions for both at point of use.
% \end{function}
+%
+%\section{Variables and constants}
+%
+%\begin{variable}{\c_KV_single_equal_sign_tl}
+% Constant token list to make finding \texttt{=} faster.
+%\end{variable}
+%
+%\begin{variable}{
+% \l_KV_tmpa_tl |
+% \l_KV_tmpb_tl
+%}
+% Scratch token lists.
+%\end{variable}
+%
+%\begin{variable}{
+% \l_KV_parse_tl |
+% \l_KV_currkey_tl |
+% \l_KV_currval_tl
+%}
+% Token list variables for various parts of the parsed input.
+%\end{variable}
%
% \end{documentation}
%
@@ -177,15 +260,6 @@
%
% \section{\pkg{l3keyval} implementation}
%
-% \subsection{Internal functions and variables}
-%
-% \begin{variable}{ \l_KV_tmpa_tl | \l_KV_tmpb_tl |
-% \c_KV_single_equal_sign_tl |
-% \l_KV_parse_toks | \l_KV_currkey_toks |
-% \l_KV_currval_toks }
-% Token list variables and token registers used internally.
-% \end{variable}
-%
% \begin{function}{ \KV_sanitize_outerlevel_active_equals:N |
% \KV_sanitize_outerlevel_active_commas:N }
% \begin{syntax}
@@ -198,12 +272,12 @@
% \KV_remove_surrounding_spaces_auxi:w / (EXP) }
% \begin{syntax}
%
-% "\KV_remove_surrounding_spaces:nw" <toks> <token list> "\q_nil"
+% "\KV_remove_surrounding_spaces:nw" <tl> <token list> "\q_nil"
% "\KV_remove_surrounding_spaces_auxi:w" <token list> \verb*" Q"$\sb3$
% \end{syntax}
% Removes a possible
% leading space plus a possible ending space from a <token list>.
-% The first version (which is not used in the code) stores it in <toks>.
+% The first version (which is not used in the code) stores it in <tl>.
% \end{function}
%
% \begin{function}{ \KV_add_value_element:w | \KV_set_key_element:w }
@@ -212,7 +286,7 @@
% "\KV_add_value_element:w" "\q_stop" <token list> "\q_nil"
% \end{syntax}
% Specialised functions to strip spaces from their input and set the
-% token registers "\l_KV_currkey_toks" or "\l_KV_currval_toks"
+% token registers "\l_KV_currkey_tl" or "\l_KV_currval_tl"
% respectively.
% \end{function}
%
@@ -248,24 +322,32 @@
% \begin{macrocode}
\tl_new:N \l_KV_tmpa_tl
\tl_new:N \l_KV_tmpb_tl
-\tl_new:Nn \c_KV_single_equal_sign_tl{=}
+\tl_const:Nn \c_KV_single_equal_sign_tl { = }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\l_KV_parse_toks}
-% \begin{macro}{\l_KV_currkey_toks}
-% \begin{macro}{\l_KV_currval_toks}
+% \begin{macro}{\l_KV_parse_tl}
+% \begin{macro}{\l_KV_currkey_tl}
+% \begin{macro}{\l_KV_currval_tl}
% Some more useful things.
% \begin{macrocode}
-\toks_new:N \l_KV_parse_toks
-\toks_new:N \l_KV_currkey_toks
-\toks_new:N \l_KV_currval_toks
+\tl_new:N \l_KV_parse_tl
+\tl_new:N \l_KV_currkey_tl
+\tl_new:N \l_KV_currval_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+%
+%\begin{macro}{\l_KV_level_int}
+% This is used to track how deeply nested calls to the keyval processor
+% are, so that the correct functions are always in use.
+% \begin{macrocode}
+\int_new:N \l_KV_level_int
+% \end{macrocode}
+%\end{macro}
%
% \begin{macro}{\l_KV_remove_one_level_of_braces_bool}
% A boolean to control
@@ -274,6 +356,47 @@
\bool_set_true:N \l_KV_remove_one_level_of_braces_bool
% \end{macrocode}
% \end{macro}
+%
+%\begin{macro}{\KV_process_space_removal_sanitize:NNn}
+%\begin{macro}{\KV_process_space_removal_no_sanitize:NNn}
+%\begin{macro}{\KV_process_no_space_removal_no_sanitize:NNn}
+%\begin{macro}[aux]{\KV_process_aux:NNNn}
+% The wrapper function takes care of assigning the appropriate
+% \texttt{elt} functions before and after the parsing step. In that
+% way there is no danger of a mistake with the wrong functions being
+% used.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \KV_process_space_removal_sanitize:NNn {
+ \KV_process_aux:NNNn \KV_parse_space_removal_sanitize:n
+}
+\cs_new_protected_nopar:Npn \KV_process_space_removal_no_sanitize:NNn {
+ \KV_process_aux:NNNn \KV_parse_space_removal_no_sanitize:n
+}
+\cs_new_protected_nopar:Npn \KV_process_no_space_removal_no_sanitize:NNn {
+ \KV_process_aux:NNNn \KV_parse_no_space_removal_no_sanitize:n
+}
+\cs_new_protected:Npn \KV_process_aux:NNNn #1#2#3#4 {
+ \cs_set_eq:cN
+ { KV_key_no_value_elt_ \int_use:N \l_KV_level_int :n }
+ \KV_key_no_value_elt:n
+ \cs_set_eq:cN
+ { KV_key_value_elt_ \int_use:N \l_KV_level_int :nn }
+ \KV_key_value_elt:nn
+ \cs_set_eq:NN \KV_key_no_value_elt:n #2
+ \cs_set_eq:NN \KV_key_value_elt:nn #3
+ \int_incr:N \l_KV_level_int
+ #1 {#4}
+ \int_decr:N \l_KV_level_int
+ \cs_set_eq:Nc \KV_key_no_value_elt:n
+ { KV_key_no_value_elt_ \int_use:N \l_KV_level_int :n }
+ \cs_set_eq:Nc \KV_key_value_elt:nn
+ { KV_key_value_elt_ \int_use:N \l_KV_level_int :nn }
+}
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
% \begin{macro}{\KV_sanitize_outerlevel_active_equals:N}
% \begin{macro}{\KV_sanitize_outerlevel_active_commas:N}
@@ -287,7 +410,7 @@
\char_set_lccode:nn{`\8}{`\=}
\char_set_lccode:nn{`\9}{`\,}
\tl_to_lowercase:n{\group_end:
-\cs_new_nopar:Npn \KV_sanitize_outerlevel_active_equals:N #1{
+\cs_new_protected_nopar:Npn \KV_sanitize_outerlevel_active_equals:N #1{
\tl_replace_all_in:Nnn #1 = 8
}
\cs_new_nopar:Npn \KV_sanitize_outerlevel_active_commas:N #1{
@@ -342,7 +465,7 @@
% The function here allows you to insert arbitrary functions in the
% first argument but they should all be with an |f| type
% expansion. For the application in this module, we use
-% |\toks_set:Nf|.
+% |\tl_set:Nf|.
%
% Once the expansion has been kick-started, we apply
% |\KV_remove_surrounding_spaces_auxi:w| to the replacement text of
@@ -371,22 +494,22 @@
%
% Here are some specialized versions of the above. They do exactly
% what we want in one go. First trim spaces from the value and then
-% put the result surrounded in braces onto |\l_KV_parse_toks|.
+% put the result surrounded in braces onto |\l_KV_parse_tl|.
% \begin{macrocode}
-\cs_gnew:Npn\KV_add_value_element:w\q_stop#1\q_nil{
- \toks_set:Nf\l_KV_currval_toks {
+\cs_gnew_protected:Npn\KV_add_value_element:w\q_stop#1\q_nil{
+ \tl_set:Nf\l_KV_currval_tl {
\KV_remove_surrounding_spaces_auxi:w \exp_not:N#1Q~Q
}
- \toks_put_right:No\l_KV_parse_toks{
- \exp_after:wN {\toks_use:N \l_KV_currval_toks}
+ \tl_put_right:No\l_KV_parse_tl{
+ \exp_after:wN { \l_KV_currval_tl }
}
}
% \end{macrocode}
% When storing the key we firstly remove spaces plus the prepended
% |\q_no_value|.
% \begin{macrocode}
-\cs_gnew:Npn\KV_set_key_element:w#1\q_nil{
- \toks_set:Nf\l_KV_currkey_toks
+\cs_gnew_protected:Npn\KV_set_key_element:w#1\q_nil{
+ \tl_set:Nf\l_KV_currkey_tl
{
\exp_last_unbraced:NNo \KV_remove_surrounding_spaces_auxi:w
\exp_not:N \use_none:n #1Q~Q
@@ -397,9 +520,8 @@
% \begin{macrocode}
\bool_if:NT \l_KV_remove_one_level_of_braces_bool
{
- \exp_args:NNo \toks_set:No \l_KV_currkey_toks {
- \exp_after:wN \KV_add_element_aux:w
- \toks_use:N \l_KV_currkey_toks \q_nil
+ \exp_args:NNo \tl_set:No \l_KV_currkey_tl {
+ \exp_after:wN \KV_add_element_aux:w \l_KV_currkey_tl \q_nil
}
}
}
@@ -427,10 +549,10 @@
% at the top level first. Then uses |#1| as inspector of each
% element in the comma list.
% \begin{macrocode}
-\cs_new:Npn \KV_parse_sanitize_aux:n #1 {
+\cs_new_protected:Npn \KV_parse_sanitize_aux:n #1 {
\group_begin:
- \toks_clear:N \l_KV_parse_toks
- \tl_set:Nx \l_KV_tmpa_tl { \exp_not:n {#1} }
+ \tl_clear:N \l_KV_parse_tl
+ \tl_set:Nn \l_KV_tmpa_tl {#1}
\KV_sanitize_outerlevel_active_equals:N \l_KV_tmpa_tl
\KV_sanitize_outerlevel_active_commas:N \l_KV_tmpa_tl
\exp_last_unbraced:NNV \KV_parse_elt:w \q_no_value
@@ -439,8 +561,8 @@
% We evaluate the parsed keys and values outside the group so the
% token register is restored to its previous value.
% \begin{macrocode}
- \exp_last_unbraced:NV \group_end:
- \l_KV_parse_toks
+ \exp_after:wN \group_end:
+ \l_KV_parse_tl
}
% \end{macrocode}
% \end{macro}
@@ -451,12 +573,12 @@
% the one we will use for preamble parsing where catcodes of |=| and
% |,| are as expected!
% \begin{macrocode}
-\cs_new:Npn \KV_parse_no_sanitize_aux:n #1{
+\cs_new_protected:Npn \KV_parse_no_sanitize_aux:n #1{
\group_begin:
- \toks_clear:N \l_KV_parse_toks
+ \tl_clear:N \l_KV_parse_tl
\KV_parse_elt:w \q_no_value #1 , \q_nil ,
- \exp_last_unbraced:NV \group_end:
- \l_KV_parse_toks
+ \exp_after:wN \group_end:
+ \l_KV_parse_tl
}
% \end{macrocode}
% \end{macro}
@@ -522,7 +644,7 @@
% this is slightly more tedious (but only slightly) but at least it
% always removes only one level of braces.
% \begin{macrocode}
-\cs_new:Npn \KV_split_key_value_space_removal:w #1 = #2\q_nil{
+\cs_new_protected:Npn \KV_split_key_value_space_removal:w #1 = #2\q_nil{
% \end{macrocode}
% First grab the key.
% \begin{macrocode}
@@ -531,15 +653,15 @@
% Then we start checking. If only a key was entered, |#2| contains
% |=| and nothing else, so we test for that first.
% \begin{macrocode}
- \tl_set:Nx\l_KV_tmpa_tl{\exp_not:n{#2}}
+ \tl_set:Nn\l_KV_tmpa_tl{#2}
\tl_if_eq:NNTF\l_KV_tmpa_tl\c_KV_single_equal_sign_tl
% \end{macrocode}
% Then we just insert the default key.
% \begin{macrocode}
{
- \toks_put_right:No\l_KV_parse_toks{
+ \tl_put_right:No\l_KV_parse_tl{
\exp_after:wN \KV_key_no_value_elt:n
- \exp_after:wN {\toks_use:N\l_KV_currkey_toks}
+ \exp_after:wN {\l_KV_currkey_tl}
}
}
% \end{macrocode}
@@ -552,13 +674,13 @@
{
\KV_split_key_value_space_removal_detect_error:wTF#2\q_no_value\q_nil
{\KV_split_key_value_space_removal_aux:w \q_stop #2}
- {\ERROR}
+ { \msg_kernel_error:nn { keyval } { misplaced-equals-sign } }
}
}
% \end{macrocode}
% The error test.
% \begin{macrocode}
-\cs_new:Npn
+\cs_new_protected:Npn
\KV_split_key_value_space_removal_detect_error:wTF#1=#2#3\q_nil{
\tl_if_head_eq_meaning:nNTF{#3}\q_no_value
}
@@ -570,11 +692,11 @@
% exactly one token or brace group, only the latter quark is left.
% \begin{macrocode}
\cs_new:Npn \KV_val_preserve_braces:NnN #1#2#3{{#2}}
-\cs_new:Npn\KV_split_key_value_space_removal_aux:w #1=={
+\cs_new_protected:Npn\KV_split_key_value_space_removal_aux:w #1=={
\tl_set:Nx\l_KV_tmpa_tl{\exp_not:o{\use_none:nnn#1\q_nil\q_nil}}
- \toks_put_right:No\l_KV_parse_toks{
+ \tl_put_right:No\l_KV_parse_tl{
\exp_after:wN \KV_key_value_elt:nn
- \exp_after:wN {\toks_use:N\l_KV_currkey_toks}
+ \exp_after:wN {\l_KV_currkey_tl}
}
% \end{macrocode}
% If there a blank space or nothing at all, |\l_KV_tmpa_tl| is now
@@ -584,7 +706,7 @@
% \end{macrocode}
% We just put an empty value on the stack.
% \begin{macrocode}
- { \toks_put_right:Nn\l_KV_parse_toks{{}} }
+ { \tl_put_right:Nn\l_KV_parse_tl{{}} }
{
% \end{macrocode}
% If there was exactly one brace group or token in |#1|,
@@ -596,12 +718,12 @@
{
\bool_if:NTF \l_KV_remove_one_level_of_braces_bool
{
- \toks_put_right:No\l_KV_parse_toks{
+ \tl_put_right:No\l_KV_parse_tl{
\exp_after:wN{\use_ii:nnn #1\q_nil}
}
}
{
- \toks_put_right:No\l_KV_parse_toks{
+ \tl_put_right:No\l_KV_parse_tl{
\exp_after:wN{\KV_val_preserve_braces:NnN #1\q_nil}
}
}
@@ -623,18 +745,18 @@
% however fun they may be. Since there are no spaces, a set of
% braces around a value is automatically stripped by \TeX.
% \begin{macrocode}
-\cs_new:Npn \KV_split_key_value_no_space_removal:w #1#2=#3=#4\q_nil{
+\cs_new_protected:Npn \KV_split_key_value_no_space_removal:w #1#2=#3=#4\q_nil{
\tl_set:Nn\l_KV_tmpa_tl{#4}
\tl_if_empty:NTF \l_KV_tmpa_tl
{
- \toks_put_right:Nn\l_KV_parse_toks{\KV_key_no_value_elt:n{#2}}
+ \tl_put_right:Nn\l_KV_parse_tl{\KV_key_no_value_elt:n{#2}}
}
{
\tl_if_eq:NNTF\c_KV_single_equal_sign_tl\l_KV_tmpa_tl
{
- \toks_put_right:Nn\l_KV_parse_toks{\KV_key_value_elt:nn{#2}{#3}}
+ \tl_put_right:Nn\l_KV_parse_tl{\KV_key_value_elt:nn{#2}{#3}}
}
- {\ERROR}
+ { \msg_kernel_error:nn { keyval } { misplaced-equals-sign } }
}
}
% \end{macrocode}
@@ -660,7 +782,7 @@
% version that disallows unmatched conditional and does no space
% removal.
% \begin{macrocode}
-\cs_new_nopar:Npn \KV_parse_no_space_removal_no_sanitize:n {
+\cs_new_protected_nopar:Npn \KV_parse_no_space_removal_no_sanitize:n {
\cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_no_space_removal:w
\KV_parse_no_sanitize_aux:n
}
@@ -672,14 +794,14 @@
% The other varieties can be defined in a similar manner. For the
% version needed at the document level, we can use this one.
% \begin{macrocode}
-\cs_new_nopar:Npn \KV_parse_space_removal_sanitize:n {
+\cs_new_protected_nopar:Npn \KV_parse_space_removal_sanitize:n {
\cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w
\KV_parse_sanitize_aux:n
}
% \end{macrocode}
% For preamble use by the non-programmer this is probably best.
% \begin{macrocode}
-\cs_new_nopar:Npn \KV_parse_space_removal_no_sanitize:n {
+\cs_new_protected_nopar:Npn \KV_parse_space_removal_no_sanitize:n {
\cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w
\KV_parse_no_sanitize_aux:n
}
@@ -687,6 +809,16 @@
% \end{macro}
% \end{macro}
%
+% \begin{macrocode}
+\msg_kernel_new:nnnn { keyval } { misplaced-equals-sign }
+ {Misplaced~equals~sign~in~key--value~input~\msg_line_context:}
+ {
+ I~am~trying~to~read~some~key--value~input~but~found~two~equals~
+ signs\\%
+ without~a~comma~between~them.
+ }
+% \end{macrocode}
+%
%
% \begin{macrocode}
%</initex|package>
diff --git a/Master/texmf-dist/source/latex/expl3/l3msg.dtx b/Master/texmf-dist/source/latex/expl3/l3msg.dtx
index d3b33f44c55..65e092384b9 100644
--- a/Master/texmf-dist/source/latex/expl3/l3msg.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3msg.dtx
@@ -37,7 +37,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3msg.dtx 1722 2009-11-06 13:22:12Z joseph $
+\GetIdInfo$Id: l3msg.dtx 1866 2010-03-23 08:29:27Z joseph $
{L3 Experimental LaTeX Messages module}
%\iffalse
%<*driver>
@@ -84,54 +84,68 @@
% basis. In this way, message behaviour can be altered and messages can
% be entirely suppressed.
%
-% \section{Creating new messages}
+%\section{Creating new messages}
%
% All messages have to be created before they can be used. Inside the
% message text, spaces are \emph{not} ignored. A space where \TeX\
% would normally gobble one can be created using |\ |, and a new line
-% with |\\|. New lines may have ``continuation'' text added by the
+% with |\\|. New lines may have `continuation' text added by the
% output system.
%
%\begin{function}{
-% \msg_new:nnnn|
-% \msg_new:nnn|
-% \msg_set:nnnn|
+% \msg_new:nnnn |
+% \msg_new:nnn |
+% \msg_set:nnnn |
% \msg_set:nnn
%}
% \begin{syntax}
-% "\msg_new:nnnn" \marg{module} \marg{name} \marg{text} \marg{more text}
+% "\msg_new:nnnn" \marg{module} \marg{message} \marg{text}
+% ~~~~\marg{more text}
% \end{syntax}
-% Creates new message <name> for <module> to produce <text> initially
+% Creates new <message> for <module> to produce <text> initially
% and <more text> if requested by the user. <text> and <more text> can
% use up to four macro parameters (|#1| to |#4|), which are supplied by
-% the message system. Inside <text> and <more text> spaces are not
-% ignored.
+% the message system. At the point where <message> is printed, the
+% material supplied for |#1| to |#4| will be subject to an x-type
+% expansion.
+%
+% An error will be raised by the \texttt{new} functions if the
+% message already exists: the \texttt{set} functions do not
+% carry any checking. For messages defined using
+% \cs{msg_new:nnn} or \cs{msg_set:nnn} \LaTeX3 will supply a
+% standard <more text> at the point the message is used, if this
+% is required.
%\end{function}
%
-% \section{Message classes}
+%\section{Message classes}
%
% Creating message output requires the message to be given a class.
%
%\begin{function}{
-% \msg_class_new:nn|
+% \msg_class_new:nn |
% \msg_class_set:nn
%}
% \begin{syntax}
% "\msg_class_new:nn" \marg{class} \marg{code}
% \end{syntax}
% Creates new <class> to output a message, using <code> to process
-% the message text.
+% the message text. The <class> should be a text value, while
+% the <code> may be any arbitrary material.
%\end{function}
%
% The module defines several common message classes. The following
% describes the standard behaviour of each class if no redirection of
-% the class or message is active.
+% the class or message is active. In all cases, the message may be
+% issued supplying \(0\) to \(4\) arguments. The code will
+% ensure that there an no errors if the number of arguments supplied
+% here does not match the number in the definition of the message
+% (although of course the sense of the message may be impaired).
%
%\begin{function}{
-% \msg_fatal:nnxxxx|
-% \msg_fatal:nnxxx|
-% \msg_fatal:nnxx|
-% \msg_fatal:nnx|
+% \msg_fatal:nnxxxx |
+% \msg_fatal:nnxxx |
+% \msg_fatal:nnxx |
+% \msg_fatal:nnx |
% \msg_fatal:nn
%}
% \begin{syntax}
@@ -139,14 +153,15 @@
% ~~~~\marg{arg two} \marg{arg three} \marg{arg four}
% \end{syntax}
% Issues <module> error message <name>, passing <arg one> to
-% <arg four> to the text-creating functions. The \TeX\ run then halts.
+% <arg four> to the text-creating functions. After issuing a
+% fatal error the \TeX\ run will halt.
%\end{function}
%
%\begin{function}{
-% \msg_error:nnxxxx|
-% \msg_error:nnxxx|
-% \msg_error:nnxx|
-% \msg_error:nnx|
+% \msg_error:nnxxxx |
+% \msg_error:nnxxx |
+% \msg_error:nnxx |
+% \msg_error:nnx |
% \msg_error:nn
%}
% \begin{syntax}
@@ -161,10 +176,10 @@
%\end{function}
%
%\begin{function}{
-% \msg_warning:nnxxxx|
-% \msg_warning:nnxxx|
-% \msg_warning:nnxx|
-% \msg_warning:nnx|
+% \msg_warning:nnxxxx |
+% \msg_warning:nnxxx |
+% \msg_warning:nnxx |
+% \msg_warning:nnx |
% \msg_warning:nn
%}
% \begin{syntax}
@@ -179,10 +194,10 @@
%\end{function}
%
%\begin{function}{
-% \msg_info:nnxxxx|
-% \msg_info:nnxxx|
-% \msg_info:nnxx|
-% \msg_info:nnx|
+% \msg_info:nnxxxx |
+% \msg_info:nnxxx |
+% \msg_info:nnxx |
+% \msg_info:nnx |
% \msg_info:nn
%}
% \begin{syntax}
@@ -249,8 +264,11 @@
% \begin{syntax}
% "\msg_redirect_class:nn" \marg{class one} \marg{class two}
% \end{syntax}
-% Redirect all messages of <class one> to appear as those of
-% <class two>.
+% Changes the behaviour of messages of <class one> so that they
+% are processed using the code for those of <class two>. Multiple
+% redirections are possible. Redirection to a missing class or
+% infinite loops will raise errors when the messages are used,
+% rather than at the point of redirection.
%\end{function}
%
%\begin{function}{\msg_redirect_module:nnn}
@@ -258,9 +276,11 @@
% "\msg_redirect_module:nnn" \marg{module} \marg{class one}
% \marg{class two}
% \end{syntax}
-% Redirect <module> messages of <class one> to appear in <class two>.
+% Redirects message of <class one> for <module> to act as though
+% they were from <class two>. Messages of <class one> from
+% sources other than <module> are not affected by this redirection.
% \begin{texnote}
-% This function can be used to make some messages ``silent'' by
+% This function can be used to make some messages `silent' by
% default. For example, all of the \texttt{trace} messages of
% <module> could be turned off with:
% \begin{verbatim}
@@ -273,7 +293,15 @@
% \begin{syntax}
% "\msg_redirect_name:nnn" \marg{module} \marg{message} \marg{class}
% \end{syntax}
-% Redirect <module> <message> to appear using <class>.
+% Redirects a specific <message> from a specific <module> to act
+% as a member of <class> of messages.
+% \begin{texnote}
+% This function can be used to make a selected message `silent'
+% without changing global parameters:
+% \begin{verbatim}
+% \msg_redirect_name:nnn { module } { annoying-message } { none }
+% \end{verbatim}
+% \end{texnote}
%\end{function}
%
% \section{Support functions for output}
@@ -282,18 +310,23 @@
% \begin{syntax}
% "\msg_line_context:"
% \end{syntax}
-% Prints the current line number preceded by \cs{c_msg_on_line_tl}.
+% Prints the text specified in \cs{c_msg_on_line_tl} followed by
+% the current line in the current input file.
+% \begin{texnote}
+% This is similar to the text added to messages by \LaTeXe's
+% \cs{PackageWarning} and \cs{PackageInfo}.
+% \end{texnote}
%\end{function}
%
%\begin{function}{\msg_line_number:}
% \begin{syntax}
% "\msg_line_number:"
% \end{syntax}
-% Prints the current line number.
+% Prints the current line number in the current input file.
%\end{function}
%
%\begin{function}{
-% \msg_newline:|
+% \msg_newline: |
% \msg_two_newlines:
%}
% \begin{syntax}
@@ -302,18 +335,6 @@
% Print one or two newlines with no continuation information.
%\end{function}
%
-%\begin{function}{
-% \msg_space:|
-% \msg_two_spaces:|
-% \msg_four_spaces:
-%}
-% \begin{syntax}
-% "\msg_space:"
-% \end{syntax}
-% Print one, two or four spaces: needed where a literal space would
-% otherwise be gobbled by \TeX.
-%\end{function}
-%
% \section{Low-level functions}
%
% The low-level functions do not make assumptions about module names.
@@ -321,9 +342,9 @@
% respond to redirection.
%
%\begin{function}{
-% \msg_generic_new:nnn|
-% \msg_generic_new:nn|
-% \msg_generic_set:nnn|
+% \msg_generic_new:nnn |
+% \msg_generic_new:nn |
+% \msg_generic_set:nnn |
% \msg_generic_set:nn
%}
% \begin{syntax}
@@ -331,7 +352,7 @@
% \end{syntax}
% Creates new message <name> to produce <text> initially and
% <more text> if requested by the user. <text> and <more text> can use
-% up to four macro parameters (|#1| to |#4|), which are supplied by the
+% up to four macro parameters ("#1" to "#4"), which are supplied by the
% message system. Inside <text> and <more text> spaces are not ignored.
%\end{function}
%
@@ -343,7 +364,7 @@
% Executes a \TeX\ error, interrupting compilation. The <first line>
% is displayed followed by <text> and the input prompt. <more text> is
% displays if requested by the user. If <more text> is blank a default
-% is supplied. Each line of <text> (broken with |\\|) begins with
+% is supplied. Each line of <text> (broken with "\\") begins with
% <continuation>.
%\end{function}
%
@@ -355,15 +376,15 @@
% "\msg_direct_log:xx" \marg{text} \marg{continuation}
% \end{syntax}
% Prints <text> to either the log or terminal. New lines (broken
-% with |\\|) start with <continuation>.
+% with "\\") start with <continuation>.
%\end{function}
%
% \section{Kernel-specific functions}
%
%\begin{function}{
-% \msg_kernel_new:nnnn|
-% \msg_kernel_new:nnn|
-% \msg_kernel_set:nnnn|
+% \msg_kernel_new:nnnn |
+% \msg_kernel_new:nnn |
+% \msg_kernel_set:nnnn |
% \msg_kernel_set:nnn
%}
% \begin{syntax}
@@ -372,16 +393,16 @@
% \end{syntax}
% Creates new kernel message <name> to produce <text> initially and
% <more text> if requested by the user. <text> and <more text> can use
-% up to four macro parameters (|#1| to |#4|), which are supplied by the
+% up to four macro parameters ("#1" to "#4"), which are supplied by the
% message system. Kernel messages are divided into <divisions>, roughly
% equivalent to the \LaTeXe\ package names used.
%\end{function}
%
%\begin{function}{
-% \msg_kernel_fatal:nnxxxx|
-% \msg_kernel_fatal:nnxxx|
-% \msg_kernel_fatal:nnxx|
-% \msg_kernel_fatal:nnx|
+% \msg_kernel_fatal:nnxxxx |
+% \msg_kernel_fatal:nnxxx |
+% \msg_kernel_fatal:nnxx |
+% \msg_kernel_fatal:nnx |
% \msg_kernel_fatal:nn
%}
% \begin{syntax}
@@ -394,10 +415,10 @@
%\end{function}
%
%\begin{function}{
-% \msg_kernel_error:nnxxxx|
-% \msg_kernel_error:nnxxx|
-% \msg_kernel_error:nnxx|
-% \msg_kernel_error:nnx|
+% \msg_kernel_error:nnxxxx |
+% \msg_kernel_error:nnxxx |
+% \msg_kernel_error:nnxx |
+% \msg_kernel_error:nnx |
% \msg_kernel_error:nn
%}
% \begin{syntax}
@@ -409,10 +430,10 @@
%\end{function}
%
%\begin{function}{
-% \msg_kernel_warning:nnxxxx|
-% \msg_kernel_warning:nnxxx|
-% \msg_kernel_warning:nnxx|
-% \msg_kernel_warning:nnx|
+% \msg_kernel_warning:nnxxxx |
+% \msg_kernel_warning:nnxxx |
+% \msg_kernel_warning:nnxx |
+% \msg_kernel_warning:nnx |
% \msg_kernel_warning:nn
%}
% \begin{syntax}
@@ -424,10 +445,10 @@
%\end{function}
%
%\begin{function}{
-% \msg_kernel_info:nnxxxx|
-% \msg_kernel_info:nnxxx|
-% \msg_kernel_info:nnxx|
-% \msg_kernel_info:nnx|
+% \msg_kernel_info:nnxxxx |
+% \msg_kernel_info:nnxxx |
+% \msg_kernel_info:nnxx |
+% \msg_kernel_info:nnx |
% \msg_kernel_info:nn
%}
% \begin{syntax}
@@ -442,46 +463,54 @@
% \begin{syntax}
% "\msg_kernel_bug:x" \marg{text}
% \end{syntax}
-% Short-cut for ``This is a LaTeX bug: check coding'' errors.
+% Short-cut for `This is a LaTeX bug: check coding' errors.
%\end{function}
%
% \section{Variables and constants}
%
%\begin{variable}{
-% \c_msg_fatal_tl|
-% \c_msg_error_tl|
-% \c_msg_warning_tl|
+% \c_msg_fatal_tl |
+% \c_msg_error_tl |
+% \c_msg_warning_tl |
% \c_msg_info_tl
%}
-% Simple headers for errors.
+% Simple headers for errors. Although these are marked as constants,
+% they could be changed for printing errors in a different language.
%\end{variable}
%
%\begin{variable}{
-% \c_msg_fatal_text_tl|
-% \c_msg_help_text_tl|
-% \c_msg_kernel_bug_text_tl|
-% \c_msg_kernel_bug_more_text_tl|
-% \c_msg_no_info_text_tl|
+% \c_msg_coding_error_text_tl |
+% \c_msg_fatal_text_tl |
+% \c_msg_help_text_tl |
+% \c_msg_kernel_bug_text_tl |
+% \c_msg_kernel_bug_more_text_tl |
+% \c_msg_no_info_text_tl |
% \c_msg_return_text_tl
%}
% Various pieces of text for use in messages, which are not changed by
-% the code here although they could be to alter the language.
+% the code here although they could be to alter the language. Although
+% these are marked as constants, they could be changed for printing
+% errors in a different language.
%\end{variable}
%
%\begin{variable}{\c_msg_on_line_tl}
-% The ``on line'' phrase for line numbers.
+% The `on line' phrase for line numbers. Although marked as a constant,
+% they could be changed for printing errors in a different language.
%\end{variable}
%
%\begin{variable}{
-% \c_msg_text_prefix_tl|
-% \c_msg_more_text_prefix_tl|
+% \c_msg_text_prefix_tl |
+% \c_msg_more_text_prefix_tl
%}
-% Header information for storing the ``paths'' to parts of a message.
+% Header information for storing the `paths' to parts of a message.
+% Although these are marked as constants, they could be changed for
+% printing errors in a different language.
%\end{variable}
%
%\begin{variable}{
-% \l_msg_class_tl|
-% \l_msg_current_class_tl
+% \l_msg_class_tl |
+% \l_msg_current_class_tl |
+% \l_msg_current_module_tl
%}
% Information about message method, used for filtering.
%\end{variable}
@@ -491,7 +520,7 @@
%\end{variable}
%
%\begin{variable}{
-% \l_msg_redirect_classes_prop|
+% \l_msg_redirect_classes_prop |
% \l_msg_redirect_names_prop
%}
% Re-direction lists containing the class of message to convert an
@@ -531,16 +560,17 @@
%\begin{macro}{\c_msg_info_tl}
% Header information.
% \begin{macrocode}
-\tl_new:Nn \c_msg_fatal_tl { Fatal~Error }
-\tl_new:Nn \c_msg_error_tl { Error }
-\tl_new:Nn \c_msg_warning_tl { Warning }
-\tl_new:Nn \c_msg_info_tl { Info }
+\tl_const:Nn \c_msg_fatal_tl { Fatal~Error }
+\tl_const:Nn \c_msg_error_tl { Error }
+\tl_const:Nn \c_msg_warning_tl { Warning }
+\tl_const:Nn \c_msg_info_tl { Info }
% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
+%\begin{macro}{\c_msg_coding_error_text_tl}
%\begin{macro}{\c_msg_fatal_text_tl}
%\begin{macro}{\c_msg_help_text_tl}
%\begin{macro}{\c_msg_kernel_bug_text_tl}
@@ -549,26 +579,30 @@
%\begin{macro}{\c_msg_return_text_tl}
% Simple pieces of text for messages.
% \begin{macrocode}
-\tl_new:Nn \c_msg_fatal_text_tl {
+\tl_const:Nn \c_msg_coding_error_text_tl {
+ This~is~a~coding~error.
+ \msg_two_newlines:
+}
+\tl_const:Nn \c_msg_fatal_text_tl {
This~is~a~fatal~error:~LaTeX~will~abort
}
-\tl_new:Nn \c_msg_help_text_tl {
+\tl_const:Nn \c_msg_help_text_tl {
For~immediate~help~type~H~<return>
}
-\tl_new:Nn \c_msg_kernel_bug_text_tl {
+\tl_const:Nn \c_msg_kernel_bug_text_tl {
This~is~a~LaTeX~bug:~check~coding!
}
-\tl_new:Nn \c_msg_kernel_bug_more_text_tl {
+\tl_const:Nn \c_msg_kernel_bug_more_text_tl {
There~is~a~coding~bug~somewhere~around~here.
\msg_newline:
This~probably~needs~examining~by~an~expert.
\c_msg_return_text_tl
}
-\tl_new:Nn \c_msg_no_info_text_tl {
+\tl_const:Nn \c_msg_no_info_text_tl {
LaTeX~does~not~know~anything~more~about~this~error,~sorry.
\c_msg_return_text_tl
}
-\tl_new:Nn \c_msg_return_text_tl {
+\tl_const:Nn \c_msg_return_text_tl {
\msg_two_newlines:
Try~typing~<return>~to~proceed.
\msg_newline:
@@ -577,6 +611,7 @@
% \end{macrocode}
%\end{macro}
%\end{macro}
+%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
@@ -587,13 +622,13 @@
% end of its name. This is used to push the \TeX\ part of an error
% message ``off the screen''.
%
-% No indentation here as \verb*| | is a letter!
+% No indentation here as \verb*" " is a letter!
% \begin{macrocode}
\group_begin:
\char_make_letter:N\ %
\tl_to_lowercase:n{%
\group_end:%
-\tl_new:Nn%
+\tl_const:Nn%
\c_msg_hide_tl %
{}%
}%
@@ -603,7 +638,7 @@
%\begin{macro}{\c_msg_on_line_tl}
% Text for ``on line''.
% \begin{macrocode}
-\tl_new:Nn \c_msg_on_line_tl { on~line }
+\tl_const:Nn \c_msg_on_line_tl { on~line }
% \end{macrocode}
%\end{macro}
%
@@ -611,21 +646,24 @@
%\begin{macro}{\c_msg_more_text_prefix_tl}
% Prefixes for storage areas.
% \begin{macrocode}
-\tl_new:Nn \c_msg_text_prefix_tl { msg_text ~>~ }
-\tl_new:Nn \c_msg_more_text_prefix_tl { msg_text_more ~>~ }
+\tl_const:Nn \c_msg_text_prefix_tl { msg_text ~>~ }
+\tl_const:Nn \c_msg_more_text_prefix_tl { msg_text_more ~>~ }
% \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_msg_class_tl}
%\begin{macro}{\l_msg_current_class_tl}
+%\begin{macro}{\l_msg_current_module_tl}
% For holding the current message method and that for redirection.
% \begin{macrocode}
\tl_new:N \l_msg_class_tl
\tl_new:N \l_msg_current_class_tl
+\tl_new:N \l_msg_current_module_tl
% \end{macrocode}
%\end{macro}
%\end{macro}
+%\end{macro}
%
%\begin{macro}{\l_msg_names_clist}
% Lists used for filtering.
@@ -651,6 +689,13 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\l_msg_tmp_tl}
+% A scratch variable.
+% \begin{macrocode}
+\tl_new:N \l_msg_tmp_tl
+% \end{macrocode}
+%\end{macro}
+%
% \subsection{Output helper functions}
%
%\begin{macro}{\msg_line_number:}
@@ -662,7 +707,7 @@
}
\cs_new_nopar:Npn \msg_line_context: {
\c_msg_on_line_tl
- \msg_space:
+ \c_space_tl
\msg_line_number:
}
% \end{macrocode}
@@ -678,21 +723,6 @@
% \end{macrocode}
%\end{macro}
%\end{macro}
-%
-%\begin{macro}{\msg_space:}
-%\begin{macro}{\msg_two_spaces:}
-%\begin{macro}{\msg_four_spaces:}
-% For printing spaces, some very simple functions.
-% \begin{macrocode}
-\cs_new_nopar:Npn \msg_space: { ~ }
-\cs_new_nopar:Npn \msg_two_spaces: { \msg_space: \msg_space: }
-\cs_new_nopar:Npn \msg_four_spaces: {
- \msg_two_spaces: \msg_two_spaces:
-}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
%
%\subsection{Generic functions}
%
@@ -704,11 +734,11 @@
% Creating a new message is basically the same as the non-checking
% version, and so after a check everything hands over.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_generic_new:nnn #1 {
+\cs_new_protected_nopar:Npn \msg_generic_new:nnn #1 {
\chk_if_free_cs:c { \c_msg_text_prefix_tl #1 :xxxx }
\msg_generic_set:nnn {#1}
}
-\cs_new_nopar:Npn \msg_generic_new:nn #1 {
+\cs_new_protected_nopar:Npn \msg_generic_new:nn #1 {
\chk_if_free_cs:c { \c_msg_text_prefix_tl #1 :xxxx }
\msg_generic_set:nn {#1}
}
@@ -719,42 +749,28 @@
%\begin{macro}{\msg_generic_set:nnn}
%\begin{macro}{\msg_generic_set:nn}
%\begin{macro}[aux]{\msg_generic_set_clist:n}
-%\begin{macro}[aux]{\msg_generic_set_text:n}
-%\begin{macro}[aux]{\msg_generic_set_more_text:n}
% Creating a message is quite simple. There must be a short text part,
% while the longer text may or may not be available.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_generic_set:nnn #1 {
+\cs_new_protected_nopar:Npn \msg_generic_set:nnn #1#2#3 {
\msg_generic_set_clist:n {#1}
- \char_make_space:N \
- \msg_generic_set_more_text:nnn {#1}
+ \cs_set:cpn { \c_msg_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#2}
+ \cs_set:cpn { \c_msg_more_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#3}
}
-\cs_new_nopar:Npn \msg_generic_set:nn #1 {
+\cs_new_protected_nopar:Npn \msg_generic_set:nn #1#2 {
\msg_generic_set_clist:n {#1}
- \char_make_space:N \
- \msg_generic_set_text:nn {#1}
+ \cs_set:cpn { \c_msg_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#2}
+ \cs_set_eq:cN { \c_msg_more_text_prefix_tl #1 :xxxx } \c_undefined
}
-\cs_new_nopar:Npn \msg_generic_set_clist:n #1 {
+\cs_new_protected_nopar:Npn \msg_generic_set_clist:n #1 {
\clist_if_in:NnF \l_msg_names_clist { // #1 / } {
\clist_put_right:Nn \l_msg_names_clist { // #1 / }
}
}
-\cs_new:Npn \msg_generic_set_text:nn #1#2 {
- \cs_set:cpn { \c_msg_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#2}
- \cs_set_eq:cN { \c_msg_more_text_prefix_tl #1 :xxxx } \c_undefined
- \char_make_ignore:N \
-}
-\cs_new:Npn \msg_generic_set_more_text:nnn #1#2#3 {
- \cs_set:cpn { \c_msg_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#2}
- \cs_set:cpn { \c_msg_more_text_prefix_tl #1 :xxxx } ##1##2##3##4 {#3}
- \char_make_ignore:N \
-}
% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\end{macro}
-%\end{macro}
%
%\begin{macro}{\msg_direct_interrupt:xxxx}
%\begin{macro}[aux]{\msg_direct_interrupt:n}
@@ -764,7 +780,7 @@
% spaces have to be letters: hence no indentation. The odd
% \cs{c_msg_hide_tl<spaces>} actually does the hiding: it is the
% large run of spaces in the name that is important here. The meaning
-% of |\\| is altered so that the explanation text is a simple run
+% of "\\" is altered so that the explanation text is a simple run
% whilst the initial error has line-continuation shown.
% \begin{macrocode}
\group_begin:
@@ -777,7 +793,7 @@
\cs_new_protected:Npn\msg_direct_interrupt:xxxx#1#2#3#4{%
\group_begin:%
\cs_set_eq:NN\\\msg_newline:%
-\cs_set_eq:NN\ \msg_space:%
+\cs_set_eq:NN\ \c_space_tl%
\msg_direct_interrupt_aux:n{#4}%
\cs_set_nopar:Npn\\{\msg_newline:#3}%
\tex_errhelp:D\l_msg_tmp_tl%
@@ -793,7 +809,7 @@
\group_end:%
}%
}%
-\cs_new:Npn \msg_direct_interrupt_aux:n #1 {
+\cs_new_protected:Npn \msg_direct_interrupt_aux:n #1 {
\tl_if_empty:nTF {#1} {
\tl_set:Nx \l_msg_tmp_tl { { \c_msg_no_info_text_tl } }
}{
@@ -811,14 +827,14 @@
\cs_new_protected:Npn \msg_direct_log:xx #1#2 {
\group_begin:
\cs_set:Npn \\ { \msg_newline: #2 }
- \cs_set_eq:NN \ \msg_space:
+ \cs_set_eq:NN \ \c_space_tl
\iow_log:x { #1 \msg_newline: }
\group_end:
}
\cs_new_protected:Npn \msg_direct_term:xx #1#2 {
\group_begin:
\cs_set:Npn \\ { \msg_newline: #2 }
- \cs_set_eq:NN \ \msg_space:
+ \cs_set_eq:NN \ \c_space_tl
\iow_term:x { #1 \msg_newline: }
\group_end:
}
@@ -838,16 +854,16 @@
%\begin{macro}{\msg_set:nnn}
% For making messages: all aliases.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_new:nnnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_new:nnnn #1#2 {
\msg_generic_new:nnn { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_new:nnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_new:nnn #1#2 {
\msg_generic_new:nn { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_set:nnnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_set:nnnn #1#2 {
\msg_generic_set:nnn { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_set:nnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_set:nnn #1#2 {
\msg_generic_set:nn { #1 / #2 }
}
% \end{macrocode}
@@ -862,12 +878,12 @@
% numbers of arguments. The \cs{msg_class_loop:n} function is set up
% so that redirection will work as desired.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_class_new:nn #1 {
+\cs_new_protected_nopar:Npn \msg_class_new:nn #1 {
\chk_if_free_cs:c { msg_ #1 :nnxxxx }
\prop_new:c { l_msg_redirect_ #1 _prop }
\msg_class_set:nn {#1}
}
-\cs_new_nopar:Npn \msg_class_set:nn #1#2 {
+\cs_new_protected_nopar:Npn \msg_class_set:nn #1#2 {
\prop_clear:c { l_msg_redirect_ #1 _prop }
\cs_set_protected:cpn { msg_ #1 :nnxxxx } ##1##2##3##4##5##6 {
\msg_use:nnnnxxxx {#1} {#2} {##1} {##2} {##3} {##4} {##5} {##6}
@@ -895,7 +911,7 @@
% There is then a hand-off to the system for checking if redirection is
% needed.
% \begin{macrocode}
-\cs_new:Npn \msg_use:nnnnxxxx #1#2#3#4#5#6#7#8 {
+\cs_new_protected:Npn \msg_use:nnnnxxxx #1#2#3#4#5#6#7#8 {
\cs_set_nopar:Npn \msg_use_code: {
\clist_clear:N \l_msg_redirect_classes_clist
#2
@@ -935,7 +951,7 @@
% The first auxiliary macro looks for a match by name: the most
% restrictive check.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_use_aux:nnn #1#2#3 {
+\cs_new_protected_nopar:Npn \msg_use_aux:nnn #1#2#3 {
\tl_set:Nn \l_msg_current_class_tl {#1}
\tl_set:Nn \l_msg_current_module_tl {#2}
\prop_if_in:NnTF \l_msg_redirect_names_prop { // #2 / #3 / } {
@@ -950,7 +966,7 @@
% The second function checks for general matches by module or for
% all modules.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_use_aux:nn #1#2 {
+\cs_new_protected_nopar:Npn \msg_use_aux:nn #1#2 {
\prop_if_in:cnTF { l_msg_redirect_ #1 _prop } {#2} {
\msg_use_loop_check:nn {#1} {#2}
}{
@@ -967,7 +983,7 @@
% When checking whether to loop, the same code is needed in a few
% places.
% \begin{macrocode}
-\cs_new:Npn \msg_use_loop_check:nn #1#2 {
+\cs_new_protected:Npn \msg_use_loop_check:nn #1#2 {
\prop_get:cnN { l_msg_redirect_ #1 _prop } {#2} \l_msg_class_tl
\tl_if_eq:NNTF \l_msg_current_class_tl \l_msg_class_tl {
\msg_use_code:
@@ -989,10 +1005,10 @@
\msg_direct_interrupt:xxxx
{ \c_msg_fatal_tl \msg_two_newlines: }
{
- ( \c_msg_fatal_tl ) \msg_space:
+ ( \c_msg_fatal_tl ) \c_space_tl
\use:c { \c_msg_text_prefix_tl #1 / #2 :xxxx } {#3} {#4} {#5} {#6}
}
- { ( \c_msg_fatal_tl ) \msg_space: }
+ { ( \c_msg_fatal_tl ) \c_space_tl }
{ \c_msg_fatal_text_tl }
\tex_end:D
}
@@ -1015,10 +1031,10 @@
\msg_direct_interrupt:xxxx
{ #1~\c_msg_error_tl \msg_newline: }
{
- ( #1 ) \msg_space:
+ ( #1 ) \c_space_tl
\use:c { \c_msg_text_prefix_tl #1 / #2 :xxxx } {#3} {#4} {#5} {#6}
}
- { ( #1 ) \msg_space: }
+ { ( #1 ) \c_space_tl }
{
\cs_if_exist:cTF { \c_msg_more_text_prefix_tl #1 / #2 :xxxx }
{
@@ -1044,10 +1060,10 @@
% \begin{macrocode}
\msg_class_new:nn { warning } {
\msg_direct_term:xx {
- \msg_space: #1 ~ \c_msg_warning_tl :~
+ \c_space_tl #1 ~ \c_msg_warning_tl :~
\use:c { \c_msg_text_prefix_tl #1 / #2 :xxxx } {#3} {#4} {#5} {#6}
}
- { ( #1 ) \msg_two_spaces: }
+ { ( #1 ) \c_space_tl \c_space_tl }
}
% \end{macrocode}
%\end{macro}
@@ -1065,10 +1081,10 @@
% \begin{macrocode}
\msg_class_new:nn { info } {
\msg_direct_log:xx {
- \msg_space: #1~\c_msg_info_tl :~
+ \c_space_tl #1~\c_msg_info_tl :~
\use:c { \c_msg_text_prefix_tl #1 / #2 :xxxx } {#3} {#4} {#5} {#6}
}
- { ( #1 ) \msg_two_spaces: }
+ { ( #1 ) \c_space_tl \c_space_tl }
}
% \end{macrocode}
%\end{macro}
@@ -1138,7 +1154,7 @@
%\begin{macro}{\msg_redirect_class:nn}
% Converts class one into class two.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_redirect_class:nn #1#2 {
+\cs_new_protected_nopar:Npn \msg_redirect_class:nn #1#2 {
\prop_put:cnn { l_msg_redirect_ #1 _prop } { * } {#2}
}
% \end{macrocode}
@@ -1147,7 +1163,7 @@
%\begin{macro}{\msg_redirect_module:nnn}
% For when all messages of a class should be altered for a given module.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_redirect_module:nnn #1#2#3 {
+\cs_new_protected_nopar:Npn \msg_redirect_module:nnn #1#2#3 {
\prop_put:cnn { l_msg_redirect_ #2 _prop } {#1} {#3}
}
% \end{macrocode}
@@ -1156,7 +1172,7 @@
%\begin{macro}{\msg_redirect_name:nnn}
% Named message will always use the given class.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_redirect_name:nnn #1#2#3 {
+\cs_new_protected_nopar:Npn \msg_redirect_name:nnn #1#2#3 {
\prop_put:Nnn \l_msg_redirect_names_prop { // #1 / #2 / } {#3}
}
% \end{macrocode}
@@ -1172,16 +1188,16 @@
% pre-built functions. Two functions are provided: one more general
% and one which only has the short text part.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_kernel_new:nnnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_kernel_new:nnnn #1#2 {
\msg_new:nnnn { LaTeX } { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_kernel_new:nnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_kernel_new:nnn #1#2 {
\msg_new:nnn { LaTeX } { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_kernel_set:nnnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_kernel_set:nnnn #1#2 {
\msg_set:nnnn { LaTeX } { #1 / #2 }
}
-\cs_new_nopar:Npn \msg_kernel_set:nnn #1#2 {
+\cs_new_protected_nopar:Npn \msg_kernel_set:nnn #1#2 {
\msg_set:nnn { LaTeX } { #1 / #2 }
}
% \end{macrocode}
@@ -1193,7 +1209,7 @@
%\begin{macro}[aux]{\msg_kernel_classes_new:n}
% Quickly make the fewer-arguments versions.
% \begin{macrocode}
-\cs_new_nopar:Npn \msg_kernel_classes_new:n #1 {
+\cs_new_protected_nopar:Npn \msg_kernel_classes_new:n #1 {
\cs_new_protected:cpx { msg_kernel_ #1 :nnxxx } ##1##2##3##4##5
{
\exp_not:c { msg_kernel_ #1 :nnxxxx }
@@ -1227,11 +1243,11 @@
\msg_direct_interrupt:xxxx
{ \c_msg_fatal_tl \msg_two_newlines: }
{
- ( LaTeX ) \msg_space:
+ ( LaTeX ) \c_space_tl
\use:c { \c_msg_text_prefix_tl LaTeX / #1 / #2 :xxxx }
{#3} {#4} {#5} {#6}
}
- { ( LaTeX ) \msg_space: }
+ { ( LaTeX ) \c_space_tl}
{ \c_msg_fatal_text_tl }
\tex_end:D
}
@@ -1254,11 +1270,11 @@
\msg_direct_interrupt:xxxx
{ LaTeX~\c_msg_error_tl \msg_newline: }
{
- ( LaTeX ) \msg_space:
+ ( LaTeX ) \c_space_tl
\use:c { \c_msg_text_prefix_tl LaTeX / #1 / #2 :xxxx }
{#3} {#4} {#5} {#6}
}
- { ( LaTeX ) \msg_space: }
+ { ( LaTeX ) \c_space_tl }
{
\cs_if_exist:cTF
{ \c_msg_more_text_prefix_tl LaTeX / #1 / #2 :xxxx }
@@ -1314,27 +1330,26 @@
% itself.
% \begin{macrocode}
\msg_kernel_new:nnnn { msg } { message-unknown }
- {Unknown message `#2' for module `#1'.}
- {%
- LaTeX was asked to display a message by the `#1' module.\\%
- The message was supposed to be called `#2', but I can't\\%
- find a message with that name.%
+ { Unknown~message~'#2'~for~module~'#1'.}
+ {
+ \c_msg_coding_error_text_tl
+ LaTeX~was~asked~to~display~a~message~called~'#2'\\
+ by~the~module~'#1'~module:~this~message~does~not~exist.
\c_msg_return_text_tl
}
-\msg_kernel_new:nnnn { msg } { message-class-unknown }
- {Unknown message class `#1'.}
- {%
- You have asked for a message to be redirected to class `#1'.\\%
- The message class `#1' has not been set up:\\%
- perhaps this is a typing error.%
+\msg_kernel_new:nnnn { msg } { message-class-unknown }
+ { Unknown~message~class~'#1'. }
+ {
+ LaTeX~has~been~asked~to~redirect~messages~to~a~class~'#1':\\
+ this~was~never~defined.
+
\c_msg_return_text_tl
}
\msg_kernel_new:nnnn { msg } { redirect-loop }
- {Message redirection loop for message class `#1'.}
- {%
- You have asked for a message to be redirected,\\%
- but the redirection instructions form a loop:\\%
- you've lost the message.%
+ { Message~redirection~loop~for~message~class~'#1'. }
+ {
+ LaTeX~has~been~asked~to~redirect~messages~in~an~infinite~loop.\\
+ The~original~message~here~has~been~lost.
\c_msg_return_text_tl
}
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3names.dtx b/Master/texmf-dist/source/latex/expl3/l3names.dtx
index 9f8739ee3cd..651be378791 100644
--- a/Master/texmf-dist/source/latex/expl3/l3names.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3names.dtx
@@ -39,10 +39,36 @@
\catcode`\#=6 % hash mark is macro parameter character
\catcode`\^=7 % circumflex is superscript character
\catcode`\^^I=10 % ascii tab is a blank space
+% Make \pdfstrcmp available in luatex
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
+\else
+ \directlua
+ {
+ tex.enableprimitives('',tex.extraprimitives ())
+ lua.bytecode[1]=function ()
+ function pdfstrcmp (A, B)
+ if A == B then
+ tex.write("0")
+ elseif A < B then
+ tex.write("-1")
+ else
+ tex.write("1")
+ end
+ end
+ end
+ lua.bytecode[1]()
+ }
+ \everyjob{\directlua{lua.bytecode[1]()}}
+ \long\def\pdfstrcmp#1#2{%
+ \directlua
+ {pdfstrcmp("\luaescapestring{#1}","\luaescapestring{#2}")}%
+ }
+\fi
%</initex>
%<package>\begingroup
%<*initex|package>
-\def\GetIdInfo$#1${%
+\protected\def\GetIdInfo$#1${%
\begingroup
\def\GetIdInfoString{#1}%
\def\IdInfoStringUnexp{Id}%
@@ -53,10 +79,10 @@
\fi
\next
}
-\def\GetIdInfoFull$#1 #2.#3 #4 #5 #6 #7${%
+\protected\def\GetIdInfoFull$#1 #2.#3 #4 #5 #6 #7${%
\GetIdInfoAux #5\relax{#2}#5\relax{#4}%
}
-\def\GetIdInfoAux #1#2#3#4#5#6\relax{%
+\protected\def\GetIdInfoAux #1#2#3#4#5#6\relax{%
\ifx#5/%
\expandafter\GetIdInfoAuxCVS
\else
@@ -65,13 +91,13 @@
}
%</initex|package>
%<*initex>
-\def\GetIdInfoAuxCVS #1#2\relax#3#4{%
+\protected\def\GetIdInfoAuxCVS #1#2\relax#3#4{%
\immediate\write-1{#1; v#2, #3; #4}%
}
-\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{%
+\protected\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{%
\immediate\write-1{#1; #2/#3/#4 v#5 #6}%
}
-\def\GetIdInfoMissing#1{%
+\protected\def\GetIdInfoMissing#1{%
\gdef\fileversion{000}%
\gdef\filedate{0000/00/00}%
\gdef\filedescription{#1}%
@@ -79,19 +105,19 @@
}
%</initex>
%<*package>
-\def\GetIdInfoAuxCVS #1#2\relax#3#4{%
+\protected\def\GetIdInfoAuxCVS #1#2\relax#3#4{%
\gdef\fileversion{#3}%
\gdef\filedate{#2}%
\gdef\filedescription{#4}%
\ProvidesPackage{#1}[#2 v#3 #4]%
}
-\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{%
+\protected\def\GetIdInfoAuxSVN #1#2-#3-#4\relax#5#6{%
\gdef\fileversion{#5}%
\gdef\filedate{#2/#3/#4}%
\gdef\filedescription{#6}%
\ProvidesPackage{#1}[#2/#3/#4 v#5 #6]
}
-\def\GetIdInfoMissing#1{%
+\protected\def\GetIdInfoMissing#1{%
\gdef\fileversion{000}%
\gdef\filedate{0000/00/00}%
\gdef\filedescription{#1}%
@@ -102,7 +128,7 @@
\RequirePackage{l3names}
%</driver>
%\fi
-\GetIdInfo$Id: l3names.dtx 1751 2009-11-26 08:36:12Z joseph $
+\GetIdInfo$Id: l3names.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental Naming Scheme for TeX Primitives}
%
%
@@ -288,7 +314,7 @@
% catcode regime as it was when we start changing it.
% \begin{macrocode}
%<*initex|package>
-\edef\ExplSyntaxOff{
+\protected\edef\ExplSyntaxOff{
\unexpanded{\ifodd \ExplSyntaxStatus\relax
\def\ExplSyntaxStatus{0}
}
@@ -941,10 +967,10 @@
% \end{itemize}
%
% \begin{macrocode}
-\tex_def:D \ExplSyntaxOn {
+\etex_protected:D \tex_def:D \ExplSyntaxOn {
\tex_ifodd:D \ExplSyntaxStatus \tex_relax:D
\tex_else:D
- \tex_edef:D \ExplSyntaxOff {
+ \etex_protected:D \tex_edef:D \ExplSyntaxOff {
\etex_unexpanded:D{
\tex_ifodd:D \ExplSyntaxStatus \tex_relax:D
\tex_def:D \ExplSyntaxStatus{0}
@@ -981,11 +1007,11 @@
% \LaTeX3 without adhering it's conventions according to space
% characters. These macros provide the necessary settings.
% \begin{macrocode}
-\tex_def:D \ExplSyntaxNamesOn {
+\etex_protected:D \tex_def:D \ExplSyntaxNamesOn {
\tex_catcode:D `\_=11\tex_relax:D
\tex_catcode:D `\:=11\tex_relax:D
}
-\tex_def:D \ExplSyntaxNamesOff {
+\etex_protected:D \tex_def:D \ExplSyntaxNamesOff {
\tex_catcode:D `\_=8\tex_relax:D
\tex_catcode:D `\:=12\tex_relax:D
}
@@ -1015,7 +1041,7 @@
% else svn and we extract information. To be on the safe side we
% ensure that spaces in the argument are seen.
% \begin{macrocode}
-\tex_def:D \GetIdInfo {
+\etex_protected:D \tex_def:D \GetIdInfo {
\tex_begingroup:D
\tex_catcode:D 32=10 \tex_relax:D % needed? Probably for now.
\GetIdInfoMaybeMissing:w
@@ -1023,11 +1049,11 @@
% \end{macrocode}
%
% \begin{macrocode}
-\tex_def:D\GetIdInfoMaybeMissing:w$#1$#2{
- \tex_def:D \l_tmpa_tl {#1}
- \tex_def:D \l_tmpb_tl {Id}
- \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
- \tex_def:D \l_tmpa_tl {
+\etex_protected:D \tex_def:D\GetIdInfoMaybeMissing:w$#1$#2{
+ \tex_def:D \l_kernel_tmpa_tl {#1}
+ \tex_def:D \l_kernel_tmpb_tl {Id}
+ \tex_ifx:D \l_kernel_tmpa_tl \l_kernel_tmpb_tl
+ \tex_def:D \l_kernel_tmpa_tl {
\tex_endgroup:D
\tex_def:D\filedescription{#2}
\tex_def:D\filename {[unknown~name]}
@@ -1038,14 +1064,14 @@
\tex_def:D\filetimestamp {[unknown~timestamp]}
}
\tex_else:D
- \tex_def:D \l_tmpa_tl {\GetIdInfoAuxi:w$#1${#2}}
+ \tex_def:D \l_kernel_tmpa_tl {\GetIdInfoAuxi:w$#1${#2}}
\tex_fi:D
- \l_tmpa_tl
+ \l_kernel_tmpa_tl
}
% \end{macrocode}
%
% \begin{macrocode}
-\tex_def:D\GetIdInfoAuxi:w$#1~#2.#3~#4~#5~#6~#7~#8$#9{
+\etex_protected:D \tex_def:D\GetIdInfoAuxi:w$#1~#2.#3~#4~#5~#6~#7~#8$#9{
\tex_endgroup:D
\tex_def:D\filename{#2}
\tex_def:D\fileversion{#4}
@@ -1057,7 +1083,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\tex_def:D\GetIdInfoAuxii:w #1#2#3#4#5#6\tex_relax:D{
+\etex_protected:D \tex_def:D\GetIdInfoAuxii:w #1#2#3#4#5#6\tex_relax:D{
\tex_ifx:D#5/
\tex_expandafter:D\GetIdInfoAuxCVS:w
\tex_else:D
@@ -1067,7 +1093,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\tex_def:D\GetIdInfoAuxCVS:w #1,v\tex_relax:D
+\etex_protected:D \tex_def:D\GetIdInfoAuxCVS:w #1,v\tex_relax:D
#2\tex_relax:D#3\tex_relax:D{
\tex_def:D\filedate{#2}
\tex_def:D\filenameext{#1}
@@ -1079,7 +1105,7 @@
%<initex>\tex_immediate:D\tex_write:D-1
%<initex> {\filename;~ v\fileversion,~\filedate;~\filedescription}
}
-\tex_def:D\GetIdInfoAuxSVN:w #1\tex_relax:D#2-#3-#4
+\etex_protected:D \tex_def:D\GetIdInfoAuxSVN:w #1\tex_relax:D#2-#3-#4
\tex_relax:D#5Z\tex_relax:D{
\tex_def:D\filenameext{#1}
\tex_def:D\filedate{#2/#3/#4}
@@ -1112,7 +1138,7 @@
% as the packages in this distribution do like this:
% \begin{verbatim}
% \RequirePackage{l3names}
-% \GetIdInfo$Id: l3names.dtx 1751 2009-11-26 08:36:12Z joseph $
+% \GetIdInfo$Id: l3names.dtx 1853 2010-03-21 09:11:08Z joseph $
% {L3 Experimental Box module}
% \ProvidesExplPackage
% {\filename}{\filedate}{\fileversion}{\filedescription}
@@ -1126,15 +1152,15 @@
% options just yet.
% \begin{macrocode}
%<*package>
-\tex_def:D \ProvidesExplPackage#1#2#3#4{
+\etex_protected:D \tex_def:D \ProvidesExplPackage#1#2#3#4{
\ProvidesPackage{#1}[#2~v#3~#4]
\ExplSyntaxOn
}
-\tex_def:D \ProvidesExplClass#1#2#3#4{
+\etex_protected:D \tex_def:D \ProvidesExplClass#1#2#3#4{
\ProvidesClass{#1}[#2~v#3~#4]
\ExplSyntaxOn
}
-\tex_def:D \ProvidesExplFile#1#2#3#4{
+\etex_protected:D \tex_def:D \ProvidesExplFile#1#2#3#4{
\ProvidesFile{#1}[#2~v#3~#4]
\ExplSyntaxOn
}
@@ -1230,7 +1256,7 @@
% stack is initially empty set to 0 signalling that before
% \pkg{l3names} was loaded, the ExplSyntax was off.
% \begin{macrocode}
-\tex_def:D\ExplSyntaxPopStack#1#2\q_nil{
+\etex_protected:D\tex_def:D\ExplSyntaxPopStack#1#2\q_nil{
\tex_def:D\ExplSyntaxStack{#2}
\tex_ifodd:D#1\tex_relax:D
\ExplSyntaxOn
@@ -1342,7 +1368,7 @@
% used to ensure that one of the "l3" packages isn't loaded on its own.
% \begin{macrocode}
%<*!initex>
-\tex_def:D \package_check_loaded_expl: {
+\etex_protected:D\tex_def:D \package_check_loaded_expl: {
\@ifpackageloaded{expl3}{}{
\PackageError{expl3}{Cannot~load~the~expl3~modules~separately}{
The~expl3~modules~cannot~be~loaded~separately;\MessageBreak
diff --git a/Master/texmf-dist/source/latex/expl3/l3num.dtx b/Master/texmf-dist/source/latex/expl3/l3num.dtx
index 138acc0f3cf..a17b7768cc5 100644
--- a/Master/texmf-dist/source/latex/expl3/l3num.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3num.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3num.dtx Copyright (C) 2005-2009 Frank Mittelbach, LaTeX3 project
+%% File: l3num.dtx Copyright (C) 2005-2010 Frank Mittelbach, 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3num.dtx 1451 2009-08-08 06:33:34Z joseph $
+\GetIdInfo$Id$
{L3 Experimental token numbers}
%\iffalse
%<*driver>
@@ -271,11 +271,6 @@
% These are the \TeX{} primitives \tn{ifcase} and \tn{or}.
% \end{texnote}
% \end{function}
-%
-%^^A Keep the documenation-checking happy
-%\ExplSyntaxOn
-%\seq_gput_right:Nx \g_doc_macros_seq { \token_to_str:N \or: }
-%\ExplSyntaxOff
%
% \end{documentation}
%
@@ -299,8 +294,8 @@
% Here are the remaining primitives for number comparisons and
% expressions.
% \begin{macrocode}
-\cs_new_eq:NN \if_num:w \tex_ifnum:D
-\cs_new_eq:NN \if_case:w \tex_ifcase:D
+\cs_set_eq:NN \if_num:w \tex_ifnum:D
+\cs_set_eq:NN \if_case:w \tex_ifcase:D
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -315,10 +310,10 @@
% Incrementing and decrementing of integer registers is done with
% the following functions.
% \begin{macrocode}
-\cs_set_nopar:Npn \num_incr:N #1{\num_add:Nn#1 1}
-\cs_set_nopar:Npn \num_decr:N #1{\num_add:Nn#1 \c_minus_one}
-\cs_set_nopar:Npn \num_gincr:N #1{\num_gadd:Nn#1 1}
-\cs_set_nopar:Npn \num_gdecr:N #1{\num_gadd:Nn#1 \c_minus_one}
+\cs_set_protected_nopar:Npn \num_incr:N #1{\num_add:Nn#1 1}
+\cs_set_protected_nopar:Npn \num_decr:N #1{\num_add:Nn#1 \c_minus_one}
+\cs_set_protected_nopar:Npn \num_gincr:N #1{\num_gadd:Nn#1 1}
+\cs_set_protected_nopar:Npn \num_gdecr:N #1{\num_gadd:Nn#1 \c_minus_one}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -347,8 +342,8 @@
% \begin{macro}{\num_gzero:c}
% We also need \ldots
% \begin{macrocode}
-\cs_new_nopar:Npn \num_zero:N #1 {\num_set:Nn #1 0}
-\cs_new_nopar:Npn \num_gzero:N #1 {\num_gset:Nn #1 0}
+\cs_new_protected_nopar:Npn \num_zero:N #1 {\num_set:Nn #1 0}
+\cs_new_protected_nopar:Npn \num_gzero:N #1 {\num_gset:Nn #1 0}
% \end{macrocode}
%
% \begin{macrocode}
@@ -366,7 +361,7 @@
% \begin{macro}{\num_new:c}
% Allocate a new \m{num} variable and initialize it with zero.
% \begin{macrocode}
-\cs_new_nopar:Npn \num_new:N #1{\tl_new:Nn #1{0}}
+\cs_new_protected_nopar:Npn \num_new:N #1{\tl_new:Nn #1{0}}
\cs_generate_variant:Nn \num_new:N {c}
% \end{macrocode}
% \end{macro}
@@ -378,14 +373,14 @@
% \begin{macro}{\num_gset:cn}
% Assigning values to \m{num} registers.
% \begin{macrocode}
-\cs_new_nopar:Npn \num_set:Nn #1#2{
+\cs_new_protected_nopar:Npn \num_set:Nn #1#2{
\tl_set:No #1{ \tex_number:D \intexpr_eval:n {#2} }
}
\cs_generate_variant:Nn\num_set:Nn {c}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \num_gset:Nn {\pref_global:D \num_set:Nn}
+\cs_new_protected_nopar:Npn \num_gset:Nn {\pref_global:D \num_set:Nn}
\cs_generate_variant:Nn\num_gset:Nn {c}
% \end{macrocode}
% \end{macro}
@@ -428,12 +423,12 @@
% Adding is easily done as the second argument goes through
% |\intexpr_eval:n|.
% \begin{macrocode}
-\cs_new_nopar:Npn \num_add:Nn #1#2 {\num_set:Nn #1{#1+#2}}
+\cs_new_protected_nopar:Npn \num_add:Nn #1#2 {\num_set:Nn #1{#1+#2}}
\cs_generate_variant:Nn\num_add:Nn {c}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \num_gadd:Nn {\pref_global:D \num_add:Nn}
+\cs_new_protected_nopar:Npn \num_gadd:Nn {\pref_global:D \num_add:Nn}
\cs_generate_variant:Nn\num_gadd:Nn {c}
% \end{macrocode}
% \end{macro}
diff --git a/Master/texmf-dist/source/latex/expl3/l3precom.dtx b/Master/texmf-dist/source/latex/expl3/l3precom.dtx
index d5b39b0b12e..5ee345dc70c 100644
--- a/Master/texmf-dist/source/latex/expl3/l3precom.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3precom.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3precom.dtx 1453 2009-08-08 14:38:49Z joseph $
+\GetIdInfo$Id: l3precom.dtx 1793 2010-02-09 20:36:19Z joseph $
{L3 Experimental precompilation module}
%\iffalse
%<*driver>
@@ -152,7 +152,7 @@
% Sequence in which the symbols to be dumped are stored.
% \end{variable}
%
-% \begin{variable}{\c_cs_dump_stream}
+% \begin{variable}{\g_cs_dump_stream}
% Output stream used for writing out the definitions of the
% recorded <tl var.>.
% \end{variable}
@@ -179,32 +179,20 @@
%
% We start by ensuring that the required packages are loaded.
% \begin{macrocode}
-%<package>\ProvidesExplPackage
-%<package> {\filename}{\filedate}{\fileversion}{\filedescription}
-%<package>\RequirePackage{l3num}
-%<package>\RequirePackage{l3io}
-%<package>\RequirePackage{l3seq}
-%<package>\RequirePackage{l3int}
+%<*package>
+\ProvidesExplPackage
+ {\filename}{\filedate}{\fileversion}{\filedescription}
+\package_check_loaded_expl:
+%</package>
% \end{macrocode}
%
-% \begin{macro}{\c_cs_dump_stream}
-% We need to allocate an output stream in order to be able to write
-% the precompiled code out.
-% Stream number for the dump.
-%
-% \begin{macrocode}
-%<*initex|package>
-%<*precompile>
-\iow_new:N\c_cs_dump_stream
-% \end{macrocode}
-% \end{macro}
-%
-%
% \begin{macro}{\g_cs_dump_name_tl}
% This \m{tl var.}~is used to store the name of the file.
%
% \begin{macrocode}
-\tl_new:Nn\g_cs_dump_name_tl{}
+%<*initex|package>
+%<*precompile>
+\tl_new:N \g_cs_dump_name_tl
% \end{macrocode}
% \end{macro}
%
@@ -248,14 +236,14 @@
% \begin{macrocode}
\cs_new_nopar:Npn\cs_dump:{
\iow_term:x{Precompiling~style~into~(\g_cs_dump_name_tl)}
-\iow_open:Nn\c_cs_dump_stream{\g_cs_dump_name_tl}
+\iow_open:Nn\g_cs_dump_stream{\g_cs_dump_name_tl}
% \end{macrocode}
% The first thing we write on a `dump' file is a command that
% allows us to use |*| in control sequences. We also need to be
% able to write to (and read from) the file internal control
% sequences, containing |_| and |:|.
% \begin{macrocode}
-\iow_now:Nx\c_cs_dump_stream
+\iow_now:Nx\g_cs_dump_stream
{\group_begin:
\tex_catcode:D`\token_to_str:N\*=11\scan_stop:
\token_to_str:N\ExplSyntaxOn
@@ -263,7 +251,7 @@
\seq_map_inline:Nn
\g_cs_dump_seq
{\tex_message:D{.}
-\iow_now:Nx\c_cs_dump_stream
+\iow_now:Nx\g_cs_dump_stream
% \end{macrocode}
% We use a direct |\cs_gset_nopar:Npn| to disable any type of local/global
% check on the pointers.
@@ -273,18 +261,18 @@
}
% \end{macrocode}
% We also need to remember the current values of the
-% |\g_gen_sym_num| and |\g_ggen_sym_num| counters to allow
+% |\g_gen_sym_int| and |\g_ggen_sym_int| counters to allow
% further updates after a database was dumped.
% \begin{macrocode}
-\iow_now:Nx \c_cs_dump_stream {\exp_not:n{\num_gset:Nn
- \g_gen_sym_num}
- {\num_use:N\g_gen_sym_num}^^J
-\exp_not:n{\num_gset:Nn \g_ggen_sym_num}
- {\num_use:N\g_ggen_sym_num}}
+\iow_now:Nx \g_cs_dump_stream {\exp_not:n{\int_gset:Nn
+ \g_gen_sym_int}
+ {\int_use:N\g_gen_sym_int}^^J
+\exp_not:n{\int_gset:Nn \g_ggen_sym_int}
+ {\int_use:N\g_ggen_sym_int}}
\iow_now:Nx
-\c_cs_dump_stream
+\g_cs_dump_stream
{\group_end:}
-\iow_close:N\c_cs_dump_stream
+\iow_close:N\g_cs_dump_stream
\tex_message:D{~finished}
}
%</precompile>
@@ -314,14 +302,13 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\g_gen_sym_num}
-% \begin{macro}{\g_ggen_sym_num}
+% \begin{macro}{\g_gen_sym_int}
+% \begin{macro}{\g_ggen_sym_int}
% Two counters to make up new local or global \textsl{short} names
% in pointer structures like the \textsc{ldb}.
-% We use a fake counters since operations with them are seldom.
% \begin{macrocode}
-\num_new:N\g_gen_sym_num \num_gset:Nn\g_gen_sym_num{0}
-\num_new:N\g_ggen_sym_num \num_gset:Nn\g_ggen_sym_num{0}
+\int_new:N\g_gen_sym_int \int_gset:Nn\g_gen_sym_int{0}
+\int_new:N\g_ggen_sym_int \int_gset:Nn\g_ggen_sym_int{0}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -336,8 +323,8 @@
%
% \begin{macrocode}
\cs_new_nopar:Npn\cs_gen_sym:N#1{
-\num_gincr:N\g_gen_sym_num
-\tl_set:Nc#1{l*\tex_romannumeral:D\num_use:N\g_gen_sym_num}
+\int_gincr:N\g_gen_sym_num
+\tl_set:Nc#1{l*\tex_romannumeral:D\int_use:N\g_gen_sym_int}
%<*precompile>
\exp_after:wN\cs_record_name:N#1
%</precompile>
@@ -351,8 +338,8 @@
% The global variant
% \begin{macrocode}
\cs_new_nopar:Npn\cs_ggen_sym:N#1{
-\num_gincr:N\g_ggen_sym_num
-\tl_set:Nc#1{g*\tex_romannumeral:D\num_use:N\g_ggen_sym_num}
+\int_gincr:N\g_ggen_sym_int
+\tl_set:Nc#1{g*\tex_romannumeral:D\int_use:N\g_ggen_sym_int}
%<*precompile>
\exp_after:wN\cs_record_name:N#1
%</precompile>
@@ -416,11 +403,11 @@
% \begin{macrocode}
\cs_new_nopar:Npn\dumpLaTeXstate#1{
\iow_term:x{Dumping~commands~into~(#1.dmp)}
- \iow_open:Nn\c_cs_dump_stream{#1.dmp}
+ \iow_open:Nn\g_cs_dump_stream{#1.dmp}
\seq_map_inline:Nn
\g_cs_trace_seq
{\tex_message:D{.}
- \iow_now:Nx\c_cs_dump_stream
+ \iow_now:Nx\g_cs_dump_stream
{\token_to_str:N##1~
\token_to_meaning:N##1}
}
@@ -428,10 +415,11 @@
\seq_map_inline:Nn
\g_register_trace_seq
{\tex_message:D{.}
- \iow_now:Nx\c_cs_dump_stream
+ \iow_now:Nx\g_cs_dump_stream
{\token_to_str:N##1
\toks_use:N##1}
}
+ \iow_clos:Nn \g_cs_dump_stream
\tex_message:D{~finished}
}
%</trace>
diff --git a/Master/texmf-dist/source/latex/expl3/l3prg.dtx b/Master/texmf-dist/source/latex/expl3/l3prg.dtx
index 4933c79ecb5..4ea121eb1f4 100644
--- a/Master/texmf-dist/source/latex/expl3/l3prg.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3prg.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3prg.dtx 1677 2009-11-02 08:24:04Z joseph $
+\GetIdInfo$Id: l3prg.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental control structures}
%\iffalse
%<*driver>
@@ -862,6 +862,7 @@
% Users shouldn't ask for something to be replicated once or even
% not at all but\dots
% \begin{macrocode}
+\cs_new:cpn {prg_replicate_first_-:n}#1{\cs_end: \ERROR }
\cs_new:cpn {prg_replicate_first_0:n}#1{\cs_end: }
\cs_new:cpn {prg_replicate_first_1:n}#1{\cs_end: #1}
\cs_new:cpn {prg_replicate_first_2:n}#1{\cs_end: #1#1}
@@ -925,7 +926,7 @@
% when we maintain our own stack.
% \begin{macrocode}
\int_new:N\g_prg_inline_level_int
-\cs_new:Npn\prg_stepwise_inline:nnnn #1#2#3#4{
+\cs_new_protected:Npn\prg_stepwise_inline:nnnn #1#2#3#4{
\int_gincr:N \g_prg_inline_level_int
\cs_gset_nopar:cpn{prg_stepwise_inline_\int_use:N\g_prg_inline_level_int :n}##1{#4}
\intexpr_compare:nNnTF {#2}<\c_zero
@@ -962,13 +963,13 @@
% Almost the same as above. Just store the value in |#4| and execute
% |#5|.
% \begin{macrocode}
-\cs_new:Npn \prg_stepwise_variable:nnnNn #1#2 {
+\cs_new_protected:Npn \prg_stepwise_variable:nnnNn #1#2 {
\intexpr_compare:nNnTF {#2}<\c_zero
{\exp_args:Nf\prg_stepwise_variable_decr:nnnNn}
{\exp_args:Nf\prg_stepwise_variable_incr:nnnNn}
{\intexpr_eval:n{#1}}{#2}
}
-\cs_new:Npn \prg_stepwise_variable_incr:nnnNn #1#2#3#4#5 {
+\cs_new_protected:Npn \prg_stepwise_variable_incr:nnnNn #1#2#3#4#5 {
\intexpr_compare:nNnF {#1}>{#3}
{
\cs_set_nopar:Npn #4{#1} #5
@@ -976,7 +977,7 @@
{\intexpr_eval:n{#1 + #2}}{#2}{#3}#4{#5}
}
}
-\cs_new:Npn \prg_stepwise_variable_decr:nnnNn #1#2#3#4#5 {
+\cs_new_protected:Npn \prg_stepwise_variable_decr:nnnNn #1#2#3#4#5 {
\intexpr_compare:nNnF {#1}<{#3}
{
\cs_set_nopar:Npn #4{#1} #5
@@ -1008,16 +1009,16 @@
% \begin{macro}{\bool_gset_false:c}
% Defining and setting a boolean is easy.
% \begin{macrocode}
-\cs_new_nopar:Npn \bool_new:N #1 { \cs_new_eq:NN #1 \c_false_bool }
-\cs_new_nopar:Npn \bool_new:c #1 { \cs_new_eq:cN {#1} \c_false_bool }
-\cs_new_nopar:Npn \bool_set_true:N #1 { \cs_set_eq:NN #1 \c_true_bool }
-\cs_new_nopar:Npn \bool_set_true:c #1 { \cs_set_eq:cN {#1} \c_true_bool }
-\cs_new_nopar:Npn \bool_set_false:N #1 { \cs_set_eq:NN #1 \c_false_bool }
-\cs_new_nopar:Npn \bool_set_false:c #1 { \cs_set_eq:cN {#1} \c_false_bool }
-\cs_new_nopar:Npn \bool_gset_true:N #1 { \cs_gset_eq:NN #1 \c_true_bool }
-\cs_new_nopar:Npn \bool_gset_true:c #1 { \cs_gset_eq:cN {#1} \c_true_bool }
-\cs_new_nopar:Npn \bool_gset_false:N #1 { \cs_gset_eq:NN #1 \c_false_bool }
-\cs_new_nopar:Npn \bool_gset_false:c #1 { \cs_gset_eq:cN {#1} \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_new:N #1 { \cs_new_eq:NN #1 \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_new:c #1 { \cs_new_eq:cN {#1} \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_set_true:N #1 { \cs_set_eq:NN #1 \c_true_bool }
+\cs_new_protected_nopar:Npn \bool_set_true:c #1 { \cs_set_eq:cN {#1} \c_true_bool }
+\cs_new_protected_nopar:Npn \bool_set_false:N #1 { \cs_set_eq:NN #1 \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_set_false:c #1 { \cs_set_eq:cN {#1} \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_gset_true:N #1 { \cs_gset_eq:NN #1 \c_true_bool }
+\cs_new_protected_nopar:Npn \bool_gset_true:c #1 { \cs_gset_eq:cN {#1} \c_true_bool }
+\cs_new_protected_nopar:Npn \bool_gset_false:N #1 { \cs_gset_eq:NN #1 \c_false_bool }
+\cs_new_protected_nopar:Npn \bool_gset_false:c #1 { \cs_gset_eq:cN {#1} \c_false_bool }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1145,6 +1146,8 @@
% \begin{macro}[TF]{\bool_if:n}
% \begin{macro}[aux]{\bool_get_next:N, \bool_cleanup:N, \bool_choose:NN}
% \begin{macro}[aux]{\bool_!:w}
+% \begin{macro}[aux]{\bool_Not:w}
+% \begin{macro}[aux]{\bool_Not:w}
% \begin{macro}[aux]{\bool_(:w}
% \begin{macro}[aux]{\bool_p:w}
% \begin{macro}[aux]{\bool_8_1:w}
@@ -1236,11 +1239,32 @@
}
% \end{macrocode}
% The Not operation. Discard the token read and reverse the truth
-% value of the next expression using "\intexpr_if_even_p:n".
+% value of the next expression using "\intexpr_if_even_p:n" if there
+% are brackets, otherwise reverse the logic here and now.
% \begin{macrocode}
-\cs_set:cpn {bool_!:w}#1{
- \exp_after:wN \intexpr_if_even_p:n \tex_number:D \bool_get_next:N
+\cs_set:cpn { bool_!:w } #1#2 {
+ \if_meaning:w ( #2
+ \exp_after:wN \bool_Not:w
+ \else:
+ \if_meaning:w ! #2
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_none:n
+ \else:
+ \exp_after:wN \exp_after:wN \exp_after:wN \bool_Not:N
+ \fi:
+ \fi:
+ #2
}
+\cs_new:Npn \bool_Not:w {
+ \exp_after:wN \intexpr_if_even_p:n \tex_number:D \bool_get_next:N
+}
+\cs_new:Npn \bool_Not:N #1 {
+ \exp_after:wN \bool_p:w
+ \if_meaning:w #1 \c_true_bool
+ \c_false_bool
+ \else:
+ \c_true_bool
+ \fi:
+}
% \end{macrocode}
% The Open operation. Discard the token read and start a
% sub-expression.
@@ -1302,6 +1326,8 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}[aux]{\bool_eval_skip_to_end:Nw,
% \bool_eval_skip_to_end_aux:Nw,\bool_eval_skip_to_end_auxii:Nw}
@@ -1592,7 +1618,7 @@
% by Bernd Raichle. Firstly we define the function for parsing the
% initial list and then the braced list afterwards.
% \begin{macrocode}
-\cs_new_nopar:Npn \prg_define_quicksort:nnn #1#2#3 {
+\cs_new_protected_nopar:Npn \prg_define_quicksort:nnn #1#2#3 {
\cs_set:cpx{#1_quicksort:n}##1{
\exp_not:c{#1_quicksort_start_partition:w} ##1
\exp_not:n{#2\q_nil#3\q_stop}
diff --git a/Master/texmf-dist/source/latex/expl3/l3prop.dtx b/Master/texmf-dist/source/latex/expl3/l3prop.dtx
index 9c93d32dcbc..8de35d67a5c 100644
--- a/Master/texmf-dist/source/latex/expl3/l3prop.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3prop.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3prop.dtx 1622 2009-10-25 06:41:23Z will $
+\GetIdInfo$Id: l3prop.dtx 1857 2010-03-21 21:32:09Z joseph $
{L3 Experimental Property Lists}
%\iffalse
%<*driver>
@@ -104,6 +104,7 @@
% \prop_put:NVV |
% \prop_put:cnn |
% \prop_gput:Nnn |
+% \prop_gput:NVn |
% \prop_gput:Nno |
% \prop_gput:NnV |
% \prop_gput:Nnx |
@@ -458,7 +459,7 @@
% \begin{macro}{\prop_display:c}
% Pretty print the contents of a property list on the console.
% \begin{macrocode}
-\cs_new_nopar:Npn \prop_display:N #1 {
+\cs_new_protected_nopar:Npn \prop_display:N #1 {
\iow_term:x { Property-list~\token_to_str:N #1~contains~
the~pairs~(without~outer~braces): }
\toks_clear:N \l_tmpa_toks
@@ -467,9 +468,9 @@
\toks_put_right:Nx \l_tmpa_toks {^^J>~}
}
\toks_put_right:Nx \l_tmpa_toks {
- \iow_space: \iow_char:N \{ \exp_not:n {##1} \iow_char:N \} \iow_space:
- \iow_space: => \iow_space:
- \iow_space: \iow_char:N \{ \exp_not:n {##2} \iow_char:N \}
+ \c_space_tl \iow_char:N \{ \exp_not:n {##1} \iow_char:N \} \c_space_tl
+ \c_space_tl => \c_space_tl
+ \c_space_tl \iow_char:N \{ \exp_not:n {##2} \iow_char:N \}
}
}
\toks_show:N \l_tmpa_toks
@@ -489,7 +490,7 @@
% and the 3rd argument is empty; otherwise the 3rd argument has the
% extra tokens |\q_prop| \meta{\propkey} |\q_prop| |\q_no_value| at the end.
% \begin{macrocode}
-\cs_new:Npn \prop_split_aux:Nnn #1#2#3{
+\cs_new_protected:Npn \prop_split_aux:Nnn #1#2#3{
\cs_set:Npn \prop_tmp:w ##1 \q_prop #2 \q_prop ##2##3 \q_stop {
#3 {##1}{##2}{##3}
}
@@ -507,10 +508,10 @@
% \meta{tl var.}~to be the value associated with \meta{\propkey} in \meta{\proplist},
% |\q_no_value| if not found.
% \begin{macrocode}
-\cs_new:Npn \prop_get:NnN #1#2 {
+\cs_new_protected:Npn \prop_get:NnN #1#2 {
\prop_split_aux:Nnn #1{#2}\prop_get_aux:w
}
-\cs_new:Npn \prop_get_aux:w #1#2#3#4 { \tl_set:Nx #4 {\exp_not:n{#2}} }
+\cs_new_protected:Npn \prop_get_aux:w #1#2#3#4 { \tl_set:Nn #4 {#2} }
% \end{macrocode}
%
% \begin{macrocode}
@@ -529,9 +530,9 @@
% \begin{macro}{\prop_gget_aux:w}
% The global version of the previous function.
% \begin{macrocode}
-\cs_new:Npn \prop_gget:NnN #1#2{
+\cs_new_protected:Npn \prop_gget:NnN #1#2{
\prop_split_aux:Nnn #1{#2}\prop_gget_aux:w}
-\cs_new:Npn \prop_gget_aux:w #1#2#3#4{\tl_gset:Nx#4{\exp_not:n{#2}}}
+\cs_new_protected:Npn \prop_gget_aux:w #1#2#3#4{\tl_gset:Nx#4{\exp_not:n{#2}}}
% \end{macrocode}
%
% \begin{macrocode}
@@ -550,10 +551,10 @@
% from \m{property_list}. One probably also needs the local
% variants or only the local one, or\ldots\ We decide this later.
% \begin{macrocode}
-\cs_new:Npn \prop_get_gdel:NnN #1#2#3{
+\cs_new_protected:Npn \prop_get_gdel:NnN #1#2#3{
\prop_split_aux:Nnn #1{#2}{\prop_get_del_aux:w #3{\toks_gset:Nn #1}{#2}}}
-\cs_new:Npn \prop_get_del_aux:w #1#2#3#4#5#6{
- \tl_set:Nx #1{\exp_not:n{#5}}
+\cs_new_protected:Npn \prop_get_del_aux:w #1#2#3#4#5#6{
+ \tl_set:Nn #1 {#5}
\quark_if_no_value:NF #1 {
\cs_set_nopar:Npn \prop_tmp:w ##1\q_prop#3\q_prop\q_no_value {#2{#4##1}}
\prop_tmp:w #6}
@@ -568,6 +569,7 @@
% \begin{macro}{\prop_put:NVV}
% \begin{macro}{\prop_put:cnn}
% \begin{macro}{\prop_gput:Nnn}
+% \begin{macro}{\prop_gput:NVn}
% \begin{macro}{\prop_gput:NnV}
% \begin{macro}{\prop_gput:Nno}
% \begin{macro}{\prop_gput:Nnx}
@@ -577,7 +579,7 @@
% |\prop_put:Nnn| \marg{\proplist} \marg{\propkey} \marg{\propval} adds/changes the
% value associated with \meta{\propkey} in \meta{\proplist} to \meta{\propval}.
% \begin{macrocode}
-\cs_new:Npn \prop_put:Nnn #1#2{
+\cs_new_protected:Npn \prop_put:Nnn #1#2{
\prop_split_aux:Nnn #1{#2}{
\prop_clear:N #1
\prop_put_aux:w {\toks_put_right:Nn #1}{#2}
@@ -586,7 +588,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \prop_gput:Nnn #1#2{
+\cs_new_protected:Npn \prop_gput:Nnn #1#2{
\prop_split_aux:Nnn #1{#2}{
\prop_gclear:N #1
\prop_put_aux:w {\toks_gput_right:Nn #1}{#2}
@@ -595,7 +597,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new:Npn \prop_put_aux:w #1#2#3#4#5#6{
+\cs_new_protected:Npn \prop_put_aux:w #1#2#3#4#5#6{
#1{\q_prop#2\q_prop{#6}#3}
\tl_if_empty:nF{#5}
{
@@ -610,7 +612,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_generate_variant:Nn \prop_gput:Nnn {NnV,Nno,Nnx,Nox,cnn,ccx}
+\cs_generate_variant:Nn \prop_gput:Nnn {NVn,NnV,Nno,Nnx,Nox,cnn,ccx}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -624,6 +626,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\prop_del:Nn}
% \begin{macro}{\prop_del:NV}
@@ -633,11 +636,11 @@
% |\prop_del:Nn |\meta{\proplist}\meta{\propkey} deletes the entry for
% \meta{\propkey} in \meta{\proplist}, if any.
% \begin{macrocode}
-\cs_new:Npn \prop_del:Nn #1#2{
+\cs_new_protected:Npn \prop_del:Nn #1#2{
\prop_split_aux:Nnn #1{#2}{\prop_del_aux:w {\toks_set:Nn #1}{#2}}}
-\cs_new:Npn \prop_gdel:Nn #1#2{
+\cs_new_protected:Npn \prop_gdel:Nn #1#2{
\prop_split_aux:Nnn #1{#2}{\prop_del_aux:w {\toks_gset:Nn #1}{#2}}}
-\cs_new:Npn \prop_del_aux:w #1#2#3#4#5{
+\cs_new_protected:Npn \prop_del_aux:w #1#2#3#4#5{
\cs_set_nopar:Npn \prop_tmp:w {#4}
\quark_if_no_value:NF \prop_tmp:w {
\cs_set_nopar:Npn \prop_tmp:w ##1\q_prop#2\q_prop\q_no_value {#1{#3##1}}
@@ -672,9 +675,9 @@
% F. and Louis A. which makes writing macros sometimes difficult; I
% find myself humming instead of working):
% \begin{macrocode}
-\cs_new:Npn \prop_gput_if_new:Nnn #1#2{
+\cs_new_protected:Npn \prop_gput_if_new:Nnn #1#2{
\prop_split_aux:Nnn #1{#2}{\prop_put_if_new_aux:w #1{#2}}}
-\cs_new:Npn \prop_put_if_new_aux:w #1#2#3#4#5#6{
+\cs_new_protected:Npn \prop_put_if_new_aux:w #1#2#3#4#5#6{
\tl_if_empty:nT {#5}{#1{\q_prop#2\q_prop{#6}#3}}}
% \end{macrocode}
% \end{macro}
@@ -721,7 +724,7 @@
% \m{\propkey} is on the \m{property_list} and then select
% either the true or false case.
% \begin{macrocode}
-\prg_new_conditional:Nnn \prop_if_in:Nn {TF,T,F} {
+\prg_new_protected_conditional:Nnn \prop_if_in:Nn {TF,T,F} {
\prop_split_aux:Nnn #1 {#2} {\prop_if_in_aux:w}
}
\cs_new_nopar:Npn \prop_if_in_aux:w #1#2#3 {
@@ -818,7 +821,7 @@
% we don't waste time doing that.
% \begin{macrocode}
\int_new:N \g_prop_inline_level_int
-\cs_new_nopar:Npn \prop_map_inline:Nn #1#2 {
+\cs_new_protected_nopar:Npn \prop_map_inline:Nn #1#2 {
\int_gincr:N \g_prop_inline_level_int
\cs_gset:cpn {prop_map_inline_ \int_use:N \g_prop_inline_level_int :n}
##1##2{#2}
diff --git a/Master/texmf-dist/source/latex/expl3/l3quark.dtx b/Master/texmf-dist/source/latex/expl3/l3quark.dtx
index c5c5a22c00c..954f903ca06 100644
--- a/Master/texmf-dist/source/latex/expl3/l3quark.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3quark.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3quark.dtx 1365 2009-05-31 17:26:17Z mittelba $
+\GetIdInfo$Id: l3quark.dtx 1853 2010-03-21 09:11:08Z joseph $
{L3 Experimental Quark Commands}
%\iffalse
%<*driver>
@@ -254,7 +254,7 @@
% \begin{macro}{\quark_new:N}
% Allocate a new quark.
% \begin{macrocode}
-\cs_new_nopar:Npn \quark_new:N #1{\tl_new:Nn #1{#1}}
+\cs_new_protected_nopar:Npn \quark_new:N #1 { \tl_const:Nn #1 {#1} }
% \end{macrocode}
% \end{macro}
%
@@ -391,7 +391,7 @@
\prg_new_conditional:Nnn \quark_if_no_value:n {p,TF,T,F} {
\exp_args:NNo
\if_predicate:w \str_if_eq_var_p:nf
- {\token_to_str:N\q_no_value\iow_space:}
+ {\token_to_str:N\q_no_value\c_space_tl}
{\tl_to_str:n{#1}}
\prg_return_true: \else: \prg_return_false:
\fi:
@@ -429,7 +429,7 @@
\prg_new_conditional:Nnn \quark_if_nil:n {p,TF,T,F} {
\exp_args:NNo
\if_predicate:w \str_if_eq_var_p:nf
- {\token_to_str:N\q_nil\iow_space:}
+ {\token_to_str:N\q_nil\c_space_tl}
{\tl_to_str:n{#1}}
\prg_return_true: \else: \prg_return_false:
\fi:
diff --git a/Master/texmf-dist/source/latex/expl3/l3seq.dtx b/Master/texmf-dist/source/latex/expl3/l3seq.dtx
index 4ce306b7d41..6e72397646d 100644
--- a/Master/texmf-dist/source/latex/expl3/l3seq.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3seq.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3seq.dtx Copyright (C) 1990-2009 LaTeX3 project
+%% File: l3seq.dtx Copyright (C) 1990-2010 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3seq.dtx 1692 2009-11-03 21:02:34Z joseph $
+\GetIdInfo$Id: l3seq.dtx 1857 2010-03-21 21:32:09Z joseph $
{L3 Experimental sequences and stacks}
%\iffalse
%<*driver>
@@ -284,6 +284,12 @@
% within write operations etc.
% \end{function}
%
+% \begin{function}{ \seq_map_break: | \seq_map_break:n }
+% These functions are used to break out of a mapping function at the point
+% of execution. (Please do not put `|\q_stop|' inside a <seq> that uses
+% these functions.)
+% \end{function}
+%
% \begin{function}{ \seq_show:N |
% \seq_show:c }
% \begin{syntax}
@@ -371,11 +377,6 @@
% meant for direct use.
% \end{function}
%
-% \begin{function}{ \seq_map_break: | \seq_map_break:n }
-% Functions used to implement mapping operations. They are not for
-% meant for direct use.
-% \end{function}
-%
% \begin{function}{ \seq_elt:w |
% \seq_elt_end: }
% Functions (usually used as constants) that separates items within a
@@ -545,7 +546,7 @@
% |\seq_gconcat:NNN| \m{seq~1} \m{seq~2} \m{seq~3} will globally
% assign \m{seq~1} the concatenation of \m{seq~2} and \m{seq~3}.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_gconcat:NNN #1#2#3 {
+\cs_new_protected_nopar:Npn \seq_gconcat:NNN #1#2#3 {
\tl_gset:Nx #1 { \exp_not:V #2 \exp_not:V #3 }
}
\cs_generate_variant:Nn \seq_gconcat:NNN {ccc}
@@ -577,7 +578,7 @@
% next line of code should be probably removed.
% (Will: I have no idea what this comment means.)
% \begin{macrocode}
- \tl_clear:N \l_testa_tl % catch prefixes
+ \tl_clear:N \l_kernel_testa_tl % catch prefixes
\msg_kernel_bug:x {Empty~sequence~`\token_to_str:N#1'}
\fi:
}
@@ -595,7 +596,7 @@
% Note that |##2| in the definition below for "\seq_tmp:w" contains
% exactly one token which we can compare with |\q_no_value|.
% \begin{macrocode}
-\prg_new_conditional:Nnn \seq_if_in:Nn {TF,T,F} {
+\prg_new_protected_conditional:Nnn \seq_if_in:Nn {TF,T,F} {
\cs_set:Npn \seq_tmp:w ##1 \seq_elt:w #2 \seq_elt_end: ##2##3 \q_stop {
\if_meaning:w \q_no_value ##2
\prg_return_false: \else: \prg_return_true: \fi:
@@ -618,11 +619,11 @@
% |\seq_get:NN |\meta{sequence}\meta{cmd} defines \meta{cmd} to be the
% left-most element of \meta{sequence}.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_get:NN #1 {
+\cs_new_protected_nopar:Npn \seq_get:NN #1 {
\seq_if_empty_err:N #1
\exp_after:wN \seq_get_aux:w #1 \q_stop
}
-\cs_new:Npn \seq_get_aux:w \seq_elt:w #1 \seq_elt_end: #2 \q_stop #3 {
+\cs_new_protected:Npn \seq_get_aux:w \seq_elt:w #1 \seq_elt_end: #2 \q_stop #3 {
\tl_set:Nn #3 {#1}
}
\cs_generate_variant:Nn \seq_get:NN {c}
@@ -638,11 +639,11 @@
% \meta{cmd} using \meta{def$\sb2$}, and assigns the tail of
% \meta{sequence} to \meta{sequence} using \meta{def$\sb1$}.
% \begin{macrocode}
-\cs_new:Npn \seq_pop_aux:nnNN #1#2#3 {
+\cs_new_protected:Npn \seq_pop_aux:nnNN #1#2#3 {
\seq_if_empty_err:N #3
\exp_after:wN \seq_pop_aux:w #3 \q_stop #1#2#3
}
-\cs_new:Npn \seq_pop_aux:w
+\cs_new_protected:Npn \seq_pop_aux:w
\seq_elt:w #1 \seq_elt_end: #2\q_stop #3#4#5#6 {
#3 #5 {#2}
#4 #6 {#1}
@@ -663,7 +664,7 @@
% \begin{macro}{\seq_display:N}
% \begin{macro}{\seq_display:c}
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_display:N #1 {
+\cs_new_protected_nopar:Npn \seq_display:N #1 {
\iow_term:x { Sequence~\token_to_str:N #1~contains~
the~elements~(without~outer~braces): }
\toks_clear:N \l_tmpa_toks
@@ -672,7 +673,7 @@
\toks_put_right:Nx \l_tmpa_toks {^^J>~}
}
\toks_put_right:Nx \l_tmpa_toks {
- \iow_space: \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
+ \c_space_tl \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
}
}
\toks_show:N \l_tmpa_toks
@@ -691,10 +692,10 @@
% elements specified by \meta{left} to the left of \meta{sequence}, and
% those specified by \meta{right} to the right.
% \begin{macrocode}
-\cs_new:Npn \seq_put_aux:Nnn #1 {
+\cs_new_protected:Npn \seq_put_aux:Nnn #1 {
\exp_after:wN \seq_put_aux:w #1 \q_stop #1
}
-\cs_new:Npn \seq_put_aux:w #1\q_stop #2#3#4 { \tl_set:Nn #2 {#3#1#4} }
+\cs_new_protected:Npn \seq_put_aux:w #1\q_stop #2#3#4 { \tl_set:Nn #2 {#3#1#4} }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -715,7 +716,7 @@
% \begin{macro}{\seq_put_right:co}
% Here are the usual operations for adding to the left and right.
% \begin{macrocode}
-\cs_new:Npn \seq_put_left:Nn #1#2 {
+\cs_new_protected:Npn \seq_put_left:Nn #1#2 {
\seq_put_aux:Nnn #1 {\seq_elt:w #2\seq_elt_end:} {}
}
% \end{macrocode}
@@ -726,7 +727,7 @@
\cs_generate_variant:Nn \seq_put_left:Nn {NV,No,Nx,c,cV,co}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn \seq_put_right:Nn #1#2{
+\cs_new_protected:Npn \seq_put_right:Nn #1#2{
\seq_put_aux:Nnn #1{}{\seq_elt:w #2\seq_elt_end:}}
% \end{macrocode}
% \begin{macrocode}
@@ -762,7 +763,7 @@
% \begin{macro}{\seq_gput_right:cV}
% \begin{macro}{\seq_gput_right:co}
% \begin{macrocode}
-\cs_new:Npn \seq_gput_left:Nn {
+\cs_new_protected:Npn \seq_gput_left:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -773,7 +774,7 @@
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn \seq_gput_right:Nn {
+\cs_new_protected:Npn \seq_gput_right:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -816,28 +817,32 @@
% \begin{macro}{\seq_map_variable:NNn}
% \begin{macro}{\seq_map_variable:cNn}
% \begin{macro}[aux]{\seq_map_variable_aux:Nnw}
-% \begin{macro}{\seq_map_break:}
-% \begin{macro}{\seq_map_break:n}
% Nothing spectacular here.
% \begin{macrocode}
-\cs_new:Npn \seq_map_variable_aux:Nnw #1#2 \seq_elt:w #3 \seq_elt_end: {
- \tl_set:Nx #1{\exp_not:n{#3}}
+\cs_new_protected:Npn \seq_map_variable_aux:Nnw #1#2 \seq_elt:w #3 \seq_elt_end: {
+ \tl_set:Nn #1 {#3}
\quark_if_nil:NT #1 \seq_map_break:
#2
\seq_map_variable_aux:Nnw #1{#2}
}
-\cs_new:Npn \seq_map_variable:NNn #1#2#3 {
- \tl_set:Nx #2 {\exp_not:n{\seq_map_variable_aux:Nnw #2{#3}}}
+\cs_new_protected:Npn \seq_map_variable:NNn #1#2#3 {
+ \tl_set:Nn #2 {\seq_map_variable_aux:Nnw #2{#3}}
\exp_after:wN #2 #1 \seq_elt:w \q_nil\seq_elt_end: \q_stop
}
\cs_generate_variant:Nn \seq_map_variable:NNn {c}
-
-\cs_new_eq:NN \seq_map_break: \use_none_delimit_by_q_stop:w
-\cs_new_eq:NN \seq_map_break:n \use_i_delimit_by_q_stop:nw
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+%
+% \begin{macro}{\seq_map_break:}
+% \begin{macro}{\seq_map_break:n}
+% Terminate a mapping function at the point of execution. The latter
+% takes an argument to be executed after cleaning up the map.
+% \begin{macrocode}
+\cs_new_eq:NN \seq_map_break: \use_none_delimit_by_q_stop:w
+\cs_new_eq:NN \seq_map_break:n \use_i_delimit_by_q_stop:nw
+% \end{macrocode}
% \end{macro}
% \end{macro}
%
@@ -849,9 +854,9 @@
% better to say that \meta{cmd} must be a function with one argument
% that is delimited by |\seq_elt_end:|.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_map_function:NN #1#2 {
+\cs_new_protected_nopar:Npn \seq_map_function:NN #1#2 {
\cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2{##1}}
- #1
+ #1 \use_none:n \q_stop
\cs_set_eq:NN \seq_elt:w \ERROR
}
\cs_generate_variant:Nn \seq_map_function:NN {c}
@@ -864,9 +869,9 @@
% When no braces are used, this version of mapping seems more
% natural.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_map_inline:Nn #1#2 {
+\cs_new_protected_nopar:Npn \seq_map_inline:Nn #1#2 {
\cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2}
- #1
+ #1 \use_none:n \q_stop
\cs_set_eq:NN \seq_elt:w \ERROR
}
\cs_generate_variant:Nn \seq_map_inline:Nn {c}
@@ -889,22 +894,22 @@
% \begin{macro}{\seq_gremove_duplicates:N}
% Copied from "\clist_remove_duplicates".
% \begin{macrocode}
-\cs_new:Npn \seq_remove_duplicates_aux:NN #1#2 {
+\cs_new_protected:Npn \seq_remove_duplicates_aux:NN #1#2 {
\seq_clear:N \l_seq_remove_seq
\seq_map_function:NN #2 \seq_remove_duplicates_aux:n
#1 #2 \l_seq_remove_seq
}
-\cs_new:Npn \seq_remove_duplicates_aux:n #1 {
+\cs_new_protected:Npn \seq_remove_duplicates_aux:n #1 {
\seq_if_in:NnF \l_seq_remove_seq {#1} {
\seq_put_right:Nn \l_seq_remove_seq {#1}
}
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_remove_duplicates:N {
+\cs_new_protected_nopar:Npn \seq_remove_duplicates:N {
\seq_remove_duplicates_aux:NN \seq_set_eq:NN
}
-\cs_new_nopar:Npn \seq_gremove_duplicates:N {
+\cs_new_protected_nopar:Npn \seq_gremove_duplicates:N {
\seq_remove_duplicates_aux:NN \seq_gset_eq:NN
}
% \end{macrocode}
@@ -929,7 +934,7 @@
\cs_new_eq:NN \seq_push:NV \seq_put_left:NV
\cs_new_eq:NN \seq_push:No \seq_put_left:No
\cs_new_eq:NN \seq_push:cn \seq_put_left:cn
-\cs_new_nopar:Npn \seq_pop:NN { \seq_pop_aux:nnNN \tl_set:Nn \tl_set:Nn }
+\cs_new_protected_nopar:Npn \seq_pop:NN { \seq_pop_aux:nnNN \tl_set:Nn \tl_set:Nn }
\cs_generate_variant:Nn \seq_pop:NN {c}
% \end{macrocode}
% \end{macro}
@@ -952,7 +957,7 @@
% nevertheless returned locally.
% \begin{macrocode}
\cs_new_eq:NN \seq_gpush:Nn \seq_gput_left:Nn
-\cs_new_nopar:Npn \seq_gpop:NN { \seq_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn }
+\cs_new_protected_nopar:Npn \seq_gpop:NN { \seq_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn }
\cs_generate_variant:Nn \seq_gpush:Nn {NV,No,c,Nv}
\cs_generate_variant:Nn \seq_gpop:NN {c}
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/expl3/l3skip.dtx b/Master/texmf-dist/source/latex/expl3/l3skip.dtx
index 1853812248e..bbb3acd59a9 100644
--- a/Master/texmf-dist/source/latex/expl3/l3skip.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3skip.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3skip.dtx 1362 2009-05-28 20:19:21Z joseph $
+\GetIdInfo$Id: l3skip.dtx 1867 2010-03-23 13:03:12Z will $
{L3 Experimental skip registers}
%\iffalse
%<*driver>
@@ -71,18 +71,18 @@
%
% \subsection{Functions}
%
-% \begin{function}{%
-% \skip_new:N |
-% \skip_new:c |
-%^^A \skip_new_l:N
-% }
+% \begin{function}{ \skip_new:N |
+% \skip_new:c |
+% \skip_new_local:N |
+% \skip_new_local:c }
% \begin{syntax}
% "\skip_new:N" <skip>
% \end{syntax}
% Defines <skip> to be a new variable of type "skip".
+% With the |local| variant, the variable is only available within the
+% current group level (or below).
% \begin{texnote}
% "\skip_new:N" is the equivalent to plain \TeX{}'s \tn{newskip}.
-% However, the internal register allocation is done differently.
% \end{texnote}
% \end{function}
%
@@ -276,18 +276,18 @@
%
%
%
-% \begin{function}{%
-% \dim_new:N |
-% \dim_new:c |
-%^^A \dim_new_l:N
-% }
+% \begin{function}{ \dim_new:N |
+% \dim_new:c |
+% \dim_new_local:N |
+% \dim_new_local:c }
% \begin{syntax}
% "\dim_new:N" <dim>
% \end{syntax}
% Defines <dim> to be a new variable of type "dim".
+% With the |local| variant, the variable is only available within the
+% current group level (or below).
% \begin{texnote}
% "\dim_new:N" is the equivalent to plain \TeX{}'s \tn{newdimen}.
-% However, the internal register allocation is done differently.
% \end{texnote}
% \end{function}
%
@@ -480,17 +480,15 @@
%
% \section{Muskips}
%
-% \begin{function}{%
-% \muskip_new:N |
-%^^A \muskip_new_l:N
-% }
+% \begin{function}{ \muskip_new:N |
+% \muskip_new_local:N }
% \begin{syntax}
% "\muskip_new:N" <muskip>
% \end{syntax}
% Defines <muskip> to be a new variable of type "muskip".
-% \begin{texnote}
+% With the |local| variant, the variable is only available within the
+% current group level (or below).% \begin{texnote}
% "\muskip_new:N" is the equivalent to plain \TeX{}'s \tn{newmuskip}.
-% However, the internal register allocation is done differently.
% \end{texnote}
% \end{function}
%
@@ -561,24 +559,30 @@
% \subsection{Skip registers}
%
% \begin{macro}{\skip_new:N,\skip_new:c}
-%^^A \begin{macro}{\skip_new_l:N}
+% \begin{macro}{\skip_new_local:N,\skip_new_local:c}
% Allocation of a new internal registers.
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {skip} \c_zero \c_max_register_num
-\cs_new_nopar:Npn\skip_new:N #1 { \alloc_reg:NnNN g {skip} \tex_skipdef:D #1 }
-\cs_new_nopar:Npn\skip_new_l:N #1 { \alloc_reg:NnNN l {skip} \tex_skipdef:D #1 }
+\alloc_new:nnnN {skip} \c_zero \c_max_register_int \tex_skipdef:D
%</initex>
%<*package>
-\cs_new_nopar:Npn \skip_new:N #1 {
+\cs_new_protected_nopar:Npn \skip_new:N #1 {
\chk_if_free_cs:N #1
\newskip #1
}
+\cs_new_protected_nopar:Npn \skip_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newskip \locskip
+ #1
+}
%</package>
\cs_generate_variant:Nn \skip_new:N {c}
+\cs_generate_variant:Nn \skip_new_local:N {c}
% \end{macrocode}
% \end{macro}
-%^^A \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\skip_set:Nn}
@@ -588,13 +592,13 @@
% Setting skips is again something that I would like to make
% uniform at the moment to get a better overview.
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_set:Nn #1#2 {
+\cs_new_protected_nopar:Npn \skip_set:Nn #1#2 {
#1\skip_eval:n{#2}
%<*check>
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \skip_gset:Nn {
+\cs_new_protected_nopar:Npn \skip_gset:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -615,13 +619,13 @@
% \begin{macro}{\skip_gzero:c}
% Reset the register to zero.
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_zero:N #1{
+\cs_new_protected_nopar:Npn \skip_zero:N #1{
#1\c_zero_skip \scan_stop:
%<*check>
\chk_local_or_pref_global:N #1
%</check>
}
-\cs_new_nopar:Npn \skip_gzero:N {
+\cs_new_protected_nopar:Npn \skip_gzero:N {
% \end{macrocode}
% We make sure that a local variable is not updated globally by
% changing the internal test (i.e.\ |\chk_local_or_pref_global:N|) before
@@ -654,7 +658,7 @@
% \begin{macro}{\skip_gsub:Nn}
% Adding and subtracting to and from <skip>s
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_add:Nn #1#2 {
+\cs_new_protected_nopar:Npn \skip_add:Nn #1#2 {
% \end{macrocode}
% We need to say |by| in case the first argment is a register
% accessed by its number, e.g., |\skip23|.
@@ -668,7 +672,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_sub:Nn #1#2{
+\cs_new_protected_nopar:Npn \skip_sub:Nn #1#2{
\tex_advance:D#1-\skip_eval:n{#2}
%<*check>
\chk_local_or_pref_global:N #1
@@ -677,7 +681,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_gadd:Nn {
+\cs_new_protected_nopar:Npn \skip_gadd:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -752,7 +756,7 @@
% \begin{macro}{\skip_eval:n}
% Evaluating a calc expression.
% \begin{macrocode}
-\cs_new_nopar:Npn \skip_eval:n #1 { \etex_glueexpr:D #1 \scan_stop: }
+\cs_new_protected_nopar:Npn \skip_eval:n #1 { \etex_glueexpr:D #1 \scan_stop: }
% \end{macrocode}
% \end{macro}
%
@@ -846,24 +850,30 @@
% \subsection{Dimen registers}
%
% \begin{macro}{\dim_new:N,\dim_new:c}
-%^^A \begin{macro}{\dim_new_l:N}
+% \begin{macro}{\dim_new_local:N,\dim_new_local:c}
% Allocating \meta{dim} registers...
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {dimen} \c_zero \c_max_register_num
-\cs_new_nopar:Npn \dim_new:N #1 {\alloc_reg:NnNN g {dimen} \tex_dimendef:D #1 }
-\cs_new_nopar:Npn \dim_new_l:N #1 {\alloc_reg:NnNN l {dimen} \tex_dimendef:D #1 }
+\alloc_new:nnnN {dim} \c_zero \c_max_register_int \tex_dimendef:D
%</initex>
%<*package>
-\cs_new_nopar:Npn \dim_new:N #1 {
+\cs_new_protected_nopar:Npn \dim_new:N #1 {
\chk_if_free_cs:N #1
\newdimen #1
}
+\cs_new_protected_nopar:Npn \dim_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newdimen \locdimen
+ #1
+}
%</package>
\cs_generate_variant:Nn \dim_new:N {c}
+\cs_generate_variant:Nn \dim_new_local:N {c}
% \end{macrocode}
% \end{macro}
-%^^A \end{macro}
+% \end{macro}
%
% \begin{macro}{\dim_set:Nn}
% \begin{macro}{\dim_set:cn}
@@ -875,12 +885,12 @@
% We add |\dim_eval:n| in order to allow simple arithmetic
% and a space just for those using |\dimen1| or alike. See OR!
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_set:Nn #1#2 { #1~ \dim_eval:n{#2} }
+\cs_new_protected_nopar:Npn \dim_set:Nn #1#2 { #1~ \dim_eval:n{#2} }
\cs_generate_variant:Nn \dim_set:Nn {cn,Nc}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_gset:Nn { \pref_global:D \dim_set:Nn }
+\cs_new_protected_nopar:Npn \dim_gset:Nn { \pref_global:D \dim_set:Nn }
\cs_generate_variant:Nn \dim_gset:Nn {cn,Nc,cc}
% \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
@@ -892,12 +902,12 @@
% \begin{macro}{\dim_gzero:c}
% Resetting.
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_zero:N #1 { #1\c_zero_skip }
+\cs_new_protected_nopar:Npn \dim_zero:N #1 { #1\c_zero_skip }
\cs_generate_variant:Nn \dim_zero:N {c}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_gzero:N { \pref_global:D \dim_zero:N }
+\cs_new_protected_nopar:Npn \dim_gzero:N { \pref_global:D \dim_zero:N }
\cs_generate_variant:Nn \dim_gzero:N {c}
% \end{macrocode}
% \end{macro}
@@ -912,7 +922,7 @@
% \begin{macro}{\dim_gadd:cn}
% Addition.
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_add:Nn #1#2{
+\cs_new_protected_nopar:Npn \dim_add:Nn #1#2{
% \end{macrocode}
% We need to say |by| in case the first argment is a register
% accessed by its number, e.g., |\dimen23|.
@@ -923,7 +933,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_gadd:Nn { \pref_global:D \dim_add:Nn }
+\cs_new_protected_nopar:Npn \dim_gadd:Nn { \pref_global:D \dim_add:Nn }
\cs_generate_variant:Nn \dim_gadd:Nn {cn}
% \end{macrocode}
% \end{macro}
@@ -939,12 +949,12 @@
% \begin{macro}{\dim_gsub:cn}
% Subtracting.
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_sub:Nn #1#2 { \tex_advance:D#1-#2\scan_stop: }
+\cs_new_protected_nopar:Npn \dim_sub:Nn #1#2 { \tex_advance:D#1-#2\scan_stop: }
\cs_generate_variant:Nn \dim_sub:Nn {cn,Nc}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_gsub:Nn { \pref_global:D \dim_sub:Nn }
+\cs_new_protected_nopar:Npn \dim_gsub:Nn { \pref_global:D \dim_sub:Nn }
\cs_generate_variant:Nn \dim_gsub:Nn {cn}
% \end{macrocode}
% \end{macro}
@@ -1008,7 +1018,7 @@
% \begin{macro}{\dim_eval:n}
% Evaluating a calc expression.
% \begin{macrocode}
-\cs_new_nopar:Npn \dim_eval:n #1 { \etex_dimexpr:D #1 \scan_stop: }
+\cs_new_protected_nopar:Npn \dim_eval:n #1 { \etex_dimexpr:D #1 \scan_stop: }
% \end{macrocode}
% \end{macro}
%
@@ -1060,22 +1070,27 @@
% \subsection{Muskips}
%
% \begin{macro}{\muskip_new:N}
-%^^A \begin{macro}{\muskip_new_l:N}
+% \begin{macro}{\muskip_new_local:N}
% And then we add muskips.
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {muskip} \c_zero \c_max_register_num
-\cs_new_nopar:Npn \muskip_new:N #1{\alloc_reg:NnNN g {muskip} \tex_muskipdef:D #1}
-\cs_new_nopar:Npn \muskip_new_l:N #1{\alloc_reg:NnNN l {muskip} \tex_muskipdef:D #1}
+\alloc_new:nnnN {muskip} \c_zero \c_max_register_int \tex_muskipdef:D
%</initex>
%<*package>
-\cs_new_nopar:Npn \muskip_new:N #1 {
+\cs_new_protected_nopar:Npn \muskip_new:N #1 {
\chk_if_free_cs:N #1
\newmuskip #1
}
+\cs_new_protected_nopar:Npn \muskip_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newmuskip \locmuskip
+ #1
+}
%</package>
% \end{macrocode}
-%^^A \end{macro}
+% \end{macro}
% \end{macro}
%
% \begin{macro}{\muskip_set:Nn}
@@ -1086,12 +1101,12 @@
% \begin{macro}{\muskip_gsub:Nn}
% Simple functions for muskips.
% \begin{macrocode}
-\cs_new_nopar:Npn \muskip_set:Nn#1#2{#1\etex_muexpr:D#2\scan_stop:}
-\cs_new_nopar:Npn \muskip_gset:Nn{\pref_global:D\muskip_set:Nn}
-\cs_new_nopar:Npn \muskip_add:Nn#1#2{\tex_advance:D#1\etex_muexpr:D#2\scan_stop:}
-\cs_new_nopar:Npn \muskip_gadd:Nn{\pref_global:D\muskip_add:Nn}
-\cs_new_nopar:Npn \muskip_sub:Nn#1#2{\tex_advance:D#1-\etex_muexpr:D#2\scan_stop:}
-\cs_new_nopar:Npn \muskip_gsub:Nn{\pref_global:D\muskip_sub:Nn}
+\cs_new_protected_nopar:Npn \muskip_set:Nn#1#2{#1\etex_muexpr:D#2\scan_stop:}
+\cs_new_protected_nopar:Npn \muskip_gset:Nn{\pref_global:D\muskip_set:Nn}
+\cs_new_protected_nopar:Npn \muskip_add:Nn#1#2{\tex_advance:D#1\etex_muexpr:D#2\scan_stop:}
+\cs_new_protected_nopar:Npn \muskip_gadd:Nn{\pref_global:D\muskip_add:Nn}
+\cs_new_protected_nopar:Npn \muskip_sub:Nn#1#2{\tex_advance:D#1-\etex_muexpr:D#2\scan_stop:}
+\cs_new_protected_nopar:Npn \muskip_gsub:Nn{\pref_global:D\muskip_sub:Nn}
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/Master/texmf-dist/source/latex/expl3/l3tl.dtx b/Master/texmf-dist/source/latex/expl3/l3tl.dtx
index 3e478643e76..4b38de0d0f1 100644
--- a/Master/texmf-dist/source/latex/expl3/l3tl.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3tl.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3tl.dtx Copyright (C) 1990-2009 LaTeX3 project
+%% File: l3tl.dtx Copyright (C) 1990-2010 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
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3tl.dtx 1621 2009-10-25 06:36:19Z will $
+\GetIdInfo$Id: l3tl.dtx 1873 2010-03-24 08:32:54Z joseph $
{L3 Experimental Token Lists}
%\iffalse
%<*driver>
@@ -92,6 +92,14 @@
%
% The form "\tl_new:N" initializes the token list variable with an empty value.
% \end{function}
+%
+% \begin{function}{\tl_const:Nn}
+% \begin{syntax}
+% "\tl_const:Nn" \meta{\tlvar} \Arg{token list}
+% \end{syntax}
+% Defines \meta{\tlvar} as a constant expanding to \meta{token list}.
+% The name of the constant must be free when the constant is created.
+% \end{function}
%
% \begin{function}{%
% \tl_use:N |
@@ -444,6 +452,23 @@
% empty or contains only blank spaces.
% \end{function}
%
+%
+%
+% \begin{function}{ \tl_if_single_p:n / (EXP) | \tl_if_single:n / (TF)(EXP) |
+% \tl_if_single_p:N / (EXP) | \tl_if_single:N / (TF)(EXP) }
+% \begin{syntax}
+% "\tl_if_single:NTF" \Arg{\tlvar} \Arg{true code} \Arg{false code}
+% "\tl_if_single:nTF" \Arg{\tlist} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Conditional returning true if the token list or the contents of the \tlvar\
+% consists of a single token only.
+%
+% Note that an input of `space'\footnote{But remember any number of
+% consequtive spaces are read as a single space by \TeX.} returns <true>
+% from this function.
+% \end{function}
+%
+%
% \begin{function}{\tl_to_lowercase:n |
% \tl_to_uppercase:n
% }
@@ -575,6 +600,11 @@
% This was named \tn{@empty} in \LaTeX2 and \tn{empty} in plain \TeX{}.
% \end{texnote}
% \end{variable}
+%
+% \begin{variable}{\c_space_tl}
+% A space token contained in a token list (compare this with
+% \cs{char_space_token}). For use where an explicit space is required.
+% \end{variable}
%
% \begin{variable}{%
% \l_tmpa_tl |
@@ -583,23 +613,35 @@
% \g_tmpb_tl
% }
% Scratch register for immediate use. They are not used by conditionals
-% or predicate functions.
+% or predicate functions. However, it is important to note that you should
+% never rely on such scratch variables unless you fully control the code used
+% between setting them and retrieving their value. Calling code from other
+% modules, or worse allowing arbitrary user input to interfere might result in
+% them not containing what you expect. In that is the case you better define
+% your own scratch variables that are tight to your code by giving them
+% suitable names.
% \end{variable}
%
% \begin{variable}{%
-% \l_tl_replace_toks |
+% \l_tl_replace_tl |
% }
% Internal register used in the replace functions.
% \end{variable}
%
% \begin{variable}{%
-% \l_testa_tl |
-% \l_testb_tl |
-% \g_testa_tl |
-% \g_testb_tl |
+% \l_kernel_testa_tl |
+% \l_kernel_testb_tl |
% }
% Registers used for conditional processing if the engine doesn't
-% support arbitrary string comparison.
+% support arbitrary string comparison. Not for use outside the kernel code!
+% \end{variable}
+%
+% \begin{variable}{%
+% \l_kernel_tmpa_tl |
+% \l_kernel_tmpb_tl
+% }
+% Scratch registers reserved for other places in kernel code. Not for use
+% outside the kernel code!
% \end{variable}
%
% \begin{variable}{%
@@ -805,7 +847,7 @@
% specify an initial value. This is the only way to give values to
% constants.
% \begin{macrocode}
-\cs_new:Npn \tl_new:Nn #1#2{
+\cs_new_protected:Npn \tl_new:Nn #1#2{
\chk_if_free_cs:N #1
% \end{macrocode}
% If checking we don't allow constants to be defined.
@@ -819,19 +861,30 @@
\cs_gset_nopar:Npn #1{#2}
}
\cs_generate_variant:Nn \tl_new:Nn {cn}
-\cs_new:Npn \tl_new:Nx #1#2{
+\cs_new_protected:Npn \tl_new:Nx #1#2{
\chk_if_free_cs:N #1
%<check> \chk_var_or_const:N #1
\cs_gset_nopar:Npx #1{#2}
}
-\cs_new_nopar:Npn \tl_new:N #1{\tl_new:Nn #1{}}
-\cs_new_nopar:Npn \tl_new:c #1{\tl_new:cn {#1}{}}
+\cs_new_protected_nopar:Npn \tl_new:N #1{\tl_new:Nn #1{}}
+\cs_new_protected_nopar:Npn \tl_new:c #1{\tl_new:cn {#1}{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
+%
+%\begin{macro}{\tl_const:Nn}
+% For creating constant token lists: there is not actually anything here
+% that cannot be achieved using \cs{tl_new:N} and \cs{tl_set:Nn}
+% \begin{macrocode}
+\cs_new_protected:Npn \tl_const:Nn #1#2 {
+ \tl_new:N #1
+ \tl_gset:Nn #1 {#2}
+}
+% \end{macrocode}
+%\end{macro}
%
% \begin{macro}{\tl_use:N}
% \begin{macro}{\tl_use:c}
@@ -864,94 +917,81 @@
% \end{macrocode}
% \end{macro}
%
-%
-% \begin{macro}{\tl_set:Nn}
-% \begin{macro}{\tl_set:NV}
-% \begin{macro}{\tl_set:No}
-% \begin{macro}{\tl_set:Nv}
-% \begin{macro}{\tl_set:Nf}
-% \begin{macro}{\tl_set:Nx}
-% \begin{macro}{\tl_set:cn}
-% \begin{macro}{\tl_set:cV}
-% \begin{macro}{\tl_set:co}
-% \begin{macro}{\tl_set:cx}
-% \begin{macro}{\tl_gset:Nn}
-% \begin{macro}{\tl_gset:NV}
-% \begin{macro}{\tl_gset:No}
-% \begin{macro}{\tl_gset:Nv}
-% \begin{macro}{\tl_gset:Nx}
-% \begin{macro}{\tl_gset:cn}
-% \begin{macro}{\tl_gset:cx}
-% To set token lists to a specific value to type of functions are
-% available: |\tl_set_eq:NN| takes two token-lists as its
-% arguments assign the first the contents of the second;
-% |\tl_set:Nn| has as its second argument a `real' list of tokens.
-% One can view |\tl_set_eq:NN| as a special form of |\tl_set:No|.
-% Both functions have global counterparts.
-%
-% During development we check if the token list that is being
-% assigned to exists. If not, a warning will be issued.
-% \begin{macrocode}
-%<*check>
-\cs_new:Npn \tl_set:Nn #1#2{
- \chk_exist_cs:N #1 \cs_set_nopar:Npn #1{#2}
-% \end{macrocode}
-% We use |\chk_local_or_pref_global:N| after the assignment to
-% allow constructs with |\pref_global_chk:|. But one should note
-% that this is less efficient then using the real global variant
-% since they are built-in.
-% \begin{macrocode}
- \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_set:Nx #1#2{
- \chk_exist_cs:N #1 \cs_set_nopar:Npx #1{#2} \chk_local:N #1
-}
-% \end{macrocode}
-% The the global versions.
-% \begin{macrocode}
-\cs_new:Npn \tl_gset:Nn #1#2{
- \chk_exist_cs:N #1 \cs_gset_nopar:Npn #1{#2} \chk_global:N #1
-}
-\cs_new:Npn \tl_gset:Nx #1#2{
- \chk_exist_cs:N #1 \cs_gset_nopar:Npx #1{#2} \chk_global:N #1
-}
-%</check>
-% \end{macrocode}
-% For some functions like |\tl_set:Nn| we need to define the
-% `non-check' version with arguments since we want to allow
-% constructions like |\tl_set:Nn\l_tmpa_tl\foo| and so we can't
-% use the primitive \TeX{} command.
-% \begin{macrocode}
-%<*!check>
-\cs_new:Npn\tl_set:Nn#1#2{\cs_set_nopar:Npn#1{#2}}
-\cs_new:Npn\tl_set:Nx#1#2{\cs_set_nopar:Npx#1{#2}}
-\cs_new:Npn\tl_gset:Nn#1#2{\cs_gset_nopar:Npn#1{#2}}
-\cs_new:Npn\tl_gset:Nx#1#2{\cs_gset_nopar:Npx#1{#2}}
-%</!check>
-% \end{macrocode}
-% The remaining functions can just be defined with help from the
-% expansion module.
-% \begin{macrocode}
-\cs_generate_variant:Nn \tl_set:Nn {NV,No,Nv,Nf,cn,cV,co,cx}
-\cs_generate_variant:Nn \tl_gset:Nn {NV,No,Nv,cn,cx}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
+%\begin{macro}{\tl_set:Nn}
+%\begin{macro}{\tl_set:NV}
+%\begin{macro}{\tl_set:Nv}
+%\begin{macro}{\tl_set:No}
+%\begin{macro}{\tl_set:Nf}
+%\begin{macro}{\tl_set:Nx}
+%\begin{macro}{\tl_set:cn}
+%\begin{macro}{\tl_set:cV}
+%\begin{macro}{\tl_set:cv}
+%\begin{macro}{\tl_set:co}
+%\begin{macro}{\tl_set:cx}
+%\begin{macro}{\tl_gset:Nn}
+%\begin{macro}{\tl_gset:NV}
+%\begin{macro}{\tl_gset:Nv}
+%\begin{macro}{\tl_gset:No}
+%\begin{macro}{\tl_gset:Nf}
+%\begin{macro}{\tl_gset:Nx}
+%\begin{macro}{\tl_gset:cn}
+%\begin{macro}{\tl_gset:cV}
+%\begin{macro}{\tl_gset:cv}
+%\begin{macro}{\tl_gset:cx}
+% By using \cs{exp_not:n} token list variables can contain "#" tokens.
+% \begin{macrocode}
+\cs_new_protected:Npn \tl_set:Nn #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:n {#2} }
+}
+\cs_new_protected:Npn \tl_set:Nx #1#2 {
+ \cs_set_nopar:Npx #1 {#2}
+}
+\cs_new_protected:Npn \tl_gset:Nn #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:n {#2} }
+}
+\cs_new_protected:Npn \tl_gset:Nx #1#2 {
+ \cs_gset_nopar:Npx #1 {#2}
+}
+\cs_generate_variant:Nn \tl_set:Nn { NV }
+\cs_generate_variant:Nn \tl_set:Nn { Nv }
+\cs_generate_variant:Nn \tl_set:Nn { No }
+\cs_generate_variant:Nn \tl_set:Nn { Nf }
+\cs_generate_variant:Nn \tl_set:Nn { cV }
+\cs_generate_variant:Nn \tl_set:Nn { c }
+\cs_generate_variant:Nn \tl_set:Nn { cv }
+\cs_generate_variant:Nn \tl_set:Nn { co }
+\cs_generate_variant:Nn \tl_set:Nx { c }
+\cs_generate_variant:Nn \tl_gset:Nn { NV }
+\cs_generate_variant:Nn \tl_gset:Nn { Nv }
+\cs_generate_variant:Nn \tl_gset:Nn { No }
+\cs_generate_variant:Nn \tl_gset:Nn { Nf }
+\cs_generate_variant:Nn \tl_gset:Nn { c }
+\cs_generate_variant:Nn \tl_gset:Nn { cV }
+\cs_generate_variant:Nn \tl_gset:Nn { cv }
+\cs_generate_variant:Nn \tl_gset:Nx { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+
%
% \begin{macro}{\tl_set_eq:NN}
% \begin{macro}{\tl_set_eq:Nc}
@@ -964,11 +1004,11 @@
% For setting token list variables equal to each other. First checking:
% \begin{macrocode}
%<*check>
-\cs_new_nopar:Npn \tl_set_eq:NN #1#2{
+\cs_new_protected_nopar:Npn \tl_set_eq:NN #1#2{
\chk_exist_cs:N #1 \cs_set_eq:NN #1#2
\chk_local_or_pref_global:N #1 \chk_var_or_const:N #2
}
-\cs_new_nopar:Npn \tl_gset_eq:NN #1#2{
+\cs_new_protected_nopar:Npn \tl_gset_eq:NN #1#2{
\chk_exist_cs:N #1 \cs_gset_eq:NN #1#2
\chk_global:N #1 \chk_var_or_const:N #2
}
@@ -1003,9 +1043,9 @@
% \begin{macro}{\tl_gclear:c}
% Clearing a token list variable.
% \begin{macrocode}
-\cs_new_nopar:Npn \tl_clear:N #1{\tl_set_eq:NN #1\c_empty_tl}
+\cs_new_protected_nopar:Npn \tl_clear:N #1{\tl_set_eq:NN #1\c_empty_tl}
\cs_generate_variant:Nn \tl_clear:N {c}
-\cs_new_nopar:Npn \tl_gclear:N #1{\tl_gset_eq:NN #1\c_empty_tl}
+\cs_new_protected_nopar:Npn \tl_gclear:N #1{\tl_gset_eq:NN #1\c_empty_tl}
\cs_generate_variant:Nn \tl_gclear:N {c}
% \end{macrocode}
% \end{macro}
@@ -1019,12 +1059,12 @@
% is cleared, if it doesn't it is allocated.
% \begin{macrocode}
%<*check>
-\cs_new_nopar:Npn \tl_clear_new:N #1{
+\cs_new_protected_nopar:Npn \tl_clear_new:N #1{
\chk_var_or_const:N #1
\if_predicate:w \cs_if_exist_p:N #1
\tl_clear:N #1
\else:
- \tl_new:Nn #1{}
+ \tl_new:N #1
\fi:
}
%</check>
@@ -1039,12 +1079,12 @@
% These are the global versions of the above.
% \begin{macrocode}
%<*check>
-\cs_new_nopar:Npn \tl_gclear_new:N #1{
+\cs_new_protected_nopar:Npn \tl_gclear_new:N #1{
\chk_var_or_const:N #1
\if_predicate:w \cs_if_exist_p:N #1
\tl_gclear:N #1
\else:
- \tl_new:Nn #1{}
+ \tl_new:N #1
\fi:}
%</check>
%<-check>\cs_new_eq:NN \tl_gclear_new:N \tl_gclear:N
@@ -1053,168 +1093,165 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\tl_put_left:Nn}
-% \begin{macro}{\tl_put_left:NV}
-% \begin{macro}{\tl_put_left:No}
-% \begin{macro}{\tl_put_left:Nx}
-% \begin{macro}{\tl_put_left:cn}
-% \begin{macro}{\tl_put_left:cV}
-% \begin{macro}{\tl_put_left:co}
-% \begin{macro}{\tl_gput_left:Nn}
-% \begin{macro}{\tl_gput_left:NV}
-% \begin{macro}{\tl_gput_left:No}
-% \begin{macro}{\tl_gput_left:Nx}
-% \begin{macro}{\tl_gput_left:cn}
-% \begin{macro}{\tl_gput_left:cV}
-% \begin{macro}{\tl_gput_left:co}
-% We can add tokens to the left (either globally or locally). It is
-% not quite as easy as we would like because we have to ensure the
-% assignments
-% \begin{verbatim}
-% \tl_set:Nn \l_tmpa_tl{##1abc##2def}
-% \tl_set:Nn \l_tmpb_tl{##1abc}
-% \tl_put_right:Nn \l_tmpb_tl {##2def}
-% \end{verbatim}
-% cause |\l_tmpa_tl| and |\l_tmpb_tl| to be identical. The old
-% code did not succeed in doing this (it gave an error) and so we
-% use a different technique where the item(s) to be added are first
-% stored in a temporary variable and then added using an |x| type
-% expansion combined with the appropriate level of
-% non-expansion. Putting the tokens directly into one assignment
-% does not work unless we want full expansion. Note (according to
-% the warning earlier) \TeX\ does not allow us to treat |#|s the
-% same in all cases. Tough.
-% \begin{macrocode}
-\cs_new:Npn \tl_put_left:Nn #1#2 {
- \tl_set:Nn \l_exp_tl {#2}
- \tl_set:Nx #1 { \exp_not:V \l_exp_tl \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_put_left:NV #1#2 {
- \tl_set:Nx #1 { \exp_not:V #2 \exp_not:V #1 }
-}
-\cs_new:Npn \tl_put_left:No #1#2{
- \tl_set:No \l_exp_tl {#2}
- \tl_set:Nx #1 { \exp_not:V \l_exp_tl \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_put_left:Nx #1#2{
- \tl_set:Nx #1 { #2 \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_gput_left:Nn #1#2{
- \tl_set:Nn \l_exp_tl{#2}
- \tl_gset:Nx #1 { \exp_not:V \l_exp_tl \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_gput_left:NV #1#2 {
- \tl_gset:Nx #1 { \exp_not:V #2 \exp_not:V #1 }
-}
-\cs_new:Npn \tl_gput_left:No #1#2{
- \tl_set:No \l_exp_tl {#2}
- \tl_gset:Nx #1 { \exp_not:V \l_exp_tl \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_gput_left:Nx #1#2{
- \tl_gset:Nx #1 { #2 \exp_not:V #1 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_generate_variant:Nn \tl_put_left:Nn {cn,co,cV}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_generate_variant:Nn \tl_gput_left:Nn {cn,co}
-\cs_generate_variant:Nn \tl_gput_left:NV {cV}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\tl_put_right:Nn}
-% \begin{macro}{\tl_put_right:NV}
-% \begin{macro}{\tl_put_right:No}
-% \begin{macro}{\tl_put_right:Nx}
-% \begin{macro}{\tl_put_right:cn}
-% \begin{macro}{\tl_put_right:cV}
-% \begin{macro}{\tl_put_right:co}
-% \begin{macro}{\tl_gput_right:Nn}
-% \begin{macro}{\tl_gput_right:NV}
-% \begin{macro}{\tl_gput_right:No}
-% \begin{macro}{\tl_gput_right:Nx}
-% \begin{macro}{\tl_gput_right:cn}
-% \begin{macro}{\tl_gput_right:cV}
-% \begin{macro}{\tl_gput_right:co}
-% These are variants of the functions above, but for adding tokens
-% to the right.
-% \begin{macrocode}
-\cs_new:Npn \tl_put_right:Nn #1#2 {
- \tl_set:Nn \l_exp_tl {#2}
- \tl_set:Nx #1 { \exp_not:V #1 \exp_not:V \l_exp_tl }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_gput_right:Nn #1#2{
- \tl_set:Nn \l_exp_tl {#2}
- \tl_gset:Nx #1 { \exp_not:V #1 \exp_not:V \l_exp_tl }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_put_right:NV #1#2 {
- \tl_set:Nx #1 { \exp_not:V #1 \exp_not:V #2 }
-}
-\cs_new:Npn \tl_put_right:No #1#2 {
- \tl_set:No \l_exp_tl {#2}
- \tl_set:Nx #1 { \exp_not:V #1 \exp_not:V \l_exp_tl }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_new:Npn \tl_gput_right:NV #1#2 {
- \tl_gset:Nx #1 { \exp_not:V #1 \exp_not:V #2 }
-}
-\cs_new:Npn \tl_gput_right:No #1#2 {
- \tl_set:No \l_exp_tl {#2}
- \tl_gset:Nx #1 { \exp_not:V #1 \exp_not:V \l_exp_tl }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_set:Npn \tl_put_right:Nx #1#2 {
- \tl_set:Nx #1 { \exp_not:V #1 #2 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_set:Npn \tl_gput_right:Nx #1#2 {
- \tl_gset:Nx #1 { \exp_not:V #1 #2 }
-%<check> \chk_local_or_pref_global:N #1
-}
-\cs_generate_variant:Nn \tl_put_right:Nn {cn,co}
-\cs_generate_variant:Nn \tl_put_right:NV {cV}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_generate_variant:Nn \tl_gput_right:Nn {cn,co,cV}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-%
+%\begin{macro}{\tl_put_right:Nn}
+%\begin{macro}{\tl_put_right:NV}
+%\begin{macro}{\tl_put_right:Nv}
+%\begin{macro}{\tl_put_right:No}
+%\begin{macro}{\tl_put_right:Nx}
+%\begin{macro}{\tl_put_right:cn}
+%\begin{macro}{\tl_put_right:cV}
+%\begin{macro}{\tl_put_right:cv}
+%\begin{macro}{\tl_put_right:cx}
+%\begin{macro}{\tl_gput_right:Nn}
+%\begin{macro}{\tl_gput_right:NV}
+%\begin{macro}{\tl_gput_right:Nv}
+%\begin{macro}{\tl_gput_right:No}
+%\begin{macro}{\tl_gput_right:Nx}
+%\begin{macro}{\tl_gput_right:cn}
+%\begin{macro}{\tl_gput_right:cV}
+%\begin{macro}{\tl_gput_right:cv}
+%\begin{macro}{\tl_gput_right:co}
+%\begin{macro}{\tl_gput_right:cx}
+% Adding to one end of a token list is done partially using
+% hand tuned functions for performance reasons.
+% \begin{macrocode}
+\cs_new_protected:Npn \tl_put_right:Nn #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} }
+}
+\cs_new_protected:Npn \tl_put_right:NV #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 }
+}
+\cs_new_protected:Npn \tl_put_right:Nv #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} }
+}
+\cs_new_protected:Npn \tl_put_right:Nx #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 #2 }
+}
+\cs_new_protected:Npn \tl_put_right:No #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #1 \exp_not:o {#2} }
+}
+\cs_new_protected:Npn \tl_gput_right:Nn #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:n {#2} }
+}
+\cs_new_protected:Npn \tl_gput_right:NV #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:V #2 }
+}
+\cs_new_protected:Npn \tl_gput_right:Nv #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:v {#2} }
+}
+\cs_new_protected:Npn \tl_gput_right:No #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 \exp_not:o {#2} }
+}
+\cs_new_protected:Npn \tl_gput_right:Nx #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #1 #2 }
+}
+\cs_generate_variant:Nn \tl_put_right:Nn { c }
+\cs_generate_variant:Nn \tl_put_right:NV { c }
+\cs_generate_variant:Nn \tl_put_right:Nv { c }
+\cs_generate_variant:Nn \tl_put_right:Nx { c }
+\cs_generate_variant:Nn \tl_gput_right:Nn { c }
+\cs_generate_variant:Nn \tl_gput_right:NV { c }
+\cs_generate_variant:Nn \tl_gput_right:Nv { c }
+\cs_generate_variant:Nn \tl_gput_right:No { c }
+\cs_generate_variant:Nn \tl_gput_right:Nx { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\tl_put_left:Nn}
+%\begin{macro}{\tl_put_left:NV}
+%\begin{macro}{\tl_put_left:Nv}
+%\begin{macro}{\tl_put_left:No}
+%\begin{macro}{\tl_put_left:Nx}
+%\begin{macro}{\tl_put_left:cn}
+%\begin{macro}{\tl_put_left:cV}
+%\begin{macro}{\tl_put_left:cv}
+%\begin{macro}{\tl_put_left:cx}
+%\begin{macro}{\tl_gput_left:Nn}
+%\begin{macro}{\tl_gput_left:NV}
+%\begin{macro}{\tl_gput_left:Nv}
+%\begin{macro}{\tl_gput_left:No}
+%\begin{macro}{\tl_gput_left:Nx}
+%\begin{macro}{\tl_gput_left:cn}
+%\begin{macro}{\tl_gput_left:cV}
+%\begin{macro}{\tl_gput_left:cv}
+%\begin{macro}{\tl_gput_left:cx}
+% Adding to the left is basically the same as putting on the right.
+% \begin{macrocode}
+\cs_new_protected:Npn \tl_put_left:Nn #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_put_left:NV #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_put_left:Nv #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_put_left:Nx #1#2 {
+ \cs_set_nopar:Npx #1 { #2 \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_put_left:No #1#2 {
+ \cs_set_nopar:Npx #1 { \exp_not:o {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_gput_left:Nn #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:n {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_gput_left:NV #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:V #2 \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_gput_left:Nv #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:v {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_gput_left:No #1#2 {
+ \cs_gset_nopar:Npx #1 { \exp_not:o {#2} \exp_not:V #1 }
+}
+\cs_new_protected:Npn \tl_gput_left:Nx #1#2 {
+ \cs_gset_nopar:Npx #1 { #2 \exp_not:V #1 }
+}
+\cs_generate_variant:Nn \tl_put_left:Nn { c }
+\cs_generate_variant:Nn \tl_put_left:NV { c }
+\cs_generate_variant:Nn \tl_put_left:Nv { c }
+\cs_generate_variant:Nn \tl_put_left:Nx { c }
+\cs_generate_variant:Nn \tl_gput_left:Nn { c }
+\cs_generate_variant:Nn \tl_gput_left:NV { c }
+\cs_generate_variant:Nn \tl_gput_left:Nv { c }
+\cs_generate_variant:Nn \tl_gput_left:Nx { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
% \begin{macro}{\tl_gset:Nc}
% \begin{macro}{\tl_set:Nc}
@@ -1226,7 +1263,7 @@
% Construct a control sequence on the fly from |#2| and save it in
% |#1|.
% \begin{macrocode}
-\cs_new_nopar:Npn \tl_gset:Nc {
+\cs_new_protected_nopar:Npn \tl_gset:Nc {
%<*check>
\pref_global_chk:
%</check>
@@ -1236,7 +1273,7 @@
% |\pref_global_chk:| will turn the variable check in |\tl_set:No|
% into a global check.
% \begin{macrocode}
-\cs_new_nopar:Npn \tl_set:Nc #1#2{\tl_set:No #1{\cs:w#2\cs_end:}}
+\cs_new_protected_nopar:Npn \tl_set:Nc #1#2{\tl_set:No #1{\cs:w#2\cs_end:}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1244,18 +1281,29 @@
% \subsection{Variables and constants}
%
% \begin{macro}{\c_job_name_tl}
-% Inherited from the expl3 name for the primitive.
+% Inherited from the expl3 name for the primitive: this needs to
+% actually contain the text of the jobname rather than the name of
+% the primitive, of course.
% \begin{macrocode}
-\tl_new:Nn \c_job_name_tl {\tex_jobname:D}
+\tl_new:N \c_job_name_tl
+\tl_set:Nx \c_job_name_tl { \tex_jobname:D }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c_empty_tl}
% Two constants which are often used.
% \begin{macrocode}
-\tl_new:Nn \c_empty_tl {}
+\tl_const:Nn \c_empty_tl { }
% \end{macrocode}
% \end{macro}
+%
+%
+%\begin{macro}{\c_space_tl}
+% A space as a token list (as opposed to as a character).
+% \begin{macrocode}
+\tl_const:Nn \c_space_tl { ~ }
+% \end{macrocode}
+%\end{macro}
%
% \begin{macro}{\g_tmpa_tl}
% \begin{macro}{\g_tmpb_tl}
@@ -1265,36 +1313,43 @@
% can't count on other macros not to redefine them from under you.
%
% \begin{macrocode}
-\tl_new:Nn \g_tmpa_tl{}
-\tl_new:Nn \g_tmpb_tl{}
+\tl_new:N \g_tmpa_tl
+\tl_new:N \g_tmpb_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\l_testa_tl}
-% \begin{macro}{\l_testb_tl}
-% \begin{macro}{\g_testa_tl}
-% \begin{macro}{\g_testb_tl}
-% Global and local temporaries. These are the ones for test
+% \begin{macro}{\l_kernel_testa_tl}
+% \begin{macro}{\l_kernel_testb_tl}
+% Local temporaries. These are the ones for test
% routines. This means that one can safely use other temporaries
% when calling test routines.
% \begin{macrocode}
-\tl_new:Nn \l_testa_tl {}
-\tl_new:Nn \l_testb_tl {}
-\tl_new:Nn \g_testa_tl {}
-\tl_new:Nn \g_testb_tl {}
+\tl_new:N \l_kernel_testa_tl
+\tl_new:N \l_kernel_testb_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
-% \end{macro}
-% \end{macro}
%
% \begin{macro}{\l_tmpa_tl}
% \begin{macro}{\l_tmpb_tl}
-% These are local temporary token list variables.
+% These are local temporary token list variables. Be sure not to assume
+% that the value you put into them will survive for long---see discussion above.
% \begin{macrocode}
-\tl_new:Nn \l_tmpa_tl{}
-\tl_new:Nn \l_tmpb_tl{}
+\tl_new:N \l_tmpa_tl
+\tl_new:N \l_tmpb_tl
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\l_kernel_tmpa_tl}
+% \begin{macro}{\l_kernel_tmpb_tl}
+% These are local temporary token list variables reserved for use by the
+% kernel. They should not be used by other modules.
+% \begin{macrocode}
+\tl_new:N \l_kernel_tmpa_tl
+\tl_new:N \l_kernel_tmpb_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1402,6 +1457,49 @@
% \end{macro}
% \end{macro}
%
+%
+% \begin{macro}[TF]{\tl_if_single:n}
+% \begin{macro}{\tl_if_single_p:n}
+% If the argument is a single token. `Space' is considered `true'.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \tl_if_single:n {p,TF,T,F} {
+ \tl_if_empty:nTF {#1}
+ {\prg_return_false:}
+ {
+ \tl_if_blank:nTF {#1}
+ {\prg_return_true:}
+ {
+ \_tl_if_single_aux:w #1 \q_nil
+ }
+ }
+}
+% \end{macrocode}
+% Use "\exp_after:wN" below I know what I'm doing.
+% Use "\exp_args:NV" or "\exp_args_unbraced:NV"
+% for more flexibility in your own code.
+% \begin{macrocode}
+\prg_new_conditional:Nnn \tl_if_single:N {p,TF,T,F} {
+ \tl_if_empty:NTF #1
+ {\prg_return_false:}
+ {
+ \exp_after:wN \tl_if_blank:nTF #1
+ {\prg_return_true:}
+ {
+ \exp_after:wN \_tl_if_single_aux:w #1 \q_nil
+ }
+ }
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new:Npn \_tl_if_single_aux:w #1#2 \q_nil {
+ \tl_if_empty:nTF {#2} \prg_return_true: \prg_return_false:
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
% \begin{macro}[TF]{\tl_if_eq:xx,\tl_if_eq:nn,\tl_if_eq:VV,\tl_if_eq:oo,
% \tl_if_eq:xn,\tl_if_eq:nx,\tl_if_eq:on,\tl_if_eq:no,
% \tl_if_eq:Vn,\tl_if_eq:nV,
@@ -1467,7 +1565,7 @@
% to use the new \verb|\tl_map_inline:nn| function yet.
% \begin{macrocode}
\cs_set_nopar:Npn \tl_tmp:w #1 {
- \tl_set:Nx \l_tmpa_tl {
+ \tl_set:Nx \l_kernel_tmpa_tl {
\exp_not:N \prg_new_conditional:Npnn \exp_not:c {tl_if_eq:#1}
####1 ####2 {p,TF,T,F} {
\exp_not:N \tex_ifnum:D
@@ -1475,7 +1573,7 @@
\exp_not:n{ =\c_zero \prg_return_true: \else: \prg_return_false: \fi: }
}
}
- \l_tmpa_tl
+ \l_kernel_tmpa_tl
}
\tl_tmp:w{xx} \tl_tmp:w{nx} \tl_tmp:w{ox} \tl_tmp:w{Vx}
\tl_tmp:w{xn} \tl_tmp:w{nn} \tl_tmp:w{on} \tl_tmp:w{Vn}
@@ -1495,100 +1593,100 @@
% \begin{macrocode}
\cs_if_exist:cF{pdf_strcmp:D}{
\prg_set_protected_conditional:Npnn \tl_if_eq:nn #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:nV #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl { \exp_not:n {#1} }
- \tl_set:Nx \l_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl { \exp_not:n {#1} }
+ \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
+ \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:no #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:nx #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:n{#1}}
- \tl_set:Nx \l_testb_tl {#2}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:n{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {#2}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:Vn #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_testb_tl { \exp_not:n{#2} }
- \if_meaning:w \l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
+ \tl_set:Nx \l_kernel_testb_tl { \exp_not:n{#2} }
+ \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:on #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:VV #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
+ \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
+ \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:oo #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:Vx #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl { \exp_not:V #1 }
- \tl_set:Nx \l_testb_tl {#2}
- \if_meaning:w \l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl { \exp_not:V #1 }
+ \tl_set:Nx \l_kernel_testb_tl {#2}
+ \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:ox #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {\exp_not:o{#1}}
- \tl_set:Nx \l_testb_tl {#2}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {\exp_not:o{#1}}
+ \tl_set:Nx \l_kernel_testb_tl {#2}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:xn #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {#1}
- \tl_set:Nx \l_testb_tl {\exp_not:n{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {#1}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:n{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:xV #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {#1}
- \tl_set:Nx \l_testb_tl { \exp_not:V #2 }
- \if_meaning:w \l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {#1}
+ \tl_set:Nx \l_kernel_testb_tl { \exp_not:V #2 }
+ \if_meaning:w \l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:xo #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {#1}
- \tl_set:Nx \l_testb_tl {\exp_not:o{#2}}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {#1}
+ \tl_set:Nx \l_kernel_testb_tl {\exp_not:o{#2}}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
\prg_set_protected_conditional:Npnn \tl_if_eq:xx #1#2 {TF,T,F} {
- \tl_set:Nx \l_testa_tl {#1}
- \tl_set:Nx \l_testb_tl {#2}
- \if_meaning:w\l_testa_tl \l_testb_tl
+ \tl_set:Nx \l_kernel_testa_tl {#1}
+ \tl_set:Nx \l_kernel_testb_tl {#2}
+ \if_meaning:w\l_kernel_testa_tl \l_kernel_testb_tl
\prg_return_true: \else: \prg_return_false:
\fi:
}
@@ -1670,7 +1768,7 @@
% them nestable. We can
% also make use of |\tl_map_function:Nn| from before.
% \begin{macrocode}
-\cs_new:Npn \tl_map_inline:nn #1#2{
+\cs_new_protected:Npn \tl_map_inline:nn #1#2{
\int_gincr:N \g_tl_inline_level_int
\cs_gset:cpn {tl_map_inline_ \int_use:N \g_tl_inline_level_int :n}
##1{#2}
@@ -1679,7 +1777,7 @@
#1 \q_recursion_tail\q_recursion_stop
\int_gdecr:N \g_tl_inline_level_int
}
-\cs_new:Npn \tl_map_inline:Nn #1#2{
+\cs_new_protected:Npn \tl_map_inline:Nn #1#2{
\int_gincr:N \g_tl_inline_level_int
\cs_gset:cpn {tl_map_inline_ \int_use:N \g_tl_inline_level_int :n}
##1{#2}
@@ -1703,13 +1801,13 @@
% |\tl_map_variable:nNn| \meta{\tlist} \meta{temp} \meta{action} assigns
% \meta{temp} to each element and executes \meta{action}.
% \begin{macrocode}
-\cs_new:Npn \tl_map_variable:nNn #1#2#3{
+\cs_new_protected:Npn \tl_map_variable:nNn #1#2#3{
\tl_map_variable_aux:Nnn #2 {#3} #1 \q_recursion_tail \q_recursion_stop
}
% \end{macrocode}
% Next really has to be v/V args
% \begin{macrocode}
-\cs_new_nopar:Npn \tl_map_variable:NNn {\exp_args:No \tl_map_variable:nNn}
+\cs_new_protected_nopar:Npn \tl_map_variable:NNn {\exp_args:No \tl_map_variable:nNn}
\cs_generate_variant:Nn \tl_map_variable:NNn {c}
% \end{macrocode}
% \end{macro}
@@ -1721,7 +1819,7 @@
% |#3| and then check if that's the stop marker. If it is, break the
% loop. If not, execute the action |#2| and continue.
% \begin{macrocode}
-\cs_new:Npn \tl_map_variable_aux:Nnn #1#2#3{
+\cs_new_protected:Npn \tl_map_variable_aux:Nnn #1#2#3{
\tl_set:Nn #1{#3}
\quark_if_recursion_tail_stop:N #1
#2 \tl_map_variable_aux:Nnn #1{#2}
@@ -1761,7 +1859,7 @@
% This reverses the list, leaving "\exp_stop_f:" in front, which in turn
% is removed by the "f" expansion which comes to a halt.
% \begin{macrocode}
-\cs_new_nopar:Npn \tl_reverse:N #1 {
+\cs_new_protected_nopar:Npn \tl_reverse:N #1 {
\tl_set:Nf #1 { \tl_reverse:o { #1 \exp_stop_f: } }
}
% \end{macrocode}
@@ -1774,18 +1872,18 @@
% Count number of elements within a token list or token list
% variable. Brace groups within the list are read as a single
% element.
-% "\num_elt_count:n" grabs the element and replaces it by "+1". The
-% "0" to ensure it works on an empty list.
+% \cs{tl_elt_count_aux:n} grabs the element and replaces it by "+1".
+% The "0" to ensure it works on an empty list.
% \begin{macrocode}
\cs_new:Npn \tl_elt_count:n #1{
\intexpr_eval:n {
- \tl_map_function:nN {#1}\num_elt_count:n
+ 0 \tl_map_function:nN {#1} \tl_elt_count_aux:n
}
}
\cs_generate_variant:Nn \tl_elt_count:n {V,o}
\cs_new_nopar:Npn \tl_elt_count:N #1{
\intexpr_eval:n {
- \tl_map_function:NN #1 \num_elt_count:n
+ 0 \tl_map_function:NN #1 \tl_elt_count_aux:n
}
}
% \end{macrocode}
@@ -1793,6 +1891,12 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \begin{macro}[aux]{\tl_num_elt_count_aux:n}
+% Helper function for counting elements in a token list.
+% \begin{macrocode}
+\cs_new:Npn \tl_elt_count_aux:n #1 { + 1 }
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\tl_set_rescan:Nnn, \tl_gset_rescan:Nnn}
% These functions store the \marg{\tlist} in \meta{\tlvar} after
@@ -1803,8 +1907,8 @@
% \item \marg{\tlist}
% \end{arguments}
% \begin{macrocode}
-\cs_new:Npn \tl_set_rescan:Nnn { \tl_set_rescan_aux:NNnn \tl_set:Nn }
-\cs_new:Npn \tl_gset_rescan:Nnn { \tl_set_rescan_aux:NNnn \tl_gset:Nn }
+\cs_new_protected:Npn \tl_set_rescan:Nnn { \tl_set_rescan_aux:NNnn \tl_set:Nn }
+\cs_new_protected:Npn \tl_gset_rescan:Nnn { \tl_set_rescan_aux:NNnn \tl_gset:Nn }
% \end{macrocode}
%
% \begin{macro}[aux]{\tl_set_rescan_aux:NNnn}
@@ -1845,7 +1949,7 @@
\tex_catcode:D `\B = 3 \scan_stop:
\tl_to_lowercase:n {
\group_end:
- \tl_new:Nn \c_two_ats_with_two_catcodes_tl {AB}
+ \tl_const:Nn \c_two_ats_with_two_catcodes_tl { A B }
}
% \end{macrocode}
% \end{macro}
@@ -1859,7 +1963,7 @@
% Note that if you change "\etex_everyeof:D" in "#3"
% then you'd better do it correctly!
% \begin{macrocode}
-\cs_new:Npn \tl_set_rescan_aux:NNnn #1#2#3#4 {
+\cs_new_protected:Npn \tl_set_rescan_aux:NNnn #1#2#3#4 {
\group_begin:
\toks_set:NV \etex_everyeof:D \c_two_ats_with_two_catcodes_tl
\tex_endlinechar:D = \c_minus_one
@@ -1867,7 +1971,7 @@
\exp_after:wN \tl_rescan_aux:w \etex_scantokens:D {#4}
\exp_args:NNNV
\group_end:
- #1 #2 \l_tmpa_toks
+ #1 #2 \l_tmpa_tl
}
% \end{macrocode}
%
@@ -1877,7 +1981,7 @@
\exp_after:wN \tl_rescan_aux:w
\exp_after:wN #
\exp_after:wN 1 \c_two_ats_with_two_catcodes_tl {
- \tl_set:Nn \l_tmpa_toks {#1}
+ \tl_set:Nn \l_tmpa_tl {#1}
}
% \end{macrocode}
%
@@ -1896,20 +2000,20 @@
% The expanded versions are much simpler because the "\etex_scantokens:D"
% can occur within the expansion.
% \begin{macrocode}
-\cs_new:Npn \tl_set_rescan:Nnx #1#2#3 {
+\cs_new_protected:Npn \tl_set_rescan:Nnx #1#2#3 {
\group_begin:
\etex_everyeof:D { \exp_not:N }
\tex_endlinechar:D = \c_minus_one
#2
- \tl_set:Nx \l_tmpa_tl { \etex_scantokens:D {#3} }
+ \tl_set:Nx \l_kernel_tmpa_tl { \etex_scantokens:D {#3} }
\exp_args:NNNV
\group_end:
- \tl_set:Nn #1 \l_tmpa_tl
+ \tl_set:Nn #1 \l_kernel_tmpa_tl
}
% \end{macrocode}
% Globally is easier again:
% \begin{macrocode}
-\cs_new:Npn \tl_gset_rescan:Nnx #1#2#3 {
+\cs_new_protected:Npn \tl_gset_rescan:Nnx #1#2#3 {
\group_begin:
\etex_everyeof:D { \exp_not:N }
\tex_endlinechar:D = \c_minus_one
@@ -1927,14 +2031,14 @@
% \item Token list to re-tokenise
% \end{arguments}
% \begin{macrocode}
-\cs_new:Npn \tl_rescan:nn #1#2 {
+\cs_new_protected:Npn \tl_rescan:nn #1#2 {
\group_begin:
\toks_set:NV \etex_everyeof:D \c_two_ats_with_two_catcodes_tl
\tex_endlinechar:D = \c_minus_one
#1
\exp_after:wN \tl_rescan_aux:w \etex_scantokens:D {#2}
\exp_args:NV \group_end:
- \l_tmpa_toks
+ \l_tmpa_tl
}
% \end{macrocode}
% \end{macro}
@@ -1976,131 +2080,97 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\l_tl_replace_toks}
-% A temp variable for the replace operations.
-% \begin{macrocode}
-%%\l_tl_replace_toks % moved to l3token as alloc not set up yet.
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\tl_replace_in:Nnn}
-% \begin{macro}{\tl_replace_in:cnn}
-% \begin{macro}{\tl_greplace_in:Nnn}
-% \begin{macro}{\tl_greplace_in:cnn}
-% Replacing the first item in a token list variable goes like this:
-% Define a temporary function with delimited arguments containing
-% the search term and take a closer look at what is left. We append
-% the expansion of the token list with the search term plus the quark
-% |\q_no_value|. If the search term isn't present this last one is
-% found and the following token is the quark, so we test for
-% that. If the search term is present we will have to split off the
-% |#3\q_no_value| we had, so we define yet another function with
-% delimited arguments to do this. The advantage here is that now we
-% have a special end sequence so there is no problem if the search
-% term appears more than once. Only problem left is to prevent brace
-% stripping in both ends, so we prepend the expansion of the token list
-% with |\prg_do_nothing:| later to be expanded and also prepend the
-% remainder of the first split operation with |\prg_do_nothing:| also to
-% be expanded again later on.
-%
-% \begin{macro}[aux]{\tl_replace_in_aux:NNnn}
-% \begin{arguments}
-% \item "\tl_set:Nx" or "\tl_gset:Nx"
-% \item \meta{\tlvar}
-% \item item to find
-% \item replacement text
-% \end{arguments}
-% \begin{macrocode}
-\cs_new:Npn \tl_replace_in_aux:NNnn #1#2#3#4{
- \cs_set:Npn \tl_tmp:w ##1#3##2\q_stop{
- \quark_if_no_value:nF{##2}
- {
-% \end{macrocode}
-% At this point |##1| starts with a |\prg_do_nothing:| so we expand it to
-% remove it.
-% \begin{macrocode}
- \toks_set:No\l_tl_replace_toks{##1#4}
- \cs_set:Npn \tl_tmp:w ####1#3\q_no_value{
- \toks_put_right:No \l_tl_replace_toks { ####1 }
- }
- \tl_tmp:w \prg_do_nothing: ##2
-% \end{macrocode}
-% Now all that is done is setting the token list variable equal to the
-% expansion of the token register.
-% \begin{macrocode}
- #1#2{\toks_use:N\l_tl_replace_toks}
- }
- }
-% \end{macrocode}
-% Here is where we start the process. Note that the token list might start
-% with a space token so we use this little trick with |\use:n|
-% to prevent it from being removed.
+%\begin{macro}{\_l_tl_replace_tl}
+%\begin{macro}{\tl_replace_in:Nnn}
+%\begin{macro}{\tl_replace_in:cnn}
+%\begin{macro}{\tl_greplace_in:Nnn}
+%\begin{macro}{\tl_greplace_in:cnn}
+%\begin{macro}[aux]{\_tl_replace_in_aux:NNnn}
+% The concept here is that only the first occurrence should be
+% replaced. The first step is to define an auxiliary which will
+% match the appropriate item, with a trailing marker. If the last token
+% is the marker there is nothing to do, otherwise replace the token
+% and clean up (hence the second use of \cs{_tl_tmp:w}). To prevent
+% loosing braces or spaces there are a couple of empty groups and
+% the strange-looking \cs{use:n}.
% \begin{macrocode}
- \use:n{\exp_after:wN \tl_tmp:w\exp_after:wN\prg_do_nothing:}
- #2#3 \q_no_value\q_stop
+\tl_new:N \_l_tl_replace_tl
+\cs_new_protected_nopar:Npn \tl_replace_in:Nnn {
+ \_tl_replace_in_aux:NNnn \tl_set_eq:NN
}
-% \end{macrocode}
-% Now the various versions doing the replacement either globally or
-% locally.
-% \begin{macrocode}
-\cs_new_nopar:Npn \tl_replace_in:Nnn {\tl_replace_in_aux:NNnn \tl_set:Nx}
-\cs_generate_variant:Nn\tl_replace_in:Nnn {cnn}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new_nopar:Npn \tl_greplace_in:Nnn {\tl_replace_in_aux:NNnn \tl_gset:Nx}
-\cs_generate_variant:Nn\tl_greplace_in:Nnn {cnn}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\tl_replace_all_in:Nnn}
-% \begin{macro}{\tl_replace_all_in:cnn}
-% \begin{macro}{\tl_greplace_all_in:Nnn}
-% \begin{macro}{\tl_greplace_all_in:cnn}
-% \begin{macro}[aux]{\tl_replace_all_in_aux:NNnn}
-% The version for replacing \emph{all} occurrences of the search
-% term is fairly easy since we just have to keep doing the
-% replacement on the split-off part until all are
-% replaced. Otherwise it is pretty much the same as above.
-% \begin{macrocode}
-\cs_set:Npn \tl_replace_all_in_aux:NNnn #1#2#3#4{
- \toks_clear:N \l_tl_replace_toks
- \cs_set:Npn \tl_tmp:w ##1#3##2\q_stop{
- \quark_if_no_value:nTF{##2}
+\cs_new_protected:Npn \_tl_replace_in_aux:NNnn #1#2#3#4 {
+ \cs_set:Npn \_tl_tmp:w ##1 #3 ##2 \q_stop
{
- \toks_put_right:No \l_tl_replace_toks {##1}
+ \quark_if_no_value:nF {##2}
+ {
+ \tl_set:No \_l_tl_replace_tl { ##1 #4 }
+ \cs_set:Npn \_tl_tmp:w ####1 #3 \q_no_value {
+ \tl_put_right:No \_l_tl_replace_tl {####1}
+ }
+ \_tl_tmp:w \prg_do_nothing: ##2
+ #1 #2 \_l_tl_replace_tl
+ }
}
+ \use:n
+ {
+ \exp_after:wN \_tl_tmp:w \exp_after:wN
+ \prg_do_nothing:
+ }
+ #2 #3 \q_no_value \q_stop
+}
+\cs_new_protected_nopar:Npn \tl_greplace_in:Nnn {
+ \_tl_replace_in_aux:NNnn \tl_gset_eq:NN
+}
+\cs_generate_variant:Nn \tl_replace_in:Nnn { c }
+\cs_generate_variant:Nn \tl_greplace_in:Nnn { c }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\tl_replace_all_in:Nnn}
+%\begin{macro}{\tl_replace_all_in:Nnn}
+%\begin{macro}{\tl_greplace_all_in:cnn}
+%\begin{macro}{\tl_greplace_all_in:cnn}
+%\begin{macro}[aux]{\_tl_replace_all_in_aux:NNnn}
+% A similar approach here but with a loop built in.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \tl_replace_all_in:Nnn {
+ \_tl_replace_all_in_aux:NNnn \tl_set_eq:NN
+}
+\cs_new_protected_nopar:Npn \tl_greplace_all_in:Nnn {
+ \_tl_replace_all_in_aux:NNnn \tl_gset_eq:NN
+}
+\cs_new_protected:Npn \_tl_replace_all_in_aux:NNnn #1#2#3#4 {
+ \tl_clear:N \_l_tl_replace_tl
+ \cs_set:Npn \_tl_tmp:w ##1 #3 ##2 \q_stop
{
- \toks_put_right:No \l_tl_replace_toks {##1 #4}
- \tl_tmp:w \prg_do_nothing: ##2 \q_stop
+ \quark_if_no_value:nTF {##2}
+ { \tl_put_right:No \_l_tl_replace_tl {##1} }
+ {
+ \tl_put_right:No \_l_tl_replace_tl { ##1 #4 }
+ \_tl_tmp:w \prg_do_nothing: ##2 \q_stop
+ }
}
- }
- \use:n{\exp_after:wN \tl_tmp:w \exp_after:wN \prg_do_nothing:}
- #2#3 \q_no_value\q_stop
- #1#2{\toks_use:N\l_tl_replace_toks}
+ \use:n
+ {
+ \exp_after:wN \_tl_tmp:w \exp_after:wN
+ \prg_do_nothing:
+ }
+ #2 #3 \q_no_value \q_stop
+ #1 #2 \_l_tl_replace_tl
}
+\cs_generate_variant:Nn \tl_replace_all_in:Nnn { c }
+\cs_generate_variant:Nn \tl_greplace_all_in:Nnn { c }
% \end{macrocode}
-% Now the various forms.
-% \begin{macrocode}
-\cs_new_nopar:Npn \tl_replace_all_in:Nnn {
- \tl_replace_all_in_aux:NNnn \tl_set:Nx}
-\cs_generate_variant:Nn \tl_replace_all_in:Nnn {cnn}
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new_nopar:Npn \tl_greplace_all_in:Nnn {
- \tl_replace_all_in_aux:NNnn \tl_gset:Nx}
-\cs_generate_variant:Nn \tl_greplace_all_in:Nnn {cnn}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
%
%
%
@@ -2111,8 +2181,8 @@
% Next comes a series of removal functions. I have just implemented
% them as subcases of the replace functions for now (I'm lazy).
% \begin{macrocode}
-\cs_new:Npn \tl_remove_in:Nn #1#2{\tl_replace_in:Nnn #1{#2}{}}
-\cs_new:Npn \tl_gremove_in:Nn #1#2{\tl_greplace_in:Nnn #1{#2}{}}
+\cs_new_protected:Npn \tl_remove_in:Nn #1#2{\tl_replace_in:Nnn #1{#2}{}}
+\cs_new_protected:Npn \tl_gremove_in:Nn #1#2{\tl_greplace_in:Nnn #1{#2}{}}
\cs_generate_variant:Nn \tl_remove_in:Nn {cn}
\cs_generate_variant:Nn \tl_gremove_in:Nn {cn}
% \end{macrocode}
@@ -2128,10 +2198,10 @@
% \begin{macro}{\tl_gremove_all_in:cn}
% Same old, same old.
% \begin{macrocode}
-\cs_new:Npn \tl_remove_all_in:Nn #1#2{
+\cs_new_protected:Npn \tl_remove_all_in:Nn #1#2{
\tl_replace_all_in:Nnn #1{#2}{}
}
-\cs_new:Npn \tl_gremove_all_in:Nn #1#2{
+\cs_new_protected:Npn \tl_gremove_all_in:Nn #1#2{
\tl_greplace_all_in:Nnn #1{#2}{}
}
\cs_generate_variant:Nn \tl_remove_all_in:Nn {cn}
diff --git a/Master/texmf-dist/source/latex/expl3/l3token.dtx b/Master/texmf-dist/source/latex/expl3/l3token.dtx
index 3c283052e6f..6c48ab422d4 100644
--- a/Master/texmf-dist/source/latex/expl3/l3token.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3token.dtx
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3token.dtx 1550 2009-09-22 06:06:25Z joseph $
+\GetIdInfo$Id: l3token.dtx 1857 2010-03-21 21:32:09Z joseph $
{L3 Experimental token investigation and manipulation}
%\iffalse
%<*driver>
@@ -773,7 +773,7 @@
% \char_show_value_catcode:n }
% \begin{macrocode}
\cs_new_eq:NN \char_set_catcode:w \tex_catcode:D
-\cs_new_nopar:Npn \char_set_catcode:nn #1#2 {
+\cs_new_protected_nopar:Npn \char_set_catcode:nn #1#2 {
\char_set_catcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_nopar:Npn \char_value_catcode:w { \int_use:N \tex_catcode:D }
@@ -798,22 +798,22 @@
% \char_make_other:N , \char_make_active:N ,
% \char_make_comment:N , \char_make_invalid:N }
% \begin{macrocode}
-\cs_new_nopar:Npn \char_make_escape:N #1 { \char_set_catcode:nn {`#1} {\c_zero} }
-\cs_new_nopar:Npn \char_make_begin_group:N #1 { \char_set_catcode:nn {`#1} {\c_one} }
-\cs_new_nopar:Npn \char_make_end_group:N #1 { \char_set_catcode:nn {`#1} {\c_two} }
-\cs_new_nopar:Npn \char_make_math_shift:N #1 { \char_set_catcode:nn {`#1} {\c_three} }
-\cs_new_nopar:Npn \char_make_alignment:N #1 { \char_set_catcode:nn {`#1} {\c_four} }
-\cs_new_nopar:Npn \char_make_end_line:N #1 { \char_set_catcode:nn {`#1} {\c_five} }
-\cs_new_nopar:Npn \char_make_parameter:N #1 { \char_set_catcode:nn {`#1} {\c_six} }
-\cs_new_nopar:Npn \char_make_math_superscript:N #1 { \char_set_catcode:nn {`#1} {\c_seven} }
-\cs_new_nopar:Npn \char_make_math_subscript:N #1 { \char_set_catcode:nn {`#1} {\c_eight} }
-\cs_new_nopar:Npn \char_make_ignore:N #1 { \char_set_catcode:nn {`#1} {\c_nine} }
-\cs_new_nopar:Npn \char_make_space:N #1 { \char_set_catcode:nn {`#1} {\c_ten} }
-\cs_new_nopar:Npn \char_make_letter:N #1 { \char_set_catcode:nn {`#1} {\c_eleven} }
-\cs_new_nopar:Npn \char_make_other:N #1 { \char_set_catcode:nn {`#1} {\c_twelve} }
-\cs_new_nopar:Npn \char_make_active:N #1 { \char_set_catcode:nn {`#1} {\c_thirteen} }
-\cs_new_nopar:Npn \char_make_comment:N #1 { \char_set_catcode:nn {`#1} {\c_fourteen} }
-\cs_new_nopar:Npn \char_make_invalid:N #1 { \char_set_catcode:nn {`#1} {\c_fifteen} }
+\cs_new_protected_nopar:Npn \char_make_escape:N #1 { \char_set_catcode:nn {`#1} {\c_zero} }
+\cs_new_protected_nopar:Npn \char_make_begin_group:N #1 { \char_set_catcode:nn {`#1} {\c_one} }
+\cs_new_protected_nopar:Npn \char_make_end_group:N #1 { \char_set_catcode:nn {`#1} {\c_two} }
+\cs_new_protected_nopar:Npn \char_make_math_shift:N #1 { \char_set_catcode:nn {`#1} {\c_three} }
+\cs_new_protected_nopar:Npn \char_make_alignment:N #1 { \char_set_catcode:nn {`#1} {\c_four} }
+\cs_new_protected_nopar:Npn \char_make_end_line:N #1 { \char_set_catcode:nn {`#1} {\c_five} }
+\cs_new_protected_nopar:Npn \char_make_parameter:N #1 { \char_set_catcode:nn {`#1} {\c_six} }
+\cs_new_protected_nopar:Npn \char_make_math_superscript:N #1 { \char_set_catcode:nn {`#1} {\c_seven} }
+\cs_new_protected_nopar:Npn \char_make_math_subscript:N #1 { \char_set_catcode:nn {`#1} {\c_eight} }
+\cs_new_protected_nopar:Npn \char_make_ignore:N #1 { \char_set_catcode:nn {`#1} {\c_nine} }
+\cs_new_protected_nopar:Npn \char_make_space:N #1 { \char_set_catcode:nn {`#1} {\c_ten} }
+\cs_new_protected_nopar:Npn \char_make_letter:N #1 { \char_set_catcode:nn {`#1} {\c_eleven} }
+\cs_new_protected_nopar:Npn \char_make_other:N #1 { \char_set_catcode:nn {`#1} {\c_twelve} }
+\cs_new_protected_nopar:Npn \char_make_active:N #1 { \char_set_catcode:nn {`#1} {\c_thirteen} }
+\cs_new_protected_nopar:Npn \char_make_comment:N #1 { \char_set_catcode:nn {`#1} {\c_fourteen} }
+\cs_new_protected_nopar:Npn \char_make_invalid:N #1 { \char_set_catcode:nn {`#1} {\c_fifteen} }
% \end{macrocode}
% \end{macro}
%
@@ -826,22 +826,22 @@
% \char_make_other:n , \char_make_active:n ,
% \char_make_comment:n , \char_make_invalid:n }
% \begin{macrocode}
-\cs_new_nopar:Npn \char_make_escape:n #1 { \char_set_catcode:nn {#1} {\c_zero} }
-\cs_new_nopar:Npn \char_make_begin_group:n #1 { \char_set_catcode:nn {#1} {\c_one} }
-\cs_new_nopar:Npn \char_make_end_group:n #1 { \char_set_catcode:nn {#1} {\c_two} }
-\cs_new_nopar:Npn \char_make_math_shift:n #1 { \char_set_catcode:nn {#1} {\c_three} }
-\cs_new_nopar:Npn \char_make_alignment:n #1 { \char_set_catcode:nn {#1} {\c_four} }
-\cs_new_nopar:Npn \char_make_end_line:n #1 { \char_set_catcode:nn {#1} {\c_five} }
-\cs_new_nopar:Npn \char_make_parameter:n #1 { \char_set_catcode:nn {#1} {\c_six} }
-\cs_new_nopar:Npn \char_make_math_superscript:n #1 { \char_set_catcode:nn {#1} {\c_seven} }
-\cs_new_nopar:Npn \char_make_math_subscript:n #1 { \char_set_catcode:nn {#1} {\c_eight} }
-\cs_new_nopar:Npn \char_make_ignore:n #1 { \char_set_catcode:nn {#1} {\c_nine} }
-\cs_new_nopar:Npn \char_make_space:n #1 { \char_set_catcode:nn {#1} {\c_ten} }
-\cs_new_nopar:Npn \char_make_letter:n #1 { \char_set_catcode:nn {#1} {\c_eleven} }
-\cs_new_nopar:Npn \char_make_other:n #1 { \char_set_catcode:nn {#1} {\c_twelve} }
-\cs_new_nopar:Npn \char_make_active:n #1 { \char_set_catcode:nn {#1} {\c_thirteen} }
-\cs_new_nopar:Npn \char_make_comment:n #1 { \char_set_catcode:nn {#1} {\c_fourteen} }
-\cs_new_nopar:Npn \char_make_invalid:n #1 { \char_set_catcode:nn {#1} {\c_fifteen} }
+\cs_new_protected_nopar:Npn \char_make_escape:n #1 { \char_set_catcode:nn {#1} {\c_zero} }
+\cs_new_protected_nopar:Npn \char_make_begin_group:n #1 { \char_set_catcode:nn {#1} {\c_one} }
+\cs_new_protected_nopar:Npn \char_make_end_group:n #1 { \char_set_catcode:nn {#1} {\c_two} }
+\cs_new_protected_nopar:Npn \char_make_math_shift:n #1 { \char_set_catcode:nn {#1} {\c_three} }
+\cs_new_protected_nopar:Npn \char_make_alignment:n #1 { \char_set_catcode:nn {#1} {\c_four} }
+\cs_new_protected_nopar:Npn \char_make_end_line:n #1 { \char_set_catcode:nn {#1} {\c_five} }
+\cs_new_protected_nopar:Npn \char_make_parameter:n #1 { \char_set_catcode:nn {#1} {\c_six} }
+\cs_new_protected_nopar:Npn \char_make_math_superscript:n #1 { \char_set_catcode:nn {#1} {\c_seven} }
+\cs_new_protected_nopar:Npn \char_make_math_subscript:n #1 { \char_set_catcode:nn {#1} {\c_eight} }
+\cs_new_protected_nopar:Npn \char_make_ignore:n #1 { \char_set_catcode:nn {#1} {\c_nine} }
+\cs_new_protected_nopar:Npn \char_make_space:n #1 { \char_set_catcode:nn {#1} {\c_ten} }
+\cs_new_protected_nopar:Npn \char_make_letter:n #1 { \char_set_catcode:nn {#1} {\c_eleven} }
+\cs_new_protected_nopar:Npn \char_make_other:n #1 { \char_set_catcode:nn {#1} {\c_twelve} }
+\cs_new_protected_nopar:Npn \char_make_active:n #1 { \char_set_catcode:nn {#1} {\c_thirteen} }
+\cs_new_protected_nopar:Npn \char_make_comment:n #1 { \char_set_catcode:nn {#1} {\c_fourteen} }
+\cs_new_protected_nopar:Npn \char_make_invalid:n #1 { \char_set_catcode:nn {#1} {\c_fifteen} }
% \end{macrocode}
% \end{macro}
%
@@ -856,11 +856,11 @@
% Math codes.
% \begin{macrocode}
\cs_new_eq:NN \char_set_mathcode:w \tex_mathcode:D
-\cs_new_nopar:Npn \char_set_mathcode:nn #1#2 {
+\cs_new_protected_nopar:Npn \char_set_mathcode:nn #1#2 {
\char_set_mathcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_protected_nopar:Npn \char_gset_mathcode:w { \pref_global:D \tex_mathcode:D }
-\cs_new_nopar:Npn \char_gset_mathcode:nn #1#2 {
+\cs_new_protected_nopar:Npn \char_gset_mathcode:nn #1#2 {
\char_gset_mathcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_nopar:Npn \char_value_mathcode:w { \int_use:N \tex_mathcode:D }
@@ -879,7 +879,7 @@
% \char_show_value_lccode:w, \char_show_value_lccode:n}
% \begin{macrocode}
\cs_new_eq:NN \char_set_lccode:w \tex_lccode:D
-\cs_new_nopar:Npn \char_set_lccode:nn #1#2{
+\cs_new_protected_nopar:Npn \char_set_lccode:nn #1#2{
\char_set_lccode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_nopar:Npn \char_value_lccode:w {\int_use:N\tex_lccode:D}
@@ -896,7 +896,7 @@
% \char_show_value_uccode:w, \char_show_value_uccode:n }
% \begin{macrocode}
\cs_new_eq:NN \char_set_uccode:w \tex_uccode:D
-\cs_new_nopar:Npn \char_set_uccode:nn #1#2{
+\cs_new_protected_nopar:Npn \char_set_uccode:nn #1#2{
\char_set_uccode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_nopar:Npn \char_value_uccode:w {\int_use:N\tex_uccode:D}
@@ -913,7 +913,7 @@
% \char_show_value_sfcode:w, \char_show_value_sfcode:n}
% \begin{macrocode}
\cs_new_eq:NN \char_set_sfcode:w \tex_sfcode:D
-\cs_new_nopar:Npn \char_set_sfcode:nn #1#2 {
+\cs_new_protected_nopar:Npn \char_set_sfcode:nn #1#2 {
\char_set_sfcode:w #1 = \intexpr_eval:w #2\intexpr_eval_end:
}
\cs_new_nopar:Npn \char_value_sfcode:w { \int_use:N \tex_sfcode:D }
@@ -933,7 +933,7 @@
% Creates a new token. (Will: why can't this just be
% "\cs_new_eq:NN \token_new:Nn \cs_gnew_eq:NN"? Seriously, that doesn't work!)
% \begin{macrocode}
-\cs_new_nopar:Npn \token_new:Nn #1#2 {\cs_gnew_eq:NN #1#2}
+\cs_new_protected_nopar:Npn \token_new:Nn #1#2 {\cs_gnew_eq:NN #1#2}
% \end{macrocode}
% \end{macro}
%
@@ -1513,8 +1513,8 @@
% input stream which |\l_peek_token| is set equal to.
% |\peek_gafter:NN| does the same globally to |\g_peek_token|.
% \begin{macrocode}
-\cs_new_nopar:Npn \peek_after:NN {\tex_futurelet:D \l_peek_token }
-\cs_new_nopar:Npn \peek_gafter:NN {
+\cs_new_protected_nopar:Npn \peek_after:NN {\tex_futurelet:D \l_peek_token }
+\cs_new_protected_nopar:Npn \peek_gafter:NN {
\pref_global:D \tex_futurelet:D \g_peek_token
}
% \end{macrocode}
@@ -1554,8 +1554,8 @@
% Two dedicated token list variables that store the true and false
% cases.
% \begin{macrocode}
-\tl_new:Nn \l_peek_true_tl {}
-\tl_new:Nn \l_peek_false_tl {}
+\tl_new:N \l_peek_true_tl
+\tl_new:N \l_peek_false_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1572,7 +1572,7 @@
% We also use this token list variable for storing the token we want
% to compare. This turns out to be useful.
% \begin{macrocode}
-\tl_new:Nn \l_peek_search_tl {}
+\tl_new:N \l_peek_search_tl
% \end{macrocode}
% \end{macro}
%
@@ -1582,18 +1582,18 @@
% \item the special token we're looking for.
% \end{arguments}
% \begin{macrocode}
-\cs_new:Npn \peek_token_generic:NNTF #1#2#3#4 {
+\cs_new_protected:Npn \peek_token_generic:NNTF #1#2#3#4 {
\cs_set_eq:NN \l_peek_search_token #2
\tl_set:Nn \l_peek_search_tl {#2}
- \tl_set:Nx \l_peek_true_tl {\exp_not:n{\group_align_safe_end: #3}}
- \tl_set:Nx \l_peek_false_tl {\exp_not:n{\group_align_safe_end: #4}}
+ \tl_set:Nn \l_peek_true_tl { \group_align_safe_end: #3 }
+ \tl_set:Nn \l_peek_false_tl { \group_align_safe_end: #4 }
\group_align_safe_begin:
\peek_after:NN #1
}
-\cs_new:Npn \peek_token_generic:NNT #1#2#3 {
+\cs_new_protected:Npn \peek_token_generic:NNT #1#2#3 {
\peek_token_generic:NNTF #1#2 {#3} {}
}
-\cs_new:Npn \peek_token_generic:NNF #1#2#3 {
+\cs_new_protected:Npn \peek_token_generic:NNF #1#2#3 {
\peek_token_generic:NNTF #1#2 {} {#3}
}
% \end{macrocode}
@@ -1604,12 +1604,12 @@
% stream we might as well do it the same way for all characters so
% we define this as little differently from above.
% \begin{macrocode}
-\cs_new:Npn \peek_token_remove_generic:NNTF #1#2#3#4 {
+\cs_new_protected:Npn \peek_token_remove_generic:NNTF #1#2#3#4 {
\cs_set_eq:NN \l_peek_search_token #2
\tl_set:Nn \l_peek_search_tl {#2}
- \tl_set:Nx \l_peek_true_aux_tl { \exp_not:n{ #3 } }
+ \tl_set:Nn \l_peek_true_aux_tl {#3}
\tl_set_eq:NN \l_peek_true_tl \c_peek_true_remove_next_tl
- \tl_set:Nx \l_peek_false_tl {\exp_not:n{\group_align_safe_end: #4}}
+ \tl_set:Nn \l_peek_false_tl {\group_align_safe_end: #4}
\group_align_safe_begin:
\peek_after:NN #1
}
@@ -1627,8 +1627,8 @@
% Two token list variables to help with removing the character from
% the input stream.
% \begin{macrocode}
-\tl_new:Nn \l_peek_true_aux_tl {}
-\tl_new:Nn \c_peek_true_remove_next_tl {\group_align_safe_end:
+\tl_new:N \l_peek_true_aux_tl
+\tl_const:Nn \c_peek_true_remove_next_tl {\group_align_safe_end:
\tex_afterassignment:D \l_peek_true_aux_tl \cs_set_eq:NN \peek_tmp:w
}
% \end{macrocode}
@@ -1713,7 +1713,7 @@
\peek_def_aux_ii:nnnnn {#1} {#2} {#3} {#4} { T }
\peek_def_aux_ii:nnnnn {#1} {#2} {#3} {#4} { F }
}
-\cs_new_nopar:Npn \peek_def_aux_ii:nnnnn #1#2#3#4#5 {
+\cs_new_protected_nopar:Npn \peek_def_aux_ii:nnnnn #1#2#3#4#5 {
\cs_new_nopar:cpx { #1 #5 } {
\tl_if_empty:nF {#2} {
\exp_not:n { \cs_set_eq:NN \peek_execute_branches: #2 }
@@ -1864,7 +1864,7 @@
\cs_new_nopar:Npn \peek_ignore_spaces_aux: {
\peek_after:NN \peek_ignore_spaces_execute_branches:
}
-\cs_new_nopar:Npn \peek_ignore_spaces_execute_branches: {
+\cs_new_protected_nopar:Npn \peek_ignore_spaces_execute_branches: {
\token_if_eq_meaning:NNTF \l_peek_token \c_space_token
{ \tex_afterassignment:D \peek_ignore_spaces_aux:
\cs_set_eq:NN \peek_tmp:w
diff --git a/Master/texmf-dist/source/latex/expl3/l3toks.dtx b/Master/texmf-dist/source/latex/expl3/l3toks.dtx
index 80c9305ffb6..3b3502d0ea3 100644
--- a/Master/texmf-dist/source/latex/expl3/l3toks.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3toks.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3toks.dtx 1412 2009-06-14 17:55:48Z joseph $
+\GetIdInfo$Id: l3toks.dtx 1867 2010-03-23 13:03:12Z will $
{L3 Experimental Token Registers}
%\iffalse
%<*driver>
@@ -96,13 +96,14 @@
%
% \begin{function}{ \toks_new:N |
% \toks_new:c |
-%^^A \toks_new_l:N |
-% }
+% \toks_new_local:N |
+% \toks_new_local:c }
% \begin{syntax}
% "\toks_new:N" <toks>
% \end{syntax}
% Defines <toks> to be a new token list register.
-%^^A "\toks_new_l:N" is only defined in the \LaTeX3 kernel.
+% With the |local| variant, the variable is only available within the
+% current group level (or below).
% \begin{texnote}
% This is the \LaTeX3 allocation for what was called \tn{newtoks} in
% plain \TeX.
@@ -354,19 +355,36 @@
% \subsection{Allocation and use}
%
% \begin{macro}{\toks_new:N,\toks_new:c}
-%^^A \begin{macro}{\toks_new_l:N}
+% \begin{macro}{\toks_new_local:N,\toks_new_local:c}
% Allocates a new token register.
% \begin{macrocode}
%<*initex>
-\alloc_setup_type:nnn {toks} \c_zero \c_max_register_num
-\cs_new_nopar:Npn \toks_new:N #1 { \alloc_reg:NnNN g {toks} \tex_toksdef:D #1 }
-\cs_new_nopar:Npn \toks_new_l:N #1 { \alloc_reg:NnNN l {toks} \tex_toksdef:D #1 }
+\alloc_new:nnnN {toks} \c_zero \c_max_register_int \tex_toksdef:D
%</initex>
-%<package>\cs_set_eq:NN \toks_new:N \newtoks % nick from LaTeX for the moment
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*package>
+\cs_new_protected_nopar:Npn \toks_new:N #1 {
+ \chk_if_free_cs:N #1
+ \newtoks #1
+}
+\cs_new_protected_nopar:Npn \toks_new_local:N #1 {
+ \chk_if_free_cs:N #1
+ \int_compare:nNnTF
+ \tex_currentgrouplevel:D = 0
+ \newtoks \loctoks
+ #1
+}
+%</package>
+% \end{macrocode}
+%
+% \begin{macrocode}
\cs_generate_variant:Nn \toks_new:N {c}
+\cs_generate_variant:Nn \toks_new_local:N {c}
% \end{macrocode}
% \end{macro}
-%^^A \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\toks_use:N}
@@ -396,7 +414,7 @@
% and fully.
% \begin{macrocode}
%<*check>
-\cs_new_nopar:Npn \toks_set:Nn #1 { \chk_local:N #1 #1 }
+\cs_new_protected_nopar:Npn \toks_set:Nn #1 { \chk_local:N #1 #1 }
\cs_generate_variant:Nn \toks_set:Nn {No,Nf}
%</check>
% \end{macrocode}
@@ -409,14 +427,14 @@
% \begin{macrocode}
%<*!check>
\cs_new_eq:NN \toks_set:Nn \prg_do_nothing:
-\cs_new:Npn \toks_set:NV #1#2 {
+\cs_new_protected:Npn \toks_set:NV #1#2 {
#1 \exp_after:wN { \int_to_roman:w -`0 \exp_eval_register:N #2 }
}
-\cs_new:Npn \toks_set:Nv #1#2 {
+\cs_new_protected:Npn \toks_set:Nv #1#2 {
#1 \exp_after:wN { \int_to_roman:w -`0 \exp_eval_register:c {#2} }
}
-\cs_new:Npn \toks_set:No #1#2 { #1 \exp_after:wN {#2} }
-\cs_new:Npn \toks_set:Nf #1#2 {
+\cs_new_protected:Npn \toks_set:No #1#2 { #1 \exp_after:wN {#2} }
+\cs_new_protected:Npn \toks_set:Nf #1#2 {
#1 \exp_after:wN { \int_to_roman:w -`0#2 }
}
%</!check>
@@ -448,7 +466,7 @@
% \begin{macro}{\toks_gset:cx}
% These functions are the global variants of the above.
% \begin{macrocode}
-%<check>\cs_new_nopar:Npn \toks_gset:Nn #1 { \chk_global:N #1 \pref_global:D #1 }
+%<check>\cs_new_protected_nopar:Npn \toks_gset:Nn #1 { \chk_global:N #1 \pref_global:D #1 }
%<!check>\cs_new_eq:NN \toks_gset:Nn \pref_global:D
\cs_generate_variant:Nn \toks_gset:Nn {NV,No,Nx,cn,cV,co,cx}
% \end{macrocode}
@@ -473,12 +491,12 @@
% in \m{toks1}.
% \begin{macrocode}
%<*check>
-\cs_new_nopar:Npn\toks_set_eq:NN #1#2 {
+\cs_new_protected_nopar:Npn\toks_set_eq:NN #1#2 {
\chk_local:N #1
\chk_var_or_const:N #2
#1 #2
}
-\cs_new_nopar:Npn\toks_gset_eq:NN #1#2 {
+\cs_new_protected_nopar:Npn\toks_gset_eq:NN #1#2 {
\chk_global:N #1
\chk_var_or_const:N #2
\pref_global:D #1 #2
@@ -503,14 +521,14 @@
% \begin{macro}{\toks_clear:N,\toks_gclear:N,\toks_clear:c,\toks_gclear:c}
% These functions clear a token register, either locally or globally.
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_clear:N #1 {
+\cs_new_protected_nopar:Npn \toks_clear:N #1 {
#1\c_empty_toks
%<check>\chk_local_or_pref_global:N #1
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_gclear:N {
+\cs_new_protected_nopar:Npn \toks_gclear:N {
%<check> \pref_global_chk:
%<!check> \pref_global:D
\toks_clear:N
@@ -534,13 +552,13 @@
% interfere with following tokens. In other words, the contents of
% the register might operate on what follows in the input stream.
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_use_clear:N #1 {
+\cs_new_protected_nopar:Npn \toks_use_clear:N #1 {
\exp_last_unbraced:NNV \toks_clear:N #1 #1
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_use_gclear:N {
+\cs_new_protected_nopar:Npn \toks_use_gclear:N {
%<check> \pref_global_chk:
%<!check> \pref_global:D
\toks_use_clear:N
@@ -590,7 +608,7 @@
% tokens once. We need to look out for brace stripping so we add a
% token, which is then later removed.
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_put_left:Nn #1 {
+\cs_new_protected_nopar:Npn \toks_put_left:Nn #1 {
\exp_after:wN \toks_put_left_aux:w \exp_after:wN \q_mark
\toks_use:N #1 \q_stop #1
}
@@ -601,7 +619,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_gput_left:Nn {
+\cs_new_protected_nopar:Npn \toks_gput_left:Nn {
%<check> \pref_global_chk:
%<!check> \pref_global:D
\toks_put_left:Nn
@@ -653,14 +671,14 @@
% \begin{macro}{\toks_gput_right:co}
% These macros add a list of tokens to the right of a token register.
% \begin{macrocode}
-\cs_new:Npn \toks_put_right:Nn #1#2 {
+\cs_new_protected:Npn \toks_put_right:Nn #1#2 {
#1 \exp_after:wN { \toks_use:N #1 #2 }
%<check> \chk_local_or_pref_global:N #1
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_nopar:Npn \toks_gput_right:Nn {
+\cs_new_protected_nopar:Npn \toks_gput_right:Nn {
%<check> \pref_global_chk:
%<!check> \pref_global:D
\toks_put_right:Nn
@@ -670,13 +688,13 @@
% \begin{macrocode}
%<check>\cs_generate_variant:Nn \toks_put_right:Nn {No}
%<*!check>
-\cs_new:Npn \toks_put_right:NV #1#2 {
+\cs_new_protected:Npn \toks_put_right:NV #1#2 {
#1 \exp_after:wN \exp_after:wN \exp_after:wN {
\exp_after:wN \toks_use:N \exp_after:wN #1
\int_to_roman:w -`0 \exp_eval_register:N #2
}
}
-\cs_new:Npn \toks_put_right:No #1#2 {
+\cs_new_protected:Npn \toks_put_right:No #1#2 {
#1 \exp_after:wN \exp_after:wN \exp_after:wN {
\exp_after:wN \toks_use:N \exp_after:wN #1 #2
}
@@ -707,7 +725,7 @@
% \begin{macrocode}
%<check>\cs_generate_variant:Nn \toks_put_right:Nn {Nf}
%<*!check>
-\cs_new:Npn \toks_put_right:Nf #1#2 {
+\cs_new_protected:Npn \toks_put_right:Nf #1#2 {
#1 \exp_after:wN \exp_after:wN \exp_after:wN {
\exp_after:wN \toks_use:N \exp_after:wN #1 \int_to_roman:w -`0#2
}
diff --git a/Master/texmf-dist/source/latex/expl3/l3vers.dtx b/Master/texmf-dist/source/latex/expl3/l3vers.dtx
index 247296c051b..0fd96493361 100644
--- a/Master/texmf-dist/source/latex/expl3/l3vers.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3vers.dtx
@@ -35,7 +35,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3vers.dtx 1755 2009-12-23 07:07:48Z joseph $
+\GetIdInfo$Id: l3vers.dtx 1776 2010-02-07 21:51:23Z joseph $
{L3 Experimental LaTeX format version}
%\iffalse
%<*driver>
@@ -73,8 +73,8 @@
% Just the information required: remember to update it.
% \begin{macrocode}
%<*initex>
-\tl_new:Nn \c_format_name { Experimental~LaTeX3 }
-\tl_new:Nn \c_format_date { 2009/12/23 }
+\tl_const:Nn \c_format_name { Experimental~LaTeX3 }
+\tl_const:Nn \c_format_date { 2009/12/23 }
% \end{macrocode}
%\end{macro}
%\end{macro}
diff --git a/Master/texmf-dist/source/latex/expl3/l3xref.dtx b/Master/texmf-dist/source/latex/expl3/l3xref.dtx
index c0f0fa791ac..5996ed3506b 100644
--- a/Master/texmf-dist/source/latex/expl3/l3xref.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3xref.dtx
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package|testfile>
%\fi
-\GetIdInfo$Id: l3xref.dtx 1362 2009-05-28 20:19:21Z joseph $
+\GetIdInfo$Id: l3xref.dtx 1786 2010-02-09 12:52:45Z joseph $
{L3 Experimental cross referencing}
%\iffalse
%<*testfile>
@@ -310,14 +310,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\xref_write}
-% A stream for writing cross references although they do not require
-% to be in a separate file.
-% \begin{macrocode}
-\iow_new:N \xref_write
-% \end{macrocode}
-% \end{macro}
-%
% That's it (for now).
% \begin{macrocode}
%</initex|package>
diff --git a/Master/texmf-dist/source/latex/expl3/source3.tex b/Master/texmf-dist/source/latex/expl3/source3.tex
new file mode 100644
index 00000000000..bb530ae9b02
--- /dev/null
+++ b/Master/texmf-dist/source/latex/expl3/source3.tex
@@ -0,0 +1,414 @@
+% \iffalse
+%% File: source3.dtx Copyright (C) 1990-2009 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 ``expl3 bundle'' (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%%
+%% The released version of this bundle is available from CTAN.
+%%
+%% -----------------------------------------------------------------------
+%%
+%% The development version of the bundle can be found at
+%%
+%% http://www.latex-project.org/svnroot/experimental/trunk/
+%%
+%% for those people who are interested.
+%%
+%%%%%%%%%%%
+%% NOTE: %%
+%%%%%%%%%%%
+%%
+%% Snapshots taken from the repository represent work in progress and may
+%% not work or may contain conflicting material! We therefore ask
+%% people _not_ to put them into distributions, archives, etc. without
+%% prior consultation with the LaTeX Project Team.
+%%
+%% -----------------------------------------------------------------------
+%% \fi
+
+% This document will typeset the LaTeX3 sources as a single document.
+% This will produce quite a large file (roughly ??? pages) and may
+% take a long time on a slow machine.
+
+\documentclass{l3doc}
+\listfiles
+
+\begin{document}
+
+\title{The \LaTeX3 Sources}
+\author{\Team}
+
+
+\pagenumbering{roman}
+\maketitle
+
+\begin{abstract}
+
+\parindent=0pt
+\parskip=\baselineskip
+
+\noindent This is the reference documentation for the \pkg{expl3}
+programming environment. The \pkg{expl3} modules set up an experimental
+naming scheme for \LaTeX\ commands, which allow the \LaTeX\ programmer
+to systematically name functions and variables, and specify the argument
+types of functions.
+
+The \TeX\ and \eTeX\ primitives are all given a new name according to
+these conventions. However, in the main direct use of the primitives is
+not required or encouraged: the \pkg{expl3} modules define an
+independent low-level \LaTeX3 programming language.
+
+At present, the \pkg{expl3} modules are designed to be loaded on top of
+\LaTeXe. In time, a \LaTeX3 format will be produced based on this code.
+This allows the code to be used in \LaTeXe\ packages \emph{now} while a
+stand-alone \LaTeX3 is developed.
+
+\begin{bfseries}
+ While \pkg{expl3} is still experimental, the bundle is now regarded as
+ broadly stable. The syntax conventions and functions provided are now
+ ready for wider use. There may still be changes to some functions, but
+ these will be minor when compared to the scope of \pkg{expl3}.
+
+ New modules will be added to the distributed version of \pkg{expl3} as
+ they reach maturity.
+\end{bfseries}
+
+\end{abstract}
+
+\clearpage
+
+{\def\\{:}% fix "newlines" in the ToC
+\tableofcontents}
+
+\clearpage
+\pagenumbering{arabic}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Each of the following \DocInput lines includes a file with extension
+% .dtx. Each of these files may be typeset separately. For instance
+% pdflatex l3box.dtx
+% will typeset the source of the LaTeX3 box commands. If you use the
+% Makefile, the index will be generated automatically; e.g.,
+% make doc F=l3box
+%
+% If this file is processed, each of these separate dtx files will be
+% contained as a part of a single document.
+
+\makeatletter
+\def\partname{Part}
+\def\maketitle{\part{\@title}}
+\let\thanks\@gobble
+\let\DelayPrintIndex\PrintIndex
+\let\PrintIndex\@empty
+\makeatother
+
+\part{Introduction to \pkg{expl3} and this document}
+
+This document is intended to act as a comprehensive reference manual
+for the \pkg{expl3} language. A general guide to the \LaTeX3
+programming language is found in \href{expl3.pdf}{expl3.pdf}.
+
+\section{Naming functions and variables}
+
+\LaTeX3 does not use \texttt{@} as a ``letter'' for defining
+internal macros. Instead, the symbols |_| and \texttt{:}
+are used in internal macro names to provide structure. The name of
+each \emph{function} is divided into logical units using \texttt{_},
+while \texttt{:} separates the \emph{name} of the function from the
+\emph{argument specifier} (``arg-spec''). This describes the arguments
+expected by the function. In most cases, each argument is represented
+by a single letter. The complete list of arg-spec letters for a function
+is referred to as the \emph{signature} of the function.
+
+Each function name starts with the \emph{module} to which it belongs.
+Thus apart from a small number of very basic functions, all \pkg{expl3}
+function names contain at least one underscore to divide the module
+name from the descriptive name of the function. For example, all
+functions concerned with comma lists are in module \texttt{clist} and
+begin \cs{clist_}.
+
+Every function must include an argument specifier. For functions which
+take no arguments, this will be blank and the function name will end
+\texttt{:}. Most functions take one or more arguments, and use the
+following argument specifiers:
+\begin{description}
+ \item[\texttt{D}] The \texttt{D} specifier means \emph{do not use}.
+ All of the \TeX\ primitives are initially \cs{let} to a \texttt{D}
+ name, and some are then given a second name. Only the kernel
+ team should use anything with a \texttt{D} specifier!
+ \item[\texttt{N} and \texttt{n}] These mean \emph{no manipulation},
+ of a single token for \texttt{N} and of a set of tokens given in
+ braces for \texttt{n}. Both pass the argument though exactly as
+ given. Usually, if you use a single token for an \texttt{n} argument,
+ all will be well.
+ \item[\texttt{c}] This means \emph{csname}, and indicates that the
+ argument will be turned into a csname before being used. So
+ So \cs{foo:c} |{ArgumentOne}| will act in the same way as \cs{foo:N}
+ \cs{ArgumentOne}.
+ \item[\texttt{V} and \texttt{v}] These mean \emph{value
+ of variable}. The \texttt{V} and \texttt{v} specifiers are used to
+ get the content of a variable without needing to worry about the
+ underlying \TeX\ structure containing the data. A \texttt{V}
+ argument will be a single token (similar to \texttt{N}), for example
+ \cs{foo:V} \cs{MyVariable}; on the other hand, using \texttt{v} a
+ csname is constructed first, and then the value is recovered, for
+ example \cs{foo:v} |{MyVariable}|.
+ \item[\texttt{o}] This means \emph{expansion once}. In general, the
+ \texttt{V} and \texttt{v} specifiers are favoured over \texttt{o}
+ for recovering stored information. However, \texttt{o} is useful
+ for correctly processing information with delimited arguments.
+ \item[\texttt{x}] The \texttt{x} specifier stands for \emph{exhaustive
+ expansion}: the plain \TeX\ \cs{edef}.
+ \item[\texttt{f}] The \texttt{f} specifier stands for \emph{full
+ expansion}, and in contrast to \emph{x} stops at the first
+ non-expandable item without trying to execute it.
+ \item[\texttt{T} and \texttt{F}] For logic tests, there are the branch
+ specifiers \texttt{T} (\emph{true}) and \texttt{F} (\emph{false}).
+ Both specifiers treat the input in the same way as \texttt{n} (no
+ change), but make the logic much easier to see.
+ \item[\texttt{p}] The letter \texttt{p} indicates \TeX\
+ \emph{parameters}. Normally this will be used for delimited
+ functions as \pkg{expl3} provides better methods for creating simple
+ sequential arguments.
+ \item[\texttt{w}] Finally, there is the \texttt{w} specifier for
+ \emph{weird} arguments. This covers everything else, but mainly
+ applies to delimited values (where the argument must be terminated
+ by some arbitrary string).
+\end{description}
+Notice that the argument specifier describes how the argument is
+processed prior to being passed to the underlying function. For example,
+\cs{foo:c} will take its argument, convert it to a control sequence and
+pass it to \cs{foo:N}.
+
+Variables are named in a similar manner to functions, but begin with
+a single letter to define the type of variable:
+\begin{description}
+ \item[\texttt{c}] Constant: global parameters whose value should not
+ be changed.
+ \item[\texttt{g}] Parameters whose value should only be set globally.
+ \item[\texttt{l}] Parameters whose value should only be set locally.
+\end{description}
+Each variable name is then build up in a similar way to that of a
+function, typically starting with the module\footnote{The module names are
+ not used in case of generic scratch registers defined in the data
+ type modules, e.g., the
+ \texttt{int} module contains some scratch variables called \cs{l_tmpa_int},
+ \cs{l_tmpb_int}, and so on. In such a case adding the module name up front
+ to denote the module
+ and in the back to indicate the type, as in
+ \cs{l_int_tmpa_int} would be very unreadable.} name
+and then a descriptive part.
+Variables end with a short identifier to show the variable type:
+\begin{description}
+ \item[\texttt{bool}] Either true or false.
+ \item[\texttt{box}] Box register.
+ \item[\texttt{clist}] Comma separated list.
+ \item[\texttt{dim}] `Rigid' lengths.
+ \item[\texttt{int}] Integer-valued count register.
+ \item[\texttt{num}] A `fake' integer type using only macros. Useful for
+ setting up allocation routines.
+ \item[\texttt{prop}] Property list.
+ \item[\texttt{skip}] `Rubber' lengths.
+ \item[\texttt{seq}] `Sequence': a data-type used to implement lists
+ (with access at both ends) and stacks.
+ \item[\texttt{stream}] An input or output stream (for reading from or
+ writing to, respectively).
+ \item[\texttt{tl}] Token list variables: placeholder for a token list.
+ \item[\texttt{toks}] Token register.
+\end{description}
+
+\subsubsection{Terminological inexactitude}
+
+A word of warning. In this document, and others referring to the \pkg{expl3}
+programming modules, we often refer to `variables' and `functions' as if
+they were actual constructs from a real programming language.
+In truth, \TeX\ is a macro processor, and functions are simply macros that
+may or mayn't take arguments and expand to their replacement text.
+Many of the common variables are \emph{also} macros, and if placed into the
+input stream will simply expand to their definition as well~--- a `function'
+with no arguments and a `token list variable' are in truth one and the same.
+On the other hand, some `variables' are actually registers that must be initialised and their values set and retreived with specific functions.
+
+The conventions of the \pkg{expl3} code are designed to clearly separate the
+ideas of `macros that contain data' and `macros that contain code', and a consistent wrapper is applied to all forms of `data' whether they be macros or actually registers.
+This means that sometimes we will use phrases like `the function returns a value', when actually we just mean `the macro expands to something'. Similarly, the term `execute' might be used in place of `expand' or it might refer to the more specific case of `processing in \TeX's stomach' (if you are familiar with the \TeX{}book parlance).
+
+If in doubt, please ask; chances are we've been hasty in writing certain definitions and need to be told to tighten up our terminology.
+
+\section{Documentation conventions}
+
+This document is typeset with the experimental \pkg{l3doc} class;
+several conventions are used to help describe the features of the code.
+A number of conventions are used here to make the documentation clearer.
+
+Each group of related functions is given in a box. For a function with
+a ``user'' name, this might read:
+\begin{function}{
+ \ExplSyntaxOn |
+ \ExplSyntaxOff
+ }
+ \begin{syntax}
+ "\ExplSyntaxOn" \dots\ "\ExplSyntaxOff"
+ \end{syntax}
+ The textual description of how the function works would appear here. The
+ syntax of the function is shown in mono-spaced text to the right of
+ the box. In this example, the function takes no arguments and so the
+ name of the function is simply reprinted.
+\end{function}
+
+For programming functions, which use \texttt{_} and \texttt{:} in their
+name there are a few additional conventions: If two related functions are given with identical names but
+different argument specifiers, these are termed \emph{variants} of each
+other, and the latter functions are printed in grey to show this more
+clearly. They will carry out the same function but will take different
+types of argument:
+\begin{function}{
+ \seq_new:N |
+ \seq_new:c
+ }
+ \begin{syntax}
+ "\seq_new:N" <sequence>
+ \end{syntax}
+ When a number of variants are described, the arguments are usually
+ illustrated only for the base function. Here, <sequence> indicates
+ that \cs{seq_new:N} expects the name of a sequence. From the argument
+ specifier, \cs{seq_new:c} also expects a sequence name, but as a
+ name rather than as a control sequence. Each argument given in the
+ illustration should be described in the following text.
+\end{function}
+
+Some functions are fully expandable, which allows it to be used within
+an \texttt{x}-type argument (in plain \TeX\ terms, inside an \cs{edef}).
+These fully expandable functions are indicated in the documentation by
+a star:
+\begin{function}{
+ \cs_to_str:N / (EXP)
+ }
+ \begin{syntax}
+ "\cs_to_str:N" <cs>
+ \end{syntax}
+ As with other functions, some text should follow which explains how
+ the function works. Usually, only the star will indicate that the
+ function is expandable. In this case, the function expects a <cs>,
+ shorthand for a <control sequence>.
+\end{function}
+
+Conditional (\texttt{if}) functions are normally defined in three variants, with
+\texttt{T}, \texttt{F} and \texttt{TF} argument specifiers. This allows
+them to be used for different `true'/`false' branches, depending on
+which outcome the conditional is being used to test. To indicate this
+without repetition, this information is given in a shortened form:
+\begin{function}{
+ \xetex_if_engine: / (TF) (EXP)
+ }
+ \begin{syntax}
+ "\xetex_if_engine:TF" <true code> <false code>
+ \end{syntax}
+ The underlining and italic of \texttt{TF} indicates that
+ \cs{xetex_if_engine:T}, \cs{xetex_if_engine:F} and
+ \cs{xetex_if_engine:TF} are all available. Usually, the illustration
+ will use the \texttt{TF} variant, and so both <true code>
+ and <false code> will be shown. The two variant forms \texttt{T} and
+ \texttt{F} take only <true code> and <false code>, respectively.
+ Here, the star also shows that this function is expandable.
+ With some minor exceptions, \emph{all} conditional functions in the
+ \pkg{expl3} modules should be defined in this way.
+\end{function}
+
+Variables, constants and so on are described in a similar manner:
+\begin{variable}{
+ \l_tmpa_tl
+ }
+ A short piece of text will describe the variable: there is no
+ syntax illustration in this case.
+\end{variable}
+
+In some cases, the function is similar to one in \LaTeXe\ or plain \TeX.
+In these cases, the text will include an extra `\textbf{\TeX{}hackers
+note}' section:
+\begin{function}{
+ \token_to_str:N / (EXP)
+ }
+ \begin{syntax}
+ "\token_to_str:N" <token>
+ \end{syntax}
+ The normal description text.
+ \begin{texnote}
+ Detail for the experienced \TeX\ or \LaTeXe\ programmer. In this
+ case, it would point out that this function is the \TeX\ primitive
+ \cs{string}.
+ \end{texnote}
+\end{function}
+
+\DisableImplementation
+
+\DocInput{l3names.dtx}
+
+\DocInput{l3basics.dtx}
+\DocInput{l3expan.dtx}
+\DocInput{l3prg.dtx}
+\DocInput{l3quark.dtx}
+\DocInput{l3token.dtx}
+
+\DocInput{l3int.dtx}
+\DocInput{l3intexpr.dtx}
+\DocInput{l3skip.dtx}
+
+\DocInput{l3tl.dtx}
+\DocInput{l3toks.dtx}
+\DocInput{l3seq.dtx}
+\DocInput{l3clist.dtx}
+\DocInput{l3prop.dtx}
+
+\DocInput{l3io.dtx}
+\DocInput{l3msg.dtx}
+\DocInput{l3box.dtx}
+\DocInput{l3xref.dtx}
+\DocInput{l3keyval.dtx}
+\DocInput{l3keys.dtx}
+\DocInput{l3calc.dtx}
+\DocInput{l3file.dtx}
+
+% \DocInput{l3precom.dtx}
+% \DocInput{l3alloc.dtx}
+% \DocInput{l3chk.dtx}
+
+\part{Implementation}
+\def\maketitle{}
+\EnableImplementation
+\DisableDocumentation
+\DocInputAgain
+
+%% \DocInput{l3vers.dtx} % Current version date
+
+\clearpage
+\pagestyle{headings}
+
+% Make TeX shut up.
+\hbadness=10000
+\newcount\hbadness
+\hfuzz=\maxdimen
+
+\PrintChanges
+\clearpage
+
+\begingroup
+\def\endash{--}
+\catcode`\-\active
+\def-{\futurelet\temp\indexdash}
+\def\indexdash{\ifx\temp-\endash\fi}
+
+\DelayPrintIndex
+\endgroup
+
+\end{document}
+
+