[latex3-commits] [git/LaTeX3-latex3-latex2e] lthooks2: Don't add .tex in \@curr at file (bd4055e9)

PhelypeOleinik tex.phelype at gmail.com
Wed Aug 19 00:01:56 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : lthooks2
Link       : https://github.com/latex3/latex2e/commit/bd4055e9e86e0b46a01656a61c70e0cb4c7c8fc3

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

commit bd4055e9e86e0b46a01656a61c70e0cb4c7c8fc3
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Tue Aug 18 19:01:56 2020 -0300

    Don't add .tex in \@curr at file


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

bd4055e9e86e0b46a01656a61c70e0cb4c7c8fc3
 base/ltfilehook.dtx | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/base/ltfilehook.dtx b/base/ltfilehook.dtx
index bde036f7..451d89ac 100644
--- a/base/ltfilehook.dtx
+++ b/base/ltfilehook.dtx
@@ -457,6 +457,28 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{
+%     \@filehook at if@no at extensionTF,
+%     \@filehook at drop@extension
+%   }
+%   Some actions depend on whether the file extension was explicitly
+%   given, and sometimes the extension has to be removed.  The macros
+%   below use \cs{@@_file_parse_full_name:nN} to split up the file name
+%   and either check if \meta{ext} (|#3|) is empty, or discard it.
+%    \begin{macrocode}
+\cs_new:Npn \@filehook at if@no at extensionTF #1
+  {
+    \exp_args:Ne \tl_if_empty:nTF
+      { \file_parse_full_name_apply:nN {#1} \use_iii:nnn }
+  }
+\cs_new_protected:Npn \@filehook at drop@extension #1
+  {
+    \tl_gset:Nx #1
+      { \exp_args:NV \@@_file_parse_full_name:nN #1 \use_i_ii:nnn }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\g_@@_input_file_seq,\l_@@_internal_tl}
 % \begin{macro}{\@filehook at file@push,\@filehook at file@pop}
 % \begin{macro}{\@@_file_pop_assign:nnnn}
@@ -686,13 +708,25 @@
 %   \cs{@kernel at if@file at replacedTF} short-cuts and just copies
 %   \cs{@curr at file}, otherwise the full normalisation procedure is
 %   executed.
+%
+%   At this stage the file name is parsed and normalised, but if the
+%   input doesn't have an extension, the default |.tex| is \emph{not}
+%   added to \cs{@curr at file} because for applications other than
+%   \cs{input} (graphics, for example) the default extension may not
+%   be |.tex|.  First check if the input has an extension, then if the
+%   input had no extension, call \cs{@filehook at drop@extension}.  In case
+%   of a file substitution, \cs{@curr at file} will have an extension.
 %    \begin{macrocode}
+    \@filehook at if@no at extensionTF{#1}%
+      {\@tempswatrue}{\@tempswafalse}%
     \@kernel at make@file at csname\@curr at file
       \@kernel at resolve@file at subst{#1}%
     \@kernel at if@file at replacedTF
       {\@kernel at make@file at csname\@curr at file@reqd
-         \@kernel at normalise@file at name{#1}}%
-      {\global\let\@curr at file@reqd\@curr at file}%
+         \@kernel at normalise@file at name{#1}%
+       \if at tempswa \@filehook at drop@extension\@curr at file@reqd \fi}%
+      {\if at tempswa \@filehook at drop@extension\@curr at file \fi
+       \global\let\@curr at file@reqd\@curr at file}%
   \endgroup}
 \def\@kernel at make@file at csname#1#2#3{%
   \xdef#1{\expandafter\@set at curr@file at aux





More information about the latex3-commits mailing list.