[latex3-commits] [git/LaTeX3-latex3-latex3] master: Enable \char_generate:nn for active chars (bf35c78)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Apr 19 17:12:58 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/bf35c782067bdad1bc8e651ab5e3966dbfb24325

>---------------------------------------------------------------

commit bf35c782067bdad1bc8e651ab5e3966dbfb24325
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Apr 19 16:12:58 2018 +0100

    Enable \char_generate:nn for active chars


>---------------------------------------------------------------

bf35c782067bdad1bc8e651ab5e3966dbfb24325
 l3kernel/l3candidates.dtx               |   14 ++---
 l3kernel/l3kernel-functions.dtx         |   12 -----
 l3kernel/l3token.dtx                    |   86 ++++++++++++++++---------------
 l3kernel/testfiles/m3char001.luatex.tlg |    3 +-
 l3kernel/testfiles/m3char001.tlg        |    3 +-
 l3kernel/testfiles/m3expl001.luatex.tlg |    1 -
 l3kernel/testfiles/m3expl001.ptex.tlg   |    1 -
 l3kernel/testfiles/m3expl001.tlg        |    1 -
 l3kernel/testfiles/m3expl001.uptex.tlg  |    1 -
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 +-
 l3kernel/testfiles/m3expl003.luatex.tlg |    1 -
 l3kernel/testfiles/m3expl003.ptex.tlg   |    1 -
 l3kernel/testfiles/m3expl003.tlg        |    1 -
 l3kernel/testfiles/m3expl003.uptex.tlg  |    1 -
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 +-
 15 files changed, 55 insertions(+), 75 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 3d10c40..565a34e 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -3853,9 +3853,9 @@
                 \tl_const:Nx #1
                   {
                     \exp_after:wN \exp_after:wN \exp_after:wN
-                      \exp_not:N \__kernel_char_generate:nn {##2} { 13 }
+                      \exp_not:N \char_generate:nn {##2} { 13 }
                     \exp_after:wN \exp_after:wN \exp_after:wN
-                      \exp_not:N \__kernel_char_generate:nn {##3} { 13 }
+                      \exp_not:N \char_generate:nn {##3} { 13 }
                   }
               }
             \tl_set:Nx \l_@@_internal_a_tl
@@ -3905,9 +3905,9 @@
             }
             {
               \exp_after:wN \exp_after:wN \exp_after:wN
-                \exp_not:N \__kernel_char_generate:nn {#5} { 13 }
+                \exp_not:N \char_generate:nn {#5} { 13 }
               \exp_after:wN \exp_after:wN \exp_after:wN
-                \exp_not:N \__kernel_char_generate:nn {#6} { 13 }
+                \exp_not:N \char_generate:nn {#6} { 13 }
             }
           \tl_const:cx
             {
@@ -3918,9 +3918,9 @@
             }
             {
               \exp_after:wN \exp_after:wN \exp_after:wN
-                \exp_not:N \__kernel_char_generate:nn {#2} { 13 }
+                \exp_not:N \char_generate:nn {#2} { 13 }
               \exp_after:wN \exp_after:wN \exp_after:wN
-                \exp_not:N \__kernel_char_generate:nn {#3} { 13 }
+                \exp_not:N \char_generate:nn {#3} { 13 }
             }
         }
       \@@_loop:nn
@@ -4600,7 +4600,7 @@
 % \subsection{Additions to \pkg{l3token}}
 %
 % \begin{variable}{\c_catcode_active_space_tl}
-%   While \cs{__kernel_char_generate:nn} can produce active characters in some
+%   While \cs{\char_generate:nn} can produce active characters in some
 %   engines it cannot in general.  It would be possible to simply change
 %   the catcode of space but then the code would need to avoid all
 %   spaces, making it quite unreadable.  Instead we use the primitive
diff --git a/l3kernel/l3kernel-functions.dtx b/l3kernel/l3kernel-functions.dtx
index adbd828..363ae89 100644
--- a/l3kernel/l3kernel-functions.dtx
+++ b/l3kernel/l3kernel-functions.dtx
@@ -53,18 +53,6 @@
 %
 % \section{Internal kernel functions}
 %
-% \begin{function}[EXP]{\__kernel_char_generate:nn}
-%   \begin{syntax}
-%      \cs{__kernel_char_generate:nn} \Arg{charcode} \Arg{catcode}
-%   \end{syntax}
-%   This function is identical in operation to the public
-%   \cs{char_generate:nn} but omits various sanity tests. In particular, this
-%   means it is used in certain places where engine variations need to be
-%   accounted for by the kernel.  The \meta{catcode} must give an explicit
-%   integer when expanded (and must not absorb a space for instance, nor
-%   be an integer variable).
-% \end{function}
-%
 % \begin{function}{\__kernel_chk_cs_exist:N, \__kernel_chk_cs_exist:c}
 %   \begin{syntax}
 %     \cs{__kernel_chk_cs_exist:N} \meta{cs}
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index a134479..5db4438 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -121,7 +121,8 @@
 %   be an active character.
 % \end{function}
 %
-% \begin{function}[EXP, added = 2015-09-09]{\char_generate:nn}
+% \begin{function}[EXP, added = 2015-09-09, updated = 2018-04-19]
+%   {\char_generate:nn}
 %   \begin{syntax}
 %      \cs{char_generate:nn} \Arg{charcode} \Arg{catcode}
 %   \end{syntax}
@@ -138,12 +139,14 @@
 %     \item $8$ (math subscript)
 %     \item $11$ (letter)
 %     \item $12$ (other)
+%     \item $13$ (active) (not \XeTeX{})
 %   \end{itemize}
 %   and other values raise an error.
 %
 %   The \meta{charcode} may be any one valid for the engine in use. Note
 %   however that for \XeTeX{} releases prior to 0.99992 only the 8-bit
-%   range ($0$ to $255$) is accepted due to engine limitations.
+%   range ($0$ to $255$) is accepted due to engine limitations. Note also
+%   that \XeTeX{} cannot currently generate active character tokens.
 % \end{function}
 %
 % \begin{variable}[added = 2011-09-05]{\c_catcode_other_space_tl}
@@ -1350,9 +1353,8 @@
 % \end{macro}
 %
 % \begin{macro}[EXP]{\char_generate:nn}
-% \begin{macro}[EXP]{\__kernel_char_generate:nn}
 % \begin{macro}[EXP]{\@@_generate_aux:nn}
-% \begin{macro}[EXP]{\@@_generate_aux:nnw}
+% \begin{macro}[EXP]{\@@_generate_aux:nnw, \@@_generate_auxii:nnw}
 % \begin{variable}{\l_@@_tmp_tl}
 % \begin{variable}{\c_@@_max_int}
 % \begin{macro}[EXP]{\@@_generate_invalid_catcode:}
@@ -1368,50 +1370,37 @@
       \int_value:w \int_eval:n {#1} \exp_after:wN ;
       \int_value:w \int_eval:n {#2} ;
   }
-\cs_new:Npn \__kernel_char_generate:nn #1#2
-  {
-    \exp:w \exp_after:wN
-      \@@_generate_aux:nnw \exp_after:wN
-        { \int_value:w \int_eval:n {#1} } {#2} \exp_end:
-  }
 %    \end{macrocode}
 %   Before doing any actual conversion, first some special case filtering.
-%   The \tn{Ucharcat} primitive cannot make active chars, so that is turned
-%   off here: if the primitive gets altered then the code is already in
-%   place for 8-bit engines and will kick in for \LuaTeX{} too. Spaces
-%   are also banned here as \LuaTeX{} emulation only makes normal (charcode
-%   $32$ spaces. However, |^^@| is filtered out separately as that can't be
+%   Spaces are out here as \LuaTeX{} emulation only makes normal (charcode
+%   $32$ spaces). However, |^^@| is filtered out separately as that can't be
 %   done with macro emulation either, so is flagged up separately. That
 %   done, hand off to the engine-dependent part.
 %    \begin{macrocode}
 \cs_new:Npn \@@_generate_aux:w #1 ; #2 ;
   {
-    \if_int_compare:w #2 = 13 \exp_stop_f:
-      \__kernel_msg_expandable_error:nn { kernel } { char-active }
+    \if_int_compare:w #2 = 10 \exp_stop_f:
+      \if_int_compare:w #1 =  0 \exp_stop_f:
+        \__kernel_msg_expandable_error:nn { kernel } { char-null-space }
+      \else:
+        \__kernel_msg_expandable_error:nn { kernel } { char-space }
+      \fi:
     \else:
-      \if_int_compare:w #2 = 10 \exp_stop_f:
-        \if_int_compare:w #1 =  0 \exp_stop_f:
-          \__kernel_msg_expandable_error:nn { kernel } { char-null-space }
-        \else:
-          \__kernel_msg_expandable_error:nn { kernel } { char-space }
-        \fi:
+      \if_int_odd:w 0
+          \if_int_compare:w #2 < 1  \exp_stop_f: 1 \fi:
+          \if_int_compare:w #2 = 5  \exp_stop_f: 1 \fi:
+          \if_int_compare:w #2 = 9  \exp_stop_f: 1 \fi:
+          \if_int_compare:w #2 > 13 \exp_stop_f: 1 \fi: \exp_stop_f:
+        \__kernel_msg_expandable_error:nn { kernel }
+          { char-invalid-catcode }
       \else:
         \if_int_odd:w 0
-            \if_int_compare:w #2 < 1  \exp_stop_f: 1 \fi:
-            \if_int_compare:w #2 = 5  \exp_stop_f: 1 \fi:
-            \if_int_compare:w #2 = 9  \exp_stop_f: 1 \fi:
-            \if_int_compare:w #2 > 13 \exp_stop_f: 1 \fi: \exp_stop_f:
+          \if_int_compare:w #1 < 0 \exp_stop_f: 1 \fi:
+          \if_int_compare:w #1 > \c_@@_max_int 1 \fi: \exp_stop_f:
           \__kernel_msg_expandable_error:nn { kernel }
-            { char-invalid-catcode }
+            { char-out-of-range }
         \else:
-          \if_int_odd:w 0
-            \if_int_compare:w #1 < 0 \exp_stop_f: 1 \fi:
-            \if_int_compare:w #1 > \c_@@_max_int 1 \fi: \exp_stop_f:
-            \__kernel_msg_expandable_error:nn { kernel }
-              { char-out-of-range }
-          \else:
-            \@@_generate_aux:nnw {#1} {#2}
-          \fi:
+          \@@_generate_aux:nnw {#1} {#2}
         \fi:
       \fi:
     \fi:
@@ -1425,6 +1414,9 @@
 %   out here using a primitive-based boolean expression for speed.
 %   The final level is the basic definition at the engine level: the arguments
 %   here are integers so there is no need to worry about them too much.
+%   At present \XeTeX{} cannot generate active characters so we filter that:
+%   at some future stage that may change: the slightly odd ordering of
+%   auxiliaries reflects that.
 %    \begin{macrocode}
 \group_begin:
 %<*package>
@@ -1433,16 +1425,16 @@
 %</package>
   \char_set_catcode_other:n { 0 }
   \if_int_odd:w 0
-      \cs_if_exist:NT \luatex_directlua:D { 1 }
-      \cs_if_exist:NT \utex_charcat:D     { 1 } \exp_stop_f:
+      \cs_if_exist:NT \lua_now_x:n    { 1 }
+      \cs_if_exist:NT \utex_charcat:D { 1 } \exp_stop_f:
     \int_const:Nn \c_@@_max_int { 1114111 }
-    \cs_if_exist:NTF \luatex_directlua:D
+    \cs_if_exist:NTF \lua_now_x:n
       {
         \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end:
           {
             #3
             \exp_after:wN \exp_end:
-            \luatex_directlua:D { l3kernel.charcat(#1, #2) }
+            \lua_now_x:n { l3kernel.charcat(#1, #2) }
           }
       }
       {
@@ -1450,7 +1442,18 @@
           {
             #3
             \exp_after:wN \exp_end:
-            \utex_charcat:D  #1 ~ #2 ~
+            \utex_charcat:D #1 \exp_stop_f: #2 \exp_stop_f:
+          }
+        \cs_new_eq:NN \@@_generate_auxii:nnw \@@_generate_aux:nnw
+        \cs_gset:Npn \@@_generate_aux:nnw #1#2#3 \exp_end:
+          {
+            #3
+            \if_int_compare:w #2 = 13 \exp_stop_f:
+              \__kernel_msg_expandable_error:nn { kernel } { char-active }
+            \else:
+              \@@_generate_auxii:nnw {#1} {#2}
+            \fi:
+            \exp_end:
           }
       }
   \else:
@@ -1561,7 +1564,6 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
 %
 % \begin{macro}{\c_catcode_other_space_tl}
 %   Create a space with category code $12$: an \enquote{other} space.
diff --git a/l3kernel/testfiles/m3char001.luatex.tlg b/l3kernel/testfiles/m3char001.luatex.tlg
index 8e492d9..32ce9ba 100644
--- a/l3kernel/testfiles/m3char001.luatex.tlg
+++ b/l3kernel/testfiles/m3char001.luatex.tlg
@@ -365,8 +365,7 @@ misspelled it (e.g., `\hobx'), type `I' and the correct
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ! Undefined control sequence.
-<argument> \LaTeX3 error: 
-                Cannot generate active chars.
+l. ...@
 l. ...  }
 The control sequence at the end of the top line
 of your error message was never \def'ed. If you have
diff --git a/l3kernel/testfiles/m3char001.tlg b/l3kernel/testfiles/m3char001.tlg
index c494ea9..523675f 100644
--- a/l3kernel/testfiles/m3char001.tlg
+++ b/l3kernel/testfiles/m3char001.tlg
@@ -365,8 +365,7 @@ misspelled it (e.g., `\hobx'), type `I' and the correct
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ! Undefined control sequence.
-<argument> \LaTeX3 error: 
-                           Cannot generate active chars.
+<recently read> @
 l. ...  }
 The control sequence at the end of the top line
 of your error message was never \def'ed. If you have
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 3010647..58ed2ae 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1956,7 +1956,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index bd5b281..fc04083 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 88b9b67..2006e41 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 288920d..c4e1a29 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index fdc20c2..fc9f4d9 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1954,11 +1954,11 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
 Defining \__char_generate_aux:nnw on line ...
+Defining \__char_generate_auxii:nnw on line ...
 Defining \c_catcode_other_space_tl on line ...
 Defining \c_group_begin_token on line ...
 Defining \c_group_end_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 3010647..58ed2ae 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1956,7 +1956,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index bd5b281..fc04083 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 88b9b67..2006e41 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 288920d..c4e1a29 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1954,7 +1954,6 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index fdc20c2..fc9f4d9 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1954,11 +1954,11 @@ Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
-Defining \__kernel_char_generate:nn on line ...
 Defining \__char_generate_aux:w on line ...
 Defining \l__char_tmp_tl on line ...
 Defining \c__char_max_int on line ...
 Defining \__char_generate_aux:nnw on line ...
+Defining \__char_generate_auxii:nnw on line ...
 Defining \c_catcode_other_space_tl on line ...
 Defining \c_group_begin_token on line ...
 Defining \c_group_end_token on line ...





More information about the latex3-commits mailing list