Skip to content

Commit

Permalink
Apply one-step expansion to raw option list (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
muzimuzhi authored and josephwright committed Mar 22, 2024
1 parent b16acc6 commit 505ae27
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
6 changes: 6 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ not part of the distribution.
================================================================================


2024-03-22 Yukai Chou <muzimuzhi@gmail.com>
* ltfilehook.dtx
Apply one-step expansion to raw option list, when a package
providing key-value options is loaded the second time. The same
expansion for first-time loading was requested in gh/580. (gh/1298)

2024-03-16 David Carlisle <David.Carlisle@latex-project.org>
* ifthen.dtx guard against active <=> (gh/756)

Expand Down
21 changes: 20 additions & 1 deletion base/doc/ltnews39.tex
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,22 @@ \subsection{Further updates to the guides}
added to the kernel over the last years of development. Note that the
file name hasn't changed and there is no \texttt{fntguide-historic}.

%\section{Bug fixes}
\section{Bug fixes}

\subsection{Fix inconsistent expansion on package option list}

\LaTeX{} applies one-step expansion to raw option list of packages and
classes so constructions like
\begin{verbatim}
\def\myoptions{opt1,opt2}
\usepackage[\myoptions]{foo}
\end{verbatim}
are supported. But when a package declares its options with the new
key/value approach~\cite{39:ltnews35} and was loaded a second time,
its raw option list was not expanded and an error might be raised.
This has now been corrected.
%
\githubissue{1298}

\section{Changes to packages in the \pkg{amsmath} category}

Expand Down Expand Up @@ -660,6 +675,10 @@ \subsection{Correct definition of \cs{k}}
\emph{\LaTeXe{} news 33}. June 2021.\\
\url{https://latex-project.org/news/latex2e-news/ltnews33.pdf}

\bibitem{39:ltnews35} \LaTeX{} Project Team.
\emph{\LaTeXe{} news 35}. June 2022.\\
\url{https://latex-project.org/news/latex2e-news/ltnews35.pdf}

\bibitem{39:ltnews37} \LaTeX{} Project Team.
\emph{\LaTeXe{} news 37}. June 2023.\\
\url{https://latex-project.org/news/latex2e-news/ltnews37.pdf}
Expand Down
14 changes: 11 additions & 3 deletions base/ltclass.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltclass.dtx}
[2024/02/14 v1.5i LaTeX Kernel (Class & Package Interface)]
[2024/03/22 v1.5j LaTeX Kernel (Class & Package Interface)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltclass.dtx}
Expand Down Expand Up @@ -2243,9 +2243,17 @@
% \end{macrocode}
% \changes{v1.5d}{2022/10/10}{Use \cs{protected@edef}.}
% \begin{macrocode}
\expandafter\protected@edef\csname opt@\@currname.\@currext\endcsname
\expandafter\protected@edef
\csname opt@\@currname.\@currext\endcsname
{\zap@space#2 \@empty}%
\@namedef{@raw@opt@\@currname.\@currext}{#2}%
% \end{macrocode}
% \changes{v1.5j}{2024/03/22}
% {Apply one-step expansion to raw option list,
% to be consistent with change for gh/580 (gh/1298).}
% \begin{macrocode}
\expandafter\def
\csname @raw@opt@\@currname.\@currext\expandafter\endcsname
\expandafter{#2}%
\@nameuse{opt@handler@\@currname.\@currext}%
}%
}%
Expand Down
2 changes: 1 addition & 1 deletion base/testfiles/github-0862.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

\RequirePackage[foo=\empty]{\jobname}\relax
\RequirePackage[foo=\empty]{\jobname}\relax

\END
18 changes: 18 additions & 0 deletions base/testfiles/github-1298.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% quite similar to github-0862.lvt
\documentclass{article}

\begin{filecontents}[force]{\jobname.sty}
\ProvidesPackage{\jobname}
\DeclareKeys{foo .code = \typeout{Foo was given: \detokenize{#1}}}
\ProcessKeyOptions\relax
\end{filecontents}

\input{test2e}

\START

\def\myoption{foo=\empty}
\RequirePackage[\myoption]{\jobname}\relax
\RequirePackage[\myoption]{\jobname}\relax

\END
7 changes: 7 additions & 0 deletions base/testfiles/github-1298.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
(github-1298.sty
Package: github-1298
Foo was given: \empty
)
Foo was given: \empty

0 comments on commit 505ae27

Please sign in to comment.