[latex3-commits] [git/LaTeX3-latex3-latex3] cctab: Make \cctab_gset:Nn start from IniTeX codes (7e98d40d0)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jul 7 12:17:13 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : cctab
Link       : https://github.com/latex3/latex3/commit/7e98d40d0be8f122c4b4ff19bcb16ef38ec06d6c

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

commit 7e98d40d0be8f122c4b4ff19bcb16ef38ec06d6c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jul 7 11:17:13 2020 +0100

    Make \cctab_gset:Nn start from IniTeX codes
    
    This means some adjustment to \cctab_const:Nn and
    to the description of catcode tables.
    
    This is the first step of this change. The 'early expl3'
    changes mean there will need to be adjustments to how
    document-level catcodes are set up. There are various
    possible approaches: probably they will need to be
    set explicitly, which will require reading load-unicode-data.
    As that change is more complex, it will be in a second step.
    We will also have to consider babel, UTF-8 and upTeX
    issues.


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

7e98d40d0be8f122c4b4ff19bcb16ef38ec06d6c
 l3kernel/l3cctab.dtx              | 64 +++++++++++++++++++++++----------------
 l3kernel/testfiles/m3cctab001.lvt |  1 -
 2 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/l3kernel/l3cctab.dtx b/l3kernel/l3cctab.dtx
index 5184b9fc2..ac9e4d3a4 100644
--- a/l3kernel/l3cctab.dtx
+++ b/l3kernel/l3cctab.dtx
@@ -66,28 +66,25 @@
 %   as used by \IniTeX{}.
 % \end{function}
 %
-% \begin{function}{\cctab_const:Nn,\cctab_const:cn}
+% \begin{function}[updated = 2020-07-07]{\cctab_const:Nn,\cctab_const:cn}
 %   \begin{syntax}
 %     \cs{cctab_const:Nn} \meta{category code table} \Arg{category code set up}
 %   \end{syntax}
 %   Creates a new \meta{category code table}, applies (in a group) the
-%   \meta{category code set up} on top of prevailing settings at the
-%   time the function is called, then saves them globally as a constant
+%   \meta{category code set up}, then saves them globally as a constant
 %   table.  The \meta{category code set up} can include a call to
-%   \cs{cctab_select:N}.
+%   \cs{cctab_select:N}. Without any \meta{set up}, the category codes
+%   will be those set by \IniTeX{}.
 % \end{function}
 %
-% \begin{function}{\cctab_gset:Nn,\cctab_gset:cn}
+% \begin{function}[updated = 2020-07-07]{\cctab_gset:Nn,\cctab_gset:cn}
 %   \begin{syntax}
 %     \cs{cctab_gset:Nn} \meta{category code table} \Arg{category code set up}
 %   \end{syntax}
-%   Applies (in a group) the \meta{category code set up} on top of
-%   prevailing category code settings, then saves them globally in the
-%   \meta{category code table}.  The \meta{category code set up} can
-%   include a call to \cs{cctab_select:N}.  Within a standard code block
-%   for instance, the starting point will be the code applied by
-%   \cs{c_code_cctab}.  The assignment of the table is global: the
-%   underlying primitive does not respect grouping.
+%   Applies (in a group) the \meta{category code set up}, then saves them
+%   globally in the \meta{category code table}.  The \meta{category code set up}
+%   can include a call to \cs{cctab_select:N}. Without any \meta{set up}, the
+%   category codes will be those set by \IniTeX{}.
 % \end{function}
 %
 % \section{Using category code tables}
@@ -138,15 +135,16 @@
 % \section{Constant category code tables}
 %
 % \begin{variable}{\c_code_cctab}
-%   Category code table for the code environment. This does not include
-%   setting the behaviour of the line-end character, which is only
-%   altered by \cs{ExplSyntaxOn}.
+%   Category code table for the \pkg{expl3} code environment; this does
+%   \emph{not} include \texttt{@}, which is retained as an \enquote{other}
+%   character.
 % \end{variable}
 %
 % \begin{variable}{\c_document_cctab}
-%   Category code table for a standard \LaTeX{} document. This does not
-%   include setting the behaviour of the line-end character, which is
-%   only altered by \cs{ExplSyntaxOff}.
+%   Category code table for a standard \LaTeX{} document, as set by the \LaTeX{}
+%   kernel. In particular, the upper-half of the $8$-bit range will be set to
+%   \enquote{active} with \pdfTeX{} \emph{only}. No \pkg{babel} shorthands
+%   will be activated.
 % \end{variable}
 %
 % \begin{variable}{\c_initex_cctab}
@@ -358,6 +356,7 @@
     \@@_chk_if_valid:NT #1
       {
         \group_begin:
+          \cctab_select:N \c_initex_cctab
           #2 \scan_stop:
           \@@_gset:n {#1}
         \group_end:
@@ -752,18 +751,31 @@
 %     \c_other_cctab    ,
 %     \c_str_cctab
 %   }  
-%   Creating category code tables is easy using the function above.
-%   The \texttt{other} and \texttt{string} ones are done by completely
-%   ignoring the existing codes as this makes life a lot less complex.
+%   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
-\cctab_const:Nn \c_code_cctab
-  {
-    \char_set_catcode_letter:n         { 64 }
-    \int_set:Nn \tex_endlinechar:D     { 32 }
-  }
+\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 }
diff --git a/l3kernel/testfiles/m3cctab001.lvt b/l3kernel/testfiles/m3cctab001.lvt
index c8044b2a4..561099d20 100644
--- a/l3kernel/testfiles/m3cctab001.lvt
+++ b/l3kernel/testfiles/m3cctab001.lvt
@@ -73,7 +73,6 @@
   {
     \errorstopmode
     \group_begin:
-      \char_set_catcode_letter:N \@
       \SAVECATCODES \TESTintarrayA
     \group_end:
     \cctab_begin:N \c_code_cctab





More information about the latex3-commits mailing list.