[latex3-commits] [git/LaTeX3-latex3-latex3] master: Delay cctab creation to end-of-format (ed4565e74)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jul 16 12:13:16 CEST 2020


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

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

commit ed4565e74b9537b5d7cf6c86d63467b8754ab1dc
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Jul 8 14:20:54 2020 +0100

    Delay cctab creation to end-of-format


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

ed4565e74b9537b5d7cf6c86d63467b8754ab1dc
 l3kernel/l3cctab.dtx                     | 73 ++++++++++++++++++--------------
 l3kernel/testfiles/m3cctab002.luatex.tlg |  1 +
 2 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/l3kernel/l3cctab.dtx b/l3kernel/l3cctab.dtx
index ac9e4d3a4..f9c05d81e 100644
--- a/l3kernel/l3cctab.dtx
+++ b/l3kernel/l3cctab.dtx
@@ -746,44 +746,13 @@
 % \begin{variable}
 %   {
 %     \c_initex_cctab   ,
-%     \c_code_cctab     ,
-%     \c_document_cctab ,
 %     \c_other_cctab    ,
 %     \c_str_cctab
 %   }
 %   Creating category code tables means thinking starting from \IniTeX{}.
 %   For all-other and the standard \enquote{string} tables that's easy.
-%   For document-level codes, we need to save the data as-is: some
-%   work.
 %    \begin{macrocode}
 \cctab_new:N \c_initex_cctab
-\group_begin:
-  \cs_set:Npn \@@_tmp:n #1
-    { \tex_catcode:D #1 = \tex_the:D \tex_catcode:D #1 ~ }
-  \cs_set_nopar:Npx \@@_tmp:
-    {
-      \sys_if_engine_luatex:TF
-        { \int_step_function:nnN { 0 } { "10FFFF } }
-        { \int_step_function:nnN { 0 } { 255 } }
-          \@@_tmp:n
-    }
-  \cctab_const:Nn \c_code_cctab
-    {
-      \@@_tmp:
-      \char_set_catcode_other:n { `\@ }
-    }
-\group_end:
-\cctab_const:Nn \c_document_cctab
-  {
-    \cctab_select:N \c_code_cctab
-    \int_set:Nn \tex_endlinechar:D     { 13 }
-    \char_set_catcode_space:n          { 9 }
-    \char_set_catcode_space:n          { 32 }
-    \char_set_catcode_other:n          { 58 }
-    \char_set_catcode_other:n          { 64 }
-    \char_set_catcode_math_subscript:n { 95 }
-    \char_set_catcode_active:n         { 126 }
-  }
 \cctab_const:Nn \c_other_cctab
   {
     \cctab_select:N \c_initex_cctab
@@ -799,6 +768,48 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{variable}{\c_document_cctab, \c_other_cctab}
+%  To pick up document-level category codes, we need to delay set up to the
+%  end of the format, where that's possible. Also, as there are a \emph{lot}
+%  of category codes to set, we avoid using the official interface and store the
+%  document codes using internal code. Depending on whether we are in the hook
+%  or not, the catcodes may be code or document, so we explicitly set up both
+%  correctly.
+%    \begin{macrocode}
+\cs_if_exist:NTF \@expl at finalise@setup@@ % \@@_gset:n
+  { \tl_gsput_right:Nn \@expl at finalise@setup@@ }
+  { \use:n }
+  {
+    \@@_new:N \c_code_cctab
+    \group_begin:
+      \int_set:Nn \tex_endlinechar:D { 13 }
+      \char_set_catcode_ignore:n           { 9 }   % tab
+      \char_set_catcode_ignore:n           { 32 }  % space
+      \char_set_catcode_other:n            { 34 }  % double quote
+      \char_set_catcode_alignment:n        { 38 }  % ampersand
+      \char_set_catcode_letter:n           { 58 }  % colon
+      \char_set_catcode_other:n            { 64 }  % ampersand
+      \char_set_catcode_math_superscript:n { 94 }  % circumflex
+      \char_set_catcode_letter:n           { 95 }  % underscore
+      \char_set_catcode_other:n            { 124 } % pipe
+      \char_set_catcode_space:n            { 126 } % tilde
+      \@@_gset:n \c_code_cctab
+    \group_end:
+    \cctab_const:Nn \c_document_cctab
+      {
+        \cctab_select:N \c_code_cctab
+        \int_set:Nn \tex_endlinechar:D { 13 }
+        \char_set_catcode_space:n          { 9 }
+        \char_set_catcode_space:n          { 32 }
+        \char_set_catcode_other:n          { 58 }
+        \char_set_catcode_other:n          { 64 }
+        \char_set_catcode_math_subscript:n { 95 }
+        \char_set_catcode_active:n         { 126 }
+  }
+  }
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{Messages}
 %
 %    \begin{macrocode}
diff --git a/l3kernel/testfiles/m3cctab002.luatex.tlg b/l3kernel/testfiles/m3cctab002.luatex.tlg
index cc3d56c9f..e8e4873b0 100644
--- a/l3kernel/testfiles/m3cctab002.luatex.tlg
+++ b/l3kernel/testfiles/m3cctab002.luatex.tlg
@@ -44,5 +44,6 @@ TEST 4: Nested \cctab_begin:N
 ============================================================
 TEST 5: Nested groups
 ============================================================
+\g__cctab_internalii_cctab=\catcodetable...
 \g__cctab_internaliii_cctab=\catcodetable...
 ============================================================





More information about the latex3-commits mailing list.