texlive[53655] Master/texmf-dist: filehook (3feb20)

commits+karl at tug.org commits+karl at tug.org
Mon Feb 3 23:31:24 CET 2020


Revision: 53655
          http://tug.org/svn/texlive?view=revision&revision=53655
Author:   karl
Date:     2020-02-03 23:31:24 +0100 (Mon, 03 Feb 2020)
Log Message:
-----------
filehook (3feb20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/filehook/README
    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-fink.sty
    trunk/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty
    trunk/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty
    trunk/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty
    trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty

Modified: trunk/Master/texmf-dist/doc/latex/filehook/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filehook/README	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/doc/latex/filehook/README	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,7 +1,6 @@
 LaTeX package 'filehook'
 ~~~~~~~~~~~~~~~~~~~~~~~~
-Copyright (c) 2010-2019 by Martin Scharrer <martin at scharrer-online.de>
-WWW: http://latex.scharrer-online.de/
+Copyright (c) 2010-2020 by Martin Scharrer <martin at scharrer-online.de>
 Code repository: https://bitbucket.org/martin_scharrer/filehook
 
 Provides several file hooks for files read by \input, \include and \InputIfFileExists.

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	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/source/latex/filehook/filehook.dtx	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %<=*COPYRIGHT>
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -26,10 +26,10 @@
 %<*driver>
 \ProvidesFile{filehook.dtx}[%
 %<=*DATE>
-    2019/10/03
+    2020/02/03
 %<=/DATE>
 %<=*VERSION>
-    v0.6
+    v0.7
 %<=/VERSION>
     Hooks for input files]
 \documentclass{ydoc}
@@ -55,7 +55,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1093}
+% \CheckSum{1011}
 %
 % \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
@@ -97,6 +97,7 @@
 % \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.}
+% \changes{v0.7}{2020/02/03}{Further fixes for InputIfFileExists for LaTeX format 2019/10/01.}
 %
 % \GetFileInfo{filehook.dtx}
 %
@@ -530,11 +531,67 @@
 \ProcessOptions\relax
 %    \end{macrocode}
 %
+% \subsection{General stuff}
 %
+% \begin{macro}{\iffilehook at newfmt}
+%    \begin{macrocode}
+\newif\iffilehook at newfmt
+\@ifl at t@r\fmtversion{2019/10/01}{\filehook at newfmttrue}{\filehook at newfmtfalse}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\filehook at let}[2]{<macro name 1>}{<macro name 2>}
+%    \begin{macrocode}
+\def\filehook at let#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname
+  \else
+    \expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}%
+    \expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\filehook at glet}[2]{<macro name 1>}{<macro name 2>}
+%    \begin{macrocode}
+\def\filehook at glet#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\global\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname
+  \else
+    \expandafter\global\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}%
+    \expandafter\global\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\filehook at cmp}[2]{<macro name 1>}{<macro name 2>}
+% Compare two macros definition including its space form in case of robust macros.
+%    \begin{macrocode}
+\def\filehook at cmp#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\ifx\csname #1\expandafter\endcsname\csname #2\endcsname
+      \expandafter\expandafter\expandafter\@firstoftwo
+    \else
+      \expandafter\expandafter\expandafter\@secondoftwo
+    \fi
+  \else
+    \expandafter\ifx\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+      \expandafter\expandafter\expandafter\@firstoftwo
+    \else
+      \expandafter\expandafter\expandafter\@secondoftwo
+    \fi
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \subsection{Initialisation of Hooks}
 % The general hooks are initialised to call the file specific hooks.
 %
-%
 % \begin{macro}{\filehook at csuse}
 %    \begin{macrocode}
 \begingroup
@@ -553,7 +610,7 @@
 % \begin{macro}{\filehook at include@atbegin}
 %    \begin{macrocode}
 \def\filehook at include@atbegin#1{%
-  \let\InputIfFileExists\filehook@@InputIfFileExists
+  \filehook at let{InputIfFileExists}{filehook@@InputIfFileExists}%
   \filehook at csuse{\filehook at include@atbegin@#1}%
   \filehook at include@@atbegin
 }
@@ -599,7 +656,7 @@
 % \begin{macro}{\filehook at input@atbegin}
 %    \begin{macrocode}
 \def\filehook at input@atbegin#1{%
-  \let\InputIfFileExists\filehook@@InputIfFileExists
+  \filehook at let{InputIfFileExists}{filehook@@InputIfFileExists}%
   \filehook at csuse{\filehook at input@atbegin@\filehook at ensureext{#1}}%
   \filehook at input@@atbegin
 }
@@ -1108,16 +1165,14 @@
 % 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{macrocode}
-\newif\iffilehook at newfmt
-\@ifl at t@r\fmtversion{2019/10/01}{\filehook at newfmttrue}{\filehook at newfmtfalse}
-%    \end{macrocode}
-%
 % \begin{macro}{\latex at InputIfFileExists}
 % Standard \LaTeX\ definition of \Macro\InputIfFileExists.
 %    \begin{macrocode}
 \iffilehook at newfmt
-\DeclareRobustCommand \latex at InputIfFileExists[2]{%
+\expandafter\def\expandafter\latex at InputIfFileExists\expandafter{%
+  \expandafter\protect\csname InputIfFileExists\space\endcsname
+}
+\expandafter\long\expandafter\def\csname latex at InputIfFileExists\space\endcsname#1#2{%
   \IfFileExists{#1}%
     {%
   \expandafter\@swaptwoargs\expandafter
@@ -1136,7 +1191,7 @@
 %
 % \begin{macro}{\filehook at default@InputIfFileExists}
 %    \begin{macrocode}
-\long\gdef\filehook at default@InputIfFileExists#1#2{%
+\DeclareRobustCommand\filehook at default@InputIfFileExists[2]{%
   \IfFileExists{#1}%
     {\expandafter\filehook at swap
      \expandafter{\@filef at und}%
@@ -1149,12 +1204,16 @@
     }%
 }
 %    \end{macrocode}
+% Make sure definition is global:
+%    \begin{macrocode}
+\filehook at glet{filehook at default@InputIfFileExists}{filehook at default@InputIfFileExists}%
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\filehook@@default at InputIfFileExists}
 %    \begin{macrocode}
-\long\gdef\filehook@@default at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
+\DeclareRobustCommand\filehook@@default at InputIfFileExists[2]{%
+  \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
   \IfFileExists{#1}%
     {\expandafter\filehook at swap
      \expandafter{\@filef at und}%
@@ -1165,99 +1224,20 @@
     }%
 }
 %    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\scrlfile at InputIfFileExists}
+% Make sure definition is global:
 %    \begin{macrocode}
-\long\def\scrlfile at InputIfFileExists#1#2{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \@@input \@filef at und
-      \scr at load@hook{after}{#1}%
-    }}%
-}
+\filehook at glet{filehook@@default at InputIfFileExists}{filehook@@default at InputIfFileExists}%
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\filehook at scrlfile@InputIfFileExists}
-%    \begin{macrocode}
-\long\def\filehook at scrlfile@InputIfFileExists#1#2{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \expandafter\filehook at swap
-      \expandafter{\@filef at und}%
-      {\scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \filehook at every@atbegin{#1}%
-      \filehook at atbegin{#1}%
-      \@@input}%
-      \filehook at atend{#1}%
-      \filehook at every@atend{#1}%
-      \scr at load@hook{after}{#1}%
-    }}%
-}
-%    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\filehook@@scrlfile at InputIfFileExists}
-%    \begin{macrocode}
-\long\def\filehook@@scrlfile at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \expandafter\filehook at swap
-      \expandafter{\@filef at und}%
-      {\scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \filehook at atbegin{#1}%
-      \@@input}%
-      \filehook at atend{#1}%
-      \scr at load@hook{after}{#1}%
-    }}%
-}
-%    \end{macrocode}
-% \end{macro}
-%
-%
 % \begin{macro}{\InputIfFileExists}
 % First we test for the |scrlfile| package. The test macro adds the necessary patches if so.
 % In order to also support it when it is loaded afterwards the two hooks below are used to revert the definition
 % before the package and patch it afterwards.
 %    \begin{macrocode}
-\AtBeginOfPackageFile*{scrlfile}{%
-   \let\InputIfFileExists\latex at InputIfFileExists
+\AtBeginOfPackageFile{scrlfile}{%
+   \filehook at glet{InputIfFileExists}{latex at InputIfFileExists}%
 }%
 \AtEndOfPackageFile*{scrlfile}{%
    \RequirePackage{filehook-scrlfile}%
@@ -1268,7 +1248,7 @@
 \AtBeginOfPackageFile*{fink}{%
    \RequirePackage{kvoptions}%
    \begingroup
-   \let\InputIfFileExists\latex at InputIfFileExists
+   \filehook at let{InputIfFileExists}{latex at InputIfFileExists}%
 }%
 \AtEndOfPackageFile*{fink}{%
    \edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk at mainext,maindir=\fnk at maindir}{currfile}}%
@@ -1281,9 +1261,8 @@
 % exact same position. Please note that the case when |memoir| is used together with |scrlfile| is not explicitly covered.
 % In this case the |scrlfile| package will overwrite |memoir|s definition.
 %    \begin{macrocode}
-\AtBeginOfClassFile*{memoir}{%
-  \let\filehook@@InputIfFileExists\latex at InputIfFileExists
-  \let\InputIfFileExists\latex at InputIfFileExists
+\AtBeginOfClassFile{memoir}{%
+  \filehook at let{InputIfFileExists}{latex at InputIfFileExists}%
   \let\@iinput\filehook at orig@@iinput
 }%
 \AtEndOfClassFile*{memoir}{%
@@ -1295,45 +1274,28 @@
 % 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}
-\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
-    \iffilehook at newfmt
-        \expandafter\let\csname InputIfFileExists\space\endcsname\filehook at InputIfFileExists
-    \else
-        \let\InputIfFileExists\filehook at InputIfFileExists
-    \fi
-    \iffilehook at force
-      \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                                The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
-    \fi
-\else
-    \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                            Use the 'force' option of 'filehook' to overwrite it.}{}%
-\fi
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {}% already set up
+  {%
+    \filehook at cmp{InputIfFileExists}{latex at InputIfFileExists}%
+      {%
+        \filehook at let{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+        \filehook at let{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+        \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
+      }%
+      {%
+        \iffilehook at force
+          \filehook at let{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+          \filehook at let{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+          \filehook at 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
+      }%
+  }%
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1341,10 +1303,10 @@
 \AtBeginDocument{%
     % 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
+    \filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}{}{%
         \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J%
-                                  Certain file hooks might now be dysfunctional!}
-    \fi
+                                  Certain file hooks might now be dysfunctional!}%
+    }%
 }
 %    \end{macrocode}
 %
@@ -1358,7 +1320,7 @@
 %    \begin{macrocode}
 %<!COPYRIGHT>
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{filehook-memoir}[2011/01/03 v0.1 filehook patch for memoir class]
+\ProvidesPackage{filehook-memoir}[2020/02/02 v0.2 filehook patch for memoir class]
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -1367,8 +1329,21 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\memoir at InputIfFileExists}
+% The definition taken from memoir.cls. Copyright see there.
 %    \begin{macrocode}
-\long\def\memoir at InputIfFileExists#1#2{%
+\ifcsname InputIfFileExists\space\endcsname
+  \DeclareRobustCommand \memoir at InputIfFileExists[2]{%
+    \IfFileExists{#1}%
+    {%
+      \expandafter\@swaptwoargs\expandafter
+      {\@filef at und\m at matendf{#1}\killm at matf{#1}}{%
+        #2\@addtofilelist{#1}\m at matbeginf{#1}\@@input%
+      }%
+    }%
+  }
+\else
+  % Old definition
+\renewcommand{\memoir at InputIfFileExists}[2]{%
   \IfFileExists{#1}%
     {#2\@addtofilelist{#1}\m at matbeginf{#1}%
      \@@input \@filef at und
@@ -1375,27 +1350,32 @@
      \m at matendf{#1}%
      \killm at matf{#1}}%
 }
+\fi
 %    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
-\ifcase
-    \ifx\InputIfFileExists\latex at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\memoir at InputIfFileExists 0\else
-     1%
-    \fi\fi
-\relax
-  \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-  \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-  \global\let\InputIfFileExists\filehook at InputIfFileExists
+\@tempswafalse
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {\@tempswatrue}%
+  {%
+    \filehook at cmp{InputIfFileExists}{memoir at InputIfFileExists}%
+      {\@tempswatrue}%
+      {}%
+  }%
+
+\if at tempswa
+  \filehook at glet{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+  \filehook at glet{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+  \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
   \filehook at appendwarg\filehook at atbegin{\m at matbeginf{#1}}%
   \filehook at prefixwarg\filehook at atend{\m at matendf{#1}\killm at matf{#1}}%
   \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks}
 \else
   \iffilehook at force
-    \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-    \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \global\let\InputIfFileExists\filehook at InputIfFileExists
+    \filehook at glet{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+    \filehook at glet{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+    \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
     \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J%
                               The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
   \else
@@ -1455,7 +1435,7 @@
 %    \begin{macrocode}
 %<!COPYRIGHT>
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package]
+\ProvidesPackage{filehook-scrlfile}[2020/02/02 v0.2 filehook patch for scrlfile package]
 \RequirePackage{filehook}
 \begingroup
 %    \end{macrocode}
@@ -1462,7 +1442,10 @@
 %
 % \begin{macro}{\scrlfile at InputIfFileExists}
 %    \begin{macrocode}
-\long\def\scrlfile at InputIfFileExists#1#2{%
+\expandafter\def\expandafter\sclrfile at InputIfFileExists\expandafter{%
+  \expandafter\protect\csname InputIfFileExists\space\endcsname
+}
+\expandafter\long\expandafter\def\csname scrlfile at InputIfFileExists\space\endcsname#1#2{%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -1472,21 +1455,19 @@
   \fi
   {%
     \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
+#1- at alias\endcsname}{#2}%
   }%
   {\IfFileExists{#1}{%
-      \scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \@@input \@filef at und
-      \scr at load@hook{after}{#1}%
-    }}%
+    \expandafter\scr at input@withhook\expandafter{\@filef at und}{#1}{#2}}%
+  }%
 }
 %    \end{macrocode}
 % \end{macro}
 %
+%
 % \begin{macro}{\filehook at scrlfile@InputIfFileExists}
 %    \begin{macrocode}
-\long\def\filehook at scrlfile@InputIfFileExists#1#2{%
+\DeclareRobustCommand\filehook at scrlfile@InputIfFileExists[2]{%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -1511,13 +1492,15 @@
       \scr at load@hook{after}{#1}%
     }}%
 }
+\filehook at glet{filehook at scrlfile@InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
 %    \end{macrocode}
 % \end{macro}
 %
+%
 % \begin{macro}{\filehook@@scrlfile at InputIfFileExists}
 %    \begin{macrocode}
-\long\def\filehook@@scrlfile at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
+\DeclareRobustCommand\filehook@@scrlfile at InputIfFileExists[2]{%
+  \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -1540,6 +1523,7 @@
       \scr at load@hook{after}{#1}%
     }}%
 }
+\filehook at glet{filehook@@scrlfile at InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1548,21 +1532,25 @@
 % not after the |#2\@addtofilelist{#1}| code. Otherwise the |filehook|s could simply be added to these hooks.
 % Note that this will stop working if |scrlfile| ever changes its definition of the \Macro\InputIfFileExists macro.
 %    \begin{macrocode}
-\ifcase
-    \ifx\InputIfFileExists\latex at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\scrlfile at InputIfFileExists 0\else
-     1%
-    \fi\fi
-\relax
-  \global\let\filehook at InputIfFileExists\filehook at scrlfile@InputIfFileExists
-  \global\let\filehook@@InputIfFileExists\filehook@@scrlfile at InputIfFileExists
-  \global\let\InputIfFileExists\filehook at InputIfFileExists
+\@tempswafalse
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {\@tempswatrue}%
+  {%
+    \filehook at cmp{InputIfFileExists}{scrlfile at InputIfFileExists}%
+      {\@tempswatrue}%
+      {}%
+  }%
+
+\if at tempswa
+  \filehook at glet{filehook at InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
+  \filehook at glet{filehook@@InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
+  \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
   \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}%
 \else
   \iffilehook at force
-    \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-    \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \global\let\InputIfFileExists\filehook at InputIfFileExists
+    \filehook at glet{filehook at InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
+    \filehook at glet{filehook@@InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
+    \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
     \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
                               The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
   \else

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -18,10 +18,22 @@
 %% and pgf-filehook.sty
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{filehook-memoir}[2011/01/03 v0.1 filehook patch for memoir class]
+\ProvidesPackage{filehook-memoir}[2020/02/02 v0.2 filehook patch for memoir class]
 \RequirePackage{filehook}
 \begingroup
-\long\def\memoir at InputIfFileExists#1#2{%
+\ifcsname InputIfFileExists\space\endcsname
+  \DeclareRobustCommand \memoir at InputIfFileExists[2]{%
+    \IfFileExists{#1}%
+    {%
+      \expandafter\@swaptwoargs\expandafter
+      {\@filef at und\m at matendf{#1}\killm at matf{#1}}{%
+        #2\@addtofilelist{#1}\m at matbeginf{#1}\@@input%
+      }%
+    }%
+  }
+\else
+  % Old definition
+\renewcommand{\memoir at InputIfFileExists}[2]{%
   \IfFileExists{#1}%
     {#2\@addtofilelist{#1}\m at matbeginf{#1}%
      \@@input \@filef at und
@@ -28,23 +40,28 @@
      \m at matendf{#1}%
      \killm at matf{#1}}%
 }
-\ifcase
-    \ifx\InputIfFileExists\latex at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\memoir at InputIfFileExists 0\else
-     1%
-    \fi\fi
-\relax
-  \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-  \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-  \global\let\InputIfFileExists\filehook at InputIfFileExists
+\fi
+\@tempswafalse
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {\@tempswatrue}%
+  {%
+    \filehook at cmp{InputIfFileExists}{memoir at InputIfFileExists}%
+      {\@tempswatrue}%
+      {}%
+  }%
+
+\if at tempswa
+  \filehook at glet{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+  \filehook at glet{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+  \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
   \filehook at appendwarg\filehook at atbegin{\m at matbeginf{#1}}%
   \filehook at prefixwarg\filehook at atend{\m at matendf{#1}\killm at matf{#1}}%
   \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks}
 \else
   \iffilehook at force
-    \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-    \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \global\let\InputIfFileExists\filehook at InputIfFileExists
+    \filehook at glet{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+    \filehook at glet{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+    \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
     \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J%
                               The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
   \else

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -18,10 +18,13 @@
 %% and pgf-filehook.sty
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package]
+\ProvidesPackage{filehook-scrlfile}[2020/02/02 v0.2 filehook patch for scrlfile package]
 \RequirePackage{filehook}
 \begingroup
-\long\def\scrlfile at InputIfFileExists#1#2{%
+\expandafter\def\expandafter\sclrfile at InputIfFileExists\expandafter{%
+  \expandafter\protect\csname InputIfFileExists\space\endcsname
+}
+\expandafter\long\expandafter\def\csname scrlfile at InputIfFileExists\space\endcsname#1#2{%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -31,16 +34,13 @@
   \fi
   {%
     \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
+#1- at alias\endcsname}{#2}%
   }%
   {\IfFileExists{#1}{%
-      \scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \@@input \@filef at und
-      \scr at load@hook{after}{#1}%
-    }}%
+    \expandafter\scr at input@withhook\expandafter{\@filef at und}{#1}{#2}}%
+  }%
 }
-\long\def\filehook at scrlfile@InputIfFileExists#1#2{%
+\DeclareRobustCommand\filehook at scrlfile@InputIfFileExists[2]{%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -65,8 +65,9 @@
       \scr at load@hook{after}{#1}%
     }}%
 }
-\long\def\filehook@@scrlfile at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
+\filehook at glet{filehook at scrlfile@InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
+\DeclareRobustCommand\filehook@@scrlfile at InputIfFileExists[2]{%
+  \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
   \begingroup\expandafter\expandafter\expandafter\endgroup
   \expandafter\ifx\csname #1- at alias\endcsname\relax
     \expandafter\@secondoftwo
@@ -89,21 +90,26 @@
       \scr at load@hook{after}{#1}%
     }}%
 }
-\ifcase
-    \ifx\InputIfFileExists\latex at InputIfFileExists 0\else
-    \ifx\InputIfFileExists\scrlfile at InputIfFileExists 0\else
-     1%
-    \fi\fi
-\relax
-  \global\let\filehook at InputIfFileExists\filehook at scrlfile@InputIfFileExists
-  \global\let\filehook@@InputIfFileExists\filehook@@scrlfile at InputIfFileExists
-  \global\let\InputIfFileExists\filehook at InputIfFileExists
+\filehook at glet{filehook@@scrlfile at InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
+\@tempswafalse
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {\@tempswatrue}%
+  {%
+    \filehook at cmp{InputIfFileExists}{scrlfile at InputIfFileExists}%
+      {\@tempswatrue}%
+      {}%
+  }%
+
+\if at tempswa
+  \filehook at glet{filehook at InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
+  \filehook at glet{filehook@@InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
+  \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
   \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}%
 \else
   \iffilehook at force
-    \global\let\filehook at InputIfFileExists\filehook at default@InputIfFileExists
-    \global\let\filehook@@InputIfFileExists\filehook@@default at InputIfFileExists
-    \global\let\InputIfFileExists\filehook at InputIfFileExists
+    \filehook at glet{filehook at InputIfFileExists}{filehook at scrlfile@InputIfFileExists}%
+    \filehook at glet{filehook@@InputIfFileExists}{filehook@@scrlfile at InputIfFileExists}%
+    \filehook at glet{InputIfFileExists}{filehook at InputIfFileExists}%
     \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
                               The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
   \else

Modified: trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty	2020-02-03 22:31:10 UTC (rev 53654)
+++ trunk/Master/texmf-dist/tex/latex/filehook/filehook.sty	2020-02-03 22:31:24 UTC (rev 53655)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2019 by Martin Scharrer <martin at scharrer-online.de>
+%% Copyright (C) 2011-2020 by Martin Scharrer <martin at scharrer-online.de>
 %% ----------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -19,12 +19,45 @@
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{filehook}[%
-    2019/10/03
-    v0.6
+    2020/02/03
+    v0.7
     Hooks for input files]
 \newif\iffilehook at force
 \DeclareOption{force}{\filehook at forcetrue}
 \ProcessOptions\relax
+\newif\iffilehook at newfmt
+\@ifl at t@r\fmtversion{2019/10/01}{\filehook at newfmttrue}{\filehook at newfmtfalse}
+\def\filehook at let#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname
+  \else
+    \expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}%
+    \expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+  \fi
+}
+\def\filehook at glet#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\global\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname
+  \else
+    \expandafter\global\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}%
+    \expandafter\global\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+  \fi
+}
+\def\filehook at cmp#1#2{%
+  \expandafter\ifx\csname #2\space\endcsname\relax
+    \expandafter\ifx\csname #1\expandafter\endcsname\csname #2\endcsname
+      \expandafter\expandafter\expandafter\@firstoftwo
+    \else
+      \expandafter\expandafter\expandafter\@secondoftwo
+    \fi
+  \else
+    \expandafter\ifx\csname #1\space\expandafter\endcsname\csname #2\space\endcsname
+      \expandafter\expandafter\expandafter\@firstoftwo
+    \else
+      \expandafter\expandafter\expandafter\@secondoftwo
+    \fi
+  \fi
+}
 \begingroup
 \gdef\filehook at csuse#1{\ifcsname #1\endcsname\csname #1\expandafter\endcsname\fi}
 \expandafter\ifx\csname csuse\endcsname\relax
@@ -36,7 +69,7 @@
 \fi
 \endgroup
 \def\filehook at include@atbegin#1{%
-  \let\InputIfFileExists\filehook@@InputIfFileExists
+  \filehook at let{InputIfFileExists}{filehook@@InputIfFileExists}%
   \filehook at csuse{\filehook at include@atbegin@#1}%
   \filehook at include@@atbegin
 }
@@ -52,7 +85,7 @@
 }
 \def\filehook at include@@after{}
 \def\filehook at input@atbegin#1{%
-  \let\InputIfFileExists\filehook@@InputIfFileExists
+  \filehook at let{InputIfFileExists}{filehook@@InputIfFileExists}%
   \filehook at csuse{\filehook at input@atbegin@\filehook at ensureext{#1}}%
   \filehook at input@@atbegin
 }
@@ -245,10 +278,11 @@
     \expandafter\filehook@@ensuretex#1\empty.tex\empty\empty
 }
 \def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex}
-\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]{%
+\expandafter\def\expandafter\latex at InputIfFileExists\expandafter{%
+  \expandafter\protect\csname InputIfFileExists\space\endcsname
+}
+\expandafter\long\expandafter\def\csname latex at InputIfFileExists\space\endcsname#1#2{%
   \IfFileExists{#1}%
     {%
   \expandafter\@swaptwoargs\expandafter
@@ -261,7 +295,7 @@
     }%
 }
 \fi
-\long\gdef\filehook at default@InputIfFileExists#1#2{%
+\DeclareRobustCommand\filehook at default@InputIfFileExists[2]{%
   \IfFileExists{#1}%
     {\expandafter\filehook at swap
      \expandafter{\@filef at und}%
@@ -273,8 +307,9 @@
      \filehook at every@atend{#1}%
     }%
 }
-\long\gdef\filehook@@default at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
+\filehook at glet{filehook at default@InputIfFileExists}{filehook at default@InputIfFileExists}%
+\DeclareRobustCommand\filehook@@default at InputIfFileExists[2]{%
+  \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
   \IfFileExists{#1}%
     {\expandafter\filehook at swap
      \expandafter{\@filef at und}%
@@ -284,76 +319,9 @@
      \filehook at atend{#1}%
     }%
 }
-\long\def\scrlfile at InputIfFileExists#1#2{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \@@input \@filef at und
-      \scr at load@hook{after}{#1}%
-    }}%
-}
-\long\def\filehook at scrlfile@InputIfFileExists#1#2{%
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \expandafter\filehook at swap
-      \expandafter{\@filef at und}%
-      {\scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \filehook at every@atbegin{#1}%
-      \filehook at atbegin{#1}%
-      \@@input}%
-      \filehook at atend{#1}%
-      \filehook at every@atend{#1}%
-      \scr at load@hook{after}{#1}%
-    }}%
-}
-\long\def\filehook@@scrlfile at InputIfFileExists#1#2{%
-  \let\InputIfFileExists\filehook at InputIfFileExists
-  \begingroup\expandafter\expandafter\expandafter\endgroup
-  \expandafter\ifx\csname #1- at alias\endcsname\relax
-    \expandafter\@secondoftwo
-  \else
-    \scr at replacefile@msg{\csname #1- at alias\endcsname}{#1}%
-    \expandafter\@firstoftwo
-  \fi
-  {%
-    \expandafter\InputIfFileExists\expandafter{\csname
-      #1- at alias\endcsname}{#2}%
-  }%
-  {\IfFileExists{#1}{%
-      \expandafter\filehook at swap
-      \expandafter{\@filef at und}%
-      {\scr at load@hook{before}{#1}%
-      #2\@addtofilelist{#1}%
-      \filehook at atbegin{#1}%
-      \@@input}%
-      \filehook at atend{#1}%
-      \scr at load@hook{after}{#1}%
-    }}%
-}
-\AtBeginOfPackageFile*{scrlfile}{%
-   \let\InputIfFileExists\latex at InputIfFileExists
+\filehook at glet{filehook@@default at InputIfFileExists}{filehook@@default at InputIfFileExists}%
+\AtBeginOfPackageFile{scrlfile}{%
+   \filehook at glet{InputIfFileExists}{latex at InputIfFileExists}%
 }%
 \AtEndOfPackageFile*{scrlfile}{%
    \RequirePackage{filehook-scrlfile}%
@@ -361,7 +329,7 @@
 \AtBeginOfPackageFile*{fink}{%
    \RequirePackage{kvoptions}%
    \begingroup
-   \let\InputIfFileExists\latex at InputIfFileExists
+   \filehook at let{InputIfFileExists}{latex at InputIfFileExists}%
 }%
 \AtEndOfPackageFile*{fink}{%
    \edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk at mainext,maindir=\fnk at maindir}{currfile}}%
@@ -368,9 +336,8 @@
    \expandafter\endgroup\@tempa
    \RequirePackage{filehook-fink}%
 }%
-\AtBeginOfClassFile*{memoir}{%
-  \let\filehook@@InputIfFileExists\latex at InputIfFileExists
-  \let\InputIfFileExists\latex at InputIfFileExists
+\AtBeginOfClassFile{memoir}{%
+  \filehook at let{InputIfFileExists}{latex at InputIfFileExists}%
   \let\@iinput\filehook at orig@@iinput
 }%
 \AtEndOfClassFile*{memoir}{%
@@ -377,51 +344,35 @@
   \let\@iinput\filehook@@iinput
   \RequirePackage{filehook-memoir}%
 }%
-\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
-    \iffilehook at newfmt
-        \expandafter\let\csname InputIfFileExists\space\endcsname\filehook at InputIfFileExists
-    \else
-        \let\InputIfFileExists\filehook at InputIfFileExists
-    \fi
-    \iffilehook at force
-      \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                                The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
-    \fi
-\else
-    \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
-                            Use the 'force' option of 'filehook' to overwrite it.}{}%
-\fi
+\filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}%
+  {}% already set up
+  {%
+    \filehook at cmp{InputIfFileExists}{latex at InputIfFileExists}%
+      {%
+        \filehook at let{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+        \filehook at let{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+        \filehook at let{InputIfFileExists}{filehook at InputIfFileExists}%
+      }%
+      {%
+        \iffilehook at force
+          \filehook at let{filehook at InputIfFileExists}{filehook at default@InputIfFileExists}%
+          \filehook at let{filehook@@InputIfFileExists}{filehook@@default at InputIfFileExists}%
+          \filehook at 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
+      }%
+  }%
 \AtBeginDocument{%
     % 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
+    \filehook at cmp{InputIfFileExists}{filehook at InputIfFileExists}{}{%
         \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J%
-                                  Certain file hooks might now be dysfunctional!}
-    \fi
+                                  Certain file hooks might now be dysfunctional!}%
+    }%
 }
 \endinput
 %%



More information about the tex-live-commits mailing list.