[latex3-commits] [git/LaTeX3-latex3-latex2e] robustness: fix issues with robustness: - keep \index and \glossary fragile for now - allow \DeclarMathSymbol to alter a definition if it was made by some \DeclareRobustCommand earlier - stop trying to make \small robust in ltnews.tex (as that will make a loop if it is already) (4a0e1dbf)
Frank Mittelbach
frank.mittelbach at latex-project.org
Tue Sep 10 00:44:30 CEST 2019
Repository : https://github.com/latex3/latex2e
On branch : robustness
Link : https://github.com/latex3/latex2e/commit/4a0e1dbfde80198f5ae0a79a5a574c8ac0c01e71
>---------------------------------------------------------------
commit 4a0e1dbfde80198f5ae0a79a5a574c8ac0c01e71
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Sep 10 00:44:30 2019 +0200
fix issues with robustness:
- keep \index and \glossary fragile for now
- allow \DeclarMathSymbol to alter a definition if it was made by some \DeclareRobustCommand earlier
- stop trying to make \small robust in ltnews.tex (as that will make a loop if it is already)
>---------------------------------------------------------------
4a0e1dbfde80198f5ae0a79a5a574c8ac0c01e71
base/doc/ltnews.tex | 5 +--
base/ltfssdcl.dtx | 19 +++++++++--
base/ltidxglo.dtx | 8 ++---
base/ltvers.dtx | 2 +-
base/testfiles/github-robust-0123.luatex.tlg | 8 ++---
base/testfiles/github-robust-0123.lvt | 4 +--
base/testfiles/github-robust-0123.tlg | 8 ++---
base/testfiles/github-robust-0123.xetex.tlg | 8 ++---
base/testfiles/github-robust-0123b.luatex.tlg | 20 ++++++++++++
base/testfiles/github-robust-0123b.lvt | 45 +++++++++++++++++++++++++++
base/testfiles/github-robust-0123b.tlg | 20 ++++++++++++
base/testfiles/tlb2048.tlg | 2 --
base/testfiles/vlatex03-2015.luatex.tlg | 2 --
base/testfiles/vlatex03-2015.tlg | 2 --
base/testfiles/vlatex03.luatex.tlg | 2 --
base/testfiles/vlatex03.tlg | 2 --
base/testfiles/vtl2e03-2015.luatex.tlg | 2 --
base/testfiles/vtl2e03-2015.tlg | 2 --
base/testfiles/vtl2e03.luatex.tlg | 2 --
base/testfiles/vtl2e03.tlg | 2 --
20 files changed, 124 insertions(+), 41 deletions(-)
diff --git a/base/doc/ltnews.tex b/base/doc/ltnews.tex
index a9f8e238..3b351448 100644
--- a/base/doc/ltnews.tex
+++ b/base/doc/ltnews.tex
@@ -74,8 +74,9 @@
\RequirePackage{url,csquotes}
-\expandafter
-\DeclareRobustCommand\expandafter*\expandafter\small\expandafter{\small}
+% \small already robust so better not ...
+%\expandafter
+%\DeclareRobustCommand\expandafter*\expandafter\small\expandafter{\small}
\RequirePackage{hyperref}
\hypersetup{colorlinks}
diff --git a/base/ltfssdcl.dtx b/base/ltfssdcl.dtx
index 59dfd37b..d1284a08 100644
--- a/base/ltfssdcl.dtx
+++ b/base/ltfssdcl.dtx
@@ -1212,6 +1212,8 @@
% \begin{macro}{\DeclareMathSymbol}
% \changes{v3.0r}{2016/02/18}
% {Check for mathchar not \cs{mathchar}}
+% \changes{v3.0s}{2019/09/09}{Allow definition if the math symbol was
+% a command already robust}
% \begin{macrocode}
\def\DeclareMathSymbol#1#2#3#4{%
\expandafter\in@\csname sym#3\expandafter\endcsname
@@ -1225,17 +1227,30 @@
\multiply\count@\sixt@@n
\advance\count\tw at -\count@
\if\relax\noexpand#1% is command?
+% \end{macrocode}
+% Store the command name with a space attached inside
+% \cs{reserved@@b} in case we look at a robust definition.
+% \begin{macrocode}
+ \edef\reserved at b{\expandafter\noexpand
+ \csname\expandafter\@gobble\string#1\space\endcsname}%
+% \end{macrocode}
+% Test both \verb=#1= and \verb*=#1 = for containing \texttt{mathchar}.
+% \begin{macrocode}
\edef\reserved at a
{\noexpand\in@{\expandafter\@gobble\string\mathchar}%
- {\meaning#1}}%
+ {\meaning#1\expandafter\meaning\reserved at b}}%
\reserved at a
+% \end{macrocode}
+% Drop \verb*=#1 = in case it was defined before.
+% \begin{macrocode}
+ \global\expandafter\let\reserved at b\@undefined
\ifin@
\expandafter\set at mathsymbol
\csname sym#3\endcsname#1#2%
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\@font at info{Redeclaring math symbol \string#1}%
\else
- \expandafter\ifx
+ \expandafter\ifx
\csname\expandafter\@gobble\string#1\endcsname
\relax
\expandafter\set at mathsymbol
diff --git a/base/ltidxglo.dtx b/base/ltidxglo.dtx
index 60e39f09..19349c17 100644
--- a/base/ltidxglo.dtx
+++ b/base/ltidxglo.dtx
@@ -126,7 +126,7 @@
\def\makeindex{%
\newwrite\@indexfile
\immediate\openout\@indexfile=\jobname.idx
- \DeclareRobustCommand\index{\@bsphack\begingroup
+ \def\index{\@bsphack\begingroup
\@sanitize
\@wrindex}\typeout
{Writing index file \jobname.idx}%
@@ -157,7 +157,7 @@
%
% \begin{macro}{\index}
% \begin{macrocode}
-\DeclareRobustCommand\index{\@bsphack\begingroup \@sanitize\@index}
+\def\index{\@bsphack\begingroup \@sanitize\@index}
% \end{macrocode}
% \end{macro}
%
@@ -174,7 +174,7 @@
\def\makeglossary{%
\newwrite\@glossaryfile
\immediate\openout\@glossaryfile=\jobname.glo
- \DeclareRobustCommand\glossary{\@bsphack\begingroup
+ \def\glossary{\@bsphack\begingroup
\@sanitize
\@wrglossary}\typeout
{Writing glossary file \jobname.glo }%
@@ -205,7 +205,7 @@
%
% \begin{macro}{\glossary}
% \begin{macrocode}
-\DeclareRobustCommand\glossary{\@bsphack\begingroup\@sanitize\@index}
+\def\glossary{\@bsphack\begingroup\@sanitize\@index}
% \end{macrocode}
% \end{macro}
%
diff --git a/base/ltvers.dtx b/base/ltvers.dtx
index f72eecb1..af872ed9 100644
--- a/base/ltvers.dtx
+++ b/base/ltvers.dtx
@@ -125,7 +125,7 @@
% intended to help help us internally when we locally install a
% format out of some development branch.
% \begin{macrocode}
-\edef\development at branch@name{development \the\year-\the\month-\the\day}
+\edef\development at branch@name{robustness \the\year-\the\month-\the\day}
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/base/testfiles/github-robust-0123.luatex.tlg b/base/testfiles/github-robust-0123.luatex.tlg
index cde04c9e..7a872c1d 100644
--- a/base/testfiles/github-robust-0123.luatex.tlg
+++ b/base/testfiles/github-robust-0123.luatex.tlg
@@ -214,6 +214,10 @@ l. ......dafter\show\csname Downarrow\space\endcsname
---------------------------------------
\wlog -> \immediate \write \m at ne
---------------------------------------
+\index{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
+\glossary{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
====================================
Robust ...
====================================
@@ -905,8 +909,6 @@ and I'll forget about whatever was undefined.
---------------------------------------
\global -> \global
---------------------------------------
-\glossary{foo} -> \glossary {foo}
----------------------------------------
\goodbreak -> \goodbreak
---------------------------------------
\grave -> \grave
@@ -979,8 +981,6 @@ and I'll forget about whatever was undefined.
---------------------------------------
\indent -> \indent
---------------------------------------
-\index{foo} -> \index {foo}
----------------------------------------
\infty -> \infty
---------------------------------------
\inf -> \inf
diff --git a/base/testfiles/github-robust-0123.lvt b/base/testfiles/github-robust-0123.lvt
index f0421f65..f8c69450 100644
--- a/base/testfiles/github-robust-0123.lvt
+++ b/base/testfiles/github-robust-0123.lvt
@@ -301,6 +301,8 @@
\test{\verbvisiblespace}
\test{\vglue}
\test{\wlog}
+\test{\index{foo}} % need to render argument harmless before tokenizing
+\test{\glossary{foo}} % need to render argument harmless before tokenizing
%%\test{\multicolumn{1}{c}{foo}} -- breaks badly
@@ -649,7 +651,6 @@
\test{\gg}
\test{\globaldefs}
\test{\global}
-\test{\glossary{foo}}
\test{\goodbreak}
\test{\grave}
\test{\halign}
@@ -686,7 +687,6 @@
\test{\imath}
\test{\immediate}
\test{\indent}
-\test{\index{foo}}
\test{\infty}
\test{\inf}
\test{\inputencodingname}
diff --git a/base/testfiles/github-robust-0123.tlg b/base/testfiles/github-robust-0123.tlg
index 2fa37389..659452e1 100644
--- a/base/testfiles/github-robust-0123.tlg
+++ b/base/testfiles/github-robust-0123.tlg
@@ -214,6 +214,10 @@ l. ......fter\show\csname Downarrow\space\endcsname
---------------------------------------
\wlog -> \immediate \write \m at ne
---------------------------------------
+\index{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
+\glossary{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
====================================
Robust ...
====================================
@@ -897,8 +901,6 @@ l. ......fter\show\csname Downarrow\space\endcsname
---------------------------------------
\global -> \global
---------------------------------------
-\glossary{foo} -> \glossary {foo}
----------------------------------------
\goodbreak -> \goodbreak
---------------------------------------
\grave -> \grave
@@ -971,8 +973,6 @@ l. ......fter\show\csname Downarrow\space\endcsname
---------------------------------------
\indent -> \indent
---------------------------------------
-\index{foo} -> \index {foo}
----------------------------------------
\infty -> \infty
---------------------------------------
\inf -> \inf
diff --git a/base/testfiles/github-robust-0123.xetex.tlg b/base/testfiles/github-robust-0123.xetex.tlg
index 407965db..06d714fd 100644
--- a/base/testfiles/github-robust-0123.xetex.tlg
+++ b/base/testfiles/github-robust-0123.xetex.tlg
@@ -214,6 +214,10 @@ l. ......fter\show\csname Downarrow\space\endcsname
---------------------------------------
\wlog -> \immediate \write \m at ne
---------------------------------------
+\index{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
+\glossary{foo} -> \relax \begingroup \catcode `\ 12\relax \catcode `\\12\relax \catcode `\$12\relax \catcode `\&12\relax \catcode `\#12\relax \catcode `\^12\relax \catcode `\_12\relax \catcode `\%12\relax \catcode `\~12\relax \endgroup \relax
+---------------------------------------
====================================
Robust ...
====================================
@@ -905,8 +909,6 @@ and I'll forget about whatever was undefined.
---------------------------------------
\global -> \global
---------------------------------------
-\glossary{foo} -> \glossary {foo}
----------------------------------------
\goodbreak -> \goodbreak
---------------------------------------
\grave -> \grave
@@ -979,8 +981,6 @@ and I'll forget about whatever was undefined.
---------------------------------------
\indent -> \indent
---------------------------------------
-\index{foo} -> \index {foo}
----------------------------------------
\infty -> \infty
---------------------------------------
\inf -> \inf
diff --git a/base/testfiles/github-robust-0123b.luatex.tlg b/base/testfiles/github-robust-0123b.luatex.tlg
new file mode 100644
index 00000000..71f3763d
--- /dev/null
+++ b/base/testfiles/github-robust-0123b.luatex.tlg
@@ -0,0 +1,20 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+\Downarrow -> \Downarrow
+---------------------------------------
+macro:->\protect \Downarrow + macro:->\delimiter "322B37F
+LaTeX Font Info: Redeclaring math delimiter \Downarrow on input line ...
+macro:->\protect \Downarrow + macro:->\delimiter "322B3AA
+---------------------------------------
+\hbar -> \hbar
+---------------------------------------
+macro:->\protect \hbar + \long macro:->{\mathchar '26\mkern -9muh}
+LaTeX Font Info: Redeclaring math symbol \hbar on input line ....
+\mathchar"021B + \relax
+---------------------------------------
+\clubsuit -> \clubsuit
+---------------------------------------
+\mathchar"027C + \relax
+LaTeX Font Info: Redeclaring math symbol \clubsuit on input line ....
+\mathchar"0277 + \relax
+---------------------------------------
diff --git a/base/testfiles/github-robust-0123b.lvt b/base/testfiles/github-robust-0123b.lvt
new file mode 100644
index 00000000..7e650763
--- /dev/null
+++ b/base/testfiles/github-robust-0123b.lvt
@@ -0,0 +1,45 @@
+\documentclass{article}
+
+\input{test2e}
+
+\def\test#1{\typeout{\string#1 -> #1}
+\typeout{---------------------------------------}}
+
+\START
+
+
+\test{\Downarrow}
+\typeout{\meaning\Downarrow \space + \expandafter\meaning\csname Downarrow\space\endcsname}
+
+% this should say redefinition ...
+\DeclareMathDelimiter{\Downarrow}
+ {\mathrel}{symbols}{"2B}{largesymbols}{"AA}
+
+% proof that this was changed (should show AA in the delimiter number)
+\typeout{\meaning\Downarrow \space + \expandafter\meaning\csname Downarrow\space\endcsname}
+
+\typeout{---------------------------------------}
+
+
+
+\test{\hbar}
+\typeout{\meaning\hbar \space + \expandafter\meaning\csname hbar\space\endcsname}
+
+\DeclareMathSymbol{\hbar}{\mathord}{symbols}{27}
+
+\typeout{\meaning\hbar \space + \expandafter\meaning\csname hbar\space\endcsname}
+
+\typeout{---------------------------------------}
+
+
+\test{\clubsuit}
+\typeout{\meaning\clubsuit \space + \expandafter\meaning\csname clubsuit\space\endcsname}
+
+\DeclareMathSymbol{\clubsuit}{\mathord}{symbols}{"77}
+
+\typeout{\meaning\clubsuit \space + \expandafter\meaning\csname clubsuit\space\endcsname}
+
+\typeout{---------------------------------------}
+
+
+\END
diff --git a/base/testfiles/github-robust-0123b.tlg b/base/testfiles/github-robust-0123b.tlg
new file mode 100644
index 00000000..6dbaf9a6
--- /dev/null
+++ b/base/testfiles/github-robust-0123b.tlg
@@ -0,0 +1,20 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+\Downarrow -> \Downarrow
+---------------------------------------
+macro:->\protect \Downarrow + macro:->\delimiter "322B37F
+LaTeX Font Info: Redeclaring math delimiter \Downarrow on input line ...
+macro:->\protect \Downarrow + macro:->\delimiter "322B3AA
+---------------------------------------
+\hbar -> \hbar
+---------------------------------------
+macro:->\protect \hbar + \long macro:->{\mathchar '26\mkern -9muh}
+LaTeX Font Info: Redeclaring math symbol \hbar on input line ....
+\mathchar"21B + \relax
+---------------------------------------
+\clubsuit -> \clubsuit
+---------------------------------------
+\mathchar"27C + \relax
+LaTeX Font Info: Redeclaring math symbol \clubsuit on input line ....
+\mathchar"277 + \relax
+---------------------------------------
diff --git a/base/testfiles/tlb2048.tlg b/base/testfiles/tlb2048.tlg
index a27aa95b..11da96ba 100644
--- a/base/testfiles/tlb2048.tlg
+++ b/base/testfiles/tlb2048.tlg
@@ -2,8 +2,6 @@ This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
Should display only two `Writing foo file' lines
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file tlb2048.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file tlb2048.glo
diff --git a/base/testfiles/vlatex03-2015.luatex.tlg b/base/testfiles/vlatex03-2015.luatex.tlg
index eeb1af67..7fa1c7d6 100644
--- a/base/testfiles/vlatex03-2015.luatex.tlg
+++ b/base/testfiles/vlatex03-2015.luatex.tlg
@@ -15,10 +15,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
LaTeX Font Info: Trying to load font information for U+lasy on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vlatex03-2015.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vlatex03-2015.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vlatex03-2015.tlg b/base/testfiles/vlatex03-2015.tlg
index 0168ca6e..0f9361cb 100644
--- a/base/testfiles/vlatex03-2015.tlg
+++ b/base/testfiles/vlatex03-2015.tlg
@@ -15,10 +15,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
LaTeX Font Info: Trying to load font information for U+lasy on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vlatex03-2015.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vlatex03-2015.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vlatex03.luatex.tlg b/base/testfiles/vlatex03.luatex.tlg
index 74da7e11..28e8db42 100644
--- a/base/testfiles/vlatex03.luatex.tlg
+++ b/base/testfiles/vlatex03.luatex.tlg
@@ -15,10 +15,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
LaTeX Font Info: Trying to load font information for U+lasy on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vlatex03.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vlatex03.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vlatex03.tlg b/base/testfiles/vlatex03.tlg
index c67597cf..140e8eb2 100644
--- a/base/testfiles/vlatex03.tlg
+++ b/base/testfiles/vlatex03.tlg
@@ -15,10 +15,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
LaTeX Font Info: Trying to load font information for U+lasy on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vlatex03.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vlatex03.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vtl2e03-2015.luatex.tlg b/base/testfiles/vtl2e03-2015.luatex.tlg
index 7483fe31..a35ee2d8 100644
--- a/base/testfiles/vtl2e03-2015.luatex.tlg
+++ b/base/testfiles/vtl2e03-2015.luatex.tlg
@@ -14,10 +14,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vtl2e03-2015.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vtl2e03-2015.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vtl2e03-2015.tlg b/base/testfiles/vtl2e03-2015.tlg
index 2f981d2e..14c47bfe 100644
--- a/base/testfiles/vtl2e03-2015.tlg
+++ b/base/testfiles/vtl2e03-2015.tlg
@@ -14,10 +14,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vtl2e03-2015.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vtl2e03-2015.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vtl2e03.luatex.tlg b/base/testfiles/vtl2e03.luatex.tlg
index 66eda720..22aa6481 100644
--- a/base/testfiles/vtl2e03.luatex.tlg
+++ b/base/testfiles/vtl2e03.luatex.tlg
@@ -14,10 +14,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vtl2e03.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vtl2e03.glo
*** Bug 162 ***
*** Bug 163 ***
diff --git a/base/testfiles/vtl2e03.tlg b/base/testfiles/vtl2e03.tlg
index 581a15e5..dd9d770b 100644
--- a/base/testfiles/vtl2e03.tlg
+++ b/base/testfiles/vtl2e03.tlg
@@ -14,10 +14,8 @@ LaTeX Font Info: External font `cmex10' loaded for size
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line ....
\@indexfile=\write...
-LaTeX Info: Redefining \index on input line ....
Writing index file vtl2e03.idx
\@glossaryfile=\write...
-LaTeX Info: Redefining \glossary on input line ....
Writing glossary file vtl2e03.glo
*** Bug 162 ***
*** Bug 163 ***
More information about the latex3-commits
mailing list