texlive[52272] Master/texmf-dist: filehook (3oct19)

commits+karl at tug.org commits+karl at tug.org
Thu Oct 3 23:09:13 CEST 2019


Revision: 52272
          http://tug.org/svn/texlive?view=revision&revision=52272
Author:   karl
Date:     2019-10-03 23:09:13 +0200 (Thu, 03 Oct 2019)
Log Message:
-----------
filehook (3oct19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/filehook/filehook.pdf
    trunk/Master/texmf-dist/source/latex/filehook/filehook.dtx
    trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty

Modified: trunk/Master/texmf-dist/doc/latex/filehook/filehook.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/filehook/filehook.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/filehook/filehook.dtx	2019-10-03 21:08:57 UTC (rev 52271)
+++ trunk/Master/texmf-dist/source/latex/filehook/filehook.dtx	2019-10-03 21:09:13 UTC (rev 52272)
@@ -26,10 +26,10 @@
 %<*driver>
 \ProvidesFile{filehook.dtx}[%
 %<=*DATE>
-    2019/08/19
+    2019/10/03
 %<=/DATE>
 %<=*VERSION>
-    v0.5e
+    v0.6
 %<=/VERSION>
     Hooks for input files]
 \documentclass{ydoc}
@@ -55,7 +55,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1051}
+% \CheckSum{1093}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -95,6 +95,8 @@
 % \changes{v0.5b}{2011/07/18}{Replaced \cs{@nameuse} for use with eTeX code to avoid the definition of non-existing hooks to \cs{relax}.}
 % \changes{v0.5c}{2011/10/07}{Added fall-back code for non-eTeX compilers.}
 % \changes{v0.5d}{2011/10/12}{Fix for fall-back code.}
+% \changes{v0.5e}{2019/08/19}{Fix for new LaTeX format.}
+% \changes{v0.6}{2019/10/03}{Fix for InputIfFileExists for LaTeX format 2019/10/01.}
 %
 % \GetFileInfo{filehook.dtx}
 %
@@ -1106,43 +1108,32 @@
 % This is always done inside a group to keep them temporary only.
 % The token register is used to avoid doubling of macro argument characters.
 %
-% \begin{macro}{\oldlatex at InputIfFileExists}
-% Original standard \LaTeX\ definition of \Macro\InputIfFileExists.
 %    \begin{macrocode}
-\long\def\oldlatex at InputIfFileExists#1#2{%
-  \IfFileExists{#1}%
-    {#2\@addtofilelist{#1}%
-     \@@input\@filef at und
-    }%
-}
+\newif\iffilehook at newfmt
+\@ifl at t@r\fmtversion{2019/10/01}{\filehook at newfmttrue}{\filehook at newfmtfalse}
 %    \end{macrocode}
-% \end{macro}
 %
-%
 % \begin{macro}{\latex at InputIfFileExists}
-% Standard \`LaTeX\ definition of \Macro\InputIfFileExists starting from LaTeX Kernal 2019/02/07 v1.1n.
+% Standard \LaTeX\ definition of \Macro\InputIfFileExists.
 %    \begin{macrocode}
-\long\def\newlatex at InputIfFileExists#1#2{%
+\iffilehook at newfmt
+\DeclareRobustCommand \latex at InputIfFileExists[2]{%
   \IfFileExists{#1}%
     {%
   \expandafter\@swaptwoargs\expandafter
       {\@filef at und}{#2\@addtofilelist{#1}\@@input}}}
+\else
+\long\def\latex at InputIfFileExists#1#2{%
+  \IfFileExists{#1}%
+    {#2\@addtofilelist{#1}%
+     \@@input\@filef at und
+    }%
+}
+\fi
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\latex at InputIfFileExists}
-% Standard \`LaTeX\ definition of \Macro\InputIfFileExists starting from LaTeX Kernal 2019/02/07 v1.1n.
-%    \begin{macrocode}
-\@ifundefined{@swaptwoargs}{%
-  \let\latex at InputIfFileExists\oldlatex at InputIfFileExists
-}{%
-  \let\latex at InputIfFileExists\newlatex at InputIfFileExists
-}%
-%    \end{macrocode}
-% \end{macro}
-%
-%
 % \begin{macro}{\filehook at default@InputIfFileExists}
 %    \begin{macrocode}
 \long\gdef\filehook at default@InputIfFileExists#1#2{%
@@ -1300,33 +1291,48 @@
   \RequirePackage{filehook-memoir}%
 }%
 %    \end{macrocode}
-%
 % Finally, if no specific alternate definition is detected the original \LaTeX\ definition is checked for and a
 % error is given if any other unknown definition is detected.
 % The \opt{force} option will change the error into a warning and overwrite the macro with the default.
 %    \begin{macrocode}
-\ifcase
-    \ifx\InputIfFileExists\filehook at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\newlatex at InputIfFileExists 1\else
-    \ifx\InputIfFileExists\oldlatex at InputIfFileExists 1\else
-    9%
-    \fi\fi\fi
+\def\@tempa{9}%
+\ifx\InputIfFileExists\filehook at InputIfFileExists
+    \def\@tempa{0}%
+\else
+    \iffilehook at force
+        \def\@tempa{1}%
+    \else
+        \iffilehook at newfmt
+            % check if both the robust \InputIfFileExist and its internal macro match the default LaTeX definition
+            \edef\@tempb{\noexpand\protect\expandafter\noexpand\csname InputIfFileExists\space\endcsname}%
+            \ifx\InputIfFileExists\@tempb
+                \expandafter\ifx\csname InputIfFileExists\space\expandafter\endcsname\csname latex at InputIfFileExists\space\endcsname
+                    \def\@tempa{1}%
+                \fi
+            \fi
+        \else\ifx\InputIfFileExists\latex at InputIfFileExists
+            \def\@tempa{1}%
+        \fi\fi
+    \fi
+\fi
+%
+\ifcase\@tempa
 \relax% 0
 \or% 1
     \let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
     \let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \let\InputIfFileExists\filehook at InputIfFileExists
-\else
+    \iffilehook at newfmt
+        \expandafter\let\csname InputIfFileExists\space\endcsname\filehook at InputIfFileExists
+    \else
+        \let\InputIfFileExists\filehook at InputIfFileExists
+    \fi
     \iffilehook at force
-      \let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-      \let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-      \let\InputIfFileExists\filehook at InputIfFileExists
       \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
                                 The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
-    \else
-      \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                                Use the 'force' option of 'filehook' to overwrite it.}{}%
     \fi
+\else
+    \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
+                            Use the 'force' option of 'filehook' to overwrite it.}{}%
 \fi
 %    \end{macrocode}
 % \end{macro}
@@ -1333,7 +1339,9 @@
 %
 %    \begin{macrocode}
 \AtBeginDocument{%
-    \ifx\InputIfFileExists\filehook at InputIfFileExists\else
+    % Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists<space>,
+    % for the old format to \InputIfFileExists directly.
+    \expandafter\ifx\csname InputIfFileExists\iffilehook at newfmt\space\fi\endcsname\filehook at InputIfFileExists\else
         \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J%
                                   Certain file hooks might now be dysfunctional!}
     \fi

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty	2019-10-03 21:08:57 UTC (rev 52271)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty	2019-10-03 21:09:13 UTC (rev 52272)
@@ -19,8 +19,8 @@
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{filehook}[%
-    2019/08/19
-    v0.5e
+    2019/10/03
+    v0.6
     Hooks for input files]
 \newif\iffilehook at force
 \DeclareOption{force}{\filehook at forcetrue}
@@ -245,22 +245,22 @@
     \expandafter\filehook@@ensuretex#1\empty.tex\empty\empty
 }
 \def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex}
-\long\def\oldlatex at InputIfFileExists#1#2{%
+\newif\iffilehook at newfmt
+\@ifl at t@r\fmtversion{2019/10/01}{\filehook at newfmttrue}{\filehook at newfmtfalse}
+\iffilehook at newfmt
+\DeclareRobustCommand \latex at InputIfFileExists[2]{%
   \IfFileExists{#1}%
+    {%
+  \expandafter\@swaptwoargs\expandafter
+      {\@filef at und}{#2\@addtofilelist{#1}\@@input}}}
+\else
+\long\def\latex at InputIfFileExists#1#2{%
+  \IfFileExists{#1}%
     {#2\@addtofilelist{#1}%
      \@@input\@filef at und
     }%
 }
-\long\def\newlatex at InputIfFileExists#1#2{%
-  \IfFileExists{#1}%
-    {%
-  \expandafter\@swaptwoargs\expandafter
-      {\@filef at und}{#2\@addtofilelist{#1}\@@input}}}
-\@ifundefined{@swaptwoargs}{%
-  \let\latex at InputIfFileExists\oldlatex at InputIfFileExists
-}{%
-  \let\latex at InputIfFileExists\newlatex at InputIfFileExists
-}%
+\fi
 \long\gdef\filehook at default@InputIfFileExists#1#2{%
   \IfFileExists{#1}%
     {\expandafter\filehook at swap
@@ -377,31 +377,48 @@
   \let\@iinput\filehook@@iinput
   \RequirePackage{filehook-memoir}%
 }%
-\ifcase
-    \ifx\InputIfFileExists\filehook at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\newlatex at InputIfFileExists 1\else
-    \ifx\InputIfFileExists\oldlatex at InputIfFileExists 1\else
-    9%
-    \fi\fi\fi
+\def\@tempa{9}%
+\ifx\InputIfFileExists\filehook at InputIfFileExists
+    \def\@tempa{0}%
+\else
+    \iffilehook at force
+        \def\@tempa{1}%
+    \else
+        \iffilehook at newfmt
+            % check if both the robust \InputIfFileExist and its internal macro match the default LaTeX definition
+            \edef\@tempb{\noexpand\protect\expandafter\noexpand\csname InputIfFileExists\space\endcsname}%
+            \ifx\InputIfFileExists\@tempb
+                \expandafter\ifx\csname InputIfFileExists\space\expandafter\endcsname\csname latex at InputIfFileExists\space\endcsname
+                    \def\@tempa{1}%
+                \fi
+            \fi
+        \else\ifx\InputIfFileExists\latex at InputIfFileExists
+            \def\@tempa{1}%
+        \fi\fi
+    \fi
+\fi
+\ifcase\@tempa
 \relax% 0
 \or% 1
     \let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
     \let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \let\InputIfFileExists\filehook at InputIfFileExists
-\else
+    \iffilehook at newfmt
+        \expandafter\let\csname InputIfFileExists\space\endcsname\filehook at InputIfFileExists
+    \else
+        \let\InputIfFileExists\filehook at InputIfFileExists
+    \fi
     \iffilehook at force
-      \let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-      \let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-      \let\InputIfFileExists\filehook at InputIfFileExists
       \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
                                 The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
-    \else
-      \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                                Use the 'force' option of 'filehook' to overwrite it.}{}%
     \fi
+\else
+    \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
+                            Use the 'force' option of 'filehook' to overwrite it.}{}%
 \fi
 \AtBeginDocument{%
-    \ifx\InputIfFileExists\filehook at InputIfFileExists\else
+    % Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists<space>,
+    % for the old format to \InputIfFileExists directly.
+    \expandafter\ifx\csname InputIfFileExists\iffilehook at newfmt\space\fi\endcsname\filehook at InputIfFileExists\else
         \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J%
                                   Certain file hooks might now be dysfunctional!}
     \fi



More information about the tex-live-commits mailing list