[latex3-commits] [git/LaTeX3-latex3-latex2e] utf-8-protected: avoid making the utf8 definitions in a group, and make them \protected (a2f3ea85)
David Carlisle
d.p.carlisle at gmail.com
Sat Feb 19 19:29:34 CET 2022
Repository : https://github.com/latex3/latex2e
On branch : utf-8-protected
Link : https://github.com/latex3/latex2e/commit/a2f3ea85aec034a6fdb0dba31f80d4b5336268f5
>---------------------------------------------------------------
commit a2f3ea85aec034a6fdb0dba31f80d4b5336268f5
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sat Feb 19 18:29:34 2022 +0000
avoid making the utf8 definitions in a group, and make them \protected
>---------------------------------------------------------------
a2f3ea85aec034a6fdb0dba31f80d4b5336268f5
base/utf8ienc.dtx | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/base/utf8ienc.dtx b/base/utf8ienc.dtx
index a0c96357..e579b9dd 100644
--- a/base/utf8ienc.dtx
+++ b/base/utf8ienc.dtx
@@ -216,7 +216,7 @@
%<+ts1> \ProvidesFile{ts1enc.dfu}
%<+x2> \ProvidesFile{x2enc.dfu}
%<+all> \ProvidesFile{utf8enc.dfu}
-%<-utf8-2018> [2021/12/13 v1.2o UTF-8 support]
+%<-utf8-2018> [2022/02/13 v1.3a UTF-8 support]
% \end{macrocode}
%
% \begin{macrocode}
@@ -542,15 +542,23 @@
% |\count@| and ending at |\@tempcnta|${} - 1$, each time executing
% the code in |\UTFviii at tmp|.
%
-% All this is done in a group so that temporary catcode changes
-% etc.~vanish after everything is set up.
+% Store current settings so can restore after the loops without using a group (gh/762).
+%
+% \begin{macrocode}
+\edef\reserved at a{%
+\catcode`\noexpand\~=\the\catcode`\~\relax
+\catcode`\noexpand\"=\the\catcode`\"\relax
+\count@=\the\count@\relax
+\@tempcnta=\the\@tempcnta\relax
+\let\noexpand\reserved at a\relax}
+% \end{macrocode}
%
% \begin{macrocode}
-\begingroup
\catcode`\~13
\catcode`\"12
% \end{macrocode}
%
+% \changes{v1.3a}{2022/02/19}{Use local protected definitions in the character definitions}%
% \begin{macrocode}
\def\UTFviii at loop{%
\uccode`\~\count@
@@ -566,7 +574,7 @@
% C0 controls are valid UTF-8 but defined to give the ``Character not defined error''
% They may be defined with |\DeclareUnicodeCharacter|.
% \begin{macrocode}
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at undefined@err{:\string~}}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at undefined@err{:\string~}}}
% 0 ^^@ null
\count@"1
\@tempcnta9
@@ -588,7 +596,7 @@
% \begin{macrocode}
\count@"80
\@tempcnta"C2
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at invalid@err\string~}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at invalid@err\string~}}
\UTFviii at loop
% \end{macrocode}
%
@@ -597,7 +605,7 @@
% \begin{macrocode}
\count@"C2
\@tempcnta"E0
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at two@octets\noexpand~}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at two@octets\noexpand~}}
\UTFviii at loop
% \end{macrocode}
%
@@ -605,7 +613,7 @@
% \begin{macrocode}
\count@"E0
\@tempcnta"F0
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at three@octets\noexpand~}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at three@octets\noexpand~}}
\UTFviii at loop
% \end{macrocode}
%
@@ -614,7 +622,7 @@
% \begin{macrocode}
\count@"F0
\@tempcnta"F5
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at four@octets\noexpand~}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at four@octets\noexpand~}}
\UTFviii at loop
% \end{macrocode}
%
@@ -623,12 +631,13 @@
% \begin{macrocode}
\count@"F5
\@tempcnta"100
- \def\UTFviii at tmp{\xdef~{\noexpand\UTFviii at invalid@err\string~}}
+ \def\UTFviii at tmp{\protected\edef~{\noexpand\UTFviii at invalid@err\string~}}
\UTFviii at loop
% \end{macrocode}
%
+% Restore values after the loops.
% \begin{macrocode}
-\endgroup
+\reserved at a
% \end{macrocode}
%
% \end{macro}
More information about the latex3-commits
mailing list.