[latex3-commits] [l3svn] r7397 - Warn if delimiters for xparse d, D, e, E, t args are not chars (fixes #367, fixes #368)
noreply at latex-project.org
noreply at latex-project.org
Tue Jul 18 02:45:59 CEST 2017
Author: bruno
Date: 2017-07-18 02:45:59 +0200 (Tue, 18 Jul 2017)
New Revision: 7397
Modified:
trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
trunk/l3packages/xparse/testfiles/xparse001.tlg
trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg
trunk/l3packages/xparse/testfiles/xparse004.lvt
trunk/l3packages/xparse/testfiles/xparse004.tlg
trunk/l3packages/xparse/xparse.dtx
Log:
Warn if delimiters for xparse d,D,e,E,t args are not chars (fixes #367, fixes #368)
I didn't want to make it an error right away but we may want to do it longterm?
Modified: trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg 2017-07-18 00:45:59 UTC (rev 7397)
@@ -572,6 +572,12 @@
.
. Redefining command \foo with sig. '+t\par O{default}mmm' on line ....
.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\par ' for the command '\foo' should be a single
+* character.
+*************************************************
> \foo=\protected macro:->\__xparse_start:nNNnnn {+t\par O{default}mmm}\foo
\foo code {\__xparse_grab_t_long:w \par \__xparse_grab_D:w
[]\__xparse_grab_m_3:w }{\c__xparse_no_value_tl {\prg_do_nothing:
Modified: trunk/l3packages/xparse/testfiles/xparse001.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.tlg 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse001.tlg 2017-07-18 00:45:59 UTC (rev 7397)
@@ -572,6 +572,12 @@
.
. Redefining command \foo with sig. '+t\par O{default}mmm' on line ....
.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\par ' for the command '\foo' should be a single
+* character.
+*************************************************
> \foo=\protected macro:->\__xparse_start:nNNnnn {+t\par O{default}mmm}\foo
\foo code {\__xparse_grab_t_long:w \par \__xparse_grab_D:w
[]\__xparse_grab_m_3:w }{\c__xparse_no_value_tl {\prg_do_nothing:
Modified: trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg 2017-07-18 00:45:59 UTC (rev 7397)
@@ -572,6 +572,12 @@
.
. Redefining command \foo with sig. '+t\par O{default}mmm' on line ....
.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\par ' for the command '\foo' should be a single
+* character.
+*************************************************
> \foo=\protected macro:->\__xparse_start:nNNnnn {+t\par O{default}mmm}\foo
\foo code {\__xparse_grab_t_long:w \par \__xparse_grab_D:w
[]\__xparse_grab_m_3:w }{\c__xparse_no_value_tl {\prg_do_nothing:
Modified: trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse004.luatex.tlg 2017-07-18 00:45:59 UTC (rev 7397)
@@ -360,9 +360,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter 'oh' for the command '\foo' should be a single token.
+! Argument delimiter 'oh' for the command '\foo' should be a single character.
!
! See the LaTeX3 documentation for further information.
!
@@ -373,7 +373,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'oh'.
+| character is required, LaTeX found 'oh'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -385,9 +385,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter '' for the command '\foo' should be a single token.
+! Argument delimiter '' for the command '\foo' should be a single character.
!
! See the LaTeX3 documentation for further information.
!
@@ -398,7 +398,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found ''.
+| character is required, LaTeX found ''.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -410,9 +410,10 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter '{Y}' for the command '\foo' should be a single token.
+! Argument delimiter '{Y}' for the command '\foo' should be a single
+! character.
!
! See the LaTeX3 documentation for further information.
!
@@ -423,7 +424,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found '{Y}'.
+| character is required, LaTeX found '{Y}'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1439,9 +1440,10 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter 'abc' for the command '\foo' should be a single token.
+! Argument delimiter 'abc' for the command '\foo' should be a single
+! character.
!
! See the LaTeX3 documentation for further information.
!
@@ -1452,7 +1454,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'abc'.
+| character is required, LaTeX found 'abc'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1464,9 +1466,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/bad-arg-spec"
!
-! Argument delimiter 'abc' for the command '\foo' should be a single token.
+! Bad argument specification 'D{abc}{def}' for command '\foo'.
!
! See the LaTeX3 documentation for further information.
!
@@ -1476,8 +1478,8 @@
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
-| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'abc'.
+| The argument specification provided was not valid: one or more mandatory
+| pieces of information were missing.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1788,6 +1790,12 @@
.
. Redefining command \foo with sig. 't-t{\par }+o+m' on line ....
.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\par ' for the command '\foo' should be a single
+* character.
+*************************************************
|\BooleanTrue |\BooleanTrue |\par |\par |
|\BooleanFalse |\BooleanTrue |-NoValue-|\par \A |
.................................................
@@ -1926,3 +1934,42 @@
.................................................
|2|{5}|
============================================================
+============================================================
+TEST 27: Non-character token delimiters
+============================================================
+.................................................
+. LaTeX info: "xparse/redefine-command"
+.
+. Redefining command \foo with sig. 'd\[\]' on line ....
+.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\[' for the command '\foo' should be a single character.
+*************************************************
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\]' for the command '\foo' should be a single character.
+*************************************************
+[abc
+.................................................
+. LaTeX info: "xparse/redefine-command"
+.
+. Redefining command \foo with sig. 'e{\undefinedFirstArgument
+. \undefinedSecondArgument }' on line ....
+.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\undefinedFirstArgument ' for the command '\foo' should
+* be a single character.
+*************************************************
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\undefinedSecondArgument ' for the command '\foo' should
+* be a single character.
+*************************************************
+something/-NoValue-
+============================================================
Modified: trunk/l3packages/xparse/testfiles/xparse004.lvt
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.lvt 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse004.lvt 2017-07-18 00:45:59 UTC (rev 7397)
@@ -446,4 +446,13 @@
\foo { a , bcd } { a , bcd }
}
+\TEST { Non-character~token~delimiters }
+ {
+ \DeclareDocumentCommand { \foo } { d\[\] } { \TYPE {#1} }
+ \foo \[abc\]
+ \DeclareDocumentCommand\foo
+ { e {\undefinedFirstArgument\undefinedSecondArgument}}
+ { \TYPE {#1/#2} }
+ \foo \undefinedSecondArgument {something}
+ }
\END
Modified: trunk/l3packages/xparse/testfiles/xparse004.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.tlg 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/testfiles/xparse004.tlg 2017-07-18 00:45:59 UTC (rev 7397)
@@ -360,9 +360,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter 'oh' for the command '\foo' should be a single token.
+! Argument delimiter 'oh' for the command '\foo' should be a single character.
!
! See the LaTeX3 documentation for further information.
!
@@ -373,7 +373,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'oh'.
+| character is required, LaTeX found 'oh'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -385,9 +385,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter '' for the command '\foo' should be a single token.
+! Argument delimiter '' for the command '\foo' should be a single character.
!
! See the LaTeX3 documentation for further information.
!
@@ -398,7 +398,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found ''.
+| character is required, LaTeX found ''.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -410,9 +410,10 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter '{Y}' for the command '\foo' should be a single token.
+! Argument delimiter '{Y}' for the command '\foo' should be a single
+! character.
!
! See the LaTeX3 documentation for further information.
!
@@ -423,7 +424,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found '{Y}'.
+| character is required, LaTeX found '{Y}'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1439,9 +1440,10 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/not-single-char"
!
-! Argument delimiter 'abc' for the command '\foo' should be a single token.
+! Argument delimiter 'abc' for the command '\foo' should be a single
+! character.
!
! See the LaTeX3 documentation for further information.
!
@@ -1452,7 +1454,7 @@
| This is a coding error.
|
| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'abc'.
+| character is required, LaTeX found 'abc'.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1464,9 +1466,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "xparse/not-single-token"
+! LaTeX error: "xparse/bad-arg-spec"
!
-! Argument delimiter 'abc' for the command '\foo' should be a single token.
+! Bad argument specification 'D{abc}{def}' for command '\foo'.
!
! See the LaTeX3 documentation for further information.
!
@@ -1476,8 +1478,8 @@
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
-| The argument specification provided was not valid: in a place where a single
-| token is required, LaTeX found 'abc'.
+| The argument specification provided was not valid: one or more mandatory
+| pieces of information were missing.
|
| LaTeX will ignore this entire definition.
|...............................................
@@ -1788,6 +1790,12 @@
.
. Redefining command \foo with sig. 't-t{\par }+o+m' on line ....
.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\par ' for the command '\foo' should be a single
+* character.
+*************************************************
|\BooleanTrue |\BooleanTrue |\par |\par |
|\BooleanFalse |\BooleanTrue |-NoValue-|\par \A |
.................................................
@@ -1926,3 +1934,42 @@
.................................................
|2|{5}|
============================================================
+============================================================
+TEST 27: Non-character token delimiters
+============================================================
+.................................................
+. LaTeX info: "xparse/redefine-command"
+.
+. Redefining command \foo with sig. 'd\[\]' on line ....
+.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\[' for the command '\foo' should be a single character.
+*************************************************
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\]' for the command '\foo' should be a single character.
+*************************************************
+[abc
+.................................................
+. LaTeX info: "xparse/redefine-command"
+.
+. Redefining command \foo with sig. 'e{\undefinedFirstArgument
+. \undefinedSecondArgument }' on line ....
+.................................................
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\undefinedFirstArgument ' for the command '\foo' should
+* be a single character.
+*************************************************
+*************************************************
+* LaTeX warning: "xparse/not-single-char"
+*
+* Argument delimiter '\undefinedSecondArgument ' for the command '\foo' should
+* be a single character.
+*************************************************
+something/-NoValue-
+============================================================
Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx 2017-07-18 00:14:45 UTC (rev 7396)
+++ trunk/l3packages/xparse/xparse.dtx 2017-07-18 00:45:59 UTC (rev 7397)
@@ -131,15 +131,15 @@
% internal code surrounded by a brace pair. This is the \pkg{xparse}
% type specifier for a normal \TeX{} argument.
% \item[l] An argument which reads everything up to the first
-% open group token: in standard \LaTeX{} this is a left brace.
+% begin-group token: in standard \LaTeX{} this is a left brace.
% \item[r] Reads a \enquote{required} delimited argument, where the
-% delimiters are given as \meta{token1} and \meta{token2}:
-% \texttt{r}\meta{token1}\meta{token2}. If the opening \meta{token}
+% delimiters are given as \meta{char1} and \meta{char2}:
+% \texttt{r}\meta{char1}\meta{char2}. If the opening \meta{character}
% is missing, the default marker |-NoValue-| will be inserted after
% a suitable error.
% \item[R] As for \texttt{r}, this is a \enquote{required} delimited
% argument but has a user-definable recovery \meta{default}, given
-% as \texttt{R}\meta{token1}\meta{token2}\marg{default}.
+% as \texttt{R}\meta{char1}\meta{char2}\marg{default}.
% \item[u] Reads an argument \enquote{until} \meta{tokens} are encountered,
% where the desired \meta{tokens} are given as an argument to the
% specifier: \texttt{u}\marg{tokens}.
@@ -158,35 +158,35 @@
% \item[o] A standard \LaTeX{} optional argument, surrounded with square
% brackets, which will supply
% the special |-NoValue-| marker if not given (as described later).
-% \item[d] An optional argument which is delimited by \meta{token1}
-% and \meta{token2}, which are given as arguments:
-% \texttt{d}\meta{token1}\meta{token2}. As with \texttt{o}, if no
+% \item[d] An optional argument which is delimited by \meta{char1}
+% and \meta{char2}, given as follows:
+% \texttt{d}\meta{char1}\meta{char2}. As with \texttt{o}, if no
% value is given the special marker |-NoValue-| is returned.
% \item[O] As for \texttt{o}, but returns \meta{default} if no
% value is given. Should be given as \texttt{O}\marg{default}.
% \item[D] As for \texttt{d}, but returns \meta{default} if no
-% value is given: \texttt{D}\meta{token1}\meta{token2}\marg{default}.
+% value is given: \texttt{D}\meta{char1}\meta{char2}\marg{default}.
% Internally, the \texttt{o}, \texttt{d} and \texttt{O} types are
% short-cuts to an appropriated-constructed \texttt{D} type argument.
% \item[s] An optional star, which will result in a value
% \cs{BooleanTrue} if a star is present and \cs{BooleanFalse}
% otherwise (as described later).
-% \item[t] An optional \meta{token}, which will result in a value
-% \cs{BooleanTrue} if \meta{token} is present and \cs{BooleanFalse}
-% otherwise. Given as \texttt{t}\meta{token}.
+% \item[t] An optional \meta{char}, which will result in a value
+% \cs{BooleanTrue} if \meta{char} is present and \cs{BooleanFalse}
+% otherwise. Given as \texttt{t}\meta{char}.
% \item[g] An optional argument given inside a pair of \TeX{} group
% tokens (in standard \LaTeX, |{| \ldots |}|), which returns
% |-NoValue-| if not present.
% \item[G] As for \texttt{g} but returns \meta{default} if no value
% is given: \texttt{G}\marg{default}.
% \item[e] A set of optional \emph{embellishments}, each of which
-% requires a \emph{value}: \texttt{e}\marg{tokens}. If an
+% requires a \emph{value}: \texttt{e}\marg{chars}. If an
% embellishment is not present, |-NoValue-| is returned. Each
% embellishment gives one argument, ordered as for the list of
-% \meta{tokens} in the argument specification. All \meta{tokens}
+% \meta{chars} in the argument specification. All \meta{chars}
% must be distinct. \emph{This is an experimental type}.
% \item[E] As for \texttt{e} but returns one or more \meta{defaults}
-% if values are not given: \texttt{E}\marg{tokens}\marg{defaults}. See
+% if values are not given: \texttt{E}\marg{chars}\marg{defaults}. See
% Section~\ref{sec:embellishment} for more details.
% \end{itemize}
%
@@ -235,14 +235,14 @@
% \foobaz[ {abc}] % => " {abc}"
% \end{verbatim}
%
-% Two more tokens have a special meaning when creating an argument
+% Two more characters have a special meaning when creating an argument
% specifier. First, \texttt{+} is used to make an argument long (to
% accept paragraph tokens). In contrast to \LaTeXe's \cs{newcommand},
% this applies on an argument-by-argument basis. So modifying the
% example to `|s o o +m O{default}|' means that the mandatory argument
% is now \cs{long}, whereas the optional arguments are not.
%
-% Secondly, the token \texttt{>} is used to declare so-called
+% Secondly, the character \texttt{>} is used to declare so-called
% \enquote{argument processors}, which can be used to modify the contents of an
% argument before it is passed to the macro definition. The use of
% argument processors is a somewhat advanced topic, (or at least a less
@@ -354,19 +354,19 @@
% \subsection{Default values for \enquote{embellishments}}
% \label{sec:embellishment}
%
-% The \texttt{E}-type argument allows one default value per test token.
+% The \texttt{E}-type argument allows one default value per test character.
% This is achieved by giving a list of defaults for each entry in the
% list, for example:
% \begin{verbatim}
% E{^_}{{UP}{DOWN}}
% \end{verbatim}
-% If the list of default values is \emph{shorter} than the list of test tokens,
+% If the list of default values is \emph{shorter} than the list of test characters,
% the special \cs{NoValue} marker will be returned (as for the \texttt{e}-type
% argument). Thus for example
% \begin{verbatim}
% E{^_}{{UP}}
% \end{verbatim}
-% has default \texttt{UP} for the |^| test token, but will return the
+% has default \texttt{UP} for the |^| test character, but will return the
% \cs{NoValue} marker as a default for |_|. This allows mixing of explicit
% defaults with testing for missing values.
%
@@ -514,7 +514,7 @@
%
% \begin{variable}{\BooleanFalse, \BooleanTrue}
% The \texttt{true} and \texttt{false} flags set when searching for
-% an optional token (using \texttt{s} or \texttt{t\meta{token}}) have
+% an optional character (using \texttt{s} or \texttt{t\meta{char}}) have
% names which are accessible outside of code blocks.
% \end{variable}
%
@@ -1487,7 +1487,7 @@
% The first thing that is done in the loop is to check that the various
% argument types have the correct number of data items associated with
% them. The opportunity is also taken to make sure that where a single
-% token is required, one has actually been supplied.
+% character is required, one has actually been supplied.
%
% The second is that processors and the marker~|+| for long arguments
% must be followed by arguments.
@@ -1667,10 +1667,10 @@
% }
% \begin{macro}[aux]{\@@_normalize_E_unique_check:w}
% Optional argument types. Check that all required data is present
-% (and consists of single tokens if applicable) and check for
+% (and consists of single characters if applicable) and check for
% forbidden types for expandable commands. For \texttt{E}-type
% require that there is at least one embellishment, that each one is a
-% single token, and that there aren't more optional arguments than
+% single character, and that there aren't more optional arguments than
% embellishments; also remember that each embellishment counts as one
% argument for \cs{l_@@_current_arg_int}. Then in each case
% store the data in \cs{l_@@_arg_spec_tl}, and
@@ -1680,9 +1680,9 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_normalize_type_D:w #1#2#3
{
- \@@_single_token_check:n {#1}
- \@@_single_token_check:n {#2}
\quark_if_recursion_tail_stop_do:nn {#3} { \@@_bad_arg_spec:wn }
+ \@@_single_char_check:n {#1}
+ \@@_single_char_check:n {#2}
\@@_add_arg_spec:n { D #1 #2 {#3} }
\tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
\bool_set_false:N \l_@@_grab_expandably_bool
@@ -1692,7 +1692,7 @@
{
\quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn }
\tl_if_blank:nT {#1} { \@@_bad_arg_spec:wn }
- \tl_map_function:nN {#1} \@@_single_token_check:n
+ \tl_map_function:nN {#1} \@@_single_char_check:n
\@@_normalize_E_unique_check:w #1 \q_nil \q_stop
\int_compare:nNnT { \tl_count:n {#2} } > { \tl_count:n {#1} }
{ \@@_bad_arg_spec:wn }
@@ -1720,8 +1720,8 @@
}
\cs_new_protected:Npn \@@_normalize_type_t:w #1
{
- \@@_single_token_check:n {#1}
\quark_if_recursion_tail_stop_do:Nn #1 { \@@_bad_arg_spec:wn }
+ \@@_single_char_check:n {#1}
\tl_put_right:Nn \l_@@_arg_spec_tl { t #1 }
\tl_put_right:Nn \l_@@_last_delimiters_tl {#1}
\bool_set_false:N \l_@@_grab_expandably_bool
@@ -1741,7 +1741,7 @@
% \@@_normalize_type_v:w
% }
% Mandatory arguments. First check the required data is present,
-% consists of single tokens where applicable, and that the argument
+% consists of single characters where applicable, and that the argument
% type is allowed for expandable commands if applicable. For the
% \texttt{m} and \texttt{R} argument types check that they do not
% follow some optional argument with that delimiter as otherwise the
@@ -1767,9 +1767,9 @@
}
\cs_new_protected:Npn \@@_normalize_type_R:w #1#2#3
{
- \@@_single_token_check:n {#1}
- \@@_single_token_check:n {#2}
\quark_if_recursion_tail_stop_do:nn {#3} { \@@_bad_arg_spec:wn }
+ \@@_single_char_check:n {#1}
+ \@@_single_char_check:n {#2}
\@@_delimiter_check:nnn {#1} { R/r } { \tl_to_str:n {#1} }
\@@_add_arg_spec:n { R #1 #2 {#3} }
\int_incr:N \l_@@_mandatory_args_int
@@ -1797,15 +1797,26 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_single_token_check:n}
-% A spin-out function to check that what should be single tokens really
-% are single tokens.
+% \begin{macro}{\@@_single_char_check:n}
+% Checks that what should be single characters really are single
+% characters (possibly surrounded by spaces).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_single_token_check:n #1
+\cs_new_protected:Npn \@@_single_char_check:n #1
{
- \exp_args:Nx \tl_if_single_token:nF { \tl_trim_spaces:n {#1} }
+ \exp_args:Nx \tl_if_single_token:nTF { \tl_trim_spaces:n {#1} }
{
- \__msg_kernel_error:nnxx { xparse } { not-single-token }
+ \group_begin:
+ \tex_escapechar:D = 92 \scan_stop:
+ \exp_args:Nx \tl_if_single_token:nF
+ { \exp_args:No \tl_to_str:n { \use:nn #1 { } } }
+ {
+ \__msg_kernel_warning:nnxx { xparse } { not-single-char }
+ { \iow_char:N \\ \l_@@_function_tl } { \tl_to_str:n {#1} }
+ }
+ \group_end:
+ }
+ {
+ \__msg_kernel_error:nnxx { xparse } { not-single-char }
{ \iow_char:N \\ \l_@@_function_tl } { \tl_to_str:n {#1} }
\@@_bad_def:wn
}
@@ -4139,12 +4150,15 @@
\\ \\
LaTeX~will~ignore~this~entire~definition.
}
-\__msg_kernel_new:nnnn { xparse } { not-single-token }
- { Argument~delimiter~'#2'~for~the~command~'#1'~should~be~a~single~token. }
+\__msg_kernel_new:nnnn { xparse } { not-single-char }
{
+ Argument~delimiter~'#2'~for~the~command~'#1'~should~be~
+ a~single~character.
+ }
+ {
\c__msg_coding_error_text_tl
- The~argument~specification~provided~was~not~valid:~
- in~a~place~where~a~single~token~is~required,~LaTeX~found~'#2'. \\ \\
+ The~argument~specification~provided~was~not~valid:~in~a~place~
+ where~a~single~character~is~required,~LaTeX~found~'#2'. \\ \\
LaTeX~will~ignore~this~entire~definition.
}
\__msg_kernel_new:nnnn { xparse } { processor-in-expandable }
More information about the latex3-commits
mailing list