[latex3-commits] [git/LaTeX3-latex3-latex2e] gh22: another attempt at #22 (56f4b03b)

Frank Mittelbach frank.mittelbach at latex-project.org
Wed Apr 8 21:32:15 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh22
Link       : https://github.com/latex3/latex2e/commit/56f4b03b7bca7d66bbf9abcfec10745b77802540

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

commit 56f4b03b7bca7d66bbf9abcfec10745b77802540
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Wed Apr 8 21:32:15 2020 +0200

    another attempt at #22


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

56f4b03b7bca7d66bbf9abcfec10745b77802540
 base/ltclass.dtx                                   | 153 +++++++++++++++++----
 base/testfiles/github-0022c.lvt                    |  21 +++
 .../{tlb-article-0000.tlg => github-0022c.tlg}     |   2 +
 base/testfiles/tlb-latexrelease-003.luatex.tlg     |  20 +--
 base/testfiles/tlb-latexrelease-003.tlg            |  20 +--
 5 files changed, 174 insertions(+), 42 deletions(-)

diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index 96514482..ab5899d2 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -1053,7 +1053,7 @@
 %</2ekernel>
 %<*2ekernel|latexrelease>
 %<latexrelease>\IncludeInRelease{2020/10/01}%
-%<latexrelease>                 {\@process at pti@ns}{Drop unused options}%
+%<latexrelease>                 {\@process at pti@ns}{Unused options issue}%
 \def\@process at pti@ns{%
   \@for\CurrentOption:=\@curroptions\do{%
     \@ifundefined{ds@\CurrentOption}%
@@ -1082,12 +1082,14 @@
 %    \begin{macrocode}
   \let\CurrentOption\@empty
   \let\@fileswith at pti@ns\@@fileswith at pti@ns
-  \AtEndOfPackage{\@drop at unprocessedoptions}}
+  \AtEndOfPackage{\expandafter\let
+                     \csname unprocessedoptions-\@currname.\@currext\endcsname
+                     \relax}}
 \@onlypreamble\@process at pti@ns
 %</2ekernel|latexrelease>
 %<latexrelease>\EndIncludeInRelease
 %<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease>                 {\@process at pti@ns}{Drop unused options}%
+%<latexrelease>                 {\@process at pti@ns}{Unused options issue}%
 %<latexrelease>
 %<latexrelease>\def\@process at pti@ns{%
 %<latexrelease>  \@for\CurrentOption:=\@curroptions\do{%
@@ -1270,8 +1272,7 @@
 %</2ekernel>
 %<*2ekernel|latexrelease>
 %<latexrelease>\IncludeInRelease{2020/10/01}%
-%<latexrelease>                 {\@dropunprocessedoptions}{Drop
-%<latexrelease>                                    unprocessed option}%
+%<latexrelease>                 {\RequirePackageWithOptions}{Unused options issue}%
 \def\RequirePackageWithOptions{%
 %    \end{macrocode}
 %    The resetting of \cs{unprocessedoptions} needs to be the very
@@ -1282,25 +1283,15 @@
 % \changes{v1.3k}{2020/04/07}{Use different method to ignore
 %    unprocessed options (gh/22)}
 %    \begin{macrocode}
-  \AtEndOfPackage{\@drop at unprocessedoptions}%
+  \AtEndOfPackage{\expandafter\let
+                    \csname unprocessedoptions-\@currname.\@currext\endcsname
+                    \relax}%
   \@loadwithoptions\@pkgextension\RequirePackage}
 \@onlypreamble\RequirePackageWithOptions
 %    \end{macrocode}
 % \end{macro}
 %
 %
-%  \begin{macro}{\@drop at unprocessedoptions}
-%    Kind of a longish \cs{expandafter}. We skip ahead the re-add what
-%    we scanned but drop \cs{@unprocessedoptions}.
-% \changes{v1.3k}{2020/04/07}{Use different method to ignore
-%    unprocessed options (gh/22)}
-%    \begin{macrocode}
-\long\def\@@drop at unprocessedoptions#1\@undefined\@unprocessedoptions{%
-  \let\@drop at unprocessedoptions\relax
-  #1\@undefined
-  \let\@drop at unprocessedoptions\@@drop at unprocessedoptions
-}
-\let\@drop at unprocessedoptions\@@drop at unprocessedoptions
 %</2ekernel|latexrelease>
 %<latexrelease>\EndIncludeInRelease
 %    \end{macrocode}
@@ -1310,8 +1301,7 @@
 
 %    \begin{macrocode}
 %<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease>                 {\@dropunprocessedoptions}{Drop
-%<latexrelease>                                    unprocessed option}%
+%<latexrelease>                 {\RequirePackageWithOptions}{Unused options issue}%
 %<latexrelease>
 %<latexrelease>\def\RequirePackageWithOptions{%
 %<latexrelease>  \AtEndOfPackage{\let\@unprocessedoptions\relax}%
@@ -1556,6 +1546,10 @@
 % \changes{v1.3d}{2019/10/18}{Initialize \cs{...-h@@k} only when loading
 %                             the package or class (gh/198)}
 %    \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>                 {\@onefilewithoptions}{Unused options issue}%
 \def\@onefilewithoptions#1[#2][#3]#4{%
   \@pushfilename
   \xdef\@currname{#1}%
@@ -1605,19 +1599,49 @@
          {}%
          {\@missingfileerror\@currname\@currext}%
 %    \end{macrocode}
-% |\@unprocessedoptions| will generate an error for each specified
-% option in a package unless a |\ProcessOptions| has appeared in the
-% package file.
+%    In older versions of the code |\@unprocessedoptions| would
+%    generate an error for each specified
+%    option in a package unless a |\ProcessOptions| has appeared in the
+%    package file.
 % \changes{v0.2v}{1994/01/29}
 %         {All options raise error if no \cs{ProcessOptions} appears}
 % \changes{v0.2x}{1994/02/02}
-%         {Only run the hook and options check if the file was loaded.}
+%         {Only run the hook and options check if the file was
+%    loaded.}
+%
+%    This has changed in 2020. We now use a separate macro per package
+%    to avoid interferences in case of nested packages.  The whole
+%    code for handling this issue (GitHub 22) was provided by Hironobu
+%    Yamashita, thanks for that.
+% \changes{v1.3k}{2020/04/07}{Use different method to ignore
+%    unprocessed options (gh/22)}
 %    \begin{macrocode}
-    \let\@unprocessedoptions\@@unprocessedoptions
+    \expandafter\let\csname unprocessedoptions-\@currname.\@currext\endcsname
+                    \@@unprocessedoptions
     \csname\@currname.\@currext-h@@k\endcsname
     \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
               \@undefined
-    \@unprocessedoptions}%
+%    \end{macrocode}
+%    Catch the case where the packages has handled the options and
+%    redefined \cs{@unprocessedoptions} to \cs{relax} (old interface).
+%    In that case no error should be produced.
+% \changes{v1.3k}{2020/04/07}{Use different method to ignore
+%    unprocessed options (gh/22)}
+%    \begin{macrocode}
+    \ifx\@unprocessedoptions\relax
+      \let\@unprocessedoptions\@undefined
+%    \end{macrocode}
+%    Otherwise run the per package set of unused options.
+%    \begin{macrocode}
+    \else
+      \csname unprocessedoptions-\@currname.\@currext\endcsname
+    \fi
+%    \end{macrocode}
+%    In either case we drop the macro afterwards as it is no longer needed.
+%    \begin{macrocode}
+    \expandafter\let
+        \csname unprocessedoptions-\@currname.\@currext\endcsname
+       \@undefined}%
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -1639,8 +1663,82 @@
   \reserved at a}
 \@onlypreamble\@onefilewithoptions
 %    \end{macrocode}
+%
+%    The kernel no longer uses \cs{@unprocessedoptions}
+%    \begin{macrocode}
+\let\@unprocessedoptions\@undefined  
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease>                 {\@onefilewithoptions}{Unused options issue}%
+%<latexrelease>
+%    \end{macrocode}
+%    Because of the way \cs{@onfilewithoptions} is changed for
+%    rollback handling below we have to define
+%    \cs{load at onefilewithoptions} when rollowing back!
+%    \begin{macrocode}
+%<latexrelease>\def\load at onefilewithoptions#1[#2][#3]#4{%
+%<latexrelease>  \@pushfilename
+%<latexrelease>  \xdef\@currname{#1}%
+%<latexrelease>  \global\let\@currext#4%
+%<latexrelease>  \let\CurrentOption\@empty
+%<latexrelease>  \@reset at ptions
+%<latexrelease>  \makeatletter
+%<latexrelease>  \def\reserved at a{%
+%<latexrelease>    \@ifl at aded\@currext{#1}%
+%<latexrelease>      {\@if at ptions\@currext{#1}{#2}{}%
+%<latexrelease>        {\@latex at error
+%<latexrelease>            {Option clash for \@cls at pkg\space #1}%
+%<latexrelease>            {The package #1 has already been loaded
+%<latexrelease>             with options:\MessageBreak
+%<latexrelease>             \space\space[\@ptionlist{#1.\@currext}]\MessageBreak
+%<latexrelease>             There has now been an attempt to load it
+%<latexrelease>              with options\MessageBreak
+%<latexrelease>             \space\space[#2]\MessageBreak
+%<latexrelease>             Adding the global options:\MessageBreak
+%<latexrelease>             \space\space
+%<latexrelease>                  \@ptionlist{#1.\@currext},#2\MessageBreak
+%<latexrelease>             to your \noexpand\documentclass declaration may fix this.%
+%<latexrelease>             \MessageBreak
+%<latexrelease>             Try typing \space <return> \space to proceed.}}}%
+%<latexrelease>      {\@pass at ptions\@currext{#2}{#1}%
+%<latexrelease>       \global\expandafter
+%<latexrelease>       \let\csname ver@\@currname.\@currext\endcsname\@empty
+%<latexrelease>       \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty
+%<latexrelease>       \InputIfFileExists
+%<latexrelease>         {\@currname.\@currext}%
+%<latexrelease>         {}%
+%<latexrelease>         {\@missingfileerror\@currname\@currext}%
+%<latexrelease>    \let\@unprocessedoptions\@@unprocessedoptions
+%<latexrelease>    \csname\@currname.\@currext-h@@k\endcsname
+%<latexrelease>    \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
+%<latexrelease>              \@undefined
+%<latexrelease>    \@unprocessedoptions}%
+%<latexrelease>    \@ifl at ter\@currext{#1}{#3}{}%
+%<latexrelease>      {\@latex at warning@no at line
+%<latexrelease>         {You have requested,\on at line,
+%<latexrelease>          version\MessageBreak
+%<latexrelease>            `#3' of \@cls at pkg\space #1,\MessageBreak
+%<latexrelease>          but only version\MessageBreak
+%<latexrelease>           `\csname ver@#1.\@currext\endcsname'\MessageBreak
+%<latexrelease>          is available}}%
+%<latexrelease>    \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi
+%<latexrelease>    \@popfilename
+%<latexrelease>    \@reset at ptions}%
+%<latexrelease>  \reserved at a}
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+%    \end{macrocode}
 % \end{macro}
 %
+%
+%
+%
+%
+%
 % \begin{macro}{\@@fileswith at pti@ns}
 % Save the definition (for error checking).
 % \changes{v0.2c}{1993/11/17}
@@ -1667,6 +1765,9 @@
 %    \end{macrocode}
 % \end{macro}
 %
+%
+%
+%
 % \subsection{Hooks}
 %
 % Allow code do be saved to be executed at specific later times.
diff --git a/base/testfiles/github-0022c.lvt b/base/testfiles/github-0022c.lvt
new file mode 100644
index 00000000..3eb3ae59
--- /dev/null
+++ b/base/testfiles/github-0022c.lvt
@@ -0,0 +1,21 @@
+
+\begin{filecontents}[force]{\jobname0.sty}
+\DeclareOption{FOO}{\PassOptionsToPackage{FOO}{\jobname1}}
+\ProcessOptions\relax
+\AtEndOfPackage{\RequirePackage{\jobname1}}
+\end{filecontents}
+
+\begin{filecontents}[force]{\jobname1.sty}
+\DeclareOption{FOO}{\typeout{*** FOO OPTION ***}}
+\ProcessOptions\relax
+\end{filecontents}
+\input{test2e}
+
+\START
+
+\documentclass{article}
+
+\usepackage[FOO]{\jobname0}
+
+
+\END
diff --git a/base/testfiles/tlb-article-0000.tlg b/base/testfiles/github-0022c.tlg
similarity index 89%
copy from base/testfiles/tlb-article-0000.tlg
copy to base/testfiles/github-0022c.tlg
index b96e3f6a..9b992b46 100644
--- a/base/testfiles/tlb-article-0000.tlg
+++ b/base/testfiles/github-0022c.tlg
@@ -16,4 +16,6 @@ File: size10.clo ....-..-.. v... Standard LaTeX file (size option)
 \abovecaptionskip=\skip...
 \belowcaptionskip=\skip...
 \bibindent=\dimen...
+) (github-0022c0.sty) (github-0022c1.sty
+*** FOO OPTION ***
 )
diff --git a/base/testfiles/tlb-latexrelease-003.luatex.tlg b/base/testfiles/tlb-latexrelease-003.luatex.tlg
index 251fb204..e482b5f3 100644
--- a/base/testfiles/tlb-latexrelease-003.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-003.luatex.tlg
@@ -133,14 +133,16 @@ Skipping: [....-..-..] Spaces in option clash check on input line ....
 Applying: [....-..-..] Spaces in option clash check on input line ....
 Skipping: [....-..-..] Protection for package info on input line ....
 Applying: [....-..-..] Protection for package info on input line ....
-Skipping: [....-..-..] Drop unused options on input line ....
-Applying: [....-..-..] Drop unused options on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] Spaces in \ExecuteOptions  on input line ....
 Applying: [....-..-..] Spaces in \ExecuteOptions  on input line ....
-Skipping: [....-..-..] Drop unprocessed option on input line ....
-Applying: [....-..-..] Drop unprocessed option on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
 Applying: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] Spaces in file names + optional arg on input line ...
 Applying: [....-..-..] Spaces in file names + optional arg on input line ...
 Skipping: [....-..-..] Make commands robust on input line ....
@@ -476,14 +478,16 @@ Applying: [....-..-..] Spaces in option clash check on input line ....
 Already applied: [....-..-..] Spaces in option clash check on input line ...
 Skipping: [....-..-..] Protection for package info on input line ....
 Applying: [....-..-..] Protection for package info on input line ....
-Skipping: [....-..-..] Drop unused options on input line ....
-Applying: [....-..-..] Drop unused options on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] Spaces in \ExecuteOptions  on input line ....
 Already applied: [....-..-..] Spaces in \ExecuteOptions  on input line ....
-Skipping: [....-..-..] Drop unprocessed option on input line ....
-Applying: [....-..-..] Drop unprocessed option on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
 Already applied: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] Spaces in file names + optional arg on input line ...
 Already applied: [....-..-..] Spaces in file names + optional arg on input line ....
 Applying: [....-..-..] Make commands robust on input line ....
diff --git a/base/testfiles/tlb-latexrelease-003.tlg b/base/testfiles/tlb-latexrelease-003.tlg
index c641f133..121fbaf0 100644
--- a/base/testfiles/tlb-latexrelease-003.tlg
+++ b/base/testfiles/tlb-latexrelease-003.tlg
@@ -131,14 +131,16 @@ Skipping: [....-..-..] Spaces in option clash check on input line ....
 Applying: [....-..-..] Spaces in option clash check on input line ....
 Skipping: [....-..-..] Protection for package info on input line ....
 Applying: [....-..-..] Protection for package info on input line ....
-Skipping: [....-..-..] Drop unused options on input line ....
-Applying: [....-..-..] Drop unused options on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] Spaces in \ExecuteOptions  on input line ....
 Applying: [....-..-..] Spaces in \ExecuteOptions  on input line ....
-Skipping: [....-..-..] Drop unprocessed option on input line ....
-Applying: [....-..-..] Drop unprocessed option on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
 Applying: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Skipping: [....-..-..] Spaces in file names + optional arg on input line ...
 Applying: [....-..-..] Spaces in file names + optional arg on input line ...
 Skipping: [....-..-..] Make commands robust on input line ....
@@ -468,14 +470,16 @@ Applying: [....-..-..] Spaces in option clash check on input line ....
 Already applied: [....-..-..] Spaces in option clash check on input line ...
 Skipping: [....-..-..] Protection for package info on input line ....
 Applying: [....-..-..] Protection for package info on input line ....
-Skipping: [....-..-..] Drop unused options on input line ....
-Applying: [....-..-..] Drop unused options on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] Spaces in \ExecuteOptions  on input line ....
 Already applied: [....-..-..] Spaces in \ExecuteOptions  on input line ....
-Skipping: [....-..-..] Drop unprocessed option on input line ....
-Applying: [....-..-..] Drop unprocessed option on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
 Already applied: [....-..-..] ifx tests in \@fileswith at pti@ns  on input line ....
+Skipping: [....-..-..] Unused options issue on input line ....
+Applying: [....-..-..] Unused options issue on input line ....
 Applying: [....-..-..] Spaces in file names + optional arg on input line ...
 Already applied: [....-..-..] Spaces in file names + optional arg on input line ....
 Applying: [....-..-..] Make commands robust on input line ....





More information about the latex3-commits mailing list.