[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh408: Reset \@currpkg at reqd after loading a package file (fixes #408) (d943397c)

PhelypeOleinik phelype.oleinik at latex-project.org
Sun Oct 11 18:57:26 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh408
Link       : https://github.com/latex3/latex2e/commit/d943397cbbafefa0666cb8c976a43b7effc8be2e

>---------------------------------------------------------------

commit d943397cbbafefa0666cb8c976a43b7effc8be2e
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sun Oct 11 13:57:26 2020 -0300

    Reset \@currpkg at reqd after loading a package file (fixes #408)


>---------------------------------------------------------------

d943397cbbafefa0666cb8c976a43b7effc8be2e
 base/changes.txt               |  5 ++++
 base/ltclass.dtx               | 19 ++++++++++++---
 base/testfiles/github-0408.lvt | 54 ++++++++++++++++++++++++++++++++++++++++++
 base/testfiles/github-0408.tlg | 33 ++++++++++++++++++++++++++
 4 files changed, 108 insertions(+), 3 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 36a22af1..5cf25330 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -14,6 +14,11 @@ All changes above are only part of the development branch for the next release.
 # 2020-10-01 PL 1 Release
 #########################
 
+2020-10-11  Phelype Oleinik  <phelype.oleinik at latex-project.org>
+
+	* ltclass.dtx:
+	Reset \@currpkg at reqd after loading a package file (gh/408).
+
 2020-10-08  Phelype Oleinik  <phelype.oleinik at latex-project.org>
 
 	* ltclass.dtx:
diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index e771044e..e30584dd 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltclass.dtx}
-             [2020/10/08 v1.3s LaTeX Kernel (Class & Package Interface)]
+             [2020/10/11 v1.3t LaTeX Kernel (Class & Package Interface)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltclass.dtx}
@@ -943,8 +943,9 @@
 \def\@pr at videpackage[#1]{%
   \expandafter\protected at xdef                %     <-- protected...
      \csname ver@\@currname.\@currext\endcsname{#1}% Loaded package
-  \expandafter\protected at xdef                %     <-- protected...
-     \csname ver@\@currpkg at reqd\endcsname{#1}% Requested package
+  \expandafter\let
+    \csname ver@\@currpkg at reqd\expandafter\endcsname % Requested package
+    \csname ver@\@currname.\@currext\endcsname
   \ifx\@currext\@clsextension
     \typeout{Document Class: \@gtempa\space#1}%
   \else
@@ -1801,7 +1802,13 @@
 %    \cs{@currext} are used we lose track of the substitution, so
 %    \cs{CurrentFile} and \cs{CurrentFileUsed} will be (incorrectly)
 %    the same.
+%
+%    \changes{v1.3t}{2020-10-11}{Restore \cs{@currpkg at reqd} after
+%      finished loading a package file (gh/408).}
 %    \begin{macrocode}
+          \expandafter\@swaptwoargs\expandafter
+            {\expandafter{\@currpkg at reqd}}%
+            {% <
           \edef\@currpkg at reqd{\@currname.\@currext}%
           \ifx\CurrentFile\CurrentFileUsed
           \else
@@ -1810,6 +1817,8 @@
             \edef\@currext{\string at makeletter\filename at ext}%
           \fi
           \load at onefile@withoptions{#2}%
+          \def\@currpkg at reqd%{\@currpkg at reqd}
+            }% >
 %    \end{macrocode}
 %    Now just clean up and exit.
 %    \begin{macrocode}
@@ -1838,6 +1847,10 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\let\@currpkg at reqd\@empty
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \@onlypreamble\@onefilewithoptions
 %    \end{macrocode}
 %
diff --git a/base/testfiles/github-0408.lvt b/base/testfiles/github-0408.lvt
new file mode 100644
index 00000000..a0495942
--- /dev/null
+++ b/base/testfiles/github-0408.lvt
@@ -0,0 +1,54 @@
+\RequirePackage{expl3} % force backend loading
+\ExplSyntaxOn
+\makeatletter
+\str_gremove_once:Nn \@filelist { ,l3backend-dvips.def }
+\str_gremove_once:Nn \@filelist { ,l3backend-xetex.def }
+\ExplSyntaxOff
+
+\begin{filecontents}[overwrite]{package-test-first.sty}
+\ProvidesPackage{package-test-first}[2020/10/11 11111]
+\newcommand\something{}
+\end{filecontents}
+
+\begin{filecontents}[overwrite]{package-test-before.sty}
+\ProvidesPackage{package-test-before}[2020/10/11 aaaaa]
+\RequirePackage{package-test-nest}
+\end{filecontents}
+
+\begin{filecontents}[overwrite]{package-test-after.sty}
+\ProvidesPackage{package-test-after}[2020/10/11 zzzzz]
+\end{filecontents}
+
+\begin{filecontents}[overwrite]{package-test-nest.sty}
+\ProvidesPackage{package-test-nest}[2020/10/11 {{{}}}]
+\end{filecontents}
+
+\begin{filecontents}[overwrite]{package-test.sty}
+\RequirePackage{package-test-first}
+\typeout{[1]> \@currpkg at reqd}
+\RequirePackage{package-test-before}
+\typeout{[2]> \@currpkg at reqd}
+\typeout{\csname ver at package-test-before.sty\endcsname}
+\ProvidesPackage{package-test}[2020/10/11 main package]
+\typeout{[3]> \@currpkg at reqd}
+\typeout{\csname ver at package-test-before.sty\endcsname}
+\RequirePackage{package-test-after}
+\typeout{[4]> \@currpkg at reqd}
+\end{filecontents}
+
+\documentclass{article}
+
+\input{test2e}
+
+\START
+\AddToHook{package/before/package-test}%
+  {\RequirePackage{package-test-first}}
+\usepackage{package-test}
+
+\listfiles
+
+\OMIT
+\begin{document}
+\TIMO
+
+\end{document}
diff --git a/base/testfiles/github-0408.tlg b/base/testfiles/github-0408.tlg
new file mode 100644
index 00000000..64d2a458
--- /dev/null
+++ b/base/testfiles/github-0408.tlg
@@ -0,0 +1,33 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+(package-test-first.sty
+Package: package-test-first ....-..-.. 11111
+) (package-test.sty
+[1]> package-test.sty
+(package-test-before.sty
+Package: package-test-before ....-..-.. aaaaa
+) (package-test-nest.sty
+Package: package-test-nest ....-..-.. {{{}}}
+)
+[2]> package-test.sty
+2020/10/11 aaaaa
+Package: package-test ....-..-.. main package
+[3]> package-test.sty
+2020/10/11 aaaaa
+(package-test-after.sty
+Package: package-test-after ....-..-.. zzzzz
+)
+[4]> package-test.sty
+)
+(github-0408.aux)
+ *File List*
+   expl3.sty    ....-..-.. L3 programming layer (loader) 
+ article.cls    ....-..-.. v... Standard LaTeX document class
+  size10.clo    ....-..-.. v... Standard LaTeX file (size option)
+  test2e.tex
+package-test-first.sty    ....-..-.. 11111
+package-test.sty    ....-..-.. main package
+package-test-before.sty    ....-..-.. aaaaa
+package-test-nest.sty    ....-..-.. {{{}}}
+package-test-after.sty    ....-..-.. zzzzz
+ ***********





More information about the latex3-commits mailing list.