[latex3-commits] [l3svn] r6289 - Check that delimiters really are single tokens

noreply at latex-project.org noreply at latex-project.org
Tue Nov 17 11:43:15 CET 2015


Author: bruno
Date: 2015-11-17 11:43:15 +0100 (Tue, 17 Nov 2015)
New Revision: 6289

Modified:
   trunk/l3packages/xparse/testfiles/xparse004.lvt
   trunk/l3packages/xparse/testfiles/xparse004.tlg
   trunk/l3packages/xparse/xparse.dtx
Log:
Check that delimiters really are single tokens

Argument types r, d, t expect a single token indicating what to
look for.  Previously, xparse would accept a brace group as being
a single token, which would break things later on.  Now use
\tl_if_single_token:nTF, but after space-stripping to avoid
trouble with spaces introduced at the document level.


Modified: trunk/l3packages/xparse/testfiles/xparse004.lvt
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.lvt	2015-11-17 10:25:21 UTC (rev 6288)
+++ trunk/l3packages/xparse/testfiles/xparse004.lvt	2015-11-17 10:43:15 UTC (rev 6289)
@@ -123,6 +123,8 @@
     \cs_show:N \foo
     \DeclareDocumentCommand \foo { D { } { } { } } { }
     \cs_show:N \foo
+    \DeclareDocumentCommand \foo { D { ~ X ~ } { { Y } } { } } { }
+    \cs_show:N \foo
   }
 
 \TEST { Stripping~braces~in~optional~args }

Modified: trunk/l3packages/xparse/testfiles/xparse004.tlg
===================================================================
--- trunk/l3packages/xparse/testfiles/xparse004.tlg	2015-11-17 10:25:21 UTC (rev 6288)
+++ trunk/l3packages/xparse/testfiles/xparse004.tlg	2015-11-17 10:43:15 UTC (rev 6289)
@@ -428,6 +428,33 @@
 > \foo=undefined.
 <recently read> }
 l. ...  }
+.................................................
+. LaTeX info: "xparse/define-command"
+. 
+. Defining command \foo with sig. 'D{ X }{{Y}}{}' on line ....
+.................................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "xparse/not-single-token"
+! 
+! Argument delimiter should be a single token: '{Y}'.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| The argument specification provided was not valid: in a place where a single
+| token is required, LaTeX found '{Y}'.
+| 
+| LaTeX will ignore this entire definition.
+|...............................................
+> \foo=undefined.
+<recently read> }
+l. ...  }
 ============================================================
 ============================================================
 TEST 8: Stripping braces in optional args

Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx	2015-11-17 10:25:21 UTC (rev 6288)
+++ trunk/l3packages/xparse/xparse.dtx	2015-11-17 10:43:15 UTC (rev 6289)
@@ -1256,7 +1256,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_single_token_check:n #1
   {
-    \tl_if_single:nF {#1}
+    \exp_args:Nx \tl_if_single_token:nF { \tl_trim_spaces:n {#1} }
       { \@@_single_token_check_aux:nwn {#1} }
   }
 \cs_new_protected:Npn \@@_single_token_check_aux:nwn



More information about the latex3-commits mailing list