From 51edd003e4de8bee6f4fe40b27fd4d1c9eef78ac Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 10 Dec 2010 00:12:33 +0000
Subject: filehook 0.2 (10dec10)

git-svn-id: svn://tug.org/texlive/trunk@20701 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/filehook/filehook.sty | 97 +++++++++++++++++++----
 1 file changed, 81 insertions(+), 16 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/filehook/filehook.sty')

diff --git a/Master/texmf-dist/tex/latex/filehook/filehook.sty b/Master/texmf-dist/tex/latex/filehook/filehook.sty
index 38d196ad77d..c7a632929e5 100644
--- a/Master/texmf-dist/tex/latex/filehook/filehook.sty
+++ b/Master/texmf-dist/tex/latex/filehook/filehook.sty
@@ -18,10 +18,10 @@
 %% This work consists of the files filehook.dtx, filehook.ins
 %% and the derived file filehook.sty.
 %%
-%% $Id: standalone.dtx 1803 2010-04-03 13:59:44Z martin $
+%% $Id: filehook.dtx 1905 2010-12-08 18:57:34Z martin $
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{filehook}
-    [2010/04/08 v0.1 Hooks for input files]
+    [2010/12/08 v0.2 Hooks for input files]
 \let\filehook@orig@@input@\@input@
 \let\filehook@orig@@iinput\@iinput
 \def\@input@#1{%
@@ -40,22 +40,84 @@
   \filehook@orig@@iinput{#1}%
   \filehook@input@atend{#1}%
 }
-\ifcase0%
-  \ifx\fink@input\@undefined 1\else
-  \ifx\fink@input\relax 1\fi\fi
-\relax
-\long\def\InputIfFileExists#1#2{%
-  \IfFileExists{#1}{%
-    #2\@addtofilelist{#1}%
-    \fink@prepare{#1}%
-    \filehook@atbegin{#1}%
-    \expandafter\fink@input%
-    \expandafter\fink@restore\expandafter{\finkpath}%
-    \filehook@atend{#1}%
-  }%
+\begingroup
+
+\long\def\latex@InputIfFileExists#1#2{%
+  \IfFileExists{#1}%
+    {#2\@addtofilelist{#1}%
+     \@@input\@filef@und
+    }%
 }
+\long\def\memoir@InputIfFileExists#1#2{%
+  \IfFileExists{#1}%
+    {#2\@addtofilelist{#1}\m@matbeginf{#1}%
+     \@@input \@filef@und
+     \m@matendf{#1}%
+     \killm@matf{#1}}%
+}
+\long\def\scrlfile@InputIfFileExists#1#2{%
+  \begingroup\expandafter\expandafter\expandafter\endgroup
+  \expandafter\ifx\csname #1-@alias\endcsname\relax
+    \expandafter\@secondoftwo
+  \else
+    \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+    \expandafter\@firstoftwo
+  \fi
+  {%
+    \expandafter\InputIfFileExists\expandafter{\csname
+      #1-@alias\endcsname}{#2}%
+  }%
+  {\IfFileExists{#1}{%
+      \scr@load@hook{before}{#1}%
+      #2\@addtofilelist{#1}%
+      \@@input \@filef@und
+      \scr@load@hook{after}{#1}%
+    }}%
+}
+\ifx\InputIfFileExists\scrlfile@InputIfFileExists
+
+\long\gdef\InputIfFileExists#1#2{%
+  \begingroup\expandafter\expandafter\expandafter\endgroup
+  \expandafter\ifx\csname #1-@alias\endcsname\relax
+    \expandafter\@secondoftwo
+  \else
+    \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+    \expandafter\@firstoftwo
+  \fi
+  {%
+    \expandafter\InputIfFileExists\expandafter{\csname
+      #1-@alias\endcsname}{#2}%
+  }%
+  {\IfFileExists{#1}{%
+      \scr@load@hook{before}{#1}%
+      #2\@addtofilelist{#1}%
+      \filehook@atbegin{#1}%
+      \@@input \@filef@und
+      \filehook@atend{#1}%
+      \scr@load@hook{after}{#1}%
+    }}%
+}
+
+\PackageInfo{filehook}{Package 'scrlfile' detected and compensated for.}
+
+\else
+
+\ifx\InputIfFileExists\memoir@InputIfFileExists
+  \AtEndOfPackage{%
+    \AtBeginOfFiles{\m@matbeginf{#1}}%
+    \AtEndOfFiles{\m@matendf{#1}\killm@matf{#1}}%
+  }
+  \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the 'At...OfFiles' hooks.}
 \else
-\long\def\InputIfFileExists#1#2{%
+\ifx\InputIfFileExists\latex@InputIfFileExists
+\else
+  \PackageWarning{filehook}
+    {Changed definition of \string\InputIfFileExists\space detected!^^J%
+    This macro will be redefined and this might break other packages or code.}%
+\fi
+\fi
+
+\long\gdef\InputIfFileExists#1#2{%
   \IfFileExists{#1}%
     {#2\@addtofilelist{#1}%
      \filehook@atbegin{#1}%
@@ -63,7 +125,10 @@
      \filehook@atend{#1}%
     }%
 }
+
 \fi
+
+\endgroup
 \def\filehook@include@atbegin#1{%
   \@nameuse{\filehook@include@atbegin@#1}%
 }
-- 
cgit v1.2.3

