From c855cf241a4beeea9508caf359f9090c6419cf8f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 3 Oct 2019 21:09:13 +0000 Subject: filehook (3oct19) git-svn-id: svn://tug.org/texlive/trunk@52272 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/filehook/filehook.sty | 73 ++++++++++++++--------- 1 file changed, 45 insertions(+), 28 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/filehook/filehook.sty b/Master/texmf-dist/tex/latex/filehook/filehook.sty index cf29c75c56b..5f03b9827e9 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook.sty @@ -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@force \DeclareOption{force}{\filehook@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@InputIfFileExists#1#2{% +\newif\iffilehook@newfmt +\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} +\iffilehook@newfmt +\DeclareRobustCommand \latex@InputIfFileExists[2]{% + \IfFileExists{#1}% + {% + \expandafter\@swaptwoargs\expandafter + {\@filef@und}{#2\@addtofilelist{#1}\@@input}}} +\else +\long\def\latex@InputIfFileExists#1#2{% \IfFileExists{#1}% {#2\@addtofilelist{#1}% \@@input\@filef@und }% } -\long\def\newlatex@InputIfFileExists#1#2{% - \IfFileExists{#1}% - {% - \expandafter\@swaptwoargs\expandafter - {\@filef@und}{#2\@addtofilelist{#1}\@@input}}} -\@ifundefined{@swaptwoargs}{% - \let\latex@InputIfFileExists\oldlatex@InputIfFileExists -}{% - \let\latex@InputIfFileExists\newlatex@InputIfFileExists -}% +\fi \long\gdef\filehook@default@InputIfFileExists#1#2{% \IfFileExists{#1}% {\expandafter\filehook@swap @@ -377,31 +377,48 @@ \let\@iinput\filehook@@iinput \RequirePackage{filehook-memoir}% }% -\ifcase - \ifx\InputIfFileExists\filehook@InputIfFileExists 0\else - \ifx\InputIfFileExists\newlatex@InputIfFileExists 1\else - \ifx\InputIfFileExists\oldlatex@InputIfFileExists 1\else - 9% - \fi\fi\fi +\def\@tempa{9}% +\ifx\InputIfFileExists\filehook@InputIfFileExists + \def\@tempa{0}% +\else + \iffilehook@force + \def\@tempa{1}% + \else + \iffilehook@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@InputIfFileExists\space\endcsname + \def\@tempa{1}% + \fi + \fi + \else\ifx\InputIfFileExists\latex@InputIfFileExists + \def\@tempa{1}% + \fi\fi + \fi +\fi +\ifcase\@tempa \relax% 0 \or% 1 \let\filehook@InputIfFileExists\filehook@default@InputIfFileExists \let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \let\InputIfFileExists\filehook@InputIfFileExists -\else + \iffilehook@newfmt + \expandafter\let\csname InputIfFileExists\space\endcsname\filehook@InputIfFileExists + \else + \let\InputIfFileExists\filehook@InputIfFileExists + \fi \iffilehook@force - \let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \let\InputIfFileExists\filehook@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@InputIfFileExists\else + % Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists, + % for the old format to \InputIfFileExists directly. + \expandafter\ifx\csname InputIfFileExists\iffilehook@newfmt\space\fi\endcsname\filehook@InputIfFileExists\else \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J% Certain file hooks might now be dysfunctional!} \fi -- cgit v1.2.3