[latex3-commits] [l3svn] 01/02: Simplify \char_set_catcode:nn
noreply at latex-project.org
noreply at latex-project.org
Wed Nov 11 09:42:18 CET 2015
This is an automated email from the git hooks/post-receive script.
joseph pushed a commit to branch master
in repository l3svn.
commit 145af781359cd1b18c65c50d3c88decd26214304
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Nov 11 08:22:16 2015 +0000
Simplify \char_set_catcode:nn
The idea of 'auto-updating' the list of special chars is
attractive but problematic: for plain and 2e outer tokens
cause issues but more widely we are at the wrong level to
tell if the change is really document-wide or a local
'trick'.
Upcoming is also a change to how \l_char_active_seq works.
---
l3kernel/l3token.dtx | 157 ++-----------------------------
l3kernel/testfiles/m3expl001.luatex.tlg | 3 -
l3kernel/testfiles/m3expl001.ptex.tlg | 3 -
l3kernel/testfiles/m3expl001.tlg | 3 -
l3kernel/testfiles/m3expl001.uptex.tlg | 3 -
l3kernel/testfiles/m3expl001.xetex.tlg | 3 -
l3kernel/testfiles/m3expl003.luatex.tlg | 3 -
l3kernel/testfiles/m3expl003.ptex.tlg | 3 -
l3kernel/testfiles/m3expl003.tlg | 3 -
l3kernel/testfiles/m3expl003.uptex.tlg | 3 -
l3kernel/testfiles/m3expl003.xetex.tlg | 3 -
l3kernel/testfiles/m3token005.lvt | 43 ---------
l3kernel/testfiles/m3token005.tlg | 10 --
13 files changed, 10 insertions(+), 230 deletions(-)
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 46f6e62..e6899d6 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -112,7 +112,7 @@
%
% \section{Character tokens}
%
-% \begin{function}[updated = 2015-08-09]
+% \begin{function}[updated = 2015-11-11]
% {
% \char_set_catcode_escape:N ,
% \char_set_catcode_group_begin:N ,
@@ -140,15 +140,10 @@
% \begin{verbatim}
% \char_set_catcode_other:N \%
% \end{verbatim}
-% The assignment is local. These commands update
-% \cs{l_char_special_seq} as appropriate by adding or removing the
-% \meta{character}, and in package mode they also update
-% \tn{dospecials} (plain \TeX{} and \LaTeXe{}) and \cs{@sanitize}
-% (\LaTeXe{} only). The \cs{char_set_catcode_active:N} command
-% also adds the active character to \cs{l_char_active_seq}.
+% The assignment is local.
% \end{function}
%
-% \begin{function}[updated = 2015-08-09]
+% \begin{function}[updated = 2015-11-11]
% {
% \char_set_catcode_escape:n ,
% \char_set_catcode_group_begin:n ,
@@ -174,14 +169,9 @@
% code as given by the \meta{integer expression}. This version can be
% used to set up characters which cannot otherwise be given
% (\emph{cf.}~the \texttt{N}-type variants). The assignment is local.
-% These commands update \cs{l_char_special_seq} as appropriate by
-% adding or removing the \meta{character}, and in package mode they
-% also update \tn{dospecials} (plain \TeX{} and \LaTeXe{}) and
-% \cs{@sanitize} (\LaTeXe{} only). The \cs{char_set_catcode_active:n}
-% command also adds the active character to \cs{l_char_active_seq}.
% \end{function}
%
-% \begin{function}[updated = 2015-08-09]{\char_set_catcode:nn}
+% \begin{function}[updated = 2015-11-11]{\char_set_catcode:nn}
% \begin{syntax}
% \cs{char_set_catcode:nn} \Arg{intexpr_1} \Arg{intexpr_2}
% \end{syntax}
@@ -192,12 +182,6 @@
% The setting applies within the current \TeX{} group. In general, the
% symbolic functions \cs{char_set_catcode_\meta{type}} should be preferred,
% but there are cases where these lower-level functions may be useful.
-% This command updates \cs{l_char_special_seq} as appropriate by
-% adding or removing the \meta{character}, and in package mode it
-% also updates \tn{dospecials} (plain \TeX{} and \LaTeXe{}) and
-% \cs{@sanitize} (\LaTeXe{} only).
-% If the category code is $13$ (active), the active character is
-% added to \cs{l_char_active_seq}.
% \end{function}
%
% \begin{function}[EXP]{\char_value_catcode:n}
@@ -350,17 +334,15 @@
% terminal.
% \end{function}
%
-% \begin{variable}[added = 2012-01-23, updated = 2015-08-09]{\l_char_active_seq}
+% \begin{variable}[added = 2012-01-23, updated = 2015-11-11]{\l_char_active_seq}
% Used to track which tokens may require special handling at the document
% level as they are (or have been at some point)
% of category \meta{active} (catcode~$13$). Each entry in
% the sequence consists of a single active character. Active tokens should be
% added to the sequence when they are defined for general document use.
-% This sequence is automatically updated by \cs{char_set_catcode:nn} and
-% more specific functions.
% \end{variable}
%
-% \begin{variable}[added = 2012-01-23, updated = 2015-08-09]{\l_char_special_seq}
+% \begin{variable}[added = 2012-01-23, updated = 2015-11-11]{\l_char_special_seq}
% Used to track which tokens will require special handling when working with
% verbatim-like material at the document level as they are not of categories
% \meta{letter} (catcode~$11$) or \meta{other} (catcode~$12$). Each entry in
@@ -368,8 +350,6 @@
% backslash or |\{| for an opening brace.^^A \}
% Escaped tokens should be added to the sequence when they are defined for
% general document use.
-% This sequence is automatically updated by \cs{char_set_catcode:nn} and
-% more specific functions.
% \end{variable}
%
% \section{Generic tokens}
@@ -992,137 +972,21 @@
% \begin{macro}{\char_set_catcode:nn}
% \begin{macro}{\char_value_catcode:n}
% \begin{macro}{\char_show_value_catcode:n}
-% \begin{macro}[aux]
-% {
-% \@@_set_catcode:Nn,
-% \@@_set_catcode:NnNNN,
-% \@@_set_catcode:NNN,
-% }
-% Category code changes. Besides setting the catcode using
-% \cs{tex_catcode:D}, this function keeps up to date the sequences
-% \cs{l_char_active_seq}, \cs{l_char_special_seq}, and in package
-% mode \tn{dospecials} (for plain \TeX{} and \LaTeXe{}) and
-% \tn{@sanitize} (\LaTeXe{} only) as well. The first list contains
-% active characters, and the other three contain a single-character
-% control sequence. These are constructed from the given character
-% code |#1| using the \tn{lowercase} primitive. In package mode
-% there are difficulties because |\+| and the active |^^L| are
-% \tn{outer} macros. This pushes us to only construct the
-% single-character control sequence and the active character with
-% character code |#1| if they are necessary for the update. As a
-% start, construct an \enquote{other} (catcode~$12$) with character
-% code |#1|. The second part of the \texttt{:Nn} auxiliary takes
-% care of \cs{l_char_active_seq}: if the new catcode is $13$
-% (active), then the active character is constructed through
-% \tn{lowercase} and added to the sequence unless it is already in
-% there. The first part is more intricate and distinguishes the
-% case where the original catcode is special (different from letter
-% or other, since for \eTeX{}'s \tn{numexpr}, $11/2=12/2=6$) or not.
-% If it the catcode was special, the single-character control
-% sequence may need to be removed from the token lists and sequence,
-% otherwise it may need to be added to the lists.
-%
-% The addition or removal is done by the \texttt{:NnNNN} auxiliary,
-% which performs the catcode assignment (note here that the arguments
-% of \cs{char_set_catcode:nn} are each evaluated exactly once), then
-% tests whether the new catcode is special or not. If that changed
-% compared to the previous catcode, then some work is needed: pass to
-% the \texttt{:NNN} auxiliary the single-character control sequence,
-% a function acting on token lists, and a function acting on
-% sequences. Defining this auxiliary is tricky: the odd
-% \texttt{f}-expansion expands the two \cs{tl_if_exist:NT} before the
-% definition is performed, and the macro parameter token |#| (we are
-% not yet doing a definition) stops the \texttt{f}-expansion.
-% In \LaTeXe{}, \cs{@sanitize} differs from \cs{dospecials} in that
-% it should not list begin-group and end-group character tokens.
-% For this, patch \cs{@@_set_catcode:Nn} by copying its code
-% using its \texttt{o}-expansion with arguments |#1| and |#2|
-% (braces are needed because each argument is literally two tokens,
-% a macro parameter character and a digit), and appending to it some
-% code that removes the single-character control sequence from
-% \cs{@sanitize} if the (new) catcode is $1$ or $2$.
+% Simple wrappers around the primitives.
% \begin{macrocode}
-\group_begin:
-\tex_catcode:D `@ = \c_eleven
-\tex_catcode:D \c_zero = \c_twelve
\cs_new_protected:Npn \char_set_catcode:nn #1#2
{
- \group_begin:
- \char_set_lccode:nn { 0 } {#1}
- \tex_lowercase:D
- { \group_end: \@@_set_catcode:Nn ^^@ } {#2}
+ \tex_catcode:D \__int_eval:w #1 \__int_eval_end:
+ = \__int_eval:w #2 \__int_eval_end:
}
-\tex_catcode:D \c_zero = \c_thirteen
-\cs_new_protected:Npn \@@_set_catcode:Nn #1#2
- {
- \int_compare:nNnTF { \tex_catcode:D `#1 / \c_two } = \c_six
- {
- \@@_set_catcode:NnNNN #1 {#2} \int_compare:nNnF
- \tl_put_right:Nn \seq_put_right:Nn
- }
- {
- \@@_set_catcode:NnNNN #1 {#2} \int_compare:nNnT
- \tl_remove_all:Nn \seq_remove_all:Nn
- }
- \int_compare:nNnT { \tex_catcode:D `#1 } = \c_thirteen
- {
- \group_begin:
- \char_set_lccode:nn { 0 } { `#1 }
- \tex_lowercase:D
- {
- \group_end:
- \seq_if_in:NnF \l_char_active_seq { ^^@ }
- { \seq_put_right:Nn \l_char_active_seq { ^^@ } }
- }
- }
- }
-\cs_new_protected:Npn \@@_set_catcode:NnNNN #1#2#3#4#5
- {
- \tex_catcode:D `#1 = \__int_eval:w #2 \__int_eval_end:
- #3 { \tex_catcode:D `#1 / \c_two } = \c_six
- {
- \group_begin: \exp_args:NNc \group_end:
- \@@_set_catcode:NNN {#1} #4 #5
- }
- }
-\exp_args:Nnf \use:n
- { \cs_new_protected:Npn \@@_set_catcode:NNN #1#2#3 }
- {
-%<*package>
- \tl_if_exist:NT \dospecials
- {
- \tl_if_exist:NT \@sanitize { #2 \@sanitize { \@makeother #1 } }
- #2 \dospecials { \do #1 }
- }
-%</package>
- #3 \l_char_special_seq {#1}
- }
-%<*package>
-\tl_if_exist:NT \@sanitize
- {
- \exp_args:Nno \use:n
- { \cs_gset_protected:Npn \@@_set_catcode:Nn #1#2 }
- {
- \@@_set_catcode:Nn {#1} {#2}
- \int_compare:nNnT { \tex_catcode:D `#1 / \c_two } = \c_one
- {
- \group_begin: \exp_args:NNNx \group_end:
- \tl_remove_all:Nn \@sanitize
- { \exp_not:N \@makeother \exp_not:c {#1} }
- }
- }
- }
-%</package>
\cs_new:Npn \char_value_catcode:n #1
{ \tex_the:D \tex_catcode:D \__int_eval:w #1\__int_eval_end: }
\cs_new_protected:Npn \char_show_value_catcode:n #1
{ \__msg_show_wrap:n { > ~ \char_value_catcode:n {#1} } }
-\group_end:
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}
% {
@@ -1299,8 +1163,7 @@
% \end{macro}
%
% \begin{variable}{\l_char_active_seq, \l_char_special_seq}
-% Two sequences for dealing with special characters. They must be defined
-% before \cs{char_set_catcode:nn} can be used. The first is characters
+% Two sequences for dealing with special characters. The first is characters
% which may be active, and contains the active characters themselves to
% allow easy redefinition. The second longer list is for \enquote{special}
% characters more generally, and these are escaped so that for example
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 695a87b..b9a996c 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1754,9 +1754,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 60f1210..ff20c88 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index df5e020..5b55093 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 60f1210..ff20c88 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index a6e1b56..b602641 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index dcc129c..57ba81c 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1754,9 +1754,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 3d4badd..b730062 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 2d48108..5678752 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 3d4badd..b730062 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index afb0b78..f43f113 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1752,9 +1752,6 @@ Defining \l_tmpb_clist on line ...
Defining \g_tmpa_clist on line ...
Defining \g_tmpb_clist on line ...
Defining \char_set_catcode:nn on line ...
-Defining \__char_set_catcode:Nn on line ...
-Defining \__char_set_catcode:NnNNN on line ...
-Defining \__char_set_catcode:NNN on line ...
Defining \char_value_catcode:n on line ...
Defining \char_show_value_catcode:n on line ...
Defining \char_set_catcode_escape:N on line ...
diff --git a/l3kernel/testfiles/m3token005.lvt b/l3kernel/testfiles/m3token005.lvt
index 978ca7f..b36b42d 100644
--- a/l3kernel/testfiles/m3token005.lvt
+++ b/l3kernel/testfiles/m3token005.lvt
@@ -57,47 +57,4 @@
\tl_rescan:nn { \char_set_catcode_active:N \D } { \cs_log:N D }
}
-\OMIT
-\cs_new_protected:Npn \test:
- {
- \cs_set_eq:NN \do \token_to_str:N
- \cs_set_eq:cN { @makeother } \token_to_str:N
- \TYPE
- {
- | \use:c { dospecials }
- | \use:c { @sanitize }
- | \seq_map_function:NN \l_char_special_seq \tl_to_str:n
- | \seq_map_function:NN \l_char_active_seq \tl_to_str:n
- |
- }
- }
-\TIMO
-
-\TEST { Catcode~changes~and~l_char_special_seq }
- {
- \test:
- \ExplSyntaxOff
- \test:
- \char_set_catcode_math_superscript:N \~
- \char_set_catcode_math_subscript:N \S
- \char_set_catcode_active:N \X
- \makeatletter
- \test:
- \ExplSyntaxOn
- \char_set_catcode_other:N \X
- \char_set_catcode_ignore:N \ %
- \char_set_catcode_active:N \%
- \char_set_catcode_letter:N \+
- \test:
- \tl_clear:N \l_tmpa_tl
- \seq_map_inline:Nn \l_char_special_seq
- {
- \tl_put_right:Nn \l_tmpa_tl { \char_set_catcode:nn { `#1 } }
- \tl_put_right:Nx \l_tmpa_tl { { \char_value_catcode:n { `#1 } } }
- \char_set_catcode_other:N #1
- }
- \test:
- \l_tmpa_tl
- \test:
- }
\END
diff --git a/l3kernel/testfiles/m3token005.tlg b/l3kernel/testfiles/m3token005.tlg
index f20cf63..2e2f88f 100644
--- a/l3kernel/testfiles/m3token005.tlg
+++ b/l3kernel/testfiles/m3token005.tlg
@@ -41,13 +41,3 @@ TEST 3: Char set active (make active rescan)
> C=undefined.
> D=\long macro:->Works.
============================================================
-============================================================
-TEST 4: Catcode changes and l_char_special_seq
-============================================================
-|\ \\\{\}\$\&\#\^\%\~|\ \\\$\&\#\^\%\~|\ \"\#\$\%\&\\\^\{\}\~|"$&^_~|
-|\ \\\{\}\$\&\#\^\%\~\_|\ \\\$\&\#\^\%\~\_|\ \"\#\$\%\&\\\^\{\}\~\_|"$&^_~|
-|\ \\\{\}\$\&\#\^\%\~\_\S\X|\ \\\$\&\#\^\%\~\_\S\X|\ \"\#\$\%\&\\\^\{\}\~\_\S\X|"$&^_~X|
-|\ \\\{\}\$\&\#\^\%\~\S|\ \\\$\&\#\^\%\~\S|\ \"\#\$\%\&\\\^\{\}\~\S|"$&^_~X%|
-|||\"|"$&^_~X%|
-|\ \#\$\%\&\\\^\{\}\~\S|\ \#\$\%\&\\\^\~\S|\"\ \#\$\%\&\\\^\{\}\~\S|"$&^_~X%|
-============================================================
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the latex3-commits
mailing list