[latex3-commits] [latex3/latex2e] develop: Apply one-step expansion to raw option list (#1298) (505ae27b)
github at latex-project.org
github at latex-project.org
Fri Mar 22 09:08:30 CET 2024
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/505ae27ba1e4856011f64b6388df75303d8e29d5
>---------------------------------------------------------------
commit 505ae27ba1e4856011f64b6388df75303d8e29d5
Author: Yukai Chou <muzimuzhi at gmail.com>
Date: Tue Mar 19 07:41:44 2024 +0800
Apply one-step expansion to raw option list (#1298)
>---------------------------------------------------------------
505ae27ba1e4856011f64b6388df75303d8e29d5
base/changes.txt | 6 ++++++
base/doc/ltnews39.tex | 21 ++++++++++++++++++++-
base/ltclass.dtx | 14 +++++++++++---
base/testfiles/github-1298.lvt | 18 ++++++++++++++++++
base/testfiles/github-1298.tlg | 7 +++++++
5 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 04913bdb..c6a4942c 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -7,6 +7,12 @@ not part of the distribution.
================================================================================
+2024-03-22 Yukai Chou <muzimuzhi at 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 at latex-project.org>
* ifthen.dtx guard against active <=> (gh/756)
diff --git a/base/doc/ltnews39.tex b/base/doc/ltnews39.tex
index 38fde4fb..8120b00e 100644
--- a/base/doc/ltnews39.tex
+++ b/base/doc/ltnews39.tex
@@ -538,7 +538,22 @@ revised \texttt{fntguide} as well to reflect the changes and macros
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}
@@ -660,6 +675,10 @@ didn't get this treatment. This oversight has now been corrected.
\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}
diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index c6c0495f..9feb9ece 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -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}
@@ -2243,9 +2243,17 @@
% \end{macrocode}
% \changes{v1.5d}{2022/10/10}{Use \cs{protected at edef}.}
% \begin{macrocode}
- \expandafter\protected at edef\csname opt@\@currname.\@currext\endcsname
+ \expandafter\protected at edef
+ \csname opt@\@currname.\@currext\endcsname
{\zap at space#2 \@empty}%
- \@namedef{@raw at 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 at opt@\@currname.\@currext\expandafter\endcsname
+ \expandafter{#2}%
\@nameuse{opt at handler@\@currname.\@currext}%
}%
}%
diff --git a/base/testfiles/github-1298.lvt b/base/testfiles/github-1298.lvt
new file mode 100644
index 00000000..07fbbd1e
--- /dev/null
+++ b/base/testfiles/github-1298.lvt
@@ -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
diff --git a/base/testfiles/github-1298.tlg b/base/testfiles/github-1298.tlg
new file mode 100644
index 00000000..cc213a7e
--- /dev/null
+++ b/base/testfiles/github-1298.tlg
@@ -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
More information about the latex3-commits
mailing list.