[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh422: Check for replacement file before reporting a missing file (abb5d720)

PhelypeOleinik phelype.oleinik at latex-project.org
Fri Nov 20 03:24:48 CET 2020


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

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

commit abb5d7200df776927efe603c578a478de0ad632c
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Thu Nov 19 23:24:48 2020 -0300

    Check for replacement file before reporting a missing file


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

abb5d7200df776927efe603c578a478de0ad632c
 base/ltclass.dtx    | 26 ++++++++++++++++++++------
 base/ltfilehook.dtx |  5 +++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index 7c1a66f5..52cd8093 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -2006,14 +2006,28 @@
 % \end{macro}
 %
 % \begin{macro}{\@missing at onefilewithoptions}
-%    Now the action taken when a file is not found.  Path must be
-%    included here as it eventually leads to a file lookup.
+%    Now the action taken when a file is not found.  First resolve a
+%    possible file substitution, and check if any happened.  In the
+%    common case of no substitution, the \cs{@missingfileerror} is
+%    reported and a new file is asked for.  However if the file has a
+%    declared substutition, then the replacement package is checked for
+%    existence instead, and it follows normally or errors accordingly.
+%    Path must be included here as it eventually leads to a file lookup.
 %    \begin{macrocode}
 \def\@missing at onefilewithoptions#1{%
-  \@missingfileerror{\@currpath\@currname}\@currext
-  \global\let\@currpath\@missingfile at area
-  \global\let\@currname\@missingfile at base
-  \global\let\@currext\@missingfile at ext}
+  \edef\reserved at a{%
+    \@expl@@@filehook at file@subst at begin@@nnn
+      \@currpath\@currname{.\@currext}}%
+  \@expl@@@filehook at if@file at replaced@@TF
+    {\@expl@@@filehook at clear@replacement at flag@@
+     \IfFileExists{\reserved at a}%
+       {\@gobble}{\@firstofone}}%
+    {\@expl@@@filehook at clear@replacement at flag@@\@firstofone}%
+      {\@missingfileerror{\@currpath\@currname}\@currext
+       \global\let\@currpath\@missingfile at area
+       \global\let\@currname\@missingfile at base
+       \global\let\@currext\@missingfile at ext}%
+  }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/base/ltfilehook.dtx b/base/ltfilehook.dtx
index 50f6785c..c8bca93c 100644
--- a/base/ltfilehook.dtx
+++ b/base/ltfilehook.dtx
@@ -1375,6 +1375,11 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\cs_new_eq:NN \@expl@@@filehook at file@subst at begin@@nnn
+              \__filehook_file_subst_begin:nnn
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \cs_new_eq:NN \@expl@@@filehook at normalize@file at name@@w
               \__filehook_normalize_file_name:w
 %    \end{macrocode}





More information about the latex3-commits mailing list.