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 --- .../texmf-dist/source/latex/filehook/filehook.dtx | 94 ++++++++++++---------- 1 file changed, 51 insertions(+), 43 deletions(-) (limited to 'Master/texmf-dist/source/latex/filehook') diff --git a/Master/texmf-dist/source/latex/filehook/filehook.dtx b/Master/texmf-dist/source/latex/filehook/filehook.dtx index 3db7301e64f..efaeb3d5a87 100644 --- a/Master/texmf-dist/source/latex/filehook/filehook.dtx +++ b/Master/texmf-dist/source/latex/filehook/filehook.dtx @@ -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 @@ % % \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,39 +1108,28 @@ % 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@InputIfFileExists} -% Original standard \LaTeX\ definition of \Macro\InputIfFileExists. % \begin{macrocode} -\long\def\oldlatex@InputIfFileExists#1#2{% - \IfFileExists{#1}% - {#2\@addtofilelist{#1}% - \@@input\@filef@und - }% -} +\newif\iffilehook@newfmt +\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} % \end{macrocode} -% \end{macro} -% % % \begin{macro}{\latex@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@InputIfFileExists#1#2{% +\iffilehook@newfmt +\DeclareRobustCommand \latex@InputIfFileExists[2]{% \IfFileExists{#1}% {% \expandafter\@swaptwoargs\expandafter {\@filef@und}{#2\@addtofilelist{#1}\@@input}}} -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\latex@InputIfFileExists} -% Standard \`LaTeX\ definition of \Macro\InputIfFileExists starting from LaTeX Kernal 2019/02/07 v1.1n. -% \begin{macrocode} -\@ifundefined{@swaptwoargs}{% - \let\latex@InputIfFileExists\oldlatex@InputIfFileExists -}{% - \let\latex@InputIfFileExists\newlatex@InputIfFileExists -}% +\else +\long\def\latex@InputIfFileExists#1#2{% + \IfFileExists{#1}% + {#2\@addtofilelist{#1}% + \@@input\@filef@und + }% +} +\fi % \end{macrocode} % \end{macro} % @@ -1300,40 +1291,57 @@ \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@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 % \end{macrocode} % \end{macro} % % \begin{macrocode} \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