[latex3-commits] [l3svn] r6093 - Avoid \tex_meaning:D use and \cs_to_str:N abuse in l3htoks

noreply at latex-project.org noreply at latex-project.org
Fri Sep 25 17:42:24 CEST 2015


Author: bruno
Date: 2015-09-25 17:42:23 +0200 (Fri, 25 Sep 2015)
New Revision: 6093

Modified:
   trunk/l3trial/l3htoks/l3htoks.dtx
Log:
Avoid \tex_meaning:D use and \cs_to_str:N abuse in l3htoks


Modified: trunk/l3trial/l3htoks/l3htoks.dtx
===================================================================
--- trunk/l3trial/l3htoks/l3htoks.dtx	2015-09-25 15:40:08 UTC (rev 6092)
+++ trunk/l3trial/l3htoks/l3htoks.dtx	2015-09-25 15:42:23 UTC (rev 6093)
@@ -331,6 +331,31 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsubsection{Other helpers}
+%
+% \begin{macro}[aux]
+%   {\@@_strip_escape:w, \@@_strip_escape_aux:N, \@@_strip_escape_aux:w}
+%   At the time of writing, this is almost copy of \cs{cs_to_str:N}.
+%   It is meant to remove an escape character from what follows in the
+%   input stream (which must be already turned into a string).  More
+%   precisely, if the escape character code is negative or too large
+%   then do nothing; if it is a space, then hit what follows with
+%   \cs{tex_romannumeral:D} |0| hence remove a space (this breaks if
+%   what follows starts with a digit); and in all other cases, do
+%   \cs{use_none:n}.
+%    \begin{macrocode}
+\cs_new_nopar:Npn \@@_strip_escape:w
+  {
+    \tex_romannumeral:D
+      \if:w \token_to_str:N \ \@@_strip_escape_aux:w \fi:
+      \@@_strip_escape_aux:N
+  }
+\cs_new:Npn \@@_strip_escape_aux:N #1 { \c_zero }
+\cs_new:Npn \@@_strip_escape_aux:w #1#2
+  { - \__int_value:w #1 \c_zero }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Parsing loop}
 %
 % \subsubsection{Main loop}
@@ -451,15 +476,15 @@
       {
         \tl_set:Nx \l_@@_peek_meaning_tl
           {
-            \exp_after:wN \cs_to_str:N %^^A todo: this abuses \cs_to_str:N
-            \tex_meaning:D \l_@@_peek_token
+            \exp_after:wN \@@_strip_escape:w
+            \token_to_meaning:N \l_@@_peek_token
           }
       }
       {
         \tl_set:Nx \l_@@_peek_meaning_tl
           {
             \exp_after:wN \@@_meaning_character:w
-            \tex_meaning:D \l_@@_peek_token \q_stop
+            \token_to_meaning:N \l_@@_peek_token \q_stop
           }
       }
     \group_align_safe_end:
@@ -484,7 +509,7 @@
   {
     \__int_value:w
       \exp_after:wN \@@_token_to_charcode_auxi:w
-      \tex_meaning:D
+      \token_to_meaning:N
   }
 \group_begin:
   \char_set_catcode_other:N \m



More information about the latex3-commits mailing list