[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh422: Pass \@filef at und (expanded) to \@addtofilelist (fc36d24b)

PhelypeOleinik phelype.oleinik at latex-project.org
Wed Nov 18 00:39:17 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh422
Link       : https://github.com/latex3/latex2e/commit/fc36d24bcb69e530fc1befee055dd5368dd9628c

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

commit fc36d24bcb69e530fc1befee055dd5368dd9628c
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Tue Nov 17 20:39:17 2020 -0300

    Pass \@filef at und (expanded) to \@addtofilelist
    
    Passing the argument file name would get \@filelist wrong in a file substitution


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

fc36d24bcb69e530fc1befee055dd5368dd9628c
 base/ltfilehook.dtx            | 36 +++++++++++++++++++++---------------
 base/testfiles/github-0422.tlg | 12 ++++++------
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/base/ltfilehook.dtx b/base/ltfilehook.dtx
index 8bb53d7d..bb1bbd60 100644
--- a/base/ltfilehook.dtx
+++ b/base/ltfilehook.dtx
@@ -665,7 +665,7 @@
 %    If the file exists then \cs{CurrentFile} holds its name. But we
 %    can't rely on that still being true after the file has been
 %    processed. Thus for using the name in the file hooks we need to
-%    preserve the name and then restored it for the
+%    preserve the name and then restore it for the
 %    \texttt{file/after/...} hook.
 %
 %    The hook always refers to the file requested by the user.  The hook
@@ -682,34 +682,40 @@
 %    the file name and extension are returned so that file hooks can
 %    refer to the file by their name only.  The path to the file is
 %    returned in \cs{CurrentFilePath}.
+%
+%    We pre-expand \cs{@filef at und} so that in case another file is
+%    loaded in the true branch of \cs{InputIfFileExists}, these don't
+%    change their value meanwhile. This isn't a worry with
+%    \cs[no-index]{CurrentFile...} because they are kept in a stack.
 %    \begin{macrocode}
-      \edef\reserved at a{\@filef at und
+      \edef\reserved at a{%
         \@expl@@@filehook at file@pop at assign@@nnnn
           {\CurrentFilePathUsed}%
           {\CurrentFileUsed}%
           {\CurrentFilePath}%
-          {\CurrentFile}}%
+          {\CurrentFile}%
+        \noexpand\@input at file@exists at with@hooks{\@filef at und}}%
       \expandafter\@swaptwoargs\expandafter
         {\reserved at a}%
-        {%
-          #2%
-          \@addtofilelist{#1}%
-          \UseHook{file/before}%
+        {#2}%
+      \@expl@@@filehook at file@pop@@
+    }%
+}
+\def\@input at file@exists at with@hooks#1{%
+  \@addtofilelist{\unqu at tefilef@und#1\@nil}%
+  \UseHook{file/before}%
 %    \end{macrocode}
 %    The current file name is available in \cs{CurrentFile} so we use
 %    that in the specific hook.
 %    \begin{macrocode}
-          \UseHook{file/before/\CurrentFile}%
-          \@@input
-        }%
+  \UseHook{file/before/\CurrentFile}%
+  \@@input #1% <- trailing space comes from \@filef at und
 %    \end{macrocode}
 %    And it is restored here so we can use it once more.
 %    \begin{macrocode}
-      \UseHook{file/after/\CurrentFile}%
-      \UseHook{file/after}%
-      \@expl@@@filehook at file@pop@@
-    }%
-}
+  \UseHook{file/after/\CurrentFile}%
+  \UseHook{file/after}}
+\def\unqu at tefilef@und"#1" \@nil{#1}
 %<latexrelease>\EndIncludeInRelease
 %</2ekernel|latexrelease>
 %    \end{macrocode}
diff --git a/base/testfiles/github-0422.tlg b/base/testfiles/github-0422.tlg
index af676b3a..be5339c9 100644
--- a/base/testfiles/github-0422.tlg
+++ b/base/testfiles/github-0422.tlg
@@ -39,13 +39,13 @@ Package: test-fixed
 (test-fixed) with 'opt'
 (test): I should be loaded instead.
 )
-! LaTeX Error: Option clash for package test-fixed.
+! LaTeX Error: Option clash for package test-broken.
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H <return>  for immediate help.
  ...                                              
 l. ...\usepackage[opttwo]{test-broken}\relax
                                             % Option clash
-The package test-fixed has already been loaded with options:
+The package test-broken has already been loaded with options:
   [opt]
 There has now been an attempt to load it with options
   [opttwo]
@@ -88,18 +88,18 @@ Adding the global options:
 to your \documentclass declaration may fix this.
 Try typing  <return>  to proceed.
 ==================================================
-(testpath//inputpath-fixed.sty
+(testpath/inputpath-fixed.sty
 Package: inputpath-fixed 
 (inputpath-fixed) with 'opt'
 (inputpath): I should be loaded instead.
 )
-! LaTeX Error: Option clash for package inputpath-fixed.
+! LaTeX Error: Option clash for package inputpath-broken.
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H <return>  for immediate help.
  ...                                              
 l. ...\usepackage[opttwo]{inputpath-broken}\relax
                                                   % Option clash
-The package inputpath-fixed has already been loaded with options:
+The package inputpath-broken has already been loaded with options:
   [opt]
 There has now been an attempt to load it with options
   [opttwo]
@@ -131,5 +131,5 @@ Try typing  <return>  to proceed.
 testpath/teststy.sty    
 test-fixed.sty    
 testpath/in-fixed.sty    
-./testpath//inputpath-fixed.sty    
+./testpath/inputpath-fixed.sty    
  ***********





More information about the latex3-commits mailing list.