[latex3-commits] [l3svn] r6857 - Detect attempts to define commands with more than 9 arguments
noreply at latex-project.org
noreply at latex-project.org
Thu Feb 9 05:15:05 CET 2017
Author: bruno
Date: 2017-02-09 05:15:05 +0100 (Thu, 09 Feb 2017)
New Revision: 6857
Modified:
trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
trunk/l3packages/xparse/testfiles/xparse001.tlg
trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
trunk/l3packages/xparse/xparse.dtx
Log:
Detect attempts to define commands with more than 9 arguments
Modified: trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg 2017-02-09 04:01:50 UTC (rev 6856)
+++ trunk/l3packages/xparse/testfiles/xparse001.ptex.tlg 2017-02-09 04:15:05 UTC (rev 6857)
@@ -167,9 +167,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "kernel/bad-number-of-arguments"
+! LaTeX error: "xparse/too-many-arguments"
!
-! Function '\foo code' cannot be defined with 10 arguments.
+! Too many arguments in argument specification 'mmmmmmmmmm'.
!
! See the LaTeX3 documentation for further information.
!
@@ -179,14 +179,15 @@
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
-| LaTeX has been asked to define a function '\foo code' with 10 arguments. TeX
-| allows between 0 and 9 arguments for a single function.
+| The argument specification provided has more than 9 arguments. This cannot
+| be implemented.
+|
+| LaTeX will ignore this entire definition.
|...............................................
-> \foo=\protected macro:->\__xparse_start:nNNnnn {mmmmmmmmmm}\foo \foo code
-{\__xparse_grab_m_10:w }{}{}.
+> \foo=undefined.
<recently read> }
l. ...}
-> \foo code=\relax.
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
Modified: trunk/l3packages/xparse/testfiles/xparse001.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.tlg 2017-02-09 04:01:50 UTC (rev 6856)
+++ trunk/l3packages/xparse/testfiles/xparse001.tlg 2017-02-09 04:15:05 UTC (rev 6857)
@@ -167,9 +167,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "kernel/bad-number-of-arguments"
+! LaTeX error: "xparse/too-many-arguments"
!
-! Function '\foo code' cannot be defined with 10 arguments.
+! Too many arguments in argument specification 'mmmmmmmmmm'.
!
! See the LaTeX3 documentation for further information.
!
@@ -179,14 +179,15 @@
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
-| LaTeX has been asked to define a function '\foo code' with 10 arguments. TeX
-| allows between 0 and 9 arguments for a single function.
+| The argument specification provided has more than 9 arguments. This cannot
+| be implemented.
+|
+| LaTeX will ignore this entire definition.
|...............................................
-> \foo=\protected macro:->\__xparse_start:nNNnnn {mmmmmmmmmm}\foo \foo code
-{\__xparse_grab_m_10:w }{}{}.
+> \foo=undefined.
<recently read> }
l. ...}
-> \foo code=\relax.
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
Modified: trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg 2017-02-09 04:01:50 UTC (rev 6856)
+++ trunk/l3packages/xparse/testfiles/xparse001.uptex.tlg 2017-02-09 04:15:05 UTC (rev 6857)
@@ -167,9 +167,9 @@
.................................................
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
-! LaTeX error: "kernel/bad-number-of-arguments"
+! LaTeX error: "xparse/too-many-arguments"
!
-! Function '\foo code' cannot be defined with 10 arguments.
+! Too many arguments in argument specification 'mmmmmmmmmm'.
!
! See the LaTeX3 documentation for further information.
!
@@ -179,14 +179,15 @@
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
-| LaTeX has been asked to define a function '\foo code' with 10 arguments. TeX
-| allows between 0 and 9 arguments for a single function.
+| The argument specification provided has more than 9 arguments. This cannot
+| be implemented.
+|
+| LaTeX will ignore this entire definition.
|...............................................
-> \foo=\protected macro:->\__xparse_start:nNNnnn {mmmmmmmmmm}\foo \foo code
-{\__xparse_grab_m_10:w }{}{}.
+> \foo=undefined.
<recently read> }
l. ...}
-> \foo code=\relax.
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx 2017-02-09 04:01:50 UTC (rev 6856)
+++ trunk/l3packages/xparse/xparse.dtx 2017-02-09 04:15:05 UTC (rev 6857)
@@ -1333,18 +1333,27 @@
% argument specification is valid, and count up mandatory arguments before the main
% parsing run. While normally the auxiliary should only get single
% tokens, we allow multiple tokens to catch invalid argument specifications as
-% \enquote{unknown argument types}.
+% \enquote{unknown argument types}. Also detect when there are more than $9$
+% arguments.
% \begin{macrocode}
\cs_new_protected:Npn \@@_normalize_arg_spec:n #1
{
\int_zero:N \l_@@_mandatory_args_int
+ \int_zero:N \l_@@_current_arg_int
\tl_clear:N \l_@@_arg_spec_tl
\@@_normalize_arg_spec_loop:n #1
\q_recursion_tail \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ \int_compare:nNnT \l_@@_current_arg_int > 9
+ {
+ \__msg_kernel_error:nnx { xparse } { too-many-arguments }
+ { \tl_to_str:n {#1} }
+ \@@_bad_arg_spec_no_error:wn
+ }
}
\cs_new_protected:Npn \@@_normalize_arg_spec_loop:n #1
{
\quark_if_recursion_tail_stop:n {#1}
+ \int_incr:N \l_@@_current_arg_int
\cs_if_exist_use:cF { @@_normalize_type_ \tl_to_str:n {#1} :w }
{
\__msg_kernel_error:nnx { xparse } { unknown-argument-type }
@@ -1403,6 +1412,7 @@
% \begin{macrocode}
\cs_new_protected:cpn { @@_normalize_type_>:w } #1#2
{
+ \int_decr:N \l_@@_current_arg_int
\quark_if_recursion_tail_stop_do:nn {#2} { \@@_bad_arg_spec:wn }
\bool_if:NT \l_@@_expandable_bool
{
@@ -1415,6 +1425,7 @@
}
\cs_new_protected:cpn { @@_normalize_type_+:w } #1
{
+ \int_decr:N \l_@@_current_arg_int
\quark_if_recursion_tail_stop_do:nn {#1} { \@@_bad_arg_spec:wn }
\tl_put_right:Nn \l_@@_arg_spec_tl { + }
\@@_normalize_arg_spec_loop:n {#1}
@@ -3656,6 +3667,14 @@
at~each~occurrence~of~the~token~'#1',~up~to~a~maximum~of~#2~parts.~
There~were~too~many~'#1'~tokens.
}
+\__msg_kernel_new:nnnn { xparse } { too-many-arguments }
+ { Too~many~arguments~in~argument~specification~'#1'. }
+ {
+ \c__msg_coding_error_text_tl
+ The~argument~specification~provided~has~more~than~9~arguments.~
+ This~cannot~be~implemented. \\ \\
+ LaTeX~will~ignore~this~entire~definition.
+ }
\__msg_kernel_new:nnnn { xparse } { unknown-argument-type }
{ Unknown~argument~type~'#1'~replaced~by~'m'. }
{
More information about the latex3-commits
mailing list