[latex3-commits] [l3svn] r6917 - Make l3flag more robust

noreply at latex-project.org noreply at latex-project.org
Tue Feb 14 00:17:06 CET 2017


Author: bruno
Date: 2017-02-14 00:17:06 +0100 (Tue, 14 Feb 2017)
New Revision: 6917

Modified:
   trunk/l3experimental/l3str/l3flag.dtx
Log:
Make l3flag more robust

As documented, a flag name may be given as any list of tokens
that expands (in a csname) to character tokens; presumably
quarks could appear in that argument so manipulating it as a
delimited argument is unsafe.


Modified: trunk/l3experimental/l3str/l3flag.dtx
===================================================================
--- trunk/l3experimental/l3str/l3flag.dtx	2017-02-13 23:07:49 UTC (rev 6916)
+++ trunk/l3experimental/l3str/l3flag.dtx	2017-02-13 23:17:06 UTC (rev 6917)
@@ -203,23 +203,22 @@
 % \end{macro}
 %
 % \begin{macro}{\flag_zero:n}
-% \begin{macro}[aux]{\@@_zero:ww}
+% \begin{macro}[aux]{\@@_zero:wn}
 %   Undefine control sequences, starting from the |0| flag, upwards,
 %   until reaching an undefined control sequence.  We don't use
-%   \cs{cs_undefine:N} because that would act globally.
+%   \cs{cs_undefine:c} because that would act globally.
 %    \begin{macrocode}
-\cs_new_protected:Npn \flag_zero:n #1
-  { \@@_zero:ww 0 ; #1 \q_stop }
-\cs_new_protected:Npn \@@_zero:ww #1 ; #2 \q_stop
+\cs_new_protected:Npn \flag_zero:n { \@@_zero:wn 0 ; }
+\cs_new_protected:Npn \@@_zero:wn #1 ; #2
   {
     \if_cs_exist:w flag~#2~#1 \cs_end:
+      \cs_set_eq:cN { flag~#2~#1 } \tex_undefined:D
+      \exp_after:wN \@@_zero:wn
+      \__int_value:w \__int_eval:w \c_one + #1
     \else:
-      \exp_after:wN \use_none_delimit_by_q_stop:w
+      \use_i:nnn
     \fi:
-    \cs_set_eq:cN { flag~#2~#1 } \tex_undefined:D
-    \exp_after:wN \@@_zero:ww
-    \__int_value:w \__int_eval:w \c_one + #1 ;
-    #2 \q_stop
+    ; {#2}
   }
 %    \end{macrocode}
 % \end{macro}
@@ -277,21 +276,21 @@
 % \end{macro}
 %
 % \begin{macro}[EXP]{\flag_use:n}
-% \begin{macro}[EXP, aux]{\@@_height_loop:ww, \@@_height_end:ww}
+% \begin{macro}[EXP, aux]{\@@_height_loop:wn, \@@_height_end:wn}
 %   Extract the value of the flag by going through all of the
 %   control sequences starting from |0|.
 %    \begin{macrocode}
-\cs_new:Npn \flag_use:n #1 { \@@_height_loop:ww 0; #1 \q_stop }
-\cs_new:Npn \@@_height_loop:ww #1 ; #2 \q_stop
+\cs_new:Npn \flag_use:n { \@@_height_loop:wn 0; }
+\cs_new:Npn \@@_height_loop:wn #1 ; #2
   {
     \if_cs_exist:w flag~#2~#1 \cs_end:
-      \exp_after:wN \@@_height_loop:ww \__int_value:w \__int_eval:w \c_one +
+      \exp_after:wN \@@_height_loop:wn \__int_value:w \__int_eval:w \c_one +
     \else:
-      \exp_after:wN \@@_height_end:ww
+      \exp_after:wN \@@_height_end:wn
     \fi:
-    #1 ; #2 \q_stop
+    #1 ; {#2}
   }
-\cs_new:Npn \@@_height_end:ww #1 ; #2 \q_stop { #1 }
+\cs_new:Npn \@@_height_end:wn #1 ; #2 {#1}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}



More information about the latex3-commits mailing list