[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: make commands etex protected for issue #208 (54cf1a9e)
David Carlisle
d.p.carlisle at gmail.com
Sun Nov 24 00:23:56 CET 2019
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/54cf1a9e6565708926460fdd3e1bfc7bae8e825b
>---------------------------------------------------------------
commit 54cf1a9e6565708926460fdd3e1bfc7bae8e825b
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sat Nov 23 23:23:56 2019 +0000
make commands etex protected for issue #208
>---------------------------------------------------------------
54cf1a9e6565708926460fdd3e1bfc7bae8e825b
required/graphics/changes.txt | 5 +++
required/graphics/color.dtx | 41 ++++++++++++++++------
required/graphics/testfiles/robust-color-gh208.lvt | 14 ++++++++
.../graphics/testfiles/robust-color-gh208.tlg | 5 +--
4 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/required/graphics/changes.txt b/required/graphics/changes.txt
index f4343bc2..17b0bac6 100644
--- a/required/graphics/changes.txt
+++ b/required/graphics/changes.txt
@@ -4,6 +4,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
=======================================================================
+2019-11-23 David Carlisle <David.Carlisle at latex-project.org>
+
+ * color.dtx: Made commands robust gh/208
+
+
#########################
# 2019-10-01 PL 2 Release
#########################
diff --git a/required/graphics/color.dtx b/required/graphics/color.dtx
index 8de7d013..c3cf7102 100644
--- a/required/graphics/color.dtx
+++ b/required/graphics/color.dtx
@@ -19,7 +19,7 @@
%<driver> \ProvidesFile{color.drv}
% \fi
% \ProvidesFile{color.dtx}
- [2016/07/10 v1.1e Standard LaTeX Color (DPC)]
+ [2019/11/23 v1.2a Standard LaTeX Color (DPC)]
%
% \iffalse
%<*driver>
@@ -462,10 +462,15 @@
% correctly.
% \changes{v0.3a}{1994/07/20}
% {Stop command being \cs{long}, and make robust.}
-% \changes{v0.3l}{1995/12/07}
-% {Add \cs{leavevmode}}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
+% check \cs{protected} is safe to use (for plain \TeX).
+% \begin{macrocode}
+\expandafter\@gobble\csname protected\endcsname
+% \end{macrocode}
+%
% \begin{macrocode}
-\def\textcolor#1#{\@textcolor{#1}}
+\protected\def\textcolor#1#{\@textcolor{#1}}
\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
% \end{macrocode}
% \end{macro}
@@ -481,8 +486,10 @@
% {end the group even if the colour command generates an error}
% \changes{v0.3c}{1994/09/19}
% {Use \cs{color} to parse arguments}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\pagecolor{%
+\protected\def\pagecolor{%
\begingroup
\let\ignorespaces\endgroup
\let\set at color\set at page@color
@@ -497,8 +504,10 @@
%
% \changes{v1.1a}{2014/04/23}
% {add \cs{nopagecolor} graphics/3873}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\nopagecolor{%
+\protected\def\nopagecolor{%
\@ifundefined{no at page@color}{%
\PackageInfo{color}{\string\nopagecolor\space is not supported}%
}{%
@@ -533,8 +542,10 @@
% {New internal implementation of colour commands}
% \changes{v0.3f}{1994/10/04}
% {Give info about redefinitions}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\definecolor#1#2#3{%
+\protected\def\definecolor#1#2#3{%
\@ifundefined{color@#2}%
{\c at lor@error{model `#2'}}%
{\@ifundefined{\string\color @#1}{}%
@@ -589,8 +600,10 @@
% |[named]| all the time, just give the package option |usenames|, which
% will redefine |\DefineNamedColor|, so that the colour name is declared
% as a user-colour as well as a name in the `named' model.
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\DefineNamedColor#1#2#3#4{%
+\protected\def\DefineNamedColor#1#2#3#4{%
\@ifundefined{define at color@#1}%
{\c at lor@error{model `#1'}}%
{\@ifundefined{color@#3}%
@@ -684,8 +697,10 @@
% \changes{v0.2d}{1994/05/13}
% {Stop changing \cs{reset at font}. Use the new \cs{normalfont}
% instead.}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\normalcolor{\let\current at color\default at color\set at color}
+\protected\def\normalcolor{\let\current at color\default at color\set at color}
% \end{macrocode}
% \end{macro}
%
@@ -751,8 +766,10 @@
% colour specifies the \emph{background} colour of the box.
% \changes{v0.3b}{1994/09/14}
% {New implementation}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macrocode}
-\def\colorbox#1#{\color at box{#1}}
+\protected\def\colorbox#1#{\color at box{#1}}
% \end{macrocode}
% \end{macro}
%
@@ -771,9 +788,11 @@
% colour model for both colours.
% \changes{v0.3b}{1994/09/14}
% {New implementation}
+% \changes{v1.2a}{2019/11/23}
+% {Add \cs{protected} gh/208}
% \begin{macro}{\fcolorbox}
% \begin{macrocode}
-\def\fcolorbox#1#{\color at fbox{#1}}
+\protected\def\fcolorbox#1#{\color at fbox{#1}}
% \end{macrocode}
%
% \begin{macrocode}
diff --git a/required/graphics/testfiles/robust-color-gh208.lvt b/required/graphics/testfiles/robust-color-gh208.lvt
new file mode 100644
index 00000000..47685e1c
--- /dev/null
+++ b/required/graphics/testfiles/robust-color-gh208.lvt
@@ -0,0 +1,14 @@
+\documentclass{article}
+\input{test2e}
+\usepackage{color}
+\begin{document}
+
+\START
+
+\typeout{\normalcolor}
+
+\typeout{\fcolorbox{red}{blue}{zzz}}
+
+\typeout{\textcolor{green}{abc}}
+
+\END
diff --git a/base/testfiles/github-0094.tlg b/required/graphics/testfiles/robust-color-gh208.tlg
similarity index 60%
copy from base/testfiles/github-0094.tlg
copy to required/graphics/testfiles/robust-color-gh208.tlg
index 982addfb..dfc2c869 100644
--- a/base/testfiles/github-0094.tlg
+++ b/required/graphics/testfiles/robust-color-gh208.tlg
@@ -1,4 +1,5 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
-[2
-] (github-0094.aux)
+\normalcolor
+\fcolorbox {red}{blue}{zzz}
+\textcolor {green}{abc}
More information about the latex3-commits
mailing list