[latex3-commits] [latex3/latex2e] gh-1265: fix for #1265 (draft version) (8a15036d2)
github at latex-project.org
github at latex-project.org
Sun Jun 30 15:43:15 CEST 2024
Repository : https://github.com/latex3/latex2e
On branch : gh-1265
Link : https://github.com/latex3/latex2e/commit/8a15036d2a107eaeca3cb366f634588024e33353
>---------------------------------------------------------------
commit 8a15036d2a107eaeca3cb366f634588024e33353
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Sun Jun 30 15:43:15 2024 +0200
fix for #1265 (draft version)
>---------------------------------------------------------------
8a15036d2a107eaeca3cb366f634588024e33353
base/doc/ltnews40.tex | 8 +++++-
required/amsmath/amsmath.dtx | 44 +++++++++++++++++++++++++++---
required/amsmath/testfiles/github-1265.lvt | 27 ++++++++++++++++++
required/amsmath/testfiles/github-1265.tlg | 2 ++
4 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/base/doc/ltnews40.tex b/base/doc/ltnews40.tex
index 10384e1a8..b3008e409 100644
--- a/base/doc/ltnews40.tex
+++ b/base/doc/ltnews40.tex
@@ -216,7 +216,13 @@ corrected and the warnings are suppressed.
%
\githubissue{1380}
-%\section{Changes to packages in the \pkg{amsmath} category}
+\section{Changes to packages in the \pkg{amsmath} category}
+
+\section{Extend support for \cs{dots}}
+
+\emph{write}
+%
+\githubissue{1265}
%\section{Changes to packages in the \pkg{graphics} category}
diff --git a/required/amsmath/amsmath.dtx b/required/amsmath/amsmath.dtx
index ec44957a8..28b06bc2b 100644
--- a/required/amsmath/amsmath.dtx
+++ b/required/amsmath/amsmath.dtx
@@ -85,7 +85,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesPackage{amsmath}[2024/05/23 v2.17q AMS math features]
+\ProvidesPackage{amsmath}[2024/06/29 v2.17r AMS math features]
% \end{macrocode}
%
% \section{Catcode defenses}
@@ -1087,6 +1087,14 @@ Foreign command \@backslashchar#1;\MessageBreak
\ifx9#2 \@xp\@xp\@xp\zap at to@space\fi}}}
\def\zap at to@space#1 {}
% \end{macrocode}
+%
+% \changes{v2.17r}{2024/06/29}{macro added to strip \cs{protected} (gh/1265)}
+% \begin{macrocode}
+{\uccode`9=`\p %
+ \uppercase{\gdef\stripprotected@#1#2#3\relax{%
+ \ifx9#2 \@xp\@xp\@xp\zap at to@space\fi}}}
+% \end{macrocode}
+%
% \begin{macrocode}
\def\keybin@{\gtest at true
\ifx\@let at token+\else\ifx\@let at token=\else
@@ -1139,15 +1147,34 @@ Foreign command \@backslashchar#1;\MessageBreak
\gdef\thedots@{\dotsb@}%
\else
% \end{macrocode}
-% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway argument error}
-% \begin{macrocode}
- \xdef\meaning@{\meaning\@let at token. .........}%
+% In case \cs{\@let at token} is a robust \LaTeXe{} command, i.e.,
+% expands to \cs{protect}
+% \verb*=\somename =, we save the \cs{meaning} of \verb*=\somename
+% = in \cs{meaning} (followed by some dots). Otherwise, we save the
+% \cs{meaning} of \cs{@let at token} in \cs{meaning@}. The dots are
+% needed in case the expansion of \cs{@let at token} expects arguments.
+% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway
+% argument error}
+% \changes{v2.17r}{2024/06/29}{Drop \cs{protect} if present (gh/1265)}
+% \begin{macrocode}
+ \begingroup
+ \def\protect{\protect}% % make it a quark
+ \xdef\meaning@{\@xp\stripprotect@\@let at token.........\stripprotect at . .........}%
+ \endgroup
% \end{macrocode}
% In previous versions \verb|\long| macros were not seen by the lokkahead.
% That was bad as this file uses \verb|\(re)newcommand| for \verb|\implies| etc.
% \begin{macrocode}
\xdef\meaning@@{\@xp\striplong@\meaning@\relax\meaning@}%
% \end{macrocode}
+% Until now \cs{protected} macros also stopped the lookahead, e.g.,
+% $\cong$ wasn't recognized correctly for that reason.
+%
+% \changes{v2.17r}{2024/06/29}{Handle \cs{protected} macros in
+% lookahead for dots (gh/1265)}
+% \begin{macrocode}
+ \xdef\meaning@@{\@xp\stripprotected@\meaning@@\relax\meaning@@}%
+% \end{macrocode}
% \begin{macrocode}
\@xp\math@\meaning@\math@
\ifgtest@ % if \mathxxx test
@@ -1208,6 +1235,15 @@ Foreign command \@backslashchar#1;\MessageBreak
\thedots@}
% \end{macrocode}
%
+% The helper to generate the meaning of \cs{\@let at token} or its
+% first-level expansion with \cs{protect} removed.
+% \changes{v2.17r}{2024/06/29}{Drop \cs{protect} if present (gh/1265)}
+% \begin{macrocode}
+\def\stripprotect@#1#2\stripprotect@{\ifx#1\protect
+ \meaning#2\else \meaning\@let at token \fi}
+
+% \end{macrocode}
+%
% The \qc{\=} character is necessary in the two \cs{let} assignments
% in \cs{boldsymboldots@}, because the symbol we are making
% bold might be an \qc{\=} sign.
diff --git a/required/amsmath/testfiles/github-1265.lvt b/required/amsmath/testfiles/github-1265.lvt
new file mode 100644
index 000000000..9df7fe139
--- /dev/null
+++ b/required/amsmath/testfiles/github-1265.lvt
@@ -0,0 +1,27 @@
+\documentclass{article}
+
+\input{test2e}
+
+% Any preamble code goes here
+\usepackage{amsmath}
+
+\showoutput
+
+\newbox\testbox
+
+\begin{document}
+
+% Demonstration of issue here
+
+\START
+
+\savebox\testbox{$\equiv\dots\equiv$}
+
+\box\testbox
+
+\savebox\testbox{$\cong\dots\cong$}
+
+\box\testbox
+
+\END
+
diff --git a/required/amsmath/testfiles/github-1265.tlg b/required/amsmath/testfiles/github-1265.tlg
new file mode 100644
index 000000000..1d0c69753
--- /dev/null
+++ b/required/amsmath/testfiles/github-1265.tlg
@@ -0,0 +1,2 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
More information about the latex3-commits
mailing list.